Codebase list node-moment / upstream/2.10.6+dfsg
Imported Upstream version 2.10.6+dfsg Julien Puydt 8 years ago
433 changed file(s) with 115365 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 root = true
1
2 [*]
3 charset = utf-8
4 end_of_line = lf
5 insert_final_newline = true
6 trim_trailing_whitespace = true
7 indent_style = space
8
9 [*.{js,json}]
10 indent_size = 4
11
12 [*.{yml}]
13 indent_size = 2
14
15 [*.md]
16 trim_trailing_whitespace = false
0 node_modules/
1 .DS_Store
2 min/moment+customlangs.js
3 min/moment+customlangs.min.js
4 sauce_connect.log
5 .sauce-labs.creds
6 npm-debug.log
7 .build*
8 build
9 coverage
10 nyc_output
11 .nyc_output
12 .coveralls.yml
0 {
1 "requireCurlyBraces": [
2 "if",
3 "else",
4 "for",
5 "while",
6 "do",
7 "try",
8 "catch"
9 ],
10 "requireSpaceAfterKeywords": [
11 "if",
12 "else",
13 "for",
14 "while",
15 "do",
16 "switch",
17 "return",
18 "try",
19 "catch"
20 ],
21 "requireSpaceBeforeBlockStatements": true,
22 "requireParenthesesAroundIIFE": true,
23 "requireSpacesInConditionalExpression": true,
24 "requireSpacesInAnonymousFunctionExpression": {
25 "beforeOpeningRoundBrace": true,
26 "beforeOpeningCurlyBrace": true
27 },
28 "requireSpacesInNamedFunctionExpression": {
29 "beforeOpeningCurlyBrace": true
30 },
31 "disallowSpacesInNamedFunctionExpression": {
32 "beforeOpeningRoundBrace": true
33 },
34 "requireBlocksOnNewline": true,
35 "disallowPaddingNewlinesInBlocks": true,
36 "disallowEmptyBlocks": true,
37 "disallowSpacesInsideObjectBrackets": true,
38 "disallowSpacesInsideArrayBrackets": true,
39 "disallowSpacesInsideParentheses": true,
40 "requireCommaBeforeLineBreak": true,
41 "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
42 "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
43 "requireSpaceBeforeBinaryOperators": [
44 "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
45 "&=", "|=", "^=",
46
47 "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
48 "|", "^", "&&", "||", "===", "==", ">=",
49 "<=", "<", ">", "!=", "!=="
50 ],
51 "requireSpaceAfterBinaryOperators": true,
52 "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
53 "disallowKeywords": ["with"],
54 "disallowMultipleLineStrings": true,
55 "validateLineBreaks": "LF",
56 "validateIndentation": 4,
57 "disallowTrailingWhitespace": true,
58 "disallowTrailingComma": true,
59 "requireLineFeedAtFileEnd": true,
60 "requireCapitalizedConstructors": true,
61 "validateQuoteMarks": {
62 "mark": "'",
63 "escape": true
64 },
65 "esnext": true
66 }
0 {
1 "node" : true,
2 "browser" : true,
3 "boss" : false,
4 "curly" : true,
5 "debug" : false,
6 "devel" : false,
7 "eqeqeq" : true,
8 "eqnull" : true,
9 "esnext" : true,
10 "evil" : false,
11 "forin" : false,
12 "immed" : false,
13 "laxbreak" : false,
14 "newcap" : true,
15 "noarg" : true,
16 "noempty" : false,
17 "nonew" : false,
18 "onevar" : true,
19 "plusplus" : false,
20 "regexp" : false,
21 "undef" : true,
22 "sub" : true,
23 "strict" : false,
24 "white" : true,
25 "es3" : false,
26 "camelcase" : true,
27 "globals": {
28 "define": false
29 }
30 }
0 test
0 benchmarks
1 bower_components
2 meteor
3 min
4 node_modules
5 scripts
6 tasks
7 test
0 language: node_js
1 node_js:
2 - "0.10"
3 sudo: false
4
5 env:
6 global:
7 - secure: "M4STT2TOZxjzv3cZOgSVi0J4j6enrGjgE+p5YTNUw+S6Dg6FS5pTIPeafu1kGhfm7F0uk7xPVwGKYb+3uWNO9IhkKXz8jySMMQ2iKISHwECGNNuFNjSMD1vIjbIkLwV8TyPO/PurQg2s+WtYz+DoAZsDFKpdaRUtif64OjdQ3vQ="
8 - secure: "V+i7kHoGe7VXWGplPNqJz+aDtgDF9Dh9/guoaf2BPyXLvkFW6VgMjJyoNUW7JVsakrWzAz2ubb734vAPDt7BCcFQ2BqfatOmabdFogviCaXC6IqVaEkYS2eSP7MIUPIeWJgnTrDGzkFMDk4K7y5SiVJ8UmYwZxe+tJV7kbb0Yig="
9
10 before_script:
11 - npm install -g grunt-cli
12
13 script: grunt build:travis
14
15 git:
16 depth: 10
17
18 # TODO: Fix problem with coveralls.io not displaying autogenerated files
19 # after_success: npm run coveralls
0 Changelog
1 =========
2
3 ### 2.10.6
4
5 [#2515](https://github.com/moment/moment/pull/2515) Fix regression introduced
6 in `2.10.5` related to `moment.ISO_8601` parsing.
7
8 ### 2.10.5 [See full changelog](https://gist.github.com/ichernev/6ec13ac7efc396da44b2)
9
10 Important changes:
11 * [#2357](https://github.com/moment/moment/pull/2357) Improve unit bubbling for ISO dates
12 this fixes day to year conversions to work around end-of-year (~365 days). As
13 a side effect 365 days is 11 months and 30 days, and 366 days is one year.
14 * [#2438](https://github.com/moment/moment/pull/2438) Fix inconsistent moment.min and moment.max results
15 Return invalid result if any of the inputs is invalid
16 * [#2494](https://github.com/moment/moment/pull/2494) Fix two digit year parsing with YYYY format
17 This brings the benefits of YY to YYYY
18 * [#2368](https://github.com/moment/moment/pull/2368) perf: use faster form of copying dates, across the board improvement
19
20
21 ### 2.10.3 [See full changelog](https://gist.github.com/ichernev/f264b9bed5b00f8b1b7f)
22
23 * add `moment.fn.to` and `moment.fn.toNow` (similar to `from` and `fromNow`)
24 * new locales (Sinhalese (si), Montenegrin (me), Javanese (ja))
25 * performance improvements
26
27 ### 2.10.2
28
29 * fixed moment-with-locales in browser env caused by esperanto change
30
31 ### 2.10.1
32
33 * regression: Add moment.duration.fn back
34
35 ### 2.10.0
36
37 Ported code to es6 modules.
38
39 ### 2.9.0 [See full changelog](https://gist.github.com/ichernev/0c9a9b49951111a27ce7)
40
41 languages:
42 * [2104](https://github.com/moment/moment/issues/2104) Frisian (fy) language file with unit test
43 * [2097](https://github.com/moment/moment/issues/2097) add ar-tn locale
44
45 deprecations:
46 * [2074](https://github.com/moment/moment/issues/2074) Implement `moment.fn.utcOffset`, deprecate `momen.fn.zone`
47
48 features:
49 * [2088](https://github.com/moment/moment/issues/2088) add moment.fn.isBetween
50 * [2054](https://github.com/moment/moment/issues/2054) Call updateOffset when creating moment (needed for default timezone in
51 moment-timezone)
52 * [1893](https://github.com/moment/moment/issues/1893) Add moment.isDate method
53 * [1825](https://github.com/moment/moment/issues/1825) Implement toJSON function on Duration
54 * [1809](https://github.com/moment/moment/issues/1809) Allowing moment.set() to accept a hash of units
55 * [2128](https://github.com/moment/moment/issues/2128) Add firstDayOfWeek, firstDayOfYear locale getters
56 * [2131](https://github.com/moment/moment/issues/2131) Add quarter diff support
57
58 Some bugfixes and language improvements -- [full changelog](https://gist.github.com/ichernev/0c9a9b49951111a27ce7)
59
60 ### 2.8.4 [See full changelog](https://gist.github.com/ichernev/a4fcb0a46d74e4b9b996)
61
62 Features:
63
64 * [#2000](https://github.com/moment/moment/issues/2000) Add LTS localised format that includes seconds
65 * [#1960](https://github.com/moment/moment/issues/1960) added formatToken 'x' for unix offset in milliseconds #1938
66 * [#1965](https://github.com/moment/moment/issues/1965) Support 24:00:00.000 to mean next day, at midnight.
67 * [#2002](https://github.com/moment/moment/issues/2002) Accept 'date' key when creating moment with object
68 * [#2009](https://github.com/moment/moment/issues/2009) Use native toISOString when we can
69
70 Some bugfixes and language improvements -- [full changelog](https://gist.github.com/ichernev/a4fcb0a46d74e4b9b996)
71
72 ### 2.8.3
73
74 Bugfixes:
75
76 * [#1801](https://github.com/moment/moment/issues/1801) proper pluralization for Arabic
77 * [#1833](https://github.com/moment/moment/issues/1833) improve spm integration
78 * [#1871](https://github.com/moment/moment/issues/1871) fix zone bug caused by Firefox 24
79 * [#1882](https://github.com/moment/moment/issues/1882) Use hh:mm in Czech
80 * [#1883](https://github.com/moment/moment/issues/1883) Fix 2.8.0 regression in duration as conversions
81 * [#1890](https://github.com/moment/moment/issues/1890) Faster travis builds
82 * [#1892](https://github.com/moment/moment/issues/1892) Faster isBefore/After/Same
83 * [#1848](https://github.com/moment/moment/issues/1848) Fix flaky month diffs
84 * [#1895](https://github.com/moment/moment/issues/1895) Fix 2.8.0 regression in moment.utc with format array
85 * [#1896](https://github.com/moment/moment/issues/1896) Support setting invalid instance locale (noop)
86 * [#1897](https://github.com/moment/moment/issues/1897) Support moment([str]) in addition to moment([int])
87
88 ### 2.8.2
89
90 Minor bugfixes:
91
92 * [#1874](https://github.com/moment/moment/issues/1874) use `Object.prototype.hasOwnProperty`
93 instead of `obj.hasOwnProperty` (ie8 bug)
94 * [#1873](https://github.com/moment/moment/issues/1873) add `duration#toString()`
95 * [#1859](https://github.com/moment/moment/issues/1859) better month/weekday names in norwegian
96 * [#1812](https://github.com/moment/moment/issues/1812) meridiem parsing for greek
97 * [#1804](https://github.com/moment/moment/issues/1804) spanish del -> de
98 * [#1800](https://github.com/moment/moment/issues/1800) korean LT improvement
99
100 ### 2.8.1
101
102 * bugfix [#1813](https://github.com/moment/moment/issues/1813): fix moment().lang([key]) incompatibility
103
104 ### 2.8.0 [See changelog](https://gist.github.com/ichernev/ac3899324a5fa6c8c9b4)
105
106 * incompatible changes
107 * [#1761](https://github.com/moment/moment/issues/1761): moments created without a language are no longer following the global language, in case it changes. Only newly created moments take the global language by default. In case you're affected by this, wait, comment on [#1797](https://github.com/moment/moment/issues/1797) and wait for a proper reimplementation
108 * [#1642](https://github.com/moment/moment/issues/1642): 45 days is no longer "a month" according to humanize, cutoffs for month, and year have changed. Hopefully your code does not depend on a particular answer from humanize (which it shouldn't anyway)
109 * [#1784](https://github.com/moment/moment/issues/1784): if you use the human readable English datetime format in a weird way (like storing them in a database) that would break when the format changes you're at risk.
110
111 * deprecations (old behavior will be dropped in 3.0)
112 * [#1761](https://github.com/moment/moment/issues/1761) `lang` is renamed to `locale`, `langData` -> `localeData`. Also there is now `defineLocale` that should be used when creating new locales
113 * [#1763](https://github.com/moment/moment/issues/1763) `add(unit, value)` and `subtract(unit, value)` are now deprecated. Use `add(value, unit)` and `subtract(value, unit)` instead.
114 * [#1759](https://github.com/moment/moment/issues/1759) rename `duration.toIsoString` to `duration.toISOString`. The js standard library and moment's `toISOString` follow that convention.
115
116 * new locales
117 * [#1789](https://github.com/moment/moment/issues/1789) Tibetan (bo)
118 * [#1786](https://github.com/moment/moment/issues/1786) Africaans (af)
119 * [#1778](https://github.com/moment/moment/issues/1778) Burmese (my)
120 * [#1727](https://github.com/moment/moment/issues/1727) Belarusian (be)
121
122 * bugfixes, locale bugfixes, performance improvements, features
123
124 ### 2.7.0 [See changelog](https://gist.github.com/ichernev/b0a3d456d5a84c9901d7)
125
126 * new languages
127
128 * [#1678](https://github.com/moment/moment/issues/1678) Bengali (bn)
129 * [#1628](https://github.com/moment/moment/issues/1628) Azerbaijani (az)
130 * [#1633](https://github.com/moment/moment/issues/1633) Arabic, Saudi Arabia (ar-sa)
131 * [#1648](https://github.com/moment/moment/issues/1648) Austrian German (de-at)
132
133 * features
134
135 * [#1663](https://github.com/moment/moment/issues/1663) configurable relative time thresholds
136 * [#1554](https://github.com/moment/moment/issues/1554) support anchor time in moment.calendar
137 * [#1693](https://github.com/moment/moment/issues/1693) support moment.ISO_8601 as parsing format
138 * [#1637](https://github.com/moment/moment/issues/1637) add moment.min and moment.max and deprecate min/max instance methods
139 * [#1704](https://github.com/moment/moment/issues/1704) support string value in add/subtract
140 * [#1647](https://github.com/moment/moment/issues/1647) add spm support (package manager)
141
142 * bugfixes
143
144 ### 2.6.0 [See changelog](https://gist.github.com/ichernev/10544682)
145
146 * languages
147 * [#1529](https://github.com/moment/moment/issues/1529) Serbian-Cyrillic (sr-cyr)
148 * [#1544](https://github.com/moment/moment/issues/1544), [#1546](https://github.com/moment/moment/issues/1546) Khmer Cambodia (km)
149
150 * features
151 * [#1419](https://github.com/moment/moment/issues/1419), [#1468](https://github.com/moment/moment/issues/1468), [#1467](https://github.com/moment/moment/issues/1467), [#1546](https://github.com/moment/moment/issues/1546) better handling of timezone-d moments around DST
152 * [#1462](https://github.com/moment/moment/issues/1462) add weeksInYear and isoWeeksInYear
153 * [#1475](https://github.com/moment/moment/issues/1475) support ordinal parsing
154 * [#1499](https://github.com/moment/moment/issues/1499) composer support
155 * [#1577](https://github.com/moment/moment/issues/1577), [#1604](https://github.com/moment/moment/issues/1604) put Date parsing in moment.createFromInputFallback so it can be properly deprecated and controlled in the future
156 * [#1545](https://github.com/moment/moment/issues/1545) extract two-digit year parsing in moment.parseTwoDigitYear, so it can be overwritten
157 * [#1590](https://github.com/moment/moment/issues/1590) (see [#1574](https://github.com/moment/moment/issues/1574)) set AMD global before module definition to better support non AMD module dependencies used in AMD environment
158 * [#1589](https://github.com/moment/moment/issues/1589) remove global in Node.JS environment (was not working before, nobody complained, was scheduled for removal anyway)
159 * [#1586](https://github.com/moment/moment/issues/1586) support quarter setting and parsing
160
161 * 18 bugs fixed
162
163 ### 2.5.1
164
165 * languages
166 * [#1392](https://github.com/moment/moment/issues/1392) Armenian (hy-am)
167
168 * bugfixes
169 * [#1429](https://github.com/moment/moment/issues/1429) fixes [#1423](https://github.com/moment/moment/issues/1423) weird chrome-32 bug with js object creation
170 * [#1421](https://github.com/moment/moment/issues/1421) remove html entities from Welsh
171 * [#1418](https://github.com/moment/moment/issues/1418) fixes [#1401](https://github.com/moment/moment/issues/1401) improved non-padded tokens in strict matching
172 * [#1417](https://github.com/moment/moment/issues/1417) fixes [#1404](https://github.com/moment/moment/issues/1404) handle buggy moment object created by property cloning
173 * [#1398](https://github.com/moment/moment/issues/1398) fixes [#1397](https://github.com/moment/moment/issues/1397) fix Arabic-like week number parsing
174 * [#1396](https://github.com/moment/moment/issues/1396) add leftZeroFill(4) to GGGG and gggg formats
175 * [#1373](https://github.com/moment/moment/issues/1373) use lowercase for months and days in Catalan
176
177 * testing
178 * [#1374](https://github.com/moment/moment/issues/1374) run tests on multiple browser/os combos via SauceLabs and Travis
179
180 ### 2.5.0 [See changelog](https://gist.github.com/ichernev/8104451)
181
182 * New languages
183 * Luxemburish (lb) [1247](https://github.com/moment/moment/issues/1247)
184 * Serbian (rs) [1319](https://github.com/moment/moment/issues/1319)
185 * Tamil (ta) [1324](https://github.com/moment/moment/issues/1324)
186 * Macedonian (mk) [1337](https://github.com/moment/moment/issues/1337)
187
188 * Features
189 * [1311](https://github.com/moment/moment/issues/1311) Add quarter getter and format token `Q`
190 * [1303](https://github.com/moment/moment/issues/1303) strict parsing now respects number of digits per token (fix [1196](https://github.com/moment/moment/issues/1196))
191 * 0d30bb7 add jspm support
192 * [1347](https://github.com/moment/moment/issues/1347) improve zone parsing
193 * [1362](https://github.com/moment/moment/issues/1362) support merideam parsing in Korean
194
195 * 22 bugfixes
196
197 ### 2.4.0
198
199 * **Deprecate** globally exported moment, will be removed in next major
200 * New languages
201 * Farose (fo) [#1206](https://github.com/moment/moment/issues/1206)
202 * Tagalog/Filipino (tl-ph) [#1197](https://github.com/moment/moment/issues/1197)
203 * Welsh (cy) [#1215](https://github.com/moment/moment/issues/1215)
204 * Bugfixes
205 * properly handle Z at the end of iso RegExp [#1187](https://github.com/moment/moment/issues/1187)
206 * chinese meridian time improvements [#1076](https://github.com/moment/moment/issues/1076)
207 * fix language tests [#1177](https://github.com/moment/moment/issues/1177)
208 * remove some failing tests (that should have never existed :))
209 [#1185](https://github.com/moment/moment/issues/1185)
210 [#1183](https://github.com/moment/moment/issues/1183)
211 * handle russian noun cases in weird cases [#1195](https://github.com/moment/moment/issues/1195)
212
213 ### 2.3.1
214
215 Removed a trailing comma [1169] and fixed a bug with `months`, `weekdays` getters [#1171](https://github.com/moment/moment/issues/1171).
216
217 ### 2.3.0 [See changelog](https://gist.github.com/ichernev/6864354)
218
219 Changed isValid, added strict parsing.
220 Week tokens parsing.
221
222 ### 2.2.1
223
224 Fixed bug in string prototype test.
225 Updated authors and contributors.
226
227 ### 2.2.0 [See changelog](https://gist.github.com/ichernev/00f837a9baf46a3565e4)
228
229 Added bower support.
230
231 Language files now use UMD.
232
233 Creating moment defaults to current date/month/year.
234
235 Added a bundle of moment and all language files.
236
237 ### 2.1.0 [See changelog](https://gist.github.com/timrwood/b8c2d90d528eddb53ab5)
238
239 Added better week support.
240
241 Added ability to set offset with `moment#zone`.
242
243 Added ability to set month or weekday from a string.
244
245 Added `moment#min` and `moment#max`
246
247 ### 2.0.0 [See changelog](https://gist.github.com/timrwood/e72f2eef320ed9e37c51)
248
249 Added short form localized tokens.
250
251 Added ability to define language a string should be parsed in.
252
253 Added support for reversed add/subtract arguments.
254
255 Added support for `endOf('week')` and `startOf('week')`.
256
257 Fixed the logic for `moment#diff(Moment, 'months')` and `moment#diff(Moment, 'years')`
258
259 `moment#diff` now floors instead of rounds.
260
261 Normalized `moment#toString`.
262
263 Added `isSame`, `isAfter`, and `isBefore` methods.
264
265 Added better week support.
266
267 Added `moment#toJSON`
268
269 Bugfix: Fixed parsing of first century dates
270
271 Bugfix: Parsing 10Sep2001 should work as expected
272
273 Bugfix: Fixed wierdness with `moment.utc()` parsing.
274
275 Changed language ordinal method to return the number + ordinal instead of just the ordinal.
276
277 Changed two digit year parsing cutoff to match strptime.
278
279 Removed `moment#sod` and `moment#eod` in favor of `moment#startOf` and `moment#endOf`.
280
281 Removed `moment.humanizeDuration()` in favor of `moment.duration().humanize()`.
282
283 Removed the lang data objects from the top level namespace.
284
285 Duplicate `Date` passed to `moment()` instead of referencing it.
286
287 ### 1.7.2 [See discussion](https://github.com/timrwood/moment/issues/456)
288
289 Bugfixes
290
291 ### 1.7.1 [See discussion](https://github.com/timrwood/moment/issues/384)
292
293 Bugfixes
294
295 ### 1.7.0 [See discussion](https://github.com/timrwood/moment/issues/288)
296
297 Added `moment.fn.endOf()` and `moment.fn.startOf()`.
298
299 Added validation via `moment.fn.isValid()`.
300
301 Made formatting method 3x faster. http://jsperf.com/momentjs-cached-format-functions
302
303 Add support for month/weekday callbacks in `moment.fn.format()`
304
305 Added instance specific languages.
306
307 Added two letter weekday abbreviations with the formatting token `dd`.
308
309 Various language updates.
310
311 Various bugfixes.
312
313 ### 1.6.0 [See discussion](https://github.com/timrwood/moment/pull/268)
314
315 Added Durations.
316
317 Revamped parser to support parsing non-separated strings (YYYYMMDD vs YYYY-MM-DD).
318
319 Added support for millisecond parsing and formatting tokens (S SS SSS)
320
321 Added a getter for `moment.lang()`
322
323 Various bugfixes.
324
325 There are a few things deprecated in the 1.6.0 release.
326
327 1. The format tokens `z` and `zz` (timezone abbreviations like EST CST MST etc) will no longer be supported. Due to inconsistent browser support, we are unable to consistently produce this value. See [this issue](https://github.com/timrwood/moment/issues/162) for more background.
328
329 2. The method `moment.fn.native` is deprecated in favor of `moment.fn.toDate`. There continue to be issues with Google Closure Compiler throwing errors when using `native`, even in valid instances.
330
331 3. The way to customize am/pm strings is being changed. This would only affect you if you created a custom language file. For more information, see [this issue](https://github.com/timrwood/moment/pull/222).
332
333 ### 1.5.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=10&page=1&state=closed)
334
335 Added UTC mode.
336
337 Added automatic ISO8601 parsing.
338
339 Various bugfixes.
340
341 ### 1.4.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=8&state=closed)
342
343 Added `moment.fn.toDate` as a replacement for `moment.fn.native`.
344
345 Added `moment.fn.sod` and `moment.fn.eod` to get the start and end of day.
346
347 Various bugfixes.
348
349 ### 1.3.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=7&state=closed)
350
351 Added support for parsing month names in the current language.
352
353 Added escape blocks for parsing tokens.
354
355 Added `moment.fn.calendar` to format strings like 'Today 2:30 PM', 'Tomorrow 1:25 AM', and 'Last Sunday 4:30 AM'.
356
357 Added `moment.fn.day` as a setter.
358
359 Various bugfixes
360
361 ### 1.2.0 [See milestone](https://github.com/timrwood/moment/issues?milestone=4&state=closed)
362
363 Added timezones to parser and formatter.
364
365 Added `moment.fn.isDST`.
366
367 Added `moment.fn.zone` to get the timezone offset in minutes.
368
369 ### 1.1.2 [See milestone](https://github.com/timrwood/moment/issues?milestone=6&state=closed)
370
371 Various bugfixes
372
373 ### 1.1.1 [See milestone](https://github.com/timrwood/moment/issues?milestone=5&state=closed)
374
375 Added time specific diffs (months, days, hours, etc)
376
377 ### 1.1.0
378
379 Added `moment.fn.format` localized masks. 'L LL LLL LLLL' [issue 29](https://github.com/timrwood/moment/pull/29)
380
381 Fixed [issue 31](https://github.com/timrwood/moment/pull/31).
382
383 ### 1.0.1
384
385 Added `moment.version` to get the current version.
386
387 Removed `window !== undefined` when checking if module exists to support browserify. [issue 25](https://github.com/timrwood/moment/pull/25)
388
389 ### 1.0.0
390
391 Added convenience methods for getting and setting date parts.
392
393 Added better support for `moment.add()`.
394
395 Added better lang support in NodeJS.
396
397 Renamed library from underscore.date to Moment.js
398
399 ### 0.6.1
400
401 Added Portuguese, Italian, and French language support
402
403 ### 0.6.0
404
405 Added _date.lang() support.
406 Added support for passing multiple formats to try to parse a date. _date("07-10-1986", ["MM-DD-YYYY", "YYYY-MM-DD"]);
407 Made parse from string and single format 25% faster.
408
409 ### 0.5.2
410
411 Bugfix for [issue 8](https://github.com/timrwood/underscore.date/pull/8) and [issue 9](https://github.com/timrwood/underscore.date/pull/9).
412
413 ### 0.5.1
414
415 Bugfix for [issue 5](https://github.com/timrwood/underscore.date/pull/5).
416
417 ### 0.5.0
418
419 Dropped the redundant `_date.date()` in favor of `_date()`.
420 Removed `_date.now()`, as it is a duplicate of `_date()` with no parameters.
421 Removed `_date.isLeapYear(yearNumber)`. Use `_date([yearNumber]).isLeapYear()` instead.
422 Exposed customization options through the `_date.relativeTime`, `_date.weekdays`, `_date.weekdaysShort`, `_date.months`, `_date.monthsShort`, and `_date.ordinal` variables instead of the `_date.customize()` function.
423
424 ### 0.4.1
425
426 Added date input formats for input strings.
427
428 ### 0.4.0
429
430 Added underscore.date to npm. Removed dependencies on underscore.
431
432 ### 0.3.2
433
434 Added `'z'` and `'zz'` to `_.date().format()`. Cleaned up some redundant code to trim off some bytes.
435
436 ### 0.3.1
437
438 Cleaned up the namespace. Moved all date manipulation and display functions to the _.date() object.
439
440 ### 0.3.0
441
442 Switched to the Underscore methodology of not mucking with the native objects' prototypes.
443 Made chaining possible.
444
445 ### 0.2.1
446
447 Changed date names to be a more pseudo standardized 'dddd, MMMM Do YYYY, h:mm:ss a'.
448 Added `Date.prototype` functions `add`, `subtract`, `isdst`, and `isleapyear`.
449
450 ### 0.2.0
451
452 Changed function names to be more concise.
453 Changed date format from php date format to custom format.
454
455 ### 0.1.0
456
457 Initial release
458
0 Submitting Issues
1 =================
2
3 If you are submitting a bug, please create a [jsfiddle](http://jsfiddle.net/) demonstrating the issue.
4
5 Read before submitting Pull Requests
6 ====================================
7
8 * **Pull requests to the `master` branch will be closed.** Please submit all pull requests to the `develop` branch.
9 * **Locale translations will not be merged without unit tests.** See [the British English unit tests](https://github.com/moment/moment/blob/develop/src/test/locale/en-gb.js) for an example.
10 * **Do not include the minified files in your pull request.** These are
11 `moment.js`, `locale/*.js`, `min/*.js`. Don't worry, we'll build them when
12 we cut a release.
13
14 Code organization
15 =================
16
17 Starting from version 2.10.0 the code is placed under `src/`.
18 `moment.js`, `locale/*.js`, `min/*.js` are generated only on release.
19
20 **DO NOT** submit changes to the generated files. Instead only change
21 `src/**/*.js` and run the tests.
22
23 * `src/lib/**/*.js` moment core files
24 * `src/locale/*.js` locale files
25 * `src/test/moment/*.js` moment core tests
26 * `src/test/locale/*.js` locale tests
27
28 We're using ES6 module system, but nothing else ES6, because of performance
29 considerations (added code by the transpiler, less than optimal translation to
30 ES5). So please do not use that fancy new ES6 feature in your patch, it won't
31 be accepted.
32
33 Setting up development environment
34 ==================================
35
36 To contribute, fork the library and install grunt and dependencies. You need
37 [git](http://git-scm.com/) and
38 [node](http://nodejs.org/); you might use
39 [nvm](https://github.com/creationix/nvm) or
40 [nenv](https://github.com/ryuone/nenv) to install node.
41
42 ```bash
43 git clone https://github.com/moment/moment.git
44 cd moment
45 npm install -g grunt-cli
46 npm install
47 git checkout develop # all patches against develop branch, please!
48 grunt # this runs tests and jshint
49 ```
50
51 Changing locale files
52 =====================
53
54 If you have any changes to existing locale files, `@mention` the original
55 author in the pull request (check the top of the language file), and ask if
56 he/she approves of your changes. Because I don't know any languages I can't
57 judge your locale changes, only the original author can :)
58
59 In order for your pull request to get merged it must have approval of original
60 author, or at least one other native speaker has to approve of the change
61 (happens rarely).
62
63 Grunt tasks
64 ===========
65
66 We use Grunt for managing the build. Here are some useful Grunt tasks:
67
68 * `grunt` The default task lints the code and runs the tests. You should make sure you do this before submitting a PR.
69 * `grunt test` run the tests.
70 * `grunt release` Build everything, including minified files (do not include
71 those in Pull Requests)
72 * `grunt transpile:fr,ru` Build custom locale bundles `moment-with-locales.custom.js` and `locales.custom.js` inside `build/umd/min` containing just French and Russian.
73 * `grunt size` Print size statistics.
0 module.exports = function (grunt) {
1 grunt.initConfig({
2 pkg: grunt.file.readJSON('package.json'),
3 env : {
4 sauceLabs : (grunt.file.exists('.sauce-labs.creds') ?
5 grunt.file.readJSON('.sauce-labs.creds') : {})
6 },
7 karma : {
8 options: {
9 frameworks: ['qunit'],
10 files: [
11 'min/moment-with-locales.js',
12 'min/tests.js'
13 ],
14 sauceLabs: {
15 startConnect: true,
16 testName: 'MomentJS'
17 },
18 customLaunchers: {
19 slChromeWinXp: {
20 base: 'SauceLabs',
21 browserName: 'chrome',
22 platform: 'Windows XP'
23 },
24 slIe9Win7: {
25 base: 'SauceLabs',
26 browserName: 'internet explorer',
27 platform: 'Windows 7',
28 version: '9'
29 },
30 slIe8Win7: {
31 base: 'SauceLabs',
32 browserName: 'internet explorer',
33 platform: 'Windows 7',
34 version: '8'
35 },
36 slFfLinux: {
37 base: 'SauceLabs',
38 browserName: 'firefox',
39 platform: 'Linux'
40 },
41 slSafariOsx: {
42 base: 'SauceLabs',
43 browserName: 'safari',
44 platform: 'OS X 10.8'
45 }
46 }
47 },
48 server: {
49 browsers: []
50 },
51 chrome: {
52 singleRun: true,
53 browsers: ['Chrome']
54 },
55 firefox: {
56 singleRun: true,
57 browsers: ['Firefox']
58 },
59 sauce: {
60 options: {
61 reporters: ['dots']
62 },
63 singleRun: true,
64 browsers: [
65 'slChromeWinXp',
66 'slIe9Win7',
67 'slIe8Win7',
68 'slFfLinux',
69 'slSafariOsx'
70 ]
71 }
72 },
73 uglify : {
74 main: {
75 files: {
76 'min/moment-with-locales.min.js' : 'min/moment-with-locales.js',
77 'min/locales.min.js' : 'min/locales.js',
78 'min/moment.min.js' : 'moment.js'
79 }
80 },
81 options: {
82 mangle: true,
83 compress: {
84 dead_code: false // jshint ignore:line
85 },
86 output: {
87 ascii_only: true // jshint ignore:line
88 },
89 report: 'min',
90 preserveComments: 'some'
91 }
92 },
93 jshint: {
94 all: [
95 'Gruntfile.js',
96 'tasks/**.js',
97 'src/**/*.js'
98 ],
99 options: {
100 jshintrc: true
101 }
102 },
103 jscs: {
104 all: [
105 'Gruntfile.js',
106 'tasks/**.js',
107 'src/**/*.js'
108 ],
109 options: {
110 config: '.jscs.json'
111 }
112 },
113 watch : {
114 test : {
115 files : [
116 'src/**/*.js'
117 ],
118 tasks: ['test']
119 },
120 jshint : {
121 files : '<%= jshint.all %>',
122 tasks: ['jshint']
123 }
124 },
125 benchmark: {
126 all: {
127 src: ['benchmarks/*.js']
128 }
129 },
130 exec: {
131 'meteor-init': {
132 command: [
133 // Make sure Meteor is installed, per https://meteor.com/install.
134 // The curl'ed script is safe; takes 2 minutes to read source & check.
135 'type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }',
136 // Meteor expects package.js to be in the root directory of
137 // the checkout, but we already have a package.js for Dojo
138 'mv package.js package.dojo && cp meteor/package.js .'
139 ].join(';')
140 },
141 'meteor-cleanup': {
142 // remove build files and restore Dojo's package.js
143 command: 'rm -rf ".build.*" versions.json; mv package.dojo package.js'
144 },
145 'meteor-test': {
146 command: 'spacejam --mongo-url mongodb:// test-packages ./'
147 },
148 'meteor-publish': {
149 command: 'meteor publish'
150 }
151 }
152
153 });
154
155 grunt.loadTasks('tasks');
156
157 // These plugins provide necessary tasks.
158 require('load-grunt-tasks')(grunt);
159
160 // Default task.
161 grunt.registerTask('default', ['lint', 'test:node']);
162
163 // linting
164 grunt.registerTask('lint', ['jshint', 'jscs']);
165
166 // test tasks
167 grunt.registerTask('test', ['test:node']);
168 grunt.registerTask('test:node', ['transpile', 'qtest']);
169 // TODO: For some weird reason karma doesn't like the files in
170 // build/umd/min/* but works with min/*, so update-index, then git checkout
171 grunt.registerTask('test:server', ['transpile', 'update-index', 'karma:server']);
172 grunt.registerTask('test:browser', ['transpile', 'update-index', 'karma:chrome', 'karma:firefox']);
173 grunt.registerTask('test:sauce-browser', ['transpile', 'update-index', 'env:sauceLabs', 'karma:sauce']);
174 grunt.registerTask('test:meteor', ['exec:meteor-init', 'exec:meteor-test', 'exec:meteor-cleanup']);
175
176 // travis build task
177 grunt.registerTask('build:travis', ['default']);
178 grunt.registerTask('meteor-publish', ['exec:meteor-init', 'exec:meteor-publish', 'exec:meteor-cleanup']);
179
180 // Task to be run when releasing a new version
181 grunt.registerTask('release', [
182 'default',
183 'update-index',
184 'component',
185 'uglify:main'
186 ]);
187 };
0 Copyright (c) 2011-2015 Tim Wood, Iskren Chernev, Moment.js contributors
1
2 Permission is hereby granted, free of charge, to any person
3 obtaining a copy of this software and associated documentation
4 files (the "Software"), to deal in the Software without
5 restriction, including without limitation the rights to use,
6 copy, modify, merge, publish, distribute, sublicense, and/or sell
7 copies of the Software, and to permit persons to whom the
8 Software is furnished to do so, subject to the following
9 conditions:
10
11 The above copyright notice and this permission notice shall be
12 included in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 OTHER DEALINGS IN THE SOFTWARE.
0 <?xml version="1.0"?>
1 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
2 <metadata>
3 <id>Moment.js</id>
4 <version>2.10.6</version>
5 <authors>Tim Wood</authors>
6 <owners>Cory Deppen, Iskren Chernev</owners>
7 <description>A lightweight javascript date library for parsing, manipulating, and formatting dates.</description>
8 <releaseNotes>
9 - Add LTS localised format that includes seconds
10 - Added formatToken 'x' for unix offset in milliseconds #1938
11 - Support 24:00:00.000 to mean next day, at midnight.
12 - Accept 'date' key when creating moment with object
13 - Use native toISOString when we can
14 - Some bugfixes and language improvements
15 </releaseNotes>
16 <projectUrl>http://momentjs.com/</projectUrl>
17 <iconUrl>http://pbs.twimg.com/profile_images/482670411402858496/Xrtdc94q_normal.png</iconUrl>
18 <licenseUrl>https://raw.github.com/timrwood/moment/master/LICENSE</licenseUrl>
19 <tags>JavaScript date time browser node.js</tags>
20 </metadata>
21 <files>
22 <file src="moment.js" target="Content\Scripts" />
23 <file src="min/moment.min.js" target="Content\Scripts" />
24 <file src="min/moment-with-locales.js" target="Content\Scripts" />
25 <file src="min/moment-with-locales.min.js" target="Content\Scripts" />
26 </files>
27 </package>
0 [![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)
1
2 [![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]
3 [![Coverage Status](https://coveralls.io/repos/moment/moment/badge.svg?branch=master)](https://coveralls.io/r/moment/moment?branch=master)
4
5 A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
6
7 ## [Documentation](http://momentjs.com/docs/)
8
9 ## Port to ES6 (version 2.10.0)
10
11 Moment 2.10.0 does not bring any new features, but the code is now written in
12 es6 modules and placed inside `src/`. Previously `moment.js`, `locale/*.js` and
13 `test/moment/*.js`, `test/locale/*.js` contained the source of the project. Now
14 the source is in `src/`, temporary build (es5) files are placed under
15 `build/umd/` (for running tests during development), and the `moment.js` and
16 `locale/*.js` files are updated only on release.
17
18 If you want to use a particular revision of the code, make sure to run
19 `grunt transpile update-index`, so `moment.js` and `locales/*.js` are synced
20 with `src/*`. We might place that in a commit hook in the future.
21
22 ## Upgrading to 2.0.0
23
24 There are a number of small backwards incompatible changes with version 2.0.0. [See the full descriptions here](https://gist.github.com/timrwood/e72f2eef320ed9e37c51#backwards-incompatible-changes)
25
26 * Changed language ordinal method to return the number + ordinal instead of just the ordinal.
27
28 * Changed two digit year parsing cutoff to match strptime.
29
30 * Removed `moment#sod` and `moment#eod` in favor of `moment#startOf` and `moment#endOf`.
31
32 * Removed `moment.humanizeDuration()` in favor of `moment.duration().humanize()`.
33
34 * Removed the lang data objects from the top level namespace.
35
36 * Duplicate `Date` passed to `moment()` instead of referencing it.
37
38 ## [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
39
40 ## [Contributing](https://github.com/moment/moment/blob/develop/CONTRIBUTING.md)
41
42 We're looking for co-maintainers! If you want to become a master of time please
43 write to [ichernev](https://github.com/ichernev).
44
45 ## License
46
47 Moment.js is freely distributable under the terms of the [MIT license](https://github.com/moment/moment/blob/develop/LICENSE).
48
49 [license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
50 [license-url]: LICENSE
51
52 [npm-url]: https://npmjs.org/package/moment
53 [npm-version-image]: http://img.shields.io/npm/v/moment.svg?style=flat
54 [npm-downloads-image]: http://img.shields.io/npm/dm/moment.svg?style=flat
55
56 [travis-url]: http://travis-ci.org/moment/moment
57 [travis-image]: http://img.shields.io/travis/moment/moment/develop.svg?style=flat
0 var Benchmark = require('benchmark'),
1 moment = require("./../moment.js"),
2 base = moment('2013-05-25');
3
4 module.exports = {
5 name: 'clone',
6 onComplete: function(){},
7 fn: function(){base.clone();},
8 async: true
9 };
0 var Benchmark = require('benchmark'),
1 moment = require('./../moment.js'),
2 base = new Date();
3
4 module.exports = {
5 name: 'fromDate',
6 onComplete: function(){},
7 fn: function(){
8 moment(base);
9 },
10 async: true
11 };
0 var Benchmark = require('benchmark'),
1 moment = require('./../moment.js'),
2 base = new Date();
3
4 module.exports = {
5 name: 'fromDateUtc',
6 onComplete: function(){},
7 fn: function(){
8 moment.utc(base);
9 },
10 async: true
11 };
0 var Benchmark = require('benchmark'),
1 moment = require('./../moment.js');
2
3 module.exports = {
4 name: 'makeDuration',
5 onComplete: function(){},
6 fn: function(){
7 moment.duration(5, 'years');
8 },
9 async: true
10 };
0 var Benchmark = require('benchmark');
1
2 module.exports = {
3 name: 'zeroFill',
4 tests: {
5 zeroFillMath: {
6 setup: function() {
7 var zeroFillMath = function(number, targetLength, forceSign) {
8 var absNumber = '' + Math.abs(number),
9 zerosToFill = targetLength - absNumber.length,
10 sign = number >= 0;
11 return (sign ? (forceSign ? '+' : '') : '-') +
12 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
13 }
14 },
15 fn: function() {
16 zeroFillMath(Math.random() * 1e5 | 0, 5);
17 zeroFillMath(Math.random() * 1e5 | 0, 10);
18 zeroFillMath(Math.random() * 1e10 | 0, 20);
19 },
20 async: true
21 },
22 zeroFillWhile: {
23 setup: function() {
24 var zeroFillWhile = function(number, targetLength, forceSign) {
25 var output = '' + Math.abs(number),
26 sign = number >= 0;
27
28 while (output.length < targetLength) {
29 output = '0' + output;
30 }
31 return (sign ? (forceSign ? '+' : '') : '-') + output;
32 }
33 },
34 fn: function() {
35 zeroFillWhile(Math.random() * 1e5 | 0, 5);
36 zeroFillWhile(Math.random() * 1e5 | 0, 10);
37 zeroFillWhile(Math.random() * 1e10 | 0, 20);
38 },
39 async: true
40 }
41 }
42 };
0 {
1 "name": "moment",
2 "main": "moment.js",
3 "ignore": [
4 "**/.*",
5 "benchmarks",
6 "bower_components",
7 "meteor",
8 "node_modules",
9 "scripts",
10 "tasks",
11 "test",
12 "component.json",
13 "composer.json",
14 "CONTRIBUTING.md",
15 "ender.js",
16 "Gruntfile.js",
17 "Moment.js.nuspec",
18 "package.js",
19 "package.json"
20 ]
21 }
0 {
1 "name": "moment",
2 "version": "2.10.6",
3 "main": "moment.js",
4 "description": "Parse, validate, manipulate, and display dates in JavaScript.",
5 "files": [
6 "moment.js",
7 "locale/af.js",
8 "locale/ar-ma.js",
9 "locale/ar-sa.js",
10 "locale/ar-tn.js",
11 "locale/ar.js",
12 "locale/az.js",
13 "locale/be.js",
14 "locale/bg.js",
15 "locale/bn.js",
16 "locale/bo.js",
17 "locale/br.js",
18 "locale/bs.js",
19 "locale/ca.js",
20 "locale/cs.js",
21 "locale/cv.js",
22 "locale/cy.js",
23 "locale/da.js",
24 "locale/de-at.js",
25 "locale/de.js",
26 "locale/el.js",
27 "locale/en-au.js",
28 "locale/en-ca.js",
29 "locale/en-gb.js",
30 "locale/eo.js",
31 "locale/es.js",
32 "locale/et.js",
33 "locale/eu.js",
34 "locale/fa.js",
35 "locale/fi.js",
36 "locale/fo.js",
37 "locale/fr-ca.js",
38 "locale/fr.js",
39 "locale/fy.js",
40 "locale/gl.js",
41 "locale/he.js",
42 "locale/hi.js",
43 "locale/hr.js",
44 "locale/hu.js",
45 "locale/hy-am.js",
46 "locale/id.js",
47 "locale/is.js",
48 "locale/it.js",
49 "locale/ja.js",
50 "locale/jv.js",
51 "locale/ka.js",
52 "locale/km.js",
53 "locale/ko.js",
54 "locale/lb.js",
55 "locale/lt.js",
56 "locale/lv.js",
57 "locale/me.js",
58 "locale/mk.js",
59 "locale/ml.js",
60 "locale/mr.js",
61 "locale/ms-my.js",
62 "locale/ms.js",
63 "locale/my.js",
64 "locale/nb.js",
65 "locale/ne.js",
66 "locale/nl.js",
67 "locale/nn.js",
68 "locale/pl.js",
69 "locale/pt-br.js",
70 "locale/pt.js",
71 "locale/ro.js",
72 "locale/ru.js",
73 "locale/si.js",
74 "locale/sk.js",
75 "locale/sl.js",
76 "locale/sq.js",
77 "locale/sr-cyrl.js",
78 "locale/sr.js",
79 "locale/sv.js",
80 "locale/ta.js",
81 "locale/th.js",
82 "locale/tl-ph.js",
83 "locale/tr.js",
84 "locale/tzl.js",
85 "locale/tzm-latn.js",
86 "locale/tzm.js",
87 "locale/uk.js",
88 "locale/uz.js",
89 "locale/vi.js",
90 "locale/zh-cn.js",
91 "locale/zh-tw.js"
92 ],
93 "scripts": [
94 "moment.js"
95 ]
96 }
0 {
1 "name": "moment/moment",
2 "description": "Parse, validate, manipulate, and display dates in JavaScript.",
3 "keywords": [
4 "moment",
5 "date",
6 "time",
7 "parse",
8 "format",
9 "validate",
10 "i18n",
11 "l10n",
12 "ender"
13 ],
14 "homepage": "http://github.com/moment/moment/",
15 "authors": [{"name": "Tim Wood", "email": "washwithcare@gmail.com"}],
16 "license": "MIT",
17 "type": "component",
18 "require": {
19 "robloach/component-installer": "*"
20 },
21 "extra": {
22 "component": {
23 "scripts": [
24 "moment.js"
25 ],
26 "files": [
27 "min/*.js",
28 "locale/*.js"
29 ]
30 }
31 }
32 }
0 $.ender({ moment: require('moment') })
0 //! moment.js locale configuration
1 //! locale : afrikaans (af)
2 //! author : Werner Mollentze : https://github.com/wernerm
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var af = moment.defineLocale('af', {
12 months : 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'),
13 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'),
14 weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
15 weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
16 weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
17 meridiemParse: /vm|nm/i,
18 isPM : function (input) {
19 return /^nm$/i.test(input);
20 },
21 meridiem : function (hours, minutes, isLower) {
22 if (hours < 12) {
23 return isLower ? 'vm' : 'VM';
24 } else {
25 return isLower ? 'nm' : 'NM';
26 }
27 },
28 longDateFormat : {
29 LT : 'HH:mm',
30 LTS : 'HH:mm:ss',
31 L : 'DD/MM/YYYY',
32 LL : 'D MMMM YYYY',
33 LLL : 'D MMMM YYYY HH:mm',
34 LLLL : 'dddd, D MMMM YYYY HH:mm'
35 },
36 calendar : {
37 sameDay : '[Vandag om] LT',
38 nextDay : '[Môre om] LT',
39 nextWeek : 'dddd [om] LT',
40 lastDay : '[Gister om] LT',
41 lastWeek : '[Laas] dddd [om] LT',
42 sameElse : 'L'
43 },
44 relativeTime : {
45 future : 'oor %s',
46 past : '%s gelede',
47 s : '\'n paar sekondes',
48 m : '\'n minuut',
49 mm : '%d minute',
50 h : '\'n uur',
51 hh : '%d ure',
52 d : '\'n dag',
53 dd : '%d dae',
54 M : '\'n maand',
55 MM : '%d maande',
56 y : '\'n jaar',
57 yy : '%d jaar'
58 },
59 ordinalParse: /\d{1,2}(ste|de)/,
60 ordinal : function (number) {
61 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); // Thanks to Joris Röling : https://github.com/jjupiter
62 },
63 week : {
64 dow : 1, // Maandag is die eerste dag van die week.
65 doy : 4 // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
66 }
67 });
68
69 return af;
70
71 }));
0 //! moment.js locale configuration
1 //! locale : Moroccan Arabic (ar-ma)
2 //! author : ElFadili Yassine : https://github.com/ElFadiliY
3 //! author : Abdel Said : https://github.com/abdelsaid
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var ar_ma = moment.defineLocale('ar-ma', {
13 months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
14 monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
15 weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
16 weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
17 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
18 longDateFormat : {
19 LT : 'HH:mm',
20 LTS : 'HH:mm:ss',
21 L : 'DD/MM/YYYY',
22 LL : 'D MMMM YYYY',
23 LLL : 'D MMMM YYYY HH:mm',
24 LLLL : 'dddd D MMMM YYYY HH:mm'
25 },
26 calendar : {
27 sameDay: '[اليوم على الساعة] LT',
28 nextDay: '[غدا على الساعة] LT',
29 nextWeek: 'dddd [على الساعة] LT',
30 lastDay: '[أمس على الساعة] LT',
31 lastWeek: 'dddd [على الساعة] LT',
32 sameElse: 'L'
33 },
34 relativeTime : {
35 future : 'في %s',
36 past : 'منذ %s',
37 s : 'ثوان',
38 m : 'دقيقة',
39 mm : '%d دقائق',
40 h : 'ساعة',
41 hh : '%d ساعات',
42 d : 'يوم',
43 dd : '%d أيام',
44 M : 'شهر',
45 MM : '%d أشهر',
46 y : 'سنة',
47 yy : '%d سنوات'
48 },
49 week : {
50 dow : 6, // Saturday is the first day of the week.
51 doy : 12 // The week that contains Jan 1st is the first week of the year.
52 }
53 });
54
55 return ar_ma;
56
57 }));
0 //! moment.js locale configuration
1 //! locale : Arabic Saudi Arabia (ar-sa)
2 //! author : Suhail Alkowaileet : https://github.com/xsoh
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '١',
13 '2': '٢',
14 '3': '٣',
15 '4': '٤',
16 '5': '٥',
17 '6': '٦',
18 '7': '٧',
19 '8': '٨',
20 '9': '٩',
21 '0': '٠'
22 }, numberMap = {
23 '١': '1',
24 '٢': '2',
25 '٣': '3',
26 '٤': '4',
27 '٥': '5',
28 '٦': '6',
29 '٧': '7',
30 '٨': '8',
31 '٩': '9',
32 '٠': '0'
33 };
34
35 var ar_sa = moment.defineLocale('ar-sa', {
36 months : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
37 monthsShort : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
38 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
39 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
40 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
41 longDateFormat : {
42 LT : 'HH:mm',
43 LTS : 'HH:mm:ss',
44 L : 'DD/MM/YYYY',
45 LL : 'D MMMM YYYY',
46 LLL : 'D MMMM YYYY HH:mm',
47 LLLL : 'dddd D MMMM YYYY HH:mm'
48 },
49 meridiemParse: /ص|م/,
50 isPM : function (input) {
51 return 'م' === input;
52 },
53 meridiem : function (hour, minute, isLower) {
54 if (hour < 12) {
55 return 'ص';
56 } else {
57 return 'م';
58 }
59 },
60 calendar : {
61 sameDay: '[اليوم على الساعة] LT',
62 nextDay: '[غدا على الساعة] LT',
63 nextWeek: 'dddd [على الساعة] LT',
64 lastDay: '[أمس على الساعة] LT',
65 lastWeek: 'dddd [على الساعة] LT',
66 sameElse: 'L'
67 },
68 relativeTime : {
69 future : 'في %s',
70 past : 'منذ %s',
71 s : 'ثوان',
72 m : 'دقيقة',
73 mm : '%d دقائق',
74 h : 'ساعة',
75 hh : '%d ساعات',
76 d : 'يوم',
77 dd : '%d أيام',
78 M : 'شهر',
79 MM : '%d أشهر',
80 y : 'سنة',
81 yy : '%d سنوات'
82 },
83 preparse: function (string) {
84 return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
85 return numberMap[match];
86 }).replace(/،/g, ',');
87 },
88 postformat: function (string) {
89 return string.replace(/\d/g, function (match) {
90 return symbolMap[match];
91 }).replace(/,/g, '،');
92 },
93 week : {
94 dow : 6, // Saturday is the first day of the week.
95 doy : 12 // The week that contains Jan 1st is the first week of the year.
96 }
97 });
98
99 return ar_sa;
100
101 }));
0 //! moment.js locale configuration
1 //! locale : Tunisian Arabic (ar-tn)
2
3 (function (global, factory) {
4 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
5 typeof define === 'function' && define.amd ? define(['moment'], factory) :
6 factory(global.moment)
7 }(this, function (moment) { 'use strict';
8
9
10 var ar_tn = moment.defineLocale('ar-tn', {
11 months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
12 monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
13 weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
14 weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
15 weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
16 longDateFormat: {
17 LT: 'HH:mm',
18 LTS: 'HH:mm:ss',
19 L: 'DD/MM/YYYY',
20 LL: 'D MMMM YYYY',
21 LLL: 'D MMMM YYYY HH:mm',
22 LLLL: 'dddd D MMMM YYYY HH:mm'
23 },
24 calendar: {
25 sameDay: '[اليوم على الساعة] LT',
26 nextDay: '[غدا على الساعة] LT',
27 nextWeek: 'dddd [على الساعة] LT',
28 lastDay: '[أمس على الساعة] LT',
29 lastWeek: 'dddd [على الساعة] LT',
30 sameElse: 'L'
31 },
32 relativeTime: {
33 future: 'في %s',
34 past: 'منذ %s',
35 s: 'ثوان',
36 m: 'دقيقة',
37 mm: '%d دقائق',
38 h: 'ساعة',
39 hh: '%d ساعات',
40 d: 'يوم',
41 dd: '%d أيام',
42 M: 'شهر',
43 MM: '%d أشهر',
44 y: 'سنة',
45 yy: '%d سنوات'
46 },
47 week: {
48 dow: 1, // Monday is the first day of the week.
49 doy: 4 // The week that contains Jan 4th is the first week of the year.
50 }
51 });
52
53 return ar_tn;
54
55 }));
0 //! moment.js locale configuration
1 //! Locale: Arabic (ar)
2 //! Author: Abdel Said: https://github.com/abdelsaid
3 //! Changes in months, weekdays: Ahmed Elkhatib
4 //! Native plural forms: forabi https://github.com/forabi
5
6 (function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
8 typeof define === 'function' && define.amd ? define(['moment'], factory) :
9 factory(global.moment)
10 }(this, function (moment) { 'use strict';
11
12
13 var symbolMap = {
14 '1': '١',
15 '2': '٢',
16 '3': '٣',
17 '4': '٤',
18 '5': '٥',
19 '6': '٦',
20 '7': '٧',
21 '8': '٨',
22 '9': '٩',
23 '0': '٠'
24 }, numberMap = {
25 '١': '1',
26 '٢': '2',
27 '٣': '3',
28 '٤': '4',
29 '٥': '5',
30 '٦': '6',
31 '٧': '7',
32 '٨': '8',
33 '٩': '9',
34 '٠': '0'
35 }, pluralForm = function (n) {
36 return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
37 }, plurals = {
38 s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
39 m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
40 h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
41 d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
42 M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
43 y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
44 }, pluralize = function (u) {
45 return function (number, withoutSuffix, string, isFuture) {
46 var f = pluralForm(number),
47 str = plurals[u][pluralForm(number)];
48 if (f === 2) {
49 str = str[withoutSuffix ? 0 : 1];
50 }
51 return str.replace(/%d/i, number);
52 };
53 }, months = [
54 'كانون الثاني يناير',
55 'شباط فبراير',
56 'آذار مارس',
57 'نيسان أبريل',
58 'أيار مايو',
59 'حزيران يونيو',
60 'تموز يوليو',
61 'آب أغسطس',
62 'أيلول سبتمبر',
63 'تشرين الأول أكتوبر',
64 'تشرين الثاني نوفمبر',
65 'كانون الأول ديسمبر'
66 ];
67
68 var ar = moment.defineLocale('ar', {
69 months : months,
70 monthsShort : months,
71 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
72 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
73 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
74 longDateFormat : {
75 LT : 'HH:mm',
76 LTS : 'HH:mm:ss',
77 L : 'D/\u200FM/\u200FYYYY',
78 LL : 'D MMMM YYYY',
79 LLL : 'D MMMM YYYY HH:mm',
80 LLLL : 'dddd D MMMM YYYY HH:mm'
81 },
82 meridiemParse: /ص|م/,
83 isPM : function (input) {
84 return 'م' === input;
85 },
86 meridiem : function (hour, minute, isLower) {
87 if (hour < 12) {
88 return 'ص';
89 } else {
90 return 'م';
91 }
92 },
93 calendar : {
94 sameDay: '[اليوم عند الساعة] LT',
95 nextDay: '[غدًا عند الساعة] LT',
96 nextWeek: 'dddd [عند الساعة] LT',
97 lastDay: '[أمس عند الساعة] LT',
98 lastWeek: 'dddd [عند الساعة] LT',
99 sameElse: 'L'
100 },
101 relativeTime : {
102 future : 'بعد %s',
103 past : 'منذ %s',
104 s : pluralize('s'),
105 m : pluralize('m'),
106 mm : pluralize('m'),
107 h : pluralize('h'),
108 hh : pluralize('h'),
109 d : pluralize('d'),
110 dd : pluralize('d'),
111 M : pluralize('M'),
112 MM : pluralize('M'),
113 y : pluralize('y'),
114 yy : pluralize('y')
115 },
116 preparse: function (string) {
117 return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
118 return numberMap[match];
119 }).replace(/،/g, ',');
120 },
121 postformat: function (string) {
122 return string.replace(/\d/g, function (match) {
123 return symbolMap[match];
124 }).replace(/,/g, '،');
125 },
126 week : {
127 dow : 6, // Saturday is the first day of the week.
128 doy : 12 // The week that contains Jan 1st is the first week of the year.
129 }
130 });
131
132 return ar;
133
134 }));
0 //! moment.js locale configuration
1 //! locale : azerbaijani (az)
2 //! author : topchiyev : https://github.com/topchiyev
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var suffixes = {
12 1: '-inci',
13 5: '-inci',
14 8: '-inci',
15 70: '-inci',
16 80: '-inci',
17 2: '-nci',
18 7: '-nci',
19 20: '-nci',
20 50: '-nci',
21 3: '-üncü',
22 4: '-üncü',
23 100: '-üncü',
24 6: '-ncı',
25 9: '-uncu',
26 10: '-uncu',
27 30: '-uncu',
28 60: '-ıncı',
29 90: '-ıncı'
30 };
31
32 var az = moment.defineLocale('az', {
33 months : 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split('_'),
34 monthsShort : 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'),
35 weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
36 weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
37 weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
38 longDateFormat : {
39 LT : 'HH:mm',
40 LTS : 'HH:mm:ss',
41 L : 'DD.MM.YYYY',
42 LL : 'D MMMM YYYY',
43 LLL : 'D MMMM YYYY HH:mm',
44 LLLL : 'dddd, D MMMM YYYY HH:mm'
45 },
46 calendar : {
47 sameDay : '[bugün saat] LT',
48 nextDay : '[sabah saat] LT',
49 nextWeek : '[gələn həftə] dddd [saat] LT',
50 lastDay : '[dünən] LT',
51 lastWeek : '[keçən həftə] dddd [saat] LT',
52 sameElse : 'L'
53 },
54 relativeTime : {
55 future : '%s sonra',
56 past : '%s əvvəl',
57 s : 'birneçə saniyyə',
58 m : 'bir dəqiqə',
59 mm : '%d dəqiqə',
60 h : 'bir saat',
61 hh : '%d saat',
62 d : 'bir gün',
63 dd : '%d gün',
64 M : 'bir ay',
65 MM : '%d ay',
66 y : 'bir il',
67 yy : '%d il'
68 },
69 meridiemParse: /gecə|səhər|gündüz|axşam/,
70 isPM : function (input) {
71 return /^(gündüz|axşam)$/.test(input);
72 },
73 meridiem : function (hour, minute, isLower) {
74 if (hour < 4) {
75 return 'gecə';
76 } else if (hour < 12) {
77 return 'səhər';
78 } else if (hour < 17) {
79 return 'gündüz';
80 } else {
81 return 'axşam';
82 }
83 },
84 ordinalParse: /\d{1,2}-(ıncı|inci|nci|üncü|ncı|uncu)/,
85 ordinal : function (number) {
86 if (number === 0) { // special case for zero
87 return number + '-ıncı';
88 }
89 var a = number % 10,
90 b = number % 100 - a,
91 c = number >= 100 ? 100 : null;
92 return number + (suffixes[a] || suffixes[b] || suffixes[c]);
93 },
94 week : {
95 dow : 1, // Monday is the first day of the week.
96 doy : 7 // The week that contains Jan 1st is the first week of the year.
97 }
98 });
99
100 return az;
101
102 }));
0 //! moment.js locale configuration
1 //! locale : belarusian (be)
2 //! author : Dmitry Demidov : https://github.com/demidov91
3 //! author: Praleska: http://praleska.pro/
4 //! Author : Menelion Elensúle : https://github.com/Oire
5
6 (function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
8 typeof define === 'function' && define.amd ? define(['moment'], factory) :
9 factory(global.moment)
10 }(this, function (moment) { 'use strict';
11
12
13 function plural(word, num) {
14 var forms = word.split('_');
15 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
16 }
17 function relativeTimeWithPlural(number, withoutSuffix, key) {
18 var format = {
19 'mm': withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін',
20 'hh': withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін',
21 'dd': 'дзень_дні_дзён',
22 'MM': 'месяц_месяцы_месяцаў',
23 'yy': 'год_гады_гадоў'
24 };
25 if (key === 'm') {
26 return withoutSuffix ? 'хвіліна' : 'хвіліну';
27 }
28 else if (key === 'h') {
29 return withoutSuffix ? 'гадзіна' : 'гадзіну';
30 }
31 else {
32 return number + ' ' + plural(format[key], +number);
33 }
34 }
35 function monthsCaseReplace(m, format) {
36 var months = {
37 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
38 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
39 },
40 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
41 'accusative' :
42 'nominative';
43 return months[nounCase][m.month()];
44 }
45 function weekdaysCaseReplace(m, format) {
46 var weekdays = {
47 'nominative': 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'),
48 'accusative': 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_')
49 },
50 nounCase = (/\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/).test(format) ?
51 'accusative' :
52 'nominative';
53 return weekdays[nounCase][m.day()];
54 }
55
56 var be = moment.defineLocale('be', {
57 months : monthsCaseReplace,
58 monthsShort : 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'),
59 weekdays : weekdaysCaseReplace,
60 weekdaysShort : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
61 weekdaysMin : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
62 longDateFormat : {
63 LT : 'HH:mm',
64 LTS : 'HH:mm:ss',
65 L : 'DD.MM.YYYY',
66 LL : 'D MMMM YYYY г.',
67 LLL : 'D MMMM YYYY г., HH:mm',
68 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
69 },
70 calendar : {
71 sameDay: '[Сёння ў] LT',
72 nextDay: '[Заўтра ў] LT',
73 lastDay: '[Учора ў] LT',
74 nextWeek: function () {
75 return '[У] dddd [ў] LT';
76 },
77 lastWeek: function () {
78 switch (this.day()) {
79 case 0:
80 case 3:
81 case 5:
82 case 6:
83 return '[У мінулую] dddd [ў] LT';
84 case 1:
85 case 2:
86 case 4:
87 return '[У мінулы] dddd [ў] LT';
88 }
89 },
90 sameElse: 'L'
91 },
92 relativeTime : {
93 future : 'праз %s',
94 past : '%s таму',
95 s : 'некалькі секунд',
96 m : relativeTimeWithPlural,
97 mm : relativeTimeWithPlural,
98 h : relativeTimeWithPlural,
99 hh : relativeTimeWithPlural,
100 d : 'дзень',
101 dd : relativeTimeWithPlural,
102 M : 'месяц',
103 MM : relativeTimeWithPlural,
104 y : 'год',
105 yy : relativeTimeWithPlural
106 },
107 meridiemParse: /ночы|раніцы|дня|вечара/,
108 isPM : function (input) {
109 return /^(дня|вечара)$/.test(input);
110 },
111 meridiem : function (hour, minute, isLower) {
112 if (hour < 4) {
113 return 'ночы';
114 } else if (hour < 12) {
115 return 'раніцы';
116 } else if (hour < 17) {
117 return 'дня';
118 } else {
119 return 'вечара';
120 }
121 },
122 ordinalParse: /\d{1,2}-(і|ы|га)/,
123 ordinal: function (number, period) {
124 switch (period) {
125 case 'M':
126 case 'd':
127 case 'DDD':
128 case 'w':
129 case 'W':
130 return (number % 10 === 2 || number % 10 === 3) && (number % 100 !== 12 && number % 100 !== 13) ? number + '-і' : number + '-ы';
131 case 'D':
132 return number + '-га';
133 default:
134 return number;
135 }
136 },
137 week : {
138 dow : 1, // Monday is the first day of the week.
139 doy : 7 // The week that contains Jan 1st is the first week of the year.
140 }
141 });
142
143 return be;
144
145 }));
0 //! moment.js locale configuration
1 //! locale : bulgarian (bg)
2 //! author : Krasen Borisov : https://github.com/kraz
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var bg = moment.defineLocale('bg', {
12 months : 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'.split('_'),
13 monthsShort : 'янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'.split('_'),
14 weekdays : 'неделя_понеделник_вторник_сряда_четвъртък_петък_събота'.split('_'),
15 weekdaysShort : 'нед_пон_вто_сря_чет_пет_съб'.split('_'),
16 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
17 longDateFormat : {
18 LT : 'H:mm',
19 LTS : 'H:mm:ss',
20 L : 'D.MM.YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY H:mm',
23 LLLL : 'dddd, D MMMM YYYY H:mm'
24 },
25 calendar : {
26 sameDay : '[Днес в] LT',
27 nextDay : '[Утре в] LT',
28 nextWeek : 'dddd [в] LT',
29 lastDay : '[Вчера в] LT',
30 lastWeek : function () {
31 switch (this.day()) {
32 case 0:
33 case 3:
34 case 6:
35 return '[В изминалата] dddd [в] LT';
36 case 1:
37 case 2:
38 case 4:
39 case 5:
40 return '[В изминалия] dddd [в] LT';
41 }
42 },
43 sameElse : 'L'
44 },
45 relativeTime : {
46 future : 'след %s',
47 past : 'преди %s',
48 s : 'няколко секунди',
49 m : 'минута',
50 mm : '%d минути',
51 h : 'час',
52 hh : '%d часа',
53 d : 'ден',
54 dd : '%d дни',
55 M : 'месец',
56 MM : '%d месеца',
57 y : 'година',
58 yy : '%d години'
59 },
60 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
61 ordinal : function (number) {
62 var lastDigit = number % 10,
63 last2Digits = number % 100;
64 if (number === 0) {
65 return number + '-ев';
66 } else if (last2Digits === 0) {
67 return number + '-ен';
68 } else if (last2Digits > 10 && last2Digits < 20) {
69 return number + '-ти';
70 } else if (lastDigit === 1) {
71 return number + '-ви';
72 } else if (lastDigit === 2) {
73 return number + '-ри';
74 } else if (lastDigit === 7 || lastDigit === 8) {
75 return number + '-ми';
76 } else {
77 return number + '-ти';
78 }
79 },
80 week : {
81 dow : 1, // Monday is the first day of the week.
82 doy : 7 // The week that contains Jan 1st is the first week of the year.
83 }
84 });
85
86 return bg;
87
88 }));
0 //! moment.js locale configuration
1 //! locale : Bengali (bn)
2 //! author : Kaushik Gandhi : https://github.com/kaushikgandhi
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '১',
13 '2': '২',
14 '3': '৩',
15 '4': '৪',
16 '5': '৫',
17 '6': '৬',
18 '7': '৭',
19 '8': '৮',
20 '9': '৯',
21 '0': '০'
22 },
23 numberMap = {
24 '১': '1',
25 '২': '2',
26 '৩': '3',
27 '৪': '4',
28 '৫': '5',
29 '৬': '6',
30 '৭': '7',
31 '৮': '8',
32 '৯': '9',
33 '০': '0'
34 };
35
36 var bn = moment.defineLocale('bn', {
37 months : 'জানুয়ারী_ফেবুয়ারী_মার্চ_এপ্রিল_মে_জুন_জুলাই_অগাস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'),
38 monthsShort : 'জানু_ফেব_মার্চ_এপর_মে_জুন_জুল_অগ_সেপ্ট_অক্টো_নভ_ডিসেম্'.split('_'),
39 weekdays : 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পত্তিবার_শুক্রুবার_শনিবার'.split('_'),
40 weekdaysShort : 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পত্তি_শুক্রু_শনি'.split('_'),
41 weekdaysMin : 'রব_সম_মঙ্গ_বু_ব্রিহ_শু_শনি'.split('_'),
42 longDateFormat : {
43 LT : 'A h:mm সময়',
44 LTS : 'A h:mm:ss সময়',
45 L : 'DD/MM/YYYY',
46 LL : 'D MMMM YYYY',
47 LLL : 'D MMMM YYYY, A h:mm সময়',
48 LLLL : 'dddd, D MMMM YYYY, A h:mm সময়'
49 },
50 calendar : {
51 sameDay : '[আজ] LT',
52 nextDay : '[আগামীকাল] LT',
53 nextWeek : 'dddd, LT',
54 lastDay : '[গতকাল] LT',
55 lastWeek : '[গত] dddd, LT',
56 sameElse : 'L'
57 },
58 relativeTime : {
59 future : '%s পরে',
60 past : '%s আগে',
61 s : 'কএক সেকেন্ড',
62 m : 'এক মিনিট',
63 mm : '%d মিনিট',
64 h : 'এক ঘন্টা',
65 hh : '%d ঘন্টা',
66 d : 'এক দিন',
67 dd : '%d দিন',
68 M : 'এক মাস',
69 MM : '%d মাস',
70 y : 'এক বছর',
71 yy : '%d বছর'
72 },
73 preparse: function (string) {
74 return string.replace(/[১২৩৪৫৬৭৮৯০]/g, function (match) {
75 return numberMap[match];
76 });
77 },
78 postformat: function (string) {
79 return string.replace(/\d/g, function (match) {
80 return symbolMap[match];
81 });
82 },
83 meridiemParse: /রাত|সকাল|দুপুর|বিকেল|রাত/,
84 isPM: function (input) {
85 return /^(দুপুর|বিকেল|রাত)$/.test(input);
86 },
87 //Bengali is a vast language its spoken
88 //in different forms in various parts of the world.
89 //I have just generalized with most common one used
90 meridiem : function (hour, minute, isLower) {
91 if (hour < 4) {
92 return 'রাত';
93 } else if (hour < 10) {
94 return 'সকাল';
95 } else if (hour < 17) {
96 return 'দুপুর';
97 } else if (hour < 20) {
98 return 'বিকেল';
99 } else {
100 return 'রাত';
101 }
102 },
103 week : {
104 dow : 0, // Sunday is the first day of the week.
105 doy : 6 // The week that contains Jan 1st is the first week of the year.
106 }
107 });
108
109 return bn;
110
111 }));
0 //! moment.js locale configuration
1 //! locale : tibetan (bo)
2 //! author : Thupten N. Chakrishar : https://github.com/vajradog
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '༡',
13 '2': '༢',
14 '3': '༣',
15 '4': '༤',
16 '5': '༥',
17 '6': '༦',
18 '7': '༧',
19 '8': '༨',
20 '9': '༩',
21 '0': '༠'
22 },
23 numberMap = {
24 '༡': '1',
25 '༢': '2',
26 '༣': '3',
27 '༤': '4',
28 '༥': '5',
29 '༦': '6',
30 '༧': '7',
31 '༨': '8',
32 '༩': '9',
33 '༠': '0'
34 };
35
36 var bo = moment.defineLocale('bo', {
37 months : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
38 monthsShort : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
39 weekdays : 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'),
40 weekdaysShort : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
41 weekdaysMin : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
42 longDateFormat : {
43 LT : 'A h:mm',
44 LTS : 'A h:mm:ss',
45 L : 'DD/MM/YYYY',
46 LL : 'D MMMM YYYY',
47 LLL : 'D MMMM YYYY, A h:mm',
48 LLLL : 'dddd, D MMMM YYYY, A h:mm'
49 },
50 calendar : {
51 sameDay : '[དི་རིང] LT',
52 nextDay : '[སང་ཉིན] LT',
53 nextWeek : '[བདུན་ཕྲག་རྗེས་མ], LT',
54 lastDay : '[ཁ་སང] LT',
55 lastWeek : '[བདུན་ཕྲག་མཐའ་མ] dddd, LT',
56 sameElse : 'L'
57 },
58 relativeTime : {
59 future : '%s ལ་',
60 past : '%s སྔན་ལ',
61 s : 'ལམ་སང',
62 m : 'སྐར་མ་གཅིག',
63 mm : '%d སྐར་མ',
64 h : 'ཆུ་ཚོད་གཅིག',
65 hh : '%d ཆུ་ཚོད',
66 d : 'ཉིན་གཅིག',
67 dd : '%d ཉིན་',
68 M : 'ཟླ་བ་གཅིག',
69 MM : '%d ཟླ་བ',
70 y : 'ལོ་གཅིག',
71 yy : '%d ལོ'
72 },
73 preparse: function (string) {
74 return string.replace(/[༡༢༣༤༥༦༧༨༩༠]/g, function (match) {
75 return numberMap[match];
76 });
77 },
78 postformat: function (string) {
79 return string.replace(/\d/g, function (match) {
80 return symbolMap[match];
81 });
82 },
83 meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
84 isPM: function (input) {
85 return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
86 },
87 meridiem : function (hour, minute, isLower) {
88 if (hour < 4) {
89 return 'མཚན་མོ';
90 } else if (hour < 10) {
91 return 'ཞོགས་ཀས';
92 } else if (hour < 17) {
93 return 'ཉིན་གུང';
94 } else if (hour < 20) {
95 return 'དགོང་དག';
96 } else {
97 return 'མཚན་མོ';
98 }
99 },
100 week : {
101 dow : 0, // Sunday is the first day of the week.
102 doy : 6 // The week that contains Jan 1st is the first week of the year.
103 }
104 });
105
106 return bo;
107
108 }));
0 //! moment.js locale configuration
1 //! locale : breton (br)
2 //! author : Jean-Baptiste Le Duigou : https://github.com/jbleduigou
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 function relativeTimeWithMutation(number, withoutSuffix, key) {
12 var format = {
13 'mm': 'munutenn',
14 'MM': 'miz',
15 'dd': 'devezh'
16 };
17 return number + ' ' + mutation(format[key], number);
18 }
19 function specialMutationForYears(number) {
20 switch (lastNumber(number)) {
21 case 1:
22 case 3:
23 case 4:
24 case 5:
25 case 9:
26 return number + ' bloaz';
27 default:
28 return number + ' vloaz';
29 }
30 }
31 function lastNumber(number) {
32 if (number > 9) {
33 return lastNumber(number % 10);
34 }
35 return number;
36 }
37 function mutation(text, number) {
38 if (number === 2) {
39 return softMutation(text);
40 }
41 return text;
42 }
43 function softMutation(text) {
44 var mutationTable = {
45 'm': 'v',
46 'b': 'v',
47 'd': 'z'
48 };
49 if (mutationTable[text.charAt(0)] === undefined) {
50 return text;
51 }
52 return mutationTable[text.charAt(0)] + text.substring(1);
53 }
54
55 var br = moment.defineLocale('br', {
56 months : 'Genver_C\'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'),
57 monthsShort : 'Gen_C\'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'),
58 weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
59 weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
60 weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
61 longDateFormat : {
62 LT : 'h[e]mm A',
63 LTS : 'h[e]mm:ss A',
64 L : 'DD/MM/YYYY',
65 LL : 'D [a viz] MMMM YYYY',
66 LLL : 'D [a viz] MMMM YYYY h[e]mm A',
67 LLLL : 'dddd, D [a viz] MMMM YYYY h[e]mm A'
68 },
69 calendar : {
70 sameDay : '[Hiziv da] LT',
71 nextDay : '[Warc\'hoazh da] LT',
72 nextWeek : 'dddd [da] LT',
73 lastDay : '[Dec\'h da] LT',
74 lastWeek : 'dddd [paset da] LT',
75 sameElse : 'L'
76 },
77 relativeTime : {
78 future : 'a-benn %s',
79 past : '%s \'zo',
80 s : 'un nebeud segondennoù',
81 m : 'ur vunutenn',
82 mm : relativeTimeWithMutation,
83 h : 'un eur',
84 hh : '%d eur',
85 d : 'un devezh',
86 dd : relativeTimeWithMutation,
87 M : 'ur miz',
88 MM : relativeTimeWithMutation,
89 y : 'ur bloaz',
90 yy : specialMutationForYears
91 },
92 ordinalParse: /\d{1,2}(añ|vet)/,
93 ordinal : function (number) {
94 var output = (number === 1) ? 'añ' : 'vet';
95 return number + output;
96 },
97 week : {
98 dow : 1, // Monday is the first day of the week.
99 doy : 4 // The week that contains Jan 4th is the first week of the year.
100 }
101 });
102
103 return br;
104
105 }));
0 //! moment.js locale configuration
1 //! locale : bosnian (bs)
2 //! author : Nedim Cholich : https://github.com/frontyard
3 //! based on (hr) translation by Bojan Marković
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 function translate(number, withoutSuffix, key) {
13 var result = number + ' ';
14 switch (key) {
15 case 'm':
16 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
17 case 'mm':
18 if (number === 1) {
19 result += 'minuta';
20 } else if (number === 2 || number === 3 || number === 4) {
21 result += 'minute';
22 } else {
23 result += 'minuta';
24 }
25 return result;
26 case 'h':
27 return withoutSuffix ? 'jedan sat' : 'jednog sata';
28 case 'hh':
29 if (number === 1) {
30 result += 'sat';
31 } else if (number === 2 || number === 3 || number === 4) {
32 result += 'sata';
33 } else {
34 result += 'sati';
35 }
36 return result;
37 case 'dd':
38 if (number === 1) {
39 result += 'dan';
40 } else {
41 result += 'dana';
42 }
43 return result;
44 case 'MM':
45 if (number === 1) {
46 result += 'mjesec';
47 } else if (number === 2 || number === 3 || number === 4) {
48 result += 'mjeseca';
49 } else {
50 result += 'mjeseci';
51 }
52 return result;
53 case 'yy':
54 if (number === 1) {
55 result += 'godina';
56 } else if (number === 2 || number === 3 || number === 4) {
57 result += 'godine';
58 } else {
59 result += 'godina';
60 }
61 return result;
62 }
63 }
64
65 var bs = moment.defineLocale('bs', {
66 months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
67 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
68 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
69 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
70 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
71 longDateFormat : {
72 LT : 'H:mm',
73 LTS : 'H:mm:ss',
74 L : 'DD. MM. YYYY',
75 LL : 'D. MMMM YYYY',
76 LLL : 'D. MMMM YYYY H:mm',
77 LLLL : 'dddd, D. MMMM YYYY H:mm'
78 },
79 calendar : {
80 sameDay : '[danas u] LT',
81 nextDay : '[sutra u] LT',
82 nextWeek : function () {
83 switch (this.day()) {
84 case 0:
85 return '[u] [nedjelju] [u] LT';
86 case 3:
87 return '[u] [srijedu] [u] LT';
88 case 6:
89 return '[u] [subotu] [u] LT';
90 case 1:
91 case 2:
92 case 4:
93 case 5:
94 return '[u] dddd [u] LT';
95 }
96 },
97 lastDay : '[jučer u] LT',
98 lastWeek : function () {
99 switch (this.day()) {
100 case 0:
101 case 3:
102 return '[prošlu] dddd [u] LT';
103 case 6:
104 return '[prošle] [subote] [u] LT';
105 case 1:
106 case 2:
107 case 4:
108 case 5:
109 return '[prošli] dddd [u] LT';
110 }
111 },
112 sameElse : 'L'
113 },
114 relativeTime : {
115 future : 'za %s',
116 past : 'prije %s',
117 s : 'par sekundi',
118 m : translate,
119 mm : translate,
120 h : translate,
121 hh : translate,
122 d : 'dan',
123 dd : translate,
124 M : 'mjesec',
125 MM : translate,
126 y : 'godinu',
127 yy : translate
128 },
129 ordinalParse: /\d{1,2}\./,
130 ordinal : '%d.',
131 week : {
132 dow : 1, // Monday is the first day of the week.
133 doy : 7 // The week that contains Jan 1st is the first week of the year.
134 }
135 });
136
137 return bs;
138
139 }));
0 //! moment.js locale configuration
1 //! locale : catalan (ca)
2 //! author : Juan G. Hurtado : https://github.com/juanghurtado
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var ca = moment.defineLocale('ca', {
12 months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
13 monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
14 weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
15 weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
16 weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
17 longDateFormat : {
18 LT : 'H:mm',
19 LTS : 'LT:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY H:mm',
23 LLLL : 'dddd D MMMM YYYY H:mm'
24 },
25 calendar : {
26 sameDay : function () {
27 return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
28 },
29 nextDay : function () {
30 return '[demà a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
31 },
32 nextWeek : function () {
33 return 'dddd [a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
34 },
35 lastDay : function () {
36 return '[ahir a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
37 },
38 lastWeek : function () {
39 return '[el] dddd [passat a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
40 },
41 sameElse : 'L'
42 },
43 relativeTime : {
44 future : 'en %s',
45 past : 'fa %s',
46 s : 'uns segons',
47 m : 'un minut',
48 mm : '%d minuts',
49 h : 'una hora',
50 hh : '%d hores',
51 d : 'un dia',
52 dd : '%d dies',
53 M : 'un mes',
54 MM : '%d mesos',
55 y : 'un any',
56 yy : '%d anys'
57 },
58 ordinalParse: /\d{1,2}(r|n|t|è|a)/,
59 ordinal : function (number, period) {
60 var output = (number === 1) ? 'r' :
61 (number === 2) ? 'n' :
62 (number === 3) ? 'r' :
63 (number === 4) ? 't' : 'è';
64 if (period === 'w' || period === 'W') {
65 output = 'a';
66 }
67 return number + output;
68 },
69 week : {
70 dow : 1, // Monday is the first day of the week.
71 doy : 4 // The week that contains Jan 4th is the first week of the year.
72 }
73 });
74
75 return ca;
76
77 }));
0 //! moment.js locale configuration
1 //! locale : czech (cs)
2 //! author : petrbela : https://github.com/petrbela
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var months = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_'),
12 monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_');
13 function plural(n) {
14 return (n > 1) && (n < 5) && (~~(n / 10) !== 1);
15 }
16 function translate(number, withoutSuffix, key, isFuture) {
17 var result = number + ' ';
18 switch (key) {
19 case 's': // a few seconds / in a few seconds / a few seconds ago
20 return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
21 case 'm': // a minute / in a minute / a minute ago
22 return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
23 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
24 if (withoutSuffix || isFuture) {
25 return result + (plural(number) ? 'minuty' : 'minut');
26 } else {
27 return result + 'minutami';
28 }
29 break;
30 case 'h': // an hour / in an hour / an hour ago
31 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
32 case 'hh': // 9 hours / in 9 hours / 9 hours ago
33 if (withoutSuffix || isFuture) {
34 return result + (plural(number) ? 'hodiny' : 'hodin');
35 } else {
36 return result + 'hodinami';
37 }
38 break;
39 case 'd': // a day / in a day / a day ago
40 return (withoutSuffix || isFuture) ? 'den' : 'dnem';
41 case 'dd': // 9 days / in 9 days / 9 days ago
42 if (withoutSuffix || isFuture) {
43 return result + (plural(number) ? 'dny' : 'dní');
44 } else {
45 return result + 'dny';
46 }
47 break;
48 case 'M': // a month / in a month / a month ago
49 return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
50 case 'MM': // 9 months / in 9 months / 9 months ago
51 if (withoutSuffix || isFuture) {
52 return result + (plural(number) ? 'měsíce' : 'měsíců');
53 } else {
54 return result + 'měsíci';
55 }
56 break;
57 case 'y': // a year / in a year / a year ago
58 return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
59 case 'yy': // 9 years / in 9 years / 9 years ago
60 if (withoutSuffix || isFuture) {
61 return result + (plural(number) ? 'roky' : 'let');
62 } else {
63 return result + 'lety';
64 }
65 break;
66 }
67 }
68
69 var cs = moment.defineLocale('cs', {
70 months : months,
71 monthsShort : monthsShort,
72 monthsParse : (function (months, monthsShort) {
73 var i, _monthsParse = [];
74 for (i = 0; i < 12; i++) {
75 // use custom parser to solve problem with July (červenec)
76 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
77 }
78 return _monthsParse;
79 }(months, monthsShort)),
80 weekdays : 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
81 weekdaysShort : 'ne_po_út_st_čt_pá_so'.split('_'),
82 weekdaysMin : 'ne_po_út_st_čt_pá_so'.split('_'),
83 longDateFormat : {
84 LT: 'H:mm',
85 LTS : 'H:mm:ss',
86 L : 'DD.MM.YYYY',
87 LL : 'D. MMMM YYYY',
88 LLL : 'D. MMMM YYYY H:mm',
89 LLLL : 'dddd D. MMMM YYYY H:mm'
90 },
91 calendar : {
92 sameDay: '[dnes v] LT',
93 nextDay: '[zítra v] LT',
94 nextWeek: function () {
95 switch (this.day()) {
96 case 0:
97 return '[v neděli v] LT';
98 case 1:
99 case 2:
100 return '[v] dddd [v] LT';
101 case 3:
102 return '[ve středu v] LT';
103 case 4:
104 return '[ve čtvrtek v] LT';
105 case 5:
106 return '[v pátek v] LT';
107 case 6:
108 return '[v sobotu v] LT';
109 }
110 },
111 lastDay: '[včera v] LT',
112 lastWeek: function () {
113 switch (this.day()) {
114 case 0:
115 return '[minulou neděli v] LT';
116 case 1:
117 case 2:
118 return '[minulé] dddd [v] LT';
119 case 3:
120 return '[minulou středu v] LT';
121 case 4:
122 case 5:
123 return '[minulý] dddd [v] LT';
124 case 6:
125 return '[minulou sobotu v] LT';
126 }
127 },
128 sameElse: 'L'
129 },
130 relativeTime : {
131 future : 'za %s',
132 past : 'před %s',
133 s : translate,
134 m : translate,
135 mm : translate,
136 h : translate,
137 hh : translate,
138 d : translate,
139 dd : translate,
140 M : translate,
141 MM : translate,
142 y : translate,
143 yy : translate
144 },
145 ordinalParse : /\d{1,2}\./,
146 ordinal : '%d.',
147 week : {
148 dow : 1, // Monday is the first day of the week.
149 doy : 4 // The week that contains Jan 4th is the first week of the year.
150 }
151 });
152
153 return cs;
154
155 }));
0 //! moment.js locale configuration
1 //! locale : chuvash (cv)
2 //! author : Anatoly Mironov : https://github.com/mirontoli
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var cv = moment.defineLocale('cv', {
12 months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
13 monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
14 weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
15 weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
16 weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD-MM-YYYY',
21 LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
22 LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm',
23 LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm'
24 },
25 calendar : {
26 sameDay: '[Паян] LT [сехетре]',
27 nextDay: '[Ыран] LT [сехетре]',
28 lastDay: '[Ӗнер] LT [сехетре]',
29 nextWeek: '[Ҫитес] dddd LT [сехетре]',
30 lastWeek: '[Иртнӗ] dddd LT [сехетре]',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : function (output) {
35 var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
36 return output + affix;
37 },
38 past : '%s каялла',
39 s : 'пӗр-ик ҫеккунт',
40 m : 'пӗр минут',
41 mm : '%d минут',
42 h : 'пӗр сехет',
43 hh : '%d сехет',
44 d : 'пӗр кун',
45 dd : '%d кун',
46 M : 'пӗр уйӑх',
47 MM : '%d уйӑх',
48 y : 'пӗр ҫул',
49 yy : '%d ҫул'
50 },
51 ordinalParse: /\d{1,2}-мӗш/,
52 ordinal : '%d-мӗш',
53 week : {
54 dow : 1, // Monday is the first day of the week.
55 doy : 7 // The week that contains Jan 1st is the first week of the year.
56 }
57 });
58
59 return cv;
60
61 }));
0 //! moment.js locale configuration
1 //! locale : Welsh (cy)
2 //! author : Robert Allen
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var cy = moment.defineLocale('cy', {
12 months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'),
13 monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'),
14 weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
15 weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
16 weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
17 // time formats are the same as en-gb
18 longDateFormat: {
19 LT: 'HH:mm',
20 LTS : 'HH:mm:ss',
21 L: 'DD/MM/YYYY',
22 LL: 'D MMMM YYYY',
23 LLL: 'D MMMM YYYY HH:mm',
24 LLLL: 'dddd, D MMMM YYYY HH:mm'
25 },
26 calendar: {
27 sameDay: '[Heddiw am] LT',
28 nextDay: '[Yfory am] LT',
29 nextWeek: 'dddd [am] LT',
30 lastDay: '[Ddoe am] LT',
31 lastWeek: 'dddd [diwethaf am] LT',
32 sameElse: 'L'
33 },
34 relativeTime: {
35 future: 'mewn %s',
36 past: '%s yn ôl',
37 s: 'ychydig eiliadau',
38 m: 'munud',
39 mm: '%d munud',
40 h: 'awr',
41 hh: '%d awr',
42 d: 'diwrnod',
43 dd: '%d diwrnod',
44 M: 'mis',
45 MM: '%d mis',
46 y: 'blwyddyn',
47 yy: '%d flynedd'
48 },
49 ordinalParse: /\d{1,2}(fed|ain|af|il|ydd|ed|eg)/,
50 // traditional ordinal numbers above 31 are not commonly used in colloquial Welsh
51 ordinal: function (number) {
52 var b = number,
53 output = '',
54 lookup = [
55 '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed
56 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed
57 ];
58 if (b > 20) {
59 if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) {
60 output = 'fed'; // not 30ain, 70ain or 90ain
61 } else {
62 output = 'ain';
63 }
64 } else if (b > 0) {
65 output = lookup[b];
66 }
67 return number + output;
68 },
69 week : {
70 dow : 1, // Monday is the first day of the week.
71 doy : 4 // The week that contains Jan 4th is the first week of the year.
72 }
73 });
74
75 return cy;
76
77 }));
0 //! moment.js locale configuration
1 //! locale : danish (da)
2 //! author : Ulrik Nielsen : https://github.com/mrbase
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var da = moment.defineLocale('da', {
12 months : 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'),
13 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
14 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
15 weekdaysShort : 'søn_man_tir_ons_tor_fre_lør'.split('_'),
16 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D. MMMM YYYY',
22 LLL : 'D. MMMM YYYY HH:mm',
23 LLLL : 'dddd [d.] D. MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay : '[I dag kl.] LT',
27 nextDay : '[I morgen kl.] LT',
28 nextWeek : 'dddd [kl.] LT',
29 lastDay : '[I går kl.] LT',
30 lastWeek : '[sidste] dddd [kl] LT',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : 'om %s',
35 past : '%s siden',
36 s : 'få sekunder',
37 m : 'et minut',
38 mm : '%d minutter',
39 h : 'en time',
40 hh : '%d timer',
41 d : 'en dag',
42 dd : '%d dage',
43 M : 'en måned',
44 MM : '%d måneder',
45 y : 'et år',
46 yy : '%d år'
47 },
48 ordinalParse: /\d{1,2}\./,
49 ordinal : '%d.',
50 week : {
51 dow : 1, // Monday is the first day of the week.
52 doy : 4 // The week that contains Jan 4th is the first week of the year.
53 }
54 });
55
56 return da;
57
58 }));
0 //! moment.js locale configuration
1 //! locale : austrian german (de-at)
2 //! author : lluchs : https://github.com/lluchs
3 //! author: Menelion Elensúle: https://github.com/Oire
4 //! author : Martin Groller : https://github.com/MadMG
5
6 (function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
8 typeof define === 'function' && define.amd ? define(['moment'], factory) :
9 factory(global.moment)
10 }(this, function (moment) { 'use strict';
11
12
13 function processRelativeTime(number, withoutSuffix, key, isFuture) {
14 var format = {
15 'm': ['eine Minute', 'einer Minute'],
16 'h': ['eine Stunde', 'einer Stunde'],
17 'd': ['ein Tag', 'einem Tag'],
18 'dd': [number + ' Tage', number + ' Tagen'],
19 'M': ['ein Monat', 'einem Monat'],
20 'MM': [number + ' Monate', number + ' Monaten'],
21 'y': ['ein Jahr', 'einem Jahr'],
22 'yy': [number + ' Jahre', number + ' Jahren']
23 };
24 return withoutSuffix ? format[key][0] : format[key][1];
25 }
26
27 var de_at = moment.defineLocale('de-at', {
28 months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
29 monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
30 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
31 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
32 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
33 longDateFormat : {
34 LT: 'HH:mm',
35 LTS: 'HH:mm:ss',
36 L : 'DD.MM.YYYY',
37 LL : 'D. MMMM YYYY',
38 LLL : 'D. MMMM YYYY HH:mm',
39 LLLL : 'dddd, D. MMMM YYYY HH:mm'
40 },
41 calendar : {
42 sameDay: '[Heute um] LT [Uhr]',
43 sameElse: 'L',
44 nextDay: '[Morgen um] LT [Uhr]',
45 nextWeek: 'dddd [um] LT [Uhr]',
46 lastDay: '[Gestern um] LT [Uhr]',
47 lastWeek: '[letzten] dddd [um] LT [Uhr]'
48 },
49 relativeTime : {
50 future : 'in %s',
51 past : 'vor %s',
52 s : 'ein paar Sekunden',
53 m : processRelativeTime,
54 mm : '%d Minuten',
55 h : processRelativeTime,
56 hh : '%d Stunden',
57 d : processRelativeTime,
58 dd : processRelativeTime,
59 M : processRelativeTime,
60 MM : processRelativeTime,
61 y : processRelativeTime,
62 yy : processRelativeTime
63 },
64 ordinalParse: /\d{1,2}\./,
65 ordinal : '%d.',
66 week : {
67 dow : 1, // Monday is the first day of the week.
68 doy : 4 // The week that contains Jan 4th is the first week of the year.
69 }
70 });
71
72 return de_at;
73
74 }));
0 //! moment.js locale configuration
1 //! locale : german (de)
2 //! author : lluchs : https://github.com/lluchs
3 //! author: Menelion Elensúle: https://github.com/Oire
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 function processRelativeTime(number, withoutSuffix, key, isFuture) {
13 var format = {
14 'm': ['eine Minute', 'einer Minute'],
15 'h': ['eine Stunde', 'einer Stunde'],
16 'd': ['ein Tag', 'einem Tag'],
17 'dd': [number + ' Tage', number + ' Tagen'],
18 'M': ['ein Monat', 'einem Monat'],
19 'MM': [number + ' Monate', number + ' Monaten'],
20 'y': ['ein Jahr', 'einem Jahr'],
21 'yy': [number + ' Jahre', number + ' Jahren']
22 };
23 return withoutSuffix ? format[key][0] : format[key][1];
24 }
25
26 var de = moment.defineLocale('de', {
27 months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
28 monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
29 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
30 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
31 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
32 longDateFormat : {
33 LT: 'HH:mm',
34 LTS: 'HH:mm:ss',
35 L : 'DD.MM.YYYY',
36 LL : 'D. MMMM YYYY',
37 LLL : 'D. MMMM YYYY HH:mm',
38 LLLL : 'dddd, D. MMMM YYYY HH:mm'
39 },
40 calendar : {
41 sameDay: '[Heute um] LT [Uhr]',
42 sameElse: 'L',
43 nextDay: '[Morgen um] LT [Uhr]',
44 nextWeek: 'dddd [um] LT [Uhr]',
45 lastDay: '[Gestern um] LT [Uhr]',
46 lastWeek: '[letzten] dddd [um] LT [Uhr]'
47 },
48 relativeTime : {
49 future : 'in %s',
50 past : 'vor %s',
51 s : 'ein paar Sekunden',
52 m : processRelativeTime,
53 mm : '%d Minuten',
54 h : processRelativeTime,
55 hh : '%d Stunden',
56 d : processRelativeTime,
57 dd : processRelativeTime,
58 M : processRelativeTime,
59 MM : processRelativeTime,
60 y : processRelativeTime,
61 yy : processRelativeTime
62 },
63 ordinalParse: /\d{1,2}\./,
64 ordinal : '%d.',
65 week : {
66 dow : 1, // Monday is the first day of the week.
67 doy : 4 // The week that contains Jan 4th is the first week of the year.
68 }
69 });
70
71 return de;
72
73 }));
0 //! moment.js locale configuration
1 //! locale : modern greek (el)
2 //! author : Aggelos Karalias : https://github.com/mehiel
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var el = moment.defineLocale('el', {
12 monthsNominativeEl : 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'),
13 monthsGenitiveEl : 'Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου'.split('_'),
14 months : function (momentToFormat, format) {
15 if (/D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
16 return this._monthsGenitiveEl[momentToFormat.month()];
17 } else {
18 return this._monthsNominativeEl[momentToFormat.month()];
19 }
20 },
21 monthsShort : 'Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ'.split('_'),
22 weekdays : 'Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο'.split('_'),
23 weekdaysShort : 'Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ'.split('_'),
24 weekdaysMin : 'Κυ_Δε_Τρ_Τε_Πε_Πα_Σα'.split('_'),
25 meridiem : function (hours, minutes, isLower) {
26 if (hours > 11) {
27 return isLower ? 'μμ' : 'ΜΜ';
28 } else {
29 return isLower ? 'πμ' : 'ΠΜ';
30 }
31 },
32 isPM : function (input) {
33 return ((input + '').toLowerCase()[0] === 'μ');
34 },
35 meridiemParse : /[ΠΜ]\.?Μ?\.?/i,
36 longDateFormat : {
37 LT : 'h:mm A',
38 LTS : 'h:mm:ss A',
39 L : 'DD/MM/YYYY',
40 LL : 'D MMMM YYYY',
41 LLL : 'D MMMM YYYY h:mm A',
42 LLLL : 'dddd, D MMMM YYYY h:mm A'
43 },
44 calendarEl : {
45 sameDay : '[Σήμερα {}] LT',
46 nextDay : '[Αύριο {}] LT',
47 nextWeek : 'dddd [{}] LT',
48 lastDay : '[Χθες {}] LT',
49 lastWeek : function () {
50 switch (this.day()) {
51 case 6:
52 return '[το προηγούμενο] dddd [{}] LT';
53 default:
54 return '[την προηγούμενη] dddd [{}] LT';
55 }
56 },
57 sameElse : 'L'
58 },
59 calendar : function (key, mom) {
60 var output = this._calendarEl[key],
61 hours = mom && mom.hours();
62 if (typeof output === 'function') {
63 output = output.apply(mom);
64 }
65 return output.replace('{}', (hours % 12 === 1 ? 'στη' : 'στις'));
66 },
67 relativeTime : {
68 future : 'σε %s',
69 past : '%s πριν',
70 s : 'λίγα δευτερόλεπτα',
71 m : 'ένα λεπτό',
72 mm : '%d λεπτά',
73 h : 'μία ώρα',
74 hh : '%d ώρες',
75 d : 'μία μέρα',
76 dd : '%d μέρες',
77 M : 'ένας μήνας',
78 MM : '%d μήνες',
79 y : 'ένας χρόνος',
80 yy : '%d χρόνια'
81 },
82 ordinalParse: /\d{1,2}η/,
83 ordinal: '%dη',
84 week : {
85 dow : 1, // Monday is the first day of the week.
86 doy : 4 // The week that contains Jan 4st is the first week of the year.
87 }
88 });
89
90 return el;
91
92 }));
0 //! moment.js locale configuration
1 //! locale : australian english (en-au)
2
3 (function (global, factory) {
4 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
5 typeof define === 'function' && define.amd ? define(['moment'], factory) :
6 factory(global.moment)
7 }(this, function (moment) { 'use strict';
8
9
10 var en_au = moment.defineLocale('en-au', {
11 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
12 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
13 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
14 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
15 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
16 longDateFormat : {
17 LT : 'h:mm A',
18 LTS : 'h:mm:ss A',
19 L : 'DD/MM/YYYY',
20 LL : 'D MMMM YYYY',
21 LLL : 'D MMMM YYYY h:mm A',
22 LLLL : 'dddd, D MMMM YYYY h:mm A'
23 },
24 calendar : {
25 sameDay : '[Today at] LT',
26 nextDay : '[Tomorrow at] LT',
27 nextWeek : 'dddd [at] LT',
28 lastDay : '[Yesterday at] LT',
29 lastWeek : '[Last] dddd [at] LT',
30 sameElse : 'L'
31 },
32 relativeTime : {
33 future : 'in %s',
34 past : '%s ago',
35 s : 'a few seconds',
36 m : 'a minute',
37 mm : '%d minutes',
38 h : 'an hour',
39 hh : '%d hours',
40 d : 'a day',
41 dd : '%d days',
42 M : 'a month',
43 MM : '%d months',
44 y : 'a year',
45 yy : '%d years'
46 },
47 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
48 ordinal : function (number) {
49 var b = number % 10,
50 output = (~~(number % 100 / 10) === 1) ? 'th' :
51 (b === 1) ? 'st' :
52 (b === 2) ? 'nd' :
53 (b === 3) ? 'rd' : 'th';
54 return number + output;
55 },
56 week : {
57 dow : 1, // Monday is the first day of the week.
58 doy : 4 // The week that contains Jan 4th is the first week of the year.
59 }
60 });
61
62 return en_au;
63
64 }));
0 //! moment.js locale configuration
1 //! locale : canadian english (en-ca)
2 //! author : Jonathan Abourbih : https://github.com/jonbca
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var en_ca = moment.defineLocale('en-ca', {
12 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
13 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
14 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
15 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
16 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
17 longDateFormat : {
18 LT : 'h:mm A',
19 LTS : 'h:mm:ss A',
20 L : 'YYYY-MM-DD',
21 LL : 'D MMMM, YYYY',
22 LLL : 'D MMMM, YYYY h:mm A',
23 LLLL : 'dddd, D MMMM, YYYY h:mm A'
24 },
25 calendar : {
26 sameDay : '[Today at] LT',
27 nextDay : '[Tomorrow at] LT',
28 nextWeek : 'dddd [at] LT',
29 lastDay : '[Yesterday at] LT',
30 lastWeek : '[Last] dddd [at] LT',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : 'in %s',
35 past : '%s ago',
36 s : 'a few seconds',
37 m : 'a minute',
38 mm : '%d minutes',
39 h : 'an hour',
40 hh : '%d hours',
41 d : 'a day',
42 dd : '%d days',
43 M : 'a month',
44 MM : '%d months',
45 y : 'a year',
46 yy : '%d years'
47 },
48 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
49 ordinal : function (number) {
50 var b = number % 10,
51 output = (~~(number % 100 / 10) === 1) ? 'th' :
52 (b === 1) ? 'st' :
53 (b === 2) ? 'nd' :
54 (b === 3) ? 'rd' : 'th';
55 return number + output;
56 }
57 });
58
59 return en_ca;
60
61 }));
0 //! moment.js locale configuration
1 //! locale : great britain english (en-gb)
2 //! author : Chris Gedrim : https://github.com/chrisgedrim
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var en_gb = moment.defineLocale('en-gb', {
12 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
13 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
14 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
15 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
16 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd, D MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay : '[Today at] LT',
27 nextDay : '[Tomorrow at] LT',
28 nextWeek : 'dddd [at] LT',
29 lastDay : '[Yesterday at] LT',
30 lastWeek : '[Last] dddd [at] LT',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : 'in %s',
35 past : '%s ago',
36 s : 'a few seconds',
37 m : 'a minute',
38 mm : '%d minutes',
39 h : 'an hour',
40 hh : '%d hours',
41 d : 'a day',
42 dd : '%d days',
43 M : 'a month',
44 MM : '%d months',
45 y : 'a year',
46 yy : '%d years'
47 },
48 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
49 ordinal : function (number) {
50 var b = number % 10,
51 output = (~~(number % 100 / 10) === 1) ? 'th' :
52 (b === 1) ? 'st' :
53 (b === 2) ? 'nd' :
54 (b === 3) ? 'rd' : 'th';
55 return number + output;
56 },
57 week : {
58 dow : 1, // Monday is the first day of the week.
59 doy : 4 // The week that contains Jan 4th is the first week of the year.
60 }
61 });
62
63 return en_gb;
64
65 }));
0 //! moment.js locale configuration
1 //! locale : esperanto (eo)
2 //! author : Colin Dean : https://github.com/colindean
3 //! komento: Mi estas malcerta se mi korekte traktis akuzativojn en tiu traduko.
4 //! Se ne, bonvolu korekti kaj avizi min por ke mi povas lerni!
5
6 (function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
8 typeof define === 'function' && define.amd ? define(['moment'], factory) :
9 factory(global.moment)
10 }(this, function (moment) { 'use strict';
11
12
13 var eo = moment.defineLocale('eo', {
14 months : 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'),
15 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'),
16 weekdays : 'Dimanĉo_Lundo_Mardo_Merkredo_Ĵaŭdo_Vendredo_Sabato'.split('_'),
17 weekdaysShort : 'Dim_Lun_Mard_Merk_Ĵaŭ_Ven_Sab'.split('_'),
18 weekdaysMin : 'Di_Lu_Ma_Me_Ĵa_Ve_Sa'.split('_'),
19 longDateFormat : {
20 LT : 'HH:mm',
21 LTS : 'HH:mm:ss',
22 L : 'YYYY-MM-DD',
23 LL : 'D[-an de] MMMM, YYYY',
24 LLL : 'D[-an de] MMMM, YYYY HH:mm',
25 LLLL : 'dddd, [la] D[-an de] MMMM, YYYY HH:mm'
26 },
27 meridiemParse: /[ap]\.t\.m/i,
28 isPM: function (input) {
29 return input.charAt(0).toLowerCase() === 'p';
30 },
31 meridiem : function (hours, minutes, isLower) {
32 if (hours > 11) {
33 return isLower ? 'p.t.m.' : 'P.T.M.';
34 } else {
35 return isLower ? 'a.t.m.' : 'A.T.M.';
36 }
37 },
38 calendar : {
39 sameDay : '[Hodiaŭ je] LT',
40 nextDay : '[Morgaŭ je] LT',
41 nextWeek : 'dddd [je] LT',
42 lastDay : '[Hieraŭ je] LT',
43 lastWeek : '[pasinta] dddd [je] LT',
44 sameElse : 'L'
45 },
46 relativeTime : {
47 future : 'je %s',
48 past : 'antaŭ %s',
49 s : 'sekundoj',
50 m : 'minuto',
51 mm : '%d minutoj',
52 h : 'horo',
53 hh : '%d horoj',
54 d : 'tago',//ne 'diurno', ĉar estas uzita por proksimumo
55 dd : '%d tagoj',
56 M : 'monato',
57 MM : '%d monatoj',
58 y : 'jaro',
59 yy : '%d jaroj'
60 },
61 ordinalParse: /\d{1,2}a/,
62 ordinal : '%da',
63 week : {
64 dow : 1, // Monday is the first day of the week.
65 doy : 7 // The week that contains Jan 1st is the first week of the year.
66 }
67 });
68
69 return eo;
70
71 }));
0 //! moment.js locale configuration
1 //! locale : spanish (es)
2 //! author : Julio Napurí : https://github.com/julionc
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var monthsShortDot = 'Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.'.split('_'),
12 monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
13
14 var es = moment.defineLocale('es', {
15 months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
16 monthsShort : function (m, format) {
17 if (/-MMM-/.test(format)) {
18 return monthsShort[m.month()];
19 } else {
20 return monthsShortDot[m.month()];
21 }
22 },
23 weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
24 weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
25 weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
26 longDateFormat : {
27 LT : 'H:mm',
28 LTS : 'H:mm:ss',
29 L : 'DD/MM/YYYY',
30 LL : 'D [de] MMMM [de] YYYY',
31 LLL : 'D [de] MMMM [de] YYYY H:mm',
32 LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
33 },
34 calendar : {
35 sameDay : function () {
36 return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
37 },
38 nextDay : function () {
39 return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
40 },
41 nextWeek : function () {
42 return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
43 },
44 lastDay : function () {
45 return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
46 },
47 lastWeek : function () {
48 return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
49 },
50 sameElse : 'L'
51 },
52 relativeTime : {
53 future : 'en %s',
54 past : 'hace %s',
55 s : 'unos segundos',
56 m : 'un minuto',
57 mm : '%d minutos',
58 h : 'una hora',
59 hh : '%d horas',
60 d : 'un día',
61 dd : '%d días',
62 M : 'un mes',
63 MM : '%d meses',
64 y : 'un año',
65 yy : '%d años'
66 },
67 ordinalParse : /\d{1,2}º/,
68 ordinal : '%dº',
69 week : {
70 dow : 1, // Monday is the first day of the week.
71 doy : 4 // The week that contains Jan 4th is the first week of the year.
72 }
73 });
74
75 return es;
76
77 }));
0 //! moment.js locale configuration
1 //! locale : estonian (et)
2 //! author : Henry Kehlmann : https://github.com/madhenry
3 //! improvements : Illimar Tambek : https://github.com/ragulka
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 function processRelativeTime(number, withoutSuffix, key, isFuture) {
13 var format = {
14 's' : ['mõne sekundi', 'mõni sekund', 'paar sekundit'],
15 'm' : ['ühe minuti', 'üks minut'],
16 'mm': [number + ' minuti', number + ' minutit'],
17 'h' : ['ühe tunni', 'tund aega', 'üks tund'],
18 'hh': [number + ' tunni', number + ' tundi'],
19 'd' : ['ühe päeva', 'üks päev'],
20 'M' : ['kuu aja', 'kuu aega', 'üks kuu'],
21 'MM': [number + ' kuu', number + ' kuud'],
22 'y' : ['ühe aasta', 'aasta', 'üks aasta'],
23 'yy': [number + ' aasta', number + ' aastat']
24 };
25 if (withoutSuffix) {
26 return format[key][2] ? format[key][2] : format[key][1];
27 }
28 return isFuture ? format[key][0] : format[key][1];
29 }
30
31 var et = moment.defineLocale('et', {
32 months : 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'),
33 monthsShort : 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'),
34 weekdays : 'pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev'.split('_'),
35 weekdaysShort : 'P_E_T_K_N_R_L'.split('_'),
36 weekdaysMin : 'P_E_T_K_N_R_L'.split('_'),
37 longDateFormat : {
38 LT : 'H:mm',
39 LTS : 'H:mm:ss',
40 L : 'DD.MM.YYYY',
41 LL : 'D. MMMM YYYY',
42 LLL : 'D. MMMM YYYY H:mm',
43 LLLL : 'dddd, D. MMMM YYYY H:mm'
44 },
45 calendar : {
46 sameDay : '[Täna,] LT',
47 nextDay : '[Homme,] LT',
48 nextWeek : '[Järgmine] dddd LT',
49 lastDay : '[Eile,] LT',
50 lastWeek : '[Eelmine] dddd LT',
51 sameElse : 'L'
52 },
53 relativeTime : {
54 future : '%s pärast',
55 past : '%s tagasi',
56 s : processRelativeTime,
57 m : processRelativeTime,
58 mm : processRelativeTime,
59 h : processRelativeTime,
60 hh : processRelativeTime,
61 d : processRelativeTime,
62 dd : '%d päeva',
63 M : processRelativeTime,
64 MM : processRelativeTime,
65 y : processRelativeTime,
66 yy : processRelativeTime
67 },
68 ordinalParse: /\d{1,2}\./,
69 ordinal : '%d.',
70 week : {
71 dow : 1, // Monday is the first day of the week.
72 doy : 4 // The week that contains Jan 4th is the first week of the year.
73 }
74 });
75
76 return et;
77
78 }));
0 //! moment.js locale configuration
1 //! locale : euskara (eu)
2 //! author : Eneko Illarramendi : https://github.com/eillarra
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var eu = moment.defineLocale('eu', {
12 months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
13 monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
14 weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
15 weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
16 weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'YYYY-MM-DD',
21 LL : 'YYYY[ko] MMMM[ren] D[a]',
22 LLL : 'YYYY[ko] MMMM[ren] D[a] HH:mm',
23 LLLL : 'dddd, YYYY[ko] MMMM[ren] D[a] HH:mm',
24 l : 'YYYY-M-D',
25 ll : 'YYYY[ko] MMM D[a]',
26 lll : 'YYYY[ko] MMM D[a] HH:mm',
27 llll : 'ddd, YYYY[ko] MMM D[a] HH:mm'
28 },
29 calendar : {
30 sameDay : '[gaur] LT[etan]',
31 nextDay : '[bihar] LT[etan]',
32 nextWeek : 'dddd LT[etan]',
33 lastDay : '[atzo] LT[etan]',
34 lastWeek : '[aurreko] dddd LT[etan]',
35 sameElse : 'L'
36 },
37 relativeTime : {
38 future : '%s barru',
39 past : 'duela %s',
40 s : 'segundo batzuk',
41 m : 'minutu bat',
42 mm : '%d minutu',
43 h : 'ordu bat',
44 hh : '%d ordu',
45 d : 'egun bat',
46 dd : '%d egun',
47 M : 'hilabete bat',
48 MM : '%d hilabete',
49 y : 'urte bat',
50 yy : '%d urte'
51 },
52 ordinalParse: /\d{1,2}\./,
53 ordinal : '%d.',
54 week : {
55 dow : 1, // Monday is the first day of the week.
56 doy : 7 // The week that contains Jan 1st is the first week of the year.
57 }
58 });
59
60 return eu;
61
62 }));
0 //! moment.js locale configuration
1 //! locale : Persian (fa)
2 //! author : Ebrahim Byagowi : https://github.com/ebraminio
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '۱',
13 '2': '۲',
14 '3': '۳',
15 '4': '۴',
16 '5': '۵',
17 '6': '۶',
18 '7': '۷',
19 '8': '۸',
20 '9': '۹',
21 '0': '۰'
22 }, numberMap = {
23 '۱': '1',
24 '۲': '2',
25 '۳': '3',
26 '۴': '4',
27 '۵': '5',
28 '۶': '6',
29 '۷': '7',
30 '۸': '8',
31 '۹': '9',
32 '۰': '0'
33 };
34
35 var fa = moment.defineLocale('fa', {
36 months : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
37 monthsShort : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
38 weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
39 weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
40 weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
41 longDateFormat : {
42 LT : 'HH:mm',
43 LTS : 'HH:mm:ss',
44 L : 'DD/MM/YYYY',
45 LL : 'D MMMM YYYY',
46 LLL : 'D MMMM YYYY HH:mm',
47 LLLL : 'dddd, D MMMM YYYY HH:mm'
48 },
49 meridiemParse: /قبل از ظهر|بعد از ظهر/,
50 isPM: function (input) {
51 return /بعد از ظهر/.test(input);
52 },
53 meridiem : function (hour, minute, isLower) {
54 if (hour < 12) {
55 return 'قبل از ظهر';
56 } else {
57 return 'بعد از ظهر';
58 }
59 },
60 calendar : {
61 sameDay : '[امروز ساعت] LT',
62 nextDay : '[فردا ساعت] LT',
63 nextWeek : 'dddd [ساعت] LT',
64 lastDay : '[دیروز ساعت] LT',
65 lastWeek : 'dddd [پیش] [ساعت] LT',
66 sameElse : 'L'
67 },
68 relativeTime : {
69 future : 'در %s',
70 past : '%s پیش',
71 s : 'چندین ثانیه',
72 m : 'یک دقیقه',
73 mm : '%d دقیقه',
74 h : 'یک ساعت',
75 hh : '%d ساعت',
76 d : 'یک روز',
77 dd : '%d روز',
78 M : 'یک ماه',
79 MM : '%d ماه',
80 y : 'یک سال',
81 yy : '%d سال'
82 },
83 preparse: function (string) {
84 return string.replace(/[۰-۹]/g, function (match) {
85 return numberMap[match];
86 }).replace(/،/g, ',');
87 },
88 postformat: function (string) {
89 return string.replace(/\d/g, function (match) {
90 return symbolMap[match];
91 }).replace(/,/g, '،');
92 },
93 ordinalParse: /\d{1,2}م/,
94 ordinal : '%dم',
95 week : {
96 dow : 6, // Saturday is the first day of the week.
97 doy : 12 // The week that contains Jan 1st is the first week of the year.
98 }
99 });
100
101 return fa;
102
103 }));
0 //! moment.js locale configuration
1 //! locale : finnish (fi)
2 //! author : Tarmo Aidantausta : https://github.com/bleadof
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var numbersPast = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' '),
12 numbersFuture = [
13 'nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
14 numbersPast[7], numbersPast[8], numbersPast[9]
15 ];
16 function translate(number, withoutSuffix, key, isFuture) {
17 var result = '';
18 switch (key) {
19 case 's':
20 return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
21 case 'm':
22 return isFuture ? 'minuutin' : 'minuutti';
23 case 'mm':
24 result = isFuture ? 'minuutin' : 'minuuttia';
25 break;
26 case 'h':
27 return isFuture ? 'tunnin' : 'tunti';
28 case 'hh':
29 result = isFuture ? 'tunnin' : 'tuntia';
30 break;
31 case 'd':
32 return isFuture ? 'päivän' : 'päivä';
33 case 'dd':
34 result = isFuture ? 'päivän' : 'päivää';
35 break;
36 case 'M':
37 return isFuture ? 'kuukauden' : 'kuukausi';
38 case 'MM':
39 result = isFuture ? 'kuukauden' : 'kuukautta';
40 break;
41 case 'y':
42 return isFuture ? 'vuoden' : 'vuosi';
43 case 'yy':
44 result = isFuture ? 'vuoden' : 'vuotta';
45 break;
46 }
47 result = verbalNumber(number, isFuture) + ' ' + result;
48 return result;
49 }
50 function verbalNumber(number, isFuture) {
51 return number < 10 ? (isFuture ? numbersFuture[number] : numbersPast[number]) : number;
52 }
53
54 var fi = moment.defineLocale('fi', {
55 months : 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'),
56 monthsShort : 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'),
57 weekdays : 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'),
58 weekdaysShort : 'su_ma_ti_ke_to_pe_la'.split('_'),
59 weekdaysMin : 'su_ma_ti_ke_to_pe_la'.split('_'),
60 longDateFormat : {
61 LT : 'HH.mm',
62 LTS : 'HH.mm.ss',
63 L : 'DD.MM.YYYY',
64 LL : 'Do MMMM[ta] YYYY',
65 LLL : 'Do MMMM[ta] YYYY, [klo] HH.mm',
66 LLLL : 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm',
67 l : 'D.M.YYYY',
68 ll : 'Do MMM YYYY',
69 lll : 'Do MMM YYYY, [klo] HH.mm',
70 llll : 'ddd, Do MMM YYYY, [klo] HH.mm'
71 },
72 calendar : {
73 sameDay : '[tänään] [klo] LT',
74 nextDay : '[huomenna] [klo] LT',
75 nextWeek : 'dddd [klo] LT',
76 lastDay : '[eilen] [klo] LT',
77 lastWeek : '[viime] dddd[na] [klo] LT',
78 sameElse : 'L'
79 },
80 relativeTime : {
81 future : '%s päästä',
82 past : '%s sitten',
83 s : translate,
84 m : translate,
85 mm : translate,
86 h : translate,
87 hh : translate,
88 d : translate,
89 dd : translate,
90 M : translate,
91 MM : translate,
92 y : translate,
93 yy : translate
94 },
95 ordinalParse: /\d{1,2}\./,
96 ordinal : '%d.',
97 week : {
98 dow : 1, // Monday is the first day of the week.
99 doy : 4 // The week that contains Jan 4th is the first week of the year.
100 }
101 });
102
103 return fi;
104
105 }));
0 //! moment.js locale configuration
1 //! locale : faroese (fo)
2 //! author : Ragnar Johannesen : https://github.com/ragnar123
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var fo = moment.defineLocale('fo', {
12 months : 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
13 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
14 weekdays : 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'),
15 weekdaysShort : 'sun_mán_týs_mik_hós_frí_ley'.split('_'),
16 weekdaysMin : 'su_má_tý_mi_hó_fr_le'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd D. MMMM, YYYY HH:mm'
24 },
25 calendar : {
26 sameDay : '[Í dag kl.] LT',
27 nextDay : '[Í morgin kl.] LT',
28 nextWeek : 'dddd [kl.] LT',
29 lastDay : '[Í gjár kl.] LT',
30 lastWeek : '[síðstu] dddd [kl] LT',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : 'um %s',
35 past : '%s síðani',
36 s : 'fá sekund',
37 m : 'ein minutt',
38 mm : '%d minuttir',
39 h : 'ein tími',
40 hh : '%d tímar',
41 d : 'ein dagur',
42 dd : '%d dagar',
43 M : 'ein mánaði',
44 MM : '%d mánaðir',
45 y : 'eitt ár',
46 yy : '%d ár'
47 },
48 ordinalParse: /\d{1,2}\./,
49 ordinal : '%d.',
50 week : {
51 dow : 1, // Monday is the first day of the week.
52 doy : 4 // The week that contains Jan 4th is the first week of the year.
53 }
54 });
55
56 return fo;
57
58 }));
0 //! moment.js locale configuration
1 //! locale : canadian french (fr-ca)
2 //! author : Jonathan Abourbih : https://github.com/jonbca
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var fr_ca = moment.defineLocale('fr-ca', {
12 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
13 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
14 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
15 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
16 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'YYYY-MM-DD',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd D MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[Aujourd\'hui à] LT',
27 nextDay: '[Demain à] LT',
28 nextWeek: 'dddd [à] LT',
29 lastDay: '[Hier à] LT',
30 lastWeek: 'dddd [dernier à] LT',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : 'dans %s',
35 past : 'il y a %s',
36 s : 'quelques secondes',
37 m : 'une minute',
38 mm : '%d minutes',
39 h : 'une heure',
40 hh : '%d heures',
41 d : 'un jour',
42 dd : '%d jours',
43 M : 'un mois',
44 MM : '%d mois',
45 y : 'un an',
46 yy : '%d ans'
47 },
48 ordinalParse: /\d{1,2}(er|e)/,
49 ordinal : function (number) {
50 return number + (number === 1 ? 'er' : 'e');
51 }
52 });
53
54 return fr_ca;
55
56 }));
0 //! moment.js locale configuration
1 //! locale : french (fr)
2 //! author : John Fischer : https://github.com/jfroffice
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var fr = moment.defineLocale('fr', {
12 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
13 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
14 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
15 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
16 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd D MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[Aujourd\'hui à] LT',
27 nextDay: '[Demain à] LT',
28 nextWeek: 'dddd [à] LT',
29 lastDay: '[Hier à] LT',
30 lastWeek: 'dddd [dernier à] LT',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : 'dans %s',
35 past : 'il y a %s',
36 s : 'quelques secondes',
37 m : 'une minute',
38 mm : '%d minutes',
39 h : 'une heure',
40 hh : '%d heures',
41 d : 'un jour',
42 dd : '%d jours',
43 M : 'un mois',
44 MM : '%d mois',
45 y : 'un an',
46 yy : '%d ans'
47 },
48 ordinalParse: /\d{1,2}(er|)/,
49 ordinal : function (number) {
50 return number + (number === 1 ? 'er' : '');
51 },
52 week : {
53 dow : 1, // Monday is the first day of the week.
54 doy : 4 // The week that contains Jan 4th is the first week of the year.
55 }
56 });
57
58 return fr;
59
60 }));
0 //! moment.js locale configuration
1 //! locale : frisian (fy)
2 //! author : Robin van der Vliet : https://github.com/robin0van0der0v
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var monthsShortWithDots = 'jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.'.split('_'),
12 monthsShortWithoutDots = 'jan_feb_mrt_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_');
13
14 var fy = moment.defineLocale('fy', {
15 months : 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'),
16 monthsShort : function (m, format) {
17 if (/-MMM-/.test(format)) {
18 return monthsShortWithoutDots[m.month()];
19 } else {
20 return monthsShortWithDots[m.month()];
21 }
22 },
23 weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
24 weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
25 weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
26 longDateFormat : {
27 LT : 'HH:mm',
28 LTS : 'HH:mm:ss',
29 L : 'DD-MM-YYYY',
30 LL : 'D MMMM YYYY',
31 LLL : 'D MMMM YYYY HH:mm',
32 LLLL : 'dddd D MMMM YYYY HH:mm'
33 },
34 calendar : {
35 sameDay: '[hjoed om] LT',
36 nextDay: '[moarn om] LT',
37 nextWeek: 'dddd [om] LT',
38 lastDay: '[juster om] LT',
39 lastWeek: '[ôfrûne] dddd [om] LT',
40 sameElse: 'L'
41 },
42 relativeTime : {
43 future : 'oer %s',
44 past : '%s lyn',
45 s : 'in pear sekonden',
46 m : 'ien minút',
47 mm : '%d minuten',
48 h : 'ien oere',
49 hh : '%d oeren',
50 d : 'ien dei',
51 dd : '%d dagen',
52 M : 'ien moanne',
53 MM : '%d moannen',
54 y : 'ien jier',
55 yy : '%d jierren'
56 },
57 ordinalParse: /\d{1,2}(ste|de)/,
58 ordinal : function (number) {
59 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
60 },
61 week : {
62 dow : 1, // Monday is the first day of the week.
63 doy : 4 // The week that contains Jan 4th is the first week of the year.
64 }
65 });
66
67 return fy;
68
69 }));
0 //! moment.js locale configuration
1 //! locale : galician (gl)
2 //! author : Juan G. Hurtado : https://github.com/juanghurtado
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var gl = moment.defineLocale('gl', {
12 months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
13 monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
14 weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
15 weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
16 weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
17 longDateFormat : {
18 LT : 'H:mm',
19 LTS : 'H:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY H:mm',
23 LLLL : 'dddd D MMMM YYYY H:mm'
24 },
25 calendar : {
26 sameDay : function () {
27 return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
28 },
29 nextDay : function () {
30 return '[mañá ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
31 },
32 nextWeek : function () {
33 return 'dddd [' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
34 },
35 lastDay : function () {
36 return '[onte ' + ((this.hours() !== 1) ? 'á' : 'a') + '] LT';
37 },
38 lastWeek : function () {
39 return '[o] dddd [pasado ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
40 },
41 sameElse : 'L'
42 },
43 relativeTime : {
44 future : function (str) {
45 if (str === 'uns segundos') {
46 return 'nuns segundos';
47 }
48 return 'en ' + str;
49 },
50 past : 'hai %s',
51 s : 'uns segundos',
52 m : 'un minuto',
53 mm : '%d minutos',
54 h : 'unha hora',
55 hh : '%d horas',
56 d : 'un día',
57 dd : '%d días',
58 M : 'un mes',
59 MM : '%d meses',
60 y : 'un ano',
61 yy : '%d anos'
62 },
63 ordinalParse : /\d{1,2}º/,
64 ordinal : '%dº',
65 week : {
66 dow : 1, // Monday is the first day of the week.
67 doy : 7 // The week that contains Jan 1st is the first week of the year.
68 }
69 });
70
71 return gl;
72
73 }));
0 //! moment.js locale configuration
1 //! locale : Hebrew (he)
2 //! author : Tomer Cohen : https://github.com/tomer
3 //! author : Moshe Simantov : https://github.com/DevelopmentIL
4 //! author : Tal Ater : https://github.com/TalAter
5
6 (function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
8 typeof define === 'function' && define.amd ? define(['moment'], factory) :
9 factory(global.moment)
10 }(this, function (moment) { 'use strict';
11
12
13 var he = moment.defineLocale('he', {
14 months : 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'),
15 monthsShort : 'ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳'.split('_'),
16 weekdays : 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'),
17 weekdaysShort : 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'),
18 weekdaysMin : 'א_ב_ג_ד_ה_ו_ש'.split('_'),
19 longDateFormat : {
20 LT : 'HH:mm',
21 LTS : 'HH:mm:ss',
22 L : 'DD/MM/YYYY',
23 LL : 'D [ב]MMMM YYYY',
24 LLL : 'D [ב]MMMM YYYY HH:mm',
25 LLLL : 'dddd, D [ב]MMMM YYYY HH:mm',
26 l : 'D/M/YYYY',
27 ll : 'D MMM YYYY',
28 lll : 'D MMM YYYY HH:mm',
29 llll : 'ddd, D MMM YYYY HH:mm'
30 },
31 calendar : {
32 sameDay : '[היום ב־]LT',
33 nextDay : '[מחר ב־]LT',
34 nextWeek : 'dddd [בשעה] LT',
35 lastDay : '[אתמול ב־]LT',
36 lastWeek : '[ביום] dddd [האחרון בשעה] LT',
37 sameElse : 'L'
38 },
39 relativeTime : {
40 future : 'בעוד %s',
41 past : 'לפני %s',
42 s : 'מספר שניות',
43 m : 'דקה',
44 mm : '%d דקות',
45 h : 'שעה',
46 hh : function (number) {
47 if (number === 2) {
48 return 'שעתיים';
49 }
50 return number + ' שעות';
51 },
52 d : 'יום',
53 dd : function (number) {
54 if (number === 2) {
55 return 'יומיים';
56 }
57 return number + ' ימים';
58 },
59 M : 'חודש',
60 MM : function (number) {
61 if (number === 2) {
62 return 'חודשיים';
63 }
64 return number + ' חודשים';
65 },
66 y : 'שנה',
67 yy : function (number) {
68 if (number === 2) {
69 return 'שנתיים';
70 } else if (number % 10 === 0 && number !== 10) {
71 return number + ' שנה';
72 }
73 return number + ' שנים';
74 }
75 }
76 });
77
78 return he;
79
80 }));
0 //! moment.js locale configuration
1 //! locale : hindi (hi)
2 //! author : Mayank Singhal : https://github.com/mayanksinghal
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '१',
13 '2': '२',
14 '3': '३',
15 '4': '४',
16 '5': '५',
17 '6': '६',
18 '7': '७',
19 '8': '८',
20 '9': '९',
21 '0': '०'
22 },
23 numberMap = {
24 '१': '1',
25 '२': '2',
26 '३': '3',
27 '४': '4',
28 '५': '5',
29 '६': '6',
30 '७': '7',
31 '८': '8',
32 '९': '9',
33 '०': '0'
34 };
35
36 var hi = moment.defineLocale('hi', {
37 months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
38 monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
39 weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
40 weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
41 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
42 longDateFormat : {
43 LT : 'A h:mm बजे',
44 LTS : 'A h:mm:ss बजे',
45 L : 'DD/MM/YYYY',
46 LL : 'D MMMM YYYY',
47 LLL : 'D MMMM YYYY, A h:mm बजे',
48 LLLL : 'dddd, D MMMM YYYY, A h:mm बजे'
49 },
50 calendar : {
51 sameDay : '[आज] LT',
52 nextDay : '[कल] LT',
53 nextWeek : 'dddd, LT',
54 lastDay : '[कल] LT',
55 lastWeek : '[पिछले] dddd, LT',
56 sameElse : 'L'
57 },
58 relativeTime : {
59 future : '%s में',
60 past : '%s पहले',
61 s : 'कुछ ही क्षण',
62 m : 'एक मिनट',
63 mm : '%d मिनट',
64 h : 'एक घंटा',
65 hh : '%d घंटे',
66 d : 'एक दिन',
67 dd : '%d दिन',
68 M : 'एक महीने',
69 MM : '%d महीने',
70 y : 'एक वर्ष',
71 yy : '%d वर्ष'
72 },
73 preparse: function (string) {
74 return string.replace(/[१२३४५६७८९०]/g, function (match) {
75 return numberMap[match];
76 });
77 },
78 postformat: function (string) {
79 return string.replace(/\d/g, function (match) {
80 return symbolMap[match];
81 });
82 },
83 // Hindi notation for meridiems are quite fuzzy in practice. While there exists
84 // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
85 meridiemParse: /रात|सुबह|दोपहर|शाम/,
86 meridiemHour : function (hour, meridiem) {
87 if (hour === 12) {
88 hour = 0;
89 }
90 if (meridiem === 'रात') {
91 return hour < 4 ? hour : hour + 12;
92 } else if (meridiem === 'सुबह') {
93 return hour;
94 } else if (meridiem === 'दोपहर') {
95 return hour >= 10 ? hour : hour + 12;
96 } else if (meridiem === 'शाम') {
97 return hour + 12;
98 }
99 },
100 meridiem : function (hour, minute, isLower) {
101 if (hour < 4) {
102 return 'रात';
103 } else if (hour < 10) {
104 return 'सुबह';
105 } else if (hour < 17) {
106 return 'दोपहर';
107 } else if (hour < 20) {
108 return 'शाम';
109 } else {
110 return 'रात';
111 }
112 },
113 week : {
114 dow : 0, // Sunday is the first day of the week.
115 doy : 6 // The week that contains Jan 1st is the first week of the year.
116 }
117 });
118
119 return hi;
120
121 }));
0 //! moment.js locale configuration
1 //! locale : hrvatski (hr)
2 //! author : Bojan Marković : https://github.com/bmarkovic
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 function translate(number, withoutSuffix, key) {
12 var result = number + ' ';
13 switch (key) {
14 case 'm':
15 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
16 case 'mm':
17 if (number === 1) {
18 result += 'minuta';
19 } else if (number === 2 || number === 3 || number === 4) {
20 result += 'minute';
21 } else {
22 result += 'minuta';
23 }
24 return result;
25 case 'h':
26 return withoutSuffix ? 'jedan sat' : 'jednog sata';
27 case 'hh':
28 if (number === 1) {
29 result += 'sat';
30 } else if (number === 2 || number === 3 || number === 4) {
31 result += 'sata';
32 } else {
33 result += 'sati';
34 }
35 return result;
36 case 'dd':
37 if (number === 1) {
38 result += 'dan';
39 } else {
40 result += 'dana';
41 }
42 return result;
43 case 'MM':
44 if (number === 1) {
45 result += 'mjesec';
46 } else if (number === 2 || number === 3 || number === 4) {
47 result += 'mjeseca';
48 } else {
49 result += 'mjeseci';
50 }
51 return result;
52 case 'yy':
53 if (number === 1) {
54 result += 'godina';
55 } else if (number === 2 || number === 3 || number === 4) {
56 result += 'godine';
57 } else {
58 result += 'godina';
59 }
60 return result;
61 }
62 }
63
64 var hr = moment.defineLocale('hr', {
65 months : 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
66 monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
67 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
68 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
69 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
70 longDateFormat : {
71 LT : 'H:mm',
72 LTS : 'H:mm:ss',
73 L : 'DD. MM. YYYY',
74 LL : 'D. MMMM YYYY',
75 LLL : 'D. MMMM YYYY H:mm',
76 LLLL : 'dddd, D. MMMM YYYY H:mm'
77 },
78 calendar : {
79 sameDay : '[danas u] LT',
80 nextDay : '[sutra u] LT',
81 nextWeek : function () {
82 switch (this.day()) {
83 case 0:
84 return '[u] [nedjelju] [u] LT';
85 case 3:
86 return '[u] [srijedu] [u] LT';
87 case 6:
88 return '[u] [subotu] [u] LT';
89 case 1:
90 case 2:
91 case 4:
92 case 5:
93 return '[u] dddd [u] LT';
94 }
95 },
96 lastDay : '[jučer u] LT',
97 lastWeek : function () {
98 switch (this.day()) {
99 case 0:
100 case 3:
101 return '[prošlu] dddd [u] LT';
102 case 6:
103 return '[prošle] [subote] [u] LT';
104 case 1:
105 case 2:
106 case 4:
107 case 5:
108 return '[prošli] dddd [u] LT';
109 }
110 },
111 sameElse : 'L'
112 },
113 relativeTime : {
114 future : 'za %s',
115 past : 'prije %s',
116 s : 'par sekundi',
117 m : translate,
118 mm : translate,
119 h : translate,
120 hh : translate,
121 d : 'dan',
122 dd : translate,
123 M : 'mjesec',
124 MM : translate,
125 y : 'godinu',
126 yy : translate
127 },
128 ordinalParse: /\d{1,2}\./,
129 ordinal : '%d.',
130 week : {
131 dow : 1, // Monday is the first day of the week.
132 doy : 7 // The week that contains Jan 1st is the first week of the year.
133 }
134 });
135
136 return hr;
137
138 }));
0 //! moment.js locale configuration
1 //! locale : hungarian (hu)
2 //! author : Adam Brunner : https://github.com/adambrunner
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
12 function translate(number, withoutSuffix, key, isFuture) {
13 var num = number,
14 suffix;
15 switch (key) {
16 case 's':
17 return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
18 case 'm':
19 return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
20 case 'mm':
21 return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
22 case 'h':
23 return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
24 case 'hh':
25 return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
26 case 'd':
27 return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
28 case 'dd':
29 return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
30 case 'M':
31 return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
32 case 'MM':
33 return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
34 case 'y':
35 return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
36 case 'yy':
37 return num + (isFuture || withoutSuffix ? ' év' : ' éve');
38 }
39 return '';
40 }
41 function week(isFuture) {
42 return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[this.day()] + '] LT[-kor]';
43 }
44
45 var hu = moment.defineLocale('hu', {
46 months : 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
47 monthsShort : 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
48 weekdays : 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'),
49 weekdaysShort : 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'),
50 weekdaysMin : 'v_h_k_sze_cs_p_szo'.split('_'),
51 longDateFormat : {
52 LT : 'H:mm',
53 LTS : 'H:mm:ss',
54 L : 'YYYY.MM.DD.',
55 LL : 'YYYY. MMMM D.',
56 LLL : 'YYYY. MMMM D. H:mm',
57 LLLL : 'YYYY. MMMM D., dddd H:mm'
58 },
59 meridiemParse: /de|du/i,
60 isPM: function (input) {
61 return input.charAt(1).toLowerCase() === 'u';
62 },
63 meridiem : function (hours, minutes, isLower) {
64 if (hours < 12) {
65 return isLower === true ? 'de' : 'DE';
66 } else {
67 return isLower === true ? 'du' : 'DU';
68 }
69 },
70 calendar : {
71 sameDay : '[ma] LT[-kor]',
72 nextDay : '[holnap] LT[-kor]',
73 nextWeek : function () {
74 return week.call(this, true);
75 },
76 lastDay : '[tegnap] LT[-kor]',
77 lastWeek : function () {
78 return week.call(this, false);
79 },
80 sameElse : 'L'
81 },
82 relativeTime : {
83 future : '%s múlva',
84 past : '%s',
85 s : translate,
86 m : translate,
87 mm : translate,
88 h : translate,
89 hh : translate,
90 d : translate,
91 dd : translate,
92 M : translate,
93 MM : translate,
94 y : translate,
95 yy : translate
96 },
97 ordinalParse: /\d{1,2}\./,
98 ordinal : '%d.',
99 week : {
100 dow : 1, // Monday is the first day of the week.
101 doy : 7 // The week that contains Jan 1st is the first week of the year.
102 }
103 });
104
105 return hu;
106
107 }));
0 //! moment.js locale configuration
1 //! locale : Armenian (hy-am)
2 //! author : Armendarabyan : https://github.com/armendarabyan
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 function monthsCaseReplace(m, format) {
12 var months = {
13 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
14 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
15 },
16 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
17 'accusative' :
18 'nominative';
19 return months[nounCase][m.month()];
20 }
21 function monthsShortCaseReplace(m, format) {
22 var monthsShort = 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_');
23 return monthsShort[m.month()];
24 }
25 function weekdaysCaseReplace(m, format) {
26 var weekdays = 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_');
27 return weekdays[m.day()];
28 }
29
30 var hy_am = moment.defineLocale('hy-am', {
31 months : monthsCaseReplace,
32 monthsShort : monthsShortCaseReplace,
33 weekdays : weekdaysCaseReplace,
34 weekdaysShort : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
35 weekdaysMin : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
36 longDateFormat : {
37 LT : 'HH:mm',
38 LTS : 'HH:mm:ss',
39 L : 'DD.MM.YYYY',
40 LL : 'D MMMM YYYY թ.',
41 LLL : 'D MMMM YYYY թ., HH:mm',
42 LLLL : 'dddd, D MMMM YYYY թ., HH:mm'
43 },
44 calendar : {
45 sameDay: '[այսօր] LT',
46 nextDay: '[վաղը] LT',
47 lastDay: '[երեկ] LT',
48 nextWeek: function () {
49 return 'dddd [օրը ժամը] LT';
50 },
51 lastWeek: function () {
52 return '[անցած] dddd [օրը ժամը] LT';
53 },
54 sameElse: 'L'
55 },
56 relativeTime : {
57 future : '%s հետո',
58 past : '%s առաջ',
59 s : 'մի քանի վայրկյան',
60 m : 'րոպե',
61 mm : '%d րոպե',
62 h : 'ժամ',
63 hh : '%d ժամ',
64 d : 'օր',
65 dd : '%d օր',
66 M : 'ամիս',
67 MM : '%d ամիս',
68 y : 'տարի',
69 yy : '%d տարի'
70 },
71 meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
72 isPM: function (input) {
73 return /^(ցերեկվա|երեկոյան)$/.test(input);
74 },
75 meridiem : function (hour) {
76 if (hour < 4) {
77 return 'գիշերվա';
78 } else if (hour < 12) {
79 return 'առավոտվա';
80 } else if (hour < 17) {
81 return 'ցերեկվա';
82 } else {
83 return 'երեկոյան';
84 }
85 },
86 ordinalParse: /\d{1,2}|\d{1,2}-(ին|րդ)/,
87 ordinal: function (number, period) {
88 switch (period) {
89 case 'DDD':
90 case 'w':
91 case 'W':
92 case 'DDDo':
93 if (number === 1) {
94 return number + '-ին';
95 }
96 return number + '-րդ';
97 default:
98 return number;
99 }
100 },
101 week : {
102 dow : 1, // Monday is the first day of the week.
103 doy : 7 // The week that contains Jan 1st is the first week of the year.
104 }
105 });
106
107 return hy_am;
108
109 }));
0 //! moment.js locale configuration
1 //! locale : Bahasa Indonesia (id)
2 //! author : Mohammad Satrio Utomo : https://github.com/tyok
3 //! reference: http://id.wikisource.org/wiki/Pedoman_Umum_Ejaan_Bahasa_Indonesia_yang_Disempurnakan
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var id = moment.defineLocale('id', {
13 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
14 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des'.split('_'),
15 weekdays : 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
16 weekdaysShort : 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'),
17 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'),
18 longDateFormat : {
19 LT : 'HH.mm',
20 LTS : 'HH.mm.ss',
21 L : 'DD/MM/YYYY',
22 LL : 'D MMMM YYYY',
23 LLL : 'D MMMM YYYY [pukul] HH.mm',
24 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
25 },
26 meridiemParse: /pagi|siang|sore|malam/,
27 meridiemHour : function (hour, meridiem) {
28 if (hour === 12) {
29 hour = 0;
30 }
31 if (meridiem === 'pagi') {
32 return hour;
33 } else if (meridiem === 'siang') {
34 return hour >= 11 ? hour : hour + 12;
35 } else if (meridiem === 'sore' || meridiem === 'malam') {
36 return hour + 12;
37 }
38 },
39 meridiem : function (hours, minutes, isLower) {
40 if (hours < 11) {
41 return 'pagi';
42 } else if (hours < 15) {
43 return 'siang';
44 } else if (hours < 19) {
45 return 'sore';
46 } else {
47 return 'malam';
48 }
49 },
50 calendar : {
51 sameDay : '[Hari ini pukul] LT',
52 nextDay : '[Besok pukul] LT',
53 nextWeek : 'dddd [pukul] LT',
54 lastDay : '[Kemarin pukul] LT',
55 lastWeek : 'dddd [lalu pukul] LT',
56 sameElse : 'L'
57 },
58 relativeTime : {
59 future : 'dalam %s',
60 past : '%s yang lalu',
61 s : 'beberapa detik',
62 m : 'semenit',
63 mm : '%d menit',
64 h : 'sejam',
65 hh : '%d jam',
66 d : 'sehari',
67 dd : '%d hari',
68 M : 'sebulan',
69 MM : '%d bulan',
70 y : 'setahun',
71 yy : '%d tahun'
72 },
73 week : {
74 dow : 1, // Monday is the first day of the week.
75 doy : 7 // The week that contains Jan 1st is the first week of the year.
76 }
77 });
78
79 return id;
80
81 }));
0 //! moment.js locale configuration
1 //! locale : icelandic (is)
2 //! author : Hinrik Örn Sigurðsson : https://github.com/hinrik
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 function plural(n) {
12 if (n % 100 === 11) {
13 return true;
14 } else if (n % 10 === 1) {
15 return false;
16 }
17 return true;
18 }
19 function translate(number, withoutSuffix, key, isFuture) {
20 var result = number + ' ';
21 switch (key) {
22 case 's':
23 return withoutSuffix || isFuture ? 'nokkrar sekúndur' : 'nokkrum sekúndum';
24 case 'm':
25 return withoutSuffix ? 'mínúta' : 'mínútu';
26 case 'mm':
27 if (plural(number)) {
28 return result + (withoutSuffix || isFuture ? 'mínútur' : 'mínútum');
29 } else if (withoutSuffix) {
30 return result + 'mínúta';
31 }
32 return result + 'mínútu';
33 case 'hh':
34 if (plural(number)) {
35 return result + (withoutSuffix || isFuture ? 'klukkustundir' : 'klukkustundum');
36 }
37 return result + 'klukkustund';
38 case 'd':
39 if (withoutSuffix) {
40 return 'dagur';
41 }
42 return isFuture ? 'dag' : 'degi';
43 case 'dd':
44 if (plural(number)) {
45 if (withoutSuffix) {
46 return result + 'dagar';
47 }
48 return result + (isFuture ? 'daga' : 'dögum');
49 } else if (withoutSuffix) {
50 return result + 'dagur';
51 }
52 return result + (isFuture ? 'dag' : 'degi');
53 case 'M':
54 if (withoutSuffix) {
55 return 'mánuður';
56 }
57 return isFuture ? 'mánuð' : 'mánuði';
58 case 'MM':
59 if (plural(number)) {
60 if (withoutSuffix) {
61 return result + 'mánuðir';
62 }
63 return result + (isFuture ? 'mánuði' : 'mánuðum');
64 } else if (withoutSuffix) {
65 return result + 'mánuður';
66 }
67 return result + (isFuture ? 'mánuð' : 'mánuði');
68 case 'y':
69 return withoutSuffix || isFuture ? 'ár' : 'ári';
70 case 'yy':
71 if (plural(number)) {
72 return result + (withoutSuffix || isFuture ? 'ár' : 'árum');
73 }
74 return result + (withoutSuffix || isFuture ? 'ár' : 'ári');
75 }
76 }
77
78 var is = moment.defineLocale('is', {
79 months : 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'),
80 monthsShort : 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'),
81 weekdays : 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
82 weekdaysShort : 'sun_mán_þri_mið_fim_fös_lau'.split('_'),
83 weekdaysMin : 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'),
84 longDateFormat : {
85 LT : 'H:mm',
86 LTS : 'H:mm:ss',
87 L : 'DD/MM/YYYY',
88 LL : 'D. MMMM YYYY',
89 LLL : 'D. MMMM YYYY [kl.] H:mm',
90 LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
91 },
92 calendar : {
93 sameDay : '[í dag kl.] LT',
94 nextDay : '[á morgun kl.] LT',
95 nextWeek : 'dddd [kl.] LT',
96 lastDay : '[í gær kl.] LT',
97 lastWeek : '[síðasta] dddd [kl.] LT',
98 sameElse : 'L'
99 },
100 relativeTime : {
101 future : 'eftir %s',
102 past : 'fyrir %s síðan',
103 s : translate,
104 m : translate,
105 mm : translate,
106 h : 'klukkustund',
107 hh : translate,
108 d : translate,
109 dd : translate,
110 M : translate,
111 MM : translate,
112 y : translate,
113 yy : translate
114 },
115 ordinalParse: /\d{1,2}\./,
116 ordinal : '%d.',
117 week : {
118 dow : 1, // Monday is the first day of the week.
119 doy : 4 // The week that contains Jan 4th is the first week of the year.
120 }
121 });
122
123 return is;
124
125 }));
0 //! moment.js locale configuration
1 //! locale : italian (it)
2 //! author : Lorenzo : https://github.com/aliem
3 //! author: Mattia Larentis: https://github.com/nostalgiaz
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var it = moment.defineLocale('it', {
13 months : 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
14 monthsShort : 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
15 weekdays : 'Domenica_Lunedì_Martedì_Mercoledì_Giovedì_Venerdì_Sabato'.split('_'),
16 weekdaysShort : 'Dom_Lun_Mar_Mer_Gio_Ven_Sab'.split('_'),
17 weekdaysMin : 'D_L_Ma_Me_G_V_S'.split('_'),
18 longDateFormat : {
19 LT : 'HH:mm',
20 LTS : 'HH:mm:ss',
21 L : 'DD/MM/YYYY',
22 LL : 'D MMMM YYYY',
23 LLL : 'D MMMM YYYY HH:mm',
24 LLLL : 'dddd, D MMMM YYYY HH:mm'
25 },
26 calendar : {
27 sameDay: '[Oggi alle] LT',
28 nextDay: '[Domani alle] LT',
29 nextWeek: 'dddd [alle] LT',
30 lastDay: '[Ieri alle] LT',
31 lastWeek: function () {
32 switch (this.day()) {
33 case 0:
34 return '[la scorsa] dddd [alle] LT';
35 default:
36 return '[lo scorso] dddd [alle] LT';
37 }
38 },
39 sameElse: 'L'
40 },
41 relativeTime : {
42 future : function (s) {
43 return ((/^[0-9].+$/).test(s) ? 'tra' : 'in') + ' ' + s;
44 },
45 past : '%s fa',
46 s : 'alcuni secondi',
47 m : 'un minuto',
48 mm : '%d minuti',
49 h : 'un\'ora',
50 hh : '%d ore',
51 d : 'un giorno',
52 dd : '%d giorni',
53 M : 'un mese',
54 MM : '%d mesi',
55 y : 'un anno',
56 yy : '%d anni'
57 },
58 ordinalParse : /\d{1,2}º/,
59 ordinal: '%dº',
60 week : {
61 dow : 1, // Monday is the first day of the week.
62 doy : 4 // The week that contains Jan 4th is the first week of the year.
63 }
64 });
65
66 return it;
67
68 }));
0 //! moment.js locale configuration
1 //! locale : japanese (ja)
2 //! author : LI Long : https://github.com/baryon
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var ja = moment.defineLocale('ja', {
12 months : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
13 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
14 weekdays : '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
15 weekdaysShort : '日_月_火_水_木_金_土'.split('_'),
16 weekdaysMin : '日_月_火_水_木_金_土'.split('_'),
17 longDateFormat : {
18 LT : 'Ah時m分',
19 LTS : 'Ah時m分s秒',
20 L : 'YYYY/MM/DD',
21 LL : 'YYYY年M月D日',
22 LLL : 'YYYY年M月D日Ah時m分',
23 LLLL : 'YYYY年M月D日Ah時m分 dddd'
24 },
25 meridiemParse: /午前|午後/i,
26 isPM : function (input) {
27 return input === '午後';
28 },
29 meridiem : function (hour, minute, isLower) {
30 if (hour < 12) {
31 return '午前';
32 } else {
33 return '午後';
34 }
35 },
36 calendar : {
37 sameDay : '[今日] LT',
38 nextDay : '[明日] LT',
39 nextWeek : '[来週]dddd LT',
40 lastDay : '[昨日] LT',
41 lastWeek : '[前週]dddd LT',
42 sameElse : 'L'
43 },
44 relativeTime : {
45 future : '%s後',
46 past : '%s前',
47 s : '数秒',
48 m : '1分',
49 mm : '%d分',
50 h : '1時間',
51 hh : '%d時間',
52 d : '1日',
53 dd : '%d日',
54 M : '1ヶ月',
55 MM : '%dヶ月',
56 y : '1年',
57 yy : '%d年'
58 }
59 });
60
61 return ja;
62
63 }));
0 //! moment.js locale configuration
1 //! locale : Boso Jowo (jv)
2 //! author : Rony Lantip : https://github.com/lantip
3 //! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var jv = moment.defineLocale('jv', {
13 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
14 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
15 weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
16 weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
17 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
18 longDateFormat : {
19 LT : 'HH.mm',
20 LTS : 'HH.mm.ss',
21 L : 'DD/MM/YYYY',
22 LL : 'D MMMM YYYY',
23 LLL : 'D MMMM YYYY [pukul] HH.mm',
24 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
25 },
26 meridiemParse: /enjing|siyang|sonten|ndalu/,
27 meridiemHour : function (hour, meridiem) {
28 if (hour === 12) {
29 hour = 0;
30 }
31 if (meridiem === 'enjing') {
32 return hour;
33 } else if (meridiem === 'siyang') {
34 return hour >= 11 ? hour : hour + 12;
35 } else if (meridiem === 'sonten' || meridiem === 'ndalu') {
36 return hour + 12;
37 }
38 },
39 meridiem : function (hours, minutes, isLower) {
40 if (hours < 11) {
41 return 'enjing';
42 } else if (hours < 15) {
43 return 'siyang';
44 } else if (hours < 19) {
45 return 'sonten';
46 } else {
47 return 'ndalu';
48 }
49 },
50 calendar : {
51 sameDay : '[Dinten puniko pukul] LT',
52 nextDay : '[Mbenjang pukul] LT',
53 nextWeek : 'dddd [pukul] LT',
54 lastDay : '[Kala wingi pukul] LT',
55 lastWeek : 'dddd [kepengker pukul] LT',
56 sameElse : 'L'
57 },
58 relativeTime : {
59 future : 'wonten ing %s',
60 past : '%s ingkang kepengker',
61 s : 'sawetawis detik',
62 m : 'setunggal menit',
63 mm : '%d menit',
64 h : 'setunggal jam',
65 hh : '%d jam',
66 d : 'sedinten',
67 dd : '%d dinten',
68 M : 'sewulan',
69 MM : '%d wulan',
70 y : 'setaun',
71 yy : '%d taun'
72 },
73 week : {
74 dow : 1, // Monday is the first day of the week.
75 doy : 7 // The week that contains Jan 1st is the first week of the year.
76 }
77 });
78
79 return jv;
80
81 }));
0 //! moment.js locale configuration
1 //! locale : Georgian (ka)
2 //! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 function monthsCaseReplace(m, format) {
12 var months = {
13 'nominative': 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
14 'accusative': 'იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს'.split('_')
15 },
16 nounCase = (/D[oD] *MMMM?/).test(format) ?
17 'accusative' :
18 'nominative';
19 return months[nounCase][m.month()];
20 }
21 function weekdaysCaseReplace(m, format) {
22 var weekdays = {
23 'nominative': 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'),
24 'accusative': 'კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს'.split('_')
25 },
26 nounCase = (/(წინა|შემდეგ)/).test(format) ?
27 'accusative' :
28 'nominative';
29 return weekdays[nounCase][m.day()];
30 }
31
32 var ka = moment.defineLocale('ka', {
33 months : monthsCaseReplace,
34 monthsShort : 'იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ'.split('_'),
35 weekdays : weekdaysCaseReplace,
36 weekdaysShort : 'კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ'.split('_'),
37 weekdaysMin : 'კვ_ორ_სა_ოთ_ხუ_პა_შა'.split('_'),
38 longDateFormat : {
39 LT : 'h:mm A',
40 LTS : 'h:mm:ss A',
41 L : 'DD/MM/YYYY',
42 LL : 'D MMMM YYYY',
43 LLL : 'D MMMM YYYY h:mm A',
44 LLLL : 'dddd, D MMMM YYYY h:mm A'
45 },
46 calendar : {
47 sameDay : '[დღეს] LT[-ზე]',
48 nextDay : '[ხვალ] LT[-ზე]',
49 lastDay : '[გუშინ] LT[-ზე]',
50 nextWeek : '[შემდეგ] dddd LT[-ზე]',
51 lastWeek : '[წინა] dddd LT-ზე',
52 sameElse : 'L'
53 },
54 relativeTime : {
55 future : function (s) {
56 return (/(წამი|წუთი|საათი|წელი)/).test(s) ?
57 s.replace(/ი$/, 'ში') :
58 s + 'ში';
59 },
60 past : function (s) {
61 if ((/(წამი|წუთი|საათი|დღე|თვე)/).test(s)) {
62 return s.replace(/(ი|ე)$/, 'ის წინ');
63 }
64 if ((/წელი/).test(s)) {
65 return s.replace(/წელი$/, 'წლის წინ');
66 }
67 },
68 s : 'რამდენიმე წამი',
69 m : 'წუთი',
70 mm : '%d წუთი',
71 h : 'საათი',
72 hh : '%d საათი',
73 d : 'დღე',
74 dd : '%d დღე',
75 M : 'თვე',
76 MM : '%d თვე',
77 y : 'წელი',
78 yy : '%d წელი'
79 },
80 ordinalParse: /0|1-ლი|მე-\d{1,2}|\d{1,2}-ე/,
81 ordinal : function (number) {
82 if (number === 0) {
83 return number;
84 }
85 if (number === 1) {
86 return number + '-ლი';
87 }
88 if ((number < 20) || (number <= 100 && (number % 20 === 0)) || (number % 100 === 0)) {
89 return 'მე-' + number;
90 }
91 return number + '-ე';
92 },
93 week : {
94 dow : 1,
95 doy : 7
96 }
97 });
98
99 return ka;
100
101 }));
0 //! moment.js locale configuration
1 //! locale : khmer (km)
2 //! author : Kruy Vanna : https://github.com/kruyvanna
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var km = moment.defineLocale('km', {
12 months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
13 monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
14 weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
15 weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
16 weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
17 longDateFormat: {
18 LT: 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L: 'DD/MM/YYYY',
21 LL: 'D MMMM YYYY',
22 LLL: 'D MMMM YYYY HH:mm',
23 LLLL: 'dddd, D MMMM YYYY HH:mm'
24 },
25 calendar: {
26 sameDay: '[ថ្ងៃនៈ ម៉ោង] LT',
27 nextDay: '[ស្អែក ម៉ោង] LT',
28 nextWeek: 'dddd [ម៉ោង] LT',
29 lastDay: '[ម្សិលមិញ ម៉ោង] LT',
30 lastWeek: 'dddd [សប្តាហ៍មុន] [ម៉ោង] LT',
31 sameElse: 'L'
32 },
33 relativeTime: {
34 future: '%sទៀត',
35 past: '%sមុន',
36 s: 'ប៉ុន្មានវិនាទី',
37 m: 'មួយនាទី',
38 mm: '%d នាទី',
39 h: 'មួយម៉ោង',
40 hh: '%d ម៉ោង',
41 d: 'មួយថ្ងៃ',
42 dd: '%d ថ្ងៃ',
43 M: 'មួយខែ',
44 MM: '%d ខែ',
45 y: 'មួយឆ្នាំ',
46 yy: '%d ឆ្នាំ'
47 },
48 week: {
49 dow: 1, // Monday is the first day of the week.
50 doy: 4 // The week that contains Jan 4th is the first week of the year.
51 }
52 });
53
54 return km;
55
56 }));
0 //! moment.js locale configuration
1 //! locale : korean (ko)
2 //!
3 //! authors
4 //!
5 //! - Kyungwook, Park : https://github.com/kyungw00k
6 //! - Jeeeyul Lee <jeeeyul@gmail.com>
7
8 (function (global, factory) {
9 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
10 typeof define === 'function' && define.amd ? define(['moment'], factory) :
11 factory(global.moment)
12 }(this, function (moment) { 'use strict';
13
14
15 var ko = moment.defineLocale('ko', {
16 months : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
17 monthsShort : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
18 weekdays : '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
19 weekdaysShort : '일_월_화_수_목_금_토'.split('_'),
20 weekdaysMin : '일_월_화_수_목_금_토'.split('_'),
21 longDateFormat : {
22 LT : 'A h시 m분',
23 LTS : 'A h시 m분 s초',
24 L : 'YYYY.MM.DD',
25 LL : 'YYYY년 MMMM D일',
26 LLL : 'YYYY년 MMMM D일 A h시 m분',
27 LLLL : 'YYYY년 MMMM D일 dddd A h시 m분'
28 },
29 calendar : {
30 sameDay : '오늘 LT',
31 nextDay : '내일 LT',
32 nextWeek : 'dddd LT',
33 lastDay : '어제 LT',
34 lastWeek : '지난주 dddd LT',
35 sameElse : 'L'
36 },
37 relativeTime : {
38 future : '%s 후',
39 past : '%s 전',
40 s : '몇초',
41 ss : '%d초',
42 m : '일분',
43 mm : '%d분',
44 h : '한시간',
45 hh : '%d시간',
46 d : '하루',
47 dd : '%d일',
48 M : '한달',
49 MM : '%d달',
50 y : '일년',
51 yy : '%d년'
52 },
53 ordinalParse : /\d{1,2}일/,
54 ordinal : '%d일',
55 meridiemParse : /오전|오후/,
56 isPM : function (token) {
57 return token === '오후';
58 },
59 meridiem : function (hour, minute, isUpper) {
60 return hour < 12 ? '오전' : '오후';
61 }
62 });
63
64 return ko;
65
66 }));
0 //! moment.js locale configuration
1 //! locale : Luxembourgish (lb)
2 //! author : mweimerskirch : https://github.com/mweimerskirch, David Raison : https://github.com/kwisatz
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 function processRelativeTime(number, withoutSuffix, key, isFuture) {
12 var format = {
13 'm': ['eng Minutt', 'enger Minutt'],
14 'h': ['eng Stonn', 'enger Stonn'],
15 'd': ['een Dag', 'engem Dag'],
16 'M': ['ee Mount', 'engem Mount'],
17 'y': ['ee Joer', 'engem Joer']
18 };
19 return withoutSuffix ? format[key][0] : format[key][1];
20 }
21 function processFutureTime(string) {
22 var number = string.substr(0, string.indexOf(' '));
23 if (eifelerRegelAppliesToNumber(number)) {
24 return 'a ' + string;
25 }
26 return 'an ' + string;
27 }
28 function processPastTime(string) {
29 var number = string.substr(0, string.indexOf(' '));
30 if (eifelerRegelAppliesToNumber(number)) {
31 return 'viru ' + string;
32 }
33 return 'virun ' + string;
34 }
35 /**
36 * Returns true if the word before the given number loses the '-n' ending.
37 * e.g. 'an 10 Deeg' but 'a 5 Deeg'
38 *
39 * @param number {integer}
40 * @returns {boolean}
41 */
42 function eifelerRegelAppliesToNumber(number) {
43 number = parseInt(number, 10);
44 if (isNaN(number)) {
45 return false;
46 }
47 if (number < 0) {
48 // Negative Number --> always true
49 return true;
50 } else if (number < 10) {
51 // Only 1 digit
52 if (4 <= number && number <= 7) {
53 return true;
54 }
55 return false;
56 } else if (number < 100) {
57 // 2 digits
58 var lastDigit = number % 10, firstDigit = number / 10;
59 if (lastDigit === 0) {
60 return eifelerRegelAppliesToNumber(firstDigit);
61 }
62 return eifelerRegelAppliesToNumber(lastDigit);
63 } else if (number < 10000) {
64 // 3 or 4 digits --> recursively check first digit
65 while (number >= 10) {
66 number = number / 10;
67 }
68 return eifelerRegelAppliesToNumber(number);
69 } else {
70 // Anything larger than 4 digits: recursively check first n-3 digits
71 number = number / 1000;
72 return eifelerRegelAppliesToNumber(number);
73 }
74 }
75
76 var lb = moment.defineLocale('lb', {
77 months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
78 monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
79 weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
80 weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
81 weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
82 longDateFormat: {
83 LT: 'H:mm [Auer]',
84 LTS: 'H:mm:ss [Auer]',
85 L: 'DD.MM.YYYY',
86 LL: 'D. MMMM YYYY',
87 LLL: 'D. MMMM YYYY H:mm [Auer]',
88 LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]'
89 },
90 calendar: {
91 sameDay: '[Haut um] LT',
92 sameElse: 'L',
93 nextDay: '[Muer um] LT',
94 nextWeek: 'dddd [um] LT',
95 lastDay: '[Gëschter um] LT',
96 lastWeek: function () {
97 // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
98 switch (this.day()) {
99 case 2:
100 case 4:
101 return '[Leschten] dddd [um] LT';
102 default:
103 return '[Leschte] dddd [um] LT';
104 }
105 }
106 },
107 relativeTime : {
108 future : processFutureTime,
109 past : processPastTime,
110 s : 'e puer Sekonnen',
111 m : processRelativeTime,
112 mm : '%d Minutten',
113 h : processRelativeTime,
114 hh : '%d Stonnen',
115 d : processRelativeTime,
116 dd : '%d Deeg',
117 M : processRelativeTime,
118 MM : '%d Méint',
119 y : processRelativeTime,
120 yy : '%d Joer'
121 },
122 ordinalParse: /\d{1,2}\./,
123 ordinal: '%d.',
124 week: {
125 dow: 1, // Monday is the first day of the week.
126 doy: 4 // The week that contains Jan 4th is the first week of the year.
127 }
128 });
129
130 return lb;
131
132 }));
0 //! moment.js locale configuration
1 //! locale : Lithuanian (lt)
2 //! author : Mindaugas Mozūras : https://github.com/mmozuras
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var units = {
12 'm' : 'minutė_minutės_minutę',
13 'mm': 'minutės_minučių_minutes',
14 'h' : 'valanda_valandos_valandą',
15 'hh': 'valandos_valandų_valandas',
16 'd' : 'diena_dienos_dieną',
17 'dd': 'dienos_dienų_dienas',
18 'M' : 'mėnuo_mėnesio_mėnesį',
19 'MM': 'mėnesiai_mėnesių_mėnesius',
20 'y' : 'metai_metų_metus',
21 'yy': 'metai_metų_metus'
22 },
23 weekDays = 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_');
24 function translateSeconds(number, withoutSuffix, key, isFuture) {
25 if (withoutSuffix) {
26 return 'kelios sekundės';
27 } else {
28 return isFuture ? 'kelių sekundžių' : 'kelias sekundes';
29 }
30 }
31 function monthsCaseReplace(m, format) {
32 var months = {
33 'nominative': 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
34 'accusative': 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_')
35 },
36 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
37 'accusative' :
38 'nominative';
39 return months[nounCase][m.month()];
40 }
41 function translateSingular(number, withoutSuffix, key, isFuture) {
42 return withoutSuffix ? forms(key)[0] : (isFuture ? forms(key)[1] : forms(key)[2]);
43 }
44 function special(number) {
45 return number % 10 === 0 || (number > 10 && number < 20);
46 }
47 function forms(key) {
48 return units[key].split('_');
49 }
50 function translate(number, withoutSuffix, key, isFuture) {
51 var result = number + ' ';
52 if (number === 1) {
53 return result + translateSingular(number, withoutSuffix, key[0], isFuture);
54 } else if (withoutSuffix) {
55 return result + (special(number) ? forms(key)[1] : forms(key)[0]);
56 } else {
57 if (isFuture) {
58 return result + forms(key)[1];
59 } else {
60 return result + (special(number) ? forms(key)[1] : forms(key)[2]);
61 }
62 }
63 }
64 function relativeWeekDay(moment, format) {
65 var nominative = format.indexOf('dddd HH:mm') === -1,
66 weekDay = weekDays[moment.day()];
67 return nominative ? weekDay : weekDay.substring(0, weekDay.length - 2) + 'į';
68 }
69
70 var lt = moment.defineLocale('lt', {
71 months : monthsCaseReplace,
72 monthsShort : 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'),
73 weekdays : relativeWeekDay,
74 weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
75 weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
76 longDateFormat : {
77 LT : 'HH:mm',
78 LTS : 'HH:mm:ss',
79 L : 'YYYY-MM-DD',
80 LL : 'YYYY [m.] MMMM D [d.]',
81 LLL : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
82 LLLL : 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]',
83 l : 'YYYY-MM-DD',
84 ll : 'YYYY [m.] MMMM D [d.]',
85 lll : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
86 llll : 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]'
87 },
88 calendar : {
89 sameDay : '[Šiandien] LT',
90 nextDay : '[Rytoj] LT',
91 nextWeek : 'dddd LT',
92 lastDay : '[Vakar] LT',
93 lastWeek : '[Praėjusį] dddd LT',
94 sameElse : 'L'
95 },
96 relativeTime : {
97 future : 'po %s',
98 past : 'prieš %s',
99 s : translateSeconds,
100 m : translateSingular,
101 mm : translate,
102 h : translateSingular,
103 hh : translate,
104 d : translateSingular,
105 dd : translate,
106 M : translateSingular,
107 MM : translate,
108 y : translateSingular,
109 yy : translate
110 },
111 ordinalParse: /\d{1,2}-oji/,
112 ordinal : function (number) {
113 return number + '-oji';
114 },
115 week : {
116 dow : 1, // Monday is the first day of the week.
117 doy : 4 // The week that contains Jan 4th is the first week of the year.
118 }
119 });
120
121 return lt;
122
123 }));
0 //! moment.js locale configuration
1 //! locale : latvian (lv)
2 //! author : Kristaps Karlsons : https://github.com/skakri
3 //! author : Jānis Elmeris : https://github.com/JanisE
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var units = {
13 'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
14 'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
15 'h': 'stundas_stundām_stunda_stundas'.split('_'),
16 'hh': 'stundas_stundām_stunda_stundas'.split('_'),
17 'd': 'dienas_dienām_diena_dienas'.split('_'),
18 'dd': 'dienas_dienām_diena_dienas'.split('_'),
19 'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
20 'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
21 'y': 'gada_gadiem_gads_gadi'.split('_'),
22 'yy': 'gada_gadiem_gads_gadi'.split('_')
23 };
24 /**
25 * @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
26 */
27 function format(forms, number, withoutSuffix) {
28 if (withoutSuffix) {
29 // E.g. "21 minūte", "3 minūtes".
30 return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
31 } else {
32 // E.g. "21 minūtes" as in "pēc 21 minūtes".
33 // E.g. "3 minūtēm" as in "pēc 3 minūtēm".
34 return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
35 }
36 }
37 function relativeTimeWithPlural(number, withoutSuffix, key) {
38 return number + ' ' + format(units[key], number, withoutSuffix);
39 }
40 function relativeTimeWithSingular(number, withoutSuffix, key) {
41 return format(units[key], number, withoutSuffix);
42 }
43 function relativeSeconds(number, withoutSuffix) {
44 return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
45 }
46
47 var lv = moment.defineLocale('lv', {
48 months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
49 monthsShort : 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'),
50 weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
51 weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
52 weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
53 longDateFormat : {
54 LT : 'HH:mm',
55 LTS : 'HH:mm:ss',
56 L : 'DD.MM.YYYY.',
57 LL : 'YYYY. [gada] D. MMMM',
58 LLL : 'YYYY. [gada] D. MMMM, HH:mm',
59 LLLL : 'YYYY. [gada] D. MMMM, dddd, HH:mm'
60 },
61 calendar : {
62 sameDay : '[Šodien pulksten] LT',
63 nextDay : '[Rīt pulksten] LT',
64 nextWeek : 'dddd [pulksten] LT',
65 lastDay : '[Vakar pulksten] LT',
66 lastWeek : '[Pagājušā] dddd [pulksten] LT',
67 sameElse : 'L'
68 },
69 relativeTime : {
70 future : 'pēc %s',
71 past : 'pirms %s',
72 s : relativeSeconds,
73 m : relativeTimeWithSingular,
74 mm : relativeTimeWithPlural,
75 h : relativeTimeWithSingular,
76 hh : relativeTimeWithPlural,
77 d : relativeTimeWithSingular,
78 dd : relativeTimeWithPlural,
79 M : relativeTimeWithSingular,
80 MM : relativeTimeWithPlural,
81 y : relativeTimeWithSingular,
82 yy : relativeTimeWithPlural
83 },
84 ordinalParse: /\d{1,2}\./,
85 ordinal : '%d.',
86 week : {
87 dow : 1, // Monday is the first day of the week.
88 doy : 4 // The week that contains Jan 4th is the first week of the year.
89 }
90 });
91
92 return lv;
93
94 }));
0 //! moment.js locale configuration
1 //! locale : Montenegrin (me)
2 //! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var translator = {
12 words: { //Different grammatical cases
13 m: ['jedan minut', 'jednog minuta'],
14 mm: ['minut', 'minuta', 'minuta'],
15 h: ['jedan sat', 'jednog sata'],
16 hh: ['sat', 'sata', 'sati'],
17 dd: ['dan', 'dana', 'dana'],
18 MM: ['mjesec', 'mjeseca', 'mjeseci'],
19 yy: ['godina', 'godine', 'godina']
20 },
21 correctGrammaticalCase: function (number, wordKey) {
22 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
23 },
24 translate: function (number, withoutSuffix, key) {
25 var wordKey = translator.words[key];
26 if (key.length === 1) {
27 return withoutSuffix ? wordKey[0] : wordKey[1];
28 } else {
29 return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
30 }
31 }
32 };
33
34 var me = moment.defineLocale('me', {
35 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
36 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
37 weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
38 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
39 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
40 longDateFormat: {
41 LT: 'H:mm',
42 LTS : 'H:mm:ss',
43 L: 'DD. MM. YYYY',
44 LL: 'D. MMMM YYYY',
45 LLL: 'D. MMMM YYYY H:mm',
46 LLLL: 'dddd, D. MMMM YYYY H:mm'
47 },
48 calendar: {
49 sameDay: '[danas u] LT',
50 nextDay: '[sjutra u] LT',
51
52 nextWeek: function () {
53 switch (this.day()) {
54 case 0:
55 return '[u] [nedjelju] [u] LT';
56 case 3:
57 return '[u] [srijedu] [u] LT';
58 case 6:
59 return '[u] [subotu] [u] LT';
60 case 1:
61 case 2:
62 case 4:
63 case 5:
64 return '[u] dddd [u] LT';
65 }
66 },
67 lastDay : '[juče u] LT',
68 lastWeek : function () {
69 var lastWeekDays = [
70 '[prošle] [nedjelje] [u] LT',
71 '[prošlog] [ponedjeljka] [u] LT',
72 '[prošlog] [utorka] [u] LT',
73 '[prošle] [srijede] [u] LT',
74 '[prošlog] [četvrtka] [u] LT',
75 '[prošlog] [petka] [u] LT',
76 '[prošle] [subote] [u] LT'
77 ];
78 return lastWeekDays[this.day()];
79 },
80 sameElse : 'L'
81 },
82 relativeTime : {
83 future : 'za %s',
84 past : 'prije %s',
85 s : 'nekoliko sekundi',
86 m : translator.translate,
87 mm : translator.translate,
88 h : translator.translate,
89 hh : translator.translate,
90 d : 'dan',
91 dd : translator.translate,
92 M : 'mjesec',
93 MM : translator.translate,
94 y : 'godinu',
95 yy : translator.translate
96 },
97 ordinalParse: /\d{1,2}\./,
98 ordinal : '%d.',
99 week : {
100 dow : 1, // Monday is the first day of the week.
101 doy : 7 // The week that contains Jan 1st is the first week of the year.
102 }
103 });
104
105 return me;
106
107 }));
0 //! moment.js locale configuration
1 //! locale : macedonian (mk)
2 //! author : Borislav Mickov : https://github.com/B0k0
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var mk = moment.defineLocale('mk', {
12 months : 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'),
13 monthsShort : 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'),
14 weekdays : 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'),
15 weekdaysShort : 'нед_пон_вто_сре_чет_пет_саб'.split('_'),
16 weekdaysMin : 'нe_пo_вт_ср_че_пе_сa'.split('_'),
17 longDateFormat : {
18 LT : 'H:mm',
19 LTS : 'H:mm:ss',
20 L : 'D.MM.YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY H:mm',
23 LLLL : 'dddd, D MMMM YYYY H:mm'
24 },
25 calendar : {
26 sameDay : '[Денес во] LT',
27 nextDay : '[Утре во] LT',
28 nextWeek : 'dddd [во] LT',
29 lastDay : '[Вчера во] LT',
30 lastWeek : function () {
31 switch (this.day()) {
32 case 0:
33 case 3:
34 case 6:
35 return '[Во изминатата] dddd [во] LT';
36 case 1:
37 case 2:
38 case 4:
39 case 5:
40 return '[Во изминатиот] dddd [во] LT';
41 }
42 },
43 sameElse : 'L'
44 },
45 relativeTime : {
46 future : 'после %s',
47 past : 'пред %s',
48 s : 'неколку секунди',
49 m : 'минута',
50 mm : '%d минути',
51 h : 'час',
52 hh : '%d часа',
53 d : 'ден',
54 dd : '%d дена',
55 M : 'месец',
56 MM : '%d месеци',
57 y : 'година',
58 yy : '%d години'
59 },
60 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
61 ordinal : function (number) {
62 var lastDigit = number % 10,
63 last2Digits = number % 100;
64 if (number === 0) {
65 return number + '-ев';
66 } else if (last2Digits === 0) {
67 return number + '-ен';
68 } else if (last2Digits > 10 && last2Digits < 20) {
69 return number + '-ти';
70 } else if (lastDigit === 1) {
71 return number + '-ви';
72 } else if (lastDigit === 2) {
73 return number + '-ри';
74 } else if (lastDigit === 7 || lastDigit === 8) {
75 return number + '-ми';
76 } else {
77 return number + '-ти';
78 }
79 },
80 week : {
81 dow : 1, // Monday is the first day of the week.
82 doy : 7 // The week that contains Jan 1st is the first week of the year.
83 }
84 });
85
86 return mk;
87
88 }));
0 //! moment.js locale configuration
1 //! locale : malayalam (ml)
2 //! author : Floyd Pink : https://github.com/floydpink
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var ml = moment.defineLocale('ml', {
12 months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
13 monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
14 weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
15 weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
16 weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
17 longDateFormat : {
18 LT : 'A h:mm -നു',
19 LTS : 'A h:mm:ss -നു',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY, A h:mm -നു',
23 LLLL : 'dddd, D MMMM YYYY, A h:mm -നു'
24 },
25 calendar : {
26 sameDay : '[ഇന്ന്] LT',
27 nextDay : '[നാളെ] LT',
28 nextWeek : 'dddd, LT',
29 lastDay : '[ഇന്നലെ] LT',
30 lastWeek : '[കഴിഞ്ഞ] dddd, LT',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : '%s കഴിഞ്ഞ്',
35 past : '%s മുൻപ്',
36 s : 'അൽപ നിമിഷങ്ങൾ',
37 m : 'ഒരു മിനിറ്റ്',
38 mm : '%d മിനിറ്റ്',
39 h : 'ഒരു മണിക്കൂർ',
40 hh : '%d മണിക്കൂർ',
41 d : 'ഒരു ദിവസം',
42 dd : '%d ദിവസം',
43 M : 'ഒരു മാസം',
44 MM : '%d മാസം',
45 y : 'ഒരു വർഷം',
46 yy : '%d വർഷം'
47 },
48 meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
49 isPM : function (input) {
50 return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
51 },
52 meridiem : function (hour, minute, isLower) {
53 if (hour < 4) {
54 return 'രാത്രി';
55 } else if (hour < 12) {
56 return 'രാവിലെ';
57 } else if (hour < 17) {
58 return 'ഉച്ച കഴിഞ്ഞ്';
59 } else if (hour < 20) {
60 return 'വൈകുന്നേരം';
61 } else {
62 return 'രാത്രി';
63 }
64 }
65 });
66
67 return ml;
68
69 }));
0 //! moment.js locale configuration
1 //! locale : Marathi (mr)
2 //! author : Harshad Kale : https://github.com/kalehv
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '१',
13 '2': '२',
14 '3': '३',
15 '4': '४',
16 '5': '५',
17 '6': '६',
18 '7': '७',
19 '8': '८',
20 '9': '९',
21 '0': '०'
22 },
23 numberMap = {
24 '१': '1',
25 '२': '2',
26 '३': '3',
27 '४': '4',
28 '५': '5',
29 '६': '6',
30 '७': '7',
31 '८': '8',
32 '९': '9',
33 '०': '0'
34 };
35
36 var mr = moment.defineLocale('mr', {
37 months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
38 monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
39 weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
40 weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
41 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
42 longDateFormat : {
43 LT : 'A h:mm वाजता',
44 LTS : 'A h:mm:ss वाजता',
45 L : 'DD/MM/YYYY',
46 LL : 'D MMMM YYYY',
47 LLL : 'D MMMM YYYY, A h:mm वाजता',
48 LLLL : 'dddd, D MMMM YYYY, A h:mm वाजता'
49 },
50 calendar : {
51 sameDay : '[आज] LT',
52 nextDay : '[उद्या] LT',
53 nextWeek : 'dddd, LT',
54 lastDay : '[काल] LT',
55 lastWeek: '[मागील] dddd, LT',
56 sameElse : 'L'
57 },
58 relativeTime : {
59 future : '%s नंतर',
60 past : '%s पूर्वी',
61 s : 'सेकंद',
62 m: 'एक मिनिट',
63 mm: '%d मिनिटे',
64 h : 'एक तास',
65 hh : '%d तास',
66 d : 'एक दिवस',
67 dd : '%d दिवस',
68 M : 'एक महिना',
69 MM : '%d महिने',
70 y : 'एक वर्ष',
71 yy : '%d वर्षे'
72 },
73 preparse: function (string) {
74 return string.replace(/[१२३४५६७८९०]/g, function (match) {
75 return numberMap[match];
76 });
77 },
78 postformat: function (string) {
79 return string.replace(/\d/g, function (match) {
80 return symbolMap[match];
81 });
82 },
83 meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी/,
84 meridiemHour : function (hour, meridiem) {
85 if (hour === 12) {
86 hour = 0;
87 }
88 if (meridiem === 'रात्री') {
89 return hour < 4 ? hour : hour + 12;
90 } else if (meridiem === 'सकाळी') {
91 return hour;
92 } else if (meridiem === 'दुपारी') {
93 return hour >= 10 ? hour : hour + 12;
94 } else if (meridiem === 'सायंकाळी') {
95 return hour + 12;
96 }
97 },
98 meridiem: function (hour, minute, isLower) {
99 if (hour < 4) {
100 return 'रात्री';
101 } else if (hour < 10) {
102 return 'सकाळी';
103 } else if (hour < 17) {
104 return 'दुपारी';
105 } else if (hour < 20) {
106 return 'सायंकाळी';
107 } else {
108 return 'रात्री';
109 }
110 },
111 week : {
112 dow : 0, // Sunday is the first day of the week.
113 doy : 6 // The week that contains Jan 1st is the first week of the year.
114 }
115 });
116
117 return mr;
118
119 }));
0 //! moment.js locale configuration
1 //! locale : Bahasa Malaysia (ms-MY)
2 //! author : Weldan Jamili : https://github.com/weldan
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var ms_my = moment.defineLocale('ms-my', {
12 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
13 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
14 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
15 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
16 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
17 longDateFormat : {
18 LT : 'HH.mm',
19 LTS : 'HH.mm.ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY [pukul] HH.mm',
23 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
24 },
25 meridiemParse: /pagi|tengahari|petang|malam/,
26 meridiemHour: function (hour, meridiem) {
27 if (hour === 12) {
28 hour = 0;
29 }
30 if (meridiem === 'pagi') {
31 return hour;
32 } else if (meridiem === 'tengahari') {
33 return hour >= 11 ? hour : hour + 12;
34 } else if (meridiem === 'petang' || meridiem === 'malam') {
35 return hour + 12;
36 }
37 },
38 meridiem : function (hours, minutes, isLower) {
39 if (hours < 11) {
40 return 'pagi';
41 } else if (hours < 15) {
42 return 'tengahari';
43 } else if (hours < 19) {
44 return 'petang';
45 } else {
46 return 'malam';
47 }
48 },
49 calendar : {
50 sameDay : '[Hari ini pukul] LT',
51 nextDay : '[Esok pukul] LT',
52 nextWeek : 'dddd [pukul] LT',
53 lastDay : '[Kelmarin pukul] LT',
54 lastWeek : 'dddd [lepas pukul] LT',
55 sameElse : 'L'
56 },
57 relativeTime : {
58 future : 'dalam %s',
59 past : '%s yang lepas',
60 s : 'beberapa saat',
61 m : 'seminit',
62 mm : '%d minit',
63 h : 'sejam',
64 hh : '%d jam',
65 d : 'sehari',
66 dd : '%d hari',
67 M : 'sebulan',
68 MM : '%d bulan',
69 y : 'setahun',
70 yy : '%d tahun'
71 },
72 week : {
73 dow : 1, // Monday is the first day of the week.
74 doy : 7 // The week that contains Jan 1st is the first week of the year.
75 }
76 });
77
78 return ms_my;
79
80 }));
0 //! moment.js locale configuration
1 //! locale : Bahasa Malaysia (ms-MY)
2 //! author : Weldan Jamili : https://github.com/weldan
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var ms = moment.defineLocale('ms', {
12 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
13 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
14 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
15 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
16 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
17 longDateFormat : {
18 LT : 'HH.mm',
19 LTS : 'HH.mm.ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY [pukul] HH.mm',
23 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
24 },
25 meridiemParse: /pagi|tengahari|petang|malam/,
26 meridiemHour: function (hour, meridiem) {
27 if (hour === 12) {
28 hour = 0;
29 }
30 if (meridiem === 'pagi') {
31 return hour;
32 } else if (meridiem === 'tengahari') {
33 return hour >= 11 ? hour : hour + 12;
34 } else if (meridiem === 'petang' || meridiem === 'malam') {
35 return hour + 12;
36 }
37 },
38 meridiem : function (hours, minutes, isLower) {
39 if (hours < 11) {
40 return 'pagi';
41 } else if (hours < 15) {
42 return 'tengahari';
43 } else if (hours < 19) {
44 return 'petang';
45 } else {
46 return 'malam';
47 }
48 },
49 calendar : {
50 sameDay : '[Hari ini pukul] LT',
51 nextDay : '[Esok pukul] LT',
52 nextWeek : 'dddd [pukul] LT',
53 lastDay : '[Kelmarin pukul] LT',
54 lastWeek : 'dddd [lepas pukul] LT',
55 sameElse : 'L'
56 },
57 relativeTime : {
58 future : 'dalam %s',
59 past : '%s yang lepas',
60 s : 'beberapa saat',
61 m : 'seminit',
62 mm : '%d minit',
63 h : 'sejam',
64 hh : '%d jam',
65 d : 'sehari',
66 dd : '%d hari',
67 M : 'sebulan',
68 MM : '%d bulan',
69 y : 'setahun',
70 yy : '%d tahun'
71 },
72 week : {
73 dow : 1, // Monday is the first day of the week.
74 doy : 7 // The week that contains Jan 1st is the first week of the year.
75 }
76 });
77
78 return ms;
79
80 }));
0 //! moment.js locale configuration
1 //! locale : Burmese (my)
2 //! author : Squar team, mysquar.com
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '၁',
13 '2': '၂',
14 '3': '၃',
15 '4': '၄',
16 '5': '၅',
17 '6': '၆',
18 '7': '၇',
19 '8': '၈',
20 '9': '၉',
21 '0': '၀'
22 }, numberMap = {
23 '၁': '1',
24 '၂': '2',
25 '၃': '3',
26 '၄': '4',
27 '၅': '5',
28 '၆': '6',
29 '၇': '7',
30 '၈': '8',
31 '၉': '9',
32 '၀': '0'
33 };
34
35 var my = moment.defineLocale('my', {
36 months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
37 monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
38 weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
39 weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
40 weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
41
42 longDateFormat: {
43 LT: 'HH:mm',
44 LTS: 'HH:mm:ss',
45 L: 'DD/MM/YYYY',
46 LL: 'D MMMM YYYY',
47 LLL: 'D MMMM YYYY HH:mm',
48 LLLL: 'dddd D MMMM YYYY HH:mm'
49 },
50 calendar: {
51 sameDay: '[ယနေ.] LT [မှာ]',
52 nextDay: '[မနက်ဖြန်] LT [မှာ]',
53 nextWeek: 'dddd LT [မှာ]',
54 lastDay: '[မနေ.က] LT [မှာ]',
55 lastWeek: '[ပြီးခဲ့သော] dddd LT [မှာ]',
56 sameElse: 'L'
57 },
58 relativeTime: {
59 future: 'လာမည့် %s မှာ',
60 past: 'လွန်ခဲ့သော %s က',
61 s: 'စက္ကန်.အနည်းငယ်',
62 m: 'တစ်မိနစ်',
63 mm: '%d မိနစ်',
64 h: 'တစ်နာရီ',
65 hh: '%d နာရီ',
66 d: 'တစ်ရက်',
67 dd: '%d ရက်',
68 M: 'တစ်လ',
69 MM: '%d လ',
70 y: 'တစ်နှစ်',
71 yy: '%d နှစ်'
72 },
73 preparse: function (string) {
74 return string.replace(/[၁၂၃၄၅၆၇၈၉၀]/g, function (match) {
75 return numberMap[match];
76 });
77 },
78 postformat: function (string) {
79 return string.replace(/\d/g, function (match) {
80 return symbolMap[match];
81 });
82 },
83 week: {
84 dow: 1, // Monday is the first day of the week.
85 doy: 4 // The week that contains Jan 1st is the first week of the year.
86 }
87 });
88
89 return my;
90
91 }));
0 //! moment.js locale configuration
1 //! locale : norwegian bokmål (nb)
2 //! authors : Espen Hovlandsdal : https://github.com/rexxars
3 //! Sigurd Gartmann : https://github.com/sigurdga
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var nb = moment.defineLocale('nb', {
13 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
14 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
15 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
16 weekdaysShort : 'søn_man_tirs_ons_tors_fre_lør'.split('_'),
17 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
18 longDateFormat : {
19 LT : 'H.mm',
20 LTS : 'H.mm.ss',
21 L : 'DD.MM.YYYY',
22 LL : 'D. MMMM YYYY',
23 LLL : 'D. MMMM YYYY [kl.] H.mm',
24 LLLL : 'dddd D. MMMM YYYY [kl.] H.mm'
25 },
26 calendar : {
27 sameDay: '[i dag kl.] LT',
28 nextDay: '[i morgen kl.] LT',
29 nextWeek: 'dddd [kl.] LT',
30 lastDay: '[i går kl.] LT',
31 lastWeek: '[forrige] dddd [kl.] LT',
32 sameElse: 'L'
33 },
34 relativeTime : {
35 future : 'om %s',
36 past : 'for %s siden',
37 s : 'noen sekunder',
38 m : 'ett minutt',
39 mm : '%d minutter',
40 h : 'en time',
41 hh : '%d timer',
42 d : 'en dag',
43 dd : '%d dager',
44 M : 'en måned',
45 MM : '%d måneder',
46 y : 'ett år',
47 yy : '%d år'
48 },
49 ordinalParse: /\d{1,2}\./,
50 ordinal : '%d.',
51 week : {
52 dow : 1, // Monday is the first day of the week.
53 doy : 4 // The week that contains Jan 4th is the first week of the year.
54 }
55 });
56
57 return nb;
58
59 }));
0 //! moment.js locale configuration
1 //! locale : nepali/nepalese
2 //! author : suvash : https://github.com/suvash
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var symbolMap = {
12 '1': '१',
13 '2': '२',
14 '3': '३',
15 '4': '४',
16 '5': '५',
17 '6': '६',
18 '7': '७',
19 '8': '८',
20 '9': '९',
21 '0': '०'
22 },
23 numberMap = {
24 '१': '1',
25 '२': '2',
26 '३': '3',
27 '४': '4',
28 '५': '5',
29 '६': '6',
30 '७': '7',
31 '८': '8',
32 '९': '9',
33 '०': '0'
34 };
35
36 var ne = moment.defineLocale('ne', {
37 months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
38 monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
39 weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
40 weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
41 weekdaysMin : 'आइ._सो._मङ्_बु._बि._शु._श.'.split('_'),
42 longDateFormat : {
43 LT : 'Aको h:mm बजे',
44 LTS : 'Aको h:mm:ss बजे',
45 L : 'DD/MM/YYYY',
46 LL : 'D MMMM YYYY',
47 LLL : 'D MMMM YYYY, Aको h:mm बजे',
48 LLLL : 'dddd, D MMMM YYYY, Aको h:mm बजे'
49 },
50 preparse: function (string) {
51 return string.replace(/[१२३४५६७८९०]/g, function (match) {
52 return numberMap[match];
53 });
54 },
55 postformat: function (string) {
56 return string.replace(/\d/g, function (match) {
57 return symbolMap[match];
58 });
59 },
60 meridiemParse: /राती|बिहान|दिउँसो|बेलुका|साँझ|राती/,
61 meridiemHour : function (hour, meridiem) {
62 if (hour === 12) {
63 hour = 0;
64 }
65 if (meridiem === 'राती') {
66 return hour < 3 ? hour : hour + 12;
67 } else if (meridiem === 'बिहान') {
68 return hour;
69 } else if (meridiem === 'दिउँसो') {
70 return hour >= 10 ? hour : hour + 12;
71 } else if (meridiem === 'बेलुका' || meridiem === 'साँझ') {
72 return hour + 12;
73 }
74 },
75 meridiem : function (hour, minute, isLower) {
76 if (hour < 3) {
77 return 'राती';
78 } else if (hour < 10) {
79 return 'बिहान';
80 } else if (hour < 15) {
81 return 'दिउँसो';
82 } else if (hour < 18) {
83 return 'बेलुका';
84 } else if (hour < 20) {
85 return 'साँझ';
86 } else {
87 return 'राती';
88 }
89 },
90 calendar : {
91 sameDay : '[आज] LT',
92 nextDay : '[भोली] LT',
93 nextWeek : '[आउँदो] dddd[,] LT',
94 lastDay : '[हिजो] LT',
95 lastWeek : '[गएको] dddd[,] LT',
96 sameElse : 'L'
97 },
98 relativeTime : {
99 future : '%sमा',
100 past : '%s अगाडी',
101 s : 'केही समय',
102 m : 'एक मिनेट',
103 mm : '%d मिनेट',
104 h : 'एक घण्टा',
105 hh : '%d घण्टा',
106 d : 'एक दिन',
107 dd : '%d दिन',
108 M : 'एक महिना',
109 MM : '%d महिना',
110 y : 'एक बर्ष',
111 yy : '%d बर्ष'
112 },
113 week : {
114 dow : 1, // Monday is the first day of the week.
115 doy : 7 // The week that contains Jan 1st is the first week of the year.
116 }
117 });
118
119 return ne;
120
121 }));
0 //! moment.js locale configuration
1 //! locale : dutch (nl)
2 //! author : Joris Röling : https://github.com/jjupiter
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'),
12 monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
13
14 var nl = moment.defineLocale('nl', {
15 months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
16 monthsShort : function (m, format) {
17 if (/-MMM-/.test(format)) {
18 return monthsShortWithoutDots[m.month()];
19 } else {
20 return monthsShortWithDots[m.month()];
21 }
22 },
23 weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
24 weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
25 weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
26 longDateFormat : {
27 LT : 'HH:mm',
28 LTS : 'HH:mm:ss',
29 L : 'DD-MM-YYYY',
30 LL : 'D MMMM YYYY',
31 LLL : 'D MMMM YYYY HH:mm',
32 LLLL : 'dddd D MMMM YYYY HH:mm'
33 },
34 calendar : {
35 sameDay: '[vandaag om] LT',
36 nextDay: '[morgen om] LT',
37 nextWeek: 'dddd [om] LT',
38 lastDay: '[gisteren om] LT',
39 lastWeek: '[afgelopen] dddd [om] LT',
40 sameElse: 'L'
41 },
42 relativeTime : {
43 future : 'over %s',
44 past : '%s geleden',
45 s : 'een paar seconden',
46 m : 'één minuut',
47 mm : '%d minuten',
48 h : 'één uur',
49 hh : '%d uur',
50 d : 'één dag',
51 dd : '%d dagen',
52 M : 'één maand',
53 MM : '%d maanden',
54 y : 'één jaar',
55 yy : '%d jaar'
56 },
57 ordinalParse: /\d{1,2}(ste|de)/,
58 ordinal : function (number) {
59 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
60 },
61 week : {
62 dow : 1, // Monday is the first day of the week.
63 doy : 4 // The week that contains Jan 4th is the first week of the year.
64 }
65 });
66
67 return nl;
68
69 }));
0 //! moment.js locale configuration
1 //! locale : norwegian nynorsk (nn)
2 //! author : https://github.com/mechuwind
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var nn = moment.defineLocale('nn', {
12 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
13 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
14 weekdays : 'sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag'.split('_'),
15 weekdaysShort : 'sun_mån_tys_ons_tor_fre_lau'.split('_'),
16 weekdaysMin : 'su_må_ty_on_to_fr_lø'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD.MM.YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd D MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[I dag klokka] LT',
27 nextDay: '[I morgon klokka] LT',
28 nextWeek: 'dddd [klokka] LT',
29 lastDay: '[I går klokka] LT',
30 lastWeek: '[Føregåande] dddd [klokka] LT',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : 'om %s',
35 past : 'for %s sidan',
36 s : 'nokre sekund',
37 m : 'eit minutt',
38 mm : '%d minutt',
39 h : 'ein time',
40 hh : '%d timar',
41 d : 'ein dag',
42 dd : '%d dagar',
43 M : 'ein månad',
44 MM : '%d månader',
45 y : 'eit år',
46 yy : '%d år'
47 },
48 ordinalParse: /\d{1,2}\./,
49 ordinal : '%d.',
50 week : {
51 dow : 1, // Monday is the first day of the week.
52 doy : 4 // The week that contains Jan 4th is the first week of the year.
53 }
54 });
55
56 return nn;
57
58 }));
0 //! moment.js locale configuration
1 //! locale : polish (pl)
2 //! author : Rafal Hirsz : https://github.com/evoL
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_'),
12 monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
13 function plural(n) {
14 return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1);
15 }
16 function translate(number, withoutSuffix, key) {
17 var result = number + ' ';
18 switch (key) {
19 case 'm':
20 return withoutSuffix ? 'minuta' : 'minutę';
21 case 'mm':
22 return result + (plural(number) ? 'minuty' : 'minut');
23 case 'h':
24 return withoutSuffix ? 'godzina' : 'godzinę';
25 case 'hh':
26 return result + (plural(number) ? 'godziny' : 'godzin');
27 case 'MM':
28 return result + (plural(number) ? 'miesiące' : 'miesięcy');
29 case 'yy':
30 return result + (plural(number) ? 'lata' : 'lat');
31 }
32 }
33
34 var pl = moment.defineLocale('pl', {
35 months : function (momentToFormat, format) {
36 if (format === '') {
37 // Hack: if format empty we know this is used to generate
38 // RegExp by moment. Give then back both valid forms of months
39 // in RegExp ready format.
40 return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
41 } else if (/D MMMM/.test(format)) {
42 return monthsSubjective[momentToFormat.month()];
43 } else {
44 return monthsNominative[momentToFormat.month()];
45 }
46 },
47 monthsShort : 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
48 weekdays : 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
49 weekdaysShort : 'nie_pon_wt_śr_czw_pt_sb'.split('_'),
50 weekdaysMin : 'N_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
51 longDateFormat : {
52 LT : 'HH:mm',
53 LTS : 'HH:mm:ss',
54 L : 'DD.MM.YYYY',
55 LL : 'D MMMM YYYY',
56 LLL : 'D MMMM YYYY HH:mm',
57 LLLL : 'dddd, D MMMM YYYY HH:mm'
58 },
59 calendar : {
60 sameDay: '[Dziś o] LT',
61 nextDay: '[Jutro o] LT',
62 nextWeek: '[W] dddd [o] LT',
63 lastDay: '[Wczoraj o] LT',
64 lastWeek: function () {
65 switch (this.day()) {
66 case 0:
67 return '[W zeszłą niedzielę o] LT';
68 case 3:
69 return '[W zeszłą środę o] LT';
70 case 6:
71 return '[W zeszłą sobotę o] LT';
72 default:
73 return '[W zeszły] dddd [o] LT';
74 }
75 },
76 sameElse: 'L'
77 },
78 relativeTime : {
79 future : 'za %s',
80 past : '%s temu',
81 s : 'kilka sekund',
82 m : translate,
83 mm : translate,
84 h : translate,
85 hh : translate,
86 d : '1 dzień',
87 dd : '%d dni',
88 M : 'miesiąc',
89 MM : translate,
90 y : 'rok',
91 yy : translate
92 },
93 ordinalParse: /\d{1,2}\./,
94 ordinal : '%d.',
95 week : {
96 dow : 1, // Monday is the first day of the week.
97 doy : 4 // The week that contains Jan 4th is the first week of the year.
98 }
99 });
100
101 return pl;
102
103 }));
0 //! moment.js locale configuration
1 //! locale : brazilian portuguese (pt-br)
2 //! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var pt_br = moment.defineLocale('pt-br', {
12 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
13 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
14 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
15 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
16 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D [de] MMMM [de] YYYY',
22 LLL : 'D [de] MMMM [de] YYYY [às] HH:mm',
23 LLLL : 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'
24 },
25 calendar : {
26 sameDay: '[Hoje às] LT',
27 nextDay: '[Amanhã às] LT',
28 nextWeek: 'dddd [às] LT',
29 lastDay: '[Ontem às] LT',
30 lastWeek: function () {
31 return (this.day() === 0 || this.day() === 6) ?
32 '[Último] dddd [às] LT' : // Saturday + Sunday
33 '[Última] dddd [às] LT'; // Monday - Friday
34 },
35 sameElse: 'L'
36 },
37 relativeTime : {
38 future : 'em %s',
39 past : '%s atrás',
40 s : 'poucos segundos',
41 m : 'um minuto',
42 mm : '%d minutos',
43 h : 'uma hora',
44 hh : '%d horas',
45 d : 'um dia',
46 dd : '%d dias',
47 M : 'um mês',
48 MM : '%d meses',
49 y : 'um ano',
50 yy : '%d anos'
51 },
52 ordinalParse: /\d{1,2}º/,
53 ordinal : '%dº'
54 });
55
56 return pt_br;
57
58 }));
0 //! moment.js locale configuration
1 //! locale : portuguese (pt)
2 //! author : Jefferson : https://github.com/jalex79
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var pt = moment.defineLocale('pt', {
12 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
13 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
14 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
15 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
16 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D [de] MMMM [de] YYYY',
22 LLL : 'D [de] MMMM [de] YYYY HH:mm',
23 LLLL : 'dddd, D [de] MMMM [de] YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[Hoje às] LT',
27 nextDay: '[Amanhã às] LT',
28 nextWeek: 'dddd [às] LT',
29 lastDay: '[Ontem às] LT',
30 lastWeek: function () {
31 return (this.day() === 0 || this.day() === 6) ?
32 '[Último] dddd [às] LT' : // Saturday + Sunday
33 '[Última] dddd [às] LT'; // Monday - Friday
34 },
35 sameElse: 'L'
36 },
37 relativeTime : {
38 future : 'em %s',
39 past : 'há %s',
40 s : 'segundos',
41 m : 'um minuto',
42 mm : '%d minutos',
43 h : 'uma hora',
44 hh : '%d horas',
45 d : 'um dia',
46 dd : '%d dias',
47 M : 'um mês',
48 MM : '%d meses',
49 y : 'um ano',
50 yy : '%d anos'
51 },
52 ordinalParse: /\d{1,2}º/,
53 ordinal : '%dº',
54 week : {
55 dow : 1, // Monday is the first day of the week.
56 doy : 4 // The week that contains Jan 4th is the first week of the year.
57 }
58 });
59
60 return pt;
61
62 }));
0 //! moment.js locale configuration
1 //! locale : romanian (ro)
2 //! author : Vlad Gurdiga : https://github.com/gurdiga
3 //! author : Valentin Agachi : https://github.com/avaly
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 function relativeTimeWithPlural(number, withoutSuffix, key) {
13 var format = {
14 'mm': 'minute',
15 'hh': 'ore',
16 'dd': 'zile',
17 'MM': 'luni',
18 'yy': 'ani'
19 },
20 separator = ' ';
21 if (number % 100 >= 20 || (number >= 100 && number % 100 === 0)) {
22 separator = ' de ';
23 }
24 return number + separator + format[key];
25 }
26
27 var ro = moment.defineLocale('ro', {
28 months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
29 monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
30 weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
31 weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
32 weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
33 longDateFormat : {
34 LT : 'H:mm',
35 LTS : 'H:mm:ss',
36 L : 'DD.MM.YYYY',
37 LL : 'D MMMM YYYY',
38 LLL : 'D MMMM YYYY H:mm',
39 LLLL : 'dddd, D MMMM YYYY H:mm'
40 },
41 calendar : {
42 sameDay: '[azi la] LT',
43 nextDay: '[mâine la] LT',
44 nextWeek: 'dddd [la] LT',
45 lastDay: '[ieri la] LT',
46 lastWeek: '[fosta] dddd [la] LT',
47 sameElse: 'L'
48 },
49 relativeTime : {
50 future : 'peste %s',
51 past : '%s în urmă',
52 s : 'câteva secunde',
53 m : 'un minut',
54 mm : relativeTimeWithPlural,
55 h : 'o oră',
56 hh : relativeTimeWithPlural,
57 d : 'o zi',
58 dd : relativeTimeWithPlural,
59 M : 'o lună',
60 MM : relativeTimeWithPlural,
61 y : 'un an',
62 yy : relativeTimeWithPlural
63 },
64 week : {
65 dow : 1, // Monday is the first day of the week.
66 doy : 7 // The week that contains Jan 1st is the first week of the year.
67 }
68 });
69
70 return ro;
71
72 }));
0 //! moment.js locale configuration
1 //! locale : russian (ru)
2 //! author : Viktorminator : https://github.com/Viktorminator
3 //! Author : Menelion Elensúle : https://github.com/Oire
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 function plural(word, num) {
13 var forms = word.split('_');
14 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
15 }
16 function relativeTimeWithPlural(number, withoutSuffix, key) {
17 var format = {
18 'mm': withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
19 'hh': 'час_часа_часов',
20 'dd': 'день_дня_дней',
21 'MM': 'месяц_месяца_месяцев',
22 'yy': 'год_года_лет'
23 };
24 if (key === 'm') {
25 return withoutSuffix ? 'минута' : 'минуту';
26 }
27 else {
28 return number + ' ' + plural(format[key], +number);
29 }
30 }
31 function monthsCaseReplace(m, format) {
32 var months = {
33 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
34 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
35 },
36 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
37 'accusative' :
38 'nominative';
39 return months[nounCase][m.month()];
40 }
41 function monthsShortCaseReplace(m, format) {
42 var monthsShort = {
43 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
44 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
45 },
46 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
47 'accusative' :
48 'nominative';
49 return monthsShort[nounCase][m.month()];
50 }
51 function weekdaysCaseReplace(m, format) {
52 var weekdays = {
53 'nominative': 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
54 'accusative': 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_')
55 },
56 nounCase = (/\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/).test(format) ?
57 'accusative' :
58 'nominative';
59 return weekdays[nounCase][m.day()];
60 }
61
62 var ru = moment.defineLocale('ru', {
63 months : monthsCaseReplace,
64 monthsShort : monthsShortCaseReplace,
65 weekdays : weekdaysCaseReplace,
66 weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
67 weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
68 monthsParse : [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i],
69 longDateFormat : {
70 LT : 'HH:mm',
71 LTS : 'HH:mm:ss',
72 L : 'DD.MM.YYYY',
73 LL : 'D MMMM YYYY г.',
74 LLL : 'D MMMM YYYY г., HH:mm',
75 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
76 },
77 calendar : {
78 sameDay: '[Сегодня в] LT',
79 nextDay: '[Завтра в] LT',
80 lastDay: '[Вчера в] LT',
81 nextWeek: function () {
82 return this.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
83 },
84 lastWeek: function (now) {
85 if (now.week() !== this.week()) {
86 switch (this.day()) {
87 case 0:
88 return '[В прошлое] dddd [в] LT';
89 case 1:
90 case 2:
91 case 4:
92 return '[В прошлый] dddd [в] LT';
93 case 3:
94 case 5:
95 case 6:
96 return '[В прошлую] dddd [в] LT';
97 }
98 } else {
99 if (this.day() === 2) {
100 return '[Во] dddd [в] LT';
101 } else {
102 return '[В] dddd [в] LT';
103 }
104 }
105 },
106 sameElse: 'L'
107 },
108 relativeTime : {
109 future : 'через %s',
110 past : '%s назад',
111 s : 'несколько секунд',
112 m : relativeTimeWithPlural,
113 mm : relativeTimeWithPlural,
114 h : 'час',
115 hh : relativeTimeWithPlural,
116 d : 'день',
117 dd : relativeTimeWithPlural,
118 M : 'месяц',
119 MM : relativeTimeWithPlural,
120 y : 'год',
121 yy : relativeTimeWithPlural
122 },
123 meridiemParse: /ночи|утра|дня|вечера/i,
124 isPM : function (input) {
125 return /^(дня|вечера)$/.test(input);
126 },
127 meridiem : function (hour, minute, isLower) {
128 if (hour < 4) {
129 return 'ночи';
130 } else if (hour < 12) {
131 return 'утра';
132 } else if (hour < 17) {
133 return 'дня';
134 } else {
135 return 'вечера';
136 }
137 },
138 ordinalParse: /\d{1,2}-(й|го|я)/,
139 ordinal: function (number, period) {
140 switch (period) {
141 case 'M':
142 case 'd':
143 case 'DDD':
144 return number + '-й';
145 case 'D':
146 return number + '-го';
147 case 'w':
148 case 'W':
149 return number + '-я';
150 default:
151 return number;
152 }
153 },
154 week : {
155 dow : 1, // Monday is the first day of the week.
156 doy : 7 // The week that contains Jan 1st is the first week of the year.
157 }
158 });
159
160 return ru;
161
162 }));
0 //! moment.js locale configuration
1 //! locale : Sinhalese (si)
2 //! author : Sampath Sitinamaluwa : https://github.com/sampathsris
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var si = moment.defineLocale('si', {
12 months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්‍රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
13 monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
14 weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
15 weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'),
16 weekdaysMin : 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'),
17 longDateFormat : {
18 LT : 'a h:mm',
19 LTS : 'a h:mm:ss',
20 L : 'YYYY/MM/DD',
21 LL : 'YYYY MMMM D',
22 LLL : 'YYYY MMMM D, a h:mm',
23 LLLL : 'YYYY MMMM D [වැනි] dddd, a h:mm:ss'
24 },
25 calendar : {
26 sameDay : '[අද] LT[ට]',
27 nextDay : '[හෙට] LT[ට]',
28 nextWeek : 'dddd LT[ට]',
29 lastDay : '[ඊයේ] LT[ට]',
30 lastWeek : '[පසුගිය] dddd LT[ට]',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : '%sකින්',
35 past : '%sකට පෙර',
36 s : 'තත්පර කිහිපය',
37 m : 'මිනිත්තුව',
38 mm : 'මිනිත්තු %d',
39 h : 'පැය',
40 hh : 'පැය %d',
41 d : 'දිනය',
42 dd : 'දින %d',
43 M : 'මාසය',
44 MM : 'මාස %d',
45 y : 'වසර',
46 yy : 'වසර %d'
47 },
48 ordinalParse: /\d{1,2} වැනි/,
49 ordinal : function (number) {
50 return number + ' වැනි';
51 },
52 meridiem : function (hours, minutes, isLower) {
53 if (hours > 11) {
54 return isLower ? 'ප.ව.' : 'පස් වරු';
55 } else {
56 return isLower ? 'පෙ.ව.' : 'පෙර වරු';
57 }
58 }
59 });
60
61 return si;
62
63 }));
0 //! moment.js locale configuration
1 //! locale : slovak (sk)
2 //! author : Martin Minka : https://github.com/k2s
3 //! based on work of petrbela : https://github.com/petrbela
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var months = 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_'),
13 monthsShort = 'jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec'.split('_');
14 function plural(n) {
15 return (n > 1) && (n < 5);
16 }
17 function translate(number, withoutSuffix, key, isFuture) {
18 var result = number + ' ';
19 switch (key) {
20 case 's': // a few seconds / in a few seconds / a few seconds ago
21 return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
22 case 'm': // a minute / in a minute / a minute ago
23 return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou');
24 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
25 if (withoutSuffix || isFuture) {
26 return result + (plural(number) ? 'minúty' : 'minút');
27 } else {
28 return result + 'minútami';
29 }
30 break;
31 case 'h': // an hour / in an hour / an hour ago
32 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
33 case 'hh': // 9 hours / in 9 hours / 9 hours ago
34 if (withoutSuffix || isFuture) {
35 return result + (plural(number) ? 'hodiny' : 'hodín');
36 } else {
37 return result + 'hodinami';
38 }
39 break;
40 case 'd': // a day / in a day / a day ago
41 return (withoutSuffix || isFuture) ? 'deň' : 'dňom';
42 case 'dd': // 9 days / in 9 days / 9 days ago
43 if (withoutSuffix || isFuture) {
44 return result + (plural(number) ? 'dni' : 'dní');
45 } else {
46 return result + 'dňami';
47 }
48 break;
49 case 'M': // a month / in a month / a month ago
50 return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom';
51 case 'MM': // 9 months / in 9 months / 9 months ago
52 if (withoutSuffix || isFuture) {
53 return result + (plural(number) ? 'mesiace' : 'mesiacov');
54 } else {
55 return result + 'mesiacmi';
56 }
57 break;
58 case 'y': // a year / in a year / a year ago
59 return (withoutSuffix || isFuture) ? 'rok' : 'rokom';
60 case 'yy': // 9 years / in 9 years / 9 years ago
61 if (withoutSuffix || isFuture) {
62 return result + (plural(number) ? 'roky' : 'rokov');
63 } else {
64 return result + 'rokmi';
65 }
66 break;
67 }
68 }
69
70 var sk = moment.defineLocale('sk', {
71 months : months,
72 monthsShort : monthsShort,
73 monthsParse : (function (months, monthsShort) {
74 var i, _monthsParse = [];
75 for (i = 0; i < 12; i++) {
76 // use custom parser to solve problem with July (červenec)
77 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
78 }
79 return _monthsParse;
80 }(months, monthsShort)),
81 weekdays : 'nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota'.split('_'),
82 weekdaysShort : 'ne_po_ut_st_št_pi_so'.split('_'),
83 weekdaysMin : 'ne_po_ut_st_št_pi_so'.split('_'),
84 longDateFormat : {
85 LT: 'H:mm',
86 LTS : 'H:mm:ss',
87 L : 'DD.MM.YYYY',
88 LL : 'D. MMMM YYYY',
89 LLL : 'D. MMMM YYYY H:mm',
90 LLLL : 'dddd D. MMMM YYYY H:mm'
91 },
92 calendar : {
93 sameDay: '[dnes o] LT',
94 nextDay: '[zajtra o] LT',
95 nextWeek: function () {
96 switch (this.day()) {
97 case 0:
98 return '[v nedeľu o] LT';
99 case 1:
100 case 2:
101 return '[v] dddd [o] LT';
102 case 3:
103 return '[v stredu o] LT';
104 case 4:
105 return '[vo štvrtok o] LT';
106 case 5:
107 return '[v piatok o] LT';
108 case 6:
109 return '[v sobotu o] LT';
110 }
111 },
112 lastDay: '[včera o] LT',
113 lastWeek: function () {
114 switch (this.day()) {
115 case 0:
116 return '[minulú nedeľu o] LT';
117 case 1:
118 case 2:
119 return '[minulý] dddd [o] LT';
120 case 3:
121 return '[minulú stredu o] LT';
122 case 4:
123 case 5:
124 return '[minulý] dddd [o] LT';
125 case 6:
126 return '[minulú sobotu o] LT';
127 }
128 },
129 sameElse: 'L'
130 },
131 relativeTime : {
132 future : 'za %s',
133 past : 'pred %s',
134 s : translate,
135 m : translate,
136 mm : translate,
137 h : translate,
138 hh : translate,
139 d : translate,
140 dd : translate,
141 M : translate,
142 MM : translate,
143 y : translate,
144 yy : translate
145 },
146 ordinalParse: /\d{1,2}\./,
147 ordinal : '%d.',
148 week : {
149 dow : 1, // Monday is the first day of the week.
150 doy : 4 // The week that contains Jan 4th is the first week of the year.
151 }
152 });
153
154 return sk;
155
156 }));
0 //! moment.js locale configuration
1 //! locale : slovenian (sl)
2 //! author : Robert Sedovšek : https://github.com/sedovsek
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 function processRelativeTime(number, withoutSuffix, key, isFuture) {
12 var result = number + ' ';
13 switch (key) {
14 case 's':
15 return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
16 case 'm':
17 return withoutSuffix ? 'ena minuta' : 'eno minuto';
18 case 'mm':
19 if (number === 1) {
20 result += withoutSuffix ? 'minuta' : 'minuto';
21 } else if (number === 2) {
22 result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
23 } else if (number < 5) {
24 result += withoutSuffix || isFuture ? 'minute' : 'minutami';
25 } else {
26 result += withoutSuffix || isFuture ? 'minut' : 'minutami';
27 }
28 return result;
29 case 'h':
30 return withoutSuffix ? 'ena ura' : 'eno uro';
31 case 'hh':
32 if (number === 1) {
33 result += withoutSuffix ? 'ura' : 'uro';
34 } else if (number === 2) {
35 result += withoutSuffix || isFuture ? 'uri' : 'urama';
36 } else if (number < 5) {
37 result += withoutSuffix || isFuture ? 'ure' : 'urami';
38 } else {
39 result += withoutSuffix || isFuture ? 'ur' : 'urami';
40 }
41 return result;
42 case 'd':
43 return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
44 case 'dd':
45 if (number === 1) {
46 result += withoutSuffix || isFuture ? 'dan' : 'dnem';
47 } else if (number === 2) {
48 result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
49 } else {
50 result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
51 }
52 return result;
53 case 'M':
54 return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
55 case 'MM':
56 if (number === 1) {
57 result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
58 } else if (number === 2) {
59 result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
60 } else if (number < 5) {
61 result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
62 } else {
63 result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
64 }
65 return result;
66 case 'y':
67 return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
68 case 'yy':
69 if (number === 1) {
70 result += withoutSuffix || isFuture ? 'leto' : 'letom';
71 } else if (number === 2) {
72 result += withoutSuffix || isFuture ? 'leti' : 'letoma';
73 } else if (number < 5) {
74 result += withoutSuffix || isFuture ? 'leta' : 'leti';
75 } else {
76 result += withoutSuffix || isFuture ? 'let' : 'leti';
77 }
78 return result;
79 }
80 }
81
82 var sl = moment.defineLocale('sl', {
83 months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
84 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
85 weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
86 weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
87 weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
88 longDateFormat : {
89 LT : 'H:mm',
90 LTS : 'H:mm:ss',
91 L : 'DD. MM. YYYY',
92 LL : 'D. MMMM YYYY',
93 LLL : 'D. MMMM YYYY H:mm',
94 LLLL : 'dddd, D. MMMM YYYY H:mm'
95 },
96 calendar : {
97 sameDay : '[danes ob] LT',
98 nextDay : '[jutri ob] LT',
99
100 nextWeek : function () {
101 switch (this.day()) {
102 case 0:
103 return '[v] [nedeljo] [ob] LT';
104 case 3:
105 return '[v] [sredo] [ob] LT';
106 case 6:
107 return '[v] [soboto] [ob] LT';
108 case 1:
109 case 2:
110 case 4:
111 case 5:
112 return '[v] dddd [ob] LT';
113 }
114 },
115 lastDay : '[včeraj ob] LT',
116 lastWeek : function () {
117 switch (this.day()) {
118 case 0:
119 return '[prejšnjo] [nedeljo] [ob] LT';
120 case 3:
121 return '[prejšnjo] [sredo] [ob] LT';
122 case 6:
123 return '[prejšnjo] [soboto] [ob] LT';
124 case 1:
125 case 2:
126 case 4:
127 case 5:
128 return '[prejšnji] dddd [ob] LT';
129 }
130 },
131 sameElse : 'L'
132 },
133 relativeTime : {
134 future : 'čez %s',
135 past : 'pred %s',
136 s : processRelativeTime,
137 m : processRelativeTime,
138 mm : processRelativeTime,
139 h : processRelativeTime,
140 hh : processRelativeTime,
141 d : processRelativeTime,
142 dd : processRelativeTime,
143 M : processRelativeTime,
144 MM : processRelativeTime,
145 y : processRelativeTime,
146 yy : processRelativeTime
147 },
148 ordinalParse: /\d{1,2}\./,
149 ordinal : '%d.',
150 week : {
151 dow : 1, // Monday is the first day of the week.
152 doy : 7 // The week that contains Jan 1st is the first week of the year.
153 }
154 });
155
156 return sl;
157
158 }));
0 //! moment.js locale configuration
1 //! locale : Albanian (sq)
2 //! author : Flakërim Ismani : https://github.com/flakerimi
3 //! author: Menelion Elensúle: https://github.com/Oire (tests)
4 //! author : Oerd Cukalla : https://github.com/oerd (fixes)
5
6 (function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
8 typeof define === 'function' && define.amd ? define(['moment'], factory) :
9 factory(global.moment)
10 }(this, function (moment) { 'use strict';
11
12
13 var sq = moment.defineLocale('sq', {
14 months : 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'),
15 monthsShort : 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'),
16 weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
17 weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
18 weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
19 meridiemParse: /PD|MD/,
20 isPM: function (input) {
21 return input.charAt(0) === 'M';
22 },
23 meridiem : function (hours, minutes, isLower) {
24 return hours < 12 ? 'PD' : 'MD';
25 },
26 longDateFormat : {
27 LT : 'HH:mm',
28 LTS : 'HH:mm:ss',
29 L : 'DD/MM/YYYY',
30 LL : 'D MMMM YYYY',
31 LLL : 'D MMMM YYYY HH:mm',
32 LLLL : 'dddd, D MMMM YYYY HH:mm'
33 },
34 calendar : {
35 sameDay : '[Sot në] LT',
36 nextDay : '[Nesër në] LT',
37 nextWeek : 'dddd [në] LT',
38 lastDay : '[Dje në] LT',
39 lastWeek : 'dddd [e kaluar në] LT',
40 sameElse : 'L'
41 },
42 relativeTime : {
43 future : 'në %s',
44 past : '%s më parë',
45 s : 'disa sekonda',
46 m : 'një minutë',
47 mm : '%d minuta',
48 h : 'një orë',
49 hh : '%d orë',
50 d : 'një ditë',
51 dd : '%d ditë',
52 M : 'një muaj',
53 MM : '%d muaj',
54 y : 'një vit',
55 yy : '%d vite'
56 },
57 ordinalParse: /\d{1,2}\./,
58 ordinal : '%d.',
59 week : {
60 dow : 1, // Monday is the first day of the week.
61 doy : 4 // The week that contains Jan 4th is the first week of the year.
62 }
63 });
64
65 return sq;
66
67 }));
0 //! moment.js locale configuration
1 //! locale : Serbian-cyrillic (sr-cyrl)
2 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var translator = {
12 words: { //Different grammatical cases
13 m: ['један минут', 'једне минуте'],
14 mm: ['минут', 'минуте', 'минута'],
15 h: ['један сат', 'једног сата'],
16 hh: ['сат', 'сата', 'сати'],
17 dd: ['дан', 'дана', 'дана'],
18 MM: ['месец', 'месеца', 'месеци'],
19 yy: ['година', 'године', 'година']
20 },
21 correctGrammaticalCase: function (number, wordKey) {
22 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
23 },
24 translate: function (number, withoutSuffix, key) {
25 var wordKey = translator.words[key];
26 if (key.length === 1) {
27 return withoutSuffix ? wordKey[0] : wordKey[1];
28 } else {
29 return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
30 }
31 }
32 };
33
34 var sr_cyrl = moment.defineLocale('sr-cyrl', {
35 months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
36 monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
37 weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
38 weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
39 weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
40 longDateFormat: {
41 LT: 'H:mm',
42 LTS : 'H:mm:ss',
43 L: 'DD. MM. YYYY',
44 LL: 'D. MMMM YYYY',
45 LLL: 'D. MMMM YYYY H:mm',
46 LLLL: 'dddd, D. MMMM YYYY H:mm'
47 },
48 calendar: {
49 sameDay: '[данас у] LT',
50 nextDay: '[сутра у] LT',
51 nextWeek: function () {
52 switch (this.day()) {
53 case 0:
54 return '[у] [недељу] [у] LT';
55 case 3:
56 return '[у] [среду] [у] LT';
57 case 6:
58 return '[у] [суботу] [у] LT';
59 case 1:
60 case 2:
61 case 4:
62 case 5:
63 return '[у] dddd [у] LT';
64 }
65 },
66 lastDay : '[јуче у] LT',
67 lastWeek : function () {
68 var lastWeekDays = [
69 '[прошле] [недеље] [у] LT',
70 '[прошлог] [понедељка] [у] LT',
71 '[прошлог] [уторка] [у] LT',
72 '[прошле] [среде] [у] LT',
73 '[прошлог] [четвртка] [у] LT',
74 '[прошлог] [петка] [у] LT',
75 '[прошле] [суботе] [у] LT'
76 ];
77 return lastWeekDays[this.day()];
78 },
79 sameElse : 'L'
80 },
81 relativeTime : {
82 future : 'за %s',
83 past : 'пре %s',
84 s : 'неколико секунди',
85 m : translator.translate,
86 mm : translator.translate,
87 h : translator.translate,
88 hh : translator.translate,
89 d : 'дан',
90 dd : translator.translate,
91 M : 'месец',
92 MM : translator.translate,
93 y : 'годину',
94 yy : translator.translate
95 },
96 ordinalParse: /\d{1,2}\./,
97 ordinal : '%d.',
98 week : {
99 dow : 1, // Monday is the first day of the week.
100 doy : 7 // The week that contains Jan 1st is the first week of the year.
101 }
102 });
103
104 return sr_cyrl;
105
106 }));
0 //! moment.js locale configuration
1 //! locale : Serbian-latin (sr)
2 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var translator = {
12 words: { //Different grammatical cases
13 m: ['jedan minut', 'jedne minute'],
14 mm: ['minut', 'minute', 'minuta'],
15 h: ['jedan sat', 'jednog sata'],
16 hh: ['sat', 'sata', 'sati'],
17 dd: ['dan', 'dana', 'dana'],
18 MM: ['mesec', 'meseca', 'meseci'],
19 yy: ['godina', 'godine', 'godina']
20 },
21 correctGrammaticalCase: function (number, wordKey) {
22 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
23 },
24 translate: function (number, withoutSuffix, key) {
25 var wordKey = translator.words[key];
26 if (key.length === 1) {
27 return withoutSuffix ? wordKey[0] : wordKey[1];
28 } else {
29 return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
30 }
31 }
32 };
33
34 var sr = moment.defineLocale('sr', {
35 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
36 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
37 weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
38 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
39 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
40 longDateFormat: {
41 LT: 'H:mm',
42 LTS : 'H:mm:ss',
43 L: 'DD. MM. YYYY',
44 LL: 'D. MMMM YYYY',
45 LLL: 'D. MMMM YYYY H:mm',
46 LLLL: 'dddd, D. MMMM YYYY H:mm'
47 },
48 calendar: {
49 sameDay: '[danas u] LT',
50 nextDay: '[sutra u] LT',
51 nextWeek: function () {
52 switch (this.day()) {
53 case 0:
54 return '[u] [nedelju] [u] LT';
55 case 3:
56 return '[u] [sredu] [u] LT';
57 case 6:
58 return '[u] [subotu] [u] LT';
59 case 1:
60 case 2:
61 case 4:
62 case 5:
63 return '[u] dddd [u] LT';
64 }
65 },
66 lastDay : '[juče u] LT',
67 lastWeek : function () {
68 var lastWeekDays = [
69 '[prošle] [nedelje] [u] LT',
70 '[prošlog] [ponedeljka] [u] LT',
71 '[prošlog] [utorka] [u] LT',
72 '[prošle] [srede] [u] LT',
73 '[prošlog] [četvrtka] [u] LT',
74 '[prošlog] [petka] [u] LT',
75 '[prošle] [subote] [u] LT'
76 ];
77 return lastWeekDays[this.day()];
78 },
79 sameElse : 'L'
80 },
81 relativeTime : {
82 future : 'za %s',
83 past : 'pre %s',
84 s : 'nekoliko sekundi',
85 m : translator.translate,
86 mm : translator.translate,
87 h : translator.translate,
88 hh : translator.translate,
89 d : 'dan',
90 dd : translator.translate,
91 M : 'mesec',
92 MM : translator.translate,
93 y : 'godinu',
94 yy : translator.translate
95 },
96 ordinalParse: /\d{1,2}\./,
97 ordinal : '%d.',
98 week : {
99 dow : 1, // Monday is the first day of the week.
100 doy : 7 // The week that contains Jan 1st is the first week of the year.
101 }
102 });
103
104 return sr;
105
106 }));
0 //! moment.js locale configuration
1 //! locale : swedish (sv)
2 //! author : Jens Alm : https://github.com/ulmus
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var sv = moment.defineLocale('sv', {
12 months : 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
13 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
14 weekdays : 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
15 weekdaysShort : 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
16 weekdaysMin : 'sö_må_ti_on_to_fr_lö'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'YYYY-MM-DD',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd D MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[Idag] LT',
27 nextDay: '[Imorgon] LT',
28 lastDay: '[Igår] LT',
29 nextWeek: '[På] dddd LT',
30 lastWeek: '[I] dddd[s] LT',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : 'om %s',
35 past : 'för %s sedan',
36 s : 'några sekunder',
37 m : 'en minut',
38 mm : '%d minuter',
39 h : 'en timme',
40 hh : '%d timmar',
41 d : 'en dag',
42 dd : '%d dagar',
43 M : 'en månad',
44 MM : '%d månader',
45 y : 'ett år',
46 yy : '%d år'
47 },
48 ordinalParse: /\d{1,2}(e|a)/,
49 ordinal : function (number) {
50 var b = number % 10,
51 output = (~~(number % 100 / 10) === 1) ? 'e' :
52 (b === 1) ? 'a' :
53 (b === 2) ? 'a' :
54 (b === 3) ? 'e' : 'e';
55 return number + output;
56 },
57 week : {
58 dow : 1, // Monday is the first day of the week.
59 doy : 4 // The week that contains Jan 4th is the first week of the year.
60 }
61 });
62
63 return sv;
64
65 }));
0 //! moment.js locale configuration
1 //! locale : tamil (ta)
2 //! author : Arjunkumar Krishnamoorthy : https://github.com/tk120404
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var ta = moment.defineLocale('ta', {
12 months : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
13 monthsShort : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
14 weekdays : 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'),
15 weekdaysShort : 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'),
16 weekdaysMin : 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY, HH:mm',
23 LLLL : 'dddd, D MMMM YYYY, HH:mm'
24 },
25 calendar : {
26 sameDay : '[இன்று] LT',
27 nextDay : '[நாளை] LT',
28 nextWeek : 'dddd, LT',
29 lastDay : '[நேற்று] LT',
30 lastWeek : '[கடந்த வாரம்] dddd, LT',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : '%s இல்',
35 past : '%s முன்',
36 s : 'ஒரு சில விநாடிகள்',
37 m : 'ஒரு நிமிடம்',
38 mm : '%d நிமிடங்கள்',
39 h : 'ஒரு மணி நேரம்',
40 hh : '%d மணி நேரம்',
41 d : 'ஒரு நாள்',
42 dd : '%d நாட்கள்',
43 M : 'ஒரு மாதம்',
44 MM : '%d மாதங்கள்',
45 y : 'ஒரு வருடம்',
46 yy : '%d ஆண்டுகள்'
47 },
48 ordinalParse: /\d{1,2}வது/,
49 ordinal : function (number) {
50 return number + 'வது';
51 },
52 // refer http://ta.wikipedia.org/s/1er1
53 meridiemParse: /யாமம்|வைகறை|காலை|நண்பகல்|எற்பாடு|மாலை/,
54 meridiem : function (hour, minute, isLower) {
55 if (hour < 2) {
56 return ' யாமம்';
57 } else if (hour < 6) {
58 return ' வைகறை'; // வைகறை
59 } else if (hour < 10) {
60 return ' காலை'; // காலை
61 } else if (hour < 14) {
62 return ' நண்பகல்'; // நண்பகல்
63 } else if (hour < 18) {
64 return ' எற்பாடு'; // எற்பாடு
65 } else if (hour < 22) {
66 return ' மாலை'; // மாலை
67 } else {
68 return ' யாமம்';
69 }
70 },
71 meridiemHour : function (hour, meridiem) {
72 if (hour === 12) {
73 hour = 0;
74 }
75 if (meridiem === 'யாமம்') {
76 return hour < 2 ? hour : hour + 12;
77 } else if (meridiem === 'வைகறை' || meridiem === 'காலை') {
78 return hour;
79 } else if (meridiem === 'நண்பகல்') {
80 return hour >= 10 ? hour : hour + 12;
81 } else {
82 return hour + 12;
83 }
84 },
85 week : {
86 dow : 0, // Sunday is the first day of the week.
87 doy : 6 // The week that contains Jan 1st is the first week of the year.
88 }
89 });
90
91 return ta;
92
93 }));
0 //! moment.js locale configuration
1 //! locale : thai (th)
2 //! author : Kridsada Thanabulpong : https://github.com/sirn
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var th = moment.defineLocale('th', {
12 months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
13 monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
14 weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
15 weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
16 weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
17 longDateFormat : {
18 LT : 'H นาฬิกา m นาที',
19 LTS : 'H นาฬิกา m นาที s วินาที',
20 L : 'YYYY/MM/DD',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY เวลา H นาฬิกา m นาที',
23 LLLL : 'วันddddที่ D MMMM YYYY เวลา H นาฬิกา m นาที'
24 },
25 meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
26 isPM: function (input) {
27 return input === 'หลังเที่ยง';
28 },
29 meridiem : function (hour, minute, isLower) {
30 if (hour < 12) {
31 return 'ก่อนเที่ยง';
32 } else {
33 return 'หลังเที่ยง';
34 }
35 },
36 calendar : {
37 sameDay : '[วันนี้ เวลา] LT',
38 nextDay : '[พรุ่งนี้ เวลา] LT',
39 nextWeek : 'dddd[หน้า เวลา] LT',
40 lastDay : '[เมื่อวานนี้ เวลา] LT',
41 lastWeek : '[วัน]dddd[ที่แล้ว เวลา] LT',
42 sameElse : 'L'
43 },
44 relativeTime : {
45 future : 'อีก %s',
46 past : '%sที่แล้ว',
47 s : 'ไม่กี่วินาที',
48 m : '1 นาที',
49 mm : '%d นาที',
50 h : '1 ชั่วโมง',
51 hh : '%d ชั่วโมง',
52 d : '1 วัน',
53 dd : '%d วัน',
54 M : '1 เดือน',
55 MM : '%d เดือน',
56 y : '1 ปี',
57 yy : '%d ปี'
58 }
59 });
60
61 return th;
62
63 }));
0 //! moment.js locale configuration
1 //! locale : Tagalog/Filipino (tl-ph)
2 //! author : Dan Hagman
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var tl_ph = moment.defineLocale('tl-ph', {
12 months : 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'),
13 monthsShort : 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'),
14 weekdays : 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'),
15 weekdaysShort : 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'),
16 weekdaysMin : 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'MM/D/YYYY',
21 LL : 'MMMM D, YYYY',
22 LLL : 'MMMM D, YYYY HH:mm',
23 LLLL : 'dddd, MMMM DD, YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[Ngayon sa] LT',
27 nextDay: '[Bukas sa] LT',
28 nextWeek: 'dddd [sa] LT',
29 lastDay: '[Kahapon sa] LT',
30 lastWeek: 'dddd [huling linggo] LT',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : 'sa loob ng %s',
35 past : '%s ang nakalipas',
36 s : 'ilang segundo',
37 m : 'isang minuto',
38 mm : '%d minuto',
39 h : 'isang oras',
40 hh : '%d oras',
41 d : 'isang araw',
42 dd : '%d araw',
43 M : 'isang buwan',
44 MM : '%d buwan',
45 y : 'isang taon',
46 yy : '%d taon'
47 },
48 ordinalParse: /\d{1,2}/,
49 ordinal : function (number) {
50 return number;
51 },
52 week : {
53 dow : 1, // Monday is the first day of the week.
54 doy : 4 // The week that contains Jan 4th is the first week of the year.
55 }
56 });
57
58 return tl_ph;
59
60 }));
0 //! moment.js locale configuration
1 //! locale : turkish (tr)
2 //! authors : Erhan Gundogan : https://github.com/erhangundogan,
3 //! Burak Yiğit Kaya: https://github.com/BYK
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var suffixes = {
13 1: '\'inci',
14 5: '\'inci',
15 8: '\'inci',
16 70: '\'inci',
17 80: '\'inci',
18 2: '\'nci',
19 7: '\'nci',
20 20: '\'nci',
21 50: '\'nci',
22 3: '\'üncü',
23 4: '\'üncü',
24 100: '\'üncü',
25 6: '\'ncı',
26 9: '\'uncu',
27 10: '\'uncu',
28 30: '\'uncu',
29 60: '\'ıncı',
30 90: '\'ıncı'
31 };
32
33 var tr = moment.defineLocale('tr', {
34 months : 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
35 monthsShort : 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'),
36 weekdays : 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
37 weekdaysShort : 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'),
38 weekdaysMin : 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'),
39 longDateFormat : {
40 LT : 'HH:mm',
41 LTS : 'HH:mm:ss',
42 L : 'DD.MM.YYYY',
43 LL : 'D MMMM YYYY',
44 LLL : 'D MMMM YYYY HH:mm',
45 LLLL : 'dddd, D MMMM YYYY HH:mm'
46 },
47 calendar : {
48 sameDay : '[bugün saat] LT',
49 nextDay : '[yarın saat] LT',
50 nextWeek : '[haftaya] dddd [saat] LT',
51 lastDay : '[dün] LT',
52 lastWeek : '[geçen hafta] dddd [saat] LT',
53 sameElse : 'L'
54 },
55 relativeTime : {
56 future : '%s sonra',
57 past : '%s önce',
58 s : 'birkaç saniye',
59 m : 'bir dakika',
60 mm : '%d dakika',
61 h : 'bir saat',
62 hh : '%d saat',
63 d : 'bir gün',
64 dd : '%d gün',
65 M : 'bir ay',
66 MM : '%d ay',
67 y : 'bir yıl',
68 yy : '%d yıl'
69 },
70 ordinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
71 ordinal : function (number) {
72 if (number === 0) { // special case for zero
73 return number + '\'ıncı';
74 }
75 var a = number % 10,
76 b = number % 100 - a,
77 c = number >= 100 ? 100 : null;
78 return number + (suffixes[a] || suffixes[b] || suffixes[c]);
79 },
80 week : {
81 dow : 1, // Monday is the first day of the week.
82 doy : 7 // The week that contains Jan 1st is the first week of the year.
83 }
84 });
85
86 return tr;
87
88 }));
0 //! moment.js locale configuration
1 //! locale : talossan (tzl)
2 //! author : Robin van der Vliet : https://github.com/robin0van0der0v with the help of Iustì Canun
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11
12 var tzl = moment.defineLocale('tzl', {
13 months : 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'),
14 monthsShort : 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'),
15 weekdays : 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'),
16 weekdaysShort : 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'),
17 weekdaysMin : 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'),
18 longDateFormat : {
19 LT : 'HH.mm',
20 LTS : 'LT.ss',
21 L : 'DD.MM.YYYY',
22 LL : 'D. MMMM [dallas] YYYY',
23 LLL : 'D. MMMM [dallas] YYYY LT',
24 LLLL : 'dddd, [li] D. MMMM [dallas] YYYY LT'
25 },
26 meridiem : function (hours, minutes, isLower) {
27 if (hours > 11) {
28 return isLower ? 'd\'o' : 'D\'O';
29 } else {
30 return isLower ? 'd\'a' : 'D\'A';
31 }
32 },
33 calendar : {
34 sameDay : '[oxhi à] LT',
35 nextDay : '[demà à] LT',
36 nextWeek : 'dddd [à] LT',
37 lastDay : '[ieiri à] LT',
38 lastWeek : '[sür el] dddd [lasteu à] LT',
39 sameElse : 'L'
40 },
41 relativeTime : {
42 future : 'osprei %s',
43 past : 'ja%s',
44 s : processRelativeTime,
45 m : processRelativeTime,
46 mm : processRelativeTime,
47 h : processRelativeTime,
48 hh : processRelativeTime,
49 d : processRelativeTime,
50 dd : processRelativeTime,
51 M : processRelativeTime,
52 MM : processRelativeTime,
53 y : processRelativeTime,
54 yy : processRelativeTime
55 },
56 ordinalParse: /\d{1,2}\./,
57 ordinal : '%d.',
58 week : {
59 dow : 1, // Monday is the first day of the week.
60 doy : 4 // The week that contains Jan 4th is the first week of the year.
61 }
62 });
63
64 function processRelativeTime(number, withoutSuffix, key, isFuture) {
65 var format = {
66 's': ['viensas secunds', '\'iensas secunds'],
67 'm': ['\'n míut', '\'iens míut'],
68 'mm': [number + ' míuts', ' ' + number + ' míuts'],
69 'h': ['\'n þora', '\'iensa þora'],
70 'hh': [number + ' þoras', ' ' + number + ' þoras'],
71 'd': ['\'n ziua', '\'iensa ziua'],
72 'dd': [number + ' ziuas', ' ' + number + ' ziuas'],
73 'M': ['\'n mes', '\'iens mes'],
74 'MM': [number + ' mesen', ' ' + number + ' mesen'],
75 'y': ['\'n ar', '\'iens ar'],
76 'yy': [number + ' ars', ' ' + number + ' ars']
77 };
78 return isFuture ? format[key][0] : (withoutSuffix ? format[key][0] : format[key][1].trim());
79 }
80
81 return tzl;
82
83 }));
0 //! moment.js locale configuration
1 //! locale : Morocco Central Atlas Tamaziɣt in Latin (tzm-latn)
2 //! author : Abdel Said : https://github.com/abdelsaid
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var tzm_latn = moment.defineLocale('tzm-latn', {
12 months : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
13 monthsShort : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
14 weekdays : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
15 weekdaysShort : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
16 weekdaysMin : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd D MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[asdkh g] LT',
27 nextDay: '[aska g] LT',
28 nextWeek: 'dddd [g] LT',
29 lastDay: '[assant g] LT',
30 lastWeek: 'dddd [g] LT',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : 'dadkh s yan %s',
35 past : 'yan %s',
36 s : 'imik',
37 m : 'minuḍ',
38 mm : '%d minuḍ',
39 h : 'saɛa',
40 hh : '%d tassaɛin',
41 d : 'ass',
42 dd : '%d ossan',
43 M : 'ayowr',
44 MM : '%d iyyirn',
45 y : 'asgas',
46 yy : '%d isgasn'
47 },
48 week : {
49 dow : 6, // Saturday is the first day of the week.
50 doy : 12 // The week that contains Jan 1st is the first week of the year.
51 }
52 });
53
54 return tzm_latn;
55
56 }));
0 //! moment.js locale configuration
1 //! locale : Morocco Central Atlas Tamaziɣt (tzm)
2 //! author : Abdel Said : https://github.com/abdelsaid
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var tzm = moment.defineLocale('tzm', {
12 months : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
13 monthsShort : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
14 weekdays : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
15 weekdaysShort : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
16 weekdaysMin : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS: 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'dddd D MMMM YYYY HH:mm'
24 },
25 calendar : {
26 sameDay: '[ⴰⵙⴷⵅ ⴴ] LT',
27 nextDay: '[ⴰⵙⴽⴰ ⴴ] LT',
28 nextWeek: 'dddd [ⴴ] LT',
29 lastDay: '[ⴰⵚⴰⵏⵜ ⴴ] LT',
30 lastWeek: 'dddd [ⴴ] LT',
31 sameElse: 'L'
32 },
33 relativeTime : {
34 future : 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s',
35 past : 'ⵢⴰⵏ %s',
36 s : 'ⵉⵎⵉⴽ',
37 m : 'ⵎⵉⵏⵓⴺ',
38 mm : '%d ⵎⵉⵏⵓⴺ',
39 h : 'ⵙⴰⵄⴰ',
40 hh : '%d ⵜⴰⵙⵙⴰⵄⵉⵏ',
41 d : 'ⴰⵙⵙ',
42 dd : '%d oⵙⵙⴰⵏ',
43 M : 'ⴰⵢoⵓⵔ',
44 MM : '%d ⵉⵢⵢⵉⵔⵏ',
45 y : 'ⴰⵙⴳⴰⵙ',
46 yy : '%d ⵉⵙⴳⴰⵙⵏ'
47 },
48 week : {
49 dow : 6, // Saturday is the first day of the week.
50 doy : 12 // The week that contains Jan 1st is the first week of the year.
51 }
52 });
53
54 return tzm;
55
56 }));
0 //! moment.js locale configuration
1 //! locale : ukrainian (uk)
2 //! author : zemlanin : https://github.com/zemlanin
3 //! Author : Menelion Elensúle : https://github.com/Oire
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 function plural(word, num) {
13 var forms = word.split('_');
14 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
15 }
16 function relativeTimeWithPlural(number, withoutSuffix, key) {
17 var format = {
18 'mm': 'хвилина_хвилини_хвилин',
19 'hh': 'година_години_годин',
20 'dd': 'день_дні_днів',
21 'MM': 'місяць_місяці_місяців',
22 'yy': 'рік_роки_років'
23 };
24 if (key === 'm') {
25 return withoutSuffix ? 'хвилина' : 'хвилину';
26 }
27 else if (key === 'h') {
28 return withoutSuffix ? 'година' : 'годину';
29 }
30 else {
31 return number + ' ' + plural(format[key], +number);
32 }
33 }
34 function monthsCaseReplace(m, format) {
35 var months = {
36 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
37 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
38 },
39 nounCase = (/D[oD]? *MMMM?/).test(format) ?
40 'accusative' :
41 'nominative';
42 return months[nounCase][m.month()];
43 }
44 function weekdaysCaseReplace(m, format) {
45 var weekdays = {
46 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
47 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
48 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
49 },
50 nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
51 'accusative' :
52 ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
53 'genitive' :
54 'nominative');
55 return weekdays[nounCase][m.day()];
56 }
57 function processHoursFunction(str) {
58 return function () {
59 return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
60 };
61 }
62
63 var uk = moment.defineLocale('uk', {
64 months : monthsCaseReplace,
65 monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
66 weekdays : weekdaysCaseReplace,
67 weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
68 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
69 longDateFormat : {
70 LT : 'HH:mm',
71 LTS : 'HH:mm:ss',
72 L : 'DD.MM.YYYY',
73 LL : 'D MMMM YYYY р.',
74 LLL : 'D MMMM YYYY р., HH:mm',
75 LLLL : 'dddd, D MMMM YYYY р., HH:mm'
76 },
77 calendar : {
78 sameDay: processHoursFunction('[Сьогодні '),
79 nextDay: processHoursFunction('[Завтра '),
80 lastDay: processHoursFunction('[Вчора '),
81 nextWeek: processHoursFunction('[У] dddd ['),
82 lastWeek: function () {
83 switch (this.day()) {
84 case 0:
85 case 3:
86 case 5:
87 case 6:
88 return processHoursFunction('[Минулої] dddd [').call(this);
89 case 1:
90 case 2:
91 case 4:
92 return processHoursFunction('[Минулого] dddd [').call(this);
93 }
94 },
95 sameElse: 'L'
96 },
97 relativeTime : {
98 future : 'за %s',
99 past : '%s тому',
100 s : 'декілька секунд',
101 m : relativeTimeWithPlural,
102 mm : relativeTimeWithPlural,
103 h : 'годину',
104 hh : relativeTimeWithPlural,
105 d : 'день',
106 dd : relativeTimeWithPlural,
107 M : 'місяць',
108 MM : relativeTimeWithPlural,
109 y : 'рік',
110 yy : relativeTimeWithPlural
111 },
112 // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
113 meridiemParse: /ночі|ранку|дня|вечора/,
114 isPM: function (input) {
115 return /^(дня|вечора)$/.test(input);
116 },
117 meridiem : function (hour, minute, isLower) {
118 if (hour < 4) {
119 return 'ночі';
120 } else if (hour < 12) {
121 return 'ранку';
122 } else if (hour < 17) {
123 return 'дня';
124 } else {
125 return 'вечора';
126 }
127 },
128 ordinalParse: /\d{1,2}-(й|го)/,
129 ordinal: function (number, period) {
130 switch (period) {
131 case 'M':
132 case 'd':
133 case 'DDD':
134 case 'w':
135 case 'W':
136 return number + '-й';
137 case 'D':
138 return number + '-го';
139 default:
140 return number;
141 }
142 },
143 week : {
144 dow : 1, // Monday is the first day of the week.
145 doy : 7 // The week that contains Jan 1st is the first week of the year.
146 }
147 });
148
149 return uk;
150
151 }));
0 //! moment.js locale configuration
1 //! locale : uzbek (uz)
2 //! author : Sardor Muminov : https://github.com/muminoff
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var uz = moment.defineLocale('uz', {
12 months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
13 monthsShort : 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'),
14 weekdays : 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'),
15 weekdaysShort : 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'),
16 weekdaysMin : 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM YYYY',
22 LLL : 'D MMMM YYYY HH:mm',
23 LLLL : 'D MMMM YYYY, dddd HH:mm'
24 },
25 calendar : {
26 sameDay : '[Бугун соат] LT [да]',
27 nextDay : '[Эртага] LT [да]',
28 nextWeek : 'dddd [куни соат] LT [да]',
29 lastDay : '[Кеча соат] LT [да]',
30 lastWeek : '[Утган] dddd [куни соат] LT [да]',
31 sameElse : 'L'
32 },
33 relativeTime : {
34 future : 'Якин %s ичида',
35 past : 'Бир неча %s олдин',
36 s : 'фурсат',
37 m : 'бир дакика',
38 mm : '%d дакика',
39 h : 'бир соат',
40 hh : '%d соат',
41 d : 'бир кун',
42 dd : '%d кун',
43 M : 'бир ой',
44 MM : '%d ой',
45 y : 'бир йил',
46 yy : '%d йил'
47 },
48 week : {
49 dow : 1, // Monday is the first day of the week.
50 doy : 7 // The week that contains Jan 4th is the first week of the year.
51 }
52 });
53
54 return uz;
55
56 }));
0 //! moment.js locale configuration
1 //! locale : vietnamese (vi)
2 //! author : Bang Nguyen : https://github.com/bangnk
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var vi = moment.defineLocale('vi', {
12 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('_'),
13 monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
14 weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
15 weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
16 weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
17 longDateFormat : {
18 LT : 'HH:mm',
19 LTS : 'HH:mm:ss',
20 L : 'DD/MM/YYYY',
21 LL : 'D MMMM [năm] YYYY',
22 LLL : 'D MMMM [năm] YYYY HH:mm',
23 LLLL : 'dddd, D MMMM [năm] YYYY HH:mm',
24 l : 'DD/M/YYYY',
25 ll : 'D MMM YYYY',
26 lll : 'D MMM YYYY HH:mm',
27 llll : 'ddd, D MMM YYYY HH:mm'
28 },
29 calendar : {
30 sameDay: '[Hôm nay lúc] LT',
31 nextDay: '[Ngày mai lúc] LT',
32 nextWeek: 'dddd [tuần tới lúc] LT',
33 lastDay: '[Hôm qua lúc] LT',
34 lastWeek: 'dddd [tuần rồi lúc] LT',
35 sameElse: 'L'
36 },
37 relativeTime : {
38 future : '%s tới',
39 past : '%s trước',
40 s : 'vài giây',
41 m : 'một phút',
42 mm : '%d phút',
43 h : 'một giờ',
44 hh : '%d giờ',
45 d : 'một ngày',
46 dd : '%d ngày',
47 M : 'một tháng',
48 MM : '%d tháng',
49 y : 'một năm',
50 yy : '%d năm'
51 },
52 ordinalParse: /\d{1,2}/,
53 ordinal : function (number) {
54 return number;
55 },
56 week : {
57 dow : 1, // Monday is the first day of the week.
58 doy : 4 // The week that contains Jan 4th is the first week of the year.
59 }
60 });
61
62 return vi;
63
64 }));
0 //! moment.js locale configuration
1 //! locale : chinese (zh-cn)
2 //! author : suupic : https://github.com/suupic
3 //! author : Zeno Zeng : https://github.com/zenozeng
4
5 (function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
7 typeof define === 'function' && define.amd ? define(['moment'], factory) :
8 factory(global.moment)
9 }(this, function (moment) { 'use strict';
10
11
12 var zh_cn = moment.defineLocale('zh-cn', {
13 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
14 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
15 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
16 weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
17 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
18 longDateFormat : {
19 LT : 'Ah点mm分',
20 LTS : 'Ah点m分s秒',
21 L : 'YYYY-MM-DD',
22 LL : 'YYYY年MMMD日',
23 LLL : 'YYYY年MMMD日Ah点mm分',
24 LLLL : 'YYYY年MMMD日ddddAh点mm分',
25 l : 'YYYY-MM-DD',
26 ll : 'YYYY年MMMD日',
27 lll : 'YYYY年MMMD日Ah点mm分',
28 llll : 'YYYY年MMMD日ddddAh点mm分'
29 },
30 meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
31 meridiemHour: function (hour, meridiem) {
32 if (hour === 12) {
33 hour = 0;
34 }
35 if (meridiem === '凌晨' || meridiem === '早上' ||
36 meridiem === '上午') {
37 return hour;
38 } else if (meridiem === '下午' || meridiem === '晚上') {
39 return hour + 12;
40 } else {
41 // '中午'
42 return hour >= 11 ? hour : hour + 12;
43 }
44 },
45 meridiem : function (hour, minute, isLower) {
46 var hm = hour * 100 + minute;
47 if (hm < 600) {
48 return '凌晨';
49 } else if (hm < 900) {
50 return '早上';
51 } else if (hm < 1130) {
52 return '上午';
53 } else if (hm < 1230) {
54 return '中午';
55 } else if (hm < 1800) {
56 return '下午';
57 } else {
58 return '晚上';
59 }
60 },
61 calendar : {
62 sameDay : function () {
63 return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
64 },
65 nextDay : function () {
66 return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
67 },
68 lastDay : function () {
69 return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
70 },
71 nextWeek : function () {
72 var startOfWeek, prefix;
73 startOfWeek = moment().startOf('week');
74 prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
75 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
76 },
77 lastWeek : function () {
78 var startOfWeek, prefix;
79 startOfWeek = moment().startOf('week');
80 prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
81 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
82 },
83 sameElse : 'LL'
84 },
85 ordinalParse: /\d{1,2}(日|月|周)/,
86 ordinal : function (number, period) {
87 switch (period) {
88 case 'd':
89 case 'D':
90 case 'DDD':
91 return number + '日';
92 case 'M':
93 return number + '月';
94 case 'w':
95 case 'W':
96 return number + '周';
97 default:
98 return number;
99 }
100 },
101 relativeTime : {
102 future : '%s内',
103 past : '%s前',
104 s : '几秒',
105 m : '1 分钟',
106 mm : '%d 分钟',
107 h : '1 小时',
108 hh : '%d 小时',
109 d : '1 天',
110 dd : '%d 天',
111 M : '1 个月',
112 MM : '%d 个月',
113 y : '1 年',
114 yy : '%d 年'
115 },
116 week : {
117 // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
118 dow : 1, // Monday is the first day of the week.
119 doy : 4 // The week that contains Jan 4th is the first week of the year.
120 }
121 });
122
123 return zh_cn;
124
125 }));
0 //! moment.js locale configuration
1 //! locale : traditional chinese (zh-tw)
2 //! author : Ben : https://github.com/ben-lin
3
4 (function (global, factory) {
5 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
6 typeof define === 'function' && define.amd ? define(['moment'], factory) :
7 factory(global.moment)
8 }(this, function (moment) { 'use strict';
9
10
11 var zh_tw = moment.defineLocale('zh-tw', {
12 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
13 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
14 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
15 weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
16 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
17 longDateFormat : {
18 LT : 'Ah點mm分',
19 LTS : 'Ah點m分s秒',
20 L : 'YYYY年MMMD日',
21 LL : 'YYYY年MMMD日',
22 LLL : 'YYYY年MMMD日Ah點mm分',
23 LLLL : 'YYYY年MMMD日ddddAh點mm分',
24 l : 'YYYY年MMMD日',
25 ll : 'YYYY年MMMD日',
26 lll : 'YYYY年MMMD日Ah點mm分',
27 llll : 'YYYY年MMMD日ddddAh點mm分'
28 },
29 meridiemParse: /早上|上午|中午|下午|晚上/,
30 meridiemHour : function (hour, meridiem) {
31 if (hour === 12) {
32 hour = 0;
33 }
34 if (meridiem === '早上' || meridiem === '上午') {
35 return hour;
36 } else if (meridiem === '中午') {
37 return hour >= 11 ? hour : hour + 12;
38 } else if (meridiem === '下午' || meridiem === '晚上') {
39 return hour + 12;
40 }
41 },
42 meridiem : function (hour, minute, isLower) {
43 var hm = hour * 100 + minute;
44 if (hm < 900) {
45 return '早上';
46 } else if (hm < 1130) {
47 return '上午';
48 } else if (hm < 1230) {
49 return '中午';
50 } else if (hm < 1800) {
51 return '下午';
52 } else {
53 return '晚上';
54 }
55 },
56 calendar : {
57 sameDay : '[今天]LT',
58 nextDay : '[明天]LT',
59 nextWeek : '[下]ddddLT',
60 lastDay : '[昨天]LT',
61 lastWeek : '[上]ddddLT',
62 sameElse : 'L'
63 },
64 ordinalParse: /\d{1,2}(日|月|週)/,
65 ordinal : function (number, period) {
66 switch (period) {
67 case 'd' :
68 case 'D' :
69 case 'DDD' :
70 return number + '日';
71 case 'M' :
72 return number + '月';
73 case 'w' :
74 case 'W' :
75 return number + '週';
76 default :
77 return number;
78 }
79 },
80 relativeTime : {
81 future : '%s內',
82 past : '%s前',
83 s : '幾秒',
84 m : '一分鐘',
85 mm : '%d分鐘',
86 h : '一小時',
87 hh : '%d小時',
88 d : '一天',
89 dd : '%d天',
90 M : '一個月',
91 MM : '%d個月',
92 y : '一年',
93 yy : '%d年'
94 }
95 });
96
97 return zh_tw;
98
99 }));
0 Packaging [Moment](momentjs.org) for [Meteor.js](http://meteor.com).
1
2
3 # Meteor
4
5 If you're new to Meteor, here's what the excitement is all about -
6 [watch the first two minutes](https://www.youtube.com/watch?v=fsi0aJ9yr2o); you'll be hooked by 1:28.
7
8 That screencast is from 2012. In the meantime, Meteor has become a mature JavaScript-everywhere web
9 development framework. Read more at [Why Meteor](http://www.meteorpedia.com/read/Why_Meteor).
10
11
12 # Issues
13
14 If you encounter an issue while using this package, please CC @dandv when you file it in this repo.
15
16
17 # DONE
18
19 * Simple test. Should be enough.
20
21
22 # TODO
23
24 * Add other tests; however, that is overkill, and the responsibiity of Moment, not of the Meteor integration.
0 // moment.js makes `moment` global on the window (or global) object, while Meteor expects a file-scoped global variable
1 moment = this.moment;
2 try {
3 delete this.moment;
4 } catch (e) {
5 }
0 // package metadata file for Meteor.js
1 'use strict';
2
3 var packageName = 'momentjs:moment'; // https://atmospherejs.com/momentjs/moment
4
5 var packageJson = JSON.parse(Npm.require("fs").readFileSync('package.json'));
6
7 Package.describe({
8 name: packageName,
9 summary: 'Moment.js (official): parse, validate, manipulate, and display dates - official Meteor packaging',
10 version: packageJson.version,
11 git: 'https://github.com/moment/moment.git'
12 });
13
14 Package.onUse(function (api) {
15 api.versionsFrom(['METEOR@0.9.0', 'METEOR@1.0']);
16 api.export('moment');
17 api.addFiles([
18 'moment.js',
19 'meteor/export.js'
20 ]);
21 });
22
23 Package.onTest(function (api) {
24 api.use(packageName);
25 api.use('tinytest');
26
27 api.addFiles('meteor/test.js');
28 });
0 'use strict';
1
2 Tinytest.add('Moment.is', function (test) {
3 test.ok(moment.isMoment(moment()), {message: 'simple moment object'});
4 });
0 (function (global, factory) {
1 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
2 typeof define === 'function' && define.amd ? define(['moment'], factory) :
3 factory(global.moment)
4 }(this, function (moment) { 'use strict';
5
6 //! moment.js locale configuration
7 //! locale : afrikaans (af)
8 //! author : Werner Mollentze : https://github.com/wernerm
9
10 var af = moment.defineLocale('af', {
11 months : 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'),
12 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'),
13 weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
14 weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
15 weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
16 meridiemParse: /vm|nm/i,
17 isPM : function (input) {
18 return /^nm$/i.test(input);
19 },
20 meridiem : function (hours, minutes, isLower) {
21 if (hours < 12) {
22 return isLower ? 'vm' : 'VM';
23 } else {
24 return isLower ? 'nm' : 'NM';
25 }
26 },
27 longDateFormat : {
28 LT : 'HH:mm',
29 LTS : 'HH:mm:ss',
30 L : 'DD/MM/YYYY',
31 LL : 'D MMMM YYYY',
32 LLL : 'D MMMM YYYY HH:mm',
33 LLLL : 'dddd, D MMMM YYYY HH:mm'
34 },
35 calendar : {
36 sameDay : '[Vandag om] LT',
37 nextDay : '[Môre om] LT',
38 nextWeek : 'dddd [om] LT',
39 lastDay : '[Gister om] LT',
40 lastWeek : '[Laas] dddd [om] LT',
41 sameElse : 'L'
42 },
43 relativeTime : {
44 future : 'oor %s',
45 past : '%s gelede',
46 s : '\'n paar sekondes',
47 m : '\'n minuut',
48 mm : '%d minute',
49 h : '\'n uur',
50 hh : '%d ure',
51 d : '\'n dag',
52 dd : '%d dae',
53 M : '\'n maand',
54 MM : '%d maande',
55 y : '\'n jaar',
56 yy : '%d jaar'
57 },
58 ordinalParse: /\d{1,2}(ste|de)/,
59 ordinal : function (number) {
60 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); // Thanks to Joris Röling : https://github.com/jjupiter
61 },
62 week : {
63 dow : 1, // Maandag is die eerste dag van die week.
64 doy : 4 // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
65 }
66 });
67
68 //! moment.js locale configuration
69 //! locale : Moroccan Arabic (ar-ma)
70 //! author : ElFadili Yassine : https://github.com/ElFadiliY
71 //! author : Abdel Said : https://github.com/abdelsaid
72
73 var ar_ma = moment.defineLocale('ar-ma', {
74 months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
75 monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
76 weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
77 weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
78 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
79 longDateFormat : {
80 LT : 'HH:mm',
81 LTS : 'HH:mm:ss',
82 L : 'DD/MM/YYYY',
83 LL : 'D MMMM YYYY',
84 LLL : 'D MMMM YYYY HH:mm',
85 LLLL : 'dddd D MMMM YYYY HH:mm'
86 },
87 calendar : {
88 sameDay: '[اليوم على الساعة] LT',
89 nextDay: '[غدا على الساعة] LT',
90 nextWeek: 'dddd [على الساعة] LT',
91 lastDay: '[أمس على الساعة] LT',
92 lastWeek: 'dddd [على الساعة] LT',
93 sameElse: 'L'
94 },
95 relativeTime : {
96 future : 'في %s',
97 past : 'منذ %s',
98 s : 'ثوان',
99 m : 'دقيقة',
100 mm : '%d دقائق',
101 h : 'ساعة',
102 hh : '%d ساعات',
103 d : 'يوم',
104 dd : '%d أيام',
105 M : 'شهر',
106 MM : '%d أشهر',
107 y : 'سنة',
108 yy : '%d سنوات'
109 },
110 week : {
111 dow : 6, // Saturday is the first day of the week.
112 doy : 12 // The week that contains Jan 1st is the first week of the year.
113 }
114 });
115
116 //! moment.js locale configuration
117 //! locale : Arabic Saudi Arabia (ar-sa)
118 //! author : Suhail Alkowaileet : https://github.com/xsoh
119
120 var ar_sa__symbolMap = {
121 '1': '١',
122 '2': '٢',
123 '3': '٣',
124 '4': '٤',
125 '5': '٥',
126 '6': '٦',
127 '7': '٧',
128 '8': '٨',
129 '9': '٩',
130 '0': '٠'
131 }, ar_sa__numberMap = {
132 '١': '1',
133 '٢': '2',
134 '٣': '3',
135 '٤': '4',
136 '٥': '5',
137 '٦': '6',
138 '٧': '7',
139 '٨': '8',
140 '٩': '9',
141 '٠': '0'
142 };
143
144 var ar_sa = moment.defineLocale('ar-sa', {
145 months : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
146 monthsShort : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
147 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
148 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
149 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
150 longDateFormat : {
151 LT : 'HH:mm',
152 LTS : 'HH:mm:ss',
153 L : 'DD/MM/YYYY',
154 LL : 'D MMMM YYYY',
155 LLL : 'D MMMM YYYY HH:mm',
156 LLLL : 'dddd D MMMM YYYY HH:mm'
157 },
158 meridiemParse: /ص|م/,
159 isPM : function (input) {
160 return 'م' === input;
161 },
162 meridiem : function (hour, minute, isLower) {
163 if (hour < 12) {
164 return 'ص';
165 } else {
166 return 'م';
167 }
168 },
169 calendar : {
170 sameDay: '[اليوم على الساعة] LT',
171 nextDay: '[غدا على الساعة] LT',
172 nextWeek: 'dddd [على الساعة] LT',
173 lastDay: '[أمس على الساعة] LT',
174 lastWeek: 'dddd [على الساعة] LT',
175 sameElse: 'L'
176 },
177 relativeTime : {
178 future : 'في %s',
179 past : 'منذ %s',
180 s : 'ثوان',
181 m : 'دقيقة',
182 mm : '%d دقائق',
183 h : 'ساعة',
184 hh : '%d ساعات',
185 d : 'يوم',
186 dd : '%d أيام',
187 M : 'شهر',
188 MM : '%d أشهر',
189 y : 'سنة',
190 yy : '%d سنوات'
191 },
192 preparse: function (string) {
193 return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
194 return ar_sa__numberMap[match];
195 }).replace(/،/g, ',');
196 },
197 postformat: function (string) {
198 return string.replace(/\d/g, function (match) {
199 return ar_sa__symbolMap[match];
200 }).replace(/,/g, '،');
201 },
202 week : {
203 dow : 6, // Saturday is the first day of the week.
204 doy : 12 // The week that contains Jan 1st is the first week of the year.
205 }
206 });
207
208 //! moment.js locale configuration
209 //! locale : Tunisian Arabic (ar-tn)
210
211 var ar_tn = moment.defineLocale('ar-tn', {
212 months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
213 monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
214 weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
215 weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
216 weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
217 longDateFormat: {
218 LT: 'HH:mm',
219 LTS: 'HH:mm:ss',
220 L: 'DD/MM/YYYY',
221 LL: 'D MMMM YYYY',
222 LLL: 'D MMMM YYYY HH:mm',
223 LLLL: 'dddd D MMMM YYYY HH:mm'
224 },
225 calendar: {
226 sameDay: '[اليوم على الساعة] LT',
227 nextDay: '[غدا على الساعة] LT',
228 nextWeek: 'dddd [على الساعة] LT',
229 lastDay: '[أمس على الساعة] LT',
230 lastWeek: 'dddd [على الساعة] LT',
231 sameElse: 'L'
232 },
233 relativeTime: {
234 future: 'في %s',
235 past: 'منذ %s',
236 s: 'ثوان',
237 m: 'دقيقة',
238 mm: '%d دقائق',
239 h: 'ساعة',
240 hh: '%d ساعات',
241 d: 'يوم',
242 dd: '%d أيام',
243 M: 'شهر',
244 MM: '%d أشهر',
245 y: 'سنة',
246 yy: '%d سنوات'
247 },
248 week: {
249 dow: 1, // Monday is the first day of the week.
250 doy: 4 // The week that contains Jan 4th is the first week of the year.
251 }
252 });
253
254 //! moment.js locale configuration
255 //! Locale: Arabic (ar)
256 //! Author: Abdel Said: https://github.com/abdelsaid
257 //! Changes in months, weekdays: Ahmed Elkhatib
258 //! Native plural forms: forabi https://github.com/forabi
259
260 var ar__symbolMap = {
261 '1': '١',
262 '2': '٢',
263 '3': '٣',
264 '4': '٤',
265 '5': '٥',
266 '6': '٦',
267 '7': '٧',
268 '8': '٨',
269 '9': '٩',
270 '0': '٠'
271 }, ar__numberMap = {
272 '١': '1',
273 '٢': '2',
274 '٣': '3',
275 '٤': '4',
276 '٥': '5',
277 '٦': '6',
278 '٧': '7',
279 '٨': '8',
280 '٩': '9',
281 '٠': '0'
282 }, pluralForm = function (n) {
283 return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
284 }, plurals = {
285 s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
286 m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
287 h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
288 d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
289 M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
290 y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
291 }, pluralize = function (u) {
292 return function (number, withoutSuffix, string, isFuture) {
293 var f = pluralForm(number),
294 str = plurals[u][pluralForm(number)];
295 if (f === 2) {
296 str = str[withoutSuffix ? 0 : 1];
297 }
298 return str.replace(/%d/i, number);
299 };
300 }, ar__months = [
301 'كانون الثاني يناير',
302 'شباط فبراير',
303 'آذار مارس',
304 'نيسان أبريل',
305 'أيار مايو',
306 'حزيران يونيو',
307 'تموز يوليو',
308 'آب أغسطس',
309 'أيلول سبتمبر',
310 'تشرين الأول أكتوبر',
311 'تشرين الثاني نوفمبر',
312 'كانون الأول ديسمبر'
313 ];
314
315 var ar = moment.defineLocale('ar', {
316 months : ar__months,
317 monthsShort : ar__months,
318 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
319 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
320 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
321 longDateFormat : {
322 LT : 'HH:mm',
323 LTS : 'HH:mm:ss',
324 L : 'D/\u200FM/\u200FYYYY',
325 LL : 'D MMMM YYYY',
326 LLL : 'D MMMM YYYY HH:mm',
327 LLLL : 'dddd D MMMM YYYY HH:mm'
328 },
329 meridiemParse: /ص|م/,
330 isPM : function (input) {
331 return 'م' === input;
332 },
333 meridiem : function (hour, minute, isLower) {
334 if (hour < 12) {
335 return 'ص';
336 } else {
337 return 'م';
338 }
339 },
340 calendar : {
341 sameDay: '[اليوم عند الساعة] LT',
342 nextDay: '[غدًا عند الساعة] LT',
343 nextWeek: 'dddd [عند الساعة] LT',
344 lastDay: '[أمس عند الساعة] LT',
345 lastWeek: 'dddd [عند الساعة] LT',
346 sameElse: 'L'
347 },
348 relativeTime : {
349 future : 'بعد %s',
350 past : 'منذ %s',
351 s : pluralize('s'),
352 m : pluralize('m'),
353 mm : pluralize('m'),
354 h : pluralize('h'),
355 hh : pluralize('h'),
356 d : pluralize('d'),
357 dd : pluralize('d'),
358 M : pluralize('M'),
359 MM : pluralize('M'),
360 y : pluralize('y'),
361 yy : pluralize('y')
362 },
363 preparse: function (string) {
364 return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
365 return ar__numberMap[match];
366 }).replace(/،/g, ',');
367 },
368 postformat: function (string) {
369 return string.replace(/\d/g, function (match) {
370 return ar__symbolMap[match];
371 }).replace(/,/g, '،');
372 },
373 week : {
374 dow : 6, // Saturday is the first day of the week.
375 doy : 12 // The week that contains Jan 1st is the first week of the year.
376 }
377 });
378
379 //! moment.js locale configuration
380 //! locale : azerbaijani (az)
381 //! author : topchiyev : https://github.com/topchiyev
382
383 var az__suffixes = {
384 1: '-inci',
385 5: '-inci',
386 8: '-inci',
387 70: '-inci',
388 80: '-inci',
389 2: '-nci',
390 7: '-nci',
391 20: '-nci',
392 50: '-nci',
393 3: '-üncü',
394 4: '-üncü',
395 100: '-üncü',
396 6: '-ncı',
397 9: '-uncu',
398 10: '-uncu',
399 30: '-uncu',
400 60: '-ıncı',
401 90: '-ıncı'
402 };
403
404 var az = moment.defineLocale('az', {
405 months : 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split('_'),
406 monthsShort : 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'),
407 weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
408 weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
409 weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
410 longDateFormat : {
411 LT : 'HH:mm',
412 LTS : 'HH:mm:ss',
413 L : 'DD.MM.YYYY',
414 LL : 'D MMMM YYYY',
415 LLL : 'D MMMM YYYY HH:mm',
416 LLLL : 'dddd, D MMMM YYYY HH:mm'
417 },
418 calendar : {
419 sameDay : '[bugün saat] LT',
420 nextDay : '[sabah saat] LT',
421 nextWeek : '[gələn həftə] dddd [saat] LT',
422 lastDay : '[dünən] LT',
423 lastWeek : '[keçən həftə] dddd [saat] LT',
424 sameElse : 'L'
425 },
426 relativeTime : {
427 future : '%s sonra',
428 past : '%s əvvəl',
429 s : 'birneçə saniyyə',
430 m : 'bir dəqiqə',
431 mm : '%d dəqiqə',
432 h : 'bir saat',
433 hh : '%d saat',
434 d : 'bir gün',
435 dd : '%d gün',
436 M : 'bir ay',
437 MM : '%d ay',
438 y : 'bir il',
439 yy : '%d il'
440 },
441 meridiemParse: /gecə|səhər|gündüz|axşam/,
442 isPM : function (input) {
443 return /^(gündüz|axşam)$/.test(input);
444 },
445 meridiem : function (hour, minute, isLower) {
446 if (hour < 4) {
447 return 'gecə';
448 } else if (hour < 12) {
449 return 'səhər';
450 } else if (hour < 17) {
451 return 'gündüz';
452 } else {
453 return 'axşam';
454 }
455 },
456 ordinalParse: /\d{1,2}-(ıncı|inci|nci|üncü|ncı|uncu)/,
457 ordinal : function (number) {
458 if (number === 0) { // special case for zero
459 return number + '-ıncı';
460 }
461 var a = number % 10,
462 b = number % 100 - a,
463 c = number >= 100 ? 100 : null;
464 return number + (az__suffixes[a] || az__suffixes[b] || az__suffixes[c]);
465 },
466 week : {
467 dow : 1, // Monday is the first day of the week.
468 doy : 7 // The week that contains Jan 1st is the first week of the year.
469 }
470 });
471
472 //! moment.js locale configuration
473 //! locale : belarusian (be)
474 //! author : Dmitry Demidov : https://github.com/demidov91
475 //! author: Praleska: http://praleska.pro/
476 //! Author : Menelion Elensúle : https://github.com/Oire
477
478 function be__plural(word, num) {
479 var forms = word.split('_');
480 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
481 }
482 function be__relativeTimeWithPlural(number, withoutSuffix, key) {
483 var format = {
484 'mm': withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін',
485 'hh': withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін',
486 'dd': 'дзень_дні_дзён',
487 'MM': 'месяц_месяцы_месяцаў',
488 'yy': 'год_гады_гадоў'
489 };
490 if (key === 'm') {
491 return withoutSuffix ? 'хвіліна' : 'хвіліну';
492 }
493 else if (key === 'h') {
494 return withoutSuffix ? 'гадзіна' : 'гадзіну';
495 }
496 else {
497 return number + ' ' + be__plural(format[key], +number);
498 }
499 }
500 function be__monthsCaseReplace(m, format) {
501 var months = {
502 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
503 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
504 },
505 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
506 'accusative' :
507 'nominative';
508 return months[nounCase][m.month()];
509 }
510 function be__weekdaysCaseReplace(m, format) {
511 var weekdays = {
512 'nominative': 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'),
513 'accusative': 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_')
514 },
515 nounCase = (/\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/).test(format) ?
516 'accusative' :
517 'nominative';
518 return weekdays[nounCase][m.day()];
519 }
520
521 var be = moment.defineLocale('be', {
522 months : be__monthsCaseReplace,
523 monthsShort : 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'),
524 weekdays : be__weekdaysCaseReplace,
525 weekdaysShort : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
526 weekdaysMin : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
527 longDateFormat : {
528 LT : 'HH:mm',
529 LTS : 'HH:mm:ss',
530 L : 'DD.MM.YYYY',
531 LL : 'D MMMM YYYY г.',
532 LLL : 'D MMMM YYYY г., HH:mm',
533 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
534 },
535 calendar : {
536 sameDay: '[Сёння ў] LT',
537 nextDay: '[Заўтра ў] LT',
538 lastDay: '[Учора ў] LT',
539 nextWeek: function () {
540 return '[У] dddd [ў] LT';
541 },
542 lastWeek: function () {
543 switch (this.day()) {
544 case 0:
545 case 3:
546 case 5:
547 case 6:
548 return '[У мінулую] dddd [ў] LT';
549 case 1:
550 case 2:
551 case 4:
552 return '[У мінулы] dddd [ў] LT';
553 }
554 },
555 sameElse: 'L'
556 },
557 relativeTime : {
558 future : 'праз %s',
559 past : '%s таму',
560 s : 'некалькі секунд',
561 m : be__relativeTimeWithPlural,
562 mm : be__relativeTimeWithPlural,
563 h : be__relativeTimeWithPlural,
564 hh : be__relativeTimeWithPlural,
565 d : 'дзень',
566 dd : be__relativeTimeWithPlural,
567 M : 'месяц',
568 MM : be__relativeTimeWithPlural,
569 y : 'год',
570 yy : be__relativeTimeWithPlural
571 },
572 meridiemParse: /ночы|раніцы|дня|вечара/,
573 isPM : function (input) {
574 return /^(дня|вечара)$/.test(input);
575 },
576 meridiem : function (hour, minute, isLower) {
577 if (hour < 4) {
578 return 'ночы';
579 } else if (hour < 12) {
580 return 'раніцы';
581 } else if (hour < 17) {
582 return 'дня';
583 } else {
584 return 'вечара';
585 }
586 },
587 ordinalParse: /\d{1,2}-(і|ы|га)/,
588 ordinal: function (number, period) {
589 switch (period) {
590 case 'M':
591 case 'd':
592 case 'DDD':
593 case 'w':
594 case 'W':
595 return (number % 10 === 2 || number % 10 === 3) && (number % 100 !== 12 && number % 100 !== 13) ? number + '-і' : number + '-ы';
596 case 'D':
597 return number + '-га';
598 default:
599 return number;
600 }
601 },
602 week : {
603 dow : 1, // Monday is the first day of the week.
604 doy : 7 // The week that contains Jan 1st is the first week of the year.
605 }
606 });
607
608 //! moment.js locale configuration
609 //! locale : bulgarian (bg)
610 //! author : Krasen Borisov : https://github.com/kraz
611
612 var bg = moment.defineLocale('bg', {
613 months : 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'.split('_'),
614 monthsShort : 'янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'.split('_'),
615 weekdays : 'неделя_понеделник_вторник_сряда_четвъртък_петък_събота'.split('_'),
616 weekdaysShort : 'нед_пон_вто_сря_чет_пет_съб'.split('_'),
617 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
618 longDateFormat : {
619 LT : 'H:mm',
620 LTS : 'H:mm:ss',
621 L : 'D.MM.YYYY',
622 LL : 'D MMMM YYYY',
623 LLL : 'D MMMM YYYY H:mm',
624 LLLL : 'dddd, D MMMM YYYY H:mm'
625 },
626 calendar : {
627 sameDay : '[Днес в] LT',
628 nextDay : '[Утре в] LT',
629 nextWeek : 'dddd [в] LT',
630 lastDay : '[Вчера в] LT',
631 lastWeek : function () {
632 switch (this.day()) {
633 case 0:
634 case 3:
635 case 6:
636 return '[В изминалата] dddd [в] LT';
637 case 1:
638 case 2:
639 case 4:
640 case 5:
641 return '[В изминалия] dddd [в] LT';
642 }
643 },
644 sameElse : 'L'
645 },
646 relativeTime : {
647 future : 'след %s',
648 past : 'преди %s',
649 s : 'няколко секунди',
650 m : 'минута',
651 mm : '%d минути',
652 h : 'час',
653 hh : '%d часа',
654 d : 'ден',
655 dd : '%d дни',
656 M : 'месец',
657 MM : '%d месеца',
658 y : 'година',
659 yy : '%d години'
660 },
661 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
662 ordinal : function (number) {
663 var lastDigit = number % 10,
664 last2Digits = number % 100;
665 if (number === 0) {
666 return number + '-ев';
667 } else if (last2Digits === 0) {
668 return number + '-ен';
669 } else if (last2Digits > 10 && last2Digits < 20) {
670 return number + '-ти';
671 } else if (lastDigit === 1) {
672 return number + '-ви';
673 } else if (lastDigit === 2) {
674 return number + '-ри';
675 } else if (lastDigit === 7 || lastDigit === 8) {
676 return number + '-ми';
677 } else {
678 return number + '-ти';
679 }
680 },
681 week : {
682 dow : 1, // Monday is the first day of the week.
683 doy : 7 // The week that contains Jan 1st is the first week of the year.
684 }
685 });
686
687 //! moment.js locale configuration
688 //! locale : Bengali (bn)
689 //! author : Kaushik Gandhi : https://github.com/kaushikgandhi
690
691 var bn__symbolMap = {
692 '1': '১',
693 '2': '২',
694 '3': '৩',
695 '4': '৪',
696 '5': '৫',
697 '6': '৬',
698 '7': '৭',
699 '8': '৮',
700 '9': '৯',
701 '0': '০'
702 },
703 bn__numberMap = {
704 '১': '1',
705 '২': '2',
706 '৩': '3',
707 '৪': '4',
708 '৫': '5',
709 '৬': '6',
710 '৭': '7',
711 '৮': '8',
712 '৯': '9',
713 '০': '0'
714 };
715
716 var bn = moment.defineLocale('bn', {
717 months : 'জানুয়ারী_ফেবুয়ারী_মার্চ_এপ্রিল_মে_জুন_জুলাই_অগাস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'),
718 monthsShort : 'জানু_ফেব_মার্চ_এপর_মে_জুন_জুল_অগ_সেপ্ট_অক্টো_নভ_ডিসেম্'.split('_'),
719 weekdays : 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পত্তিবার_শুক্রুবার_শনিবার'.split('_'),
720 weekdaysShort : 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পত্তি_শুক্রু_শনি'.split('_'),
721 weekdaysMin : 'রব_সম_মঙ্গ_বু_ব্রিহ_শু_শনি'.split('_'),
722 longDateFormat : {
723 LT : 'A h:mm সময়',
724 LTS : 'A h:mm:ss সময়',
725 L : 'DD/MM/YYYY',
726 LL : 'D MMMM YYYY',
727 LLL : 'D MMMM YYYY, A h:mm সময়',
728 LLLL : 'dddd, D MMMM YYYY, A h:mm সময়'
729 },
730 calendar : {
731 sameDay : '[আজ] LT',
732 nextDay : '[আগামীকাল] LT',
733 nextWeek : 'dddd, LT',
734 lastDay : '[গতকাল] LT',
735 lastWeek : '[গত] dddd, LT',
736 sameElse : 'L'
737 },
738 relativeTime : {
739 future : '%s পরে',
740 past : '%s আগে',
741 s : 'কএক সেকেন্ড',
742 m : 'এক মিনিট',
743 mm : '%d মিনিট',
744 h : 'এক ঘন্টা',
745 hh : '%d ঘন্টা',
746 d : 'এক দিন',
747 dd : '%d দিন',
748 M : 'এক মাস',
749 MM : '%d মাস',
750 y : 'এক বছর',
751 yy : '%d বছর'
752 },
753 preparse: function (string) {
754 return string.replace(/[১২৩৪৫৬৭৮৯০]/g, function (match) {
755 return bn__numberMap[match];
756 });
757 },
758 postformat: function (string) {
759 return string.replace(/\d/g, function (match) {
760 return bn__symbolMap[match];
761 });
762 },
763 meridiemParse: /রাত|সকাল|দুপুর|বিকেল|রাত/,
764 isPM: function (input) {
765 return /^(দুপুর|বিকেল|রাত)$/.test(input);
766 },
767 //Bengali is a vast language its spoken
768 //in different forms in various parts of the world.
769 //I have just generalized with most common one used
770 meridiem : function (hour, minute, isLower) {
771 if (hour < 4) {
772 return 'রাত';
773 } else if (hour < 10) {
774 return 'সকাল';
775 } else if (hour < 17) {
776 return 'দুপুর';
777 } else if (hour < 20) {
778 return 'বিকেল';
779 } else {
780 return 'রাত';
781 }
782 },
783 week : {
784 dow : 0, // Sunday is the first day of the week.
785 doy : 6 // The week that contains Jan 1st is the first week of the year.
786 }
787 });
788
789 //! moment.js locale configuration
790 //! locale : tibetan (bo)
791 //! author : Thupten N. Chakrishar : https://github.com/vajradog
792
793 var bo__symbolMap = {
794 '1': '༡',
795 '2': '༢',
796 '3': '༣',
797 '4': '༤',
798 '5': '༥',
799 '6': '༦',
800 '7': '༧',
801 '8': '༨',
802 '9': '༩',
803 '0': '༠'
804 },
805 bo__numberMap = {
806 '༡': '1',
807 '༢': '2',
808 '༣': '3',
809 '༤': '4',
810 '༥': '5',
811 '༦': '6',
812 '༧': '7',
813 '༨': '8',
814 '༩': '9',
815 '༠': '0'
816 };
817
818 var bo = moment.defineLocale('bo', {
819 months : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
820 monthsShort : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
821 weekdays : 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'),
822 weekdaysShort : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
823 weekdaysMin : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
824 longDateFormat : {
825 LT : 'A h:mm',
826 LTS : 'A h:mm:ss',
827 L : 'DD/MM/YYYY',
828 LL : 'D MMMM YYYY',
829 LLL : 'D MMMM YYYY, A h:mm',
830 LLLL : 'dddd, D MMMM YYYY, A h:mm'
831 },
832 calendar : {
833 sameDay : '[དི་རིང] LT',
834 nextDay : '[སང་ཉིན] LT',
835 nextWeek : '[བདུན་ཕྲག་རྗེས་མ], LT',
836 lastDay : '[ཁ་སང] LT',
837 lastWeek : '[བདུན་ཕྲག་མཐའ་མ] dddd, LT',
838 sameElse : 'L'
839 },
840 relativeTime : {
841 future : '%s ལ་',
842 past : '%s སྔན་ལ',
843 s : 'ལམ་སང',
844 m : 'སྐར་མ་གཅིག',
845 mm : '%d སྐར་མ',
846 h : 'ཆུ་ཚོད་གཅིག',
847 hh : '%d ཆུ་ཚོད',
848 d : 'ཉིན་གཅིག',
849 dd : '%d ཉིན་',
850 M : 'ཟླ་བ་གཅིག',
851 MM : '%d ཟླ་བ',
852 y : 'ལོ་གཅིག',
853 yy : '%d ལོ'
854 },
855 preparse: function (string) {
856 return string.replace(/[༡༢༣༤༥༦༧༨༩༠]/g, function (match) {
857 return bo__numberMap[match];
858 });
859 },
860 postformat: function (string) {
861 return string.replace(/\d/g, function (match) {
862 return bo__symbolMap[match];
863 });
864 },
865 meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
866 isPM: function (input) {
867 return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
868 },
869 meridiem : function (hour, minute, isLower) {
870 if (hour < 4) {
871 return 'མཚན་མོ';
872 } else if (hour < 10) {
873 return 'ཞོགས་ཀས';
874 } else if (hour < 17) {
875 return 'ཉིན་གུང';
876 } else if (hour < 20) {
877 return 'དགོང་དག';
878 } else {
879 return 'མཚན་མོ';
880 }
881 },
882 week : {
883 dow : 0, // Sunday is the first day of the week.
884 doy : 6 // The week that contains Jan 1st is the first week of the year.
885 }
886 });
887
888 //! moment.js locale configuration
889 //! locale : breton (br)
890 //! author : Jean-Baptiste Le Duigou : https://github.com/jbleduigou
891
892 function relativeTimeWithMutation(number, withoutSuffix, key) {
893 var format = {
894 'mm': 'munutenn',
895 'MM': 'miz',
896 'dd': 'devezh'
897 };
898 return number + ' ' + mutation(format[key], number);
899 }
900 function specialMutationForYears(number) {
901 switch (lastNumber(number)) {
902 case 1:
903 case 3:
904 case 4:
905 case 5:
906 case 9:
907 return number + ' bloaz';
908 default:
909 return number + ' vloaz';
910 }
911 }
912 function lastNumber(number) {
913 if (number > 9) {
914 return lastNumber(number % 10);
915 }
916 return number;
917 }
918 function mutation(text, number) {
919 if (number === 2) {
920 return softMutation(text);
921 }
922 return text;
923 }
924 function softMutation(text) {
925 var mutationTable = {
926 'm': 'v',
927 'b': 'v',
928 'd': 'z'
929 };
930 if (mutationTable[text.charAt(0)] === undefined) {
931 return text;
932 }
933 return mutationTable[text.charAt(0)] + text.substring(1);
934 }
935
936 var br = moment.defineLocale('br', {
937 months : 'Genver_C\'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'),
938 monthsShort : 'Gen_C\'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'),
939 weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
940 weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
941 weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
942 longDateFormat : {
943 LT : 'h[e]mm A',
944 LTS : 'h[e]mm:ss A',
945 L : 'DD/MM/YYYY',
946 LL : 'D [a viz] MMMM YYYY',
947 LLL : 'D [a viz] MMMM YYYY h[e]mm A',
948 LLLL : 'dddd, D [a viz] MMMM YYYY h[e]mm A'
949 },
950 calendar : {
951 sameDay : '[Hiziv da] LT',
952 nextDay : '[Warc\'hoazh da] LT',
953 nextWeek : 'dddd [da] LT',
954 lastDay : '[Dec\'h da] LT',
955 lastWeek : 'dddd [paset da] LT',
956 sameElse : 'L'
957 },
958 relativeTime : {
959 future : 'a-benn %s',
960 past : '%s \'zo',
961 s : 'un nebeud segondennoù',
962 m : 'ur vunutenn',
963 mm : relativeTimeWithMutation,
964 h : 'un eur',
965 hh : '%d eur',
966 d : 'un devezh',
967 dd : relativeTimeWithMutation,
968 M : 'ur miz',
969 MM : relativeTimeWithMutation,
970 y : 'ur bloaz',
971 yy : specialMutationForYears
972 },
973 ordinalParse: /\d{1,2}(añ|vet)/,
974 ordinal : function (number) {
975 var output = (number === 1) ? 'añ' : 'vet';
976 return number + output;
977 },
978 week : {
979 dow : 1, // Monday is the first day of the week.
980 doy : 4 // The week that contains Jan 4th is the first week of the year.
981 }
982 });
983
984 //! moment.js locale configuration
985 //! locale : bosnian (bs)
986 //! author : Nedim Cholich : https://github.com/frontyard
987 //! based on (hr) translation by Bojan Marković
988
989 function bs__translate(number, withoutSuffix, key) {
990 var result = number + ' ';
991 switch (key) {
992 case 'm':
993 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
994 case 'mm':
995 if (number === 1) {
996 result += 'minuta';
997 } else if (number === 2 || number === 3 || number === 4) {
998 result += 'minute';
999 } else {
1000 result += 'minuta';
1001 }
1002 return result;
1003 case 'h':
1004 return withoutSuffix ? 'jedan sat' : 'jednog sata';
1005 case 'hh':
1006 if (number === 1) {
1007 result += 'sat';
1008 } else if (number === 2 || number === 3 || number === 4) {
1009 result += 'sata';
1010 } else {
1011 result += 'sati';
1012 }
1013 return result;
1014 case 'dd':
1015 if (number === 1) {
1016 result += 'dan';
1017 } else {
1018 result += 'dana';
1019 }
1020 return result;
1021 case 'MM':
1022 if (number === 1) {
1023 result += 'mjesec';
1024 } else if (number === 2 || number === 3 || number === 4) {
1025 result += 'mjeseca';
1026 } else {
1027 result += 'mjeseci';
1028 }
1029 return result;
1030 case 'yy':
1031 if (number === 1) {
1032 result += 'godina';
1033 } else if (number === 2 || number === 3 || number === 4) {
1034 result += 'godine';
1035 } else {
1036 result += 'godina';
1037 }
1038 return result;
1039 }
1040 }
1041
1042 var bs = moment.defineLocale('bs', {
1043 months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
1044 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
1045 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
1046 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
1047 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
1048 longDateFormat : {
1049 LT : 'H:mm',
1050 LTS : 'H:mm:ss',
1051 L : 'DD. MM. YYYY',
1052 LL : 'D. MMMM YYYY',
1053 LLL : 'D. MMMM YYYY H:mm',
1054 LLLL : 'dddd, D. MMMM YYYY H:mm'
1055 },
1056 calendar : {
1057 sameDay : '[danas u] LT',
1058 nextDay : '[sutra u] LT',
1059 nextWeek : function () {
1060 switch (this.day()) {
1061 case 0:
1062 return '[u] [nedjelju] [u] LT';
1063 case 3:
1064 return '[u] [srijedu] [u] LT';
1065 case 6:
1066 return '[u] [subotu] [u] LT';
1067 case 1:
1068 case 2:
1069 case 4:
1070 case 5:
1071 return '[u] dddd [u] LT';
1072 }
1073 },
1074 lastDay : '[jučer u] LT',
1075 lastWeek : function () {
1076 switch (this.day()) {
1077 case 0:
1078 case 3:
1079 return '[prošlu] dddd [u] LT';
1080 case 6:
1081 return '[prošle] [subote] [u] LT';
1082 case 1:
1083 case 2:
1084 case 4:
1085 case 5:
1086 return '[prošli] dddd [u] LT';
1087 }
1088 },
1089 sameElse : 'L'
1090 },
1091 relativeTime : {
1092 future : 'za %s',
1093 past : 'prije %s',
1094 s : 'par sekundi',
1095 m : bs__translate,
1096 mm : bs__translate,
1097 h : bs__translate,
1098 hh : bs__translate,
1099 d : 'dan',
1100 dd : bs__translate,
1101 M : 'mjesec',
1102 MM : bs__translate,
1103 y : 'godinu',
1104 yy : bs__translate
1105 },
1106 ordinalParse: /\d{1,2}\./,
1107 ordinal : '%d.',
1108 week : {
1109 dow : 1, // Monday is the first day of the week.
1110 doy : 7 // The week that contains Jan 1st is the first week of the year.
1111 }
1112 });
1113
1114 //! moment.js locale configuration
1115 //! locale : catalan (ca)
1116 //! author : Juan G. Hurtado : https://github.com/juanghurtado
1117
1118 var ca = moment.defineLocale('ca', {
1119 months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
1120 monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
1121 weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
1122 weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
1123 weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
1124 longDateFormat : {
1125 LT : 'H:mm',
1126 LTS : 'LT:ss',
1127 L : 'DD/MM/YYYY',
1128 LL : 'D MMMM YYYY',
1129 LLL : 'D MMMM YYYY H:mm',
1130 LLLL : 'dddd D MMMM YYYY H:mm'
1131 },
1132 calendar : {
1133 sameDay : function () {
1134 return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
1135 },
1136 nextDay : function () {
1137 return '[demà a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
1138 },
1139 nextWeek : function () {
1140 return 'dddd [a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
1141 },
1142 lastDay : function () {
1143 return '[ahir a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
1144 },
1145 lastWeek : function () {
1146 return '[el] dddd [passat a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
1147 },
1148 sameElse : 'L'
1149 },
1150 relativeTime : {
1151 future : 'en %s',
1152 past : 'fa %s',
1153 s : 'uns segons',
1154 m : 'un minut',
1155 mm : '%d minuts',
1156 h : 'una hora',
1157 hh : '%d hores',
1158 d : 'un dia',
1159 dd : '%d dies',
1160 M : 'un mes',
1161 MM : '%d mesos',
1162 y : 'un any',
1163 yy : '%d anys'
1164 },
1165 ordinalParse: /\d{1,2}(r|n|t|è|a)/,
1166 ordinal : function (number, period) {
1167 var output = (number === 1) ? 'r' :
1168 (number === 2) ? 'n' :
1169 (number === 3) ? 'r' :
1170 (number === 4) ? 't' : 'è';
1171 if (period === 'w' || period === 'W') {
1172 output = 'a';
1173 }
1174 return number + output;
1175 },
1176 week : {
1177 dow : 1, // Monday is the first day of the week.
1178 doy : 4 // The week that contains Jan 4th is the first week of the year.
1179 }
1180 });
1181
1182 //! moment.js locale configuration
1183 //! locale : czech (cs)
1184 //! author : petrbela : https://github.com/petrbela
1185
1186 var cs__months = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_'),
1187 cs__monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_');
1188 function cs__plural(n) {
1189 return (n > 1) && (n < 5) && (~~(n / 10) !== 1);
1190 }
1191 function cs__translate(number, withoutSuffix, key, isFuture) {
1192 var result = number + ' ';
1193 switch (key) {
1194 case 's': // a few seconds / in a few seconds / a few seconds ago
1195 return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
1196 case 'm': // a minute / in a minute / a minute ago
1197 return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
1198 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
1199 if (withoutSuffix || isFuture) {
1200 return result + (cs__plural(number) ? 'minuty' : 'minut');
1201 } else {
1202 return result + 'minutami';
1203 }
1204 break;
1205 case 'h': // an hour / in an hour / an hour ago
1206 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
1207 case 'hh': // 9 hours / in 9 hours / 9 hours ago
1208 if (withoutSuffix || isFuture) {
1209 return result + (cs__plural(number) ? 'hodiny' : 'hodin');
1210 } else {
1211 return result + 'hodinami';
1212 }
1213 break;
1214 case 'd': // a day / in a day / a day ago
1215 return (withoutSuffix || isFuture) ? 'den' : 'dnem';
1216 case 'dd': // 9 days / in 9 days / 9 days ago
1217 if (withoutSuffix || isFuture) {
1218 return result + (cs__plural(number) ? 'dny' : 'dní');
1219 } else {
1220 return result + 'dny';
1221 }
1222 break;
1223 case 'M': // a month / in a month / a month ago
1224 return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
1225 case 'MM': // 9 months / in 9 months / 9 months ago
1226 if (withoutSuffix || isFuture) {
1227 return result + (cs__plural(number) ? 'měsíce' : 'měsíců');
1228 } else {
1229 return result + 'měsíci';
1230 }
1231 break;
1232 case 'y': // a year / in a year / a year ago
1233 return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
1234 case 'yy': // 9 years / in 9 years / 9 years ago
1235 if (withoutSuffix || isFuture) {
1236 return result + (cs__plural(number) ? 'roky' : 'let');
1237 } else {
1238 return result + 'lety';
1239 }
1240 break;
1241 }
1242 }
1243
1244 var cs = moment.defineLocale('cs', {
1245 months : cs__months,
1246 monthsShort : cs__monthsShort,
1247 monthsParse : (function (months, monthsShort) {
1248 var i, _monthsParse = [];
1249 for (i = 0; i < 12; i++) {
1250 // use custom parser to solve problem with July (červenec)
1251 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
1252 }
1253 return _monthsParse;
1254 }(cs__months, cs__monthsShort)),
1255 weekdays : 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
1256 weekdaysShort : 'ne_po_út_st_čt_pá_so'.split('_'),
1257 weekdaysMin : 'ne_po_út_st_čt_pá_so'.split('_'),
1258 longDateFormat : {
1259 LT: 'H:mm',
1260 LTS : 'H:mm:ss',
1261 L : 'DD.MM.YYYY',
1262 LL : 'D. MMMM YYYY',
1263 LLL : 'D. MMMM YYYY H:mm',
1264 LLLL : 'dddd D. MMMM YYYY H:mm'
1265 },
1266 calendar : {
1267 sameDay: '[dnes v] LT',
1268 nextDay: '[zítra v] LT',
1269 nextWeek: function () {
1270 switch (this.day()) {
1271 case 0:
1272 return '[v neděli v] LT';
1273 case 1:
1274 case 2:
1275 return '[v] dddd [v] LT';
1276 case 3:
1277 return '[ve středu v] LT';
1278 case 4:
1279 return '[ve čtvrtek v] LT';
1280 case 5:
1281 return '[v pátek v] LT';
1282 case 6:
1283 return '[v sobotu v] LT';
1284 }
1285 },
1286 lastDay: '[včera v] LT',
1287 lastWeek: function () {
1288 switch (this.day()) {
1289 case 0:
1290 return '[minulou neděli v] LT';
1291 case 1:
1292 case 2:
1293 return '[minulé] dddd [v] LT';
1294 case 3:
1295 return '[minulou středu v] LT';
1296 case 4:
1297 case 5:
1298 return '[minulý] dddd [v] LT';
1299 case 6:
1300 return '[minulou sobotu v] LT';
1301 }
1302 },
1303 sameElse: 'L'
1304 },
1305 relativeTime : {
1306 future : 'za %s',
1307 past : 'před %s',
1308 s : cs__translate,
1309 m : cs__translate,
1310 mm : cs__translate,
1311 h : cs__translate,
1312 hh : cs__translate,
1313 d : cs__translate,
1314 dd : cs__translate,
1315 M : cs__translate,
1316 MM : cs__translate,
1317 y : cs__translate,
1318 yy : cs__translate
1319 },
1320 ordinalParse : /\d{1,2}\./,
1321 ordinal : '%d.',
1322 week : {
1323 dow : 1, // Monday is the first day of the week.
1324 doy : 4 // The week that contains Jan 4th is the first week of the year.
1325 }
1326 });
1327
1328 //! moment.js locale configuration
1329 //! locale : chuvash (cv)
1330 //! author : Anatoly Mironov : https://github.com/mirontoli
1331
1332 var cv = moment.defineLocale('cv', {
1333 months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
1334 monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
1335 weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
1336 weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
1337 weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
1338 longDateFormat : {
1339 LT : 'HH:mm',
1340 LTS : 'HH:mm:ss',
1341 L : 'DD-MM-YYYY',
1342 LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
1343 LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm',
1344 LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm'
1345 },
1346 calendar : {
1347 sameDay: '[Паян] LT [сехетре]',
1348 nextDay: '[Ыран] LT [сехетре]',
1349 lastDay: '[Ӗнер] LT [сехетре]',
1350 nextWeek: '[Ҫитес] dddd LT [сехетре]',
1351 lastWeek: '[Иртнӗ] dddd LT [сехетре]',
1352 sameElse: 'L'
1353 },
1354 relativeTime : {
1355 future : function (output) {
1356 var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
1357 return output + affix;
1358 },
1359 past : '%s каялла',
1360 s : 'пӗр-ик ҫеккунт',
1361 m : 'пӗр минут',
1362 mm : '%d минут',
1363 h : 'пӗр сехет',
1364 hh : '%d сехет',
1365 d : 'пӗр кун',
1366 dd : '%d кун',
1367 M : 'пӗр уйӑх',
1368 MM : '%d уйӑх',
1369 y : 'пӗр ҫул',
1370 yy : '%d ҫул'
1371 },
1372 ordinalParse: /\d{1,2}-мӗш/,
1373 ordinal : '%d-мӗш',
1374 week : {
1375 dow : 1, // Monday is the first day of the week.
1376 doy : 7 // The week that contains Jan 1st is the first week of the year.
1377 }
1378 });
1379
1380 //! moment.js locale configuration
1381 //! locale : Welsh (cy)
1382 //! author : Robert Allen
1383
1384 var cy = moment.defineLocale('cy', {
1385 months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'),
1386 monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'),
1387 weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
1388 weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
1389 weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
1390 // time formats are the same as en-gb
1391 longDateFormat: {
1392 LT: 'HH:mm',
1393 LTS : 'HH:mm:ss',
1394 L: 'DD/MM/YYYY',
1395 LL: 'D MMMM YYYY',
1396 LLL: 'D MMMM YYYY HH:mm',
1397 LLLL: 'dddd, D MMMM YYYY HH:mm'
1398 },
1399 calendar: {
1400 sameDay: '[Heddiw am] LT',
1401 nextDay: '[Yfory am] LT',
1402 nextWeek: 'dddd [am] LT',
1403 lastDay: '[Ddoe am] LT',
1404 lastWeek: 'dddd [diwethaf am] LT',
1405 sameElse: 'L'
1406 },
1407 relativeTime: {
1408 future: 'mewn %s',
1409 past: '%s yn ôl',
1410 s: 'ychydig eiliadau',
1411 m: 'munud',
1412 mm: '%d munud',
1413 h: 'awr',
1414 hh: '%d awr',
1415 d: 'diwrnod',
1416 dd: '%d diwrnod',
1417 M: 'mis',
1418 MM: '%d mis',
1419 y: 'blwyddyn',
1420 yy: '%d flynedd'
1421 },
1422 ordinalParse: /\d{1,2}(fed|ain|af|il|ydd|ed|eg)/,
1423 // traditional ordinal numbers above 31 are not commonly used in colloquial Welsh
1424 ordinal: function (number) {
1425 var b = number,
1426 output = '',
1427 lookup = [
1428 '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed
1429 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed
1430 ];
1431 if (b > 20) {
1432 if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) {
1433 output = 'fed'; // not 30ain, 70ain or 90ain
1434 } else {
1435 output = 'ain';
1436 }
1437 } else if (b > 0) {
1438 output = lookup[b];
1439 }
1440 return number + output;
1441 },
1442 week : {
1443 dow : 1, // Monday is the first day of the week.
1444 doy : 4 // The week that contains Jan 4th is the first week of the year.
1445 }
1446 });
1447
1448 //! moment.js locale configuration
1449 //! locale : danish (da)
1450 //! author : Ulrik Nielsen : https://github.com/mrbase
1451
1452 var da = moment.defineLocale('da', {
1453 months : 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'),
1454 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
1455 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
1456 weekdaysShort : 'søn_man_tir_ons_tor_fre_lør'.split('_'),
1457 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
1458 longDateFormat : {
1459 LT : 'HH:mm',
1460 LTS : 'HH:mm:ss',
1461 L : 'DD/MM/YYYY',
1462 LL : 'D. MMMM YYYY',
1463 LLL : 'D. MMMM YYYY HH:mm',
1464 LLLL : 'dddd [d.] D. MMMM YYYY HH:mm'
1465 },
1466 calendar : {
1467 sameDay : '[I dag kl.] LT',
1468 nextDay : '[I morgen kl.] LT',
1469 nextWeek : 'dddd [kl.] LT',
1470 lastDay : '[I går kl.] LT',
1471 lastWeek : '[sidste] dddd [kl] LT',
1472 sameElse : 'L'
1473 },
1474 relativeTime : {
1475 future : 'om %s',
1476 past : '%s siden',
1477 s : 'få sekunder',
1478 m : 'et minut',
1479 mm : '%d minutter',
1480 h : 'en time',
1481 hh : '%d timer',
1482 d : 'en dag',
1483 dd : '%d dage',
1484 M : 'en måned',
1485 MM : '%d måneder',
1486 y : 'et år',
1487 yy : '%d år'
1488 },
1489 ordinalParse: /\d{1,2}\./,
1490 ordinal : '%d.',
1491 week : {
1492 dow : 1, // Monday is the first day of the week.
1493 doy : 4 // The week that contains Jan 4th is the first week of the year.
1494 }
1495 });
1496
1497 //! moment.js locale configuration
1498 //! locale : austrian german (de-at)
1499 //! author : lluchs : https://github.com/lluchs
1500 //! author: Menelion Elensúle: https://github.com/Oire
1501 //! author : Martin Groller : https://github.com/MadMG
1502
1503 function de_at__processRelativeTime(number, withoutSuffix, key, isFuture) {
1504 var format = {
1505 'm': ['eine Minute', 'einer Minute'],
1506 'h': ['eine Stunde', 'einer Stunde'],
1507 'd': ['ein Tag', 'einem Tag'],
1508 'dd': [number + ' Tage', number + ' Tagen'],
1509 'M': ['ein Monat', 'einem Monat'],
1510 'MM': [number + ' Monate', number + ' Monaten'],
1511 'y': ['ein Jahr', 'einem Jahr'],
1512 'yy': [number + ' Jahre', number + ' Jahren']
1513 };
1514 return withoutSuffix ? format[key][0] : format[key][1];
1515 }
1516
1517 var de_at = moment.defineLocale('de-at', {
1518 months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
1519 monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
1520 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
1521 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
1522 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
1523 longDateFormat : {
1524 LT: 'HH:mm',
1525 LTS: 'HH:mm:ss',
1526 L : 'DD.MM.YYYY',
1527 LL : 'D. MMMM YYYY',
1528 LLL : 'D. MMMM YYYY HH:mm',
1529 LLLL : 'dddd, D. MMMM YYYY HH:mm'
1530 },
1531 calendar : {
1532 sameDay: '[Heute um] LT [Uhr]',
1533 sameElse: 'L',
1534 nextDay: '[Morgen um] LT [Uhr]',
1535 nextWeek: 'dddd [um] LT [Uhr]',
1536 lastDay: '[Gestern um] LT [Uhr]',
1537 lastWeek: '[letzten] dddd [um] LT [Uhr]'
1538 },
1539 relativeTime : {
1540 future : 'in %s',
1541 past : 'vor %s',
1542 s : 'ein paar Sekunden',
1543 m : de_at__processRelativeTime,
1544 mm : '%d Minuten',
1545 h : de_at__processRelativeTime,
1546 hh : '%d Stunden',
1547 d : de_at__processRelativeTime,
1548 dd : de_at__processRelativeTime,
1549 M : de_at__processRelativeTime,
1550 MM : de_at__processRelativeTime,
1551 y : de_at__processRelativeTime,
1552 yy : de_at__processRelativeTime
1553 },
1554 ordinalParse: /\d{1,2}\./,
1555 ordinal : '%d.',
1556 week : {
1557 dow : 1, // Monday is the first day of the week.
1558 doy : 4 // The week that contains Jan 4th is the first week of the year.
1559 }
1560 });
1561
1562 //! moment.js locale configuration
1563 //! locale : german (de)
1564 //! author : lluchs : https://github.com/lluchs
1565 //! author: Menelion Elensúle: https://github.com/Oire
1566
1567 function de__processRelativeTime(number, withoutSuffix, key, isFuture) {
1568 var format = {
1569 'm': ['eine Minute', 'einer Minute'],
1570 'h': ['eine Stunde', 'einer Stunde'],
1571 'd': ['ein Tag', 'einem Tag'],
1572 'dd': [number + ' Tage', number + ' Tagen'],
1573 'M': ['ein Monat', 'einem Monat'],
1574 'MM': [number + ' Monate', number + ' Monaten'],
1575 'y': ['ein Jahr', 'einem Jahr'],
1576 'yy': [number + ' Jahre', number + ' Jahren']
1577 };
1578 return withoutSuffix ? format[key][0] : format[key][1];
1579 }
1580
1581 var de = moment.defineLocale('de', {
1582 months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
1583 monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
1584 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
1585 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
1586 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
1587 longDateFormat : {
1588 LT: 'HH:mm',
1589 LTS: 'HH:mm:ss',
1590 L : 'DD.MM.YYYY',
1591 LL : 'D. MMMM YYYY',
1592 LLL : 'D. MMMM YYYY HH:mm',
1593 LLLL : 'dddd, D. MMMM YYYY HH:mm'
1594 },
1595 calendar : {
1596 sameDay: '[Heute um] LT [Uhr]',
1597 sameElse: 'L',
1598 nextDay: '[Morgen um] LT [Uhr]',
1599 nextWeek: 'dddd [um] LT [Uhr]',
1600 lastDay: '[Gestern um] LT [Uhr]',
1601 lastWeek: '[letzten] dddd [um] LT [Uhr]'
1602 },
1603 relativeTime : {
1604 future : 'in %s',
1605 past : 'vor %s',
1606 s : 'ein paar Sekunden',
1607 m : de__processRelativeTime,
1608 mm : '%d Minuten',
1609 h : de__processRelativeTime,
1610 hh : '%d Stunden',
1611 d : de__processRelativeTime,
1612 dd : de__processRelativeTime,
1613 M : de__processRelativeTime,
1614 MM : de__processRelativeTime,
1615 y : de__processRelativeTime,
1616 yy : de__processRelativeTime
1617 },
1618 ordinalParse: /\d{1,2}\./,
1619 ordinal : '%d.',
1620 week : {
1621 dow : 1, // Monday is the first day of the week.
1622 doy : 4 // The week that contains Jan 4th is the first week of the year.
1623 }
1624 });
1625
1626 //! moment.js locale configuration
1627 //! locale : modern greek (el)
1628 //! author : Aggelos Karalias : https://github.com/mehiel
1629
1630 var el = moment.defineLocale('el', {
1631 monthsNominativeEl : 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'),
1632 monthsGenitiveEl : 'Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου'.split('_'),
1633 months : function (momentToFormat, format) {
1634 if (/D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
1635 return this._monthsGenitiveEl[momentToFormat.month()];
1636 } else {
1637 return this._monthsNominativeEl[momentToFormat.month()];
1638 }
1639 },
1640 monthsShort : 'Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ'.split('_'),
1641 weekdays : 'Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο'.split('_'),
1642 weekdaysShort : 'Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ'.split('_'),
1643 weekdaysMin : 'Κυ_Δε_Τρ_Τε_Πε_Πα_Σα'.split('_'),
1644 meridiem : function (hours, minutes, isLower) {
1645 if (hours > 11) {
1646 return isLower ? 'μμ' : 'ΜΜ';
1647 } else {
1648 return isLower ? 'πμ' : 'ΠΜ';
1649 }
1650 },
1651 isPM : function (input) {
1652 return ((input + '').toLowerCase()[0] === 'μ');
1653 },
1654 meridiemParse : /[ΠΜ]\.?Μ?\.?/i,
1655 longDateFormat : {
1656 LT : 'h:mm A',
1657 LTS : 'h:mm:ss A',
1658 L : 'DD/MM/YYYY',
1659 LL : 'D MMMM YYYY',
1660 LLL : 'D MMMM YYYY h:mm A',
1661 LLLL : 'dddd, D MMMM YYYY h:mm A'
1662 },
1663 calendarEl : {
1664 sameDay : '[Σήμερα {}] LT',
1665 nextDay : '[Αύριο {}] LT',
1666 nextWeek : 'dddd [{}] LT',
1667 lastDay : '[Χθες {}] LT',
1668 lastWeek : function () {
1669 switch (this.day()) {
1670 case 6:
1671 return '[το προηγούμενο] dddd [{}] LT';
1672 default:
1673 return '[την προηγούμενη] dddd [{}] LT';
1674 }
1675 },
1676 sameElse : 'L'
1677 },
1678 calendar : function (key, mom) {
1679 var output = this._calendarEl[key],
1680 hours = mom && mom.hours();
1681 if (typeof output === 'function') {
1682 output = output.apply(mom);
1683 }
1684 return output.replace('{}', (hours % 12 === 1 ? 'στη' : 'στις'));
1685 },
1686 relativeTime : {
1687 future : 'σε %s',
1688 past : '%s πριν',
1689 s : 'λίγα δευτερόλεπτα',
1690 m : 'ένα λεπτό',
1691 mm : '%d λεπτά',
1692 h : 'μία ώρα',
1693 hh : '%d ώρες',
1694 d : 'μία μέρα',
1695 dd : '%d μέρες',
1696 M : 'ένας μήνας',
1697 MM : '%d μήνες',
1698 y : 'ένας χρόνος',
1699 yy : '%d χρόνια'
1700 },
1701 ordinalParse: /\d{1,2}η/,
1702 ordinal: '%dη',
1703 week : {
1704 dow : 1, // Monday is the first day of the week.
1705 doy : 4 // The week that contains Jan 4st is the first week of the year.
1706 }
1707 });
1708
1709 //! moment.js locale configuration
1710 //! locale : australian english (en-au)
1711
1712 var en_au = moment.defineLocale('en-au', {
1713 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
1714 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
1715 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
1716 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
1717 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
1718 longDateFormat : {
1719 LT : 'h:mm A',
1720 LTS : 'h:mm:ss A',
1721 L : 'DD/MM/YYYY',
1722 LL : 'D MMMM YYYY',
1723 LLL : 'D MMMM YYYY h:mm A',
1724 LLLL : 'dddd, D MMMM YYYY h:mm A'
1725 },
1726 calendar : {
1727 sameDay : '[Today at] LT',
1728 nextDay : '[Tomorrow at] LT',
1729 nextWeek : 'dddd [at] LT',
1730 lastDay : '[Yesterday at] LT',
1731 lastWeek : '[Last] dddd [at] LT',
1732 sameElse : 'L'
1733 },
1734 relativeTime : {
1735 future : 'in %s',
1736 past : '%s ago',
1737 s : 'a few seconds',
1738 m : 'a minute',
1739 mm : '%d minutes',
1740 h : 'an hour',
1741 hh : '%d hours',
1742 d : 'a day',
1743 dd : '%d days',
1744 M : 'a month',
1745 MM : '%d months',
1746 y : 'a year',
1747 yy : '%d years'
1748 },
1749 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
1750 ordinal : function (number) {
1751 var b = number % 10,
1752 output = (~~(number % 100 / 10) === 1) ? 'th' :
1753 (b === 1) ? 'st' :
1754 (b === 2) ? 'nd' :
1755 (b === 3) ? 'rd' : 'th';
1756 return number + output;
1757 },
1758 week : {
1759 dow : 1, // Monday is the first day of the week.
1760 doy : 4 // The week that contains Jan 4th is the first week of the year.
1761 }
1762 });
1763
1764 //! moment.js locale configuration
1765 //! locale : canadian english (en-ca)
1766 //! author : Jonathan Abourbih : https://github.com/jonbca
1767
1768 var en_ca = moment.defineLocale('en-ca', {
1769 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
1770 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
1771 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
1772 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
1773 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
1774 longDateFormat : {
1775 LT : 'h:mm A',
1776 LTS : 'h:mm:ss A',
1777 L : 'YYYY-MM-DD',
1778 LL : 'D MMMM, YYYY',
1779 LLL : 'D MMMM, YYYY h:mm A',
1780 LLLL : 'dddd, D MMMM, YYYY h:mm A'
1781 },
1782 calendar : {
1783 sameDay : '[Today at] LT',
1784 nextDay : '[Tomorrow at] LT',
1785 nextWeek : 'dddd [at] LT',
1786 lastDay : '[Yesterday at] LT',
1787 lastWeek : '[Last] dddd [at] LT',
1788 sameElse : 'L'
1789 },
1790 relativeTime : {
1791 future : 'in %s',
1792 past : '%s ago',
1793 s : 'a few seconds',
1794 m : 'a minute',
1795 mm : '%d minutes',
1796 h : 'an hour',
1797 hh : '%d hours',
1798 d : 'a day',
1799 dd : '%d days',
1800 M : 'a month',
1801 MM : '%d months',
1802 y : 'a year',
1803 yy : '%d years'
1804 },
1805 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
1806 ordinal : function (number) {
1807 var b = number % 10,
1808 output = (~~(number % 100 / 10) === 1) ? 'th' :
1809 (b === 1) ? 'st' :
1810 (b === 2) ? 'nd' :
1811 (b === 3) ? 'rd' : 'th';
1812 return number + output;
1813 }
1814 });
1815
1816 //! moment.js locale configuration
1817 //! locale : great britain english (en-gb)
1818 //! author : Chris Gedrim : https://github.com/chrisgedrim
1819
1820 var en_gb = moment.defineLocale('en-gb', {
1821 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
1822 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
1823 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
1824 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
1825 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
1826 longDateFormat : {
1827 LT : 'HH:mm',
1828 LTS : 'HH:mm:ss',
1829 L : 'DD/MM/YYYY',
1830 LL : 'D MMMM YYYY',
1831 LLL : 'D MMMM YYYY HH:mm',
1832 LLLL : 'dddd, D MMMM YYYY HH:mm'
1833 },
1834 calendar : {
1835 sameDay : '[Today at] LT',
1836 nextDay : '[Tomorrow at] LT',
1837 nextWeek : 'dddd [at] LT',
1838 lastDay : '[Yesterday at] LT',
1839 lastWeek : '[Last] dddd [at] LT',
1840 sameElse : 'L'
1841 },
1842 relativeTime : {
1843 future : 'in %s',
1844 past : '%s ago',
1845 s : 'a few seconds',
1846 m : 'a minute',
1847 mm : '%d minutes',
1848 h : 'an hour',
1849 hh : '%d hours',
1850 d : 'a day',
1851 dd : '%d days',
1852 M : 'a month',
1853 MM : '%d months',
1854 y : 'a year',
1855 yy : '%d years'
1856 },
1857 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
1858 ordinal : function (number) {
1859 var b = number % 10,
1860 output = (~~(number % 100 / 10) === 1) ? 'th' :
1861 (b === 1) ? 'st' :
1862 (b === 2) ? 'nd' :
1863 (b === 3) ? 'rd' : 'th';
1864 return number + output;
1865 },
1866 week : {
1867 dow : 1, // Monday is the first day of the week.
1868 doy : 4 // The week that contains Jan 4th is the first week of the year.
1869 }
1870 });
1871
1872 //! moment.js locale configuration
1873 //! locale : esperanto (eo)
1874 //! author : Colin Dean : https://github.com/colindean
1875 //! komento: Mi estas malcerta se mi korekte traktis akuzativojn en tiu traduko.
1876 //! Se ne, bonvolu korekti kaj avizi min por ke mi povas lerni!
1877
1878 var eo = moment.defineLocale('eo', {
1879 months : 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'),
1880 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'),
1881 weekdays : 'Dimanĉo_Lundo_Mardo_Merkredo_Ĵaŭdo_Vendredo_Sabato'.split('_'),
1882 weekdaysShort : 'Dim_Lun_Mard_Merk_Ĵaŭ_Ven_Sab'.split('_'),
1883 weekdaysMin : 'Di_Lu_Ma_Me_Ĵa_Ve_Sa'.split('_'),
1884 longDateFormat : {
1885 LT : 'HH:mm',
1886 LTS : 'HH:mm:ss',
1887 L : 'YYYY-MM-DD',
1888 LL : 'D[-an de] MMMM, YYYY',
1889 LLL : 'D[-an de] MMMM, YYYY HH:mm',
1890 LLLL : 'dddd, [la] D[-an de] MMMM, YYYY HH:mm'
1891 },
1892 meridiemParse: /[ap]\.t\.m/i,
1893 isPM: function (input) {
1894 return input.charAt(0).toLowerCase() === 'p';
1895 },
1896 meridiem : function (hours, minutes, isLower) {
1897 if (hours > 11) {
1898 return isLower ? 'p.t.m.' : 'P.T.M.';
1899 } else {
1900 return isLower ? 'a.t.m.' : 'A.T.M.';
1901 }
1902 },
1903 calendar : {
1904 sameDay : '[Hodiaŭ je] LT',
1905 nextDay : '[Morgaŭ je] LT',
1906 nextWeek : 'dddd [je] LT',
1907 lastDay : '[Hieraŭ je] LT',
1908 lastWeek : '[pasinta] dddd [je] LT',
1909 sameElse : 'L'
1910 },
1911 relativeTime : {
1912 future : 'je %s',
1913 past : 'antaŭ %s',
1914 s : 'sekundoj',
1915 m : 'minuto',
1916 mm : '%d minutoj',
1917 h : 'horo',
1918 hh : '%d horoj',
1919 d : 'tago',//ne 'diurno', ĉar estas uzita por proksimumo
1920 dd : '%d tagoj',
1921 M : 'monato',
1922 MM : '%d monatoj',
1923 y : 'jaro',
1924 yy : '%d jaroj'
1925 },
1926 ordinalParse: /\d{1,2}a/,
1927 ordinal : '%da',
1928 week : {
1929 dow : 1, // Monday is the first day of the week.
1930 doy : 7 // The week that contains Jan 1st is the first week of the year.
1931 }
1932 });
1933
1934 //! moment.js locale configuration
1935 //! locale : spanish (es)
1936 //! author : Julio Napurí : https://github.com/julionc
1937
1938 var monthsShortDot = 'Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.'.split('_'),
1939 es__monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
1940
1941 var es = moment.defineLocale('es', {
1942 months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
1943 monthsShort : function (m, format) {
1944 if (/-MMM-/.test(format)) {
1945 return es__monthsShort[m.month()];
1946 } else {
1947 return monthsShortDot[m.month()];
1948 }
1949 },
1950 weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
1951 weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
1952 weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
1953 longDateFormat : {
1954 LT : 'H:mm',
1955 LTS : 'H:mm:ss',
1956 L : 'DD/MM/YYYY',
1957 LL : 'D [de] MMMM [de] YYYY',
1958 LLL : 'D [de] MMMM [de] YYYY H:mm',
1959 LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
1960 },
1961 calendar : {
1962 sameDay : function () {
1963 return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
1964 },
1965 nextDay : function () {
1966 return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
1967 },
1968 nextWeek : function () {
1969 return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
1970 },
1971 lastDay : function () {
1972 return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
1973 },
1974 lastWeek : function () {
1975 return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
1976 },
1977 sameElse : 'L'
1978 },
1979 relativeTime : {
1980 future : 'en %s',
1981 past : 'hace %s',
1982 s : 'unos segundos',
1983 m : 'un minuto',
1984 mm : '%d minutos',
1985 h : 'una hora',
1986 hh : '%d horas',
1987 d : 'un día',
1988 dd : '%d días',
1989 M : 'un mes',
1990 MM : '%d meses',
1991 y : 'un año',
1992 yy : '%d años'
1993 },
1994 ordinalParse : /\d{1,2}º/,
1995 ordinal : '%dº',
1996 week : {
1997 dow : 1, // Monday is the first day of the week.
1998 doy : 4 // The week that contains Jan 4th is the first week of the year.
1999 }
2000 });
2001
2002 //! moment.js locale configuration
2003 //! locale : estonian (et)
2004 //! author : Henry Kehlmann : https://github.com/madhenry
2005 //! improvements : Illimar Tambek : https://github.com/ragulka
2006
2007 function et__processRelativeTime(number, withoutSuffix, key, isFuture) {
2008 var format = {
2009 's' : ['mõne sekundi', 'mõni sekund', 'paar sekundit'],
2010 'm' : ['ühe minuti', 'üks minut'],
2011 'mm': [number + ' minuti', number + ' minutit'],
2012 'h' : ['ühe tunni', 'tund aega', 'üks tund'],
2013 'hh': [number + ' tunni', number + ' tundi'],
2014 'd' : ['ühe päeva', 'üks päev'],
2015 'M' : ['kuu aja', 'kuu aega', 'üks kuu'],
2016 'MM': [number + ' kuu', number + ' kuud'],
2017 'y' : ['ühe aasta', 'aasta', 'üks aasta'],
2018 'yy': [number + ' aasta', number + ' aastat']
2019 };
2020 if (withoutSuffix) {
2021 return format[key][2] ? format[key][2] : format[key][1];
2022 }
2023 return isFuture ? format[key][0] : format[key][1];
2024 }
2025
2026 var et = moment.defineLocale('et', {
2027 months : 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'),
2028 monthsShort : 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'),
2029 weekdays : 'pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev'.split('_'),
2030 weekdaysShort : 'P_E_T_K_N_R_L'.split('_'),
2031 weekdaysMin : 'P_E_T_K_N_R_L'.split('_'),
2032 longDateFormat : {
2033 LT : 'H:mm',
2034 LTS : 'H:mm:ss',
2035 L : 'DD.MM.YYYY',
2036 LL : 'D. MMMM YYYY',
2037 LLL : 'D. MMMM YYYY H:mm',
2038 LLLL : 'dddd, D. MMMM YYYY H:mm'
2039 },
2040 calendar : {
2041 sameDay : '[Täna,] LT',
2042 nextDay : '[Homme,] LT',
2043 nextWeek : '[Järgmine] dddd LT',
2044 lastDay : '[Eile,] LT',
2045 lastWeek : '[Eelmine] dddd LT',
2046 sameElse : 'L'
2047 },
2048 relativeTime : {
2049 future : '%s pärast',
2050 past : '%s tagasi',
2051 s : et__processRelativeTime,
2052 m : et__processRelativeTime,
2053 mm : et__processRelativeTime,
2054 h : et__processRelativeTime,
2055 hh : et__processRelativeTime,
2056 d : et__processRelativeTime,
2057 dd : '%d päeva',
2058 M : et__processRelativeTime,
2059 MM : et__processRelativeTime,
2060 y : et__processRelativeTime,
2061 yy : et__processRelativeTime
2062 },
2063 ordinalParse: /\d{1,2}\./,
2064 ordinal : '%d.',
2065 week : {
2066 dow : 1, // Monday is the first day of the week.
2067 doy : 4 // The week that contains Jan 4th is the first week of the year.
2068 }
2069 });
2070
2071 //! moment.js locale configuration
2072 //! locale : euskara (eu)
2073 //! author : Eneko Illarramendi : https://github.com/eillarra
2074
2075 var eu = moment.defineLocale('eu', {
2076 months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
2077 monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
2078 weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
2079 weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
2080 weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
2081 longDateFormat : {
2082 LT : 'HH:mm',
2083 LTS : 'HH:mm:ss',
2084 L : 'YYYY-MM-DD',
2085 LL : 'YYYY[ko] MMMM[ren] D[a]',
2086 LLL : 'YYYY[ko] MMMM[ren] D[a] HH:mm',
2087 LLLL : 'dddd, YYYY[ko] MMMM[ren] D[a] HH:mm',
2088 l : 'YYYY-M-D',
2089 ll : 'YYYY[ko] MMM D[a]',
2090 lll : 'YYYY[ko] MMM D[a] HH:mm',
2091 llll : 'ddd, YYYY[ko] MMM D[a] HH:mm'
2092 },
2093 calendar : {
2094 sameDay : '[gaur] LT[etan]',
2095 nextDay : '[bihar] LT[etan]',
2096 nextWeek : 'dddd LT[etan]',
2097 lastDay : '[atzo] LT[etan]',
2098 lastWeek : '[aurreko] dddd LT[etan]',
2099 sameElse : 'L'
2100 },
2101 relativeTime : {
2102 future : '%s barru',
2103 past : 'duela %s',
2104 s : 'segundo batzuk',
2105 m : 'minutu bat',
2106 mm : '%d minutu',
2107 h : 'ordu bat',
2108 hh : '%d ordu',
2109 d : 'egun bat',
2110 dd : '%d egun',
2111 M : 'hilabete bat',
2112 MM : '%d hilabete',
2113 y : 'urte bat',
2114 yy : '%d urte'
2115 },
2116 ordinalParse: /\d{1,2}\./,
2117 ordinal : '%d.',
2118 week : {
2119 dow : 1, // Monday is the first day of the week.
2120 doy : 7 // The week that contains Jan 1st is the first week of the year.
2121 }
2122 });
2123
2124 //! moment.js locale configuration
2125 //! locale : Persian (fa)
2126 //! author : Ebrahim Byagowi : https://github.com/ebraminio
2127
2128 var fa__symbolMap = {
2129 '1': '۱',
2130 '2': '۲',
2131 '3': '۳',
2132 '4': '۴',
2133 '5': '۵',
2134 '6': '۶',
2135 '7': '۷',
2136 '8': '۸',
2137 '9': '۹',
2138 '0': '۰'
2139 }, fa__numberMap = {
2140 '۱': '1',
2141 '۲': '2',
2142 '۳': '3',
2143 '۴': '4',
2144 '۵': '5',
2145 '۶': '6',
2146 '۷': '7',
2147 '۸': '8',
2148 '۹': '9',
2149 '۰': '0'
2150 };
2151
2152 var fa = moment.defineLocale('fa', {
2153 months : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
2154 monthsShort : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
2155 weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
2156 weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
2157 weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
2158 longDateFormat : {
2159 LT : 'HH:mm',
2160 LTS : 'HH:mm:ss',
2161 L : 'DD/MM/YYYY',
2162 LL : 'D MMMM YYYY',
2163 LLL : 'D MMMM YYYY HH:mm',
2164 LLLL : 'dddd, D MMMM YYYY HH:mm'
2165 },
2166 meridiemParse: /قبل از ظهر|بعد از ظهر/,
2167 isPM: function (input) {
2168 return /بعد از ظهر/.test(input);
2169 },
2170 meridiem : function (hour, minute, isLower) {
2171 if (hour < 12) {
2172 return 'قبل از ظهر';
2173 } else {
2174 return 'بعد از ظهر';
2175 }
2176 },
2177 calendar : {
2178 sameDay : '[امروز ساعت] LT',
2179 nextDay : '[فردا ساعت] LT',
2180 nextWeek : 'dddd [ساعت] LT',
2181 lastDay : '[دیروز ساعت] LT',
2182 lastWeek : 'dddd [پیش] [ساعت] LT',
2183 sameElse : 'L'
2184 },
2185 relativeTime : {
2186 future : 'در %s',
2187 past : '%s پیش',
2188 s : 'چندین ثانیه',
2189 m : 'یک دقیقه',
2190 mm : '%d دقیقه',
2191 h : 'یک ساعت',
2192 hh : '%d ساعت',
2193 d : 'یک روز',
2194 dd : '%d روز',
2195 M : 'یک ماه',
2196 MM : '%d ماه',
2197 y : 'یک سال',
2198 yy : '%d سال'
2199 },
2200 preparse: function (string) {
2201 return string.replace(/[۰-۹]/g, function (match) {
2202 return fa__numberMap[match];
2203 }).replace(/،/g, ',');
2204 },
2205 postformat: function (string) {
2206 return string.replace(/\d/g, function (match) {
2207 return fa__symbolMap[match];
2208 }).replace(/,/g, '،');
2209 },
2210 ordinalParse: /\d{1,2}م/,
2211 ordinal : '%dم',
2212 week : {
2213 dow : 6, // Saturday is the first day of the week.
2214 doy : 12 // The week that contains Jan 1st is the first week of the year.
2215 }
2216 });
2217
2218 //! moment.js locale configuration
2219 //! locale : finnish (fi)
2220 //! author : Tarmo Aidantausta : https://github.com/bleadof
2221
2222 var numbersPast = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' '),
2223 numbersFuture = [
2224 'nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
2225 numbersPast[7], numbersPast[8], numbersPast[9]
2226 ];
2227 function fi__translate(number, withoutSuffix, key, isFuture) {
2228 var result = '';
2229 switch (key) {
2230 case 's':
2231 return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
2232 case 'm':
2233 return isFuture ? 'minuutin' : 'minuutti';
2234 case 'mm':
2235 result = isFuture ? 'minuutin' : 'minuuttia';
2236 break;
2237 case 'h':
2238 return isFuture ? 'tunnin' : 'tunti';
2239 case 'hh':
2240 result = isFuture ? 'tunnin' : 'tuntia';
2241 break;
2242 case 'd':
2243 return isFuture ? 'päivän' : 'päivä';
2244 case 'dd':
2245 result = isFuture ? 'päivän' : 'päivää';
2246 break;
2247 case 'M':
2248 return isFuture ? 'kuukauden' : 'kuukausi';
2249 case 'MM':
2250 result = isFuture ? 'kuukauden' : 'kuukautta';
2251 break;
2252 case 'y':
2253 return isFuture ? 'vuoden' : 'vuosi';
2254 case 'yy':
2255 result = isFuture ? 'vuoden' : 'vuotta';
2256 break;
2257 }
2258 result = verbalNumber(number, isFuture) + ' ' + result;
2259 return result;
2260 }
2261 function verbalNumber(number, isFuture) {
2262 return number < 10 ? (isFuture ? numbersFuture[number] : numbersPast[number]) : number;
2263 }
2264
2265 var fi = moment.defineLocale('fi', {
2266 months : 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'),
2267 monthsShort : 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'),
2268 weekdays : 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'),
2269 weekdaysShort : 'su_ma_ti_ke_to_pe_la'.split('_'),
2270 weekdaysMin : 'su_ma_ti_ke_to_pe_la'.split('_'),
2271 longDateFormat : {
2272 LT : 'HH.mm',
2273 LTS : 'HH.mm.ss',
2274 L : 'DD.MM.YYYY',
2275 LL : 'Do MMMM[ta] YYYY',
2276 LLL : 'Do MMMM[ta] YYYY, [klo] HH.mm',
2277 LLLL : 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm',
2278 l : 'D.M.YYYY',
2279 ll : 'Do MMM YYYY',
2280 lll : 'Do MMM YYYY, [klo] HH.mm',
2281 llll : 'ddd, Do MMM YYYY, [klo] HH.mm'
2282 },
2283 calendar : {
2284 sameDay : '[tänään] [klo] LT',
2285 nextDay : '[huomenna] [klo] LT',
2286 nextWeek : 'dddd [klo] LT',
2287 lastDay : '[eilen] [klo] LT',
2288 lastWeek : '[viime] dddd[na] [klo] LT',
2289 sameElse : 'L'
2290 },
2291 relativeTime : {
2292 future : '%s päästä',
2293 past : '%s sitten',
2294 s : fi__translate,
2295 m : fi__translate,
2296 mm : fi__translate,
2297 h : fi__translate,
2298 hh : fi__translate,
2299 d : fi__translate,
2300 dd : fi__translate,
2301 M : fi__translate,
2302 MM : fi__translate,
2303 y : fi__translate,
2304 yy : fi__translate
2305 },
2306 ordinalParse: /\d{1,2}\./,
2307 ordinal : '%d.',
2308 week : {
2309 dow : 1, // Monday is the first day of the week.
2310 doy : 4 // The week that contains Jan 4th is the first week of the year.
2311 }
2312 });
2313
2314 //! moment.js locale configuration
2315 //! locale : faroese (fo)
2316 //! author : Ragnar Johannesen : https://github.com/ragnar123
2317
2318 var fo = moment.defineLocale('fo', {
2319 months : 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
2320 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
2321 weekdays : 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'),
2322 weekdaysShort : 'sun_mán_týs_mik_hós_frí_ley'.split('_'),
2323 weekdaysMin : 'su_má_tý_mi_hó_fr_le'.split('_'),
2324 longDateFormat : {
2325 LT : 'HH:mm',
2326 LTS : 'HH:mm:ss',
2327 L : 'DD/MM/YYYY',
2328 LL : 'D MMMM YYYY',
2329 LLL : 'D MMMM YYYY HH:mm',
2330 LLLL : 'dddd D. MMMM, YYYY HH:mm'
2331 },
2332 calendar : {
2333 sameDay : '[Í dag kl.] LT',
2334 nextDay : '[Í morgin kl.] LT',
2335 nextWeek : 'dddd [kl.] LT',
2336 lastDay : '[Í gjár kl.] LT',
2337 lastWeek : '[síðstu] dddd [kl] LT',
2338 sameElse : 'L'
2339 },
2340 relativeTime : {
2341 future : 'um %s',
2342 past : '%s síðani',
2343 s : 'fá sekund',
2344 m : 'ein minutt',
2345 mm : '%d minuttir',
2346 h : 'ein tími',
2347 hh : '%d tímar',
2348 d : 'ein dagur',
2349 dd : '%d dagar',
2350 M : 'ein mánaði',
2351 MM : '%d mánaðir',
2352 y : 'eitt ár',
2353 yy : '%d ár'
2354 },
2355 ordinalParse: /\d{1,2}\./,
2356 ordinal : '%d.',
2357 week : {
2358 dow : 1, // Monday is the first day of the week.
2359 doy : 4 // The week that contains Jan 4th is the first week of the year.
2360 }
2361 });
2362
2363 //! moment.js locale configuration
2364 //! locale : canadian french (fr-ca)
2365 //! author : Jonathan Abourbih : https://github.com/jonbca
2366
2367 var fr_ca = moment.defineLocale('fr-ca', {
2368 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
2369 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
2370 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
2371 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
2372 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
2373 longDateFormat : {
2374 LT : 'HH:mm',
2375 LTS : 'HH:mm:ss',
2376 L : 'YYYY-MM-DD',
2377 LL : 'D MMMM YYYY',
2378 LLL : 'D MMMM YYYY HH:mm',
2379 LLLL : 'dddd D MMMM YYYY HH:mm'
2380 },
2381 calendar : {
2382 sameDay: '[Aujourd\'hui à] LT',
2383 nextDay: '[Demain à] LT',
2384 nextWeek: 'dddd [à] LT',
2385 lastDay: '[Hier à] LT',
2386 lastWeek: 'dddd [dernier à] LT',
2387 sameElse: 'L'
2388 },
2389 relativeTime : {
2390 future : 'dans %s',
2391 past : 'il y a %s',
2392 s : 'quelques secondes',
2393 m : 'une minute',
2394 mm : '%d minutes',
2395 h : 'une heure',
2396 hh : '%d heures',
2397 d : 'un jour',
2398 dd : '%d jours',
2399 M : 'un mois',
2400 MM : '%d mois',
2401 y : 'un an',
2402 yy : '%d ans'
2403 },
2404 ordinalParse: /\d{1,2}(er|e)/,
2405 ordinal : function (number) {
2406 return number + (number === 1 ? 'er' : 'e');
2407 }
2408 });
2409
2410 //! moment.js locale configuration
2411 //! locale : french (fr)
2412 //! author : John Fischer : https://github.com/jfroffice
2413
2414 var fr = moment.defineLocale('fr', {
2415 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
2416 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
2417 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
2418 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
2419 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
2420 longDateFormat : {
2421 LT : 'HH:mm',
2422 LTS : 'HH:mm:ss',
2423 L : 'DD/MM/YYYY',
2424 LL : 'D MMMM YYYY',
2425 LLL : 'D MMMM YYYY HH:mm',
2426 LLLL : 'dddd D MMMM YYYY HH:mm'
2427 },
2428 calendar : {
2429 sameDay: '[Aujourd\'hui à] LT',
2430 nextDay: '[Demain à] LT',
2431 nextWeek: 'dddd [à] LT',
2432 lastDay: '[Hier à] LT',
2433 lastWeek: 'dddd [dernier à] LT',
2434 sameElse: 'L'
2435 },
2436 relativeTime : {
2437 future : 'dans %s',
2438 past : 'il y a %s',
2439 s : 'quelques secondes',
2440 m : 'une minute',
2441 mm : '%d minutes',
2442 h : 'une heure',
2443 hh : '%d heures',
2444 d : 'un jour',
2445 dd : '%d jours',
2446 M : 'un mois',
2447 MM : '%d mois',
2448 y : 'un an',
2449 yy : '%d ans'
2450 },
2451 ordinalParse: /\d{1,2}(er|)/,
2452 ordinal : function (number) {
2453 return number + (number === 1 ? 'er' : '');
2454 },
2455 week : {
2456 dow : 1, // Monday is the first day of the week.
2457 doy : 4 // The week that contains Jan 4th is the first week of the year.
2458 }
2459 });
2460
2461 //! moment.js locale configuration
2462 //! locale : frisian (fy)
2463 //! author : Robin van der Vliet : https://github.com/robin0van0der0v
2464
2465 var fy__monthsShortWithDots = 'jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.'.split('_'),
2466 fy__monthsShortWithoutDots = 'jan_feb_mrt_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_');
2467
2468 var fy = moment.defineLocale('fy', {
2469 months : 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'),
2470 monthsShort : function (m, format) {
2471 if (/-MMM-/.test(format)) {
2472 return fy__monthsShortWithoutDots[m.month()];
2473 } else {
2474 return fy__monthsShortWithDots[m.month()];
2475 }
2476 },
2477 weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
2478 weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
2479 weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
2480 longDateFormat : {
2481 LT : 'HH:mm',
2482 LTS : 'HH:mm:ss',
2483 L : 'DD-MM-YYYY',
2484 LL : 'D MMMM YYYY',
2485 LLL : 'D MMMM YYYY HH:mm',
2486 LLLL : 'dddd D MMMM YYYY HH:mm'
2487 },
2488 calendar : {
2489 sameDay: '[hjoed om] LT',
2490 nextDay: '[moarn om] LT',
2491 nextWeek: 'dddd [om] LT',
2492 lastDay: '[juster om] LT',
2493 lastWeek: '[ôfrûne] dddd [om] LT',
2494 sameElse: 'L'
2495 },
2496 relativeTime : {
2497 future : 'oer %s',
2498 past : '%s lyn',
2499 s : 'in pear sekonden',
2500 m : 'ien minút',
2501 mm : '%d minuten',
2502 h : 'ien oere',
2503 hh : '%d oeren',
2504 d : 'ien dei',
2505 dd : '%d dagen',
2506 M : 'ien moanne',
2507 MM : '%d moannen',
2508 y : 'ien jier',
2509 yy : '%d jierren'
2510 },
2511 ordinalParse: /\d{1,2}(ste|de)/,
2512 ordinal : function (number) {
2513 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
2514 },
2515 week : {
2516 dow : 1, // Monday is the first day of the week.
2517 doy : 4 // The week that contains Jan 4th is the first week of the year.
2518 }
2519 });
2520
2521 //! moment.js locale configuration
2522 //! locale : galician (gl)
2523 //! author : Juan G. Hurtado : https://github.com/juanghurtado
2524
2525 var gl = moment.defineLocale('gl', {
2526 months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
2527 monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
2528 weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
2529 weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
2530 weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
2531 longDateFormat : {
2532 LT : 'H:mm',
2533 LTS : 'H:mm:ss',
2534 L : 'DD/MM/YYYY',
2535 LL : 'D MMMM YYYY',
2536 LLL : 'D MMMM YYYY H:mm',
2537 LLLL : 'dddd D MMMM YYYY H:mm'
2538 },
2539 calendar : {
2540 sameDay : function () {
2541 return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
2542 },
2543 nextDay : function () {
2544 return '[mañá ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
2545 },
2546 nextWeek : function () {
2547 return 'dddd [' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
2548 },
2549 lastDay : function () {
2550 return '[onte ' + ((this.hours() !== 1) ? 'á' : 'a') + '] LT';
2551 },
2552 lastWeek : function () {
2553 return '[o] dddd [pasado ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
2554 },
2555 sameElse : 'L'
2556 },
2557 relativeTime : {
2558 future : function (str) {
2559 if (str === 'uns segundos') {
2560 return 'nuns segundos';
2561 }
2562 return 'en ' + str;
2563 },
2564 past : 'hai %s',
2565 s : 'uns segundos',
2566 m : 'un minuto',
2567 mm : '%d minutos',
2568 h : 'unha hora',
2569 hh : '%d horas',
2570 d : 'un día',
2571 dd : '%d días',
2572 M : 'un mes',
2573 MM : '%d meses',
2574 y : 'un ano',
2575 yy : '%d anos'
2576 },
2577 ordinalParse : /\d{1,2}º/,
2578 ordinal : '%dº',
2579 week : {
2580 dow : 1, // Monday is the first day of the week.
2581 doy : 7 // The week that contains Jan 1st is the first week of the year.
2582 }
2583 });
2584
2585 //! moment.js locale configuration
2586 //! locale : Hebrew (he)
2587 //! author : Tomer Cohen : https://github.com/tomer
2588 //! author : Moshe Simantov : https://github.com/DevelopmentIL
2589 //! author : Tal Ater : https://github.com/TalAter
2590
2591 var he = moment.defineLocale('he', {
2592 months : 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'),
2593 monthsShort : 'ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳'.split('_'),
2594 weekdays : 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'),
2595 weekdaysShort : 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'),
2596 weekdaysMin : 'א_ב_ג_ד_ה_ו_ש'.split('_'),
2597 longDateFormat : {
2598 LT : 'HH:mm',
2599 LTS : 'HH:mm:ss',
2600 L : 'DD/MM/YYYY',
2601 LL : 'D [ב]MMMM YYYY',
2602 LLL : 'D [ב]MMMM YYYY HH:mm',
2603 LLLL : 'dddd, D [ב]MMMM YYYY HH:mm',
2604 l : 'D/M/YYYY',
2605 ll : 'D MMM YYYY',
2606 lll : 'D MMM YYYY HH:mm',
2607 llll : 'ddd, D MMM YYYY HH:mm'
2608 },
2609 calendar : {
2610 sameDay : '[היום ב־]LT',
2611 nextDay : '[מחר ב־]LT',
2612 nextWeek : 'dddd [בשעה] LT',
2613 lastDay : '[אתמול ב־]LT',
2614 lastWeek : '[ביום] dddd [האחרון בשעה] LT',
2615 sameElse : 'L'
2616 },
2617 relativeTime : {
2618 future : 'בעוד %s',
2619 past : 'לפני %s',
2620 s : 'מספר שניות',
2621 m : 'דקה',
2622 mm : '%d דקות',
2623 h : 'שעה',
2624 hh : function (number) {
2625 if (number === 2) {
2626 return 'שעתיים';
2627 }
2628 return number + ' שעות';
2629 },
2630 d : 'יום',
2631 dd : function (number) {
2632 if (number === 2) {
2633 return 'יומיים';
2634 }
2635 return number + ' ימים';
2636 },
2637 M : 'חודש',
2638 MM : function (number) {
2639 if (number === 2) {
2640 return 'חודשיים';
2641 }
2642 return number + ' חודשים';
2643 },
2644 y : 'שנה',
2645 yy : function (number) {
2646 if (number === 2) {
2647 return 'שנתיים';
2648 } else if (number % 10 === 0 && number !== 10) {
2649 return number + ' שנה';
2650 }
2651 return number + ' שנים';
2652 }
2653 }
2654 });
2655
2656 //! moment.js locale configuration
2657 //! locale : hindi (hi)
2658 //! author : Mayank Singhal : https://github.com/mayanksinghal
2659
2660 var hi__symbolMap = {
2661 '1': '१',
2662 '2': '२',
2663 '3': '३',
2664 '4': '४',
2665 '5': '५',
2666 '6': '६',
2667 '7': '७',
2668 '8': '८',
2669 '9': '९',
2670 '0': '०'
2671 },
2672 hi__numberMap = {
2673 '१': '1',
2674 '२': '2',
2675 '३': '3',
2676 '४': '4',
2677 '५': '5',
2678 '६': '6',
2679 '७': '7',
2680 '८': '8',
2681 '९': '9',
2682 '०': '0'
2683 };
2684
2685 var hi = moment.defineLocale('hi', {
2686 months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
2687 monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
2688 weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
2689 weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
2690 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
2691 longDateFormat : {
2692 LT : 'A h:mm बजे',
2693 LTS : 'A h:mm:ss बजे',
2694 L : 'DD/MM/YYYY',
2695 LL : 'D MMMM YYYY',
2696 LLL : 'D MMMM YYYY, A h:mm बजे',
2697 LLLL : 'dddd, D MMMM YYYY, A h:mm बजे'
2698 },
2699 calendar : {
2700 sameDay : '[आज] LT',
2701 nextDay : '[कल] LT',
2702 nextWeek : 'dddd, LT',
2703 lastDay : '[कल] LT',
2704 lastWeek : '[पिछले] dddd, LT',
2705 sameElse : 'L'
2706 },
2707 relativeTime : {
2708 future : '%s में',
2709 past : '%s पहले',
2710 s : 'कुछ ही क्षण',
2711 m : 'एक मिनट',
2712 mm : '%d मिनट',
2713 h : 'एक घंटा',
2714 hh : '%d घंटे',
2715 d : 'एक दिन',
2716 dd : '%d दिन',
2717 M : 'एक महीने',
2718 MM : '%d महीने',
2719 y : 'एक वर्ष',
2720 yy : '%d वर्ष'
2721 },
2722 preparse: function (string) {
2723 return string.replace(/[१२३४५६७८९०]/g, function (match) {
2724 return hi__numberMap[match];
2725 });
2726 },
2727 postformat: function (string) {
2728 return string.replace(/\d/g, function (match) {
2729 return hi__symbolMap[match];
2730 });
2731 },
2732 // Hindi notation for meridiems are quite fuzzy in practice. While there exists
2733 // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
2734 meridiemParse: /रात|सुबह|दोपहर|शाम/,
2735 meridiemHour : function (hour, meridiem) {
2736 if (hour === 12) {
2737 hour = 0;
2738 }
2739 if (meridiem === 'रात') {
2740 return hour < 4 ? hour : hour + 12;
2741 } else if (meridiem === 'सुबह') {
2742 return hour;
2743 } else if (meridiem === 'दोपहर') {
2744 return hour >= 10 ? hour : hour + 12;
2745 } else if (meridiem === 'शाम') {
2746 return hour + 12;
2747 }
2748 },
2749 meridiem : function (hour, minute, isLower) {
2750 if (hour < 4) {
2751 return 'रात';
2752 } else if (hour < 10) {
2753 return 'सुबह';
2754 } else if (hour < 17) {
2755 return 'दोपहर';
2756 } else if (hour < 20) {
2757 return 'शाम';
2758 } else {
2759 return 'रात';
2760 }
2761 },
2762 week : {
2763 dow : 0, // Sunday is the first day of the week.
2764 doy : 6 // The week that contains Jan 1st is the first week of the year.
2765 }
2766 });
2767
2768 //! moment.js locale configuration
2769 //! locale : hrvatski (hr)
2770 //! author : Bojan Marković : https://github.com/bmarkovic
2771
2772 function hr__translate(number, withoutSuffix, key) {
2773 var result = number + ' ';
2774 switch (key) {
2775 case 'm':
2776 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
2777 case 'mm':
2778 if (number === 1) {
2779 result += 'minuta';
2780 } else if (number === 2 || number === 3 || number === 4) {
2781 result += 'minute';
2782 } else {
2783 result += 'minuta';
2784 }
2785 return result;
2786 case 'h':
2787 return withoutSuffix ? 'jedan sat' : 'jednog sata';
2788 case 'hh':
2789 if (number === 1) {
2790 result += 'sat';
2791 } else if (number === 2 || number === 3 || number === 4) {
2792 result += 'sata';
2793 } else {
2794 result += 'sati';
2795 }
2796 return result;
2797 case 'dd':
2798 if (number === 1) {
2799 result += 'dan';
2800 } else {
2801 result += 'dana';
2802 }
2803 return result;
2804 case 'MM':
2805 if (number === 1) {
2806 result += 'mjesec';
2807 } else if (number === 2 || number === 3 || number === 4) {
2808 result += 'mjeseca';
2809 } else {
2810 result += 'mjeseci';
2811 }
2812 return result;
2813 case 'yy':
2814 if (number === 1) {
2815 result += 'godina';
2816 } else if (number === 2 || number === 3 || number === 4) {
2817 result += 'godine';
2818 } else {
2819 result += 'godina';
2820 }
2821 return result;
2822 }
2823 }
2824
2825 var hr = moment.defineLocale('hr', {
2826 months : 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
2827 monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
2828 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
2829 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
2830 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
2831 longDateFormat : {
2832 LT : 'H:mm',
2833 LTS : 'H:mm:ss',
2834 L : 'DD. MM. YYYY',
2835 LL : 'D. MMMM YYYY',
2836 LLL : 'D. MMMM YYYY H:mm',
2837 LLLL : 'dddd, D. MMMM YYYY H:mm'
2838 },
2839 calendar : {
2840 sameDay : '[danas u] LT',
2841 nextDay : '[sutra u] LT',
2842 nextWeek : function () {
2843 switch (this.day()) {
2844 case 0:
2845 return '[u] [nedjelju] [u] LT';
2846 case 3:
2847 return '[u] [srijedu] [u] LT';
2848 case 6:
2849 return '[u] [subotu] [u] LT';
2850 case 1:
2851 case 2:
2852 case 4:
2853 case 5:
2854 return '[u] dddd [u] LT';
2855 }
2856 },
2857 lastDay : '[jučer u] LT',
2858 lastWeek : function () {
2859 switch (this.day()) {
2860 case 0:
2861 case 3:
2862 return '[prošlu] dddd [u] LT';
2863 case 6:
2864 return '[prošle] [subote] [u] LT';
2865 case 1:
2866 case 2:
2867 case 4:
2868 case 5:
2869 return '[prošli] dddd [u] LT';
2870 }
2871 },
2872 sameElse : 'L'
2873 },
2874 relativeTime : {
2875 future : 'za %s',
2876 past : 'prije %s',
2877 s : 'par sekundi',
2878 m : hr__translate,
2879 mm : hr__translate,
2880 h : hr__translate,
2881 hh : hr__translate,
2882 d : 'dan',
2883 dd : hr__translate,
2884 M : 'mjesec',
2885 MM : hr__translate,
2886 y : 'godinu',
2887 yy : hr__translate
2888 },
2889 ordinalParse: /\d{1,2}\./,
2890 ordinal : '%d.',
2891 week : {
2892 dow : 1, // Monday is the first day of the week.
2893 doy : 7 // The week that contains Jan 1st is the first week of the year.
2894 }
2895 });
2896
2897 //! moment.js locale configuration
2898 //! locale : hungarian (hu)
2899 //! author : Adam Brunner : https://github.com/adambrunner
2900
2901 var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
2902 function hu__translate(number, withoutSuffix, key, isFuture) {
2903 var num = number,
2904 suffix;
2905 switch (key) {
2906 case 's':
2907 return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
2908 case 'm':
2909 return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
2910 case 'mm':
2911 return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
2912 case 'h':
2913 return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
2914 case 'hh':
2915 return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
2916 case 'd':
2917 return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
2918 case 'dd':
2919 return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
2920 case 'M':
2921 return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
2922 case 'MM':
2923 return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
2924 case 'y':
2925 return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
2926 case 'yy':
2927 return num + (isFuture || withoutSuffix ? ' év' : ' éve');
2928 }
2929 return '';
2930 }
2931 function week(isFuture) {
2932 return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[this.day()] + '] LT[-kor]';
2933 }
2934
2935 var hu = moment.defineLocale('hu', {
2936 months : 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
2937 monthsShort : 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
2938 weekdays : 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'),
2939 weekdaysShort : 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'),
2940 weekdaysMin : 'v_h_k_sze_cs_p_szo'.split('_'),
2941 longDateFormat : {
2942 LT : 'H:mm',
2943 LTS : 'H:mm:ss',
2944 L : 'YYYY.MM.DD.',
2945 LL : 'YYYY. MMMM D.',
2946 LLL : 'YYYY. MMMM D. H:mm',
2947 LLLL : 'YYYY. MMMM D., dddd H:mm'
2948 },
2949 meridiemParse: /de|du/i,
2950 isPM: function (input) {
2951 return input.charAt(1).toLowerCase() === 'u';
2952 },
2953 meridiem : function (hours, minutes, isLower) {
2954 if (hours < 12) {
2955 return isLower === true ? 'de' : 'DE';
2956 } else {
2957 return isLower === true ? 'du' : 'DU';
2958 }
2959 },
2960 calendar : {
2961 sameDay : '[ma] LT[-kor]',
2962 nextDay : '[holnap] LT[-kor]',
2963 nextWeek : function () {
2964 return week.call(this, true);
2965 },
2966 lastDay : '[tegnap] LT[-kor]',
2967 lastWeek : function () {
2968 return week.call(this, false);
2969 },
2970 sameElse : 'L'
2971 },
2972 relativeTime : {
2973 future : '%s múlva',
2974 past : '%s',
2975 s : hu__translate,
2976 m : hu__translate,
2977 mm : hu__translate,
2978 h : hu__translate,
2979 hh : hu__translate,
2980 d : hu__translate,
2981 dd : hu__translate,
2982 M : hu__translate,
2983 MM : hu__translate,
2984 y : hu__translate,
2985 yy : hu__translate
2986 },
2987 ordinalParse: /\d{1,2}\./,
2988 ordinal : '%d.',
2989 week : {
2990 dow : 1, // Monday is the first day of the week.
2991 doy : 7 // The week that contains Jan 1st is the first week of the year.
2992 }
2993 });
2994
2995 //! moment.js locale configuration
2996 //! locale : Armenian (hy-am)
2997 //! author : Armendarabyan : https://github.com/armendarabyan
2998
2999 function hy_am__monthsCaseReplace(m, format) {
3000 var months = {
3001 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
3002 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
3003 },
3004 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
3005 'accusative' :
3006 'nominative';
3007 return months[nounCase][m.month()];
3008 }
3009 function hy_am__monthsShortCaseReplace(m, format) {
3010 var monthsShort = 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_');
3011 return monthsShort[m.month()];
3012 }
3013 function hy_am__weekdaysCaseReplace(m, format) {
3014 var weekdays = 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_');
3015 return weekdays[m.day()];
3016 }
3017
3018 var hy_am = moment.defineLocale('hy-am', {
3019 months : hy_am__monthsCaseReplace,
3020 monthsShort : hy_am__monthsShortCaseReplace,
3021 weekdays : hy_am__weekdaysCaseReplace,
3022 weekdaysShort : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
3023 weekdaysMin : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
3024 longDateFormat : {
3025 LT : 'HH:mm',
3026 LTS : 'HH:mm:ss',
3027 L : 'DD.MM.YYYY',
3028 LL : 'D MMMM YYYY թ.',
3029 LLL : 'D MMMM YYYY թ., HH:mm',
3030 LLLL : 'dddd, D MMMM YYYY թ., HH:mm'
3031 },
3032 calendar : {
3033 sameDay: '[այսօր] LT',
3034 nextDay: '[վաղը] LT',
3035 lastDay: '[երեկ] LT',
3036 nextWeek: function () {
3037 return 'dddd [օրը ժամը] LT';
3038 },
3039 lastWeek: function () {
3040 return '[անցած] dddd [օրը ժամը] LT';
3041 },
3042 sameElse: 'L'
3043 },
3044 relativeTime : {
3045 future : '%s հետո',
3046 past : '%s առաջ',
3047 s : 'մի քանի վայրկյան',
3048 m : 'րոպե',
3049 mm : '%d րոպե',
3050 h : 'ժամ',
3051 hh : '%d ժամ',
3052 d : 'օր',
3053 dd : '%d օր',
3054 M : 'ամիս',
3055 MM : '%d ամիս',
3056 y : 'տարի',
3057 yy : '%d տարի'
3058 },
3059 meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
3060 isPM: function (input) {
3061 return /^(ցերեկվա|երեկոյան)$/.test(input);
3062 },
3063 meridiem : function (hour) {
3064 if (hour < 4) {
3065 return 'գիշերվա';
3066 } else if (hour < 12) {
3067 return 'առավոտվա';
3068 } else if (hour < 17) {
3069 return 'ցերեկվա';
3070 } else {
3071 return 'երեկոյան';
3072 }
3073 },
3074 ordinalParse: /\d{1,2}|\d{1,2}-(ին|րդ)/,
3075 ordinal: function (number, period) {
3076 switch (period) {
3077 case 'DDD':
3078 case 'w':
3079 case 'W':
3080 case 'DDDo':
3081 if (number === 1) {
3082 return number + '-ին';
3083 }
3084 return number + '-րդ';
3085 default:
3086 return number;
3087 }
3088 },
3089 week : {
3090 dow : 1, // Monday is the first day of the week.
3091 doy : 7 // The week that contains Jan 1st is the first week of the year.
3092 }
3093 });
3094
3095 //! moment.js locale configuration
3096 //! locale : Bahasa Indonesia (id)
3097 //! author : Mohammad Satrio Utomo : https://github.com/tyok
3098 //! reference: http://id.wikisource.org/wiki/Pedoman_Umum_Ejaan_Bahasa_Indonesia_yang_Disempurnakan
3099
3100 var id = moment.defineLocale('id', {
3101 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
3102 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des'.split('_'),
3103 weekdays : 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
3104 weekdaysShort : 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'),
3105 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'),
3106 longDateFormat : {
3107 LT : 'HH.mm',
3108 LTS : 'HH.mm.ss',
3109 L : 'DD/MM/YYYY',
3110 LL : 'D MMMM YYYY',
3111 LLL : 'D MMMM YYYY [pukul] HH.mm',
3112 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
3113 },
3114 meridiemParse: /pagi|siang|sore|malam/,
3115 meridiemHour : function (hour, meridiem) {
3116 if (hour === 12) {
3117 hour = 0;
3118 }
3119 if (meridiem === 'pagi') {
3120 return hour;
3121 } else if (meridiem === 'siang') {
3122 return hour >= 11 ? hour : hour + 12;
3123 } else if (meridiem === 'sore' || meridiem === 'malam') {
3124 return hour + 12;
3125 }
3126 },
3127 meridiem : function (hours, minutes, isLower) {
3128 if (hours < 11) {
3129 return 'pagi';
3130 } else if (hours < 15) {
3131 return 'siang';
3132 } else if (hours < 19) {
3133 return 'sore';
3134 } else {
3135 return 'malam';
3136 }
3137 },
3138 calendar : {
3139 sameDay : '[Hari ini pukul] LT',
3140 nextDay : '[Besok pukul] LT',
3141 nextWeek : 'dddd [pukul] LT',
3142 lastDay : '[Kemarin pukul] LT',
3143 lastWeek : 'dddd [lalu pukul] LT',
3144 sameElse : 'L'
3145 },
3146 relativeTime : {
3147 future : 'dalam %s',
3148 past : '%s yang lalu',
3149 s : 'beberapa detik',
3150 m : 'semenit',
3151 mm : '%d menit',
3152 h : 'sejam',
3153 hh : '%d jam',
3154 d : 'sehari',
3155 dd : '%d hari',
3156 M : 'sebulan',
3157 MM : '%d bulan',
3158 y : 'setahun',
3159 yy : '%d tahun'
3160 },
3161 week : {
3162 dow : 1, // Monday is the first day of the week.
3163 doy : 7 // The week that contains Jan 1st is the first week of the year.
3164 }
3165 });
3166
3167 //! moment.js locale configuration
3168 //! locale : icelandic (is)
3169 //! author : Hinrik Örn Sigurðsson : https://github.com/hinrik
3170
3171 function is__plural(n) {
3172 if (n % 100 === 11) {
3173 return true;
3174 } else if (n % 10 === 1) {
3175 return false;
3176 }
3177 return true;
3178 }
3179 function is__translate(number, withoutSuffix, key, isFuture) {
3180 var result = number + ' ';
3181 switch (key) {
3182 case 's':
3183 return withoutSuffix || isFuture ? 'nokkrar sekúndur' : 'nokkrum sekúndum';
3184 case 'm':
3185 return withoutSuffix ? 'mínúta' : 'mínútu';
3186 case 'mm':
3187 if (is__plural(number)) {
3188 return result + (withoutSuffix || isFuture ? 'mínútur' : 'mínútum');
3189 } else if (withoutSuffix) {
3190 return result + 'mínúta';
3191 }
3192 return result + 'mínútu';
3193 case 'hh':
3194 if (is__plural(number)) {
3195 return result + (withoutSuffix || isFuture ? 'klukkustundir' : 'klukkustundum');
3196 }
3197 return result + 'klukkustund';
3198 case 'd':
3199 if (withoutSuffix) {
3200 return 'dagur';
3201 }
3202 return isFuture ? 'dag' : 'degi';
3203 case 'dd':
3204 if (is__plural(number)) {
3205 if (withoutSuffix) {
3206 return result + 'dagar';
3207 }
3208 return result + (isFuture ? 'daga' : 'dögum');
3209 } else if (withoutSuffix) {
3210 return result + 'dagur';
3211 }
3212 return result + (isFuture ? 'dag' : 'degi');
3213 case 'M':
3214 if (withoutSuffix) {
3215 return 'mánuður';
3216 }
3217 return isFuture ? 'mánuð' : 'mánuði';
3218 case 'MM':
3219 if (is__plural(number)) {
3220 if (withoutSuffix) {
3221 return result + 'mánuðir';
3222 }
3223 return result + (isFuture ? 'mánuði' : 'mánuðum');
3224 } else if (withoutSuffix) {
3225 return result + 'mánuður';
3226 }
3227 return result + (isFuture ? 'mánuð' : 'mánuði');
3228 case 'y':
3229 return withoutSuffix || isFuture ? 'ár' : 'ári';
3230 case 'yy':
3231 if (is__plural(number)) {
3232 return result + (withoutSuffix || isFuture ? 'ár' : 'árum');
3233 }
3234 return result + (withoutSuffix || isFuture ? 'ár' : 'ári');
3235 }
3236 }
3237
3238 var is = moment.defineLocale('is', {
3239 months : 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'),
3240 monthsShort : 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'),
3241 weekdays : 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
3242 weekdaysShort : 'sun_mán_þri_mið_fim_fös_lau'.split('_'),
3243 weekdaysMin : 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'),
3244 longDateFormat : {
3245 LT : 'H:mm',
3246 LTS : 'H:mm:ss',
3247 L : 'DD/MM/YYYY',
3248 LL : 'D. MMMM YYYY',
3249 LLL : 'D. MMMM YYYY [kl.] H:mm',
3250 LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
3251 },
3252 calendar : {
3253 sameDay : '[í dag kl.] LT',
3254 nextDay : '[á morgun kl.] LT',
3255 nextWeek : 'dddd [kl.] LT',
3256 lastDay : '[í gær kl.] LT',
3257 lastWeek : '[síðasta] dddd [kl.] LT',
3258 sameElse : 'L'
3259 },
3260 relativeTime : {
3261 future : 'eftir %s',
3262 past : 'fyrir %s síðan',
3263 s : is__translate,
3264 m : is__translate,
3265 mm : is__translate,
3266 h : 'klukkustund',
3267 hh : is__translate,
3268 d : is__translate,
3269 dd : is__translate,
3270 M : is__translate,
3271 MM : is__translate,
3272 y : is__translate,
3273 yy : is__translate
3274 },
3275 ordinalParse: /\d{1,2}\./,
3276 ordinal : '%d.',
3277 week : {
3278 dow : 1, // Monday is the first day of the week.
3279 doy : 4 // The week that contains Jan 4th is the first week of the year.
3280 }
3281 });
3282
3283 //! moment.js locale configuration
3284 //! locale : italian (it)
3285 //! author : Lorenzo : https://github.com/aliem
3286 //! author: Mattia Larentis: https://github.com/nostalgiaz
3287
3288 var it = moment.defineLocale('it', {
3289 months : 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
3290 monthsShort : 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
3291 weekdays : 'Domenica_Lunedì_Martedì_Mercoledì_Giovedì_Venerdì_Sabato'.split('_'),
3292 weekdaysShort : 'Dom_Lun_Mar_Mer_Gio_Ven_Sab'.split('_'),
3293 weekdaysMin : 'D_L_Ma_Me_G_V_S'.split('_'),
3294 longDateFormat : {
3295 LT : 'HH:mm',
3296 LTS : 'HH:mm:ss',
3297 L : 'DD/MM/YYYY',
3298 LL : 'D MMMM YYYY',
3299 LLL : 'D MMMM YYYY HH:mm',
3300 LLLL : 'dddd, D MMMM YYYY HH:mm'
3301 },
3302 calendar : {
3303 sameDay: '[Oggi alle] LT',
3304 nextDay: '[Domani alle] LT',
3305 nextWeek: 'dddd [alle] LT',
3306 lastDay: '[Ieri alle] LT',
3307 lastWeek: function () {
3308 switch (this.day()) {
3309 case 0:
3310 return '[la scorsa] dddd [alle] LT';
3311 default:
3312 return '[lo scorso] dddd [alle] LT';
3313 }
3314 },
3315 sameElse: 'L'
3316 },
3317 relativeTime : {
3318 future : function (s) {
3319 return ((/^[0-9].+$/).test(s) ? 'tra' : 'in') + ' ' + s;
3320 },
3321 past : '%s fa',
3322 s : 'alcuni secondi',
3323 m : 'un minuto',
3324 mm : '%d minuti',
3325 h : 'un\'ora',
3326 hh : '%d ore',
3327 d : 'un giorno',
3328 dd : '%d giorni',
3329 M : 'un mese',
3330 MM : '%d mesi',
3331 y : 'un anno',
3332 yy : '%d anni'
3333 },
3334 ordinalParse : /\d{1,2}º/,
3335 ordinal: '%dº',
3336 week : {
3337 dow : 1, // Monday is the first day of the week.
3338 doy : 4 // The week that contains Jan 4th is the first week of the year.
3339 }
3340 });
3341
3342 //! moment.js locale configuration
3343 //! locale : japanese (ja)
3344 //! author : LI Long : https://github.com/baryon
3345
3346 var ja = moment.defineLocale('ja', {
3347 months : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
3348 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
3349 weekdays : '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
3350 weekdaysShort : '日_月_火_水_木_金_土'.split('_'),
3351 weekdaysMin : '日_月_火_水_木_金_土'.split('_'),
3352 longDateFormat : {
3353 LT : 'Ah時m分',
3354 LTS : 'Ah時m分s秒',
3355 L : 'YYYY/MM/DD',
3356 LL : 'YYYY年M月D日',
3357 LLL : 'YYYY年M月D日Ah時m分',
3358 LLLL : 'YYYY年M月D日Ah時m分 dddd'
3359 },
3360 meridiemParse: /午前|午後/i,
3361 isPM : function (input) {
3362 return input === '午後';
3363 },
3364 meridiem : function (hour, minute, isLower) {
3365 if (hour < 12) {
3366 return '午前';
3367 } else {
3368 return '午後';
3369 }
3370 },
3371 calendar : {
3372 sameDay : '[今日] LT',
3373 nextDay : '[明日] LT',
3374 nextWeek : '[来週]dddd LT',
3375 lastDay : '[昨日] LT',
3376 lastWeek : '[前週]dddd LT',
3377 sameElse : 'L'
3378 },
3379 relativeTime : {
3380 future : '%s後',
3381 past : '%s前',
3382 s : '数秒',
3383 m : '1分',
3384 mm : '%d分',
3385 h : '1時間',
3386 hh : '%d時間',
3387 d : '1日',
3388 dd : '%d日',
3389 M : '1ヶ月',
3390 MM : '%dヶ月',
3391 y : '1年',
3392 yy : '%d年'
3393 }
3394 });
3395
3396 //! moment.js locale configuration
3397 //! locale : Boso Jowo (jv)
3398 //! author : Rony Lantip : https://github.com/lantip
3399 //! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
3400
3401 var jv = moment.defineLocale('jv', {
3402 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
3403 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
3404 weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
3405 weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
3406 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
3407 longDateFormat : {
3408 LT : 'HH.mm',
3409 LTS : 'HH.mm.ss',
3410 L : 'DD/MM/YYYY',
3411 LL : 'D MMMM YYYY',
3412 LLL : 'D MMMM YYYY [pukul] HH.mm',
3413 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
3414 },
3415 meridiemParse: /enjing|siyang|sonten|ndalu/,
3416 meridiemHour : function (hour, meridiem) {
3417 if (hour === 12) {
3418 hour = 0;
3419 }
3420 if (meridiem === 'enjing') {
3421 return hour;
3422 } else if (meridiem === 'siyang') {
3423 return hour >= 11 ? hour : hour + 12;
3424 } else if (meridiem === 'sonten' || meridiem === 'ndalu') {
3425 return hour + 12;
3426 }
3427 },
3428 meridiem : function (hours, minutes, isLower) {
3429 if (hours < 11) {
3430 return 'enjing';
3431 } else if (hours < 15) {
3432 return 'siyang';
3433 } else if (hours < 19) {
3434 return 'sonten';
3435 } else {
3436 return 'ndalu';
3437 }
3438 },
3439 calendar : {
3440 sameDay : '[Dinten puniko pukul] LT',
3441 nextDay : '[Mbenjang pukul] LT',
3442 nextWeek : 'dddd [pukul] LT',
3443 lastDay : '[Kala wingi pukul] LT',
3444 lastWeek : 'dddd [kepengker pukul] LT',
3445 sameElse : 'L'
3446 },
3447 relativeTime : {
3448 future : 'wonten ing %s',
3449 past : '%s ingkang kepengker',
3450 s : 'sawetawis detik',
3451 m : 'setunggal menit',
3452 mm : '%d menit',
3453 h : 'setunggal jam',
3454 hh : '%d jam',
3455 d : 'sedinten',
3456 dd : '%d dinten',
3457 M : 'sewulan',
3458 MM : '%d wulan',
3459 y : 'setaun',
3460 yy : '%d taun'
3461 },
3462 week : {
3463 dow : 1, // Monday is the first day of the week.
3464 doy : 7 // The week that contains Jan 1st is the first week of the year.
3465 }
3466 });
3467
3468 //! moment.js locale configuration
3469 //! locale : Georgian (ka)
3470 //! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
3471
3472 function ka__monthsCaseReplace(m, format) {
3473 var months = {
3474 'nominative': 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
3475 'accusative': 'იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს'.split('_')
3476 },
3477 nounCase = (/D[oD] *MMMM?/).test(format) ?
3478 'accusative' :
3479 'nominative';
3480 return months[nounCase][m.month()];
3481 }
3482 function ka__weekdaysCaseReplace(m, format) {
3483 var weekdays = {
3484 'nominative': 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'),
3485 'accusative': 'კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს'.split('_')
3486 },
3487 nounCase = (/(წინა|შემდეგ)/).test(format) ?
3488 'accusative' :
3489 'nominative';
3490 return weekdays[nounCase][m.day()];
3491 }
3492
3493 var ka = moment.defineLocale('ka', {
3494 months : ka__monthsCaseReplace,
3495 monthsShort : 'იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ'.split('_'),
3496 weekdays : ka__weekdaysCaseReplace,
3497 weekdaysShort : 'კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ'.split('_'),
3498 weekdaysMin : 'კვ_ორ_სა_ოთ_ხუ_პა_შა'.split('_'),
3499 longDateFormat : {
3500 LT : 'h:mm A',
3501 LTS : 'h:mm:ss A',
3502 L : 'DD/MM/YYYY',
3503 LL : 'D MMMM YYYY',
3504 LLL : 'D MMMM YYYY h:mm A',
3505 LLLL : 'dddd, D MMMM YYYY h:mm A'
3506 },
3507 calendar : {
3508 sameDay : '[დღეს] LT[-ზე]',
3509 nextDay : '[ხვალ] LT[-ზე]',
3510 lastDay : '[გუშინ] LT[-ზე]',
3511 nextWeek : '[შემდეგ] dddd LT[-ზე]',
3512 lastWeek : '[წინა] dddd LT-ზე',
3513 sameElse : 'L'
3514 },
3515 relativeTime : {
3516 future : function (s) {
3517 return (/(წამი|წუთი|საათი|წელი)/).test(s) ?
3518 s.replace(/ი$/, 'ში') :
3519 s + 'ში';
3520 },
3521 past : function (s) {
3522 if ((/(წამი|წუთი|საათი|დღე|თვე)/).test(s)) {
3523 return s.replace(/(ი|ე)$/, 'ის წინ');
3524 }
3525 if ((/წელი/).test(s)) {
3526 return s.replace(/წელი$/, 'წლის წინ');
3527 }
3528 },
3529 s : 'რამდენიმე წამი',
3530 m : 'წუთი',
3531 mm : '%d წუთი',
3532 h : 'საათი',
3533 hh : '%d საათი',
3534 d : 'დღე',
3535 dd : '%d დღე',
3536 M : 'თვე',
3537 MM : '%d თვე',
3538 y : 'წელი',
3539 yy : '%d წელი'
3540 },
3541 ordinalParse: /0|1-ლი|მე-\d{1,2}|\d{1,2}-ე/,
3542 ordinal : function (number) {
3543 if (number === 0) {
3544 return number;
3545 }
3546 if (number === 1) {
3547 return number + '-ლი';
3548 }
3549 if ((number < 20) || (number <= 100 && (number % 20 === 0)) || (number % 100 === 0)) {
3550 return 'მე-' + number;
3551 }
3552 return number + '-ე';
3553 },
3554 week : {
3555 dow : 1,
3556 doy : 7
3557 }
3558 });
3559
3560 //! moment.js locale configuration
3561 //! locale : khmer (km)
3562 //! author : Kruy Vanna : https://github.com/kruyvanna
3563
3564 var km = moment.defineLocale('km', {
3565 months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
3566 monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
3567 weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
3568 weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
3569 weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
3570 longDateFormat: {
3571 LT: 'HH:mm',
3572 LTS : 'HH:mm:ss',
3573 L: 'DD/MM/YYYY',
3574 LL: 'D MMMM YYYY',
3575 LLL: 'D MMMM YYYY HH:mm',
3576 LLLL: 'dddd, D MMMM YYYY HH:mm'
3577 },
3578 calendar: {
3579 sameDay: '[ថ្ងៃនៈ ម៉ោង] LT',
3580 nextDay: '[ស្អែក ម៉ោង] LT',
3581 nextWeek: 'dddd [ម៉ោង] LT',
3582 lastDay: '[ម្សិលមិញ ម៉ោង] LT',
3583 lastWeek: 'dddd [សប្តាហ៍មុន] [ម៉ោង] LT',
3584 sameElse: 'L'
3585 },
3586 relativeTime: {
3587 future: '%sទៀត',
3588 past: '%sមុន',
3589 s: 'ប៉ុន្មានវិនាទី',
3590 m: 'មួយនាទី',
3591 mm: '%d នាទី',
3592 h: 'មួយម៉ោង',
3593 hh: '%d ម៉ោង',
3594 d: 'មួយថ្ងៃ',
3595 dd: '%d ថ្ងៃ',
3596 M: 'មួយខែ',
3597 MM: '%d ខែ',
3598 y: 'មួយឆ្នាំ',
3599 yy: '%d ឆ្នាំ'
3600 },
3601 week: {
3602 dow: 1, // Monday is the first day of the week.
3603 doy: 4 // The week that contains Jan 4th is the first week of the year.
3604 }
3605 });
3606
3607 //! moment.js locale configuration
3608 //! locale : korean (ko)
3609 //!
3610 //! authors
3611 //!
3612 //! - Kyungwook, Park : https://github.com/kyungw00k
3613 //! - Jeeeyul Lee <jeeeyul@gmail.com>
3614
3615 var ko = moment.defineLocale('ko', {
3616 months : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
3617 monthsShort : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
3618 weekdays : '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
3619 weekdaysShort : '일_월_화_수_목_금_토'.split('_'),
3620 weekdaysMin : '일_월_화_수_목_금_토'.split('_'),
3621 longDateFormat : {
3622 LT : 'A h시 m분',
3623 LTS : 'A h시 m분 s초',
3624 L : 'YYYY.MM.DD',
3625 LL : 'YYYY년 MMMM D일',
3626 LLL : 'YYYY년 MMMM D일 A h시 m분',
3627 LLLL : 'YYYY년 MMMM D일 dddd A h시 m분'
3628 },
3629 calendar : {
3630 sameDay : '오늘 LT',
3631 nextDay : '내일 LT',
3632 nextWeek : 'dddd LT',
3633 lastDay : '어제 LT',
3634 lastWeek : '지난주 dddd LT',
3635 sameElse : 'L'
3636 },
3637 relativeTime : {
3638 future : '%s 후',
3639 past : '%s 전',
3640 s : '몇초',
3641 ss : '%d초',
3642 m : '일분',
3643 mm : '%d분',
3644 h : '한시간',
3645 hh : '%d시간',
3646 d : '하루',
3647 dd : '%d일',
3648 M : '한달',
3649 MM : '%d달',
3650 y : '일년',
3651 yy : '%d년'
3652 },
3653 ordinalParse : /\d{1,2}일/,
3654 ordinal : '%d일',
3655 meridiemParse : /오전|오후/,
3656 isPM : function (token) {
3657 return token === '오후';
3658 },
3659 meridiem : function (hour, minute, isUpper) {
3660 return hour < 12 ? '오전' : '오후';
3661 }
3662 });
3663
3664 //! moment.js locale configuration
3665 //! locale : Luxembourgish (lb)
3666 //! author : mweimerskirch : https://github.com/mweimerskirch, David Raison : https://github.com/kwisatz
3667
3668 function lb__processRelativeTime(number, withoutSuffix, key, isFuture) {
3669 var format = {
3670 'm': ['eng Minutt', 'enger Minutt'],
3671 'h': ['eng Stonn', 'enger Stonn'],
3672 'd': ['een Dag', 'engem Dag'],
3673 'M': ['ee Mount', 'engem Mount'],
3674 'y': ['ee Joer', 'engem Joer']
3675 };
3676 return withoutSuffix ? format[key][0] : format[key][1];
3677 }
3678 function processFutureTime(string) {
3679 var number = string.substr(0, string.indexOf(' '));
3680 if (eifelerRegelAppliesToNumber(number)) {
3681 return 'a ' + string;
3682 }
3683 return 'an ' + string;
3684 }
3685 function processPastTime(string) {
3686 var number = string.substr(0, string.indexOf(' '));
3687 if (eifelerRegelAppliesToNumber(number)) {
3688 return 'viru ' + string;
3689 }
3690 return 'virun ' + string;
3691 }
3692 /**
3693 * Returns true if the word before the given number loses the '-n' ending.
3694 * e.g. 'an 10 Deeg' but 'a 5 Deeg'
3695 *
3696 * @param number {integer}
3697 * @returns {boolean}
3698 */
3699 function eifelerRegelAppliesToNumber(number) {
3700 number = parseInt(number, 10);
3701 if (isNaN(number)) {
3702 return false;
3703 }
3704 if (number < 0) {
3705 // Negative Number --> always true
3706 return true;
3707 } else if (number < 10) {
3708 // Only 1 digit
3709 if (4 <= number && number <= 7) {
3710 return true;
3711 }
3712 return false;
3713 } else if (number < 100) {
3714 // 2 digits
3715 var lastDigit = number % 10, firstDigit = number / 10;
3716 if (lastDigit === 0) {
3717 return eifelerRegelAppliesToNumber(firstDigit);
3718 }
3719 return eifelerRegelAppliesToNumber(lastDigit);
3720 } else if (number < 10000) {
3721 // 3 or 4 digits --> recursively check first digit
3722 while (number >= 10) {
3723 number = number / 10;
3724 }
3725 return eifelerRegelAppliesToNumber(number);
3726 } else {
3727 // Anything larger than 4 digits: recursively check first n-3 digits
3728 number = number / 1000;
3729 return eifelerRegelAppliesToNumber(number);
3730 }
3731 }
3732
3733 var lb = moment.defineLocale('lb', {
3734 months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
3735 monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
3736 weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
3737 weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
3738 weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
3739 longDateFormat: {
3740 LT: 'H:mm [Auer]',
3741 LTS: 'H:mm:ss [Auer]',
3742 L: 'DD.MM.YYYY',
3743 LL: 'D. MMMM YYYY',
3744 LLL: 'D. MMMM YYYY H:mm [Auer]',
3745 LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]'
3746 },
3747 calendar: {
3748 sameDay: '[Haut um] LT',
3749 sameElse: 'L',
3750 nextDay: '[Muer um] LT',
3751 nextWeek: 'dddd [um] LT',
3752 lastDay: '[Gëschter um] LT',
3753 lastWeek: function () {
3754 // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
3755 switch (this.day()) {
3756 case 2:
3757 case 4:
3758 return '[Leschten] dddd [um] LT';
3759 default:
3760 return '[Leschte] dddd [um] LT';
3761 }
3762 }
3763 },
3764 relativeTime : {
3765 future : processFutureTime,
3766 past : processPastTime,
3767 s : 'e puer Sekonnen',
3768 m : lb__processRelativeTime,
3769 mm : '%d Minutten',
3770 h : lb__processRelativeTime,
3771 hh : '%d Stonnen',
3772 d : lb__processRelativeTime,
3773 dd : '%d Deeg',
3774 M : lb__processRelativeTime,
3775 MM : '%d Méint',
3776 y : lb__processRelativeTime,
3777 yy : '%d Joer'
3778 },
3779 ordinalParse: /\d{1,2}\./,
3780 ordinal: '%d.',
3781 week: {
3782 dow: 1, // Monday is the first day of the week.
3783 doy: 4 // The week that contains Jan 4th is the first week of the year.
3784 }
3785 });
3786
3787 //! moment.js locale configuration
3788 //! locale : Lithuanian (lt)
3789 //! author : Mindaugas Mozūras : https://github.com/mmozuras
3790
3791 var lt__units = {
3792 'm' : 'minutė_minutės_minutę',
3793 'mm': 'minutės_minučių_minutes',
3794 'h' : 'valanda_valandos_valandą',
3795 'hh': 'valandos_valandų_valandas',
3796 'd' : 'diena_dienos_dieną',
3797 'dd': 'dienos_dienų_dienas',
3798 'M' : 'mėnuo_mėnesio_mėnesį',
3799 'MM': 'mėnesiai_mėnesių_mėnesius',
3800 'y' : 'metai_metų_metus',
3801 'yy': 'metai_metų_metus'
3802 },
3803 weekDays = 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_');
3804 function translateSeconds(number, withoutSuffix, key, isFuture) {
3805 if (withoutSuffix) {
3806 return 'kelios sekundės';
3807 } else {
3808 return isFuture ? 'kelių sekundžių' : 'kelias sekundes';
3809 }
3810 }
3811 function lt__monthsCaseReplace(m, format) {
3812 var months = {
3813 'nominative': 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
3814 'accusative': 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_')
3815 },
3816 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
3817 'accusative' :
3818 'nominative';
3819 return months[nounCase][m.month()];
3820 }
3821 function translateSingular(number, withoutSuffix, key, isFuture) {
3822 return withoutSuffix ? forms(key)[0] : (isFuture ? forms(key)[1] : forms(key)[2]);
3823 }
3824 function special(number) {
3825 return number % 10 === 0 || (number > 10 && number < 20);
3826 }
3827 function forms(key) {
3828 return lt__units[key].split('_');
3829 }
3830 function lt__translate(number, withoutSuffix, key, isFuture) {
3831 var result = number + ' ';
3832 if (number === 1) {
3833 return result + translateSingular(number, withoutSuffix, key[0], isFuture);
3834 } else if (withoutSuffix) {
3835 return result + (special(number) ? forms(key)[1] : forms(key)[0]);
3836 } else {
3837 if (isFuture) {
3838 return result + forms(key)[1];
3839 } else {
3840 return result + (special(number) ? forms(key)[1] : forms(key)[2]);
3841 }
3842 }
3843 }
3844 function relativeWeekDay(moment, format) {
3845 var nominative = format.indexOf('dddd HH:mm') === -1,
3846 weekDay = weekDays[moment.day()];
3847 return nominative ? weekDay : weekDay.substring(0, weekDay.length - 2) + 'į';
3848 }
3849
3850 var lt = moment.defineLocale('lt', {
3851 months : lt__monthsCaseReplace,
3852 monthsShort : 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'),
3853 weekdays : relativeWeekDay,
3854 weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
3855 weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
3856 longDateFormat : {
3857 LT : 'HH:mm',
3858 LTS : 'HH:mm:ss',
3859 L : 'YYYY-MM-DD',
3860 LL : 'YYYY [m.] MMMM D [d.]',
3861 LLL : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
3862 LLLL : 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]',
3863 l : 'YYYY-MM-DD',
3864 ll : 'YYYY [m.] MMMM D [d.]',
3865 lll : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
3866 llll : 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]'
3867 },
3868 calendar : {
3869 sameDay : '[Šiandien] LT',
3870 nextDay : '[Rytoj] LT',
3871 nextWeek : 'dddd LT',
3872 lastDay : '[Vakar] LT',
3873 lastWeek : '[Praėjusį] dddd LT',
3874 sameElse : 'L'
3875 },
3876 relativeTime : {
3877 future : 'po %s',
3878 past : 'prieš %s',
3879 s : translateSeconds,
3880 m : translateSingular,
3881 mm : lt__translate,
3882 h : translateSingular,
3883 hh : lt__translate,
3884 d : translateSingular,
3885 dd : lt__translate,
3886 M : translateSingular,
3887 MM : lt__translate,
3888 y : translateSingular,
3889 yy : lt__translate
3890 },
3891 ordinalParse: /\d{1,2}-oji/,
3892 ordinal : function (number) {
3893 return number + '-oji';
3894 },
3895 week : {
3896 dow : 1, // Monday is the first day of the week.
3897 doy : 4 // The week that contains Jan 4th is the first week of the year.
3898 }
3899 });
3900
3901 //! moment.js locale configuration
3902 //! locale : latvian (lv)
3903 //! author : Kristaps Karlsons : https://github.com/skakri
3904 //! author : Jānis Elmeris : https://github.com/JanisE
3905
3906 var lv__units = {
3907 'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
3908 'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
3909 'h': 'stundas_stundām_stunda_stundas'.split('_'),
3910 'hh': 'stundas_stundām_stunda_stundas'.split('_'),
3911 'd': 'dienas_dienām_diena_dienas'.split('_'),
3912 'dd': 'dienas_dienām_diena_dienas'.split('_'),
3913 'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
3914 'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
3915 'y': 'gada_gadiem_gads_gadi'.split('_'),
3916 'yy': 'gada_gadiem_gads_gadi'.split('_')
3917 };
3918 /**
3919 * @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
3920 */
3921 function format(forms, number, withoutSuffix) {
3922 if (withoutSuffix) {
3923 // E.g. "21 minūte", "3 minūtes".
3924 return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
3925 } else {
3926 // E.g. "21 minūtes" as in "pēc 21 minūtes".
3927 // E.g. "3 minūtēm" as in "pēc 3 minūtēm".
3928 return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
3929 }
3930 }
3931 function lv__relativeTimeWithPlural(number, withoutSuffix, key) {
3932 return number + ' ' + format(lv__units[key], number, withoutSuffix);
3933 }
3934 function relativeTimeWithSingular(number, withoutSuffix, key) {
3935 return format(lv__units[key], number, withoutSuffix);
3936 }
3937 function relativeSeconds(number, withoutSuffix) {
3938 return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
3939 }
3940
3941 var lv = moment.defineLocale('lv', {
3942 months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
3943 monthsShort : 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'),
3944 weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
3945 weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
3946 weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
3947 longDateFormat : {
3948 LT : 'HH:mm',
3949 LTS : 'HH:mm:ss',
3950 L : 'DD.MM.YYYY.',
3951 LL : 'YYYY. [gada] D. MMMM',
3952 LLL : 'YYYY. [gada] D. MMMM, HH:mm',
3953 LLLL : 'YYYY. [gada] D. MMMM, dddd, HH:mm'
3954 },
3955 calendar : {
3956 sameDay : '[Šodien pulksten] LT',
3957 nextDay : '[Rīt pulksten] LT',
3958 nextWeek : 'dddd [pulksten] LT',
3959 lastDay : '[Vakar pulksten] LT',
3960 lastWeek : '[Pagājušā] dddd [pulksten] LT',
3961 sameElse : 'L'
3962 },
3963 relativeTime : {
3964 future : 'pēc %s',
3965 past : 'pirms %s',
3966 s : relativeSeconds,
3967 m : relativeTimeWithSingular,
3968 mm : lv__relativeTimeWithPlural,
3969 h : relativeTimeWithSingular,
3970 hh : lv__relativeTimeWithPlural,
3971 d : relativeTimeWithSingular,
3972 dd : lv__relativeTimeWithPlural,
3973 M : relativeTimeWithSingular,
3974 MM : lv__relativeTimeWithPlural,
3975 y : relativeTimeWithSingular,
3976 yy : lv__relativeTimeWithPlural
3977 },
3978 ordinalParse: /\d{1,2}\./,
3979 ordinal : '%d.',
3980 week : {
3981 dow : 1, // Monday is the first day of the week.
3982 doy : 4 // The week that contains Jan 4th is the first week of the year.
3983 }
3984 });
3985
3986 //! moment.js locale configuration
3987 //! locale : Montenegrin (me)
3988 //! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
3989
3990 var me__translator = {
3991 words: { //Different grammatical cases
3992 m: ['jedan minut', 'jednog minuta'],
3993 mm: ['minut', 'minuta', 'minuta'],
3994 h: ['jedan sat', 'jednog sata'],
3995 hh: ['sat', 'sata', 'sati'],
3996 dd: ['dan', 'dana', 'dana'],
3997 MM: ['mjesec', 'mjeseca', 'mjeseci'],
3998 yy: ['godina', 'godine', 'godina']
3999 },
4000 correctGrammaticalCase: function (number, wordKey) {
4001 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
4002 },
4003 translate: function (number, withoutSuffix, key) {
4004 var wordKey = me__translator.words[key];
4005 if (key.length === 1) {
4006 return withoutSuffix ? wordKey[0] : wordKey[1];
4007 } else {
4008 return number + ' ' + me__translator.correctGrammaticalCase(number, wordKey);
4009 }
4010 }
4011 };
4012
4013 var me = moment.defineLocale('me', {
4014 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
4015 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
4016 weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
4017 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
4018 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
4019 longDateFormat: {
4020 LT: 'H:mm',
4021 LTS : 'H:mm:ss',
4022 L: 'DD. MM. YYYY',
4023 LL: 'D. MMMM YYYY',
4024 LLL: 'D. MMMM YYYY H:mm',
4025 LLLL: 'dddd, D. MMMM YYYY H:mm'
4026 },
4027 calendar: {
4028 sameDay: '[danas u] LT',
4029 nextDay: '[sjutra u] LT',
4030
4031 nextWeek: function () {
4032 switch (this.day()) {
4033 case 0:
4034 return '[u] [nedjelju] [u] LT';
4035 case 3:
4036 return '[u] [srijedu] [u] LT';
4037 case 6:
4038 return '[u] [subotu] [u] LT';
4039 case 1:
4040 case 2:
4041 case 4:
4042 case 5:
4043 return '[u] dddd [u] LT';
4044 }
4045 },
4046 lastDay : '[juče u] LT',
4047 lastWeek : function () {
4048 var lastWeekDays = [
4049 '[prošle] [nedjelje] [u] LT',
4050 '[prošlog] [ponedjeljka] [u] LT',
4051 '[prošlog] [utorka] [u] LT',
4052 '[prošle] [srijede] [u] LT',
4053 '[prošlog] [četvrtka] [u] LT',
4054 '[prošlog] [petka] [u] LT',
4055 '[prošle] [subote] [u] LT'
4056 ];
4057 return lastWeekDays[this.day()];
4058 },
4059 sameElse : 'L'
4060 },
4061 relativeTime : {
4062 future : 'za %s',
4063 past : 'prije %s',
4064 s : 'nekoliko sekundi',
4065 m : me__translator.translate,
4066 mm : me__translator.translate,
4067 h : me__translator.translate,
4068 hh : me__translator.translate,
4069 d : 'dan',
4070 dd : me__translator.translate,
4071 M : 'mjesec',
4072 MM : me__translator.translate,
4073 y : 'godinu',
4074 yy : me__translator.translate
4075 },
4076 ordinalParse: /\d{1,2}\./,
4077 ordinal : '%d.',
4078 week : {
4079 dow : 1, // Monday is the first day of the week.
4080 doy : 7 // The week that contains Jan 1st is the first week of the year.
4081 }
4082 });
4083
4084 //! moment.js locale configuration
4085 //! locale : macedonian (mk)
4086 //! author : Borislav Mickov : https://github.com/B0k0
4087
4088 var mk = moment.defineLocale('mk', {
4089 months : 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'),
4090 monthsShort : 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'),
4091 weekdays : 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'),
4092 weekdaysShort : 'нед_пон_вто_сре_чет_пет_саб'.split('_'),
4093 weekdaysMin : 'нe_пo_вт_ср_че_пе_сa'.split('_'),
4094 longDateFormat : {
4095 LT : 'H:mm',
4096 LTS : 'H:mm:ss',
4097 L : 'D.MM.YYYY',
4098 LL : 'D MMMM YYYY',
4099 LLL : 'D MMMM YYYY H:mm',
4100 LLLL : 'dddd, D MMMM YYYY H:mm'
4101 },
4102 calendar : {
4103 sameDay : '[Денес во] LT',
4104 nextDay : '[Утре во] LT',
4105 nextWeek : 'dddd [во] LT',
4106 lastDay : '[Вчера во] LT',
4107 lastWeek : function () {
4108 switch (this.day()) {
4109 case 0:
4110 case 3:
4111 case 6:
4112 return '[Во изминатата] dddd [во] LT';
4113 case 1:
4114 case 2:
4115 case 4:
4116 case 5:
4117 return '[Во изминатиот] dddd [во] LT';
4118 }
4119 },
4120 sameElse : 'L'
4121 },
4122 relativeTime : {
4123 future : 'после %s',
4124 past : 'пред %s',
4125 s : 'неколку секунди',
4126 m : 'минута',
4127 mm : '%d минути',
4128 h : 'час',
4129 hh : '%d часа',
4130 d : 'ден',
4131 dd : '%d дена',
4132 M : 'месец',
4133 MM : '%d месеци',
4134 y : 'година',
4135 yy : '%d години'
4136 },
4137 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
4138 ordinal : function (number) {
4139 var lastDigit = number % 10,
4140 last2Digits = number % 100;
4141 if (number === 0) {
4142 return number + '-ев';
4143 } else if (last2Digits === 0) {
4144 return number + '-ен';
4145 } else if (last2Digits > 10 && last2Digits < 20) {
4146 return number + '-ти';
4147 } else if (lastDigit === 1) {
4148 return number + '-ви';
4149 } else if (lastDigit === 2) {
4150 return number + '-ри';
4151 } else if (lastDigit === 7 || lastDigit === 8) {
4152 return number + '-ми';
4153 } else {
4154 return number + '-ти';
4155 }
4156 },
4157 week : {
4158 dow : 1, // Monday is the first day of the week.
4159 doy : 7 // The week that contains Jan 1st is the first week of the year.
4160 }
4161 });
4162
4163 //! moment.js locale configuration
4164 //! locale : malayalam (ml)
4165 //! author : Floyd Pink : https://github.com/floydpink
4166
4167 var ml = moment.defineLocale('ml', {
4168 months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
4169 monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
4170 weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
4171 weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
4172 weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
4173 longDateFormat : {
4174 LT : 'A h:mm -നു',
4175 LTS : 'A h:mm:ss -നു',
4176 L : 'DD/MM/YYYY',
4177 LL : 'D MMMM YYYY',
4178 LLL : 'D MMMM YYYY, A h:mm -നു',
4179 LLLL : 'dddd, D MMMM YYYY, A h:mm -നു'
4180 },
4181 calendar : {
4182 sameDay : '[ഇന്ന്] LT',
4183 nextDay : '[നാളെ] LT',
4184 nextWeek : 'dddd, LT',
4185 lastDay : '[ഇന്നലെ] LT',
4186 lastWeek : '[കഴിഞ്ഞ] dddd, LT',
4187 sameElse : 'L'
4188 },
4189 relativeTime : {
4190 future : '%s കഴിഞ്ഞ്',
4191 past : '%s മുൻപ്',
4192 s : 'അൽപ നിമിഷങ്ങൾ',
4193 m : 'ഒരു മിനിറ്റ്',
4194 mm : '%d മിനിറ്റ്',
4195 h : 'ഒരു മണിക്കൂർ',
4196 hh : '%d മണിക്കൂർ',
4197 d : 'ഒരു ദിവസം',
4198 dd : '%d ദിവസം',
4199 M : 'ഒരു മാസം',
4200 MM : '%d മാസം',
4201 y : 'ഒരു വർഷം',
4202 yy : '%d വർഷം'
4203 },
4204 meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
4205 isPM : function (input) {
4206 return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
4207 },
4208 meridiem : function (hour, minute, isLower) {
4209 if (hour < 4) {
4210 return 'രാത്രി';
4211 } else if (hour < 12) {
4212 return 'രാവിലെ';
4213 } else if (hour < 17) {
4214 return 'ഉച്ച കഴിഞ്ഞ്';
4215 } else if (hour < 20) {
4216 return 'വൈകുന്നേരം';
4217 } else {
4218 return 'രാത്രി';
4219 }
4220 }
4221 });
4222
4223 //! moment.js locale configuration
4224 //! locale : Marathi (mr)
4225 //! author : Harshad Kale : https://github.com/kalehv
4226
4227 var mr__symbolMap = {
4228 '1': '१',
4229 '2': '२',
4230 '3': '३',
4231 '4': '४',
4232 '5': '५',
4233 '6': '६',
4234 '7': '७',
4235 '8': '८',
4236 '9': '९',
4237 '0': '०'
4238 },
4239 mr__numberMap = {
4240 '१': '1',
4241 '२': '2',
4242 '३': '3',
4243 '४': '4',
4244 '५': '5',
4245 '६': '6',
4246 '७': '7',
4247 '८': '8',
4248 '९': '9',
4249 '०': '0'
4250 };
4251
4252 var mr = moment.defineLocale('mr', {
4253 months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
4254 monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
4255 weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
4256 weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
4257 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
4258 longDateFormat : {
4259 LT : 'A h:mm वाजता',
4260 LTS : 'A h:mm:ss वाजता',
4261 L : 'DD/MM/YYYY',
4262 LL : 'D MMMM YYYY',
4263 LLL : 'D MMMM YYYY, A h:mm वाजता',
4264 LLLL : 'dddd, D MMMM YYYY, A h:mm वाजता'
4265 },
4266 calendar : {
4267 sameDay : '[आज] LT',
4268 nextDay : '[उद्या] LT',
4269 nextWeek : 'dddd, LT',
4270 lastDay : '[काल] LT',
4271 lastWeek: '[मागील] dddd, LT',
4272 sameElse : 'L'
4273 },
4274 relativeTime : {
4275 future : '%s नंतर',
4276 past : '%s पूर्वी',
4277 s : 'सेकंद',
4278 m: 'एक मिनिट',
4279 mm: '%d मिनिटे',
4280 h : 'एक तास',
4281 hh : '%d तास',
4282 d : 'एक दिवस',
4283 dd : '%d दिवस',
4284 M : 'एक महिना',
4285 MM : '%d महिने',
4286 y : 'एक वर्ष',
4287 yy : '%d वर्षे'
4288 },
4289 preparse: function (string) {
4290 return string.replace(/[१२३४५६७८९०]/g, function (match) {
4291 return mr__numberMap[match];
4292 });
4293 },
4294 postformat: function (string) {
4295 return string.replace(/\d/g, function (match) {
4296 return mr__symbolMap[match];
4297 });
4298 },
4299 meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी/,
4300 meridiemHour : function (hour, meridiem) {
4301 if (hour === 12) {
4302 hour = 0;
4303 }
4304 if (meridiem === 'रात्री') {
4305 return hour < 4 ? hour : hour + 12;
4306 } else if (meridiem === 'सकाळी') {
4307 return hour;
4308 } else if (meridiem === 'दुपारी') {
4309 return hour >= 10 ? hour : hour + 12;
4310 } else if (meridiem === 'सायंकाळी') {
4311 return hour + 12;
4312 }
4313 },
4314 meridiem: function (hour, minute, isLower) {
4315 if (hour < 4) {
4316 return 'रात्री';
4317 } else if (hour < 10) {
4318 return 'सकाळी';
4319 } else if (hour < 17) {
4320 return 'दुपारी';
4321 } else if (hour < 20) {
4322 return 'सायंकाळी';
4323 } else {
4324 return 'रात्री';
4325 }
4326 },
4327 week : {
4328 dow : 0, // Sunday is the first day of the week.
4329 doy : 6 // The week that contains Jan 1st is the first week of the year.
4330 }
4331 });
4332
4333 //! moment.js locale configuration
4334 //! locale : Bahasa Malaysia (ms-MY)
4335 //! author : Weldan Jamili : https://github.com/weldan
4336
4337 var ms_my = moment.defineLocale('ms-my', {
4338 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
4339 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
4340 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
4341 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
4342 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
4343 longDateFormat : {
4344 LT : 'HH.mm',
4345 LTS : 'HH.mm.ss',
4346 L : 'DD/MM/YYYY',
4347 LL : 'D MMMM YYYY',
4348 LLL : 'D MMMM YYYY [pukul] HH.mm',
4349 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
4350 },
4351 meridiemParse: /pagi|tengahari|petang|malam/,
4352 meridiemHour: function (hour, meridiem) {
4353 if (hour === 12) {
4354 hour = 0;
4355 }
4356 if (meridiem === 'pagi') {
4357 return hour;
4358 } else if (meridiem === 'tengahari') {
4359 return hour >= 11 ? hour : hour + 12;
4360 } else if (meridiem === 'petang' || meridiem === 'malam') {
4361 return hour + 12;
4362 }
4363 },
4364 meridiem : function (hours, minutes, isLower) {
4365 if (hours < 11) {
4366 return 'pagi';
4367 } else if (hours < 15) {
4368 return 'tengahari';
4369 } else if (hours < 19) {
4370 return 'petang';
4371 } else {
4372 return 'malam';
4373 }
4374 },
4375 calendar : {
4376 sameDay : '[Hari ini pukul] LT',
4377 nextDay : '[Esok pukul] LT',
4378 nextWeek : 'dddd [pukul] LT',
4379 lastDay : '[Kelmarin pukul] LT',
4380 lastWeek : 'dddd [lepas pukul] LT',
4381 sameElse : 'L'
4382 },
4383 relativeTime : {
4384 future : 'dalam %s',
4385 past : '%s yang lepas',
4386 s : 'beberapa saat',
4387 m : 'seminit',
4388 mm : '%d minit',
4389 h : 'sejam',
4390 hh : '%d jam',
4391 d : 'sehari',
4392 dd : '%d hari',
4393 M : 'sebulan',
4394 MM : '%d bulan',
4395 y : 'setahun',
4396 yy : '%d tahun'
4397 },
4398 week : {
4399 dow : 1, // Monday is the first day of the week.
4400 doy : 7 // The week that contains Jan 1st is the first week of the year.
4401 }
4402 });
4403
4404 //! moment.js locale configuration
4405 //! locale : Bahasa Malaysia (ms-MY)
4406 //! author : Weldan Jamili : https://github.com/weldan
4407
4408 var ms = moment.defineLocale('ms', {
4409 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
4410 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
4411 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
4412 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
4413 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
4414 longDateFormat : {
4415 LT : 'HH.mm',
4416 LTS : 'HH.mm.ss',
4417 L : 'DD/MM/YYYY',
4418 LL : 'D MMMM YYYY',
4419 LLL : 'D MMMM YYYY [pukul] HH.mm',
4420 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
4421 },
4422 meridiemParse: /pagi|tengahari|petang|malam/,
4423 meridiemHour: function (hour, meridiem) {
4424 if (hour === 12) {
4425 hour = 0;
4426 }
4427 if (meridiem === 'pagi') {
4428 return hour;
4429 } else if (meridiem === 'tengahari') {
4430 return hour >= 11 ? hour : hour + 12;
4431 } else if (meridiem === 'petang' || meridiem === 'malam') {
4432 return hour + 12;
4433 }
4434 },
4435 meridiem : function (hours, minutes, isLower) {
4436 if (hours < 11) {
4437 return 'pagi';
4438 } else if (hours < 15) {
4439 return 'tengahari';
4440 } else if (hours < 19) {
4441 return 'petang';
4442 } else {
4443 return 'malam';
4444 }
4445 },
4446 calendar : {
4447 sameDay : '[Hari ini pukul] LT',
4448 nextDay : '[Esok pukul] LT',
4449 nextWeek : 'dddd [pukul] LT',
4450 lastDay : '[Kelmarin pukul] LT',
4451 lastWeek : 'dddd [lepas pukul] LT',
4452 sameElse : 'L'
4453 },
4454 relativeTime : {
4455 future : 'dalam %s',
4456 past : '%s yang lepas',
4457 s : 'beberapa saat',
4458 m : 'seminit',
4459 mm : '%d minit',
4460 h : 'sejam',
4461 hh : '%d jam',
4462 d : 'sehari',
4463 dd : '%d hari',
4464 M : 'sebulan',
4465 MM : '%d bulan',
4466 y : 'setahun',
4467 yy : '%d tahun'
4468 },
4469 week : {
4470 dow : 1, // Monday is the first day of the week.
4471 doy : 7 // The week that contains Jan 1st is the first week of the year.
4472 }
4473 });
4474
4475 //! moment.js locale configuration
4476 //! locale : Burmese (my)
4477 //! author : Squar team, mysquar.com
4478
4479 var my__symbolMap = {
4480 '1': '၁',
4481 '2': '၂',
4482 '3': '၃',
4483 '4': '၄',
4484 '5': '၅',
4485 '6': '၆',
4486 '7': '၇',
4487 '8': '၈',
4488 '9': '၉',
4489 '0': '၀'
4490 }, my__numberMap = {
4491 '၁': '1',
4492 '၂': '2',
4493 '၃': '3',
4494 '၄': '4',
4495 '၅': '5',
4496 '၆': '6',
4497 '၇': '7',
4498 '၈': '8',
4499 '၉': '9',
4500 '၀': '0'
4501 };
4502
4503 var my = moment.defineLocale('my', {
4504 months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
4505 monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
4506 weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
4507 weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
4508 weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
4509
4510 longDateFormat: {
4511 LT: 'HH:mm',
4512 LTS: 'HH:mm:ss',
4513 L: 'DD/MM/YYYY',
4514 LL: 'D MMMM YYYY',
4515 LLL: 'D MMMM YYYY HH:mm',
4516 LLLL: 'dddd D MMMM YYYY HH:mm'
4517 },
4518 calendar: {
4519 sameDay: '[ယနေ.] LT [မှာ]',
4520 nextDay: '[မနက်ဖြန်] LT [မှာ]',
4521 nextWeek: 'dddd LT [မှာ]',
4522 lastDay: '[မနေ.က] LT [မှာ]',
4523 lastWeek: '[ပြီးခဲ့သော] dddd LT [မှာ]',
4524 sameElse: 'L'
4525 },
4526 relativeTime: {
4527 future: 'လာမည့် %s မှာ',
4528 past: 'လွန်ခဲ့သော %s က',
4529 s: 'စက္ကန်.အနည်းငယ်',
4530 m: 'တစ်မိနစ်',
4531 mm: '%d မိနစ်',
4532 h: 'တစ်နာရီ',
4533 hh: '%d နာရီ',
4534 d: 'တစ်ရက်',
4535 dd: '%d ရက်',
4536 M: 'တစ်လ',
4537 MM: '%d လ',
4538 y: 'တစ်နှစ်',
4539 yy: '%d နှစ်'
4540 },
4541 preparse: function (string) {
4542 return string.replace(/[၁၂၃၄၅၆၇၈၉၀]/g, function (match) {
4543 return my__numberMap[match];
4544 });
4545 },
4546 postformat: function (string) {
4547 return string.replace(/\d/g, function (match) {
4548 return my__symbolMap[match];
4549 });
4550 },
4551 week: {
4552 dow: 1, // Monday is the first day of the week.
4553 doy: 4 // The week that contains Jan 1st is the first week of the year.
4554 }
4555 });
4556
4557 //! moment.js locale configuration
4558 //! locale : norwegian bokmål (nb)
4559 //! authors : Espen Hovlandsdal : https://github.com/rexxars
4560 //! Sigurd Gartmann : https://github.com/sigurdga
4561
4562 var nb = moment.defineLocale('nb', {
4563 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
4564 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
4565 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
4566 weekdaysShort : 'søn_man_tirs_ons_tors_fre_lør'.split('_'),
4567 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
4568 longDateFormat : {
4569 LT : 'H.mm',
4570 LTS : 'H.mm.ss',
4571 L : 'DD.MM.YYYY',
4572 LL : 'D. MMMM YYYY',
4573 LLL : 'D. MMMM YYYY [kl.] H.mm',
4574 LLLL : 'dddd D. MMMM YYYY [kl.] H.mm'
4575 },
4576 calendar : {
4577 sameDay: '[i dag kl.] LT',
4578 nextDay: '[i morgen kl.] LT',
4579 nextWeek: 'dddd [kl.] LT',
4580 lastDay: '[i går kl.] LT',
4581 lastWeek: '[forrige] dddd [kl.] LT',
4582 sameElse: 'L'
4583 },
4584 relativeTime : {
4585 future : 'om %s',
4586 past : 'for %s siden',
4587 s : 'noen sekunder',
4588 m : 'ett minutt',
4589 mm : '%d minutter',
4590 h : 'en time',
4591 hh : '%d timer',
4592 d : 'en dag',
4593 dd : '%d dager',
4594 M : 'en måned',
4595 MM : '%d måneder',
4596 y : 'ett år',
4597 yy : '%d år'
4598 },
4599 ordinalParse: /\d{1,2}\./,
4600 ordinal : '%d.',
4601 week : {
4602 dow : 1, // Monday is the first day of the week.
4603 doy : 4 // The week that contains Jan 4th is the first week of the year.
4604 }
4605 });
4606
4607 //! moment.js locale configuration
4608 //! locale : nepali/nepalese
4609 //! author : suvash : https://github.com/suvash
4610
4611 var ne__symbolMap = {
4612 '1': '१',
4613 '2': '२',
4614 '3': '३',
4615 '4': '४',
4616 '5': '५',
4617 '6': '६',
4618 '7': '७',
4619 '8': '८',
4620 '9': '९',
4621 '0': '०'
4622 },
4623 ne__numberMap = {
4624 '१': '1',
4625 '२': '2',
4626 '३': '3',
4627 '४': '4',
4628 '५': '5',
4629 '६': '6',
4630 '७': '7',
4631 '८': '8',
4632 '९': '9',
4633 '०': '0'
4634 };
4635
4636 var ne = moment.defineLocale('ne', {
4637 months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
4638 monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
4639 weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
4640 weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
4641 weekdaysMin : 'आइ._सो._मङ्_बु._बि._शु._श.'.split('_'),
4642 longDateFormat : {
4643 LT : 'Aको h:mm बजे',
4644 LTS : 'Aको h:mm:ss बजे',
4645 L : 'DD/MM/YYYY',
4646 LL : 'D MMMM YYYY',
4647 LLL : 'D MMMM YYYY, Aको h:mm बजे',
4648 LLLL : 'dddd, D MMMM YYYY, Aको h:mm बजे'
4649 },
4650 preparse: function (string) {
4651 return string.replace(/[१२३४५६७८९०]/g, function (match) {
4652 return ne__numberMap[match];
4653 });
4654 },
4655 postformat: function (string) {
4656 return string.replace(/\d/g, function (match) {
4657 return ne__symbolMap[match];
4658 });
4659 },
4660 meridiemParse: /राती|बिहान|दिउँसो|बेलुका|साँझ|राती/,
4661 meridiemHour : function (hour, meridiem) {
4662 if (hour === 12) {
4663 hour = 0;
4664 }
4665 if (meridiem === 'राती') {
4666 return hour < 3 ? hour : hour + 12;
4667 } else if (meridiem === 'बिहान') {
4668 return hour;
4669 } else if (meridiem === 'दिउँसो') {
4670 return hour >= 10 ? hour : hour + 12;
4671 } else if (meridiem === 'बेलुका' || meridiem === 'साँझ') {
4672 return hour + 12;
4673 }
4674 },
4675 meridiem : function (hour, minute, isLower) {
4676 if (hour < 3) {
4677 return 'राती';
4678 } else if (hour < 10) {
4679 return 'बिहान';
4680 } else if (hour < 15) {
4681 return 'दिउँसो';
4682 } else if (hour < 18) {
4683 return 'बेलुका';
4684 } else if (hour < 20) {
4685 return 'साँझ';
4686 } else {
4687 return 'राती';
4688 }
4689 },
4690 calendar : {
4691 sameDay : '[आज] LT',
4692 nextDay : '[भोली] LT',
4693 nextWeek : '[आउँदो] dddd[,] LT',
4694 lastDay : '[हिजो] LT',
4695 lastWeek : '[गएको] dddd[,] LT',
4696 sameElse : 'L'
4697 },
4698 relativeTime : {
4699 future : '%sमा',
4700 past : '%s अगाडी',
4701 s : 'केही समय',
4702 m : 'एक मिनेट',
4703 mm : '%d मिनेट',
4704 h : 'एक घण्टा',
4705 hh : '%d घण्टा',
4706 d : 'एक दिन',
4707 dd : '%d दिन',
4708 M : 'एक महिना',
4709 MM : '%d महिना',
4710 y : 'एक बर्ष',
4711 yy : '%d बर्ष'
4712 },
4713 week : {
4714 dow : 1, // Monday is the first day of the week.
4715 doy : 7 // The week that contains Jan 1st is the first week of the year.
4716 }
4717 });
4718
4719 //! moment.js locale configuration
4720 //! locale : dutch (nl)
4721 //! author : Joris Röling : https://github.com/jjupiter
4722
4723 var nl__monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'),
4724 nl__monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
4725
4726 var nl = moment.defineLocale('nl', {
4727 months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
4728 monthsShort : function (m, format) {
4729 if (/-MMM-/.test(format)) {
4730 return nl__monthsShortWithoutDots[m.month()];
4731 } else {
4732 return nl__monthsShortWithDots[m.month()];
4733 }
4734 },
4735 weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
4736 weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
4737 weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
4738 longDateFormat : {
4739 LT : 'HH:mm',
4740 LTS : 'HH:mm:ss',
4741 L : 'DD-MM-YYYY',
4742 LL : 'D MMMM YYYY',
4743 LLL : 'D MMMM YYYY HH:mm',
4744 LLLL : 'dddd D MMMM YYYY HH:mm'
4745 },
4746 calendar : {
4747 sameDay: '[vandaag om] LT',
4748 nextDay: '[morgen om] LT',
4749 nextWeek: 'dddd [om] LT',
4750 lastDay: '[gisteren om] LT',
4751 lastWeek: '[afgelopen] dddd [om] LT',
4752 sameElse: 'L'
4753 },
4754 relativeTime : {
4755 future : 'over %s',
4756 past : '%s geleden',
4757 s : 'een paar seconden',
4758 m : 'één minuut',
4759 mm : '%d minuten',
4760 h : 'één uur',
4761 hh : '%d uur',
4762 d : 'één dag',
4763 dd : '%d dagen',
4764 M : 'één maand',
4765 MM : '%d maanden',
4766 y : 'één jaar',
4767 yy : '%d jaar'
4768 },
4769 ordinalParse: /\d{1,2}(ste|de)/,
4770 ordinal : function (number) {
4771 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
4772 },
4773 week : {
4774 dow : 1, // Monday is the first day of the week.
4775 doy : 4 // The week that contains Jan 4th is the first week of the year.
4776 }
4777 });
4778
4779 //! moment.js locale configuration
4780 //! locale : norwegian nynorsk (nn)
4781 //! author : https://github.com/mechuwind
4782
4783 var nn = moment.defineLocale('nn', {
4784 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
4785 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
4786 weekdays : 'sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag'.split('_'),
4787 weekdaysShort : 'sun_mån_tys_ons_tor_fre_lau'.split('_'),
4788 weekdaysMin : 'su_må_ty_on_to_fr_lø'.split('_'),
4789 longDateFormat : {
4790 LT : 'HH:mm',
4791 LTS : 'HH:mm:ss',
4792 L : 'DD.MM.YYYY',
4793 LL : 'D MMMM YYYY',
4794 LLL : 'D MMMM YYYY HH:mm',
4795 LLLL : 'dddd D MMMM YYYY HH:mm'
4796 },
4797 calendar : {
4798 sameDay: '[I dag klokka] LT',
4799 nextDay: '[I morgon klokka] LT',
4800 nextWeek: 'dddd [klokka] LT',
4801 lastDay: '[I går klokka] LT',
4802 lastWeek: '[Føregåande] dddd [klokka] LT',
4803 sameElse: 'L'
4804 },
4805 relativeTime : {
4806 future : 'om %s',
4807 past : 'for %s sidan',
4808 s : 'nokre sekund',
4809 m : 'eit minutt',
4810 mm : '%d minutt',
4811 h : 'ein time',
4812 hh : '%d timar',
4813 d : 'ein dag',
4814 dd : '%d dagar',
4815 M : 'ein månad',
4816 MM : '%d månader',
4817 y : 'eit år',
4818 yy : '%d år'
4819 },
4820 ordinalParse: /\d{1,2}\./,
4821 ordinal : '%d.',
4822 week : {
4823 dow : 1, // Monday is the first day of the week.
4824 doy : 4 // The week that contains Jan 4th is the first week of the year.
4825 }
4826 });
4827
4828 //! moment.js locale configuration
4829 //! locale : polish (pl)
4830 //! author : Rafal Hirsz : https://github.com/evoL
4831
4832 var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_'),
4833 monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
4834 function pl__plural(n) {
4835 return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1);
4836 }
4837 function pl__translate(number, withoutSuffix, key) {
4838 var result = number + ' ';
4839 switch (key) {
4840 case 'm':
4841 return withoutSuffix ? 'minuta' : 'minutę';
4842 case 'mm':
4843 return result + (pl__plural(number) ? 'minuty' : 'minut');
4844 case 'h':
4845 return withoutSuffix ? 'godzina' : 'godzinę';
4846 case 'hh':
4847 return result + (pl__plural(number) ? 'godziny' : 'godzin');
4848 case 'MM':
4849 return result + (pl__plural(number) ? 'miesiące' : 'miesięcy');
4850 case 'yy':
4851 return result + (pl__plural(number) ? 'lata' : 'lat');
4852 }
4853 }
4854
4855 var pl = moment.defineLocale('pl', {
4856 months : function (momentToFormat, format) {
4857 if (format === '') {
4858 // Hack: if format empty we know this is used to generate
4859 // RegExp by moment. Give then back both valid forms of months
4860 // in RegExp ready format.
4861 return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
4862 } else if (/D MMMM/.test(format)) {
4863 return monthsSubjective[momentToFormat.month()];
4864 } else {
4865 return monthsNominative[momentToFormat.month()];
4866 }
4867 },
4868 monthsShort : 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
4869 weekdays : 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
4870 weekdaysShort : 'nie_pon_wt_śr_czw_pt_sb'.split('_'),
4871 weekdaysMin : 'N_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
4872 longDateFormat : {
4873 LT : 'HH:mm',
4874 LTS : 'HH:mm:ss',
4875 L : 'DD.MM.YYYY',
4876 LL : 'D MMMM YYYY',
4877 LLL : 'D MMMM YYYY HH:mm',
4878 LLLL : 'dddd, D MMMM YYYY HH:mm'
4879 },
4880 calendar : {
4881 sameDay: '[Dziś o] LT',
4882 nextDay: '[Jutro o] LT',
4883 nextWeek: '[W] dddd [o] LT',
4884 lastDay: '[Wczoraj o] LT',
4885 lastWeek: function () {
4886 switch (this.day()) {
4887 case 0:
4888 return '[W zeszłą niedzielę o] LT';
4889 case 3:
4890 return '[W zeszłą środę o] LT';
4891 case 6:
4892 return '[W zeszłą sobotę o] LT';
4893 default:
4894 return '[W zeszły] dddd [o] LT';
4895 }
4896 },
4897 sameElse: 'L'
4898 },
4899 relativeTime : {
4900 future : 'za %s',
4901 past : '%s temu',
4902 s : 'kilka sekund',
4903 m : pl__translate,
4904 mm : pl__translate,
4905 h : pl__translate,
4906 hh : pl__translate,
4907 d : '1 dzień',
4908 dd : '%d dni',
4909 M : 'miesiąc',
4910 MM : pl__translate,
4911 y : 'rok',
4912 yy : pl__translate
4913 },
4914 ordinalParse: /\d{1,2}\./,
4915 ordinal : '%d.',
4916 week : {
4917 dow : 1, // Monday is the first day of the week.
4918 doy : 4 // The week that contains Jan 4th is the first week of the year.
4919 }
4920 });
4921
4922 //! moment.js locale configuration
4923 //! locale : brazilian portuguese (pt-br)
4924 //! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
4925
4926 var pt_br = moment.defineLocale('pt-br', {
4927 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
4928 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
4929 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
4930 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
4931 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
4932 longDateFormat : {
4933 LT : 'HH:mm',
4934 LTS : 'HH:mm:ss',
4935 L : 'DD/MM/YYYY',
4936 LL : 'D [de] MMMM [de] YYYY',
4937 LLL : 'D [de] MMMM [de] YYYY [às] HH:mm',
4938 LLLL : 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'
4939 },
4940 calendar : {
4941 sameDay: '[Hoje às] LT',
4942 nextDay: '[Amanhã às] LT',
4943 nextWeek: 'dddd [às] LT',
4944 lastDay: '[Ontem às] LT',
4945 lastWeek: function () {
4946 return (this.day() === 0 || this.day() === 6) ?
4947 '[Último] dddd [às] LT' : // Saturday + Sunday
4948 '[Última] dddd [às] LT'; // Monday - Friday
4949 },
4950 sameElse: 'L'
4951 },
4952 relativeTime : {
4953 future : 'em %s',
4954 past : '%s atrás',
4955 s : 'poucos segundos',
4956 m : 'um minuto',
4957 mm : '%d minutos',
4958 h : 'uma hora',
4959 hh : '%d horas',
4960 d : 'um dia',
4961 dd : '%d dias',
4962 M : 'um mês',
4963 MM : '%d meses',
4964 y : 'um ano',
4965 yy : '%d anos'
4966 },
4967 ordinalParse: /\d{1,2}º/,
4968 ordinal : '%dº'
4969 });
4970
4971 //! moment.js locale configuration
4972 //! locale : portuguese (pt)
4973 //! author : Jefferson : https://github.com/jalex79
4974
4975 var pt = moment.defineLocale('pt', {
4976 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
4977 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
4978 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
4979 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
4980 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
4981 longDateFormat : {
4982 LT : 'HH:mm',
4983 LTS : 'HH:mm:ss',
4984 L : 'DD/MM/YYYY',
4985 LL : 'D [de] MMMM [de] YYYY',
4986 LLL : 'D [de] MMMM [de] YYYY HH:mm',
4987 LLLL : 'dddd, D [de] MMMM [de] YYYY HH:mm'
4988 },
4989 calendar : {
4990 sameDay: '[Hoje às] LT',
4991 nextDay: '[Amanhã às] LT',
4992 nextWeek: 'dddd [às] LT',
4993 lastDay: '[Ontem às] LT',
4994 lastWeek: function () {
4995 return (this.day() === 0 || this.day() === 6) ?
4996 '[Último] dddd [às] LT' : // Saturday + Sunday
4997 '[Última] dddd [às] LT'; // Monday - Friday
4998 },
4999 sameElse: 'L'
5000 },
5001 relativeTime : {
5002 future : 'em %s',
5003 past : 'há %s',
5004 s : 'segundos',
5005 m : 'um minuto',
5006 mm : '%d minutos',
5007 h : 'uma hora',
5008 hh : '%d horas',
5009 d : 'um dia',
5010 dd : '%d dias',
5011 M : 'um mês',
5012 MM : '%d meses',
5013 y : 'um ano',
5014 yy : '%d anos'
5015 },
5016 ordinalParse: /\d{1,2}º/,
5017 ordinal : '%dº',
5018 week : {
5019 dow : 1, // Monday is the first day of the week.
5020 doy : 4 // The week that contains Jan 4th is the first week of the year.
5021 }
5022 });
5023
5024 //! moment.js locale configuration
5025 //! locale : romanian (ro)
5026 //! author : Vlad Gurdiga : https://github.com/gurdiga
5027 //! author : Valentin Agachi : https://github.com/avaly
5028
5029 function ro__relativeTimeWithPlural(number, withoutSuffix, key) {
5030 var format = {
5031 'mm': 'minute',
5032 'hh': 'ore',
5033 'dd': 'zile',
5034 'MM': 'luni',
5035 'yy': 'ani'
5036 },
5037 separator = ' ';
5038 if (number % 100 >= 20 || (number >= 100 && number % 100 === 0)) {
5039 separator = ' de ';
5040 }
5041 return number + separator + format[key];
5042 }
5043
5044 var ro = moment.defineLocale('ro', {
5045 months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
5046 monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
5047 weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
5048 weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
5049 weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
5050 longDateFormat : {
5051 LT : 'H:mm',
5052 LTS : 'H:mm:ss',
5053 L : 'DD.MM.YYYY',
5054 LL : 'D MMMM YYYY',
5055 LLL : 'D MMMM YYYY H:mm',
5056 LLLL : 'dddd, D MMMM YYYY H:mm'
5057 },
5058 calendar : {
5059 sameDay: '[azi la] LT',
5060 nextDay: '[mâine la] LT',
5061 nextWeek: 'dddd [la] LT',
5062 lastDay: '[ieri la] LT',
5063 lastWeek: '[fosta] dddd [la] LT',
5064 sameElse: 'L'
5065 },
5066 relativeTime : {
5067 future : 'peste %s',
5068 past : '%s în urmă',
5069 s : 'câteva secunde',
5070 m : 'un minut',
5071 mm : ro__relativeTimeWithPlural,
5072 h : 'o oră',
5073 hh : ro__relativeTimeWithPlural,
5074 d : 'o zi',
5075 dd : ro__relativeTimeWithPlural,
5076 M : 'o lună',
5077 MM : ro__relativeTimeWithPlural,
5078 y : 'un an',
5079 yy : ro__relativeTimeWithPlural
5080 },
5081 week : {
5082 dow : 1, // Monday is the first day of the week.
5083 doy : 7 // The week that contains Jan 1st is the first week of the year.
5084 }
5085 });
5086
5087 //! moment.js locale configuration
5088 //! locale : russian (ru)
5089 //! author : Viktorminator : https://github.com/Viktorminator
5090 //! Author : Menelion Elensúle : https://github.com/Oire
5091
5092 function ru__plural(word, num) {
5093 var forms = word.split('_');
5094 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
5095 }
5096 function ru__relativeTimeWithPlural(number, withoutSuffix, key) {
5097 var format = {
5098 'mm': withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
5099 'hh': 'час_часа_часов',
5100 'dd': 'день_дня_дней',
5101 'MM': 'месяц_месяца_месяцев',
5102 'yy': 'год_года_лет'
5103 };
5104 if (key === 'm') {
5105 return withoutSuffix ? 'минута' : 'минуту';
5106 }
5107 else {
5108 return number + ' ' + ru__plural(format[key], +number);
5109 }
5110 }
5111 function ru__monthsCaseReplace(m, format) {
5112 var months = {
5113 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
5114 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
5115 },
5116 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
5117 'accusative' :
5118 'nominative';
5119 return months[nounCase][m.month()];
5120 }
5121 function ru__monthsShortCaseReplace(m, format) {
5122 var monthsShort = {
5123 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
5124 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
5125 },
5126 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
5127 'accusative' :
5128 'nominative';
5129 return monthsShort[nounCase][m.month()];
5130 }
5131 function ru__weekdaysCaseReplace(m, format) {
5132 var weekdays = {
5133 'nominative': 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
5134 'accusative': 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_')
5135 },
5136 nounCase = (/\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/).test(format) ?
5137 'accusative' :
5138 'nominative';
5139 return weekdays[nounCase][m.day()];
5140 }
5141
5142 var ru = moment.defineLocale('ru', {
5143 months : ru__monthsCaseReplace,
5144 monthsShort : ru__monthsShortCaseReplace,
5145 weekdays : ru__weekdaysCaseReplace,
5146 weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
5147 weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
5148 monthsParse : [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i],
5149 longDateFormat : {
5150 LT : 'HH:mm',
5151 LTS : 'HH:mm:ss',
5152 L : 'DD.MM.YYYY',
5153 LL : 'D MMMM YYYY г.',
5154 LLL : 'D MMMM YYYY г., HH:mm',
5155 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
5156 },
5157 calendar : {
5158 sameDay: '[Сегодня в] LT',
5159 nextDay: '[Завтра в] LT',
5160 lastDay: '[Вчера в] LT',
5161 nextWeek: function () {
5162 return this.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
5163 },
5164 lastWeek: function (now) {
5165 if (now.week() !== this.week()) {
5166 switch (this.day()) {
5167 case 0:
5168 return '[В прошлое] dddd [в] LT';
5169 case 1:
5170 case 2:
5171 case 4:
5172 return '[В прошлый] dddd [в] LT';
5173 case 3:
5174 case 5:
5175 case 6:
5176 return '[В прошлую] dddd [в] LT';
5177 }
5178 } else {
5179 if (this.day() === 2) {
5180 return '[Во] dddd [в] LT';
5181 } else {
5182 return '[В] dddd [в] LT';
5183 }
5184 }
5185 },
5186 sameElse: 'L'
5187 },
5188 relativeTime : {
5189 future : 'через %s',
5190 past : '%s назад',
5191 s : 'несколько секунд',
5192 m : ru__relativeTimeWithPlural,
5193 mm : ru__relativeTimeWithPlural,
5194 h : 'час',
5195 hh : ru__relativeTimeWithPlural,
5196 d : 'день',
5197 dd : ru__relativeTimeWithPlural,
5198 M : 'месяц',
5199 MM : ru__relativeTimeWithPlural,
5200 y : 'год',
5201 yy : ru__relativeTimeWithPlural
5202 },
5203 meridiemParse: /ночи|утра|дня|вечера/i,
5204 isPM : function (input) {
5205 return /^(дня|вечера)$/.test(input);
5206 },
5207 meridiem : function (hour, minute, isLower) {
5208 if (hour < 4) {
5209 return 'ночи';
5210 } else if (hour < 12) {
5211 return 'утра';
5212 } else if (hour < 17) {
5213 return 'дня';
5214 } else {
5215 return 'вечера';
5216 }
5217 },
5218 ordinalParse: /\d{1,2}-(й|го|я)/,
5219 ordinal: function (number, period) {
5220 switch (period) {
5221 case 'M':
5222 case 'd':
5223 case 'DDD':
5224 return number + '-й';
5225 case 'D':
5226 return number + '-го';
5227 case 'w':
5228 case 'W':
5229 return number + '-я';
5230 default:
5231 return number;
5232 }
5233 },
5234 week : {
5235 dow : 1, // Monday is the first day of the week.
5236 doy : 7 // The week that contains Jan 1st is the first week of the year.
5237 }
5238 });
5239
5240 //! moment.js locale configuration
5241 //! locale : Sinhalese (si)
5242 //! author : Sampath Sitinamaluwa : https://github.com/sampathsris
5243
5244 var si = moment.defineLocale('si', {
5245 months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්‍රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
5246 monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
5247 weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
5248 weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'),
5249 weekdaysMin : 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'),
5250 longDateFormat : {
5251 LT : 'a h:mm',
5252 LTS : 'a h:mm:ss',
5253 L : 'YYYY/MM/DD',
5254 LL : 'YYYY MMMM D',
5255 LLL : 'YYYY MMMM D, a h:mm',
5256 LLLL : 'YYYY MMMM D [වැනි] dddd, a h:mm:ss'
5257 },
5258 calendar : {
5259 sameDay : '[අද] LT[ට]',
5260 nextDay : '[හෙට] LT[ට]',
5261 nextWeek : 'dddd LT[ට]',
5262 lastDay : '[ඊයේ] LT[ට]',
5263 lastWeek : '[පසුගිය] dddd LT[ට]',
5264 sameElse : 'L'
5265 },
5266 relativeTime : {
5267 future : '%sකින්',
5268 past : '%sකට පෙර',
5269 s : 'තත්පර කිහිපය',
5270 m : 'මිනිත්තුව',
5271 mm : 'මිනිත්තු %d',
5272 h : 'පැය',
5273 hh : 'පැය %d',
5274 d : 'දිනය',
5275 dd : 'දින %d',
5276 M : 'මාසය',
5277 MM : 'මාස %d',
5278 y : 'වසර',
5279 yy : 'වසර %d'
5280 },
5281 ordinalParse: /\d{1,2} වැනි/,
5282 ordinal : function (number) {
5283 return number + ' වැනි';
5284 },
5285 meridiem : function (hours, minutes, isLower) {
5286 if (hours > 11) {
5287 return isLower ? 'ප.ව.' : 'පස් වරු';
5288 } else {
5289 return isLower ? 'පෙ.ව.' : 'පෙර වරු';
5290 }
5291 }
5292 });
5293
5294 //! moment.js locale configuration
5295 //! locale : slovak (sk)
5296 //! author : Martin Minka : https://github.com/k2s
5297 //! based on work of petrbela : https://github.com/petrbela
5298
5299 var sk__months = 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_'),
5300 sk__monthsShort = 'jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec'.split('_');
5301 function sk__plural(n) {
5302 return (n > 1) && (n < 5);
5303 }
5304 function sk__translate(number, withoutSuffix, key, isFuture) {
5305 var result = number + ' ';
5306 switch (key) {
5307 case 's': // a few seconds / in a few seconds / a few seconds ago
5308 return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
5309 case 'm': // a minute / in a minute / a minute ago
5310 return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou');
5311 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
5312 if (withoutSuffix || isFuture) {
5313 return result + (sk__plural(number) ? 'minúty' : 'minút');
5314 } else {
5315 return result + 'minútami';
5316 }
5317 break;
5318 case 'h': // an hour / in an hour / an hour ago
5319 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
5320 case 'hh': // 9 hours / in 9 hours / 9 hours ago
5321 if (withoutSuffix || isFuture) {
5322 return result + (sk__plural(number) ? 'hodiny' : 'hodín');
5323 } else {
5324 return result + 'hodinami';
5325 }
5326 break;
5327 case 'd': // a day / in a day / a day ago
5328 return (withoutSuffix || isFuture) ? 'deň' : 'dňom';
5329 case 'dd': // 9 days / in 9 days / 9 days ago
5330 if (withoutSuffix || isFuture) {
5331 return result + (sk__plural(number) ? 'dni' : 'dní');
5332 } else {
5333 return result + 'dňami';
5334 }
5335 break;
5336 case 'M': // a month / in a month / a month ago
5337 return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom';
5338 case 'MM': // 9 months / in 9 months / 9 months ago
5339 if (withoutSuffix || isFuture) {
5340 return result + (sk__plural(number) ? 'mesiace' : 'mesiacov');
5341 } else {
5342 return result + 'mesiacmi';
5343 }
5344 break;
5345 case 'y': // a year / in a year / a year ago
5346 return (withoutSuffix || isFuture) ? 'rok' : 'rokom';
5347 case 'yy': // 9 years / in 9 years / 9 years ago
5348 if (withoutSuffix || isFuture) {
5349 return result + (sk__plural(number) ? 'roky' : 'rokov');
5350 } else {
5351 return result + 'rokmi';
5352 }
5353 break;
5354 }
5355 }
5356
5357 var sk = moment.defineLocale('sk', {
5358 months : sk__months,
5359 monthsShort : sk__monthsShort,
5360 monthsParse : (function (months, monthsShort) {
5361 var i, _monthsParse = [];
5362 for (i = 0; i < 12; i++) {
5363 // use custom parser to solve problem with July (červenec)
5364 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
5365 }
5366 return _monthsParse;
5367 }(sk__months, sk__monthsShort)),
5368 weekdays : 'nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota'.split('_'),
5369 weekdaysShort : 'ne_po_ut_st_št_pi_so'.split('_'),
5370 weekdaysMin : 'ne_po_ut_st_št_pi_so'.split('_'),
5371 longDateFormat : {
5372 LT: 'H:mm',
5373 LTS : 'H:mm:ss',
5374 L : 'DD.MM.YYYY',
5375 LL : 'D. MMMM YYYY',
5376 LLL : 'D. MMMM YYYY H:mm',
5377 LLLL : 'dddd D. MMMM YYYY H:mm'
5378 },
5379 calendar : {
5380 sameDay: '[dnes o] LT',
5381 nextDay: '[zajtra o] LT',
5382 nextWeek: function () {
5383 switch (this.day()) {
5384 case 0:
5385 return '[v nedeľu o] LT';
5386 case 1:
5387 case 2:
5388 return '[v] dddd [o] LT';
5389 case 3:
5390 return '[v stredu o] LT';
5391 case 4:
5392 return '[vo štvrtok o] LT';
5393 case 5:
5394 return '[v piatok o] LT';
5395 case 6:
5396 return '[v sobotu o] LT';
5397 }
5398 },
5399 lastDay: '[včera o] LT',
5400 lastWeek: function () {
5401 switch (this.day()) {
5402 case 0:
5403 return '[minulú nedeľu o] LT';
5404 case 1:
5405 case 2:
5406 return '[minulý] dddd [o] LT';
5407 case 3:
5408 return '[minulú stredu o] LT';
5409 case 4:
5410 case 5:
5411 return '[minulý] dddd [o] LT';
5412 case 6:
5413 return '[minulú sobotu o] LT';
5414 }
5415 },
5416 sameElse: 'L'
5417 },
5418 relativeTime : {
5419 future : 'za %s',
5420 past : 'pred %s',
5421 s : sk__translate,
5422 m : sk__translate,
5423 mm : sk__translate,
5424 h : sk__translate,
5425 hh : sk__translate,
5426 d : sk__translate,
5427 dd : sk__translate,
5428 M : sk__translate,
5429 MM : sk__translate,
5430 y : sk__translate,
5431 yy : sk__translate
5432 },
5433 ordinalParse: /\d{1,2}\./,
5434 ordinal : '%d.',
5435 week : {
5436 dow : 1, // Monday is the first day of the week.
5437 doy : 4 // The week that contains Jan 4th is the first week of the year.
5438 }
5439 });
5440
5441 //! moment.js locale configuration
5442 //! locale : slovenian (sl)
5443 //! author : Robert Sedovšek : https://github.com/sedovsek
5444
5445 function sl__processRelativeTime(number, withoutSuffix, key, isFuture) {
5446 var result = number + ' ';
5447 switch (key) {
5448 case 's':
5449 return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
5450 case 'm':
5451 return withoutSuffix ? 'ena minuta' : 'eno minuto';
5452 case 'mm':
5453 if (number === 1) {
5454 result += withoutSuffix ? 'minuta' : 'minuto';
5455 } else if (number === 2) {
5456 result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
5457 } else if (number < 5) {
5458 result += withoutSuffix || isFuture ? 'minute' : 'minutami';
5459 } else {
5460 result += withoutSuffix || isFuture ? 'minut' : 'minutami';
5461 }
5462 return result;
5463 case 'h':
5464 return withoutSuffix ? 'ena ura' : 'eno uro';
5465 case 'hh':
5466 if (number === 1) {
5467 result += withoutSuffix ? 'ura' : 'uro';
5468 } else if (number === 2) {
5469 result += withoutSuffix || isFuture ? 'uri' : 'urama';
5470 } else if (number < 5) {
5471 result += withoutSuffix || isFuture ? 'ure' : 'urami';
5472 } else {
5473 result += withoutSuffix || isFuture ? 'ur' : 'urami';
5474 }
5475 return result;
5476 case 'd':
5477 return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
5478 case 'dd':
5479 if (number === 1) {
5480 result += withoutSuffix || isFuture ? 'dan' : 'dnem';
5481 } else if (number === 2) {
5482 result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
5483 } else {
5484 result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
5485 }
5486 return result;
5487 case 'M':
5488 return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
5489 case 'MM':
5490 if (number === 1) {
5491 result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
5492 } else if (number === 2) {
5493 result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
5494 } else if (number < 5) {
5495 result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
5496 } else {
5497 result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
5498 }
5499 return result;
5500 case 'y':
5501 return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
5502 case 'yy':
5503 if (number === 1) {
5504 result += withoutSuffix || isFuture ? 'leto' : 'letom';
5505 } else if (number === 2) {
5506 result += withoutSuffix || isFuture ? 'leti' : 'letoma';
5507 } else if (number < 5) {
5508 result += withoutSuffix || isFuture ? 'leta' : 'leti';
5509 } else {
5510 result += withoutSuffix || isFuture ? 'let' : 'leti';
5511 }
5512 return result;
5513 }
5514 }
5515
5516 var sl = moment.defineLocale('sl', {
5517 months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
5518 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
5519 weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
5520 weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
5521 weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
5522 longDateFormat : {
5523 LT : 'H:mm',
5524 LTS : 'H:mm:ss',
5525 L : 'DD. MM. YYYY',
5526 LL : 'D. MMMM YYYY',
5527 LLL : 'D. MMMM YYYY H:mm',
5528 LLLL : 'dddd, D. MMMM YYYY H:mm'
5529 },
5530 calendar : {
5531 sameDay : '[danes ob] LT',
5532 nextDay : '[jutri ob] LT',
5533
5534 nextWeek : function () {
5535 switch (this.day()) {
5536 case 0:
5537 return '[v] [nedeljo] [ob] LT';
5538 case 3:
5539 return '[v] [sredo] [ob] LT';
5540 case 6:
5541 return '[v] [soboto] [ob] LT';
5542 case 1:
5543 case 2:
5544 case 4:
5545 case 5:
5546 return '[v] dddd [ob] LT';
5547 }
5548 },
5549 lastDay : '[včeraj ob] LT',
5550 lastWeek : function () {
5551 switch (this.day()) {
5552 case 0:
5553 return '[prejšnjo] [nedeljo] [ob] LT';
5554 case 3:
5555 return '[prejšnjo] [sredo] [ob] LT';
5556 case 6:
5557 return '[prejšnjo] [soboto] [ob] LT';
5558 case 1:
5559 case 2:
5560 case 4:
5561 case 5:
5562 return '[prejšnji] dddd [ob] LT';
5563 }
5564 },
5565 sameElse : 'L'
5566 },
5567 relativeTime : {
5568 future : 'čez %s',
5569 past : 'pred %s',
5570 s : sl__processRelativeTime,
5571 m : sl__processRelativeTime,
5572 mm : sl__processRelativeTime,
5573 h : sl__processRelativeTime,
5574 hh : sl__processRelativeTime,
5575 d : sl__processRelativeTime,
5576 dd : sl__processRelativeTime,
5577 M : sl__processRelativeTime,
5578 MM : sl__processRelativeTime,
5579 y : sl__processRelativeTime,
5580 yy : sl__processRelativeTime
5581 },
5582 ordinalParse: /\d{1,2}\./,
5583 ordinal : '%d.',
5584 week : {
5585 dow : 1, // Monday is the first day of the week.
5586 doy : 7 // The week that contains Jan 1st is the first week of the year.
5587 }
5588 });
5589
5590 //! moment.js locale configuration
5591 //! locale : Albanian (sq)
5592 //! author : Flakërim Ismani : https://github.com/flakerimi
5593 //! author: Menelion Elensúle: https://github.com/Oire (tests)
5594 //! author : Oerd Cukalla : https://github.com/oerd (fixes)
5595
5596 var sq = moment.defineLocale('sq', {
5597 months : 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'),
5598 monthsShort : 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'),
5599 weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
5600 weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
5601 weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
5602 meridiemParse: /PD|MD/,
5603 isPM: function (input) {
5604 return input.charAt(0) === 'M';
5605 },
5606 meridiem : function (hours, minutes, isLower) {
5607 return hours < 12 ? 'PD' : 'MD';
5608 },
5609 longDateFormat : {
5610 LT : 'HH:mm',
5611 LTS : 'HH:mm:ss',
5612 L : 'DD/MM/YYYY',
5613 LL : 'D MMMM YYYY',
5614 LLL : 'D MMMM YYYY HH:mm',
5615 LLLL : 'dddd, D MMMM YYYY HH:mm'
5616 },
5617 calendar : {
5618 sameDay : '[Sot në] LT',
5619 nextDay : '[Nesër në] LT',
5620 nextWeek : 'dddd [në] LT',
5621 lastDay : '[Dje në] LT',
5622 lastWeek : 'dddd [e kaluar në] LT',
5623 sameElse : 'L'
5624 },
5625 relativeTime : {
5626 future : 'në %s',
5627 past : '%s më parë',
5628 s : 'disa sekonda',
5629 m : 'një minutë',
5630 mm : '%d minuta',
5631 h : 'një orë',
5632 hh : '%d orë',
5633 d : 'një ditë',
5634 dd : '%d ditë',
5635 M : 'një muaj',
5636 MM : '%d muaj',
5637 y : 'një vit',
5638 yy : '%d vite'
5639 },
5640 ordinalParse: /\d{1,2}\./,
5641 ordinal : '%d.',
5642 week : {
5643 dow : 1, // Monday is the first day of the week.
5644 doy : 4 // The week that contains Jan 4th is the first week of the year.
5645 }
5646 });
5647
5648 //! moment.js locale configuration
5649 //! locale : Serbian-cyrillic (sr-cyrl)
5650 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
5651
5652 var sr_cyrl__translator = {
5653 words: { //Different grammatical cases
5654 m: ['један минут', 'једне минуте'],
5655 mm: ['минут', 'минуте', 'минута'],
5656 h: ['један сат', 'једног сата'],
5657 hh: ['сат', 'сата', 'сати'],
5658 dd: ['дан', 'дана', 'дана'],
5659 MM: ['месец', 'месеца', 'месеци'],
5660 yy: ['година', 'године', 'година']
5661 },
5662 correctGrammaticalCase: function (number, wordKey) {
5663 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
5664 },
5665 translate: function (number, withoutSuffix, key) {
5666 var wordKey = sr_cyrl__translator.words[key];
5667 if (key.length === 1) {
5668 return withoutSuffix ? wordKey[0] : wordKey[1];
5669 } else {
5670 return number + ' ' + sr_cyrl__translator.correctGrammaticalCase(number, wordKey);
5671 }
5672 }
5673 };
5674
5675 var sr_cyrl = moment.defineLocale('sr-cyrl', {
5676 months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
5677 monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
5678 weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
5679 weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
5680 weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
5681 longDateFormat: {
5682 LT: 'H:mm',
5683 LTS : 'H:mm:ss',
5684 L: 'DD. MM. YYYY',
5685 LL: 'D. MMMM YYYY',
5686 LLL: 'D. MMMM YYYY H:mm',
5687 LLLL: 'dddd, D. MMMM YYYY H:mm'
5688 },
5689 calendar: {
5690 sameDay: '[данас у] LT',
5691 nextDay: '[сутра у] LT',
5692 nextWeek: function () {
5693 switch (this.day()) {
5694 case 0:
5695 return '[у] [недељу] [у] LT';
5696 case 3:
5697 return '[у] [среду] [у] LT';
5698 case 6:
5699 return '[у] [суботу] [у] LT';
5700 case 1:
5701 case 2:
5702 case 4:
5703 case 5:
5704 return '[у] dddd [у] LT';
5705 }
5706 },
5707 lastDay : '[јуче у] LT',
5708 lastWeek : function () {
5709 var lastWeekDays = [
5710 '[прошле] [недеље] [у] LT',
5711 '[прошлог] [понедељка] [у] LT',
5712 '[прошлог] [уторка] [у] LT',
5713 '[прошле] [среде] [у] LT',
5714 '[прошлог] [четвртка] [у] LT',
5715 '[прошлог] [петка] [у] LT',
5716 '[прошле] [суботе] [у] LT'
5717 ];
5718 return lastWeekDays[this.day()];
5719 },
5720 sameElse : 'L'
5721 },
5722 relativeTime : {
5723 future : 'за %s',
5724 past : 'пре %s',
5725 s : 'неколико секунди',
5726 m : sr_cyrl__translator.translate,
5727 mm : sr_cyrl__translator.translate,
5728 h : sr_cyrl__translator.translate,
5729 hh : sr_cyrl__translator.translate,
5730 d : 'дан',
5731 dd : sr_cyrl__translator.translate,
5732 M : 'месец',
5733 MM : sr_cyrl__translator.translate,
5734 y : 'годину',
5735 yy : sr_cyrl__translator.translate
5736 },
5737 ordinalParse: /\d{1,2}\./,
5738 ordinal : '%d.',
5739 week : {
5740 dow : 1, // Monday is the first day of the week.
5741 doy : 7 // The week that contains Jan 1st is the first week of the year.
5742 }
5743 });
5744
5745 //! moment.js locale configuration
5746 //! locale : Serbian-latin (sr)
5747 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
5748
5749 var sr__translator = {
5750 words: { //Different grammatical cases
5751 m: ['jedan minut', 'jedne minute'],
5752 mm: ['minut', 'minute', 'minuta'],
5753 h: ['jedan sat', 'jednog sata'],
5754 hh: ['sat', 'sata', 'sati'],
5755 dd: ['dan', 'dana', 'dana'],
5756 MM: ['mesec', 'meseca', 'meseci'],
5757 yy: ['godina', 'godine', 'godina']
5758 },
5759 correctGrammaticalCase: function (number, wordKey) {
5760 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
5761 },
5762 translate: function (number, withoutSuffix, key) {
5763 var wordKey = sr__translator.words[key];
5764 if (key.length === 1) {
5765 return withoutSuffix ? wordKey[0] : wordKey[1];
5766 } else {
5767 return number + ' ' + sr__translator.correctGrammaticalCase(number, wordKey);
5768 }
5769 }
5770 };
5771
5772 var sr = moment.defineLocale('sr', {
5773 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
5774 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
5775 weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
5776 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
5777 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
5778 longDateFormat: {
5779 LT: 'H:mm',
5780 LTS : 'H:mm:ss',
5781 L: 'DD. MM. YYYY',
5782 LL: 'D. MMMM YYYY',
5783 LLL: 'D. MMMM YYYY H:mm',
5784 LLLL: 'dddd, D. MMMM YYYY H:mm'
5785 },
5786 calendar: {
5787 sameDay: '[danas u] LT',
5788 nextDay: '[sutra u] LT',
5789 nextWeek: function () {
5790 switch (this.day()) {
5791 case 0:
5792 return '[u] [nedelju] [u] LT';
5793 case 3:
5794 return '[u] [sredu] [u] LT';
5795 case 6:
5796 return '[u] [subotu] [u] LT';
5797 case 1:
5798 case 2:
5799 case 4:
5800 case 5:
5801 return '[u] dddd [u] LT';
5802 }
5803 },
5804 lastDay : '[juče u] LT',
5805 lastWeek : function () {
5806 var lastWeekDays = [
5807 '[prošle] [nedelje] [u] LT',
5808 '[prošlog] [ponedeljka] [u] LT',
5809 '[prošlog] [utorka] [u] LT',
5810 '[prošle] [srede] [u] LT',
5811 '[prošlog] [četvrtka] [u] LT',
5812 '[prošlog] [petka] [u] LT',
5813 '[prošle] [subote] [u] LT'
5814 ];
5815 return lastWeekDays[this.day()];
5816 },
5817 sameElse : 'L'
5818 },
5819 relativeTime : {
5820 future : 'za %s',
5821 past : 'pre %s',
5822 s : 'nekoliko sekundi',
5823 m : sr__translator.translate,
5824 mm : sr__translator.translate,
5825 h : sr__translator.translate,
5826 hh : sr__translator.translate,
5827 d : 'dan',
5828 dd : sr__translator.translate,
5829 M : 'mesec',
5830 MM : sr__translator.translate,
5831 y : 'godinu',
5832 yy : sr__translator.translate
5833 },
5834 ordinalParse: /\d{1,2}\./,
5835 ordinal : '%d.',
5836 week : {
5837 dow : 1, // Monday is the first day of the week.
5838 doy : 7 // The week that contains Jan 1st is the first week of the year.
5839 }
5840 });
5841
5842 //! moment.js locale configuration
5843 //! locale : swedish (sv)
5844 //! author : Jens Alm : https://github.com/ulmus
5845
5846 var sv = moment.defineLocale('sv', {
5847 months : 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
5848 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
5849 weekdays : 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
5850 weekdaysShort : 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
5851 weekdaysMin : 'sö_må_ti_on_to_fr_lö'.split('_'),
5852 longDateFormat : {
5853 LT : 'HH:mm',
5854 LTS : 'HH:mm:ss',
5855 L : 'YYYY-MM-DD',
5856 LL : 'D MMMM YYYY',
5857 LLL : 'D MMMM YYYY HH:mm',
5858 LLLL : 'dddd D MMMM YYYY HH:mm'
5859 },
5860 calendar : {
5861 sameDay: '[Idag] LT',
5862 nextDay: '[Imorgon] LT',
5863 lastDay: '[Igår] LT',
5864 nextWeek: '[På] dddd LT',
5865 lastWeek: '[I] dddd[s] LT',
5866 sameElse: 'L'
5867 },
5868 relativeTime : {
5869 future : 'om %s',
5870 past : 'för %s sedan',
5871 s : 'några sekunder',
5872 m : 'en minut',
5873 mm : '%d minuter',
5874 h : 'en timme',
5875 hh : '%d timmar',
5876 d : 'en dag',
5877 dd : '%d dagar',
5878 M : 'en månad',
5879 MM : '%d månader',
5880 y : 'ett år',
5881 yy : '%d år'
5882 },
5883 ordinalParse: /\d{1,2}(e|a)/,
5884 ordinal : function (number) {
5885 var b = number % 10,
5886 output = (~~(number % 100 / 10) === 1) ? 'e' :
5887 (b === 1) ? 'a' :
5888 (b === 2) ? 'a' :
5889 (b === 3) ? 'e' : 'e';
5890 return number + output;
5891 },
5892 week : {
5893 dow : 1, // Monday is the first day of the week.
5894 doy : 4 // The week that contains Jan 4th is the first week of the year.
5895 }
5896 });
5897
5898 //! moment.js locale configuration
5899 //! locale : tamil (ta)
5900 //! author : Arjunkumar Krishnamoorthy : https://github.com/tk120404
5901
5902 var ta = moment.defineLocale('ta', {
5903 months : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
5904 monthsShort : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
5905 weekdays : 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'),
5906 weekdaysShort : 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'),
5907 weekdaysMin : 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'),
5908 longDateFormat : {
5909 LT : 'HH:mm',
5910 LTS : 'HH:mm:ss',
5911 L : 'DD/MM/YYYY',
5912 LL : 'D MMMM YYYY',
5913 LLL : 'D MMMM YYYY, HH:mm',
5914 LLLL : 'dddd, D MMMM YYYY, HH:mm'
5915 },
5916 calendar : {
5917 sameDay : '[இன்று] LT',
5918 nextDay : '[நாளை] LT',
5919 nextWeek : 'dddd, LT',
5920 lastDay : '[நேற்று] LT',
5921 lastWeek : '[கடந்த வாரம்] dddd, LT',
5922 sameElse : 'L'
5923 },
5924 relativeTime : {
5925 future : '%s இல்',
5926 past : '%s முன்',
5927 s : 'ஒரு சில விநாடிகள்',
5928 m : 'ஒரு நிமிடம்',
5929 mm : '%d நிமிடங்கள்',
5930 h : 'ஒரு மணி நேரம்',
5931 hh : '%d மணி நேரம்',
5932 d : 'ஒரு நாள்',
5933 dd : '%d நாட்கள்',
5934 M : 'ஒரு மாதம்',
5935 MM : '%d மாதங்கள்',
5936 y : 'ஒரு வருடம்',
5937 yy : '%d ஆண்டுகள்'
5938 },
5939 ordinalParse: /\d{1,2}வது/,
5940 ordinal : function (number) {
5941 return number + 'வது';
5942 },
5943 // refer http://ta.wikipedia.org/s/1er1
5944 meridiemParse: /யாமம்|வைகறை|காலை|நண்பகல்|எற்பாடு|மாலை/,
5945 meridiem : function (hour, minute, isLower) {
5946 if (hour < 2) {
5947 return ' யாமம்';
5948 } else if (hour < 6) {
5949 return ' வைகறை'; // வைகறை
5950 } else if (hour < 10) {
5951 return ' காலை'; // காலை
5952 } else if (hour < 14) {
5953 return ' நண்பகல்'; // நண்பகல்
5954 } else if (hour < 18) {
5955 return ' எற்பாடு'; // எற்பாடு
5956 } else if (hour < 22) {
5957 return ' மாலை'; // மாலை
5958 } else {
5959 return ' யாமம்';
5960 }
5961 },
5962 meridiemHour : function (hour, meridiem) {
5963 if (hour === 12) {
5964 hour = 0;
5965 }
5966 if (meridiem === 'யாமம்') {
5967 return hour < 2 ? hour : hour + 12;
5968 } else if (meridiem === 'வைகறை' || meridiem === 'காலை') {
5969 return hour;
5970 } else if (meridiem === 'நண்பகல்') {
5971 return hour >= 10 ? hour : hour + 12;
5972 } else {
5973 return hour + 12;
5974 }
5975 },
5976 week : {
5977 dow : 0, // Sunday is the first day of the week.
5978 doy : 6 // The week that contains Jan 1st is the first week of the year.
5979 }
5980 });
5981
5982 //! moment.js locale configuration
5983 //! locale : thai (th)
5984 //! author : Kridsada Thanabulpong : https://github.com/sirn
5985
5986 var th = moment.defineLocale('th', {
5987 months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
5988 monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
5989 weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
5990 weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
5991 weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
5992 longDateFormat : {
5993 LT : 'H นาฬิกา m นาที',
5994 LTS : 'H นาฬิกา m นาที s วินาที',
5995 L : 'YYYY/MM/DD',
5996 LL : 'D MMMM YYYY',
5997 LLL : 'D MMMM YYYY เวลา H นาฬิกา m นาที',
5998 LLLL : 'วันddddที่ D MMMM YYYY เวลา H นาฬิกา m นาที'
5999 },
6000 meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
6001 isPM: function (input) {
6002 return input === 'หลังเที่ยง';
6003 },
6004 meridiem : function (hour, minute, isLower) {
6005 if (hour < 12) {
6006 return 'ก่อนเที่ยง';
6007 } else {
6008 return 'หลังเที่ยง';
6009 }
6010 },
6011 calendar : {
6012 sameDay : '[วันนี้ เวลา] LT',
6013 nextDay : '[พรุ่งนี้ เวลา] LT',
6014 nextWeek : 'dddd[หน้า เวลา] LT',
6015 lastDay : '[เมื่อวานนี้ เวลา] LT',
6016 lastWeek : '[วัน]dddd[ที่แล้ว เวลา] LT',
6017 sameElse : 'L'
6018 },
6019 relativeTime : {
6020 future : 'อีก %s',
6021 past : '%sที่แล้ว',
6022 s : 'ไม่กี่วินาที',
6023 m : '1 นาที',
6024 mm : '%d นาที',
6025 h : '1 ชั่วโมง',
6026 hh : '%d ชั่วโมง',
6027 d : '1 วัน',
6028 dd : '%d วัน',
6029 M : '1 เดือน',
6030 MM : '%d เดือน',
6031 y : '1 ปี',
6032 yy : '%d ปี'
6033 }
6034 });
6035
6036 //! moment.js locale configuration
6037 //! locale : Tagalog/Filipino (tl-ph)
6038 //! author : Dan Hagman
6039
6040 var tl_ph = moment.defineLocale('tl-ph', {
6041 months : 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'),
6042 monthsShort : 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'),
6043 weekdays : 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'),
6044 weekdaysShort : 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'),
6045 weekdaysMin : 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'),
6046 longDateFormat : {
6047 LT : 'HH:mm',
6048 LTS : 'HH:mm:ss',
6049 L : 'MM/D/YYYY',
6050 LL : 'MMMM D, YYYY',
6051 LLL : 'MMMM D, YYYY HH:mm',
6052 LLLL : 'dddd, MMMM DD, YYYY HH:mm'
6053 },
6054 calendar : {
6055 sameDay: '[Ngayon sa] LT',
6056 nextDay: '[Bukas sa] LT',
6057 nextWeek: 'dddd [sa] LT',
6058 lastDay: '[Kahapon sa] LT',
6059 lastWeek: 'dddd [huling linggo] LT',
6060 sameElse: 'L'
6061 },
6062 relativeTime : {
6063 future : 'sa loob ng %s',
6064 past : '%s ang nakalipas',
6065 s : 'ilang segundo',
6066 m : 'isang minuto',
6067 mm : '%d minuto',
6068 h : 'isang oras',
6069 hh : '%d oras',
6070 d : 'isang araw',
6071 dd : '%d araw',
6072 M : 'isang buwan',
6073 MM : '%d buwan',
6074 y : 'isang taon',
6075 yy : '%d taon'
6076 },
6077 ordinalParse: /\d{1,2}/,
6078 ordinal : function (number) {
6079 return number;
6080 },
6081 week : {
6082 dow : 1, // Monday is the first day of the week.
6083 doy : 4 // The week that contains Jan 4th is the first week of the year.
6084 }
6085 });
6086
6087 //! moment.js locale configuration
6088 //! locale : turkish (tr)
6089 //! authors : Erhan Gundogan : https://github.com/erhangundogan,
6090 //! Burak Yiğit Kaya: https://github.com/BYK
6091
6092 var tr__suffixes = {
6093 1: '\'inci',
6094 5: '\'inci',
6095 8: '\'inci',
6096 70: '\'inci',
6097 80: '\'inci',
6098 2: '\'nci',
6099 7: '\'nci',
6100 20: '\'nci',
6101 50: '\'nci',
6102 3: '\'üncü',
6103 4: '\'üncü',
6104 100: '\'üncü',
6105 6: '\'ncı',
6106 9: '\'uncu',
6107 10: '\'uncu',
6108 30: '\'uncu',
6109 60: '\'ıncı',
6110 90: '\'ıncı'
6111 };
6112
6113 var tr = moment.defineLocale('tr', {
6114 months : 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
6115 monthsShort : 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'),
6116 weekdays : 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
6117 weekdaysShort : 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'),
6118 weekdaysMin : 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'),
6119 longDateFormat : {
6120 LT : 'HH:mm',
6121 LTS : 'HH:mm:ss',
6122 L : 'DD.MM.YYYY',
6123 LL : 'D MMMM YYYY',
6124 LLL : 'D MMMM YYYY HH:mm',
6125 LLLL : 'dddd, D MMMM YYYY HH:mm'
6126 },
6127 calendar : {
6128 sameDay : '[bugün saat] LT',
6129 nextDay : '[yarın saat] LT',
6130 nextWeek : '[haftaya] dddd [saat] LT',
6131 lastDay : '[dün] LT',
6132 lastWeek : '[geçen hafta] dddd [saat] LT',
6133 sameElse : 'L'
6134 },
6135 relativeTime : {
6136 future : '%s sonra',
6137 past : '%s önce',
6138 s : 'birkaç saniye',
6139 m : 'bir dakika',
6140 mm : '%d dakika',
6141 h : 'bir saat',
6142 hh : '%d saat',
6143 d : 'bir gün',
6144 dd : '%d gün',
6145 M : 'bir ay',
6146 MM : '%d ay',
6147 y : 'bir yıl',
6148 yy : '%d yıl'
6149 },
6150 ordinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
6151 ordinal : function (number) {
6152 if (number === 0) { // special case for zero
6153 return number + '\'ıncı';
6154 }
6155 var a = number % 10,
6156 b = number % 100 - a,
6157 c = number >= 100 ? 100 : null;
6158 return number + (tr__suffixes[a] || tr__suffixes[b] || tr__suffixes[c]);
6159 },
6160 week : {
6161 dow : 1, // Monday is the first day of the week.
6162 doy : 7 // The week that contains Jan 1st is the first week of the year.
6163 }
6164 });
6165
6166 //! moment.js locale configuration
6167 //! locale : talossan (tzl)
6168 //! author : Robin van der Vliet : https://github.com/robin0van0der0v with the help of Iustì Canun
6169
6170
6171 var tzl = moment.defineLocale('tzl', {
6172 months : 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'),
6173 monthsShort : 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'),
6174 weekdays : 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'),
6175 weekdaysShort : 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'),
6176 weekdaysMin : 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'),
6177 longDateFormat : {
6178 LT : 'HH.mm',
6179 LTS : 'LT.ss',
6180 L : 'DD.MM.YYYY',
6181 LL : 'D. MMMM [dallas] YYYY',
6182 LLL : 'D. MMMM [dallas] YYYY LT',
6183 LLLL : 'dddd, [li] D. MMMM [dallas] YYYY LT'
6184 },
6185 meridiem : function (hours, minutes, isLower) {
6186 if (hours > 11) {
6187 return isLower ? 'd\'o' : 'D\'O';
6188 } else {
6189 return isLower ? 'd\'a' : 'D\'A';
6190 }
6191 },
6192 calendar : {
6193 sameDay : '[oxhi à] LT',
6194 nextDay : '[demà à] LT',
6195 nextWeek : 'dddd [à] LT',
6196 lastDay : '[ieiri à] LT',
6197 lastWeek : '[sür el] dddd [lasteu à] LT',
6198 sameElse : 'L'
6199 },
6200 relativeTime : {
6201 future : 'osprei %s',
6202 past : 'ja%s',
6203 s : tzl__processRelativeTime,
6204 m : tzl__processRelativeTime,
6205 mm : tzl__processRelativeTime,
6206 h : tzl__processRelativeTime,
6207 hh : tzl__processRelativeTime,
6208 d : tzl__processRelativeTime,
6209 dd : tzl__processRelativeTime,
6210 M : tzl__processRelativeTime,
6211 MM : tzl__processRelativeTime,
6212 y : tzl__processRelativeTime,
6213 yy : tzl__processRelativeTime
6214 },
6215 ordinalParse: /\d{1,2}\./,
6216 ordinal : '%d.',
6217 week : {
6218 dow : 1, // Monday is the first day of the week.
6219 doy : 4 // The week that contains Jan 4th is the first week of the year.
6220 }
6221 });
6222
6223 function tzl__processRelativeTime(number, withoutSuffix, key, isFuture) {
6224 var format = {
6225 's': ['viensas secunds', '\'iensas secunds'],
6226 'm': ['\'n míut', '\'iens míut'],
6227 'mm': [number + ' míuts', ' ' + number + ' míuts'],
6228 'h': ['\'n þora', '\'iensa þora'],
6229 'hh': [number + ' þoras', ' ' + number + ' þoras'],
6230 'd': ['\'n ziua', '\'iensa ziua'],
6231 'dd': [number + ' ziuas', ' ' + number + ' ziuas'],
6232 'M': ['\'n mes', '\'iens mes'],
6233 'MM': [number + ' mesen', ' ' + number + ' mesen'],
6234 'y': ['\'n ar', '\'iens ar'],
6235 'yy': [number + ' ars', ' ' + number + ' ars']
6236 };
6237 return isFuture ? format[key][0] : (withoutSuffix ? format[key][0] : format[key][1].trim());
6238 }
6239
6240 //! moment.js locale configuration
6241 //! locale : Morocco Central Atlas Tamaziɣt in Latin (tzm-latn)
6242 //! author : Abdel Said : https://github.com/abdelsaid
6243
6244 var tzm_latn = moment.defineLocale('tzm-latn', {
6245 months : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
6246 monthsShort : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
6247 weekdays : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
6248 weekdaysShort : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
6249 weekdaysMin : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
6250 longDateFormat : {
6251 LT : 'HH:mm',
6252 LTS : 'HH:mm:ss',
6253 L : 'DD/MM/YYYY',
6254 LL : 'D MMMM YYYY',
6255 LLL : 'D MMMM YYYY HH:mm',
6256 LLLL : 'dddd D MMMM YYYY HH:mm'
6257 },
6258 calendar : {
6259 sameDay: '[asdkh g] LT',
6260 nextDay: '[aska g] LT',
6261 nextWeek: 'dddd [g] LT',
6262 lastDay: '[assant g] LT',
6263 lastWeek: 'dddd [g] LT',
6264 sameElse: 'L'
6265 },
6266 relativeTime : {
6267 future : 'dadkh s yan %s',
6268 past : 'yan %s',
6269 s : 'imik',
6270 m : 'minuḍ',
6271 mm : '%d minuḍ',
6272 h : 'saɛa',
6273 hh : '%d tassaɛin',
6274 d : 'ass',
6275 dd : '%d ossan',
6276 M : 'ayowr',
6277 MM : '%d iyyirn',
6278 y : 'asgas',
6279 yy : '%d isgasn'
6280 },
6281 week : {
6282 dow : 6, // Saturday is the first day of the week.
6283 doy : 12 // The week that contains Jan 1st is the first week of the year.
6284 }
6285 });
6286
6287 //! moment.js locale configuration
6288 //! locale : Morocco Central Atlas Tamaziɣt (tzm)
6289 //! author : Abdel Said : https://github.com/abdelsaid
6290
6291 var tzm = moment.defineLocale('tzm', {
6292 months : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
6293 monthsShort : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
6294 weekdays : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
6295 weekdaysShort : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
6296 weekdaysMin : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
6297 longDateFormat : {
6298 LT : 'HH:mm',
6299 LTS: 'HH:mm:ss',
6300 L : 'DD/MM/YYYY',
6301 LL : 'D MMMM YYYY',
6302 LLL : 'D MMMM YYYY HH:mm',
6303 LLLL : 'dddd D MMMM YYYY HH:mm'
6304 },
6305 calendar : {
6306 sameDay: '[ⴰⵙⴷⵅ ⴴ] LT',
6307 nextDay: '[ⴰⵙⴽⴰ ⴴ] LT',
6308 nextWeek: 'dddd [ⴴ] LT',
6309 lastDay: '[ⴰⵚⴰⵏⵜ ⴴ] LT',
6310 lastWeek: 'dddd [ⴴ] LT',
6311 sameElse: 'L'
6312 },
6313 relativeTime : {
6314 future : 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s',
6315 past : 'ⵢⴰⵏ %s',
6316 s : 'ⵉⵎⵉⴽ',
6317 m : 'ⵎⵉⵏⵓⴺ',
6318 mm : '%d ⵎⵉⵏⵓⴺ',
6319 h : 'ⵙⴰⵄⴰ',
6320 hh : '%d ⵜⴰⵙⵙⴰⵄⵉⵏ',
6321 d : 'ⴰⵙⵙ',
6322 dd : '%d oⵙⵙⴰⵏ',
6323 M : 'ⴰⵢoⵓⵔ',
6324 MM : '%d ⵉⵢⵢⵉⵔⵏ',
6325 y : 'ⴰⵙⴳⴰⵙ',
6326 yy : '%d ⵉⵙⴳⴰⵙⵏ'
6327 },
6328 week : {
6329 dow : 6, // Saturday is the first day of the week.
6330 doy : 12 // The week that contains Jan 1st is the first week of the year.
6331 }
6332 });
6333
6334 //! moment.js locale configuration
6335 //! locale : ukrainian (uk)
6336 //! author : zemlanin : https://github.com/zemlanin
6337 //! Author : Menelion Elensúle : https://github.com/Oire
6338
6339 function uk__plural(word, num) {
6340 var forms = word.split('_');
6341 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
6342 }
6343 function uk__relativeTimeWithPlural(number, withoutSuffix, key) {
6344 var format = {
6345 'mm': 'хвилина_хвилини_хвилин',
6346 'hh': 'година_години_годин',
6347 'dd': 'день_дні_днів',
6348 'MM': 'місяць_місяці_місяців',
6349 'yy': 'рік_роки_років'
6350 };
6351 if (key === 'm') {
6352 return withoutSuffix ? 'хвилина' : 'хвилину';
6353 }
6354 else if (key === 'h') {
6355 return withoutSuffix ? 'година' : 'годину';
6356 }
6357 else {
6358 return number + ' ' + uk__plural(format[key], +number);
6359 }
6360 }
6361 function uk__monthsCaseReplace(m, format) {
6362 var months = {
6363 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
6364 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
6365 },
6366 nounCase = (/D[oD]? *MMMM?/).test(format) ?
6367 'accusative' :
6368 'nominative';
6369 return months[nounCase][m.month()];
6370 }
6371 function uk__weekdaysCaseReplace(m, format) {
6372 var weekdays = {
6373 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
6374 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
6375 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
6376 },
6377 nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
6378 'accusative' :
6379 ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
6380 'genitive' :
6381 'nominative');
6382 return weekdays[nounCase][m.day()];
6383 }
6384 function processHoursFunction(str) {
6385 return function () {
6386 return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
6387 };
6388 }
6389
6390 var uk = moment.defineLocale('uk', {
6391 months : uk__monthsCaseReplace,
6392 monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
6393 weekdays : uk__weekdaysCaseReplace,
6394 weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
6395 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
6396 longDateFormat : {
6397 LT : 'HH:mm',
6398 LTS : 'HH:mm:ss',
6399 L : 'DD.MM.YYYY',
6400 LL : 'D MMMM YYYY р.',
6401 LLL : 'D MMMM YYYY р., HH:mm',
6402 LLLL : 'dddd, D MMMM YYYY р., HH:mm'
6403 },
6404 calendar : {
6405 sameDay: processHoursFunction('[Сьогодні '),
6406 nextDay: processHoursFunction('[Завтра '),
6407 lastDay: processHoursFunction('[Вчора '),
6408 nextWeek: processHoursFunction('[У] dddd ['),
6409 lastWeek: function () {
6410 switch (this.day()) {
6411 case 0:
6412 case 3:
6413 case 5:
6414 case 6:
6415 return processHoursFunction('[Минулої] dddd [').call(this);
6416 case 1:
6417 case 2:
6418 case 4:
6419 return processHoursFunction('[Минулого] dddd [').call(this);
6420 }
6421 },
6422 sameElse: 'L'
6423 },
6424 relativeTime : {
6425 future : 'за %s',
6426 past : '%s тому',
6427 s : 'декілька секунд',
6428 m : uk__relativeTimeWithPlural,
6429 mm : uk__relativeTimeWithPlural,
6430 h : 'годину',
6431 hh : uk__relativeTimeWithPlural,
6432 d : 'день',
6433 dd : uk__relativeTimeWithPlural,
6434 M : 'місяць',
6435 MM : uk__relativeTimeWithPlural,
6436 y : 'рік',
6437 yy : uk__relativeTimeWithPlural
6438 },
6439 // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
6440 meridiemParse: /ночі|ранку|дня|вечора/,
6441 isPM: function (input) {
6442 return /^(дня|вечора)$/.test(input);
6443 },
6444 meridiem : function (hour, minute, isLower) {
6445 if (hour < 4) {
6446 return 'ночі';
6447 } else if (hour < 12) {
6448 return 'ранку';
6449 } else if (hour < 17) {
6450 return 'дня';
6451 } else {
6452 return 'вечора';
6453 }
6454 },
6455 ordinalParse: /\d{1,2}-(й|го)/,
6456 ordinal: function (number, period) {
6457 switch (period) {
6458 case 'M':
6459 case 'd':
6460 case 'DDD':
6461 case 'w':
6462 case 'W':
6463 return number + '-й';
6464 case 'D':
6465 return number + '-го';
6466 default:
6467 return number;
6468 }
6469 },
6470 week : {
6471 dow : 1, // Monday is the first day of the week.
6472 doy : 7 // The week that contains Jan 1st is the first week of the year.
6473 }
6474 });
6475
6476 //! moment.js locale configuration
6477 //! locale : uzbek (uz)
6478 //! author : Sardor Muminov : https://github.com/muminoff
6479
6480 var uz = moment.defineLocale('uz', {
6481 months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
6482 monthsShort : 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'),
6483 weekdays : 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'),
6484 weekdaysShort : 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'),
6485 weekdaysMin : 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'),
6486 longDateFormat : {
6487 LT : 'HH:mm',
6488 LTS : 'HH:mm:ss',
6489 L : 'DD/MM/YYYY',
6490 LL : 'D MMMM YYYY',
6491 LLL : 'D MMMM YYYY HH:mm',
6492 LLLL : 'D MMMM YYYY, dddd HH:mm'
6493 },
6494 calendar : {
6495 sameDay : '[Бугун соат] LT [да]',
6496 nextDay : '[Эртага] LT [да]',
6497 nextWeek : 'dddd [куни соат] LT [да]',
6498 lastDay : '[Кеча соат] LT [да]',
6499 lastWeek : '[Утган] dddd [куни соат] LT [да]',
6500 sameElse : 'L'
6501 },
6502 relativeTime : {
6503 future : 'Якин %s ичида',
6504 past : 'Бир неча %s олдин',
6505 s : 'фурсат',
6506 m : 'бир дакика',
6507 mm : '%d дакика',
6508 h : 'бир соат',
6509 hh : '%d соат',
6510 d : 'бир кун',
6511 dd : '%d кун',
6512 M : 'бир ой',
6513 MM : '%d ой',
6514 y : 'бир йил',
6515 yy : '%d йил'
6516 },
6517 week : {
6518 dow : 1, // Monday is the first day of the week.
6519 doy : 7 // The week that contains Jan 4th is the first week of the year.
6520 }
6521 });
6522
6523 //! moment.js locale configuration
6524 //! locale : vietnamese (vi)
6525 //! author : Bang Nguyen : https://github.com/bangnk
6526
6527 var vi = moment.defineLocale('vi', {
6528 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('_'),
6529 monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
6530 weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
6531 weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
6532 weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
6533 longDateFormat : {
6534 LT : 'HH:mm',
6535 LTS : 'HH:mm:ss',
6536 L : 'DD/MM/YYYY',
6537 LL : 'D MMMM [năm] YYYY',
6538 LLL : 'D MMMM [năm] YYYY HH:mm',
6539 LLLL : 'dddd, D MMMM [năm] YYYY HH:mm',
6540 l : 'DD/M/YYYY',
6541 ll : 'D MMM YYYY',
6542 lll : 'D MMM YYYY HH:mm',
6543 llll : 'ddd, D MMM YYYY HH:mm'
6544 },
6545 calendar : {
6546 sameDay: '[Hôm nay lúc] LT',
6547 nextDay: '[Ngày mai lúc] LT',
6548 nextWeek: 'dddd [tuần tới lúc] LT',
6549 lastDay: '[Hôm qua lúc] LT',
6550 lastWeek: 'dddd [tuần rồi lúc] LT',
6551 sameElse: 'L'
6552 },
6553 relativeTime : {
6554 future : '%s tới',
6555 past : '%s trước',
6556 s : 'vài giây',
6557 m : 'một phút',
6558 mm : '%d phút',
6559 h : 'một giờ',
6560 hh : '%d giờ',
6561 d : 'một ngày',
6562 dd : '%d ngày',
6563 M : 'một tháng',
6564 MM : '%d tháng',
6565 y : 'một năm',
6566 yy : '%d năm'
6567 },
6568 ordinalParse: /\d{1,2}/,
6569 ordinal : function (number) {
6570 return number;
6571 },
6572 week : {
6573 dow : 1, // Monday is the first day of the week.
6574 doy : 4 // The week that contains Jan 4th is the first week of the year.
6575 }
6576 });
6577
6578 //! moment.js locale configuration
6579 //! locale : chinese (zh-cn)
6580 //! author : suupic : https://github.com/suupic
6581 //! author : Zeno Zeng : https://github.com/zenozeng
6582
6583 var zh_cn = moment.defineLocale('zh-cn', {
6584 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
6585 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
6586 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
6587 weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
6588 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
6589 longDateFormat : {
6590 LT : 'Ah点mm分',
6591 LTS : 'Ah点m分s秒',
6592 L : 'YYYY-MM-DD',
6593 LL : 'YYYY年MMMD日',
6594 LLL : 'YYYY年MMMD日Ah点mm分',
6595 LLLL : 'YYYY年MMMD日ddddAh点mm分',
6596 l : 'YYYY-MM-DD',
6597 ll : 'YYYY年MMMD日',
6598 lll : 'YYYY年MMMD日Ah点mm分',
6599 llll : 'YYYY年MMMD日ddddAh点mm分'
6600 },
6601 meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
6602 meridiemHour: function (hour, meridiem) {
6603 if (hour === 12) {
6604 hour = 0;
6605 }
6606 if (meridiem === '凌晨' || meridiem === '早上' ||
6607 meridiem === '上午') {
6608 return hour;
6609 } else if (meridiem === '下午' || meridiem === '晚上') {
6610 return hour + 12;
6611 } else {
6612 // '中午'
6613 return hour >= 11 ? hour : hour + 12;
6614 }
6615 },
6616 meridiem : function (hour, minute, isLower) {
6617 var hm = hour * 100 + minute;
6618 if (hm < 600) {
6619 return '凌晨';
6620 } else if (hm < 900) {
6621 return '早上';
6622 } else if (hm < 1130) {
6623 return '上午';
6624 } else if (hm < 1230) {
6625 return '中午';
6626 } else if (hm < 1800) {
6627 return '下午';
6628 } else {
6629 return '晚上';
6630 }
6631 },
6632 calendar : {
6633 sameDay : function () {
6634 return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
6635 },
6636 nextDay : function () {
6637 return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
6638 },
6639 lastDay : function () {
6640 return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
6641 },
6642 nextWeek : function () {
6643 var startOfWeek, prefix;
6644 startOfWeek = moment().startOf('week');
6645 prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
6646 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
6647 },
6648 lastWeek : function () {
6649 var startOfWeek, prefix;
6650 startOfWeek = moment().startOf('week');
6651 prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
6652 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
6653 },
6654 sameElse : 'LL'
6655 },
6656 ordinalParse: /\d{1,2}(日|月|周)/,
6657 ordinal : function (number, period) {
6658 switch (period) {
6659 case 'd':
6660 case 'D':
6661 case 'DDD':
6662 return number + '日';
6663 case 'M':
6664 return number + '月';
6665 case 'w':
6666 case 'W':
6667 return number + '周';
6668 default:
6669 return number;
6670 }
6671 },
6672 relativeTime : {
6673 future : '%s内',
6674 past : '%s前',
6675 s : '几秒',
6676 m : '1 分钟',
6677 mm : '%d 分钟',
6678 h : '1 小时',
6679 hh : '%d 小时',
6680 d : '1 天',
6681 dd : '%d 天',
6682 M : '1 个月',
6683 MM : '%d 个月',
6684 y : '1 年',
6685 yy : '%d 年'
6686 },
6687 week : {
6688 // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
6689 dow : 1, // Monday is the first day of the week.
6690 doy : 4 // The week that contains Jan 4th is the first week of the year.
6691 }
6692 });
6693
6694 //! moment.js locale configuration
6695 //! locale : traditional chinese (zh-tw)
6696 //! author : Ben : https://github.com/ben-lin
6697
6698 var zh_tw = moment.defineLocale('zh-tw', {
6699 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
6700 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
6701 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
6702 weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
6703 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
6704 longDateFormat : {
6705 LT : 'Ah點mm分',
6706 LTS : 'Ah點m分s秒',
6707 L : 'YYYY年MMMD日',
6708 LL : 'YYYY年MMMD日',
6709 LLL : 'YYYY年MMMD日Ah點mm分',
6710 LLLL : 'YYYY年MMMD日ddddAh點mm分',
6711 l : 'YYYY年MMMD日',
6712 ll : 'YYYY年MMMD日',
6713 lll : 'YYYY年MMMD日Ah點mm分',
6714 llll : 'YYYY年MMMD日ddddAh點mm分'
6715 },
6716 meridiemParse: /早上|上午|中午|下午|晚上/,
6717 meridiemHour : function (hour, meridiem) {
6718 if (hour === 12) {
6719 hour = 0;
6720 }
6721 if (meridiem === '早上' || meridiem === '上午') {
6722 return hour;
6723 } else if (meridiem === '中午') {
6724 return hour >= 11 ? hour : hour + 12;
6725 } else if (meridiem === '下午' || meridiem === '晚上') {
6726 return hour + 12;
6727 }
6728 },
6729 meridiem : function (hour, minute, isLower) {
6730 var hm = hour * 100 + minute;
6731 if (hm < 900) {
6732 return '早上';
6733 } else if (hm < 1130) {
6734 return '上午';
6735 } else if (hm < 1230) {
6736 return '中午';
6737 } else if (hm < 1800) {
6738 return '下午';
6739 } else {
6740 return '晚上';
6741 }
6742 },
6743 calendar : {
6744 sameDay : '[今天]LT',
6745 nextDay : '[明天]LT',
6746 nextWeek : '[下]ddddLT',
6747 lastDay : '[昨天]LT',
6748 lastWeek : '[上]ddddLT',
6749 sameElse : 'L'
6750 },
6751 ordinalParse: /\d{1,2}(日|月|週)/,
6752 ordinal : function (number, period) {
6753 switch (period) {
6754 case 'd' :
6755 case 'D' :
6756 case 'DDD' :
6757 return number + '日';
6758 case 'M' :
6759 return number + '月';
6760 case 'w' :
6761 case 'W' :
6762 return number + '週';
6763 default :
6764 return number;
6765 }
6766 },
6767 relativeTime : {
6768 future : '%s內',
6769 past : '%s前',
6770 s : '幾秒',
6771 m : '一分鐘',
6772 mm : '%d分鐘',
6773 h : '一小時',
6774 hh : '%d小時',
6775 d : '一天',
6776 dd : '%d天',
6777 M : '一個月',
6778 MM : '%d個月',
6779 y : '一年',
6780 yy : '%d年'
6781 }
6782 });
6783
6784
6785
6786 }));
0 (function (global, factory) {
1 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
2 typeof define === 'function' && define.amd ? define(factory) :
3 global.moment = factory()
4 }(this, function () { 'use strict';
5
6 var hookCallback;
7
8 function utils_hooks__hooks () {
9 return hookCallback.apply(null, arguments);
10 }
11
12 // This is done to register the method called with moment()
13 // without creating circular dependencies.
14 function setHookCallback (callback) {
15 hookCallback = callback;
16 }
17
18 function isArray(input) {
19 return Object.prototype.toString.call(input) === '[object Array]';
20 }
21
22 function isDate(input) {
23 return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
24 }
25
26 function map(arr, fn) {
27 var res = [], i;
28 for (i = 0; i < arr.length; ++i) {
29 res.push(fn(arr[i], i));
30 }
31 return res;
32 }
33
34 function hasOwnProp(a, b) {
35 return Object.prototype.hasOwnProperty.call(a, b);
36 }
37
38 function extend(a, b) {
39 for (var i in b) {
40 if (hasOwnProp(b, i)) {
41 a[i] = b[i];
42 }
43 }
44
45 if (hasOwnProp(b, 'toString')) {
46 a.toString = b.toString;
47 }
48
49 if (hasOwnProp(b, 'valueOf')) {
50 a.valueOf = b.valueOf;
51 }
52
53 return a;
54 }
55
56 function create_utc__createUTC (input, format, locale, strict) {
57 return createLocalOrUTC(input, format, locale, strict, true).utc();
58 }
59
60 function defaultParsingFlags() {
61 // We need to deep clone this object.
62 return {
63 empty : false,
64 unusedTokens : [],
65 unusedInput : [],
66 overflow : -2,
67 charsLeftOver : 0,
68 nullInput : false,
69 invalidMonth : null,
70 invalidFormat : false,
71 userInvalidated : false,
72 iso : false
73 };
74 }
75
76 function getParsingFlags(m) {
77 if (m._pf == null) {
78 m._pf = defaultParsingFlags();
79 }
80 return m._pf;
81 }
82
83 function valid__isValid(m) {
84 if (m._isValid == null) {
85 var flags = getParsingFlags(m);
86 m._isValid = !isNaN(m._d.getTime()) &&
87 flags.overflow < 0 &&
88 !flags.empty &&
89 !flags.invalidMonth &&
90 !flags.invalidWeekday &&
91 !flags.nullInput &&
92 !flags.invalidFormat &&
93 !flags.userInvalidated;
94
95 if (m._strict) {
96 m._isValid = m._isValid &&
97 flags.charsLeftOver === 0 &&
98 flags.unusedTokens.length === 0 &&
99 flags.bigHour === undefined;
100 }
101 }
102 return m._isValid;
103 }
104
105 function valid__createInvalid (flags) {
106 var m = create_utc__createUTC(NaN);
107 if (flags != null) {
108 extend(getParsingFlags(m), flags);
109 }
110 else {
111 getParsingFlags(m).userInvalidated = true;
112 }
113
114 return m;
115 }
116
117 var momentProperties = utils_hooks__hooks.momentProperties = [];
118
119 function copyConfig(to, from) {
120 var i, prop, val;
121
122 if (typeof from._isAMomentObject !== 'undefined') {
123 to._isAMomentObject = from._isAMomentObject;
124 }
125 if (typeof from._i !== 'undefined') {
126 to._i = from._i;
127 }
128 if (typeof from._f !== 'undefined') {
129 to._f = from._f;
130 }
131 if (typeof from._l !== 'undefined') {
132 to._l = from._l;
133 }
134 if (typeof from._strict !== 'undefined') {
135 to._strict = from._strict;
136 }
137 if (typeof from._tzm !== 'undefined') {
138 to._tzm = from._tzm;
139 }
140 if (typeof from._isUTC !== 'undefined') {
141 to._isUTC = from._isUTC;
142 }
143 if (typeof from._offset !== 'undefined') {
144 to._offset = from._offset;
145 }
146 if (typeof from._pf !== 'undefined') {
147 to._pf = getParsingFlags(from);
148 }
149 if (typeof from._locale !== 'undefined') {
150 to._locale = from._locale;
151 }
152
153 if (momentProperties.length > 0) {
154 for (i in momentProperties) {
155 prop = momentProperties[i];
156 val = from[prop];
157 if (typeof val !== 'undefined') {
158 to[prop] = val;
159 }
160 }
161 }
162
163 return to;
164 }
165
166 var updateInProgress = false;
167
168 // Moment prototype object
169 function Moment(config) {
170 copyConfig(this, config);
171 this._d = new Date(config._d != null ? config._d.getTime() : NaN);
172 // Prevent infinite loop in case updateOffset creates new moment
173 // objects.
174 if (updateInProgress === false) {
175 updateInProgress = true;
176 utils_hooks__hooks.updateOffset(this);
177 updateInProgress = false;
178 }
179 }
180
181 function isMoment (obj) {
182 return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
183 }
184
185 function absFloor (number) {
186 if (number < 0) {
187 return Math.ceil(number);
188 } else {
189 return Math.floor(number);
190 }
191 }
192
193 function toInt(argumentForCoercion) {
194 var coercedNumber = +argumentForCoercion,
195 value = 0;
196
197 if (coercedNumber !== 0 && isFinite(coercedNumber)) {
198 value = absFloor(coercedNumber);
199 }
200
201 return value;
202 }
203
204 function compareArrays(array1, array2, dontConvert) {
205 var len = Math.min(array1.length, array2.length),
206 lengthDiff = Math.abs(array1.length - array2.length),
207 diffs = 0,
208 i;
209 for (i = 0; i < len; i++) {
210 if ((dontConvert && array1[i] !== array2[i]) ||
211 (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
212 diffs++;
213 }
214 }
215 return diffs + lengthDiff;
216 }
217
218 function Locale() {
219 }
220
221 var locales = {};
222 var globalLocale;
223
224 function normalizeLocale(key) {
225 return key ? key.toLowerCase().replace('_', '-') : key;
226 }
227
228 // pick the locale from the array
229 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
230 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
231 function chooseLocale(names) {
232 var i = 0, j, next, locale, split;
233
234 while (i < names.length) {
235 split = normalizeLocale(names[i]).split('-');
236 j = split.length;
237 next = normalizeLocale(names[i + 1]);
238 next = next ? next.split('-') : null;
239 while (j > 0) {
240 locale = loadLocale(split.slice(0, j).join('-'));
241 if (locale) {
242 return locale;
243 }
244 if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
245 //the next array item is better than a shallower substring of this one
246 break;
247 }
248 j--;
249 }
250 i++;
251 }
252 return null;
253 }
254
255 function loadLocale(name) {
256 var oldLocale = null;
257 // TODO: Find a better way to register and load all the locales in Node
258 if (!locales[name] && typeof module !== 'undefined' &&
259 module && module.exports) {
260 try {
261 oldLocale = globalLocale._abbr;
262 require('./locale/' + name);
263 // because defineLocale currently also sets the global locale, we
264 // want to undo that for lazy loaded locales
265 locale_locales__getSetGlobalLocale(oldLocale);
266 } catch (e) { }
267 }
268 return locales[name];
269 }
270
271 // This function will load locale and then set the global locale. If
272 // no arguments are passed in, it will simply return the current global
273 // locale key.
274 function locale_locales__getSetGlobalLocale (key, values) {
275 var data;
276 if (key) {
277 if (typeof values === 'undefined') {
278 data = locale_locales__getLocale(key);
279 }
280 else {
281 data = defineLocale(key, values);
282 }
283
284 if (data) {
285 // moment.duration._locale = moment._locale = data;
286 globalLocale = data;
287 }
288 }
289
290 return globalLocale._abbr;
291 }
292
293 function defineLocale (name, values) {
294 if (values !== null) {
295 values.abbr = name;
296 locales[name] = locales[name] || new Locale();
297 locales[name].set(values);
298
299 // backwards compat for now: also set the locale
300 locale_locales__getSetGlobalLocale(name);
301
302 return locales[name];
303 } else {
304 // useful for testing
305 delete locales[name];
306 return null;
307 }
308 }
309
310 // returns locale data
311 function locale_locales__getLocale (key) {
312 var locale;
313
314 if (key && key._locale && key._locale._abbr) {
315 key = key._locale._abbr;
316 }
317
318 if (!key) {
319 return globalLocale;
320 }
321
322 if (!isArray(key)) {
323 //short-circuit everything else
324 locale = loadLocale(key);
325 if (locale) {
326 return locale;
327 }
328 key = [key];
329 }
330
331 return chooseLocale(key);
332 }
333
334 var aliases = {};
335
336 function addUnitAlias (unit, shorthand) {
337 var lowerCase = unit.toLowerCase();
338 aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
339 }
340
341 function normalizeUnits(units) {
342 return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
343 }
344
345 function normalizeObjectUnits(inputObject) {
346 var normalizedInput = {},
347 normalizedProp,
348 prop;
349
350 for (prop in inputObject) {
351 if (hasOwnProp(inputObject, prop)) {
352 normalizedProp = normalizeUnits(prop);
353 if (normalizedProp) {
354 normalizedInput[normalizedProp] = inputObject[prop];
355 }
356 }
357 }
358
359 return normalizedInput;
360 }
361
362 function makeGetSet (unit, keepTime) {
363 return function (value) {
364 if (value != null) {
365 get_set__set(this, unit, value);
366 utils_hooks__hooks.updateOffset(this, keepTime);
367 return this;
368 } else {
369 return get_set__get(this, unit);
370 }
371 };
372 }
373
374 function get_set__get (mom, unit) {
375 return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
376 }
377
378 function get_set__set (mom, unit, value) {
379 return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
380 }
381
382 // MOMENTS
383
384 function getSet (units, value) {
385 var unit;
386 if (typeof units === 'object') {
387 for (unit in units) {
388 this.set(unit, units[unit]);
389 }
390 } else {
391 units = normalizeUnits(units);
392 if (typeof this[units] === 'function') {
393 return this[units](value);
394 }
395 }
396 return this;
397 }
398
399 function zeroFill(number, targetLength, forceSign) {
400 var absNumber = '' + Math.abs(number),
401 zerosToFill = targetLength - absNumber.length,
402 sign = number >= 0;
403 return (sign ? (forceSign ? '+' : '') : '-') +
404 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
405 }
406
407 var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
408
409 var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
410
411 var formatFunctions = {};
412
413 var formatTokenFunctions = {};
414
415 // token: 'M'
416 // padded: ['MM', 2]
417 // ordinal: 'Mo'
418 // callback: function () { this.month() + 1 }
419 function addFormatToken (token, padded, ordinal, callback) {
420 var func = callback;
421 if (typeof callback === 'string') {
422 func = function () {
423 return this[callback]();
424 };
425 }
426 if (token) {
427 formatTokenFunctions[token] = func;
428 }
429 if (padded) {
430 formatTokenFunctions[padded[0]] = function () {
431 return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
432 };
433 }
434 if (ordinal) {
435 formatTokenFunctions[ordinal] = function () {
436 return this.localeData().ordinal(func.apply(this, arguments), token);
437 };
438 }
439 }
440
441 function removeFormattingTokens(input) {
442 if (input.match(/\[[\s\S]/)) {
443 return input.replace(/^\[|\]$/g, '');
444 }
445 return input.replace(/\\/g, '');
446 }
447
448 function makeFormatFunction(format) {
449 var array = format.match(formattingTokens), i, length;
450
451 for (i = 0, length = array.length; i < length; i++) {
452 if (formatTokenFunctions[array[i]]) {
453 array[i] = formatTokenFunctions[array[i]];
454 } else {
455 array[i] = removeFormattingTokens(array[i]);
456 }
457 }
458
459 return function (mom) {
460 var output = '';
461 for (i = 0; i < length; i++) {
462 output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
463 }
464 return output;
465 };
466 }
467
468 // format date using native date object
469 function formatMoment(m, format) {
470 if (!m.isValid()) {
471 return m.localeData().invalidDate();
472 }
473
474 format = expandFormat(format, m.localeData());
475 formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
476
477 return formatFunctions[format](m);
478 }
479
480 function expandFormat(format, locale) {
481 var i = 5;
482
483 function replaceLongDateFormatTokens(input) {
484 return locale.longDateFormat(input) || input;
485 }
486
487 localFormattingTokens.lastIndex = 0;
488 while (i >= 0 && localFormattingTokens.test(format)) {
489 format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
490 localFormattingTokens.lastIndex = 0;
491 i -= 1;
492 }
493
494 return format;
495 }
496
497 var match1 = /\d/; // 0 - 9
498 var match2 = /\d\d/; // 00 - 99
499 var match3 = /\d{3}/; // 000 - 999
500 var match4 = /\d{4}/; // 0000 - 9999
501 var match6 = /[+-]?\d{6}/; // -999999 - 999999
502 var match1to2 = /\d\d?/; // 0 - 99
503 var match1to3 = /\d{1,3}/; // 0 - 999
504 var match1to4 = /\d{1,4}/; // 0 - 9999
505 var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
506
507 var matchUnsigned = /\d+/; // 0 - inf
508 var matchSigned = /[+-]?\d+/; // -inf - inf
509
510 var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
511
512 var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
513
514 // any word (or two) characters or numbers including two/three word month in arabic.
515 var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
516
517 var regexes = {};
518
519 function isFunction (sth) {
520 // https://github.com/moment/moment/issues/2325
521 return typeof sth === 'function' &&
522 Object.prototype.toString.call(sth) === '[object Function]';
523 }
524
525
526 function addRegexToken (token, regex, strictRegex) {
527 regexes[token] = isFunction(regex) ? regex : function (isStrict) {
528 return (isStrict && strictRegex) ? strictRegex : regex;
529 };
530 }
531
532 function getParseRegexForToken (token, config) {
533 if (!hasOwnProp(regexes, token)) {
534 return new RegExp(unescapeFormat(token));
535 }
536
537 return regexes[token](config._strict, config._locale);
538 }
539
540 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
541 function unescapeFormat(s) {
542 return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
543 return p1 || p2 || p3 || p4;
544 }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
545 }
546
547 var tokens = {};
548
549 function addParseToken (token, callback) {
550 var i, func = callback;
551 if (typeof token === 'string') {
552 token = [token];
553 }
554 if (typeof callback === 'number') {
555 func = function (input, array) {
556 array[callback] = toInt(input);
557 };
558 }
559 for (i = 0; i < token.length; i++) {
560 tokens[token[i]] = func;
561 }
562 }
563
564 function addWeekParseToken (token, callback) {
565 addParseToken(token, function (input, array, config, token) {
566 config._w = config._w || {};
567 callback(input, config._w, config, token);
568 });
569 }
570
571 function addTimeToArrayFromToken(token, input, config) {
572 if (input != null && hasOwnProp(tokens, token)) {
573 tokens[token](input, config._a, config, token);
574 }
575 }
576
577 var YEAR = 0;
578 var MONTH = 1;
579 var DATE = 2;
580 var HOUR = 3;
581 var MINUTE = 4;
582 var SECOND = 5;
583 var MILLISECOND = 6;
584
585 function daysInMonth(year, month) {
586 return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
587 }
588
589 // FORMATTING
590
591 addFormatToken('M', ['MM', 2], 'Mo', function () {
592 return this.month() + 1;
593 });
594
595 addFormatToken('MMM', 0, 0, function (format) {
596 return this.localeData().monthsShort(this, format);
597 });
598
599 addFormatToken('MMMM', 0, 0, function (format) {
600 return this.localeData().months(this, format);
601 });
602
603 // ALIASES
604
605 addUnitAlias('month', 'M');
606
607 // PARSING
608
609 addRegexToken('M', match1to2);
610 addRegexToken('MM', match1to2, match2);
611 addRegexToken('MMM', matchWord);
612 addRegexToken('MMMM', matchWord);
613
614 addParseToken(['M', 'MM'], function (input, array) {
615 array[MONTH] = toInt(input) - 1;
616 });
617
618 addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
619 var month = config._locale.monthsParse(input, token, config._strict);
620 // if we didn't find a month name, mark the date as invalid.
621 if (month != null) {
622 array[MONTH] = month;
623 } else {
624 getParsingFlags(config).invalidMonth = input;
625 }
626 });
627
628 // LOCALES
629
630 var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
631 function localeMonths (m) {
632 return this._months[m.month()];
633 }
634
635 var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
636 function localeMonthsShort (m) {
637 return this._monthsShort[m.month()];
638 }
639
640 function localeMonthsParse (monthName, format, strict) {
641 var i, mom, regex;
642
643 if (!this._monthsParse) {
644 this._monthsParse = [];
645 this._longMonthsParse = [];
646 this._shortMonthsParse = [];
647 }
648
649 for (i = 0; i < 12; i++) {
650 // make the regex if we don't have it already
651 mom = create_utc__createUTC([2000, i]);
652 if (strict && !this._longMonthsParse[i]) {
653 this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
654 this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
655 }
656 if (!strict && !this._monthsParse[i]) {
657 regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
658 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
659 }
660 // test the regex
661 if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
662 return i;
663 } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
664 return i;
665 } else if (!strict && this._monthsParse[i].test(monthName)) {
666 return i;
667 }
668 }
669 }
670
671 // MOMENTS
672
673 function setMonth (mom, value) {
674 var dayOfMonth;
675
676 // TODO: Move this out of here!
677 if (typeof value === 'string') {
678 value = mom.localeData().monthsParse(value);
679 // TODO: Another silent failure?
680 if (typeof value !== 'number') {
681 return mom;
682 }
683 }
684
685 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
686 mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
687 return mom;
688 }
689
690 function getSetMonth (value) {
691 if (value != null) {
692 setMonth(this, value);
693 utils_hooks__hooks.updateOffset(this, true);
694 return this;
695 } else {
696 return get_set__get(this, 'Month');
697 }
698 }
699
700 function getDaysInMonth () {
701 return daysInMonth(this.year(), this.month());
702 }
703
704 function checkOverflow (m) {
705 var overflow;
706 var a = m._a;
707
708 if (a && getParsingFlags(m).overflow === -2) {
709 overflow =
710 a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
711 a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
712 a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
713 a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
714 a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
715 a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
716 -1;
717
718 if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
719 overflow = DATE;
720 }
721
722 getParsingFlags(m).overflow = overflow;
723 }
724
725 return m;
726 }
727
728 function warn(msg) {
729 if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
730 console.warn('Deprecation warning: ' + msg);
731 }
732 }
733
734 function deprecate(msg, fn) {
735 var firstTime = true;
736
737 return extend(function () {
738 if (firstTime) {
739 warn(msg + '\n' + (new Error()).stack);
740 firstTime = false;
741 }
742 return fn.apply(this, arguments);
743 }, fn);
744 }
745
746 var deprecations = {};
747
748 function deprecateSimple(name, msg) {
749 if (!deprecations[name]) {
750 warn(msg);
751 deprecations[name] = true;
752 }
753 }
754
755 utils_hooks__hooks.suppressDeprecationWarnings = false;
756
757 var from_string__isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
758
759 var isoDates = [
760 ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
761 ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
762 ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
763 ['GGGG-[W]WW', /\d{4}-W\d{2}/],
764 ['YYYY-DDD', /\d{4}-\d{3}/]
765 ];
766
767 // iso time formats and regexes
768 var isoTimes = [
769 ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
770 ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
771 ['HH:mm', /(T| )\d\d:\d\d/],
772 ['HH', /(T| )\d\d/]
773 ];
774
775 var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
776
777 // date from iso format
778 function configFromISO(config) {
779 var i, l,
780 string = config._i,
781 match = from_string__isoRegex.exec(string);
782
783 if (match) {
784 getParsingFlags(config).iso = true;
785 for (i = 0, l = isoDates.length; i < l; i++) {
786 if (isoDates[i][1].exec(string)) {
787 config._f = isoDates[i][0];
788 break;
789 }
790 }
791 for (i = 0, l = isoTimes.length; i < l; i++) {
792 if (isoTimes[i][1].exec(string)) {
793 // match[6] should be 'T' or space
794 config._f += (match[6] || ' ') + isoTimes[i][0];
795 break;
796 }
797 }
798 if (string.match(matchOffset)) {
799 config._f += 'Z';
800 }
801 configFromStringAndFormat(config);
802 } else {
803 config._isValid = false;
804 }
805 }
806
807 // date from iso format or fallback
808 function configFromString(config) {
809 var matched = aspNetJsonRegex.exec(config._i);
810
811 if (matched !== null) {
812 config._d = new Date(+matched[1]);
813 return;
814 }
815
816 configFromISO(config);
817 if (config._isValid === false) {
818 delete config._isValid;
819 utils_hooks__hooks.createFromInputFallback(config);
820 }
821 }
822
823 utils_hooks__hooks.createFromInputFallback = deprecate(
824 'moment construction falls back to js Date. This is ' +
825 'discouraged and will be removed in upcoming major ' +
826 'release. Please refer to ' +
827 'https://github.com/moment/moment/issues/1407 for more info.',
828 function (config) {
829 config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
830 }
831 );
832
833 function createDate (y, m, d, h, M, s, ms) {
834 //can't just apply() to create a date:
835 //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
836 var date = new Date(y, m, d, h, M, s, ms);
837
838 //the date constructor doesn't accept years < 1970
839 if (y < 1970) {
840 date.setFullYear(y);
841 }
842 return date;
843 }
844
845 function createUTCDate (y) {
846 var date = new Date(Date.UTC.apply(null, arguments));
847 if (y < 1970) {
848 date.setUTCFullYear(y);
849 }
850 return date;
851 }
852
853 addFormatToken(0, ['YY', 2], 0, function () {
854 return this.year() % 100;
855 });
856
857 addFormatToken(0, ['YYYY', 4], 0, 'year');
858 addFormatToken(0, ['YYYYY', 5], 0, 'year');
859 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
860
861 // ALIASES
862
863 addUnitAlias('year', 'y');
864
865 // PARSING
866
867 addRegexToken('Y', matchSigned);
868 addRegexToken('YY', match1to2, match2);
869 addRegexToken('YYYY', match1to4, match4);
870 addRegexToken('YYYYY', match1to6, match6);
871 addRegexToken('YYYYYY', match1to6, match6);
872
873 addParseToken(['YYYYY', 'YYYYYY'], YEAR);
874 addParseToken('YYYY', function (input, array) {
875 array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
876 });
877 addParseToken('YY', function (input, array) {
878 array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
879 });
880
881 // HELPERS
882
883 function daysInYear(year) {
884 return isLeapYear(year) ? 366 : 365;
885 }
886
887 function isLeapYear(year) {
888 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
889 }
890
891 // HOOKS
892
893 utils_hooks__hooks.parseTwoDigitYear = function (input) {
894 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
895 };
896
897 // MOMENTS
898
899 var getSetYear = makeGetSet('FullYear', false);
900
901 function getIsLeapYear () {
902 return isLeapYear(this.year());
903 }
904
905 addFormatToken('w', ['ww', 2], 'wo', 'week');
906 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
907
908 // ALIASES
909
910 addUnitAlias('week', 'w');
911 addUnitAlias('isoWeek', 'W');
912
913 // PARSING
914
915 addRegexToken('w', match1to2);
916 addRegexToken('ww', match1to2, match2);
917 addRegexToken('W', match1to2);
918 addRegexToken('WW', match1to2, match2);
919
920 addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
921 week[token.substr(0, 1)] = toInt(input);
922 });
923
924 // HELPERS
925
926 // firstDayOfWeek 0 = sun, 6 = sat
927 // the day of the week that starts the week
928 // (usually sunday or monday)
929 // firstDayOfWeekOfYear 0 = sun, 6 = sat
930 // the first week is the week that contains the first
931 // of this day of the week
932 // (eg. ISO weeks use thursday (4))
933 function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
934 var end = firstDayOfWeekOfYear - firstDayOfWeek,
935 daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
936 adjustedMoment;
937
938
939 if (daysToDayOfWeek > end) {
940 daysToDayOfWeek -= 7;
941 }
942
943 if (daysToDayOfWeek < end - 7) {
944 daysToDayOfWeek += 7;
945 }
946
947 adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
948 return {
949 week: Math.ceil(adjustedMoment.dayOfYear() / 7),
950 year: adjustedMoment.year()
951 };
952 }
953
954 // LOCALES
955
956 function localeWeek (mom) {
957 return weekOfYear(mom, this._week.dow, this._week.doy).week;
958 }
959
960 var defaultLocaleWeek = {
961 dow : 0, // Sunday is the first day of the week.
962 doy : 6 // The week that contains Jan 1st is the first week of the year.
963 };
964
965 function localeFirstDayOfWeek () {
966 return this._week.dow;
967 }
968
969 function localeFirstDayOfYear () {
970 return this._week.doy;
971 }
972
973 // MOMENTS
974
975 function getSetWeek (input) {
976 var week = this.localeData().week(this);
977 return input == null ? week : this.add((input - week) * 7, 'd');
978 }
979
980 function getSetISOWeek (input) {
981 var week = weekOfYear(this, 1, 4).week;
982 return input == null ? week : this.add((input - week) * 7, 'd');
983 }
984
985 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
986
987 // ALIASES
988
989 addUnitAlias('dayOfYear', 'DDD');
990
991 // PARSING
992
993 addRegexToken('DDD', match1to3);
994 addRegexToken('DDDD', match3);
995 addParseToken(['DDD', 'DDDD'], function (input, array, config) {
996 config._dayOfYear = toInt(input);
997 });
998
999 // HELPERS
1000
1001 //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1002 function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
1003 var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear;
1004 if (d < firstDayOfWeek) {
1005 d += 7;
1006 }
1007
1008 weekday = weekday != null ? 1 * weekday : firstDayOfWeek;
1009
1010 dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday;
1011
1012 return {
1013 year: dayOfYear > 0 ? year : year - 1,
1014 dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
1015 };
1016 }
1017
1018 // MOMENTS
1019
1020 function getSetDayOfYear (input) {
1021 var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
1022 return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
1023 }
1024
1025 // Pick the first defined of two or three arguments.
1026 function defaults(a, b, c) {
1027 if (a != null) {
1028 return a;
1029 }
1030 if (b != null) {
1031 return b;
1032 }
1033 return c;
1034 }
1035
1036 function currentDateArray(config) {
1037 var now = new Date();
1038 if (config._useUTC) {
1039 return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
1040 }
1041 return [now.getFullYear(), now.getMonth(), now.getDate()];
1042 }
1043
1044 // convert an array to a date.
1045 // the array should mirror the parameters below
1046 // note: all values past the year are optional and will default to the lowest possible value.
1047 // [year, month, day , hour, minute, second, millisecond]
1048 function configFromArray (config) {
1049 var i, date, input = [], currentDate, yearToUse;
1050
1051 if (config._d) {
1052 return;
1053 }
1054
1055 currentDate = currentDateArray(config);
1056
1057 //compute day of the year from weeks and weekdays
1058 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
1059 dayOfYearFromWeekInfo(config);
1060 }
1061
1062 //if the day of the year is set, figure out what it is
1063 if (config._dayOfYear) {
1064 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
1065
1066 if (config._dayOfYear > daysInYear(yearToUse)) {
1067 getParsingFlags(config)._overflowDayOfYear = true;
1068 }
1069
1070 date = createUTCDate(yearToUse, 0, config._dayOfYear);
1071 config._a[MONTH] = date.getUTCMonth();
1072 config._a[DATE] = date.getUTCDate();
1073 }
1074
1075 // Default to current date.
1076 // * if no year, month, day of month are given, default to today
1077 // * if day of month is given, default month and year
1078 // * if month is given, default only year
1079 // * if year is given, don't default anything
1080 for (i = 0; i < 3 && config._a[i] == null; ++i) {
1081 config._a[i] = input[i] = currentDate[i];
1082 }
1083
1084 // Zero out whatever was not defaulted, including time
1085 for (; i < 7; i++) {
1086 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
1087 }
1088
1089 // Check for 24:00:00.000
1090 if (config._a[HOUR] === 24 &&
1091 config._a[MINUTE] === 0 &&
1092 config._a[SECOND] === 0 &&
1093 config._a[MILLISECOND] === 0) {
1094 config._nextDay = true;
1095 config._a[HOUR] = 0;
1096 }
1097
1098 config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
1099 // Apply timezone offset from input. The actual utcOffset can be changed
1100 // with parseZone.
1101 if (config._tzm != null) {
1102 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
1103 }
1104
1105 if (config._nextDay) {
1106 config._a[HOUR] = 24;
1107 }
1108 }
1109
1110 function dayOfYearFromWeekInfo(config) {
1111 var w, weekYear, week, weekday, dow, doy, temp;
1112
1113 w = config._w;
1114 if (w.GG != null || w.W != null || w.E != null) {
1115 dow = 1;
1116 doy = 4;
1117
1118 // TODO: We need to take the current isoWeekYear, but that depends on
1119 // how we interpret now (local, utc, fixed offset). So create
1120 // a now version of current config (take local/utc/offset flags, and
1121 // create now).
1122 weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
1123 week = defaults(w.W, 1);
1124 weekday = defaults(w.E, 1);
1125 } else {
1126 dow = config._locale._week.dow;
1127 doy = config._locale._week.doy;
1128
1129 weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
1130 week = defaults(w.w, 1);
1131
1132 if (w.d != null) {
1133 // weekday -- low day numbers are considered next week
1134 weekday = w.d;
1135 if (weekday < dow) {
1136 ++week;
1137 }
1138 } else if (w.e != null) {
1139 // local weekday -- counting starts from begining of week
1140 weekday = w.e + dow;
1141 } else {
1142 // default to begining of week
1143 weekday = dow;
1144 }
1145 }
1146 temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
1147
1148 config._a[YEAR] = temp.year;
1149 config._dayOfYear = temp.dayOfYear;
1150 }
1151
1152 utils_hooks__hooks.ISO_8601 = function () {};
1153
1154 // date from string and format string
1155 function configFromStringAndFormat(config) {
1156 // TODO: Move this to another part of the creation flow to prevent circular deps
1157 if (config._f === utils_hooks__hooks.ISO_8601) {
1158 configFromISO(config);
1159 return;
1160 }
1161
1162 config._a = [];
1163 getParsingFlags(config).empty = true;
1164
1165 // This array is used to make a Date, either with `new Date` or `Date.UTC`
1166 var string = '' + config._i,
1167 i, parsedInput, tokens, token, skipped,
1168 stringLength = string.length,
1169 totalParsedInputLength = 0;
1170
1171 tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
1172
1173 for (i = 0; i < tokens.length; i++) {
1174 token = tokens[i];
1175 parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
1176 if (parsedInput) {
1177 skipped = string.substr(0, string.indexOf(parsedInput));
1178 if (skipped.length > 0) {
1179 getParsingFlags(config).unusedInput.push(skipped);
1180 }
1181 string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
1182 totalParsedInputLength += parsedInput.length;
1183 }
1184 // don't parse if it's not a known token
1185 if (formatTokenFunctions[token]) {
1186 if (parsedInput) {
1187 getParsingFlags(config).empty = false;
1188 }
1189 else {
1190 getParsingFlags(config).unusedTokens.push(token);
1191 }
1192 addTimeToArrayFromToken(token, parsedInput, config);
1193 }
1194 else if (config._strict && !parsedInput) {
1195 getParsingFlags(config).unusedTokens.push(token);
1196 }
1197 }
1198
1199 // add remaining unparsed input length to the string
1200 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
1201 if (string.length > 0) {
1202 getParsingFlags(config).unusedInput.push(string);
1203 }
1204
1205 // clear _12h flag if hour is <= 12
1206 if (getParsingFlags(config).bigHour === true &&
1207 config._a[HOUR] <= 12 &&
1208 config._a[HOUR] > 0) {
1209 getParsingFlags(config).bigHour = undefined;
1210 }
1211 // handle meridiem
1212 config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
1213
1214 configFromArray(config);
1215 checkOverflow(config);
1216 }
1217
1218
1219 function meridiemFixWrap (locale, hour, meridiem) {
1220 var isPm;
1221
1222 if (meridiem == null) {
1223 // nothing to do
1224 return hour;
1225 }
1226 if (locale.meridiemHour != null) {
1227 return locale.meridiemHour(hour, meridiem);
1228 } else if (locale.isPM != null) {
1229 // Fallback
1230 isPm = locale.isPM(meridiem);
1231 if (isPm && hour < 12) {
1232 hour += 12;
1233 }
1234 if (!isPm && hour === 12) {
1235 hour = 0;
1236 }
1237 return hour;
1238 } else {
1239 // this is not supposed to happen
1240 return hour;
1241 }
1242 }
1243
1244 function configFromStringAndArray(config) {
1245 var tempConfig,
1246 bestMoment,
1247
1248 scoreToBeat,
1249 i,
1250 currentScore;
1251
1252 if (config._f.length === 0) {
1253 getParsingFlags(config).invalidFormat = true;
1254 config._d = new Date(NaN);
1255 return;
1256 }
1257
1258 for (i = 0; i < config._f.length; i++) {
1259 currentScore = 0;
1260 tempConfig = copyConfig({}, config);
1261 if (config._useUTC != null) {
1262 tempConfig._useUTC = config._useUTC;
1263 }
1264 tempConfig._f = config._f[i];
1265 configFromStringAndFormat(tempConfig);
1266
1267 if (!valid__isValid(tempConfig)) {
1268 continue;
1269 }
1270
1271 // if there is any input that was not parsed add a penalty for that format
1272 currentScore += getParsingFlags(tempConfig).charsLeftOver;
1273
1274 //or tokens
1275 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
1276
1277 getParsingFlags(tempConfig).score = currentScore;
1278
1279 if (scoreToBeat == null || currentScore < scoreToBeat) {
1280 scoreToBeat = currentScore;
1281 bestMoment = tempConfig;
1282 }
1283 }
1284
1285 extend(config, bestMoment || tempConfig);
1286 }
1287
1288 function configFromObject(config) {
1289 if (config._d) {
1290 return;
1291 }
1292
1293 var i = normalizeObjectUnits(config._i);
1294 config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
1295
1296 configFromArray(config);
1297 }
1298
1299 function createFromConfig (config) {
1300 var res = new Moment(checkOverflow(prepareConfig(config)));
1301 if (res._nextDay) {
1302 // Adding is smart enough around DST
1303 res.add(1, 'd');
1304 res._nextDay = undefined;
1305 }
1306
1307 return res;
1308 }
1309
1310 function prepareConfig (config) {
1311 var input = config._i,
1312 format = config._f;
1313
1314 config._locale = config._locale || locale_locales__getLocale(config._l);
1315
1316 if (input === null || (format === undefined && input === '')) {
1317 return valid__createInvalid({nullInput: true});
1318 }
1319
1320 if (typeof input === 'string') {
1321 config._i = input = config._locale.preparse(input);
1322 }
1323
1324 if (isMoment(input)) {
1325 return new Moment(checkOverflow(input));
1326 } else if (isArray(format)) {
1327 configFromStringAndArray(config);
1328 } else if (format) {
1329 configFromStringAndFormat(config);
1330 } else if (isDate(input)) {
1331 config._d = input;
1332 } else {
1333 configFromInput(config);
1334 }
1335
1336 return config;
1337 }
1338
1339 function configFromInput(config) {
1340 var input = config._i;
1341 if (input === undefined) {
1342 config._d = new Date();
1343 } else if (isDate(input)) {
1344 config._d = new Date(+input);
1345 } else if (typeof input === 'string') {
1346 configFromString(config);
1347 } else if (isArray(input)) {
1348 config._a = map(input.slice(0), function (obj) {
1349 return parseInt(obj, 10);
1350 });
1351 configFromArray(config);
1352 } else if (typeof(input) === 'object') {
1353 configFromObject(config);
1354 } else if (typeof(input) === 'number') {
1355 // from milliseconds
1356 config._d = new Date(input);
1357 } else {
1358 utils_hooks__hooks.createFromInputFallback(config);
1359 }
1360 }
1361
1362 function createLocalOrUTC (input, format, locale, strict, isUTC) {
1363 var c = {};
1364
1365 if (typeof(locale) === 'boolean') {
1366 strict = locale;
1367 locale = undefined;
1368 }
1369 // object construction must be done this way.
1370 // https://github.com/moment/moment/issues/1423
1371 c._isAMomentObject = true;
1372 c._useUTC = c._isUTC = isUTC;
1373 c._l = locale;
1374 c._i = input;
1375 c._f = format;
1376 c._strict = strict;
1377
1378 return createFromConfig(c);
1379 }
1380
1381 function local__createLocal (input, format, locale, strict) {
1382 return createLocalOrUTC(input, format, locale, strict, false);
1383 }
1384
1385 var prototypeMin = deprecate(
1386 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
1387 function () {
1388 var other = local__createLocal.apply(null, arguments);
1389 return other < this ? this : other;
1390 }
1391 );
1392
1393 var prototypeMax = deprecate(
1394 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
1395 function () {
1396 var other = local__createLocal.apply(null, arguments);
1397 return other > this ? this : other;
1398 }
1399 );
1400
1401 // Pick a moment m from moments so that m[fn](other) is true for all
1402 // other. This relies on the function fn to be transitive.
1403 //
1404 // moments should either be an array of moment objects or an array, whose
1405 // first element is an array of moment objects.
1406 function pickBy(fn, moments) {
1407 var res, i;
1408 if (moments.length === 1 && isArray(moments[0])) {
1409 moments = moments[0];
1410 }
1411 if (!moments.length) {
1412 return local__createLocal();
1413 }
1414 res = moments[0];
1415 for (i = 1; i < moments.length; ++i) {
1416 if (!moments[i].isValid() || moments[i][fn](res)) {
1417 res = moments[i];
1418 }
1419 }
1420 return res;
1421 }
1422
1423 // TODO: Use [].sort instead?
1424 function min () {
1425 var args = [].slice.call(arguments, 0);
1426
1427 return pickBy('isBefore', args);
1428 }
1429
1430 function max () {
1431 var args = [].slice.call(arguments, 0);
1432
1433 return pickBy('isAfter', args);
1434 }
1435
1436 function Duration (duration) {
1437 var normalizedInput = normalizeObjectUnits(duration),
1438 years = normalizedInput.year || 0,
1439 quarters = normalizedInput.quarter || 0,
1440 months = normalizedInput.month || 0,
1441 weeks = normalizedInput.week || 0,
1442 days = normalizedInput.day || 0,
1443 hours = normalizedInput.hour || 0,
1444 minutes = normalizedInput.minute || 0,
1445 seconds = normalizedInput.second || 0,
1446 milliseconds = normalizedInput.millisecond || 0;
1447
1448 // representation for dateAddRemove
1449 this._milliseconds = +milliseconds +
1450 seconds * 1e3 + // 1000
1451 minutes * 6e4 + // 1000 * 60
1452 hours * 36e5; // 1000 * 60 * 60
1453 // Because of dateAddRemove treats 24 hours as different from a
1454 // day when working around DST, we need to store them separately
1455 this._days = +days +
1456 weeks * 7;
1457 // It is impossible translate months into days without knowing
1458 // which months you are are talking about, so we have to store
1459 // it separately.
1460 this._months = +months +
1461 quarters * 3 +
1462 years * 12;
1463
1464 this._data = {};
1465
1466 this._locale = locale_locales__getLocale();
1467
1468 this._bubble();
1469 }
1470
1471 function isDuration (obj) {
1472 return obj instanceof Duration;
1473 }
1474
1475 function offset (token, separator) {
1476 addFormatToken(token, 0, 0, function () {
1477 var offset = this.utcOffset();
1478 var sign = '+';
1479 if (offset < 0) {
1480 offset = -offset;
1481 sign = '-';
1482 }
1483 return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
1484 });
1485 }
1486
1487 offset('Z', ':');
1488 offset('ZZ', '');
1489
1490 // PARSING
1491
1492 addRegexToken('Z', matchOffset);
1493 addRegexToken('ZZ', matchOffset);
1494 addParseToken(['Z', 'ZZ'], function (input, array, config) {
1495 config._useUTC = true;
1496 config._tzm = offsetFromString(input);
1497 });
1498
1499 // HELPERS
1500
1501 // timezone chunker
1502 // '+10:00' > ['10', '00']
1503 // '-1530' > ['-15', '30']
1504 var chunkOffset = /([\+\-]|\d\d)/gi;
1505
1506 function offsetFromString(string) {
1507 var matches = ((string || '').match(matchOffset) || []);
1508 var chunk = matches[matches.length - 1] || [];
1509 var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
1510 var minutes = +(parts[1] * 60) + toInt(parts[2]);
1511
1512 return parts[0] === '+' ? minutes : -minutes;
1513 }
1514
1515 // Return a moment from input, that is local/utc/zone equivalent to model.
1516 function cloneWithOffset(input, model) {
1517 var res, diff;
1518 if (model._isUTC) {
1519 res = model.clone();
1520 diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
1521 // Use low-level api, because this fn is low-level api.
1522 res._d.setTime(+res._d + diff);
1523 utils_hooks__hooks.updateOffset(res, false);
1524 return res;
1525 } else {
1526 return local__createLocal(input).local();
1527 }
1528 }
1529
1530 function getDateOffset (m) {
1531 // On Firefox.24 Date#getTimezoneOffset returns a floating point.
1532 // https://github.com/moment/moment/pull/1871
1533 return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
1534 }
1535
1536 // HOOKS
1537
1538 // This function will be called whenever a moment is mutated.
1539 // It is intended to keep the offset in sync with the timezone.
1540 utils_hooks__hooks.updateOffset = function () {};
1541
1542 // MOMENTS
1543
1544 // keepLocalTime = true means only change the timezone, without
1545 // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
1546 // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
1547 // +0200, so we adjust the time as needed, to be valid.
1548 //
1549 // Keeping the time actually adds/subtracts (one hour)
1550 // from the actual represented time. That is why we call updateOffset
1551 // a second time. In case it wants us to change the offset again
1552 // _changeInProgress == true case, then we have to adjust, because
1553 // there is no such time in the given timezone.
1554 function getSetOffset (input, keepLocalTime) {
1555 var offset = this._offset || 0,
1556 localAdjust;
1557 if (input != null) {
1558 if (typeof input === 'string') {
1559 input = offsetFromString(input);
1560 }
1561 if (Math.abs(input) < 16) {
1562 input = input * 60;
1563 }
1564 if (!this._isUTC && keepLocalTime) {
1565 localAdjust = getDateOffset(this);
1566 }
1567 this._offset = input;
1568 this._isUTC = true;
1569 if (localAdjust != null) {
1570 this.add(localAdjust, 'm');
1571 }
1572 if (offset !== input) {
1573 if (!keepLocalTime || this._changeInProgress) {
1574 add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
1575 } else if (!this._changeInProgress) {
1576 this._changeInProgress = true;
1577 utils_hooks__hooks.updateOffset(this, true);
1578 this._changeInProgress = null;
1579 }
1580 }
1581 return this;
1582 } else {
1583 return this._isUTC ? offset : getDateOffset(this);
1584 }
1585 }
1586
1587 function getSetZone (input, keepLocalTime) {
1588 if (input != null) {
1589 if (typeof input !== 'string') {
1590 input = -input;
1591 }
1592
1593 this.utcOffset(input, keepLocalTime);
1594
1595 return this;
1596 } else {
1597 return -this.utcOffset();
1598 }
1599 }
1600
1601 function setOffsetToUTC (keepLocalTime) {
1602 return this.utcOffset(0, keepLocalTime);
1603 }
1604
1605 function setOffsetToLocal (keepLocalTime) {
1606 if (this._isUTC) {
1607 this.utcOffset(0, keepLocalTime);
1608 this._isUTC = false;
1609
1610 if (keepLocalTime) {
1611 this.subtract(getDateOffset(this), 'm');
1612 }
1613 }
1614 return this;
1615 }
1616
1617 function setOffsetToParsedOffset () {
1618 if (this._tzm) {
1619 this.utcOffset(this._tzm);
1620 } else if (typeof this._i === 'string') {
1621 this.utcOffset(offsetFromString(this._i));
1622 }
1623 return this;
1624 }
1625
1626 function hasAlignedHourOffset (input) {
1627 input = input ? local__createLocal(input).utcOffset() : 0;
1628
1629 return (this.utcOffset() - input) % 60 === 0;
1630 }
1631
1632 function isDaylightSavingTime () {
1633 return (
1634 this.utcOffset() > this.clone().month(0).utcOffset() ||
1635 this.utcOffset() > this.clone().month(5).utcOffset()
1636 );
1637 }
1638
1639 function isDaylightSavingTimeShifted () {
1640 if (typeof this._isDSTShifted !== 'undefined') {
1641 return this._isDSTShifted;
1642 }
1643
1644 var c = {};
1645
1646 copyConfig(c, this);
1647 c = prepareConfig(c);
1648
1649 if (c._a) {
1650 var other = c._isUTC ? create_utc__createUTC(c._a) : local__createLocal(c._a);
1651 this._isDSTShifted = this.isValid() &&
1652 compareArrays(c._a, other.toArray()) > 0;
1653 } else {
1654 this._isDSTShifted = false;
1655 }
1656
1657 return this._isDSTShifted;
1658 }
1659
1660 function isLocal () {
1661 return !this._isUTC;
1662 }
1663
1664 function isUtcOffset () {
1665 return this._isUTC;
1666 }
1667
1668 function isUtc () {
1669 return this._isUTC && this._offset === 0;
1670 }
1671
1672 var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
1673
1674 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
1675 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
1676 var create__isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
1677
1678 function create__createDuration (input, key) {
1679 var duration = input,
1680 // matching against regexp is expensive, do it on demand
1681 match = null,
1682 sign,
1683 ret,
1684 diffRes;
1685
1686 if (isDuration(input)) {
1687 duration = {
1688 ms : input._milliseconds,
1689 d : input._days,
1690 M : input._months
1691 };
1692 } else if (typeof input === 'number') {
1693 duration = {};
1694 if (key) {
1695 duration[key] = input;
1696 } else {
1697 duration.milliseconds = input;
1698 }
1699 } else if (!!(match = aspNetRegex.exec(input))) {
1700 sign = (match[1] === '-') ? -1 : 1;
1701 duration = {
1702 y : 0,
1703 d : toInt(match[DATE]) * sign,
1704 h : toInt(match[HOUR]) * sign,
1705 m : toInt(match[MINUTE]) * sign,
1706 s : toInt(match[SECOND]) * sign,
1707 ms : toInt(match[MILLISECOND]) * sign
1708 };
1709 } else if (!!(match = create__isoRegex.exec(input))) {
1710 sign = (match[1] === '-') ? -1 : 1;
1711 duration = {
1712 y : parseIso(match[2], sign),
1713 M : parseIso(match[3], sign),
1714 d : parseIso(match[4], sign),
1715 h : parseIso(match[5], sign),
1716 m : parseIso(match[6], sign),
1717 s : parseIso(match[7], sign),
1718 w : parseIso(match[8], sign)
1719 };
1720 } else if (duration == null) {// checks for null or undefined
1721 duration = {};
1722 } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
1723 diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
1724
1725 duration = {};
1726 duration.ms = diffRes.milliseconds;
1727 duration.M = diffRes.months;
1728 }
1729
1730 ret = new Duration(duration);
1731
1732 if (isDuration(input) && hasOwnProp(input, '_locale')) {
1733 ret._locale = input._locale;
1734 }
1735
1736 return ret;
1737 }
1738
1739 create__createDuration.fn = Duration.prototype;
1740
1741 function parseIso (inp, sign) {
1742 // We'd normally use ~~inp for this, but unfortunately it also
1743 // converts floats to ints.
1744 // inp may be undefined, so careful calling replace on it.
1745 var res = inp && parseFloat(inp.replace(',', '.'));
1746 // apply sign while we're at it
1747 return (isNaN(res) ? 0 : res) * sign;
1748 }
1749
1750 function positiveMomentsDifference(base, other) {
1751 var res = {milliseconds: 0, months: 0};
1752
1753 res.months = other.month() - base.month() +
1754 (other.year() - base.year()) * 12;
1755 if (base.clone().add(res.months, 'M').isAfter(other)) {
1756 --res.months;
1757 }
1758
1759 res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
1760
1761 return res;
1762 }
1763
1764 function momentsDifference(base, other) {
1765 var res;
1766 other = cloneWithOffset(other, base);
1767 if (base.isBefore(other)) {
1768 res = positiveMomentsDifference(base, other);
1769 } else {
1770 res = positiveMomentsDifference(other, base);
1771 res.milliseconds = -res.milliseconds;
1772 res.months = -res.months;
1773 }
1774
1775 return res;
1776 }
1777
1778 function createAdder(direction, name) {
1779 return function (val, period) {
1780 var dur, tmp;
1781 //invert the arguments, but complain about it
1782 if (period !== null && !isNaN(+period)) {
1783 deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
1784 tmp = val; val = period; period = tmp;
1785 }
1786
1787 val = typeof val === 'string' ? +val : val;
1788 dur = create__createDuration(val, period);
1789 add_subtract__addSubtract(this, dur, direction);
1790 return this;
1791 };
1792 }
1793
1794 function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
1795 var milliseconds = duration._milliseconds,
1796 days = duration._days,
1797 months = duration._months;
1798 updateOffset = updateOffset == null ? true : updateOffset;
1799
1800 if (milliseconds) {
1801 mom._d.setTime(+mom._d + milliseconds * isAdding);
1802 }
1803 if (days) {
1804 get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
1805 }
1806 if (months) {
1807 setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
1808 }
1809 if (updateOffset) {
1810 utils_hooks__hooks.updateOffset(mom, days || months);
1811 }
1812 }
1813
1814 var add_subtract__add = createAdder(1, 'add');
1815 var add_subtract__subtract = createAdder(-1, 'subtract');
1816
1817 function moment_calendar__calendar (time, formats) {
1818 // We want to compare the start of today, vs this.
1819 // Getting start-of-today depends on whether we're local/utc/offset or not.
1820 var now = time || local__createLocal(),
1821 sod = cloneWithOffset(now, this).startOf('day'),
1822 diff = this.diff(sod, 'days', true),
1823 format = diff < -6 ? 'sameElse' :
1824 diff < -1 ? 'lastWeek' :
1825 diff < 0 ? 'lastDay' :
1826 diff < 1 ? 'sameDay' :
1827 diff < 2 ? 'nextDay' :
1828 diff < 7 ? 'nextWeek' : 'sameElse';
1829 return this.format(formats && formats[format] || this.localeData().calendar(format, this, local__createLocal(now)));
1830 }
1831
1832 function clone () {
1833 return new Moment(this);
1834 }
1835
1836 function isAfter (input, units) {
1837 var inputMs;
1838 units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
1839 if (units === 'millisecond') {
1840 input = isMoment(input) ? input : local__createLocal(input);
1841 return +this > +input;
1842 } else {
1843 inputMs = isMoment(input) ? +input : +local__createLocal(input);
1844 return inputMs < +this.clone().startOf(units);
1845 }
1846 }
1847
1848 function isBefore (input, units) {
1849 var inputMs;
1850 units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
1851 if (units === 'millisecond') {
1852 input = isMoment(input) ? input : local__createLocal(input);
1853 return +this < +input;
1854 } else {
1855 inputMs = isMoment(input) ? +input : +local__createLocal(input);
1856 return +this.clone().endOf(units) < inputMs;
1857 }
1858 }
1859
1860 function isBetween (from, to, units) {
1861 return this.isAfter(from, units) && this.isBefore(to, units);
1862 }
1863
1864 function isSame (input, units) {
1865 var inputMs;
1866 units = normalizeUnits(units || 'millisecond');
1867 if (units === 'millisecond') {
1868 input = isMoment(input) ? input : local__createLocal(input);
1869 return +this === +input;
1870 } else {
1871 inputMs = +local__createLocal(input);
1872 return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
1873 }
1874 }
1875
1876 function diff (input, units, asFloat) {
1877 var that = cloneWithOffset(input, this),
1878 zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
1879 delta, output;
1880
1881 units = normalizeUnits(units);
1882
1883 if (units === 'year' || units === 'month' || units === 'quarter') {
1884 output = monthDiff(this, that);
1885 if (units === 'quarter') {
1886 output = output / 3;
1887 } else if (units === 'year') {
1888 output = output / 12;
1889 }
1890 } else {
1891 delta = this - that;
1892 output = units === 'second' ? delta / 1e3 : // 1000
1893 units === 'minute' ? delta / 6e4 : // 1000 * 60
1894 units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
1895 units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
1896 units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
1897 delta;
1898 }
1899 return asFloat ? output : absFloor(output);
1900 }
1901
1902 function monthDiff (a, b) {
1903 // difference in months
1904 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
1905 // b is in (anchor - 1 month, anchor + 1 month)
1906 anchor = a.clone().add(wholeMonthDiff, 'months'),
1907 anchor2, adjust;
1908
1909 if (b - anchor < 0) {
1910 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
1911 // linear across the month
1912 adjust = (b - anchor) / (anchor - anchor2);
1913 } else {
1914 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
1915 // linear across the month
1916 adjust = (b - anchor) / (anchor2 - anchor);
1917 }
1918
1919 return -(wholeMonthDiff + adjust);
1920 }
1921
1922 utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
1923
1924 function toString () {
1925 return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
1926 }
1927
1928 function moment_format__toISOString () {
1929 var m = this.clone().utc();
1930 if (0 < m.year() && m.year() <= 9999) {
1931 if ('function' === typeof Date.prototype.toISOString) {
1932 // native implementation is ~50x faster, use it when we can
1933 return this.toDate().toISOString();
1934 } else {
1935 return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1936 }
1937 } else {
1938 return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1939 }
1940 }
1941
1942 function moment_format__format (inputString) {
1943 var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
1944 return this.localeData().postformat(output);
1945 }
1946
1947 function from (time, withoutSuffix) {
1948 if (!this.isValid()) {
1949 return this.localeData().invalidDate();
1950 }
1951 return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
1952 }
1953
1954 function fromNow (withoutSuffix) {
1955 return this.from(local__createLocal(), withoutSuffix);
1956 }
1957
1958 function to (time, withoutSuffix) {
1959 if (!this.isValid()) {
1960 return this.localeData().invalidDate();
1961 }
1962 return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
1963 }
1964
1965 function toNow (withoutSuffix) {
1966 return this.to(local__createLocal(), withoutSuffix);
1967 }
1968
1969 function locale (key) {
1970 var newLocaleData;
1971
1972 if (key === undefined) {
1973 return this._locale._abbr;
1974 } else {
1975 newLocaleData = locale_locales__getLocale(key);
1976 if (newLocaleData != null) {
1977 this._locale = newLocaleData;
1978 }
1979 return this;
1980 }
1981 }
1982
1983 var lang = deprecate(
1984 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
1985 function (key) {
1986 if (key === undefined) {
1987 return this.localeData();
1988 } else {
1989 return this.locale(key);
1990 }
1991 }
1992 );
1993
1994 function localeData () {
1995 return this._locale;
1996 }
1997
1998 function startOf (units) {
1999 units = normalizeUnits(units);
2000 // the following switch intentionally omits break keywords
2001 // to utilize falling through the cases.
2002 switch (units) {
2003 case 'year':
2004 this.month(0);
2005 /* falls through */
2006 case 'quarter':
2007 case 'month':
2008 this.date(1);
2009 /* falls through */
2010 case 'week':
2011 case 'isoWeek':
2012 case 'day':
2013 this.hours(0);
2014 /* falls through */
2015 case 'hour':
2016 this.minutes(0);
2017 /* falls through */
2018 case 'minute':
2019 this.seconds(0);
2020 /* falls through */
2021 case 'second':
2022 this.milliseconds(0);
2023 }
2024
2025 // weeks are a special case
2026 if (units === 'week') {
2027 this.weekday(0);
2028 }
2029 if (units === 'isoWeek') {
2030 this.isoWeekday(1);
2031 }
2032
2033 // quarters are also special
2034 if (units === 'quarter') {
2035 this.month(Math.floor(this.month() / 3) * 3);
2036 }
2037
2038 return this;
2039 }
2040
2041 function endOf (units) {
2042 units = normalizeUnits(units);
2043 if (units === undefined || units === 'millisecond') {
2044 return this;
2045 }
2046 return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
2047 }
2048
2049 function to_type__valueOf () {
2050 return +this._d - ((this._offset || 0) * 60000);
2051 }
2052
2053 function unix () {
2054 return Math.floor(+this / 1000);
2055 }
2056
2057 function toDate () {
2058 return this._offset ? new Date(+this) : this._d;
2059 }
2060
2061 function toArray () {
2062 var m = this;
2063 return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
2064 }
2065
2066 function toObject () {
2067 var m = this;
2068 return {
2069 years: m.year(),
2070 months: m.month(),
2071 date: m.date(),
2072 hours: m.hours(),
2073 minutes: m.minutes(),
2074 seconds: m.seconds(),
2075 milliseconds: m.milliseconds()
2076 };
2077 }
2078
2079 function moment_valid__isValid () {
2080 return valid__isValid(this);
2081 }
2082
2083 function parsingFlags () {
2084 return extend({}, getParsingFlags(this));
2085 }
2086
2087 function invalidAt () {
2088 return getParsingFlags(this).overflow;
2089 }
2090
2091 addFormatToken(0, ['gg', 2], 0, function () {
2092 return this.weekYear() % 100;
2093 });
2094
2095 addFormatToken(0, ['GG', 2], 0, function () {
2096 return this.isoWeekYear() % 100;
2097 });
2098
2099 function addWeekYearFormatToken (token, getter) {
2100 addFormatToken(0, [token, token.length], 0, getter);
2101 }
2102
2103 addWeekYearFormatToken('gggg', 'weekYear');
2104 addWeekYearFormatToken('ggggg', 'weekYear');
2105 addWeekYearFormatToken('GGGG', 'isoWeekYear');
2106 addWeekYearFormatToken('GGGGG', 'isoWeekYear');
2107
2108 // ALIASES
2109
2110 addUnitAlias('weekYear', 'gg');
2111 addUnitAlias('isoWeekYear', 'GG');
2112
2113 // PARSING
2114
2115 addRegexToken('G', matchSigned);
2116 addRegexToken('g', matchSigned);
2117 addRegexToken('GG', match1to2, match2);
2118 addRegexToken('gg', match1to2, match2);
2119 addRegexToken('GGGG', match1to4, match4);
2120 addRegexToken('gggg', match1to4, match4);
2121 addRegexToken('GGGGG', match1to6, match6);
2122 addRegexToken('ggggg', match1to6, match6);
2123
2124 addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
2125 week[token.substr(0, 2)] = toInt(input);
2126 });
2127
2128 addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
2129 week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
2130 });
2131
2132 // HELPERS
2133
2134 function weeksInYear(year, dow, doy) {
2135 return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
2136 }
2137
2138 // MOMENTS
2139
2140 function getSetWeekYear (input) {
2141 var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
2142 return input == null ? year : this.add((input - year), 'y');
2143 }
2144
2145 function getSetISOWeekYear (input) {
2146 var year = weekOfYear(this, 1, 4).year;
2147 return input == null ? year : this.add((input - year), 'y');
2148 }
2149
2150 function getISOWeeksInYear () {
2151 return weeksInYear(this.year(), 1, 4);
2152 }
2153
2154 function getWeeksInYear () {
2155 var weekInfo = this.localeData()._week;
2156 return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
2157 }
2158
2159 addFormatToken('Q', 0, 0, 'quarter');
2160
2161 // ALIASES
2162
2163 addUnitAlias('quarter', 'Q');
2164
2165 // PARSING
2166
2167 addRegexToken('Q', match1);
2168 addParseToken('Q', function (input, array) {
2169 array[MONTH] = (toInt(input) - 1) * 3;
2170 });
2171
2172 // MOMENTS
2173
2174 function getSetQuarter (input) {
2175 return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
2176 }
2177
2178 addFormatToken('D', ['DD', 2], 'Do', 'date');
2179
2180 // ALIASES
2181
2182 addUnitAlias('date', 'D');
2183
2184 // PARSING
2185
2186 addRegexToken('D', match1to2);
2187 addRegexToken('DD', match1to2, match2);
2188 addRegexToken('Do', function (isStrict, locale) {
2189 return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
2190 });
2191
2192 addParseToken(['D', 'DD'], DATE);
2193 addParseToken('Do', function (input, array) {
2194 array[DATE] = toInt(input.match(match1to2)[0], 10);
2195 });
2196
2197 // MOMENTS
2198
2199 var getSetDayOfMonth = makeGetSet('Date', true);
2200
2201 addFormatToken('d', 0, 'do', 'day');
2202
2203 addFormatToken('dd', 0, 0, function (format) {
2204 return this.localeData().weekdaysMin(this, format);
2205 });
2206
2207 addFormatToken('ddd', 0, 0, function (format) {
2208 return this.localeData().weekdaysShort(this, format);
2209 });
2210
2211 addFormatToken('dddd', 0, 0, function (format) {
2212 return this.localeData().weekdays(this, format);
2213 });
2214
2215 addFormatToken('e', 0, 0, 'weekday');
2216 addFormatToken('E', 0, 0, 'isoWeekday');
2217
2218 // ALIASES
2219
2220 addUnitAlias('day', 'd');
2221 addUnitAlias('weekday', 'e');
2222 addUnitAlias('isoWeekday', 'E');
2223
2224 // PARSING
2225
2226 addRegexToken('d', match1to2);
2227 addRegexToken('e', match1to2);
2228 addRegexToken('E', match1to2);
2229 addRegexToken('dd', matchWord);
2230 addRegexToken('ddd', matchWord);
2231 addRegexToken('dddd', matchWord);
2232
2233 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
2234 var weekday = config._locale.weekdaysParse(input);
2235 // if we didn't get a weekday name, mark the date as invalid
2236 if (weekday != null) {
2237 week.d = weekday;
2238 } else {
2239 getParsingFlags(config).invalidWeekday = input;
2240 }
2241 });
2242
2243 addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
2244 week[token] = toInt(input);
2245 });
2246
2247 // HELPERS
2248
2249 function parseWeekday(input, locale) {
2250 if (typeof input !== 'string') {
2251 return input;
2252 }
2253
2254 if (!isNaN(input)) {
2255 return parseInt(input, 10);
2256 }
2257
2258 input = locale.weekdaysParse(input);
2259 if (typeof input === 'number') {
2260 return input;
2261 }
2262
2263 return null;
2264 }
2265
2266 // LOCALES
2267
2268 var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
2269 function localeWeekdays (m) {
2270 return this._weekdays[m.day()];
2271 }
2272
2273 var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
2274 function localeWeekdaysShort (m) {
2275 return this._weekdaysShort[m.day()];
2276 }
2277
2278 var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
2279 function localeWeekdaysMin (m) {
2280 return this._weekdaysMin[m.day()];
2281 }
2282
2283 function localeWeekdaysParse (weekdayName) {
2284 var i, mom, regex;
2285
2286 this._weekdaysParse = this._weekdaysParse || [];
2287
2288 for (i = 0; i < 7; i++) {
2289 // make the regex if we don't have it already
2290 if (!this._weekdaysParse[i]) {
2291 mom = local__createLocal([2000, 1]).day(i);
2292 regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
2293 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
2294 }
2295 // test the regex
2296 if (this._weekdaysParse[i].test(weekdayName)) {
2297 return i;
2298 }
2299 }
2300 }
2301
2302 // MOMENTS
2303
2304 function getSetDayOfWeek (input) {
2305 var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
2306 if (input != null) {
2307 input = parseWeekday(input, this.localeData());
2308 return this.add(input - day, 'd');
2309 } else {
2310 return day;
2311 }
2312 }
2313
2314 function getSetLocaleDayOfWeek (input) {
2315 var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
2316 return input == null ? weekday : this.add(input - weekday, 'd');
2317 }
2318
2319 function getSetISODayOfWeek (input) {
2320 // behaves the same as moment#day except
2321 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
2322 // as a setter, sunday should belong to the previous week.
2323 return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
2324 }
2325
2326 addFormatToken('H', ['HH', 2], 0, 'hour');
2327 addFormatToken('h', ['hh', 2], 0, function () {
2328 return this.hours() % 12 || 12;
2329 });
2330
2331 function meridiem (token, lowercase) {
2332 addFormatToken(token, 0, 0, function () {
2333 return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
2334 });
2335 }
2336
2337 meridiem('a', true);
2338 meridiem('A', false);
2339
2340 // ALIASES
2341
2342 addUnitAlias('hour', 'h');
2343
2344 // PARSING
2345
2346 function matchMeridiem (isStrict, locale) {
2347 return locale._meridiemParse;
2348 }
2349
2350 addRegexToken('a', matchMeridiem);
2351 addRegexToken('A', matchMeridiem);
2352 addRegexToken('H', match1to2);
2353 addRegexToken('h', match1to2);
2354 addRegexToken('HH', match1to2, match2);
2355 addRegexToken('hh', match1to2, match2);
2356
2357 addParseToken(['H', 'HH'], HOUR);
2358 addParseToken(['a', 'A'], function (input, array, config) {
2359 config._isPm = config._locale.isPM(input);
2360 config._meridiem = input;
2361 });
2362 addParseToken(['h', 'hh'], function (input, array, config) {
2363 array[HOUR] = toInt(input);
2364 getParsingFlags(config).bigHour = true;
2365 });
2366
2367 // LOCALES
2368
2369 function localeIsPM (input) {
2370 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
2371 // Using charAt should be more compatible.
2372 return ((input + '').toLowerCase().charAt(0) === 'p');
2373 }
2374
2375 var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
2376 function localeMeridiem (hours, minutes, isLower) {
2377 if (hours > 11) {
2378 return isLower ? 'pm' : 'PM';
2379 } else {
2380 return isLower ? 'am' : 'AM';
2381 }
2382 }
2383
2384
2385 // MOMENTS
2386
2387 // Setting the hour should keep the time, because the user explicitly
2388 // specified which hour he wants. So trying to maintain the same hour (in
2389 // a new timezone) makes sense. Adding/subtracting hours does not follow
2390 // this rule.
2391 var getSetHour = makeGetSet('Hours', true);
2392
2393 addFormatToken('m', ['mm', 2], 0, 'minute');
2394
2395 // ALIASES
2396
2397 addUnitAlias('minute', 'm');
2398
2399 // PARSING
2400
2401 addRegexToken('m', match1to2);
2402 addRegexToken('mm', match1to2, match2);
2403 addParseToken(['m', 'mm'], MINUTE);
2404
2405 // MOMENTS
2406
2407 var getSetMinute = makeGetSet('Minutes', false);
2408
2409 addFormatToken('s', ['ss', 2], 0, 'second');
2410
2411 // ALIASES
2412
2413 addUnitAlias('second', 's');
2414
2415 // PARSING
2416
2417 addRegexToken('s', match1to2);
2418 addRegexToken('ss', match1to2, match2);
2419 addParseToken(['s', 'ss'], SECOND);
2420
2421 // MOMENTS
2422
2423 var getSetSecond = makeGetSet('Seconds', false);
2424
2425 addFormatToken('S', 0, 0, function () {
2426 return ~~(this.millisecond() / 100);
2427 });
2428
2429 addFormatToken(0, ['SS', 2], 0, function () {
2430 return ~~(this.millisecond() / 10);
2431 });
2432
2433 addFormatToken(0, ['SSS', 3], 0, 'millisecond');
2434 addFormatToken(0, ['SSSS', 4], 0, function () {
2435 return this.millisecond() * 10;
2436 });
2437 addFormatToken(0, ['SSSSS', 5], 0, function () {
2438 return this.millisecond() * 100;
2439 });
2440 addFormatToken(0, ['SSSSSS', 6], 0, function () {
2441 return this.millisecond() * 1000;
2442 });
2443 addFormatToken(0, ['SSSSSSS', 7], 0, function () {
2444 return this.millisecond() * 10000;
2445 });
2446 addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
2447 return this.millisecond() * 100000;
2448 });
2449 addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
2450 return this.millisecond() * 1000000;
2451 });
2452
2453
2454 // ALIASES
2455
2456 addUnitAlias('millisecond', 'ms');
2457
2458 // PARSING
2459
2460 addRegexToken('S', match1to3, match1);
2461 addRegexToken('SS', match1to3, match2);
2462 addRegexToken('SSS', match1to3, match3);
2463
2464 var token;
2465 for (token = 'SSSS'; token.length <= 9; token += 'S') {
2466 addRegexToken(token, matchUnsigned);
2467 }
2468
2469 function parseMs(input, array) {
2470 array[MILLISECOND] = toInt(('0.' + input) * 1000);
2471 }
2472
2473 for (token = 'S'; token.length <= 9; token += 'S') {
2474 addParseToken(token, parseMs);
2475 }
2476 // MOMENTS
2477
2478 var getSetMillisecond = makeGetSet('Milliseconds', false);
2479
2480 addFormatToken('z', 0, 0, 'zoneAbbr');
2481 addFormatToken('zz', 0, 0, 'zoneName');
2482
2483 // MOMENTS
2484
2485 function getZoneAbbr () {
2486 return this._isUTC ? 'UTC' : '';
2487 }
2488
2489 function getZoneName () {
2490 return this._isUTC ? 'Coordinated Universal Time' : '';
2491 }
2492
2493 var momentPrototype__proto = Moment.prototype;
2494
2495 momentPrototype__proto.add = add_subtract__add;
2496 momentPrototype__proto.calendar = moment_calendar__calendar;
2497 momentPrototype__proto.clone = clone;
2498 momentPrototype__proto.diff = diff;
2499 momentPrototype__proto.endOf = endOf;
2500 momentPrototype__proto.format = moment_format__format;
2501 momentPrototype__proto.from = from;
2502 momentPrototype__proto.fromNow = fromNow;
2503 momentPrototype__proto.to = to;
2504 momentPrototype__proto.toNow = toNow;
2505 momentPrototype__proto.get = getSet;
2506 momentPrototype__proto.invalidAt = invalidAt;
2507 momentPrototype__proto.isAfter = isAfter;
2508 momentPrototype__proto.isBefore = isBefore;
2509 momentPrototype__proto.isBetween = isBetween;
2510 momentPrototype__proto.isSame = isSame;
2511 momentPrototype__proto.isValid = moment_valid__isValid;
2512 momentPrototype__proto.lang = lang;
2513 momentPrototype__proto.locale = locale;
2514 momentPrototype__proto.localeData = localeData;
2515 momentPrototype__proto.max = prototypeMax;
2516 momentPrototype__proto.min = prototypeMin;
2517 momentPrototype__proto.parsingFlags = parsingFlags;
2518 momentPrototype__proto.set = getSet;
2519 momentPrototype__proto.startOf = startOf;
2520 momentPrototype__proto.subtract = add_subtract__subtract;
2521 momentPrototype__proto.toArray = toArray;
2522 momentPrototype__proto.toObject = toObject;
2523 momentPrototype__proto.toDate = toDate;
2524 momentPrototype__proto.toISOString = moment_format__toISOString;
2525 momentPrototype__proto.toJSON = moment_format__toISOString;
2526 momentPrototype__proto.toString = toString;
2527 momentPrototype__proto.unix = unix;
2528 momentPrototype__proto.valueOf = to_type__valueOf;
2529
2530 // Year
2531 momentPrototype__proto.year = getSetYear;
2532 momentPrototype__proto.isLeapYear = getIsLeapYear;
2533
2534 // Week Year
2535 momentPrototype__proto.weekYear = getSetWeekYear;
2536 momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
2537
2538 // Quarter
2539 momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
2540
2541 // Month
2542 momentPrototype__proto.month = getSetMonth;
2543 momentPrototype__proto.daysInMonth = getDaysInMonth;
2544
2545 // Week
2546 momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
2547 momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
2548 momentPrototype__proto.weeksInYear = getWeeksInYear;
2549 momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
2550
2551 // Day
2552 momentPrototype__proto.date = getSetDayOfMonth;
2553 momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
2554 momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
2555 momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
2556 momentPrototype__proto.dayOfYear = getSetDayOfYear;
2557
2558 // Hour
2559 momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
2560
2561 // Minute
2562 momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
2563
2564 // Second
2565 momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
2566
2567 // Millisecond
2568 momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
2569
2570 // Offset
2571 momentPrototype__proto.utcOffset = getSetOffset;
2572 momentPrototype__proto.utc = setOffsetToUTC;
2573 momentPrototype__proto.local = setOffsetToLocal;
2574 momentPrototype__proto.parseZone = setOffsetToParsedOffset;
2575 momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
2576 momentPrototype__proto.isDST = isDaylightSavingTime;
2577 momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
2578 momentPrototype__proto.isLocal = isLocal;
2579 momentPrototype__proto.isUtcOffset = isUtcOffset;
2580 momentPrototype__proto.isUtc = isUtc;
2581 momentPrototype__proto.isUTC = isUtc;
2582
2583 // Timezone
2584 momentPrototype__proto.zoneAbbr = getZoneAbbr;
2585 momentPrototype__proto.zoneName = getZoneName;
2586
2587 // Deprecations
2588 momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
2589 momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
2590 momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
2591 momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
2592
2593 var momentPrototype = momentPrototype__proto;
2594
2595 function moment_moment__createUnix (input) {
2596 return local__createLocal(input * 1000);
2597 }
2598
2599 function moment_moment__createInZone () {
2600 return local__createLocal.apply(null, arguments).parseZone();
2601 }
2602
2603 var defaultCalendar = {
2604 sameDay : '[Today at] LT',
2605 nextDay : '[Tomorrow at] LT',
2606 nextWeek : 'dddd [at] LT',
2607 lastDay : '[Yesterday at] LT',
2608 lastWeek : '[Last] dddd [at] LT',
2609 sameElse : 'L'
2610 };
2611
2612 function locale_calendar__calendar (key, mom, now) {
2613 var output = this._calendar[key];
2614 return typeof output === 'function' ? output.call(mom, now) : output;
2615 }
2616
2617 var defaultLongDateFormat = {
2618 LTS : 'h:mm:ss A',
2619 LT : 'h:mm A',
2620 L : 'MM/DD/YYYY',
2621 LL : 'MMMM D, YYYY',
2622 LLL : 'MMMM D, YYYY h:mm A',
2623 LLLL : 'dddd, MMMM D, YYYY h:mm A'
2624 };
2625
2626 function longDateFormat (key) {
2627 var format = this._longDateFormat[key],
2628 formatUpper = this._longDateFormat[key.toUpperCase()];
2629
2630 if (format || !formatUpper) {
2631 return format;
2632 }
2633
2634 this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
2635 return val.slice(1);
2636 });
2637
2638 return this._longDateFormat[key];
2639 }
2640
2641 var defaultInvalidDate = 'Invalid date';
2642
2643 function invalidDate () {
2644 return this._invalidDate;
2645 }
2646
2647 var defaultOrdinal = '%d';
2648 var defaultOrdinalParse = /\d{1,2}/;
2649
2650 function ordinal (number) {
2651 return this._ordinal.replace('%d', number);
2652 }
2653
2654 function preParsePostFormat (string) {
2655 return string;
2656 }
2657
2658 var defaultRelativeTime = {
2659 future : 'in %s',
2660 past : '%s ago',
2661 s : 'a few seconds',
2662 m : 'a minute',
2663 mm : '%d minutes',
2664 h : 'an hour',
2665 hh : '%d hours',
2666 d : 'a day',
2667 dd : '%d days',
2668 M : 'a month',
2669 MM : '%d months',
2670 y : 'a year',
2671 yy : '%d years'
2672 };
2673
2674 function relative__relativeTime (number, withoutSuffix, string, isFuture) {
2675 var output = this._relativeTime[string];
2676 return (typeof output === 'function') ?
2677 output(number, withoutSuffix, string, isFuture) :
2678 output.replace(/%d/i, number);
2679 }
2680
2681 function pastFuture (diff, output) {
2682 var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
2683 return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
2684 }
2685
2686 function locale_set__set (config) {
2687 var prop, i;
2688 for (i in config) {
2689 prop = config[i];
2690 if (typeof prop === 'function') {
2691 this[i] = prop;
2692 } else {
2693 this['_' + i] = prop;
2694 }
2695 }
2696 // Lenient ordinal parsing accepts just a number in addition to
2697 // number + (possibly) stuff coming from _ordinalParseLenient.
2698 this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
2699 }
2700
2701 var prototype__proto = Locale.prototype;
2702
2703 prototype__proto._calendar = defaultCalendar;
2704 prototype__proto.calendar = locale_calendar__calendar;
2705 prototype__proto._longDateFormat = defaultLongDateFormat;
2706 prototype__proto.longDateFormat = longDateFormat;
2707 prototype__proto._invalidDate = defaultInvalidDate;
2708 prototype__proto.invalidDate = invalidDate;
2709 prototype__proto._ordinal = defaultOrdinal;
2710 prototype__proto.ordinal = ordinal;
2711 prototype__proto._ordinalParse = defaultOrdinalParse;
2712 prototype__proto.preparse = preParsePostFormat;
2713 prototype__proto.postformat = preParsePostFormat;
2714 prototype__proto._relativeTime = defaultRelativeTime;
2715 prototype__proto.relativeTime = relative__relativeTime;
2716 prototype__proto.pastFuture = pastFuture;
2717 prototype__proto.set = locale_set__set;
2718
2719 // Month
2720 prototype__proto.months = localeMonths;
2721 prototype__proto._months = defaultLocaleMonths;
2722 prototype__proto.monthsShort = localeMonthsShort;
2723 prototype__proto._monthsShort = defaultLocaleMonthsShort;
2724 prototype__proto.monthsParse = localeMonthsParse;
2725
2726 // Week
2727 prototype__proto.week = localeWeek;
2728 prototype__proto._week = defaultLocaleWeek;
2729 prototype__proto.firstDayOfYear = localeFirstDayOfYear;
2730 prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
2731
2732 // Day of Week
2733 prototype__proto.weekdays = localeWeekdays;
2734 prototype__proto._weekdays = defaultLocaleWeekdays;
2735 prototype__proto.weekdaysMin = localeWeekdaysMin;
2736 prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
2737 prototype__proto.weekdaysShort = localeWeekdaysShort;
2738 prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
2739 prototype__proto.weekdaysParse = localeWeekdaysParse;
2740
2741 // Hours
2742 prototype__proto.isPM = localeIsPM;
2743 prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
2744 prototype__proto.meridiem = localeMeridiem;
2745
2746 function lists__get (format, index, field, setter) {
2747 var locale = locale_locales__getLocale();
2748 var utc = create_utc__createUTC().set(setter, index);
2749 return locale[field](utc, format);
2750 }
2751
2752 function list (format, index, field, count, setter) {
2753 if (typeof format === 'number') {
2754 index = format;
2755 format = undefined;
2756 }
2757
2758 format = format || '';
2759
2760 if (index != null) {
2761 return lists__get(format, index, field, setter);
2762 }
2763
2764 var i;
2765 var out = [];
2766 for (i = 0; i < count; i++) {
2767 out[i] = lists__get(format, i, field, setter);
2768 }
2769 return out;
2770 }
2771
2772 function lists__listMonths (format, index) {
2773 return list(format, index, 'months', 12, 'month');
2774 }
2775
2776 function lists__listMonthsShort (format, index) {
2777 return list(format, index, 'monthsShort', 12, 'month');
2778 }
2779
2780 function lists__listWeekdays (format, index) {
2781 return list(format, index, 'weekdays', 7, 'day');
2782 }
2783
2784 function lists__listWeekdaysShort (format, index) {
2785 return list(format, index, 'weekdaysShort', 7, 'day');
2786 }
2787
2788 function lists__listWeekdaysMin (format, index) {
2789 return list(format, index, 'weekdaysMin', 7, 'day');
2790 }
2791
2792 locale_locales__getSetGlobalLocale('en', {
2793 ordinalParse: /\d{1,2}(th|st|nd|rd)/,
2794 ordinal : function (number) {
2795 var b = number % 10,
2796 output = (toInt(number % 100 / 10) === 1) ? 'th' :
2797 (b === 1) ? 'st' :
2798 (b === 2) ? 'nd' :
2799 (b === 3) ? 'rd' : 'th';
2800 return number + output;
2801 }
2802 });
2803
2804 // Side effect imports
2805 utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
2806 utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
2807
2808 var mathAbs = Math.abs;
2809
2810 function duration_abs__abs () {
2811 var data = this._data;
2812
2813 this._milliseconds = mathAbs(this._milliseconds);
2814 this._days = mathAbs(this._days);
2815 this._months = mathAbs(this._months);
2816
2817 data.milliseconds = mathAbs(data.milliseconds);
2818 data.seconds = mathAbs(data.seconds);
2819 data.minutes = mathAbs(data.minutes);
2820 data.hours = mathAbs(data.hours);
2821 data.months = mathAbs(data.months);
2822 data.years = mathAbs(data.years);
2823
2824 return this;
2825 }
2826
2827 function duration_add_subtract__addSubtract (duration, input, value, direction) {
2828 var other = create__createDuration(input, value);
2829
2830 duration._milliseconds += direction * other._milliseconds;
2831 duration._days += direction * other._days;
2832 duration._months += direction * other._months;
2833
2834 return duration._bubble();
2835 }
2836
2837 // supports only 2.0-style add(1, 's') or add(duration)
2838 function duration_add_subtract__add (input, value) {
2839 return duration_add_subtract__addSubtract(this, input, value, 1);
2840 }
2841
2842 // supports only 2.0-style subtract(1, 's') or subtract(duration)
2843 function duration_add_subtract__subtract (input, value) {
2844 return duration_add_subtract__addSubtract(this, input, value, -1);
2845 }
2846
2847 function absCeil (number) {
2848 if (number < 0) {
2849 return Math.floor(number);
2850 } else {
2851 return Math.ceil(number);
2852 }
2853 }
2854
2855 function bubble () {
2856 var milliseconds = this._milliseconds;
2857 var days = this._days;
2858 var months = this._months;
2859 var data = this._data;
2860 var seconds, minutes, hours, years, monthsFromDays;
2861
2862 // if we have a mix of positive and negative values, bubble down first
2863 // check: https://github.com/moment/moment/issues/2166
2864 if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
2865 (milliseconds <= 0 && days <= 0 && months <= 0))) {
2866 milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
2867 days = 0;
2868 months = 0;
2869 }
2870
2871 // The following code bubbles up values, see the tests for
2872 // examples of what that means.
2873 data.milliseconds = milliseconds % 1000;
2874
2875 seconds = absFloor(milliseconds / 1000);
2876 data.seconds = seconds % 60;
2877
2878 minutes = absFloor(seconds / 60);
2879 data.minutes = minutes % 60;
2880
2881 hours = absFloor(minutes / 60);
2882 data.hours = hours % 24;
2883
2884 days += absFloor(hours / 24);
2885
2886 // convert days to months
2887 monthsFromDays = absFloor(daysToMonths(days));
2888 months += monthsFromDays;
2889 days -= absCeil(monthsToDays(monthsFromDays));
2890
2891 // 12 months -> 1 year
2892 years = absFloor(months / 12);
2893 months %= 12;
2894
2895 data.days = days;
2896 data.months = months;
2897 data.years = years;
2898
2899 return this;
2900 }
2901
2902 function daysToMonths (days) {
2903 // 400 years have 146097 days (taking into account leap year rules)
2904 // 400 years have 12 months === 4800
2905 return days * 4800 / 146097;
2906 }
2907
2908 function monthsToDays (months) {
2909 // the reverse of daysToMonths
2910 return months * 146097 / 4800;
2911 }
2912
2913 function as (units) {
2914 var days;
2915 var months;
2916 var milliseconds = this._milliseconds;
2917
2918 units = normalizeUnits(units);
2919
2920 if (units === 'month' || units === 'year') {
2921 days = this._days + milliseconds / 864e5;
2922 months = this._months + daysToMonths(days);
2923 return units === 'month' ? months : months / 12;
2924 } else {
2925 // handle milliseconds separately because of floating point math errors (issue #1867)
2926 days = this._days + Math.round(monthsToDays(this._months));
2927 switch (units) {
2928 case 'week' : return days / 7 + milliseconds / 6048e5;
2929 case 'day' : return days + milliseconds / 864e5;
2930 case 'hour' : return days * 24 + milliseconds / 36e5;
2931 case 'minute' : return days * 1440 + milliseconds / 6e4;
2932 case 'second' : return days * 86400 + milliseconds / 1000;
2933 // Math.floor prevents floating point math errors here
2934 case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
2935 default: throw new Error('Unknown unit ' + units);
2936 }
2937 }
2938 }
2939
2940 // TODO: Use this.as('ms')?
2941 function duration_as__valueOf () {
2942 return (
2943 this._milliseconds +
2944 this._days * 864e5 +
2945 (this._months % 12) * 2592e6 +
2946 toInt(this._months / 12) * 31536e6
2947 );
2948 }
2949
2950 function makeAs (alias) {
2951 return function () {
2952 return this.as(alias);
2953 };
2954 }
2955
2956 var asMilliseconds = makeAs('ms');
2957 var asSeconds = makeAs('s');
2958 var asMinutes = makeAs('m');
2959 var asHours = makeAs('h');
2960 var asDays = makeAs('d');
2961 var asWeeks = makeAs('w');
2962 var asMonths = makeAs('M');
2963 var asYears = makeAs('y');
2964
2965 function duration_get__get (units) {
2966 units = normalizeUnits(units);
2967 return this[units + 's']();
2968 }
2969
2970 function makeGetter(name) {
2971 return function () {
2972 return this._data[name];
2973 };
2974 }
2975
2976 var milliseconds = makeGetter('milliseconds');
2977 var seconds = makeGetter('seconds');
2978 var minutes = makeGetter('minutes');
2979 var hours = makeGetter('hours');
2980 var days = makeGetter('days');
2981 var duration_get__months = makeGetter('months');
2982 var years = makeGetter('years');
2983
2984 function weeks () {
2985 return absFloor(this.days() / 7);
2986 }
2987
2988 var round = Math.round;
2989 var thresholds = {
2990 s: 45, // seconds to minute
2991 m: 45, // minutes to hour
2992 h: 22, // hours to day
2993 d: 26, // days to month
2994 M: 11 // months to year
2995 };
2996
2997 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
2998 function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
2999 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
3000 }
3001
3002 function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
3003 var duration = create__createDuration(posNegDuration).abs();
3004 var seconds = round(duration.as('s'));
3005 var minutes = round(duration.as('m'));
3006 var hours = round(duration.as('h'));
3007 var days = round(duration.as('d'));
3008 var months = round(duration.as('M'));
3009 var years = round(duration.as('y'));
3010
3011 var a = seconds < thresholds.s && ['s', seconds] ||
3012 minutes === 1 && ['m'] ||
3013 minutes < thresholds.m && ['mm', minutes] ||
3014 hours === 1 && ['h'] ||
3015 hours < thresholds.h && ['hh', hours] ||
3016 days === 1 && ['d'] ||
3017 days < thresholds.d && ['dd', days] ||
3018 months === 1 && ['M'] ||
3019 months < thresholds.M && ['MM', months] ||
3020 years === 1 && ['y'] || ['yy', years];
3021
3022 a[2] = withoutSuffix;
3023 a[3] = +posNegDuration > 0;
3024 a[4] = locale;
3025 return substituteTimeAgo.apply(null, a);
3026 }
3027
3028 // This function allows you to set a threshold for relative time strings
3029 function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
3030 if (thresholds[threshold] === undefined) {
3031 return false;
3032 }
3033 if (limit === undefined) {
3034 return thresholds[threshold];
3035 }
3036 thresholds[threshold] = limit;
3037 return true;
3038 }
3039
3040 function humanize (withSuffix) {
3041 var locale = this.localeData();
3042 var output = duration_humanize__relativeTime(this, !withSuffix, locale);
3043
3044 if (withSuffix) {
3045 output = locale.pastFuture(+this, output);
3046 }
3047
3048 return locale.postformat(output);
3049 }
3050
3051 var iso_string__abs = Math.abs;
3052
3053 function iso_string__toISOString() {
3054 // for ISO strings we do not use the normal bubbling rules:
3055 // * milliseconds bubble up until they become hours
3056 // * days do not bubble at all
3057 // * months bubble up until they become years
3058 // This is because there is no context-free conversion between hours and days
3059 // (think of clock changes)
3060 // and also not between days and months (28-31 days per month)
3061 var seconds = iso_string__abs(this._milliseconds) / 1000;
3062 var days = iso_string__abs(this._days);
3063 var months = iso_string__abs(this._months);
3064 var minutes, hours, years;
3065
3066 // 3600 seconds -> 60 minutes -> 1 hour
3067 minutes = absFloor(seconds / 60);
3068 hours = absFloor(minutes / 60);
3069 seconds %= 60;
3070 minutes %= 60;
3071
3072 // 12 months -> 1 year
3073 years = absFloor(months / 12);
3074 months %= 12;
3075
3076
3077 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
3078 var Y = years;
3079 var M = months;
3080 var D = days;
3081 var h = hours;
3082 var m = minutes;
3083 var s = seconds;
3084 var total = this.asSeconds();
3085
3086 if (!total) {
3087 // this is the same as C#'s (Noda) and python (isodate)...
3088 // but not other JS (goog.date)
3089 return 'P0D';
3090 }
3091
3092 return (total < 0 ? '-' : '') +
3093 'P' +
3094 (Y ? Y + 'Y' : '') +
3095 (M ? M + 'M' : '') +
3096 (D ? D + 'D' : '') +
3097 ((h || m || s) ? 'T' : '') +
3098 (h ? h + 'H' : '') +
3099 (m ? m + 'M' : '') +
3100 (s ? s + 'S' : '');
3101 }
3102
3103 var duration_prototype__proto = Duration.prototype;
3104
3105 duration_prototype__proto.abs = duration_abs__abs;
3106 duration_prototype__proto.add = duration_add_subtract__add;
3107 duration_prototype__proto.subtract = duration_add_subtract__subtract;
3108 duration_prototype__proto.as = as;
3109 duration_prototype__proto.asMilliseconds = asMilliseconds;
3110 duration_prototype__proto.asSeconds = asSeconds;
3111 duration_prototype__proto.asMinutes = asMinutes;
3112 duration_prototype__proto.asHours = asHours;
3113 duration_prototype__proto.asDays = asDays;
3114 duration_prototype__proto.asWeeks = asWeeks;
3115 duration_prototype__proto.asMonths = asMonths;
3116 duration_prototype__proto.asYears = asYears;
3117 duration_prototype__proto.valueOf = duration_as__valueOf;
3118 duration_prototype__proto._bubble = bubble;
3119 duration_prototype__proto.get = duration_get__get;
3120 duration_prototype__proto.milliseconds = milliseconds;
3121 duration_prototype__proto.seconds = seconds;
3122 duration_prototype__proto.minutes = minutes;
3123 duration_prototype__proto.hours = hours;
3124 duration_prototype__proto.days = days;
3125 duration_prototype__proto.weeks = weeks;
3126 duration_prototype__proto.months = duration_get__months;
3127 duration_prototype__proto.years = years;
3128 duration_prototype__proto.humanize = humanize;
3129 duration_prototype__proto.toISOString = iso_string__toISOString;
3130 duration_prototype__proto.toString = iso_string__toISOString;
3131 duration_prototype__proto.toJSON = iso_string__toISOString;
3132 duration_prototype__proto.locale = locale;
3133 duration_prototype__proto.localeData = localeData;
3134
3135 // Deprecations
3136 duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
3137 duration_prototype__proto.lang = lang;
3138
3139 // Side effect imports
3140
3141 addFormatToken('X', 0, 0, 'unix');
3142 addFormatToken('x', 0, 0, 'valueOf');
3143
3144 // PARSING
3145
3146 addRegexToken('x', matchSigned);
3147 addRegexToken('X', matchTimestamp);
3148 addParseToken('X', function (input, array, config) {
3149 config._d = new Date(parseFloat(input, 10) * 1000);
3150 });
3151 addParseToken('x', function (input, array, config) {
3152 config._d = new Date(toInt(input));
3153 });
3154
3155 // Side effect imports
3156
3157 ;
3158
3159 //! moment.js
3160 //! version : 2.10.6
3161 //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
3162 //! license : MIT
3163 //! momentjs.com
3164
3165 utils_hooks__hooks.version = '2.10.6';
3166
3167 setHookCallback(local__createLocal);
3168
3169 utils_hooks__hooks.fn = momentPrototype;
3170 utils_hooks__hooks.min = min;
3171 utils_hooks__hooks.max = max;
3172 utils_hooks__hooks.utc = create_utc__createUTC;
3173 utils_hooks__hooks.unix = moment_moment__createUnix;
3174 utils_hooks__hooks.months = lists__listMonths;
3175 utils_hooks__hooks.isDate = isDate;
3176 utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
3177 utils_hooks__hooks.invalid = valid__createInvalid;
3178 utils_hooks__hooks.duration = create__createDuration;
3179 utils_hooks__hooks.isMoment = isMoment;
3180 utils_hooks__hooks.weekdays = lists__listWeekdays;
3181 utils_hooks__hooks.parseZone = moment_moment__createInZone;
3182 utils_hooks__hooks.localeData = locale_locales__getLocale;
3183 utils_hooks__hooks.isDuration = isDuration;
3184 utils_hooks__hooks.monthsShort = lists__listMonthsShort;
3185 utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
3186 utils_hooks__hooks.defineLocale = defineLocale;
3187 utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
3188 utils_hooks__hooks.normalizeUnits = normalizeUnits;
3189 utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
3190
3191 var _moment__default = utils_hooks__hooks;
3192
3193 //! moment.js locale configuration
3194 //! locale : afrikaans (af)
3195 //! author : Werner Mollentze : https://github.com/wernerm
3196
3197 var af = _moment__default.defineLocale('af', {
3198 months : 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'),
3199 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'),
3200 weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
3201 weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
3202 weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
3203 meridiemParse: /vm|nm/i,
3204 isPM : function (input) {
3205 return /^nm$/i.test(input);
3206 },
3207 meridiem : function (hours, minutes, isLower) {
3208 if (hours < 12) {
3209 return isLower ? 'vm' : 'VM';
3210 } else {
3211 return isLower ? 'nm' : 'NM';
3212 }
3213 },
3214 longDateFormat : {
3215 LT : 'HH:mm',
3216 LTS : 'HH:mm:ss',
3217 L : 'DD/MM/YYYY',
3218 LL : 'D MMMM YYYY',
3219 LLL : 'D MMMM YYYY HH:mm',
3220 LLLL : 'dddd, D MMMM YYYY HH:mm'
3221 },
3222 calendar : {
3223 sameDay : '[Vandag om] LT',
3224 nextDay : '[Môre om] LT',
3225 nextWeek : 'dddd [om] LT',
3226 lastDay : '[Gister om] LT',
3227 lastWeek : '[Laas] dddd [om] LT',
3228 sameElse : 'L'
3229 },
3230 relativeTime : {
3231 future : 'oor %s',
3232 past : '%s gelede',
3233 s : '\'n paar sekondes',
3234 m : '\'n minuut',
3235 mm : '%d minute',
3236 h : '\'n uur',
3237 hh : '%d ure',
3238 d : '\'n dag',
3239 dd : '%d dae',
3240 M : '\'n maand',
3241 MM : '%d maande',
3242 y : '\'n jaar',
3243 yy : '%d jaar'
3244 },
3245 ordinalParse: /\d{1,2}(ste|de)/,
3246 ordinal : function (number) {
3247 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); // Thanks to Joris Röling : https://github.com/jjupiter
3248 },
3249 week : {
3250 dow : 1, // Maandag is die eerste dag van die week.
3251 doy : 4 // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
3252 }
3253 });
3254
3255 //! moment.js locale configuration
3256 //! locale : Moroccan Arabic (ar-ma)
3257 //! author : ElFadili Yassine : https://github.com/ElFadiliY
3258 //! author : Abdel Said : https://github.com/abdelsaid
3259
3260 var ar_ma = _moment__default.defineLocale('ar-ma', {
3261 months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
3262 monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
3263 weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
3264 weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
3265 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
3266 longDateFormat : {
3267 LT : 'HH:mm',
3268 LTS : 'HH:mm:ss',
3269 L : 'DD/MM/YYYY',
3270 LL : 'D MMMM YYYY',
3271 LLL : 'D MMMM YYYY HH:mm',
3272 LLLL : 'dddd D MMMM YYYY HH:mm'
3273 },
3274 calendar : {
3275 sameDay: '[اليوم على الساعة] LT',
3276 nextDay: '[غدا على الساعة] LT',
3277 nextWeek: 'dddd [على الساعة] LT',
3278 lastDay: '[أمس على الساعة] LT',
3279 lastWeek: 'dddd [على الساعة] LT',
3280 sameElse: 'L'
3281 },
3282 relativeTime : {
3283 future : 'في %s',
3284 past : 'منذ %s',
3285 s : 'ثوان',
3286 m : 'دقيقة',
3287 mm : '%d دقائق',
3288 h : 'ساعة',
3289 hh : '%d ساعات',
3290 d : 'يوم',
3291 dd : '%d أيام',
3292 M : 'شهر',
3293 MM : '%d أشهر',
3294 y : 'سنة',
3295 yy : '%d سنوات'
3296 },
3297 week : {
3298 dow : 6, // Saturday is the first day of the week.
3299 doy : 12 // The week that contains Jan 1st is the first week of the year.
3300 }
3301 });
3302
3303 //! moment.js locale configuration
3304 //! locale : Arabic Saudi Arabia (ar-sa)
3305 //! author : Suhail Alkowaileet : https://github.com/xsoh
3306
3307 var ar_sa__symbolMap = {
3308 '1': '١',
3309 '2': '٢',
3310 '3': '٣',
3311 '4': '٤',
3312 '5': '٥',
3313 '6': '٦',
3314 '7': '٧',
3315 '8': '٨',
3316 '9': '٩',
3317 '0': '٠'
3318 }, ar_sa__numberMap = {
3319 '١': '1',
3320 '٢': '2',
3321 '٣': '3',
3322 '٤': '4',
3323 '٥': '5',
3324 '٦': '6',
3325 '٧': '7',
3326 '٨': '8',
3327 '٩': '9',
3328 '٠': '0'
3329 };
3330
3331 var ar_sa = _moment__default.defineLocale('ar-sa', {
3332 months : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
3333 monthsShort : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
3334 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
3335 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
3336 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
3337 longDateFormat : {
3338 LT : 'HH:mm',
3339 LTS : 'HH:mm:ss',
3340 L : 'DD/MM/YYYY',
3341 LL : 'D MMMM YYYY',
3342 LLL : 'D MMMM YYYY HH:mm',
3343 LLLL : 'dddd D MMMM YYYY HH:mm'
3344 },
3345 meridiemParse: /ص|م/,
3346 isPM : function (input) {
3347 return 'م' === input;
3348 },
3349 meridiem : function (hour, minute, isLower) {
3350 if (hour < 12) {
3351 return 'ص';
3352 } else {
3353 return 'م';
3354 }
3355 },
3356 calendar : {
3357 sameDay: '[اليوم على الساعة] LT',
3358 nextDay: '[غدا على الساعة] LT',
3359 nextWeek: 'dddd [على الساعة] LT',
3360 lastDay: '[أمس على الساعة] LT',
3361 lastWeek: 'dddd [على الساعة] LT',
3362 sameElse: 'L'
3363 },
3364 relativeTime : {
3365 future : 'في %s',
3366 past : 'منذ %s',
3367 s : 'ثوان',
3368 m : 'دقيقة',
3369 mm : '%d دقائق',
3370 h : 'ساعة',
3371 hh : '%d ساعات',
3372 d : 'يوم',
3373 dd : '%d أيام',
3374 M : 'شهر',
3375 MM : '%d أشهر',
3376 y : 'سنة',
3377 yy : '%d سنوات'
3378 },
3379 preparse: function (string) {
3380 return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
3381 return ar_sa__numberMap[match];
3382 }).replace(/،/g, ',');
3383 },
3384 postformat: function (string) {
3385 return string.replace(/\d/g, function (match) {
3386 return ar_sa__symbolMap[match];
3387 }).replace(/,/g, '،');
3388 },
3389 week : {
3390 dow : 6, // Saturday is the first day of the week.
3391 doy : 12 // The week that contains Jan 1st is the first week of the year.
3392 }
3393 });
3394
3395 //! moment.js locale configuration
3396 //! locale : Tunisian Arabic (ar-tn)
3397
3398 var ar_tn = _moment__default.defineLocale('ar-tn', {
3399 months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
3400 monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
3401 weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
3402 weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
3403 weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
3404 longDateFormat: {
3405 LT: 'HH:mm',
3406 LTS: 'HH:mm:ss',
3407 L: 'DD/MM/YYYY',
3408 LL: 'D MMMM YYYY',
3409 LLL: 'D MMMM YYYY HH:mm',
3410 LLLL: 'dddd D MMMM YYYY HH:mm'
3411 },
3412 calendar: {
3413 sameDay: '[اليوم على الساعة] LT',
3414 nextDay: '[غدا على الساعة] LT',
3415 nextWeek: 'dddd [على الساعة] LT',
3416 lastDay: '[أمس على الساعة] LT',
3417 lastWeek: 'dddd [على الساعة] LT',
3418 sameElse: 'L'
3419 },
3420 relativeTime: {
3421 future: 'في %s',
3422 past: 'منذ %s',
3423 s: 'ثوان',
3424 m: 'دقيقة',
3425 mm: '%d دقائق',
3426 h: 'ساعة',
3427 hh: '%d ساعات',
3428 d: 'يوم',
3429 dd: '%d أيام',
3430 M: 'شهر',
3431 MM: '%d أشهر',
3432 y: 'سنة',
3433 yy: '%d سنوات'
3434 },
3435 week: {
3436 dow: 1, // Monday is the first day of the week.
3437 doy: 4 // The week that contains Jan 4th is the first week of the year.
3438 }
3439 });
3440
3441 //! moment.js locale configuration
3442 //! Locale: Arabic (ar)
3443 //! Author: Abdel Said: https://github.com/abdelsaid
3444 //! Changes in months, weekdays: Ahmed Elkhatib
3445 //! Native plural forms: forabi https://github.com/forabi
3446
3447 var ar__symbolMap = {
3448 '1': '١',
3449 '2': '٢',
3450 '3': '٣',
3451 '4': '٤',
3452 '5': '٥',
3453 '6': '٦',
3454 '7': '٧',
3455 '8': '٨',
3456 '9': '٩',
3457 '0': '٠'
3458 }, ar__numberMap = {
3459 '١': '1',
3460 '٢': '2',
3461 '٣': '3',
3462 '٤': '4',
3463 '٥': '5',
3464 '٦': '6',
3465 '٧': '7',
3466 '٨': '8',
3467 '٩': '9',
3468 '٠': '0'
3469 }, pluralForm = function (n) {
3470 return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
3471 }, plurals = {
3472 s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
3473 m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
3474 h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
3475 d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
3476 M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
3477 y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
3478 }, pluralize = function (u) {
3479 return function (number, withoutSuffix, string, isFuture) {
3480 var f = pluralForm(number),
3481 str = plurals[u][pluralForm(number)];
3482 if (f === 2) {
3483 str = str[withoutSuffix ? 0 : 1];
3484 }
3485 return str.replace(/%d/i, number);
3486 };
3487 }, ar__months = [
3488 'كانون الثاني يناير',
3489 'شباط فبراير',
3490 'آذار مارس',
3491 'نيسان أبريل',
3492 'أيار مايو',
3493 'حزيران يونيو',
3494 'تموز يوليو',
3495 'آب أغسطس',
3496 'أيلول سبتمبر',
3497 'تشرين الأول أكتوبر',
3498 'تشرين الثاني نوفمبر',
3499 'كانون الأول ديسمبر'
3500 ];
3501
3502 var ar = _moment__default.defineLocale('ar', {
3503 months : ar__months,
3504 monthsShort : ar__months,
3505 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
3506 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
3507 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
3508 longDateFormat : {
3509 LT : 'HH:mm',
3510 LTS : 'HH:mm:ss',
3511 L : 'D/\u200FM/\u200FYYYY',
3512 LL : 'D MMMM YYYY',
3513 LLL : 'D MMMM YYYY HH:mm',
3514 LLLL : 'dddd D MMMM YYYY HH:mm'
3515 },
3516 meridiemParse: /ص|م/,
3517 isPM : function (input) {
3518 return 'م' === input;
3519 },
3520 meridiem : function (hour, minute, isLower) {
3521 if (hour < 12) {
3522 return 'ص';
3523 } else {
3524 return 'م';
3525 }
3526 },
3527 calendar : {
3528 sameDay: '[اليوم عند الساعة] LT',
3529 nextDay: '[غدًا عند الساعة] LT',
3530 nextWeek: 'dddd [عند الساعة] LT',
3531 lastDay: '[أمس عند الساعة] LT',
3532 lastWeek: 'dddd [عند الساعة] LT',
3533 sameElse: 'L'
3534 },
3535 relativeTime : {
3536 future : 'بعد %s',
3537 past : 'منذ %s',
3538 s : pluralize('s'),
3539 m : pluralize('m'),
3540 mm : pluralize('m'),
3541 h : pluralize('h'),
3542 hh : pluralize('h'),
3543 d : pluralize('d'),
3544 dd : pluralize('d'),
3545 M : pluralize('M'),
3546 MM : pluralize('M'),
3547 y : pluralize('y'),
3548 yy : pluralize('y')
3549 },
3550 preparse: function (string) {
3551 return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
3552 return ar__numberMap[match];
3553 }).replace(/،/g, ',');
3554 },
3555 postformat: function (string) {
3556 return string.replace(/\d/g, function (match) {
3557 return ar__symbolMap[match];
3558 }).replace(/,/g, '،');
3559 },
3560 week : {
3561 dow : 6, // Saturday is the first day of the week.
3562 doy : 12 // The week that contains Jan 1st is the first week of the year.
3563 }
3564 });
3565
3566 //! moment.js locale configuration
3567 //! locale : azerbaijani (az)
3568 //! author : topchiyev : https://github.com/topchiyev
3569
3570 var az__suffixes = {
3571 1: '-inci',
3572 5: '-inci',
3573 8: '-inci',
3574 70: '-inci',
3575 80: '-inci',
3576 2: '-nci',
3577 7: '-nci',
3578 20: '-nci',
3579 50: '-nci',
3580 3: '-üncü',
3581 4: '-üncü',
3582 100: '-üncü',
3583 6: '-ncı',
3584 9: '-uncu',
3585 10: '-uncu',
3586 30: '-uncu',
3587 60: '-ıncı',
3588 90: '-ıncı'
3589 };
3590
3591 var az = _moment__default.defineLocale('az', {
3592 months : 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split('_'),
3593 monthsShort : 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'),
3594 weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
3595 weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
3596 weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
3597 longDateFormat : {
3598 LT : 'HH:mm',
3599 LTS : 'HH:mm:ss',
3600 L : 'DD.MM.YYYY',
3601 LL : 'D MMMM YYYY',
3602 LLL : 'D MMMM YYYY HH:mm',
3603 LLLL : 'dddd, D MMMM YYYY HH:mm'
3604 },
3605 calendar : {
3606 sameDay : '[bugün saat] LT',
3607 nextDay : '[sabah saat] LT',
3608 nextWeek : '[gələn həftə] dddd [saat] LT',
3609 lastDay : '[dünən] LT',
3610 lastWeek : '[keçən həftə] dddd [saat] LT',
3611 sameElse : 'L'
3612 },
3613 relativeTime : {
3614 future : '%s sonra',
3615 past : '%s əvvəl',
3616 s : 'birneçə saniyyə',
3617 m : 'bir dəqiqə',
3618 mm : '%d dəqiqə',
3619 h : 'bir saat',
3620 hh : '%d saat',
3621 d : 'bir gün',
3622 dd : '%d gün',
3623 M : 'bir ay',
3624 MM : '%d ay',
3625 y : 'bir il',
3626 yy : '%d il'
3627 },
3628 meridiemParse: /gecə|səhər|gündüz|axşam/,
3629 isPM : function (input) {
3630 return /^(gündüz|axşam)$/.test(input);
3631 },
3632 meridiem : function (hour, minute, isLower) {
3633 if (hour < 4) {
3634 return 'gecə';
3635 } else if (hour < 12) {
3636 return 'səhər';
3637 } else if (hour < 17) {
3638 return 'gündüz';
3639 } else {
3640 return 'axşam';
3641 }
3642 },
3643 ordinalParse: /\d{1,2}-(ıncı|inci|nci|üncü|ncı|uncu)/,
3644 ordinal : function (number) {
3645 if (number === 0) { // special case for zero
3646 return number + '-ıncı';
3647 }
3648 var a = number % 10,
3649 b = number % 100 - a,
3650 c = number >= 100 ? 100 : null;
3651 return number + (az__suffixes[a] || az__suffixes[b] || az__suffixes[c]);
3652 },
3653 week : {
3654 dow : 1, // Monday is the first day of the week.
3655 doy : 7 // The week that contains Jan 1st is the first week of the year.
3656 }
3657 });
3658
3659 //! moment.js locale configuration
3660 //! locale : belarusian (be)
3661 //! author : Dmitry Demidov : https://github.com/demidov91
3662 //! author: Praleska: http://praleska.pro/
3663 //! Author : Menelion Elensúle : https://github.com/Oire
3664
3665 function be__plural(word, num) {
3666 var forms = word.split('_');
3667 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
3668 }
3669 function be__relativeTimeWithPlural(number, withoutSuffix, key) {
3670 var format = {
3671 'mm': withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін',
3672 'hh': withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін',
3673 'dd': 'дзень_дні_дзён',
3674 'MM': 'месяц_месяцы_месяцаў',
3675 'yy': 'год_гады_гадоў'
3676 };
3677 if (key === 'm') {
3678 return withoutSuffix ? 'хвіліна' : 'хвіліну';
3679 }
3680 else if (key === 'h') {
3681 return withoutSuffix ? 'гадзіна' : 'гадзіну';
3682 }
3683 else {
3684 return number + ' ' + be__plural(format[key], +number);
3685 }
3686 }
3687 function be__monthsCaseReplace(m, format) {
3688 var months = {
3689 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
3690 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
3691 },
3692 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
3693 'accusative' :
3694 'nominative';
3695 return months[nounCase][m.month()];
3696 }
3697 function be__weekdaysCaseReplace(m, format) {
3698 var weekdays = {
3699 'nominative': 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'),
3700 'accusative': 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_')
3701 },
3702 nounCase = (/\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/).test(format) ?
3703 'accusative' :
3704 'nominative';
3705 return weekdays[nounCase][m.day()];
3706 }
3707
3708 var be = _moment__default.defineLocale('be', {
3709 months : be__monthsCaseReplace,
3710 monthsShort : 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'),
3711 weekdays : be__weekdaysCaseReplace,
3712 weekdaysShort : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
3713 weekdaysMin : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
3714 longDateFormat : {
3715 LT : 'HH:mm',
3716 LTS : 'HH:mm:ss',
3717 L : 'DD.MM.YYYY',
3718 LL : 'D MMMM YYYY г.',
3719 LLL : 'D MMMM YYYY г., HH:mm',
3720 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
3721 },
3722 calendar : {
3723 sameDay: '[Сёння ў] LT',
3724 nextDay: '[Заўтра ў] LT',
3725 lastDay: '[Учора ў] LT',
3726 nextWeek: function () {
3727 return '[У] dddd [ў] LT';
3728 },
3729 lastWeek: function () {
3730 switch (this.day()) {
3731 case 0:
3732 case 3:
3733 case 5:
3734 case 6:
3735 return '[У мінулую] dddd [ў] LT';
3736 case 1:
3737 case 2:
3738 case 4:
3739 return '[У мінулы] dddd [ў] LT';
3740 }
3741 },
3742 sameElse: 'L'
3743 },
3744 relativeTime : {
3745 future : 'праз %s',
3746 past : '%s таму',
3747 s : 'некалькі секунд',
3748 m : be__relativeTimeWithPlural,
3749 mm : be__relativeTimeWithPlural,
3750 h : be__relativeTimeWithPlural,
3751 hh : be__relativeTimeWithPlural,
3752 d : 'дзень',
3753 dd : be__relativeTimeWithPlural,
3754 M : 'месяц',
3755 MM : be__relativeTimeWithPlural,
3756 y : 'год',
3757 yy : be__relativeTimeWithPlural
3758 },
3759 meridiemParse: /ночы|раніцы|дня|вечара/,
3760 isPM : function (input) {
3761 return /^(дня|вечара)$/.test(input);
3762 },
3763 meridiem : function (hour, minute, isLower) {
3764 if (hour < 4) {
3765 return 'ночы';
3766 } else if (hour < 12) {
3767 return 'раніцы';
3768 } else if (hour < 17) {
3769 return 'дня';
3770 } else {
3771 return 'вечара';
3772 }
3773 },
3774 ordinalParse: /\d{1,2}-(і|ы|га)/,
3775 ordinal: function (number, period) {
3776 switch (period) {
3777 case 'M':
3778 case 'd':
3779 case 'DDD':
3780 case 'w':
3781 case 'W':
3782 return (number % 10 === 2 || number % 10 === 3) && (number % 100 !== 12 && number % 100 !== 13) ? number + '-і' : number + '-ы';
3783 case 'D':
3784 return number + '-га';
3785 default:
3786 return number;
3787 }
3788 },
3789 week : {
3790 dow : 1, // Monday is the first day of the week.
3791 doy : 7 // The week that contains Jan 1st is the first week of the year.
3792 }
3793 });
3794
3795 //! moment.js locale configuration
3796 //! locale : bulgarian (bg)
3797 //! author : Krasen Borisov : https://github.com/kraz
3798
3799 var bg = _moment__default.defineLocale('bg', {
3800 months : 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'.split('_'),
3801 monthsShort : 'янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'.split('_'),
3802 weekdays : 'неделя_понеделник_вторник_сряда_четвъртък_петък_събота'.split('_'),
3803 weekdaysShort : 'нед_пон_вто_сря_чет_пет_съб'.split('_'),
3804 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
3805 longDateFormat : {
3806 LT : 'H:mm',
3807 LTS : 'H:mm:ss',
3808 L : 'D.MM.YYYY',
3809 LL : 'D MMMM YYYY',
3810 LLL : 'D MMMM YYYY H:mm',
3811 LLLL : 'dddd, D MMMM YYYY H:mm'
3812 },
3813 calendar : {
3814 sameDay : '[Днес в] LT',
3815 nextDay : '[Утре в] LT',
3816 nextWeek : 'dddd [в] LT',
3817 lastDay : '[Вчера в] LT',
3818 lastWeek : function () {
3819 switch (this.day()) {
3820 case 0:
3821 case 3:
3822 case 6:
3823 return '[В изминалата] dddd [в] LT';
3824 case 1:
3825 case 2:
3826 case 4:
3827 case 5:
3828 return '[В изминалия] dddd [в] LT';
3829 }
3830 },
3831 sameElse : 'L'
3832 },
3833 relativeTime : {
3834 future : 'след %s',
3835 past : 'преди %s',
3836 s : 'няколко секунди',
3837 m : 'минута',
3838 mm : '%d минути',
3839 h : 'час',
3840 hh : '%d часа',
3841 d : 'ден',
3842 dd : '%d дни',
3843 M : 'месец',
3844 MM : '%d месеца',
3845 y : 'година',
3846 yy : '%d години'
3847 },
3848 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
3849 ordinal : function (number) {
3850 var lastDigit = number % 10,
3851 last2Digits = number % 100;
3852 if (number === 0) {
3853 return number + '-ев';
3854 } else if (last2Digits === 0) {
3855 return number + '-ен';
3856 } else if (last2Digits > 10 && last2Digits < 20) {
3857 return number + '-ти';
3858 } else if (lastDigit === 1) {
3859 return number + '-ви';
3860 } else if (lastDigit === 2) {
3861 return number + '-ри';
3862 } else if (lastDigit === 7 || lastDigit === 8) {
3863 return number + '-ми';
3864 } else {
3865 return number + '-ти';
3866 }
3867 },
3868 week : {
3869 dow : 1, // Monday is the first day of the week.
3870 doy : 7 // The week that contains Jan 1st is the first week of the year.
3871 }
3872 });
3873
3874 //! moment.js locale configuration
3875 //! locale : Bengali (bn)
3876 //! author : Kaushik Gandhi : https://github.com/kaushikgandhi
3877
3878 var bn__symbolMap = {
3879 '1': '১',
3880 '2': '২',
3881 '3': '৩',
3882 '4': '৪',
3883 '5': '৫',
3884 '6': '৬',
3885 '7': '৭',
3886 '8': '৮',
3887 '9': '৯',
3888 '0': '০'
3889 },
3890 bn__numberMap = {
3891 '১': '1',
3892 '২': '2',
3893 '৩': '3',
3894 '৪': '4',
3895 '৫': '5',
3896 '৬': '6',
3897 '৭': '7',
3898 '৮': '8',
3899 '৯': '9',
3900 '০': '0'
3901 };
3902
3903 var bn = _moment__default.defineLocale('bn', {
3904 months : 'জানুয়ারী_ফেবুয়ারী_মার্চ_এপ্রিল_মে_জুন_জুলাই_অগাস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'),
3905 monthsShort : 'জানু_ফেব_মার্চ_এপর_মে_জুন_জুল_অগ_সেপ্ট_অক্টো_নভ_ডিসেম্'.split('_'),
3906 weekdays : 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পত্তিবার_শুক্রুবার_শনিবার'.split('_'),
3907 weekdaysShort : 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পত্তি_শুক্রু_শনি'.split('_'),
3908 weekdaysMin : 'রব_সম_মঙ্গ_বু_ব্রিহ_শু_শনি'.split('_'),
3909 longDateFormat : {
3910 LT : 'A h:mm সময়',
3911 LTS : 'A h:mm:ss সময়',
3912 L : 'DD/MM/YYYY',
3913 LL : 'D MMMM YYYY',
3914 LLL : 'D MMMM YYYY, A h:mm সময়',
3915 LLLL : 'dddd, D MMMM YYYY, A h:mm সময়'
3916 },
3917 calendar : {
3918 sameDay : '[আজ] LT',
3919 nextDay : '[আগামীকাল] LT',
3920 nextWeek : 'dddd, LT',
3921 lastDay : '[গতকাল] LT',
3922 lastWeek : '[গত] dddd, LT',
3923 sameElse : 'L'
3924 },
3925 relativeTime : {
3926 future : '%s পরে',
3927 past : '%s আগে',
3928 s : 'কএক সেকেন্ড',
3929 m : 'এক মিনিট',
3930 mm : '%d মিনিট',
3931 h : 'এক ঘন্টা',
3932 hh : '%d ঘন্টা',
3933 d : 'এক দিন',
3934 dd : '%d দিন',
3935 M : 'এক মাস',
3936 MM : '%d মাস',
3937 y : 'এক বছর',
3938 yy : '%d বছর'
3939 },
3940 preparse: function (string) {
3941 return string.replace(/[১২৩৪৫৬৭৮৯০]/g, function (match) {
3942 return bn__numberMap[match];
3943 });
3944 },
3945 postformat: function (string) {
3946 return string.replace(/\d/g, function (match) {
3947 return bn__symbolMap[match];
3948 });
3949 },
3950 meridiemParse: /রাত|সকাল|দুপুর|বিকেল|রাত/,
3951 isPM: function (input) {
3952 return /^(দুপুর|বিকেল|রাত)$/.test(input);
3953 },
3954 //Bengali is a vast language its spoken
3955 //in different forms in various parts of the world.
3956 //I have just generalized with most common one used
3957 meridiem : function (hour, minute, isLower) {
3958 if (hour < 4) {
3959 return 'রাত';
3960 } else if (hour < 10) {
3961 return 'সকাল';
3962 } else if (hour < 17) {
3963 return 'দুপুর';
3964 } else if (hour < 20) {
3965 return 'বিকেল';
3966 } else {
3967 return 'রাত';
3968 }
3969 },
3970 week : {
3971 dow : 0, // Sunday is the first day of the week.
3972 doy : 6 // The week that contains Jan 1st is the first week of the year.
3973 }
3974 });
3975
3976 //! moment.js locale configuration
3977 //! locale : tibetan (bo)
3978 //! author : Thupten N. Chakrishar : https://github.com/vajradog
3979
3980 var bo__symbolMap = {
3981 '1': '༡',
3982 '2': '༢',
3983 '3': '༣',
3984 '4': '༤',
3985 '5': '༥',
3986 '6': '༦',
3987 '7': '༧',
3988 '8': '༨',
3989 '9': '༩',
3990 '0': '༠'
3991 },
3992 bo__numberMap = {
3993 '༡': '1',
3994 '༢': '2',
3995 '༣': '3',
3996 '༤': '4',
3997 '༥': '5',
3998 '༦': '6',
3999 '༧': '7',
4000 '༨': '8',
4001 '༩': '9',
4002 '༠': '0'
4003 };
4004
4005 var bo = _moment__default.defineLocale('bo', {
4006 months : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
4007 monthsShort : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
4008 weekdays : 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'),
4009 weekdaysShort : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
4010 weekdaysMin : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
4011 longDateFormat : {
4012 LT : 'A h:mm',
4013 LTS : 'A h:mm:ss',
4014 L : 'DD/MM/YYYY',
4015 LL : 'D MMMM YYYY',
4016 LLL : 'D MMMM YYYY, A h:mm',
4017 LLLL : 'dddd, D MMMM YYYY, A h:mm'
4018 },
4019 calendar : {
4020 sameDay : '[དི་རིང] LT',
4021 nextDay : '[སང་ཉིན] LT',
4022 nextWeek : '[བདུན་ཕྲག་རྗེས་མ], LT',
4023 lastDay : '[ཁ་སང] LT',
4024 lastWeek : '[བདུན་ཕྲག་མཐའ་མ] dddd, LT',
4025 sameElse : 'L'
4026 },
4027 relativeTime : {
4028 future : '%s ལ་',
4029 past : '%s སྔན་ལ',
4030 s : 'ལམ་སང',
4031 m : 'སྐར་མ་གཅིག',
4032 mm : '%d སྐར་མ',
4033 h : 'ཆུ་ཚོད་གཅིག',
4034 hh : '%d ཆུ་ཚོད',
4035 d : 'ཉིན་གཅིག',
4036 dd : '%d ཉིན་',
4037 M : 'ཟླ་བ་གཅིག',
4038 MM : '%d ཟླ་བ',
4039 y : 'ལོ་གཅིག',
4040 yy : '%d ལོ'
4041 },
4042 preparse: function (string) {
4043 return string.replace(/[༡༢༣༤༥༦༧༨༩༠]/g, function (match) {
4044 return bo__numberMap[match];
4045 });
4046 },
4047 postformat: function (string) {
4048 return string.replace(/\d/g, function (match) {
4049 return bo__symbolMap[match];
4050 });
4051 },
4052 meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
4053 isPM: function (input) {
4054 return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
4055 },
4056 meridiem : function (hour, minute, isLower) {
4057 if (hour < 4) {
4058 return 'མཚན་མོ';
4059 } else if (hour < 10) {
4060 return 'ཞོགས་ཀས';
4061 } else if (hour < 17) {
4062 return 'ཉིན་གུང';
4063 } else if (hour < 20) {
4064 return 'དགོང་དག';
4065 } else {
4066 return 'མཚན་མོ';
4067 }
4068 },
4069 week : {
4070 dow : 0, // Sunday is the first day of the week.
4071 doy : 6 // The week that contains Jan 1st is the first week of the year.
4072 }
4073 });
4074
4075 //! moment.js locale configuration
4076 //! locale : breton (br)
4077 //! author : Jean-Baptiste Le Duigou : https://github.com/jbleduigou
4078
4079 function relativeTimeWithMutation(number, withoutSuffix, key) {
4080 var format = {
4081 'mm': 'munutenn',
4082 'MM': 'miz',
4083 'dd': 'devezh'
4084 };
4085 return number + ' ' + mutation(format[key], number);
4086 }
4087 function specialMutationForYears(number) {
4088 switch (lastNumber(number)) {
4089 case 1:
4090 case 3:
4091 case 4:
4092 case 5:
4093 case 9:
4094 return number + ' bloaz';
4095 default:
4096 return number + ' vloaz';
4097 }
4098 }
4099 function lastNumber(number) {
4100 if (number > 9) {
4101 return lastNumber(number % 10);
4102 }
4103 return number;
4104 }
4105 function mutation(text, number) {
4106 if (number === 2) {
4107 return softMutation(text);
4108 }
4109 return text;
4110 }
4111 function softMutation(text) {
4112 var mutationTable = {
4113 'm': 'v',
4114 'b': 'v',
4115 'd': 'z'
4116 };
4117 if (mutationTable[text.charAt(0)] === undefined) {
4118 return text;
4119 }
4120 return mutationTable[text.charAt(0)] + text.substring(1);
4121 }
4122
4123 var br = _moment__default.defineLocale('br', {
4124 months : 'Genver_C\'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'),
4125 monthsShort : 'Gen_C\'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'),
4126 weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
4127 weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
4128 weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
4129 longDateFormat : {
4130 LT : 'h[e]mm A',
4131 LTS : 'h[e]mm:ss A',
4132 L : 'DD/MM/YYYY',
4133 LL : 'D [a viz] MMMM YYYY',
4134 LLL : 'D [a viz] MMMM YYYY h[e]mm A',
4135 LLLL : 'dddd, D [a viz] MMMM YYYY h[e]mm A'
4136 },
4137 calendar : {
4138 sameDay : '[Hiziv da] LT',
4139 nextDay : '[Warc\'hoazh da] LT',
4140 nextWeek : 'dddd [da] LT',
4141 lastDay : '[Dec\'h da] LT',
4142 lastWeek : 'dddd [paset da] LT',
4143 sameElse : 'L'
4144 },
4145 relativeTime : {
4146 future : 'a-benn %s',
4147 past : '%s \'zo',
4148 s : 'un nebeud segondennoù',
4149 m : 'ur vunutenn',
4150 mm : relativeTimeWithMutation,
4151 h : 'un eur',
4152 hh : '%d eur',
4153 d : 'un devezh',
4154 dd : relativeTimeWithMutation,
4155 M : 'ur miz',
4156 MM : relativeTimeWithMutation,
4157 y : 'ur bloaz',
4158 yy : specialMutationForYears
4159 },
4160 ordinalParse: /\d{1,2}(añ|vet)/,
4161 ordinal : function (number) {
4162 var output = (number === 1) ? 'añ' : 'vet';
4163 return number + output;
4164 },
4165 week : {
4166 dow : 1, // Monday is the first day of the week.
4167 doy : 4 // The week that contains Jan 4th is the first week of the year.
4168 }
4169 });
4170
4171 //! moment.js locale configuration
4172 //! locale : bosnian (bs)
4173 //! author : Nedim Cholich : https://github.com/frontyard
4174 //! based on (hr) translation by Bojan Marković
4175
4176 function bs__translate(number, withoutSuffix, key) {
4177 var result = number + ' ';
4178 switch (key) {
4179 case 'm':
4180 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
4181 case 'mm':
4182 if (number === 1) {
4183 result += 'minuta';
4184 } else if (number === 2 || number === 3 || number === 4) {
4185 result += 'minute';
4186 } else {
4187 result += 'minuta';
4188 }
4189 return result;
4190 case 'h':
4191 return withoutSuffix ? 'jedan sat' : 'jednog sata';
4192 case 'hh':
4193 if (number === 1) {
4194 result += 'sat';
4195 } else if (number === 2 || number === 3 || number === 4) {
4196 result += 'sata';
4197 } else {
4198 result += 'sati';
4199 }
4200 return result;
4201 case 'dd':
4202 if (number === 1) {
4203 result += 'dan';
4204 } else {
4205 result += 'dana';
4206 }
4207 return result;
4208 case 'MM':
4209 if (number === 1) {
4210 result += 'mjesec';
4211 } else if (number === 2 || number === 3 || number === 4) {
4212 result += 'mjeseca';
4213 } else {
4214 result += 'mjeseci';
4215 }
4216 return result;
4217 case 'yy':
4218 if (number === 1) {
4219 result += 'godina';
4220 } else if (number === 2 || number === 3 || number === 4) {
4221 result += 'godine';
4222 } else {
4223 result += 'godina';
4224 }
4225 return result;
4226 }
4227 }
4228
4229 var bs = _moment__default.defineLocale('bs', {
4230 months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
4231 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
4232 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
4233 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
4234 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
4235 longDateFormat : {
4236 LT : 'H:mm',
4237 LTS : 'H:mm:ss',
4238 L : 'DD. MM. YYYY',
4239 LL : 'D. MMMM YYYY',
4240 LLL : 'D. MMMM YYYY H:mm',
4241 LLLL : 'dddd, D. MMMM YYYY H:mm'
4242 },
4243 calendar : {
4244 sameDay : '[danas u] LT',
4245 nextDay : '[sutra u] LT',
4246 nextWeek : function () {
4247 switch (this.day()) {
4248 case 0:
4249 return '[u] [nedjelju] [u] LT';
4250 case 3:
4251 return '[u] [srijedu] [u] LT';
4252 case 6:
4253 return '[u] [subotu] [u] LT';
4254 case 1:
4255 case 2:
4256 case 4:
4257 case 5:
4258 return '[u] dddd [u] LT';
4259 }
4260 },
4261 lastDay : '[jučer u] LT',
4262 lastWeek : function () {
4263 switch (this.day()) {
4264 case 0:
4265 case 3:
4266 return '[prošlu] dddd [u] LT';
4267 case 6:
4268 return '[prošle] [subote] [u] LT';
4269 case 1:
4270 case 2:
4271 case 4:
4272 case 5:
4273 return '[prošli] dddd [u] LT';
4274 }
4275 },
4276 sameElse : 'L'
4277 },
4278 relativeTime : {
4279 future : 'za %s',
4280 past : 'prije %s',
4281 s : 'par sekundi',
4282 m : bs__translate,
4283 mm : bs__translate,
4284 h : bs__translate,
4285 hh : bs__translate,
4286 d : 'dan',
4287 dd : bs__translate,
4288 M : 'mjesec',
4289 MM : bs__translate,
4290 y : 'godinu',
4291 yy : bs__translate
4292 },
4293 ordinalParse: /\d{1,2}\./,
4294 ordinal : '%d.',
4295 week : {
4296 dow : 1, // Monday is the first day of the week.
4297 doy : 7 // The week that contains Jan 1st is the first week of the year.
4298 }
4299 });
4300
4301 //! moment.js locale configuration
4302 //! locale : catalan (ca)
4303 //! author : Juan G. Hurtado : https://github.com/juanghurtado
4304
4305 var ca = _moment__default.defineLocale('ca', {
4306 months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
4307 monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
4308 weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
4309 weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
4310 weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
4311 longDateFormat : {
4312 LT : 'H:mm',
4313 LTS : 'LT:ss',
4314 L : 'DD/MM/YYYY',
4315 LL : 'D MMMM YYYY',
4316 LLL : 'D MMMM YYYY H:mm',
4317 LLLL : 'dddd D MMMM YYYY H:mm'
4318 },
4319 calendar : {
4320 sameDay : function () {
4321 return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
4322 },
4323 nextDay : function () {
4324 return '[demà a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
4325 },
4326 nextWeek : function () {
4327 return 'dddd [a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
4328 },
4329 lastDay : function () {
4330 return '[ahir a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
4331 },
4332 lastWeek : function () {
4333 return '[el] dddd [passat a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
4334 },
4335 sameElse : 'L'
4336 },
4337 relativeTime : {
4338 future : 'en %s',
4339 past : 'fa %s',
4340 s : 'uns segons',
4341 m : 'un minut',
4342 mm : '%d minuts',
4343 h : 'una hora',
4344 hh : '%d hores',
4345 d : 'un dia',
4346 dd : '%d dies',
4347 M : 'un mes',
4348 MM : '%d mesos',
4349 y : 'un any',
4350 yy : '%d anys'
4351 },
4352 ordinalParse: /\d{1,2}(r|n|t|è|a)/,
4353 ordinal : function (number, period) {
4354 var output = (number === 1) ? 'r' :
4355 (number === 2) ? 'n' :
4356 (number === 3) ? 'r' :
4357 (number === 4) ? 't' : 'è';
4358 if (period === 'w' || period === 'W') {
4359 output = 'a';
4360 }
4361 return number + output;
4362 },
4363 week : {
4364 dow : 1, // Monday is the first day of the week.
4365 doy : 4 // The week that contains Jan 4th is the first week of the year.
4366 }
4367 });
4368
4369 //! moment.js locale configuration
4370 //! locale : czech (cs)
4371 //! author : petrbela : https://github.com/petrbela
4372
4373 var cs__months = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_'),
4374 cs__monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_');
4375 function cs__plural(n) {
4376 return (n > 1) && (n < 5) && (~~(n / 10) !== 1);
4377 }
4378 function cs__translate(number, withoutSuffix, key, isFuture) {
4379 var result = number + ' ';
4380 switch (key) {
4381 case 's': // a few seconds / in a few seconds / a few seconds ago
4382 return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
4383 case 'm': // a minute / in a minute / a minute ago
4384 return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
4385 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
4386 if (withoutSuffix || isFuture) {
4387 return result + (cs__plural(number) ? 'minuty' : 'minut');
4388 } else {
4389 return result + 'minutami';
4390 }
4391 break;
4392 case 'h': // an hour / in an hour / an hour ago
4393 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
4394 case 'hh': // 9 hours / in 9 hours / 9 hours ago
4395 if (withoutSuffix || isFuture) {
4396 return result + (cs__plural(number) ? 'hodiny' : 'hodin');
4397 } else {
4398 return result + 'hodinami';
4399 }
4400 break;
4401 case 'd': // a day / in a day / a day ago
4402 return (withoutSuffix || isFuture) ? 'den' : 'dnem';
4403 case 'dd': // 9 days / in 9 days / 9 days ago
4404 if (withoutSuffix || isFuture) {
4405 return result + (cs__plural(number) ? 'dny' : 'dní');
4406 } else {
4407 return result + 'dny';
4408 }
4409 break;
4410 case 'M': // a month / in a month / a month ago
4411 return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
4412 case 'MM': // 9 months / in 9 months / 9 months ago
4413 if (withoutSuffix || isFuture) {
4414 return result + (cs__plural(number) ? 'měsíce' : 'měsíců');
4415 } else {
4416 return result + 'měsíci';
4417 }
4418 break;
4419 case 'y': // a year / in a year / a year ago
4420 return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
4421 case 'yy': // 9 years / in 9 years / 9 years ago
4422 if (withoutSuffix || isFuture) {
4423 return result + (cs__plural(number) ? 'roky' : 'let');
4424 } else {
4425 return result + 'lety';
4426 }
4427 break;
4428 }
4429 }
4430
4431 var cs = _moment__default.defineLocale('cs', {
4432 months : cs__months,
4433 monthsShort : cs__monthsShort,
4434 monthsParse : (function (months, monthsShort) {
4435 var i, _monthsParse = [];
4436 for (i = 0; i < 12; i++) {
4437 // use custom parser to solve problem with July (červenec)
4438 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
4439 }
4440 return _monthsParse;
4441 }(cs__months, cs__monthsShort)),
4442 weekdays : 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
4443 weekdaysShort : 'ne_po_út_st_čt_pá_so'.split('_'),
4444 weekdaysMin : 'ne_po_út_st_čt_pá_so'.split('_'),
4445 longDateFormat : {
4446 LT: 'H:mm',
4447 LTS : 'H:mm:ss',
4448 L : 'DD.MM.YYYY',
4449 LL : 'D. MMMM YYYY',
4450 LLL : 'D. MMMM YYYY H:mm',
4451 LLLL : 'dddd D. MMMM YYYY H:mm'
4452 },
4453 calendar : {
4454 sameDay: '[dnes v] LT',
4455 nextDay: '[zítra v] LT',
4456 nextWeek: function () {
4457 switch (this.day()) {
4458 case 0:
4459 return '[v neděli v] LT';
4460 case 1:
4461 case 2:
4462 return '[v] dddd [v] LT';
4463 case 3:
4464 return '[ve středu v] LT';
4465 case 4:
4466 return '[ve čtvrtek v] LT';
4467 case 5:
4468 return '[v pátek v] LT';
4469 case 6:
4470 return '[v sobotu v] LT';
4471 }
4472 },
4473 lastDay: '[včera v] LT',
4474 lastWeek: function () {
4475 switch (this.day()) {
4476 case 0:
4477 return '[minulou neděli v] LT';
4478 case 1:
4479 case 2:
4480 return '[minulé] dddd [v] LT';
4481 case 3:
4482 return '[minulou středu v] LT';
4483 case 4:
4484 case 5:
4485 return '[minulý] dddd [v] LT';
4486 case 6:
4487 return '[minulou sobotu v] LT';
4488 }
4489 },
4490 sameElse: 'L'
4491 },
4492 relativeTime : {
4493 future : 'za %s',
4494 past : 'před %s',
4495 s : cs__translate,
4496 m : cs__translate,
4497 mm : cs__translate,
4498 h : cs__translate,
4499 hh : cs__translate,
4500 d : cs__translate,
4501 dd : cs__translate,
4502 M : cs__translate,
4503 MM : cs__translate,
4504 y : cs__translate,
4505 yy : cs__translate
4506 },
4507 ordinalParse : /\d{1,2}\./,
4508 ordinal : '%d.',
4509 week : {
4510 dow : 1, // Monday is the first day of the week.
4511 doy : 4 // The week that contains Jan 4th is the first week of the year.
4512 }
4513 });
4514
4515 //! moment.js locale configuration
4516 //! locale : chuvash (cv)
4517 //! author : Anatoly Mironov : https://github.com/mirontoli
4518
4519 var cv = _moment__default.defineLocale('cv', {
4520 months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
4521 monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
4522 weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
4523 weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
4524 weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
4525 longDateFormat : {
4526 LT : 'HH:mm',
4527 LTS : 'HH:mm:ss',
4528 L : 'DD-MM-YYYY',
4529 LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
4530 LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm',
4531 LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm'
4532 },
4533 calendar : {
4534 sameDay: '[Паян] LT [сехетре]',
4535 nextDay: '[Ыран] LT [сехетре]',
4536 lastDay: '[Ӗнер] LT [сехетре]',
4537 nextWeek: '[Ҫитес] dddd LT [сехетре]',
4538 lastWeek: '[Иртнӗ] dddd LT [сехетре]',
4539 sameElse: 'L'
4540 },
4541 relativeTime : {
4542 future : function (output) {
4543 var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
4544 return output + affix;
4545 },
4546 past : '%s каялла',
4547 s : 'пӗр-ик ҫеккунт',
4548 m : 'пӗр минут',
4549 mm : '%d минут',
4550 h : 'пӗр сехет',
4551 hh : '%d сехет',
4552 d : 'пӗр кун',
4553 dd : '%d кун',
4554 M : 'пӗр уйӑх',
4555 MM : '%d уйӑх',
4556 y : 'пӗр ҫул',
4557 yy : '%d ҫул'
4558 },
4559 ordinalParse: /\d{1,2}-мӗш/,
4560 ordinal : '%d-мӗш',
4561 week : {
4562 dow : 1, // Monday is the first day of the week.
4563 doy : 7 // The week that contains Jan 1st is the first week of the year.
4564 }
4565 });
4566
4567 //! moment.js locale configuration
4568 //! locale : Welsh (cy)
4569 //! author : Robert Allen
4570
4571 var cy = _moment__default.defineLocale('cy', {
4572 months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'),
4573 monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'),
4574 weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
4575 weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
4576 weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
4577 // time formats are the same as en-gb
4578 longDateFormat: {
4579 LT: 'HH:mm',
4580 LTS : 'HH:mm:ss',
4581 L: 'DD/MM/YYYY',
4582 LL: 'D MMMM YYYY',
4583 LLL: 'D MMMM YYYY HH:mm',
4584 LLLL: 'dddd, D MMMM YYYY HH:mm'
4585 },
4586 calendar: {
4587 sameDay: '[Heddiw am] LT',
4588 nextDay: '[Yfory am] LT',
4589 nextWeek: 'dddd [am] LT',
4590 lastDay: '[Ddoe am] LT',
4591 lastWeek: 'dddd [diwethaf am] LT',
4592 sameElse: 'L'
4593 },
4594 relativeTime: {
4595 future: 'mewn %s',
4596 past: '%s yn ôl',
4597 s: 'ychydig eiliadau',
4598 m: 'munud',
4599 mm: '%d munud',
4600 h: 'awr',
4601 hh: '%d awr',
4602 d: 'diwrnod',
4603 dd: '%d diwrnod',
4604 M: 'mis',
4605 MM: '%d mis',
4606 y: 'blwyddyn',
4607 yy: '%d flynedd'
4608 },
4609 ordinalParse: /\d{1,2}(fed|ain|af|il|ydd|ed|eg)/,
4610 // traditional ordinal numbers above 31 are not commonly used in colloquial Welsh
4611 ordinal: function (number) {
4612 var b = number,
4613 output = '',
4614 lookup = [
4615 '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed
4616 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed
4617 ];
4618 if (b > 20) {
4619 if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) {
4620 output = 'fed'; // not 30ain, 70ain or 90ain
4621 } else {
4622 output = 'ain';
4623 }
4624 } else if (b > 0) {
4625 output = lookup[b];
4626 }
4627 return number + output;
4628 },
4629 week : {
4630 dow : 1, // Monday is the first day of the week.
4631 doy : 4 // The week that contains Jan 4th is the first week of the year.
4632 }
4633 });
4634
4635 //! moment.js locale configuration
4636 //! locale : danish (da)
4637 //! author : Ulrik Nielsen : https://github.com/mrbase
4638
4639 var da = _moment__default.defineLocale('da', {
4640 months : 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'),
4641 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
4642 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
4643 weekdaysShort : 'søn_man_tir_ons_tor_fre_lør'.split('_'),
4644 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
4645 longDateFormat : {
4646 LT : 'HH:mm',
4647 LTS : 'HH:mm:ss',
4648 L : 'DD/MM/YYYY',
4649 LL : 'D. MMMM YYYY',
4650 LLL : 'D. MMMM YYYY HH:mm',
4651 LLLL : 'dddd [d.] D. MMMM YYYY HH:mm'
4652 },
4653 calendar : {
4654 sameDay : '[I dag kl.] LT',
4655 nextDay : '[I morgen kl.] LT',
4656 nextWeek : 'dddd [kl.] LT',
4657 lastDay : '[I går kl.] LT',
4658 lastWeek : '[sidste] dddd [kl] LT',
4659 sameElse : 'L'
4660 },
4661 relativeTime : {
4662 future : 'om %s',
4663 past : '%s siden',
4664 s : 'få sekunder',
4665 m : 'et minut',
4666 mm : '%d minutter',
4667 h : 'en time',
4668 hh : '%d timer',
4669 d : 'en dag',
4670 dd : '%d dage',
4671 M : 'en måned',
4672 MM : '%d måneder',
4673 y : 'et år',
4674 yy : '%d år'
4675 },
4676 ordinalParse: /\d{1,2}\./,
4677 ordinal : '%d.',
4678 week : {
4679 dow : 1, // Monday is the first day of the week.
4680 doy : 4 // The week that contains Jan 4th is the first week of the year.
4681 }
4682 });
4683
4684 //! moment.js locale configuration
4685 //! locale : austrian german (de-at)
4686 //! author : lluchs : https://github.com/lluchs
4687 //! author: Menelion Elensúle: https://github.com/Oire
4688 //! author : Martin Groller : https://github.com/MadMG
4689
4690 function de_at__processRelativeTime(number, withoutSuffix, key, isFuture) {
4691 var format = {
4692 'm': ['eine Minute', 'einer Minute'],
4693 'h': ['eine Stunde', 'einer Stunde'],
4694 'd': ['ein Tag', 'einem Tag'],
4695 'dd': [number + ' Tage', number + ' Tagen'],
4696 'M': ['ein Monat', 'einem Monat'],
4697 'MM': [number + ' Monate', number + ' Monaten'],
4698 'y': ['ein Jahr', 'einem Jahr'],
4699 'yy': [number + ' Jahre', number + ' Jahren']
4700 };
4701 return withoutSuffix ? format[key][0] : format[key][1];
4702 }
4703
4704 var de_at = _moment__default.defineLocale('de-at', {
4705 months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
4706 monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
4707 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
4708 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
4709 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
4710 longDateFormat : {
4711 LT: 'HH:mm',
4712 LTS: 'HH:mm:ss',
4713 L : 'DD.MM.YYYY',
4714 LL : 'D. MMMM YYYY',
4715 LLL : 'D. MMMM YYYY HH:mm',
4716 LLLL : 'dddd, D. MMMM YYYY HH:mm'
4717 },
4718 calendar : {
4719 sameDay: '[Heute um] LT [Uhr]',
4720 sameElse: 'L',
4721 nextDay: '[Morgen um] LT [Uhr]',
4722 nextWeek: 'dddd [um] LT [Uhr]',
4723 lastDay: '[Gestern um] LT [Uhr]',
4724 lastWeek: '[letzten] dddd [um] LT [Uhr]'
4725 },
4726 relativeTime : {
4727 future : 'in %s',
4728 past : 'vor %s',
4729 s : 'ein paar Sekunden',
4730 m : de_at__processRelativeTime,
4731 mm : '%d Minuten',
4732 h : de_at__processRelativeTime,
4733 hh : '%d Stunden',
4734 d : de_at__processRelativeTime,
4735 dd : de_at__processRelativeTime,
4736 M : de_at__processRelativeTime,
4737 MM : de_at__processRelativeTime,
4738 y : de_at__processRelativeTime,
4739 yy : de_at__processRelativeTime
4740 },
4741 ordinalParse: /\d{1,2}\./,
4742 ordinal : '%d.',
4743 week : {
4744 dow : 1, // Monday is the first day of the week.
4745 doy : 4 // The week that contains Jan 4th is the first week of the year.
4746 }
4747 });
4748
4749 //! moment.js locale configuration
4750 //! locale : german (de)
4751 //! author : lluchs : https://github.com/lluchs
4752 //! author: Menelion Elensúle: https://github.com/Oire
4753
4754 function de__processRelativeTime(number, withoutSuffix, key, isFuture) {
4755 var format = {
4756 'm': ['eine Minute', 'einer Minute'],
4757 'h': ['eine Stunde', 'einer Stunde'],
4758 'd': ['ein Tag', 'einem Tag'],
4759 'dd': [number + ' Tage', number + ' Tagen'],
4760 'M': ['ein Monat', 'einem Monat'],
4761 'MM': [number + ' Monate', number + ' Monaten'],
4762 'y': ['ein Jahr', 'einem Jahr'],
4763 'yy': [number + ' Jahre', number + ' Jahren']
4764 };
4765 return withoutSuffix ? format[key][0] : format[key][1];
4766 }
4767
4768 var de = _moment__default.defineLocale('de', {
4769 months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
4770 monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
4771 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
4772 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
4773 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
4774 longDateFormat : {
4775 LT: 'HH:mm',
4776 LTS: 'HH:mm:ss',
4777 L : 'DD.MM.YYYY',
4778 LL : 'D. MMMM YYYY',
4779 LLL : 'D. MMMM YYYY HH:mm',
4780 LLLL : 'dddd, D. MMMM YYYY HH:mm'
4781 },
4782 calendar : {
4783 sameDay: '[Heute um] LT [Uhr]',
4784 sameElse: 'L',
4785 nextDay: '[Morgen um] LT [Uhr]',
4786 nextWeek: 'dddd [um] LT [Uhr]',
4787 lastDay: '[Gestern um] LT [Uhr]',
4788 lastWeek: '[letzten] dddd [um] LT [Uhr]'
4789 },
4790 relativeTime : {
4791 future : 'in %s',
4792 past : 'vor %s',
4793 s : 'ein paar Sekunden',
4794 m : de__processRelativeTime,
4795 mm : '%d Minuten',
4796 h : de__processRelativeTime,
4797 hh : '%d Stunden',
4798 d : de__processRelativeTime,
4799 dd : de__processRelativeTime,
4800 M : de__processRelativeTime,
4801 MM : de__processRelativeTime,
4802 y : de__processRelativeTime,
4803 yy : de__processRelativeTime
4804 },
4805 ordinalParse: /\d{1,2}\./,
4806 ordinal : '%d.',
4807 week : {
4808 dow : 1, // Monday is the first day of the week.
4809 doy : 4 // The week that contains Jan 4th is the first week of the year.
4810 }
4811 });
4812
4813 //! moment.js locale configuration
4814 //! locale : modern greek (el)
4815 //! author : Aggelos Karalias : https://github.com/mehiel
4816
4817 var el = _moment__default.defineLocale('el', {
4818 monthsNominativeEl : 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'),
4819 monthsGenitiveEl : 'Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου'.split('_'),
4820 months : function (momentToFormat, format) {
4821 if (/D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
4822 return this._monthsGenitiveEl[momentToFormat.month()];
4823 } else {
4824 return this._monthsNominativeEl[momentToFormat.month()];
4825 }
4826 },
4827 monthsShort : 'Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ'.split('_'),
4828 weekdays : 'Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο'.split('_'),
4829 weekdaysShort : 'Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ'.split('_'),
4830 weekdaysMin : 'Κυ_Δε_Τρ_Τε_Πε_Πα_Σα'.split('_'),
4831 meridiem : function (hours, minutes, isLower) {
4832 if (hours > 11) {
4833 return isLower ? 'μμ' : 'ΜΜ';
4834 } else {
4835 return isLower ? 'πμ' : 'ΠΜ';
4836 }
4837 },
4838 isPM : function (input) {
4839 return ((input + '').toLowerCase()[0] === 'μ');
4840 },
4841 meridiemParse : /[ΠΜ]\.?Μ?\.?/i,
4842 longDateFormat : {
4843 LT : 'h:mm A',
4844 LTS : 'h:mm:ss A',
4845 L : 'DD/MM/YYYY',
4846 LL : 'D MMMM YYYY',
4847 LLL : 'D MMMM YYYY h:mm A',
4848 LLLL : 'dddd, D MMMM YYYY h:mm A'
4849 },
4850 calendarEl : {
4851 sameDay : '[Σήμερα {}] LT',
4852 nextDay : '[Αύριο {}] LT',
4853 nextWeek : 'dddd [{}] LT',
4854 lastDay : '[Χθες {}] LT',
4855 lastWeek : function () {
4856 switch (this.day()) {
4857 case 6:
4858 return '[το προηγούμενο] dddd [{}] LT';
4859 default:
4860 return '[την προηγούμενη] dddd [{}] LT';
4861 }
4862 },
4863 sameElse : 'L'
4864 },
4865 calendar : function (key, mom) {
4866 var output = this._calendarEl[key],
4867 hours = mom && mom.hours();
4868 if (typeof output === 'function') {
4869 output = output.apply(mom);
4870 }
4871 return output.replace('{}', (hours % 12 === 1 ? 'στη' : 'στις'));
4872 },
4873 relativeTime : {
4874 future : 'σε %s',
4875 past : '%s πριν',
4876 s : 'λίγα δευτερόλεπτα',
4877 m : 'ένα λεπτό',
4878 mm : '%d λεπτά',
4879 h : 'μία ώρα',
4880 hh : '%d ώρες',
4881 d : 'μία μέρα',
4882 dd : '%d μέρες',
4883 M : 'ένας μήνας',
4884 MM : '%d μήνες',
4885 y : 'ένας χρόνος',
4886 yy : '%d χρόνια'
4887 },
4888 ordinalParse: /\d{1,2}η/,
4889 ordinal: '%dη',
4890 week : {
4891 dow : 1, // Monday is the first day of the week.
4892 doy : 4 // The week that contains Jan 4st is the first week of the year.
4893 }
4894 });
4895
4896 //! moment.js locale configuration
4897 //! locale : australian english (en-au)
4898
4899 var en_au = _moment__default.defineLocale('en-au', {
4900 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
4901 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
4902 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
4903 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
4904 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
4905 longDateFormat : {
4906 LT : 'h:mm A',
4907 LTS : 'h:mm:ss A',
4908 L : 'DD/MM/YYYY',
4909 LL : 'D MMMM YYYY',
4910 LLL : 'D MMMM YYYY h:mm A',
4911 LLLL : 'dddd, D MMMM YYYY h:mm A'
4912 },
4913 calendar : {
4914 sameDay : '[Today at] LT',
4915 nextDay : '[Tomorrow at] LT',
4916 nextWeek : 'dddd [at] LT',
4917 lastDay : '[Yesterday at] LT',
4918 lastWeek : '[Last] dddd [at] LT',
4919 sameElse : 'L'
4920 },
4921 relativeTime : {
4922 future : 'in %s',
4923 past : '%s ago',
4924 s : 'a few seconds',
4925 m : 'a minute',
4926 mm : '%d minutes',
4927 h : 'an hour',
4928 hh : '%d hours',
4929 d : 'a day',
4930 dd : '%d days',
4931 M : 'a month',
4932 MM : '%d months',
4933 y : 'a year',
4934 yy : '%d years'
4935 },
4936 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
4937 ordinal : function (number) {
4938 var b = number % 10,
4939 output = (~~(number % 100 / 10) === 1) ? 'th' :
4940 (b === 1) ? 'st' :
4941 (b === 2) ? 'nd' :
4942 (b === 3) ? 'rd' : 'th';
4943 return number + output;
4944 },
4945 week : {
4946 dow : 1, // Monday is the first day of the week.
4947 doy : 4 // The week that contains Jan 4th is the first week of the year.
4948 }
4949 });
4950
4951 //! moment.js locale configuration
4952 //! locale : canadian english (en-ca)
4953 //! author : Jonathan Abourbih : https://github.com/jonbca
4954
4955 var en_ca = _moment__default.defineLocale('en-ca', {
4956 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
4957 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
4958 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
4959 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
4960 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
4961 longDateFormat : {
4962 LT : 'h:mm A',
4963 LTS : 'h:mm:ss A',
4964 L : 'YYYY-MM-DD',
4965 LL : 'D MMMM, YYYY',
4966 LLL : 'D MMMM, YYYY h:mm A',
4967 LLLL : 'dddd, D MMMM, YYYY h:mm A'
4968 },
4969 calendar : {
4970 sameDay : '[Today at] LT',
4971 nextDay : '[Tomorrow at] LT',
4972 nextWeek : 'dddd [at] LT',
4973 lastDay : '[Yesterday at] LT',
4974 lastWeek : '[Last] dddd [at] LT',
4975 sameElse : 'L'
4976 },
4977 relativeTime : {
4978 future : 'in %s',
4979 past : '%s ago',
4980 s : 'a few seconds',
4981 m : 'a minute',
4982 mm : '%d minutes',
4983 h : 'an hour',
4984 hh : '%d hours',
4985 d : 'a day',
4986 dd : '%d days',
4987 M : 'a month',
4988 MM : '%d months',
4989 y : 'a year',
4990 yy : '%d years'
4991 },
4992 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
4993 ordinal : function (number) {
4994 var b = number % 10,
4995 output = (~~(number % 100 / 10) === 1) ? 'th' :
4996 (b === 1) ? 'st' :
4997 (b === 2) ? 'nd' :
4998 (b === 3) ? 'rd' : 'th';
4999 return number + output;
5000 }
5001 });
5002
5003 //! moment.js locale configuration
5004 //! locale : great britain english (en-gb)
5005 //! author : Chris Gedrim : https://github.com/chrisgedrim
5006
5007 var en_gb = _moment__default.defineLocale('en-gb', {
5008 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
5009 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
5010 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
5011 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
5012 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
5013 longDateFormat : {
5014 LT : 'HH:mm',
5015 LTS : 'HH:mm:ss',
5016 L : 'DD/MM/YYYY',
5017 LL : 'D MMMM YYYY',
5018 LLL : 'D MMMM YYYY HH:mm',
5019 LLLL : 'dddd, D MMMM YYYY HH:mm'
5020 },
5021 calendar : {
5022 sameDay : '[Today at] LT',
5023 nextDay : '[Tomorrow at] LT',
5024 nextWeek : 'dddd [at] LT',
5025 lastDay : '[Yesterday at] LT',
5026 lastWeek : '[Last] dddd [at] LT',
5027 sameElse : 'L'
5028 },
5029 relativeTime : {
5030 future : 'in %s',
5031 past : '%s ago',
5032 s : 'a few seconds',
5033 m : 'a minute',
5034 mm : '%d minutes',
5035 h : 'an hour',
5036 hh : '%d hours',
5037 d : 'a day',
5038 dd : '%d days',
5039 M : 'a month',
5040 MM : '%d months',
5041 y : 'a year',
5042 yy : '%d years'
5043 },
5044 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
5045 ordinal : function (number) {
5046 var b = number % 10,
5047 output = (~~(number % 100 / 10) === 1) ? 'th' :
5048 (b === 1) ? 'st' :
5049 (b === 2) ? 'nd' :
5050 (b === 3) ? 'rd' : 'th';
5051 return number + output;
5052 },
5053 week : {
5054 dow : 1, // Monday is the first day of the week.
5055 doy : 4 // The week that contains Jan 4th is the first week of the year.
5056 }
5057 });
5058
5059 //! moment.js locale configuration
5060 //! locale : esperanto (eo)
5061 //! author : Colin Dean : https://github.com/colindean
5062 //! komento: Mi estas malcerta se mi korekte traktis akuzativojn en tiu traduko.
5063 //! Se ne, bonvolu korekti kaj avizi min por ke mi povas lerni!
5064
5065 var eo = _moment__default.defineLocale('eo', {
5066 months : 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'),
5067 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'),
5068 weekdays : 'Dimanĉo_Lundo_Mardo_Merkredo_Ĵaŭdo_Vendredo_Sabato'.split('_'),
5069 weekdaysShort : 'Dim_Lun_Mard_Merk_Ĵaŭ_Ven_Sab'.split('_'),
5070 weekdaysMin : 'Di_Lu_Ma_Me_Ĵa_Ve_Sa'.split('_'),
5071 longDateFormat : {
5072 LT : 'HH:mm',
5073 LTS : 'HH:mm:ss',
5074 L : 'YYYY-MM-DD',
5075 LL : 'D[-an de] MMMM, YYYY',
5076 LLL : 'D[-an de] MMMM, YYYY HH:mm',
5077 LLLL : 'dddd, [la] D[-an de] MMMM, YYYY HH:mm'
5078 },
5079 meridiemParse: /[ap]\.t\.m/i,
5080 isPM: function (input) {
5081 return input.charAt(0).toLowerCase() === 'p';
5082 },
5083 meridiem : function (hours, minutes, isLower) {
5084 if (hours > 11) {
5085 return isLower ? 'p.t.m.' : 'P.T.M.';
5086 } else {
5087 return isLower ? 'a.t.m.' : 'A.T.M.';
5088 }
5089 },
5090 calendar : {
5091 sameDay : '[Hodiaŭ je] LT',
5092 nextDay : '[Morgaŭ je] LT',
5093 nextWeek : 'dddd [je] LT',
5094 lastDay : '[Hieraŭ je] LT',
5095 lastWeek : '[pasinta] dddd [je] LT',
5096 sameElse : 'L'
5097 },
5098 relativeTime : {
5099 future : 'je %s',
5100 past : 'antaŭ %s',
5101 s : 'sekundoj',
5102 m : 'minuto',
5103 mm : '%d minutoj',
5104 h : 'horo',
5105 hh : '%d horoj',
5106 d : 'tago',//ne 'diurno', ĉar estas uzita por proksimumo
5107 dd : '%d tagoj',
5108 M : 'monato',
5109 MM : '%d monatoj',
5110 y : 'jaro',
5111 yy : '%d jaroj'
5112 },
5113 ordinalParse: /\d{1,2}a/,
5114 ordinal : '%da',
5115 week : {
5116 dow : 1, // Monday is the first day of the week.
5117 doy : 7 // The week that contains Jan 1st is the first week of the year.
5118 }
5119 });
5120
5121 //! moment.js locale configuration
5122 //! locale : spanish (es)
5123 //! author : Julio Napurí : https://github.com/julionc
5124
5125 var monthsShortDot = 'Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.'.split('_'),
5126 es__monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
5127
5128 var es = _moment__default.defineLocale('es', {
5129 months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
5130 monthsShort : function (m, format) {
5131 if (/-MMM-/.test(format)) {
5132 return es__monthsShort[m.month()];
5133 } else {
5134 return monthsShortDot[m.month()];
5135 }
5136 },
5137 weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
5138 weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
5139 weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
5140 longDateFormat : {
5141 LT : 'H:mm',
5142 LTS : 'H:mm:ss',
5143 L : 'DD/MM/YYYY',
5144 LL : 'D [de] MMMM [de] YYYY',
5145 LLL : 'D [de] MMMM [de] YYYY H:mm',
5146 LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
5147 },
5148 calendar : {
5149 sameDay : function () {
5150 return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
5151 },
5152 nextDay : function () {
5153 return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
5154 },
5155 nextWeek : function () {
5156 return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
5157 },
5158 lastDay : function () {
5159 return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
5160 },
5161 lastWeek : function () {
5162 return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
5163 },
5164 sameElse : 'L'
5165 },
5166 relativeTime : {
5167 future : 'en %s',
5168 past : 'hace %s',
5169 s : 'unos segundos',
5170 m : 'un minuto',
5171 mm : '%d minutos',
5172 h : 'una hora',
5173 hh : '%d horas',
5174 d : 'un día',
5175 dd : '%d días',
5176 M : 'un mes',
5177 MM : '%d meses',
5178 y : 'un año',
5179 yy : '%d años'
5180 },
5181 ordinalParse : /\d{1,2}º/,
5182 ordinal : '%dº',
5183 week : {
5184 dow : 1, // Monday is the first day of the week.
5185 doy : 4 // The week that contains Jan 4th is the first week of the year.
5186 }
5187 });
5188
5189 //! moment.js locale configuration
5190 //! locale : estonian (et)
5191 //! author : Henry Kehlmann : https://github.com/madhenry
5192 //! improvements : Illimar Tambek : https://github.com/ragulka
5193
5194 function et__processRelativeTime(number, withoutSuffix, key, isFuture) {
5195 var format = {
5196 's' : ['mõne sekundi', 'mõni sekund', 'paar sekundit'],
5197 'm' : ['ühe minuti', 'üks minut'],
5198 'mm': [number + ' minuti', number + ' minutit'],
5199 'h' : ['ühe tunni', 'tund aega', 'üks tund'],
5200 'hh': [number + ' tunni', number + ' tundi'],
5201 'd' : ['ühe päeva', 'üks päev'],
5202 'M' : ['kuu aja', 'kuu aega', 'üks kuu'],
5203 'MM': [number + ' kuu', number + ' kuud'],
5204 'y' : ['ühe aasta', 'aasta', 'üks aasta'],
5205 'yy': [number + ' aasta', number + ' aastat']
5206 };
5207 if (withoutSuffix) {
5208 return format[key][2] ? format[key][2] : format[key][1];
5209 }
5210 return isFuture ? format[key][0] : format[key][1];
5211 }
5212
5213 var et = _moment__default.defineLocale('et', {
5214 months : 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'),
5215 monthsShort : 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'),
5216 weekdays : 'pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev'.split('_'),
5217 weekdaysShort : 'P_E_T_K_N_R_L'.split('_'),
5218 weekdaysMin : 'P_E_T_K_N_R_L'.split('_'),
5219 longDateFormat : {
5220 LT : 'H:mm',
5221 LTS : 'H:mm:ss',
5222 L : 'DD.MM.YYYY',
5223 LL : 'D. MMMM YYYY',
5224 LLL : 'D. MMMM YYYY H:mm',
5225 LLLL : 'dddd, D. MMMM YYYY H:mm'
5226 },
5227 calendar : {
5228 sameDay : '[Täna,] LT',
5229 nextDay : '[Homme,] LT',
5230 nextWeek : '[Järgmine] dddd LT',
5231 lastDay : '[Eile,] LT',
5232 lastWeek : '[Eelmine] dddd LT',
5233 sameElse : 'L'
5234 },
5235 relativeTime : {
5236 future : '%s pärast',
5237 past : '%s tagasi',
5238 s : et__processRelativeTime,
5239 m : et__processRelativeTime,
5240 mm : et__processRelativeTime,
5241 h : et__processRelativeTime,
5242 hh : et__processRelativeTime,
5243 d : et__processRelativeTime,
5244 dd : '%d päeva',
5245 M : et__processRelativeTime,
5246 MM : et__processRelativeTime,
5247 y : et__processRelativeTime,
5248 yy : et__processRelativeTime
5249 },
5250 ordinalParse: /\d{1,2}\./,
5251 ordinal : '%d.',
5252 week : {
5253 dow : 1, // Monday is the first day of the week.
5254 doy : 4 // The week that contains Jan 4th is the first week of the year.
5255 }
5256 });
5257
5258 //! moment.js locale configuration
5259 //! locale : euskara (eu)
5260 //! author : Eneko Illarramendi : https://github.com/eillarra
5261
5262 var eu = _moment__default.defineLocale('eu', {
5263 months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
5264 monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
5265 weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
5266 weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
5267 weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
5268 longDateFormat : {
5269 LT : 'HH:mm',
5270 LTS : 'HH:mm:ss',
5271 L : 'YYYY-MM-DD',
5272 LL : 'YYYY[ko] MMMM[ren] D[a]',
5273 LLL : 'YYYY[ko] MMMM[ren] D[a] HH:mm',
5274 LLLL : 'dddd, YYYY[ko] MMMM[ren] D[a] HH:mm',
5275 l : 'YYYY-M-D',
5276 ll : 'YYYY[ko] MMM D[a]',
5277 lll : 'YYYY[ko] MMM D[a] HH:mm',
5278 llll : 'ddd, YYYY[ko] MMM D[a] HH:mm'
5279 },
5280 calendar : {
5281 sameDay : '[gaur] LT[etan]',
5282 nextDay : '[bihar] LT[etan]',
5283 nextWeek : 'dddd LT[etan]',
5284 lastDay : '[atzo] LT[etan]',
5285 lastWeek : '[aurreko] dddd LT[etan]',
5286 sameElse : 'L'
5287 },
5288 relativeTime : {
5289 future : '%s barru',
5290 past : 'duela %s',
5291 s : 'segundo batzuk',
5292 m : 'minutu bat',
5293 mm : '%d minutu',
5294 h : 'ordu bat',
5295 hh : '%d ordu',
5296 d : 'egun bat',
5297 dd : '%d egun',
5298 M : 'hilabete bat',
5299 MM : '%d hilabete',
5300 y : 'urte bat',
5301 yy : '%d urte'
5302 },
5303 ordinalParse: /\d{1,2}\./,
5304 ordinal : '%d.',
5305 week : {
5306 dow : 1, // Monday is the first day of the week.
5307 doy : 7 // The week that contains Jan 1st is the first week of the year.
5308 }
5309 });
5310
5311 //! moment.js locale configuration
5312 //! locale : Persian (fa)
5313 //! author : Ebrahim Byagowi : https://github.com/ebraminio
5314
5315 var fa__symbolMap = {
5316 '1': '۱',
5317 '2': '۲',
5318 '3': '۳',
5319 '4': '۴',
5320 '5': '۵',
5321 '6': '۶',
5322 '7': '۷',
5323 '8': '۸',
5324 '9': '۹',
5325 '0': '۰'
5326 }, fa__numberMap = {
5327 '۱': '1',
5328 '۲': '2',
5329 '۳': '3',
5330 '۴': '4',
5331 '۵': '5',
5332 '۶': '6',
5333 '۷': '7',
5334 '۸': '8',
5335 '۹': '9',
5336 '۰': '0'
5337 };
5338
5339 var fa = _moment__default.defineLocale('fa', {
5340 months : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
5341 monthsShort : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
5342 weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
5343 weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
5344 weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
5345 longDateFormat : {
5346 LT : 'HH:mm',
5347 LTS : 'HH:mm:ss',
5348 L : 'DD/MM/YYYY',
5349 LL : 'D MMMM YYYY',
5350 LLL : 'D MMMM YYYY HH:mm',
5351 LLLL : 'dddd, D MMMM YYYY HH:mm'
5352 },
5353 meridiemParse: /قبل از ظهر|بعد از ظهر/,
5354 isPM: function (input) {
5355 return /بعد از ظهر/.test(input);
5356 },
5357 meridiem : function (hour, minute, isLower) {
5358 if (hour < 12) {
5359 return 'قبل از ظهر';
5360 } else {
5361 return 'بعد از ظهر';
5362 }
5363 },
5364 calendar : {
5365 sameDay : '[امروز ساعت] LT',
5366 nextDay : '[فردا ساعت] LT',
5367 nextWeek : 'dddd [ساعت] LT',
5368 lastDay : '[دیروز ساعت] LT',
5369 lastWeek : 'dddd [پیش] [ساعت] LT',
5370 sameElse : 'L'
5371 },
5372 relativeTime : {
5373 future : 'در %s',
5374 past : '%s پیش',
5375 s : 'چندین ثانیه',
5376 m : 'یک دقیقه',
5377 mm : '%d دقیقه',
5378 h : 'یک ساعت',
5379 hh : '%d ساعت',
5380 d : 'یک روز',
5381 dd : '%d روز',
5382 M : 'یک ماه',
5383 MM : '%d ماه',
5384 y : 'یک سال',
5385 yy : '%d سال'
5386 },
5387 preparse: function (string) {
5388 return string.replace(/[۰-۹]/g, function (match) {
5389 return fa__numberMap[match];
5390 }).replace(/،/g, ',');
5391 },
5392 postformat: function (string) {
5393 return string.replace(/\d/g, function (match) {
5394 return fa__symbolMap[match];
5395 }).replace(/,/g, '،');
5396 },
5397 ordinalParse: /\d{1,2}م/,
5398 ordinal : '%dم',
5399 week : {
5400 dow : 6, // Saturday is the first day of the week.
5401 doy : 12 // The week that contains Jan 1st is the first week of the year.
5402 }
5403 });
5404
5405 //! moment.js locale configuration
5406 //! locale : finnish (fi)
5407 //! author : Tarmo Aidantausta : https://github.com/bleadof
5408
5409 var numbersPast = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' '),
5410 numbersFuture = [
5411 'nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
5412 numbersPast[7], numbersPast[8], numbersPast[9]
5413 ];
5414 function fi__translate(number, withoutSuffix, key, isFuture) {
5415 var result = '';
5416 switch (key) {
5417 case 's':
5418 return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
5419 case 'm':
5420 return isFuture ? 'minuutin' : 'minuutti';
5421 case 'mm':
5422 result = isFuture ? 'minuutin' : 'minuuttia';
5423 break;
5424 case 'h':
5425 return isFuture ? 'tunnin' : 'tunti';
5426 case 'hh':
5427 result = isFuture ? 'tunnin' : 'tuntia';
5428 break;
5429 case 'd':
5430 return isFuture ? 'päivän' : 'päivä';
5431 case 'dd':
5432 result = isFuture ? 'päivän' : 'päivää';
5433 break;
5434 case 'M':
5435 return isFuture ? 'kuukauden' : 'kuukausi';
5436 case 'MM':
5437 result = isFuture ? 'kuukauden' : 'kuukautta';
5438 break;
5439 case 'y':
5440 return isFuture ? 'vuoden' : 'vuosi';
5441 case 'yy':
5442 result = isFuture ? 'vuoden' : 'vuotta';
5443 break;
5444 }
5445 result = verbalNumber(number, isFuture) + ' ' + result;
5446 return result;
5447 }
5448 function verbalNumber(number, isFuture) {
5449 return number < 10 ? (isFuture ? numbersFuture[number] : numbersPast[number]) : number;
5450 }
5451
5452 var fi = _moment__default.defineLocale('fi', {
5453 months : 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'),
5454 monthsShort : 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'),
5455 weekdays : 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'),
5456 weekdaysShort : 'su_ma_ti_ke_to_pe_la'.split('_'),
5457 weekdaysMin : 'su_ma_ti_ke_to_pe_la'.split('_'),
5458 longDateFormat : {
5459 LT : 'HH.mm',
5460 LTS : 'HH.mm.ss',
5461 L : 'DD.MM.YYYY',
5462 LL : 'Do MMMM[ta] YYYY',
5463 LLL : 'Do MMMM[ta] YYYY, [klo] HH.mm',
5464 LLLL : 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm',
5465 l : 'D.M.YYYY',
5466 ll : 'Do MMM YYYY',
5467 lll : 'Do MMM YYYY, [klo] HH.mm',
5468 llll : 'ddd, Do MMM YYYY, [klo] HH.mm'
5469 },
5470 calendar : {
5471 sameDay : '[tänään] [klo] LT',
5472 nextDay : '[huomenna] [klo] LT',
5473 nextWeek : 'dddd [klo] LT',
5474 lastDay : '[eilen] [klo] LT',
5475 lastWeek : '[viime] dddd[na] [klo] LT',
5476 sameElse : 'L'
5477 },
5478 relativeTime : {
5479 future : '%s päästä',
5480 past : '%s sitten',
5481 s : fi__translate,
5482 m : fi__translate,
5483 mm : fi__translate,
5484 h : fi__translate,
5485 hh : fi__translate,
5486 d : fi__translate,
5487 dd : fi__translate,
5488 M : fi__translate,
5489 MM : fi__translate,
5490 y : fi__translate,
5491 yy : fi__translate
5492 },
5493 ordinalParse: /\d{1,2}\./,
5494 ordinal : '%d.',
5495 week : {
5496 dow : 1, // Monday is the first day of the week.
5497 doy : 4 // The week that contains Jan 4th is the first week of the year.
5498 }
5499 });
5500
5501 //! moment.js locale configuration
5502 //! locale : faroese (fo)
5503 //! author : Ragnar Johannesen : https://github.com/ragnar123
5504
5505 var fo = _moment__default.defineLocale('fo', {
5506 months : 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
5507 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
5508 weekdays : 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'),
5509 weekdaysShort : 'sun_mán_týs_mik_hós_frí_ley'.split('_'),
5510 weekdaysMin : 'su_má_tý_mi_hó_fr_le'.split('_'),
5511 longDateFormat : {
5512 LT : 'HH:mm',
5513 LTS : 'HH:mm:ss',
5514 L : 'DD/MM/YYYY',
5515 LL : 'D MMMM YYYY',
5516 LLL : 'D MMMM YYYY HH:mm',
5517 LLLL : 'dddd D. MMMM, YYYY HH:mm'
5518 },
5519 calendar : {
5520 sameDay : '[Í dag kl.] LT',
5521 nextDay : '[Í morgin kl.] LT',
5522 nextWeek : 'dddd [kl.] LT',
5523 lastDay : '[Í gjár kl.] LT',
5524 lastWeek : '[síðstu] dddd [kl] LT',
5525 sameElse : 'L'
5526 },
5527 relativeTime : {
5528 future : 'um %s',
5529 past : '%s síðani',
5530 s : 'fá sekund',
5531 m : 'ein minutt',
5532 mm : '%d minuttir',
5533 h : 'ein tími',
5534 hh : '%d tímar',
5535 d : 'ein dagur',
5536 dd : '%d dagar',
5537 M : 'ein mánaði',
5538 MM : '%d mánaðir',
5539 y : 'eitt ár',
5540 yy : '%d ár'
5541 },
5542 ordinalParse: /\d{1,2}\./,
5543 ordinal : '%d.',
5544 week : {
5545 dow : 1, // Monday is the first day of the week.
5546 doy : 4 // The week that contains Jan 4th is the first week of the year.
5547 }
5548 });
5549
5550 //! moment.js locale configuration
5551 //! locale : canadian french (fr-ca)
5552 //! author : Jonathan Abourbih : https://github.com/jonbca
5553
5554 var fr_ca = _moment__default.defineLocale('fr-ca', {
5555 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
5556 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
5557 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
5558 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
5559 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
5560 longDateFormat : {
5561 LT : 'HH:mm',
5562 LTS : 'HH:mm:ss',
5563 L : 'YYYY-MM-DD',
5564 LL : 'D MMMM YYYY',
5565 LLL : 'D MMMM YYYY HH:mm',
5566 LLLL : 'dddd D MMMM YYYY HH:mm'
5567 },
5568 calendar : {
5569 sameDay: '[Aujourd\'hui à] LT',
5570 nextDay: '[Demain à] LT',
5571 nextWeek: 'dddd [à] LT',
5572 lastDay: '[Hier à] LT',
5573 lastWeek: 'dddd [dernier à] LT',
5574 sameElse: 'L'
5575 },
5576 relativeTime : {
5577 future : 'dans %s',
5578 past : 'il y a %s',
5579 s : 'quelques secondes',
5580 m : 'une minute',
5581 mm : '%d minutes',
5582 h : 'une heure',
5583 hh : '%d heures',
5584 d : 'un jour',
5585 dd : '%d jours',
5586 M : 'un mois',
5587 MM : '%d mois',
5588 y : 'un an',
5589 yy : '%d ans'
5590 },
5591 ordinalParse: /\d{1,2}(er|e)/,
5592 ordinal : function (number) {
5593 return number + (number === 1 ? 'er' : 'e');
5594 }
5595 });
5596
5597 //! moment.js locale configuration
5598 //! locale : french (fr)
5599 //! author : John Fischer : https://github.com/jfroffice
5600
5601 var fr = _moment__default.defineLocale('fr', {
5602 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
5603 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
5604 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
5605 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
5606 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
5607 longDateFormat : {
5608 LT : 'HH:mm',
5609 LTS : 'HH:mm:ss',
5610 L : 'DD/MM/YYYY',
5611 LL : 'D MMMM YYYY',
5612 LLL : 'D MMMM YYYY HH:mm',
5613 LLLL : 'dddd D MMMM YYYY HH:mm'
5614 },
5615 calendar : {
5616 sameDay: '[Aujourd\'hui à] LT',
5617 nextDay: '[Demain à] LT',
5618 nextWeek: 'dddd [à] LT',
5619 lastDay: '[Hier à] LT',
5620 lastWeek: 'dddd [dernier à] LT',
5621 sameElse: 'L'
5622 },
5623 relativeTime : {
5624 future : 'dans %s',
5625 past : 'il y a %s',
5626 s : 'quelques secondes',
5627 m : 'une minute',
5628 mm : '%d minutes',
5629 h : 'une heure',
5630 hh : '%d heures',
5631 d : 'un jour',
5632 dd : '%d jours',
5633 M : 'un mois',
5634 MM : '%d mois',
5635 y : 'un an',
5636 yy : '%d ans'
5637 },
5638 ordinalParse: /\d{1,2}(er|)/,
5639 ordinal : function (number) {
5640 return number + (number === 1 ? 'er' : '');
5641 },
5642 week : {
5643 dow : 1, // Monday is the first day of the week.
5644 doy : 4 // The week that contains Jan 4th is the first week of the year.
5645 }
5646 });
5647
5648 //! moment.js locale configuration
5649 //! locale : frisian (fy)
5650 //! author : Robin van der Vliet : https://github.com/robin0van0der0v
5651
5652 var fy__monthsShortWithDots = 'jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.'.split('_'),
5653 fy__monthsShortWithoutDots = 'jan_feb_mrt_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_');
5654
5655 var fy = _moment__default.defineLocale('fy', {
5656 months : 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'),
5657 monthsShort : function (m, format) {
5658 if (/-MMM-/.test(format)) {
5659 return fy__monthsShortWithoutDots[m.month()];
5660 } else {
5661 return fy__monthsShortWithDots[m.month()];
5662 }
5663 },
5664 weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
5665 weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
5666 weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
5667 longDateFormat : {
5668 LT : 'HH:mm',
5669 LTS : 'HH:mm:ss',
5670 L : 'DD-MM-YYYY',
5671 LL : 'D MMMM YYYY',
5672 LLL : 'D MMMM YYYY HH:mm',
5673 LLLL : 'dddd D MMMM YYYY HH:mm'
5674 },
5675 calendar : {
5676 sameDay: '[hjoed om] LT',
5677 nextDay: '[moarn om] LT',
5678 nextWeek: 'dddd [om] LT',
5679 lastDay: '[juster om] LT',
5680 lastWeek: '[ôfrûne] dddd [om] LT',
5681 sameElse: 'L'
5682 },
5683 relativeTime : {
5684 future : 'oer %s',
5685 past : '%s lyn',
5686 s : 'in pear sekonden',
5687 m : 'ien minút',
5688 mm : '%d minuten',
5689 h : 'ien oere',
5690 hh : '%d oeren',
5691 d : 'ien dei',
5692 dd : '%d dagen',
5693 M : 'ien moanne',
5694 MM : '%d moannen',
5695 y : 'ien jier',
5696 yy : '%d jierren'
5697 },
5698 ordinalParse: /\d{1,2}(ste|de)/,
5699 ordinal : function (number) {
5700 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
5701 },
5702 week : {
5703 dow : 1, // Monday is the first day of the week.
5704 doy : 4 // The week that contains Jan 4th is the first week of the year.
5705 }
5706 });
5707
5708 //! moment.js locale configuration
5709 //! locale : galician (gl)
5710 //! author : Juan G. Hurtado : https://github.com/juanghurtado
5711
5712 var gl = _moment__default.defineLocale('gl', {
5713 months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
5714 monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
5715 weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
5716 weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
5717 weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
5718 longDateFormat : {
5719 LT : 'H:mm',
5720 LTS : 'H:mm:ss',
5721 L : 'DD/MM/YYYY',
5722 LL : 'D MMMM YYYY',
5723 LLL : 'D MMMM YYYY H:mm',
5724 LLLL : 'dddd D MMMM YYYY H:mm'
5725 },
5726 calendar : {
5727 sameDay : function () {
5728 return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
5729 },
5730 nextDay : function () {
5731 return '[mañá ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
5732 },
5733 nextWeek : function () {
5734 return 'dddd [' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
5735 },
5736 lastDay : function () {
5737 return '[onte ' + ((this.hours() !== 1) ? 'á' : 'a') + '] LT';
5738 },
5739 lastWeek : function () {
5740 return '[o] dddd [pasado ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
5741 },
5742 sameElse : 'L'
5743 },
5744 relativeTime : {
5745 future : function (str) {
5746 if (str === 'uns segundos') {
5747 return 'nuns segundos';
5748 }
5749 return 'en ' + str;
5750 },
5751 past : 'hai %s',
5752 s : 'uns segundos',
5753 m : 'un minuto',
5754 mm : '%d minutos',
5755 h : 'unha hora',
5756 hh : '%d horas',
5757 d : 'un día',
5758 dd : '%d días',
5759 M : 'un mes',
5760 MM : '%d meses',
5761 y : 'un ano',
5762 yy : '%d anos'
5763 },
5764 ordinalParse : /\d{1,2}º/,
5765 ordinal : '%dº',
5766 week : {
5767 dow : 1, // Monday is the first day of the week.
5768 doy : 7 // The week that contains Jan 1st is the first week of the year.
5769 }
5770 });
5771
5772 //! moment.js locale configuration
5773 //! locale : Hebrew (he)
5774 //! author : Tomer Cohen : https://github.com/tomer
5775 //! author : Moshe Simantov : https://github.com/DevelopmentIL
5776 //! author : Tal Ater : https://github.com/TalAter
5777
5778 var he = _moment__default.defineLocale('he', {
5779 months : 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'),
5780 monthsShort : 'ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳'.split('_'),
5781 weekdays : 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'),
5782 weekdaysShort : 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'),
5783 weekdaysMin : 'א_ב_ג_ד_ה_ו_ש'.split('_'),
5784 longDateFormat : {
5785 LT : 'HH:mm',
5786 LTS : 'HH:mm:ss',
5787 L : 'DD/MM/YYYY',
5788 LL : 'D [ב]MMMM YYYY',
5789 LLL : 'D [ב]MMMM YYYY HH:mm',
5790 LLLL : 'dddd, D [ב]MMMM YYYY HH:mm',
5791 l : 'D/M/YYYY',
5792 ll : 'D MMM YYYY',
5793 lll : 'D MMM YYYY HH:mm',
5794 llll : 'ddd, D MMM YYYY HH:mm'
5795 },
5796 calendar : {
5797 sameDay : '[היום ב־]LT',
5798 nextDay : '[מחר ב־]LT',
5799 nextWeek : 'dddd [בשעה] LT',
5800 lastDay : '[אתמול ב־]LT',
5801 lastWeek : '[ביום] dddd [האחרון בשעה] LT',
5802 sameElse : 'L'
5803 },
5804 relativeTime : {
5805 future : 'בעוד %s',
5806 past : 'לפני %s',
5807 s : 'מספר שניות',
5808 m : 'דקה',
5809 mm : '%d דקות',
5810 h : 'שעה',
5811 hh : function (number) {
5812 if (number === 2) {
5813 return 'שעתיים';
5814 }
5815 return number + ' שעות';
5816 },
5817 d : 'יום',
5818 dd : function (number) {
5819 if (number === 2) {
5820 return 'יומיים';
5821 }
5822 return number + ' ימים';
5823 },
5824 M : 'חודש',
5825 MM : function (number) {
5826 if (number === 2) {
5827 return 'חודשיים';
5828 }
5829 return number + ' חודשים';
5830 },
5831 y : 'שנה',
5832 yy : function (number) {
5833 if (number === 2) {
5834 return 'שנתיים';
5835 } else if (number % 10 === 0 && number !== 10) {
5836 return number + ' שנה';
5837 }
5838 return number + ' שנים';
5839 }
5840 }
5841 });
5842
5843 //! moment.js locale configuration
5844 //! locale : hindi (hi)
5845 //! author : Mayank Singhal : https://github.com/mayanksinghal
5846
5847 var hi__symbolMap = {
5848 '1': '१',
5849 '2': '२',
5850 '3': '३',
5851 '4': '४',
5852 '5': '५',
5853 '6': '६',
5854 '7': '७',
5855 '8': '८',
5856 '9': '९',
5857 '0': '०'
5858 },
5859 hi__numberMap = {
5860 '१': '1',
5861 '२': '2',
5862 '३': '3',
5863 '४': '4',
5864 '५': '5',
5865 '६': '6',
5866 '७': '7',
5867 '८': '8',
5868 '९': '9',
5869 '०': '0'
5870 };
5871
5872 var hi = _moment__default.defineLocale('hi', {
5873 months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
5874 monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
5875 weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
5876 weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
5877 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
5878 longDateFormat : {
5879 LT : 'A h:mm बजे',
5880 LTS : 'A h:mm:ss बजे',
5881 L : 'DD/MM/YYYY',
5882 LL : 'D MMMM YYYY',
5883 LLL : 'D MMMM YYYY, A h:mm बजे',
5884 LLLL : 'dddd, D MMMM YYYY, A h:mm बजे'
5885 },
5886 calendar : {
5887 sameDay : '[आज] LT',
5888 nextDay : '[कल] LT',
5889 nextWeek : 'dddd, LT',
5890 lastDay : '[कल] LT',
5891 lastWeek : '[पिछले] dddd, LT',
5892 sameElse : 'L'
5893 },
5894 relativeTime : {
5895 future : '%s में',
5896 past : '%s पहले',
5897 s : 'कुछ ही क्षण',
5898 m : 'एक मिनट',
5899 mm : '%d मिनट',
5900 h : 'एक घंटा',
5901 hh : '%d घंटे',
5902 d : 'एक दिन',
5903 dd : '%d दिन',
5904 M : 'एक महीने',
5905 MM : '%d महीने',
5906 y : 'एक वर्ष',
5907 yy : '%d वर्ष'
5908 },
5909 preparse: function (string) {
5910 return string.replace(/[१२३४५६७८९०]/g, function (match) {
5911 return hi__numberMap[match];
5912 });
5913 },
5914 postformat: function (string) {
5915 return string.replace(/\d/g, function (match) {
5916 return hi__symbolMap[match];
5917 });
5918 },
5919 // Hindi notation for meridiems are quite fuzzy in practice. While there exists
5920 // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
5921 meridiemParse: /रात|सुबह|दोपहर|शाम/,
5922 meridiemHour : function (hour, meridiem) {
5923 if (hour === 12) {
5924 hour = 0;
5925 }
5926 if (meridiem === 'रात') {
5927 return hour < 4 ? hour : hour + 12;
5928 } else if (meridiem === 'सुबह') {
5929 return hour;
5930 } else if (meridiem === 'दोपहर') {
5931 return hour >= 10 ? hour : hour + 12;
5932 } else if (meridiem === 'शाम') {
5933 return hour + 12;
5934 }
5935 },
5936 meridiem : function (hour, minute, isLower) {
5937 if (hour < 4) {
5938 return 'रात';
5939 } else if (hour < 10) {
5940 return 'सुबह';
5941 } else if (hour < 17) {
5942 return 'दोपहर';
5943 } else if (hour < 20) {
5944 return 'शाम';
5945 } else {
5946 return 'रात';
5947 }
5948 },
5949 week : {
5950 dow : 0, // Sunday is the first day of the week.
5951 doy : 6 // The week that contains Jan 1st is the first week of the year.
5952 }
5953 });
5954
5955 //! moment.js locale configuration
5956 //! locale : hrvatski (hr)
5957 //! author : Bojan Marković : https://github.com/bmarkovic
5958
5959 function hr__translate(number, withoutSuffix, key) {
5960 var result = number + ' ';
5961 switch (key) {
5962 case 'm':
5963 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
5964 case 'mm':
5965 if (number === 1) {
5966 result += 'minuta';
5967 } else if (number === 2 || number === 3 || number === 4) {
5968 result += 'minute';
5969 } else {
5970 result += 'minuta';
5971 }
5972 return result;
5973 case 'h':
5974 return withoutSuffix ? 'jedan sat' : 'jednog sata';
5975 case 'hh':
5976 if (number === 1) {
5977 result += 'sat';
5978 } else if (number === 2 || number === 3 || number === 4) {
5979 result += 'sata';
5980 } else {
5981 result += 'sati';
5982 }
5983 return result;
5984 case 'dd':
5985 if (number === 1) {
5986 result += 'dan';
5987 } else {
5988 result += 'dana';
5989 }
5990 return result;
5991 case 'MM':
5992 if (number === 1) {
5993 result += 'mjesec';
5994 } else if (number === 2 || number === 3 || number === 4) {
5995 result += 'mjeseca';
5996 } else {
5997 result += 'mjeseci';
5998 }
5999 return result;
6000 case 'yy':
6001 if (number === 1) {
6002 result += 'godina';
6003 } else if (number === 2 || number === 3 || number === 4) {
6004 result += 'godine';
6005 } else {
6006 result += 'godina';
6007 }
6008 return result;
6009 }
6010 }
6011
6012 var hr = _moment__default.defineLocale('hr', {
6013 months : 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
6014 monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
6015 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
6016 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
6017 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
6018 longDateFormat : {
6019 LT : 'H:mm',
6020 LTS : 'H:mm:ss',
6021 L : 'DD. MM. YYYY',
6022 LL : 'D. MMMM YYYY',
6023 LLL : 'D. MMMM YYYY H:mm',
6024 LLLL : 'dddd, D. MMMM YYYY H:mm'
6025 },
6026 calendar : {
6027 sameDay : '[danas u] LT',
6028 nextDay : '[sutra u] LT',
6029 nextWeek : function () {
6030 switch (this.day()) {
6031 case 0:
6032 return '[u] [nedjelju] [u] LT';
6033 case 3:
6034 return '[u] [srijedu] [u] LT';
6035 case 6:
6036 return '[u] [subotu] [u] LT';
6037 case 1:
6038 case 2:
6039 case 4:
6040 case 5:
6041 return '[u] dddd [u] LT';
6042 }
6043 },
6044 lastDay : '[jučer u] LT',
6045 lastWeek : function () {
6046 switch (this.day()) {
6047 case 0:
6048 case 3:
6049 return '[prošlu] dddd [u] LT';
6050 case 6:
6051 return '[prošle] [subote] [u] LT';
6052 case 1:
6053 case 2:
6054 case 4:
6055 case 5:
6056 return '[prošli] dddd [u] LT';
6057 }
6058 },
6059 sameElse : 'L'
6060 },
6061 relativeTime : {
6062 future : 'za %s',
6063 past : 'prije %s',
6064 s : 'par sekundi',
6065 m : hr__translate,
6066 mm : hr__translate,
6067 h : hr__translate,
6068 hh : hr__translate,
6069 d : 'dan',
6070 dd : hr__translate,
6071 M : 'mjesec',
6072 MM : hr__translate,
6073 y : 'godinu',
6074 yy : hr__translate
6075 },
6076 ordinalParse: /\d{1,2}\./,
6077 ordinal : '%d.',
6078 week : {
6079 dow : 1, // Monday is the first day of the week.
6080 doy : 7 // The week that contains Jan 1st is the first week of the year.
6081 }
6082 });
6083
6084 //! moment.js locale configuration
6085 //! locale : hungarian (hu)
6086 //! author : Adam Brunner : https://github.com/adambrunner
6087
6088 var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
6089 function hu__translate(number, withoutSuffix, key, isFuture) {
6090 var num = number,
6091 suffix;
6092 switch (key) {
6093 case 's':
6094 return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
6095 case 'm':
6096 return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
6097 case 'mm':
6098 return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
6099 case 'h':
6100 return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
6101 case 'hh':
6102 return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
6103 case 'd':
6104 return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
6105 case 'dd':
6106 return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
6107 case 'M':
6108 return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
6109 case 'MM':
6110 return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
6111 case 'y':
6112 return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
6113 case 'yy':
6114 return num + (isFuture || withoutSuffix ? ' év' : ' éve');
6115 }
6116 return '';
6117 }
6118 function week(isFuture) {
6119 return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[this.day()] + '] LT[-kor]';
6120 }
6121
6122 var hu = _moment__default.defineLocale('hu', {
6123 months : 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
6124 monthsShort : 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
6125 weekdays : 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'),
6126 weekdaysShort : 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'),
6127 weekdaysMin : 'v_h_k_sze_cs_p_szo'.split('_'),
6128 longDateFormat : {
6129 LT : 'H:mm',
6130 LTS : 'H:mm:ss',
6131 L : 'YYYY.MM.DD.',
6132 LL : 'YYYY. MMMM D.',
6133 LLL : 'YYYY. MMMM D. H:mm',
6134 LLLL : 'YYYY. MMMM D., dddd H:mm'
6135 },
6136 meridiemParse: /de|du/i,
6137 isPM: function (input) {
6138 return input.charAt(1).toLowerCase() === 'u';
6139 },
6140 meridiem : function (hours, minutes, isLower) {
6141 if (hours < 12) {
6142 return isLower === true ? 'de' : 'DE';
6143 } else {
6144 return isLower === true ? 'du' : 'DU';
6145 }
6146 },
6147 calendar : {
6148 sameDay : '[ma] LT[-kor]',
6149 nextDay : '[holnap] LT[-kor]',
6150 nextWeek : function () {
6151 return week.call(this, true);
6152 },
6153 lastDay : '[tegnap] LT[-kor]',
6154 lastWeek : function () {
6155 return week.call(this, false);
6156 },
6157 sameElse : 'L'
6158 },
6159 relativeTime : {
6160 future : '%s múlva',
6161 past : '%s',
6162 s : hu__translate,
6163 m : hu__translate,
6164 mm : hu__translate,
6165 h : hu__translate,
6166 hh : hu__translate,
6167 d : hu__translate,
6168 dd : hu__translate,
6169 M : hu__translate,
6170 MM : hu__translate,
6171 y : hu__translate,
6172 yy : hu__translate
6173 },
6174 ordinalParse: /\d{1,2}\./,
6175 ordinal : '%d.',
6176 week : {
6177 dow : 1, // Monday is the first day of the week.
6178 doy : 7 // The week that contains Jan 1st is the first week of the year.
6179 }
6180 });
6181
6182 //! moment.js locale configuration
6183 //! locale : Armenian (hy-am)
6184 //! author : Armendarabyan : https://github.com/armendarabyan
6185
6186 function hy_am__monthsCaseReplace(m, format) {
6187 var months = {
6188 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
6189 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
6190 },
6191 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
6192 'accusative' :
6193 'nominative';
6194 return months[nounCase][m.month()];
6195 }
6196 function hy_am__monthsShortCaseReplace(m, format) {
6197 var monthsShort = 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_');
6198 return monthsShort[m.month()];
6199 }
6200 function hy_am__weekdaysCaseReplace(m, format) {
6201 var weekdays = 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_');
6202 return weekdays[m.day()];
6203 }
6204
6205 var hy_am = _moment__default.defineLocale('hy-am', {
6206 months : hy_am__monthsCaseReplace,
6207 monthsShort : hy_am__monthsShortCaseReplace,
6208 weekdays : hy_am__weekdaysCaseReplace,
6209 weekdaysShort : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
6210 weekdaysMin : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
6211 longDateFormat : {
6212 LT : 'HH:mm',
6213 LTS : 'HH:mm:ss',
6214 L : 'DD.MM.YYYY',
6215 LL : 'D MMMM YYYY թ.',
6216 LLL : 'D MMMM YYYY թ., HH:mm',
6217 LLLL : 'dddd, D MMMM YYYY թ., HH:mm'
6218 },
6219 calendar : {
6220 sameDay: '[այսօր] LT',
6221 nextDay: '[վաղը] LT',
6222 lastDay: '[երեկ] LT',
6223 nextWeek: function () {
6224 return 'dddd [օրը ժամը] LT';
6225 },
6226 lastWeek: function () {
6227 return '[անցած] dddd [օրը ժամը] LT';
6228 },
6229 sameElse: 'L'
6230 },
6231 relativeTime : {
6232 future : '%s հետո',
6233 past : '%s առաջ',
6234 s : 'մի քանի վայրկյան',
6235 m : 'րոպե',
6236 mm : '%d րոպե',
6237 h : 'ժամ',
6238 hh : '%d ժամ',
6239 d : 'օր',
6240 dd : '%d օր',
6241 M : 'ամիս',
6242 MM : '%d ամիս',
6243 y : 'տարի',
6244 yy : '%d տարի'
6245 },
6246 meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
6247 isPM: function (input) {
6248 return /^(ցերեկվա|երեկոյան)$/.test(input);
6249 },
6250 meridiem : function (hour) {
6251 if (hour < 4) {
6252 return 'գիշերվա';
6253 } else if (hour < 12) {
6254 return 'առավոտվա';
6255 } else if (hour < 17) {
6256 return 'ցերեկվա';
6257 } else {
6258 return 'երեկոյան';
6259 }
6260 },
6261 ordinalParse: /\d{1,2}|\d{1,2}-(ին|րդ)/,
6262 ordinal: function (number, period) {
6263 switch (period) {
6264 case 'DDD':
6265 case 'w':
6266 case 'W':
6267 case 'DDDo':
6268 if (number === 1) {
6269 return number + '-ին';
6270 }
6271 return number + '-րդ';
6272 default:
6273 return number;
6274 }
6275 },
6276 week : {
6277 dow : 1, // Monday is the first day of the week.
6278 doy : 7 // The week that contains Jan 1st is the first week of the year.
6279 }
6280 });
6281
6282 //! moment.js locale configuration
6283 //! locale : Bahasa Indonesia (id)
6284 //! author : Mohammad Satrio Utomo : https://github.com/tyok
6285 //! reference: http://id.wikisource.org/wiki/Pedoman_Umum_Ejaan_Bahasa_Indonesia_yang_Disempurnakan
6286
6287 var id = _moment__default.defineLocale('id', {
6288 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
6289 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des'.split('_'),
6290 weekdays : 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
6291 weekdaysShort : 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'),
6292 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'),
6293 longDateFormat : {
6294 LT : 'HH.mm',
6295 LTS : 'HH.mm.ss',
6296 L : 'DD/MM/YYYY',
6297 LL : 'D MMMM YYYY',
6298 LLL : 'D MMMM YYYY [pukul] HH.mm',
6299 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
6300 },
6301 meridiemParse: /pagi|siang|sore|malam/,
6302 meridiemHour : function (hour, meridiem) {
6303 if (hour === 12) {
6304 hour = 0;
6305 }
6306 if (meridiem === 'pagi') {
6307 return hour;
6308 } else if (meridiem === 'siang') {
6309 return hour >= 11 ? hour : hour + 12;
6310 } else if (meridiem === 'sore' || meridiem === 'malam') {
6311 return hour + 12;
6312 }
6313 },
6314 meridiem : function (hours, minutes, isLower) {
6315 if (hours < 11) {
6316 return 'pagi';
6317 } else if (hours < 15) {
6318 return 'siang';
6319 } else if (hours < 19) {
6320 return 'sore';
6321 } else {
6322 return 'malam';
6323 }
6324 },
6325 calendar : {
6326 sameDay : '[Hari ini pukul] LT',
6327 nextDay : '[Besok pukul] LT',
6328 nextWeek : 'dddd [pukul] LT',
6329 lastDay : '[Kemarin pukul] LT',
6330 lastWeek : 'dddd [lalu pukul] LT',
6331 sameElse : 'L'
6332 },
6333 relativeTime : {
6334 future : 'dalam %s',
6335 past : '%s yang lalu',
6336 s : 'beberapa detik',
6337 m : 'semenit',
6338 mm : '%d menit',
6339 h : 'sejam',
6340 hh : '%d jam',
6341 d : 'sehari',
6342 dd : '%d hari',
6343 M : 'sebulan',
6344 MM : '%d bulan',
6345 y : 'setahun',
6346 yy : '%d tahun'
6347 },
6348 week : {
6349 dow : 1, // Monday is the first day of the week.
6350 doy : 7 // The week that contains Jan 1st is the first week of the year.
6351 }
6352 });
6353
6354 //! moment.js locale configuration
6355 //! locale : icelandic (is)
6356 //! author : Hinrik Örn Sigurðsson : https://github.com/hinrik
6357
6358 function is__plural(n) {
6359 if (n % 100 === 11) {
6360 return true;
6361 } else if (n % 10 === 1) {
6362 return false;
6363 }
6364 return true;
6365 }
6366 function is__translate(number, withoutSuffix, key, isFuture) {
6367 var result = number + ' ';
6368 switch (key) {
6369 case 's':
6370 return withoutSuffix || isFuture ? 'nokkrar sekúndur' : 'nokkrum sekúndum';
6371 case 'm':
6372 return withoutSuffix ? 'mínúta' : 'mínútu';
6373 case 'mm':
6374 if (is__plural(number)) {
6375 return result + (withoutSuffix || isFuture ? 'mínútur' : 'mínútum');
6376 } else if (withoutSuffix) {
6377 return result + 'mínúta';
6378 }
6379 return result + 'mínútu';
6380 case 'hh':
6381 if (is__plural(number)) {
6382 return result + (withoutSuffix || isFuture ? 'klukkustundir' : 'klukkustundum');
6383 }
6384 return result + 'klukkustund';
6385 case 'd':
6386 if (withoutSuffix) {
6387 return 'dagur';
6388 }
6389 return isFuture ? 'dag' : 'degi';
6390 case 'dd':
6391 if (is__plural(number)) {
6392 if (withoutSuffix) {
6393 return result + 'dagar';
6394 }
6395 return result + (isFuture ? 'daga' : 'dögum');
6396 } else if (withoutSuffix) {
6397 return result + 'dagur';
6398 }
6399 return result + (isFuture ? 'dag' : 'degi');
6400 case 'M':
6401 if (withoutSuffix) {
6402 return 'mánuður';
6403 }
6404 return isFuture ? 'mánuð' : 'mánuði';
6405 case 'MM':
6406 if (is__plural(number)) {
6407 if (withoutSuffix) {
6408 return result + 'mánuðir';
6409 }
6410 return result + (isFuture ? 'mánuði' : 'mánuðum');
6411 } else if (withoutSuffix) {
6412 return result + 'mánuður';
6413 }
6414 return result + (isFuture ? 'mánuð' : 'mánuði');
6415 case 'y':
6416 return withoutSuffix || isFuture ? 'ár' : 'ári';
6417 case 'yy':
6418 if (is__plural(number)) {
6419 return result + (withoutSuffix || isFuture ? 'ár' : 'árum');
6420 }
6421 return result + (withoutSuffix || isFuture ? 'ár' : 'ári');
6422 }
6423 }
6424
6425 var is = _moment__default.defineLocale('is', {
6426 months : 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'),
6427 monthsShort : 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'),
6428 weekdays : 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
6429 weekdaysShort : 'sun_mán_þri_mið_fim_fös_lau'.split('_'),
6430 weekdaysMin : 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'),
6431 longDateFormat : {
6432 LT : 'H:mm',
6433 LTS : 'H:mm:ss',
6434 L : 'DD/MM/YYYY',
6435 LL : 'D. MMMM YYYY',
6436 LLL : 'D. MMMM YYYY [kl.] H:mm',
6437 LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
6438 },
6439 calendar : {
6440 sameDay : '[í dag kl.] LT',
6441 nextDay : '[á morgun kl.] LT',
6442 nextWeek : 'dddd [kl.] LT',
6443 lastDay : '[í gær kl.] LT',
6444 lastWeek : '[síðasta] dddd [kl.] LT',
6445 sameElse : 'L'
6446 },
6447 relativeTime : {
6448 future : 'eftir %s',
6449 past : 'fyrir %s síðan',
6450 s : is__translate,
6451 m : is__translate,
6452 mm : is__translate,
6453 h : 'klukkustund',
6454 hh : is__translate,
6455 d : is__translate,
6456 dd : is__translate,
6457 M : is__translate,
6458 MM : is__translate,
6459 y : is__translate,
6460 yy : is__translate
6461 },
6462 ordinalParse: /\d{1,2}\./,
6463 ordinal : '%d.',
6464 week : {
6465 dow : 1, // Monday is the first day of the week.
6466 doy : 4 // The week that contains Jan 4th is the first week of the year.
6467 }
6468 });
6469
6470 //! moment.js locale configuration
6471 //! locale : italian (it)
6472 //! author : Lorenzo : https://github.com/aliem
6473 //! author: Mattia Larentis: https://github.com/nostalgiaz
6474
6475 var it = _moment__default.defineLocale('it', {
6476 months : 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
6477 monthsShort : 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
6478 weekdays : 'Domenica_Lunedì_Martedì_Mercoledì_Giovedì_Venerdì_Sabato'.split('_'),
6479 weekdaysShort : 'Dom_Lun_Mar_Mer_Gio_Ven_Sab'.split('_'),
6480 weekdaysMin : 'D_L_Ma_Me_G_V_S'.split('_'),
6481 longDateFormat : {
6482 LT : 'HH:mm',
6483 LTS : 'HH:mm:ss',
6484 L : 'DD/MM/YYYY',
6485 LL : 'D MMMM YYYY',
6486 LLL : 'D MMMM YYYY HH:mm',
6487 LLLL : 'dddd, D MMMM YYYY HH:mm'
6488 },
6489 calendar : {
6490 sameDay: '[Oggi alle] LT',
6491 nextDay: '[Domani alle] LT',
6492 nextWeek: 'dddd [alle] LT',
6493 lastDay: '[Ieri alle] LT',
6494 lastWeek: function () {
6495 switch (this.day()) {
6496 case 0:
6497 return '[la scorsa] dddd [alle] LT';
6498 default:
6499 return '[lo scorso] dddd [alle] LT';
6500 }
6501 },
6502 sameElse: 'L'
6503 },
6504 relativeTime : {
6505 future : function (s) {
6506 return ((/^[0-9].+$/).test(s) ? 'tra' : 'in') + ' ' + s;
6507 },
6508 past : '%s fa',
6509 s : 'alcuni secondi',
6510 m : 'un minuto',
6511 mm : '%d minuti',
6512 h : 'un\'ora',
6513 hh : '%d ore',
6514 d : 'un giorno',
6515 dd : '%d giorni',
6516 M : 'un mese',
6517 MM : '%d mesi',
6518 y : 'un anno',
6519 yy : '%d anni'
6520 },
6521 ordinalParse : /\d{1,2}º/,
6522 ordinal: '%dº',
6523 week : {
6524 dow : 1, // Monday is the first day of the week.
6525 doy : 4 // The week that contains Jan 4th is the first week of the year.
6526 }
6527 });
6528
6529 //! moment.js locale configuration
6530 //! locale : japanese (ja)
6531 //! author : LI Long : https://github.com/baryon
6532
6533 var ja = _moment__default.defineLocale('ja', {
6534 months : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
6535 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
6536 weekdays : '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
6537 weekdaysShort : '日_月_火_水_木_金_土'.split('_'),
6538 weekdaysMin : '日_月_火_水_木_金_土'.split('_'),
6539 longDateFormat : {
6540 LT : 'Ah時m分',
6541 LTS : 'Ah時m分s秒',
6542 L : 'YYYY/MM/DD',
6543 LL : 'YYYY年M月D日',
6544 LLL : 'YYYY年M月D日Ah時m分',
6545 LLLL : 'YYYY年M月D日Ah時m分 dddd'
6546 },
6547 meridiemParse: /午前|午後/i,
6548 isPM : function (input) {
6549 return input === '午後';
6550 },
6551 meridiem : function (hour, minute, isLower) {
6552 if (hour < 12) {
6553 return '午前';
6554 } else {
6555 return '午後';
6556 }
6557 },
6558 calendar : {
6559 sameDay : '[今日] LT',
6560 nextDay : '[明日] LT',
6561 nextWeek : '[来週]dddd LT',
6562 lastDay : '[昨日] LT',
6563 lastWeek : '[前週]dddd LT',
6564 sameElse : 'L'
6565 },
6566 relativeTime : {
6567 future : '%s後',
6568 past : '%s前',
6569 s : '数秒',
6570 m : '1分',
6571 mm : '%d分',
6572 h : '1時間',
6573 hh : '%d時間',
6574 d : '1日',
6575 dd : '%d日',
6576 M : '1ヶ月',
6577 MM : '%dヶ月',
6578 y : '1年',
6579 yy : '%d年'
6580 }
6581 });
6582
6583 //! moment.js locale configuration
6584 //! locale : Boso Jowo (jv)
6585 //! author : Rony Lantip : https://github.com/lantip
6586 //! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
6587
6588 var jv = _moment__default.defineLocale('jv', {
6589 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
6590 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
6591 weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
6592 weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
6593 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
6594 longDateFormat : {
6595 LT : 'HH.mm',
6596 LTS : 'HH.mm.ss',
6597 L : 'DD/MM/YYYY',
6598 LL : 'D MMMM YYYY',
6599 LLL : 'D MMMM YYYY [pukul] HH.mm',
6600 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
6601 },
6602 meridiemParse: /enjing|siyang|sonten|ndalu/,
6603 meridiemHour : function (hour, meridiem) {
6604 if (hour === 12) {
6605 hour = 0;
6606 }
6607 if (meridiem === 'enjing') {
6608 return hour;
6609 } else if (meridiem === 'siyang') {
6610 return hour >= 11 ? hour : hour + 12;
6611 } else if (meridiem === 'sonten' || meridiem === 'ndalu') {
6612 return hour + 12;
6613 }
6614 },
6615 meridiem : function (hours, minutes, isLower) {
6616 if (hours < 11) {
6617 return 'enjing';
6618 } else if (hours < 15) {
6619 return 'siyang';
6620 } else if (hours < 19) {
6621 return 'sonten';
6622 } else {
6623 return 'ndalu';
6624 }
6625 },
6626 calendar : {
6627 sameDay : '[Dinten puniko pukul] LT',
6628 nextDay : '[Mbenjang pukul] LT',
6629 nextWeek : 'dddd [pukul] LT',
6630 lastDay : '[Kala wingi pukul] LT',
6631 lastWeek : 'dddd [kepengker pukul] LT',
6632 sameElse : 'L'
6633 },
6634 relativeTime : {
6635 future : 'wonten ing %s',
6636 past : '%s ingkang kepengker',
6637 s : 'sawetawis detik',
6638 m : 'setunggal menit',
6639 mm : '%d menit',
6640 h : 'setunggal jam',
6641 hh : '%d jam',
6642 d : 'sedinten',
6643 dd : '%d dinten',
6644 M : 'sewulan',
6645 MM : '%d wulan',
6646 y : 'setaun',
6647 yy : '%d taun'
6648 },
6649 week : {
6650 dow : 1, // Monday is the first day of the week.
6651 doy : 7 // The week that contains Jan 1st is the first week of the year.
6652 }
6653 });
6654
6655 //! moment.js locale configuration
6656 //! locale : Georgian (ka)
6657 //! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
6658
6659 function ka__monthsCaseReplace(m, format) {
6660 var months = {
6661 'nominative': 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
6662 'accusative': 'იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს'.split('_')
6663 },
6664 nounCase = (/D[oD] *MMMM?/).test(format) ?
6665 'accusative' :
6666 'nominative';
6667 return months[nounCase][m.month()];
6668 }
6669 function ka__weekdaysCaseReplace(m, format) {
6670 var weekdays = {
6671 'nominative': 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'),
6672 'accusative': 'კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს'.split('_')
6673 },
6674 nounCase = (/(წინა|შემდეგ)/).test(format) ?
6675 'accusative' :
6676 'nominative';
6677 return weekdays[nounCase][m.day()];
6678 }
6679
6680 var ka = _moment__default.defineLocale('ka', {
6681 months : ka__monthsCaseReplace,
6682 monthsShort : 'იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ'.split('_'),
6683 weekdays : ka__weekdaysCaseReplace,
6684 weekdaysShort : 'კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ'.split('_'),
6685 weekdaysMin : 'კვ_ორ_სა_ოთ_ხუ_პა_შა'.split('_'),
6686 longDateFormat : {
6687 LT : 'h:mm A',
6688 LTS : 'h:mm:ss A',
6689 L : 'DD/MM/YYYY',
6690 LL : 'D MMMM YYYY',
6691 LLL : 'D MMMM YYYY h:mm A',
6692 LLLL : 'dddd, D MMMM YYYY h:mm A'
6693 },
6694 calendar : {
6695 sameDay : '[დღეს] LT[-ზე]',
6696 nextDay : '[ხვალ] LT[-ზე]',
6697 lastDay : '[გუშინ] LT[-ზე]',
6698 nextWeek : '[შემდეგ] dddd LT[-ზე]',
6699 lastWeek : '[წინა] dddd LT-ზე',
6700 sameElse : 'L'
6701 },
6702 relativeTime : {
6703 future : function (s) {
6704 return (/(წამი|წუთი|საათი|წელი)/).test(s) ?
6705 s.replace(/ი$/, 'ში') :
6706 s + 'ში';
6707 },
6708 past : function (s) {
6709 if ((/(წამი|წუთი|საათი|დღე|თვე)/).test(s)) {
6710 return s.replace(/(ი|ე)$/, 'ის წინ');
6711 }
6712 if ((/წელი/).test(s)) {
6713 return s.replace(/წელი$/, 'წლის წინ');
6714 }
6715 },
6716 s : 'რამდენიმე წამი',
6717 m : 'წუთი',
6718 mm : '%d წუთი',
6719 h : 'საათი',
6720 hh : '%d საათი',
6721 d : 'დღე',
6722 dd : '%d დღე',
6723 M : 'თვე',
6724 MM : '%d თვე',
6725 y : 'წელი',
6726 yy : '%d წელი'
6727 },
6728 ordinalParse: /0|1-ლი|მე-\d{1,2}|\d{1,2}-ე/,
6729 ordinal : function (number) {
6730 if (number === 0) {
6731 return number;
6732 }
6733 if (number === 1) {
6734 return number + '-ლი';
6735 }
6736 if ((number < 20) || (number <= 100 && (number % 20 === 0)) || (number % 100 === 0)) {
6737 return 'მე-' + number;
6738 }
6739 return number + '-ე';
6740 },
6741 week : {
6742 dow : 1,
6743 doy : 7
6744 }
6745 });
6746
6747 //! moment.js locale configuration
6748 //! locale : khmer (km)
6749 //! author : Kruy Vanna : https://github.com/kruyvanna
6750
6751 var km = _moment__default.defineLocale('km', {
6752 months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
6753 monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
6754 weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
6755 weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
6756 weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
6757 longDateFormat: {
6758 LT: 'HH:mm',
6759 LTS : 'HH:mm:ss',
6760 L: 'DD/MM/YYYY',
6761 LL: 'D MMMM YYYY',
6762 LLL: 'D MMMM YYYY HH:mm',
6763 LLLL: 'dddd, D MMMM YYYY HH:mm'
6764 },
6765 calendar: {
6766 sameDay: '[ថ្ងៃនៈ ម៉ោង] LT',
6767 nextDay: '[ស្អែក ម៉ោង] LT',
6768 nextWeek: 'dddd [ម៉ោង] LT',
6769 lastDay: '[ម្សិលមិញ ម៉ោង] LT',
6770 lastWeek: 'dddd [សប្តាហ៍មុន] [ម៉ោង] LT',
6771 sameElse: 'L'
6772 },
6773 relativeTime: {
6774 future: '%sទៀត',
6775 past: '%sមុន',
6776 s: 'ប៉ុន្មានវិនាទី',
6777 m: 'មួយនាទី',
6778 mm: '%d នាទី',
6779 h: 'មួយម៉ោង',
6780 hh: '%d ម៉ោង',
6781 d: 'មួយថ្ងៃ',
6782 dd: '%d ថ្ងៃ',
6783 M: 'មួយខែ',
6784 MM: '%d ខែ',
6785 y: 'មួយឆ្នាំ',
6786 yy: '%d ឆ្នាំ'
6787 },
6788 week: {
6789 dow: 1, // Monday is the first day of the week.
6790 doy: 4 // The week that contains Jan 4th is the first week of the year.
6791 }
6792 });
6793
6794 //! moment.js locale configuration
6795 //! locale : korean (ko)
6796 //!
6797 //! authors
6798 //!
6799 //! - Kyungwook, Park : https://github.com/kyungw00k
6800 //! - Jeeeyul Lee <jeeeyul@gmail.com>
6801
6802 var ko = _moment__default.defineLocale('ko', {
6803 months : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
6804 monthsShort : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
6805 weekdays : '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
6806 weekdaysShort : '일_월_화_수_목_금_토'.split('_'),
6807 weekdaysMin : '일_월_화_수_목_금_토'.split('_'),
6808 longDateFormat : {
6809 LT : 'A h시 m분',
6810 LTS : 'A h시 m분 s초',
6811 L : 'YYYY.MM.DD',
6812 LL : 'YYYY년 MMMM D일',
6813 LLL : 'YYYY년 MMMM D일 A h시 m분',
6814 LLLL : 'YYYY년 MMMM D일 dddd A h시 m분'
6815 },
6816 calendar : {
6817 sameDay : '오늘 LT',
6818 nextDay : '내일 LT',
6819 nextWeek : 'dddd LT',
6820 lastDay : '어제 LT',
6821 lastWeek : '지난주 dddd LT',
6822 sameElse : 'L'
6823 },
6824 relativeTime : {
6825 future : '%s 후',
6826 past : '%s 전',
6827 s : '몇초',
6828 ss : '%d초',
6829 m : '일분',
6830 mm : '%d분',
6831 h : '한시간',
6832 hh : '%d시간',
6833 d : '하루',
6834 dd : '%d일',
6835 M : '한달',
6836 MM : '%d달',
6837 y : '일년',
6838 yy : '%d년'
6839 },
6840 ordinalParse : /\d{1,2}일/,
6841 ordinal : '%d일',
6842 meridiemParse : /오전|오후/,
6843 isPM : function (token) {
6844 return token === '오후';
6845 },
6846 meridiem : function (hour, minute, isUpper) {
6847 return hour < 12 ? '오전' : '오후';
6848 }
6849 });
6850
6851 //! moment.js locale configuration
6852 //! locale : Luxembourgish (lb)
6853 //! author : mweimerskirch : https://github.com/mweimerskirch, David Raison : https://github.com/kwisatz
6854
6855 function lb__processRelativeTime(number, withoutSuffix, key, isFuture) {
6856 var format = {
6857 'm': ['eng Minutt', 'enger Minutt'],
6858 'h': ['eng Stonn', 'enger Stonn'],
6859 'd': ['een Dag', 'engem Dag'],
6860 'M': ['ee Mount', 'engem Mount'],
6861 'y': ['ee Joer', 'engem Joer']
6862 };
6863 return withoutSuffix ? format[key][0] : format[key][1];
6864 }
6865 function processFutureTime(string) {
6866 var number = string.substr(0, string.indexOf(' '));
6867 if (eifelerRegelAppliesToNumber(number)) {
6868 return 'a ' + string;
6869 }
6870 return 'an ' + string;
6871 }
6872 function processPastTime(string) {
6873 var number = string.substr(0, string.indexOf(' '));
6874 if (eifelerRegelAppliesToNumber(number)) {
6875 return 'viru ' + string;
6876 }
6877 return 'virun ' + string;
6878 }
6879 /**
6880 * Returns true if the word before the given number loses the '-n' ending.
6881 * e.g. 'an 10 Deeg' but 'a 5 Deeg'
6882 *
6883 * @param number {integer}
6884 * @returns {boolean}
6885 */
6886 function eifelerRegelAppliesToNumber(number) {
6887 number = parseInt(number, 10);
6888 if (isNaN(number)) {
6889 return false;
6890 }
6891 if (number < 0) {
6892 // Negative Number --> always true
6893 return true;
6894 } else if (number < 10) {
6895 // Only 1 digit
6896 if (4 <= number && number <= 7) {
6897 return true;
6898 }
6899 return false;
6900 } else if (number < 100) {
6901 // 2 digits
6902 var lastDigit = number % 10, firstDigit = number / 10;
6903 if (lastDigit === 0) {
6904 return eifelerRegelAppliesToNumber(firstDigit);
6905 }
6906 return eifelerRegelAppliesToNumber(lastDigit);
6907 } else if (number < 10000) {
6908 // 3 or 4 digits --> recursively check first digit
6909 while (number >= 10) {
6910 number = number / 10;
6911 }
6912 return eifelerRegelAppliesToNumber(number);
6913 } else {
6914 // Anything larger than 4 digits: recursively check first n-3 digits
6915 number = number / 1000;
6916 return eifelerRegelAppliesToNumber(number);
6917 }
6918 }
6919
6920 var lb = _moment__default.defineLocale('lb', {
6921 months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
6922 monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
6923 weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
6924 weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
6925 weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
6926 longDateFormat: {
6927 LT: 'H:mm [Auer]',
6928 LTS: 'H:mm:ss [Auer]',
6929 L: 'DD.MM.YYYY',
6930 LL: 'D. MMMM YYYY',
6931 LLL: 'D. MMMM YYYY H:mm [Auer]',
6932 LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]'
6933 },
6934 calendar: {
6935 sameDay: '[Haut um] LT',
6936 sameElse: 'L',
6937 nextDay: '[Muer um] LT',
6938 nextWeek: 'dddd [um] LT',
6939 lastDay: '[Gëschter um] LT',
6940 lastWeek: function () {
6941 // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
6942 switch (this.day()) {
6943 case 2:
6944 case 4:
6945 return '[Leschten] dddd [um] LT';
6946 default:
6947 return '[Leschte] dddd [um] LT';
6948 }
6949 }
6950 },
6951 relativeTime : {
6952 future : processFutureTime,
6953 past : processPastTime,
6954 s : 'e puer Sekonnen',
6955 m : lb__processRelativeTime,
6956 mm : '%d Minutten',
6957 h : lb__processRelativeTime,
6958 hh : '%d Stonnen',
6959 d : lb__processRelativeTime,
6960 dd : '%d Deeg',
6961 M : lb__processRelativeTime,
6962 MM : '%d Méint',
6963 y : lb__processRelativeTime,
6964 yy : '%d Joer'
6965 },
6966 ordinalParse: /\d{1,2}\./,
6967 ordinal: '%d.',
6968 week: {
6969 dow: 1, // Monday is the first day of the week.
6970 doy: 4 // The week that contains Jan 4th is the first week of the year.
6971 }
6972 });
6973
6974 //! moment.js locale configuration
6975 //! locale : Lithuanian (lt)
6976 //! author : Mindaugas Mozūras : https://github.com/mmozuras
6977
6978 var lt__units = {
6979 'm' : 'minutė_minutės_minutę',
6980 'mm': 'minutės_minučių_minutes',
6981 'h' : 'valanda_valandos_valandą',
6982 'hh': 'valandos_valandų_valandas',
6983 'd' : 'diena_dienos_dieną',
6984 'dd': 'dienos_dienų_dienas',
6985 'M' : 'mėnuo_mėnesio_mėnesį',
6986 'MM': 'mėnesiai_mėnesių_mėnesius',
6987 'y' : 'metai_metų_metus',
6988 'yy': 'metai_metų_metus'
6989 },
6990 weekDays = 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_');
6991 function translateSeconds(number, withoutSuffix, key, isFuture) {
6992 if (withoutSuffix) {
6993 return 'kelios sekundės';
6994 } else {
6995 return isFuture ? 'kelių sekundžių' : 'kelias sekundes';
6996 }
6997 }
6998 function lt__monthsCaseReplace(m, format) {
6999 var months = {
7000 'nominative': 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
7001 'accusative': 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_')
7002 },
7003 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
7004 'accusative' :
7005 'nominative';
7006 return months[nounCase][m.month()];
7007 }
7008 function translateSingular(number, withoutSuffix, key, isFuture) {
7009 return withoutSuffix ? forms(key)[0] : (isFuture ? forms(key)[1] : forms(key)[2]);
7010 }
7011 function special(number) {
7012 return number % 10 === 0 || (number > 10 && number < 20);
7013 }
7014 function forms(key) {
7015 return lt__units[key].split('_');
7016 }
7017 function lt__translate(number, withoutSuffix, key, isFuture) {
7018 var result = number + ' ';
7019 if (number === 1) {
7020 return result + translateSingular(number, withoutSuffix, key[0], isFuture);
7021 } else if (withoutSuffix) {
7022 return result + (special(number) ? forms(key)[1] : forms(key)[0]);
7023 } else {
7024 if (isFuture) {
7025 return result + forms(key)[1];
7026 } else {
7027 return result + (special(number) ? forms(key)[1] : forms(key)[2]);
7028 }
7029 }
7030 }
7031 function relativeWeekDay(moment, format) {
7032 var nominative = format.indexOf('dddd HH:mm') === -1,
7033 weekDay = weekDays[moment.day()];
7034 return nominative ? weekDay : weekDay.substring(0, weekDay.length - 2) + 'į';
7035 }
7036
7037 var lt = _moment__default.defineLocale('lt', {
7038 months : lt__monthsCaseReplace,
7039 monthsShort : 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'),
7040 weekdays : relativeWeekDay,
7041 weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
7042 weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
7043 longDateFormat : {
7044 LT : 'HH:mm',
7045 LTS : 'HH:mm:ss',
7046 L : 'YYYY-MM-DD',
7047 LL : 'YYYY [m.] MMMM D [d.]',
7048 LLL : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
7049 LLLL : 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]',
7050 l : 'YYYY-MM-DD',
7051 ll : 'YYYY [m.] MMMM D [d.]',
7052 lll : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
7053 llll : 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]'
7054 },
7055 calendar : {
7056 sameDay : '[Šiandien] LT',
7057 nextDay : '[Rytoj] LT',
7058 nextWeek : 'dddd LT',
7059 lastDay : '[Vakar] LT',
7060 lastWeek : '[Praėjusį] dddd LT',
7061 sameElse : 'L'
7062 },
7063 relativeTime : {
7064 future : 'po %s',
7065 past : 'prieš %s',
7066 s : translateSeconds,
7067 m : translateSingular,
7068 mm : lt__translate,
7069 h : translateSingular,
7070 hh : lt__translate,
7071 d : translateSingular,
7072 dd : lt__translate,
7073 M : translateSingular,
7074 MM : lt__translate,
7075 y : translateSingular,
7076 yy : lt__translate
7077 },
7078 ordinalParse: /\d{1,2}-oji/,
7079 ordinal : function (number) {
7080 return number + '-oji';
7081 },
7082 week : {
7083 dow : 1, // Monday is the first day of the week.
7084 doy : 4 // The week that contains Jan 4th is the first week of the year.
7085 }
7086 });
7087
7088 //! moment.js locale configuration
7089 //! locale : latvian (lv)
7090 //! author : Kristaps Karlsons : https://github.com/skakri
7091 //! author : Jānis Elmeris : https://github.com/JanisE
7092
7093 var lv__units = {
7094 'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
7095 'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
7096 'h': 'stundas_stundām_stunda_stundas'.split('_'),
7097 'hh': 'stundas_stundām_stunda_stundas'.split('_'),
7098 'd': 'dienas_dienām_diena_dienas'.split('_'),
7099 'dd': 'dienas_dienām_diena_dienas'.split('_'),
7100 'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
7101 'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
7102 'y': 'gada_gadiem_gads_gadi'.split('_'),
7103 'yy': 'gada_gadiem_gads_gadi'.split('_')
7104 };
7105 /**
7106 * @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
7107 */
7108 function lv__format(forms, number, withoutSuffix) {
7109 if (withoutSuffix) {
7110 // E.g. "21 minūte", "3 minūtes".
7111 return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
7112 } else {
7113 // E.g. "21 minūtes" as in "pēc 21 minūtes".
7114 // E.g. "3 minūtēm" as in "pēc 3 minūtēm".
7115 return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
7116 }
7117 }
7118 function lv__relativeTimeWithPlural(number, withoutSuffix, key) {
7119 return number + ' ' + lv__format(lv__units[key], number, withoutSuffix);
7120 }
7121 function relativeTimeWithSingular(number, withoutSuffix, key) {
7122 return lv__format(lv__units[key], number, withoutSuffix);
7123 }
7124 function relativeSeconds(number, withoutSuffix) {
7125 return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
7126 }
7127
7128 var lv = _moment__default.defineLocale('lv', {
7129 months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
7130 monthsShort : 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'),
7131 weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
7132 weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
7133 weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
7134 longDateFormat : {
7135 LT : 'HH:mm',
7136 LTS : 'HH:mm:ss',
7137 L : 'DD.MM.YYYY.',
7138 LL : 'YYYY. [gada] D. MMMM',
7139 LLL : 'YYYY. [gada] D. MMMM, HH:mm',
7140 LLLL : 'YYYY. [gada] D. MMMM, dddd, HH:mm'
7141 },
7142 calendar : {
7143 sameDay : '[Šodien pulksten] LT',
7144 nextDay : '[Rīt pulksten] LT',
7145 nextWeek : 'dddd [pulksten] LT',
7146 lastDay : '[Vakar pulksten] LT',
7147 lastWeek : '[Pagājušā] dddd [pulksten] LT',
7148 sameElse : 'L'
7149 },
7150 relativeTime : {
7151 future : 'pēc %s',
7152 past : 'pirms %s',
7153 s : relativeSeconds,
7154 m : relativeTimeWithSingular,
7155 mm : lv__relativeTimeWithPlural,
7156 h : relativeTimeWithSingular,
7157 hh : lv__relativeTimeWithPlural,
7158 d : relativeTimeWithSingular,
7159 dd : lv__relativeTimeWithPlural,
7160 M : relativeTimeWithSingular,
7161 MM : lv__relativeTimeWithPlural,
7162 y : relativeTimeWithSingular,
7163 yy : lv__relativeTimeWithPlural
7164 },
7165 ordinalParse: /\d{1,2}\./,
7166 ordinal : '%d.',
7167 week : {
7168 dow : 1, // Monday is the first day of the week.
7169 doy : 4 // The week that contains Jan 4th is the first week of the year.
7170 }
7171 });
7172
7173 //! moment.js locale configuration
7174 //! locale : Montenegrin (me)
7175 //! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
7176
7177 var me__translator = {
7178 words: { //Different grammatical cases
7179 m: ['jedan minut', 'jednog minuta'],
7180 mm: ['minut', 'minuta', 'minuta'],
7181 h: ['jedan sat', 'jednog sata'],
7182 hh: ['sat', 'sata', 'sati'],
7183 dd: ['dan', 'dana', 'dana'],
7184 MM: ['mjesec', 'mjeseca', 'mjeseci'],
7185 yy: ['godina', 'godine', 'godina']
7186 },
7187 correctGrammaticalCase: function (number, wordKey) {
7188 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
7189 },
7190 translate: function (number, withoutSuffix, key) {
7191 var wordKey = me__translator.words[key];
7192 if (key.length === 1) {
7193 return withoutSuffix ? wordKey[0] : wordKey[1];
7194 } else {
7195 return number + ' ' + me__translator.correctGrammaticalCase(number, wordKey);
7196 }
7197 }
7198 };
7199
7200 var me = _moment__default.defineLocale('me', {
7201 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
7202 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
7203 weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
7204 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
7205 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
7206 longDateFormat: {
7207 LT: 'H:mm',
7208 LTS : 'H:mm:ss',
7209 L: 'DD. MM. YYYY',
7210 LL: 'D. MMMM YYYY',
7211 LLL: 'D. MMMM YYYY H:mm',
7212 LLLL: 'dddd, D. MMMM YYYY H:mm'
7213 },
7214 calendar: {
7215 sameDay: '[danas u] LT',
7216 nextDay: '[sjutra u] LT',
7217
7218 nextWeek: function () {
7219 switch (this.day()) {
7220 case 0:
7221 return '[u] [nedjelju] [u] LT';
7222 case 3:
7223 return '[u] [srijedu] [u] LT';
7224 case 6:
7225 return '[u] [subotu] [u] LT';
7226 case 1:
7227 case 2:
7228 case 4:
7229 case 5:
7230 return '[u] dddd [u] LT';
7231 }
7232 },
7233 lastDay : '[juče u] LT',
7234 lastWeek : function () {
7235 var lastWeekDays = [
7236 '[prošle] [nedjelje] [u] LT',
7237 '[prošlog] [ponedjeljka] [u] LT',
7238 '[prošlog] [utorka] [u] LT',
7239 '[prošle] [srijede] [u] LT',
7240 '[prošlog] [četvrtka] [u] LT',
7241 '[prošlog] [petka] [u] LT',
7242 '[prošle] [subote] [u] LT'
7243 ];
7244 return lastWeekDays[this.day()];
7245 },
7246 sameElse : 'L'
7247 },
7248 relativeTime : {
7249 future : 'za %s',
7250 past : 'prije %s',
7251 s : 'nekoliko sekundi',
7252 m : me__translator.translate,
7253 mm : me__translator.translate,
7254 h : me__translator.translate,
7255 hh : me__translator.translate,
7256 d : 'dan',
7257 dd : me__translator.translate,
7258 M : 'mjesec',
7259 MM : me__translator.translate,
7260 y : 'godinu',
7261 yy : me__translator.translate
7262 },
7263 ordinalParse: /\d{1,2}\./,
7264 ordinal : '%d.',
7265 week : {
7266 dow : 1, // Monday is the first day of the week.
7267 doy : 7 // The week that contains Jan 1st is the first week of the year.
7268 }
7269 });
7270
7271 //! moment.js locale configuration
7272 //! locale : macedonian (mk)
7273 //! author : Borislav Mickov : https://github.com/B0k0
7274
7275 var mk = _moment__default.defineLocale('mk', {
7276 months : 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'),
7277 monthsShort : 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'),
7278 weekdays : 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'),
7279 weekdaysShort : 'нед_пон_вто_сре_чет_пет_саб'.split('_'),
7280 weekdaysMin : 'нe_пo_вт_ср_че_пе_сa'.split('_'),
7281 longDateFormat : {
7282 LT : 'H:mm',
7283 LTS : 'H:mm:ss',
7284 L : 'D.MM.YYYY',
7285 LL : 'D MMMM YYYY',
7286 LLL : 'D MMMM YYYY H:mm',
7287 LLLL : 'dddd, D MMMM YYYY H:mm'
7288 },
7289 calendar : {
7290 sameDay : '[Денес во] LT',
7291 nextDay : '[Утре во] LT',
7292 nextWeek : 'dddd [во] LT',
7293 lastDay : '[Вчера во] LT',
7294 lastWeek : function () {
7295 switch (this.day()) {
7296 case 0:
7297 case 3:
7298 case 6:
7299 return '[Во изминатата] dddd [во] LT';
7300 case 1:
7301 case 2:
7302 case 4:
7303 case 5:
7304 return '[Во изминатиот] dddd [во] LT';
7305 }
7306 },
7307 sameElse : 'L'
7308 },
7309 relativeTime : {
7310 future : 'после %s',
7311 past : 'пред %s',
7312 s : 'неколку секунди',
7313 m : 'минута',
7314 mm : '%d минути',
7315 h : 'час',
7316 hh : '%d часа',
7317 d : 'ден',
7318 dd : '%d дена',
7319 M : 'месец',
7320 MM : '%d месеци',
7321 y : 'година',
7322 yy : '%d години'
7323 },
7324 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
7325 ordinal : function (number) {
7326 var lastDigit = number % 10,
7327 last2Digits = number % 100;
7328 if (number === 0) {
7329 return number + '-ев';
7330 } else if (last2Digits === 0) {
7331 return number + '-ен';
7332 } else if (last2Digits > 10 && last2Digits < 20) {
7333 return number + '-ти';
7334 } else if (lastDigit === 1) {
7335 return number + '-ви';
7336 } else if (lastDigit === 2) {
7337 return number + '-ри';
7338 } else if (lastDigit === 7 || lastDigit === 8) {
7339 return number + '-ми';
7340 } else {
7341 return number + '-ти';
7342 }
7343 },
7344 week : {
7345 dow : 1, // Monday is the first day of the week.
7346 doy : 7 // The week that contains Jan 1st is the first week of the year.
7347 }
7348 });
7349
7350 //! moment.js locale configuration
7351 //! locale : malayalam (ml)
7352 //! author : Floyd Pink : https://github.com/floydpink
7353
7354 var ml = _moment__default.defineLocale('ml', {
7355 months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
7356 monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
7357 weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
7358 weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
7359 weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
7360 longDateFormat : {
7361 LT : 'A h:mm -നു',
7362 LTS : 'A h:mm:ss -നു',
7363 L : 'DD/MM/YYYY',
7364 LL : 'D MMMM YYYY',
7365 LLL : 'D MMMM YYYY, A h:mm -നു',
7366 LLLL : 'dddd, D MMMM YYYY, A h:mm -നു'
7367 },
7368 calendar : {
7369 sameDay : '[ഇന്ന്] LT',
7370 nextDay : '[നാളെ] LT',
7371 nextWeek : 'dddd, LT',
7372 lastDay : '[ഇന്നലെ] LT',
7373 lastWeek : '[കഴിഞ്ഞ] dddd, LT',
7374 sameElse : 'L'
7375 },
7376 relativeTime : {
7377 future : '%s കഴിഞ്ഞ്',
7378 past : '%s മുൻപ്',
7379 s : 'അൽപ നിമിഷങ്ങൾ',
7380 m : 'ഒരു മിനിറ്റ്',
7381 mm : '%d മിനിറ്റ്',
7382 h : 'ഒരു മണിക്കൂർ',
7383 hh : '%d മണിക്കൂർ',
7384 d : 'ഒരു ദിവസം',
7385 dd : '%d ദിവസം',
7386 M : 'ഒരു മാസം',
7387 MM : '%d മാസം',
7388 y : 'ഒരു വർഷം',
7389 yy : '%d വർഷം'
7390 },
7391 meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
7392 isPM : function (input) {
7393 return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
7394 },
7395 meridiem : function (hour, minute, isLower) {
7396 if (hour < 4) {
7397 return 'രാത്രി';
7398 } else if (hour < 12) {
7399 return 'രാവിലെ';
7400 } else if (hour < 17) {
7401 return 'ഉച്ച കഴിഞ്ഞ്';
7402 } else if (hour < 20) {
7403 return 'വൈകുന്നേരം';
7404 } else {
7405 return 'രാത്രി';
7406 }
7407 }
7408 });
7409
7410 //! moment.js locale configuration
7411 //! locale : Marathi (mr)
7412 //! author : Harshad Kale : https://github.com/kalehv
7413
7414 var mr__symbolMap = {
7415 '1': '१',
7416 '2': '२',
7417 '3': '३',
7418 '4': '४',
7419 '5': '५',
7420 '6': '६',
7421 '7': '७',
7422 '8': '८',
7423 '9': '९',
7424 '0': '०'
7425 },
7426 mr__numberMap = {
7427 '१': '1',
7428 '२': '2',
7429 '३': '3',
7430 '४': '4',
7431 '५': '5',
7432 '६': '6',
7433 '७': '7',
7434 '८': '8',
7435 '९': '9',
7436 '०': '0'
7437 };
7438
7439 var mr = _moment__default.defineLocale('mr', {
7440 months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
7441 monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
7442 weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
7443 weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
7444 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
7445 longDateFormat : {
7446 LT : 'A h:mm वाजता',
7447 LTS : 'A h:mm:ss वाजता',
7448 L : 'DD/MM/YYYY',
7449 LL : 'D MMMM YYYY',
7450 LLL : 'D MMMM YYYY, A h:mm वाजता',
7451 LLLL : 'dddd, D MMMM YYYY, A h:mm वाजता'
7452 },
7453 calendar : {
7454 sameDay : '[आज] LT',
7455 nextDay : '[उद्या] LT',
7456 nextWeek : 'dddd, LT',
7457 lastDay : '[काल] LT',
7458 lastWeek: '[मागील] dddd, LT',
7459 sameElse : 'L'
7460 },
7461 relativeTime : {
7462 future : '%s नंतर',
7463 past : '%s पूर्वी',
7464 s : 'सेकंद',
7465 m: 'एक मिनिट',
7466 mm: '%d मिनिटे',
7467 h : 'एक तास',
7468 hh : '%d तास',
7469 d : 'एक दिवस',
7470 dd : '%d दिवस',
7471 M : 'एक महिना',
7472 MM : '%d महिने',
7473 y : 'एक वर्ष',
7474 yy : '%d वर्षे'
7475 },
7476 preparse: function (string) {
7477 return string.replace(/[१२३४५६७८९०]/g, function (match) {
7478 return mr__numberMap[match];
7479 });
7480 },
7481 postformat: function (string) {
7482 return string.replace(/\d/g, function (match) {
7483 return mr__symbolMap[match];
7484 });
7485 },
7486 meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी/,
7487 meridiemHour : function (hour, meridiem) {
7488 if (hour === 12) {
7489 hour = 0;
7490 }
7491 if (meridiem === 'रात्री') {
7492 return hour < 4 ? hour : hour + 12;
7493 } else if (meridiem === 'सकाळी') {
7494 return hour;
7495 } else if (meridiem === 'दुपारी') {
7496 return hour >= 10 ? hour : hour + 12;
7497 } else if (meridiem === 'सायंकाळी') {
7498 return hour + 12;
7499 }
7500 },
7501 meridiem: function (hour, minute, isLower) {
7502 if (hour < 4) {
7503 return 'रात्री';
7504 } else if (hour < 10) {
7505 return 'सकाळी';
7506 } else if (hour < 17) {
7507 return 'दुपारी';
7508 } else if (hour < 20) {
7509 return 'सायंकाळी';
7510 } else {
7511 return 'रात्री';
7512 }
7513 },
7514 week : {
7515 dow : 0, // Sunday is the first day of the week.
7516 doy : 6 // The week that contains Jan 1st is the first week of the year.
7517 }
7518 });
7519
7520 //! moment.js locale configuration
7521 //! locale : Bahasa Malaysia (ms-MY)
7522 //! author : Weldan Jamili : https://github.com/weldan
7523
7524 var ms_my = _moment__default.defineLocale('ms-my', {
7525 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
7526 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
7527 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
7528 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
7529 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
7530 longDateFormat : {
7531 LT : 'HH.mm',
7532 LTS : 'HH.mm.ss',
7533 L : 'DD/MM/YYYY',
7534 LL : 'D MMMM YYYY',
7535 LLL : 'D MMMM YYYY [pukul] HH.mm',
7536 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
7537 },
7538 meridiemParse: /pagi|tengahari|petang|malam/,
7539 meridiemHour: function (hour, meridiem) {
7540 if (hour === 12) {
7541 hour = 0;
7542 }
7543 if (meridiem === 'pagi') {
7544 return hour;
7545 } else if (meridiem === 'tengahari') {
7546 return hour >= 11 ? hour : hour + 12;
7547 } else if (meridiem === 'petang' || meridiem === 'malam') {
7548 return hour + 12;
7549 }
7550 },
7551 meridiem : function (hours, minutes, isLower) {
7552 if (hours < 11) {
7553 return 'pagi';
7554 } else if (hours < 15) {
7555 return 'tengahari';
7556 } else if (hours < 19) {
7557 return 'petang';
7558 } else {
7559 return 'malam';
7560 }
7561 },
7562 calendar : {
7563 sameDay : '[Hari ini pukul] LT',
7564 nextDay : '[Esok pukul] LT',
7565 nextWeek : 'dddd [pukul] LT',
7566 lastDay : '[Kelmarin pukul] LT',
7567 lastWeek : 'dddd [lepas pukul] LT',
7568 sameElse : 'L'
7569 },
7570 relativeTime : {
7571 future : 'dalam %s',
7572 past : '%s yang lepas',
7573 s : 'beberapa saat',
7574 m : 'seminit',
7575 mm : '%d minit',
7576 h : 'sejam',
7577 hh : '%d jam',
7578 d : 'sehari',
7579 dd : '%d hari',
7580 M : 'sebulan',
7581 MM : '%d bulan',
7582 y : 'setahun',
7583 yy : '%d tahun'
7584 },
7585 week : {
7586 dow : 1, // Monday is the first day of the week.
7587 doy : 7 // The week that contains Jan 1st is the first week of the year.
7588 }
7589 });
7590
7591 //! moment.js locale configuration
7592 //! locale : Bahasa Malaysia (ms-MY)
7593 //! author : Weldan Jamili : https://github.com/weldan
7594
7595 var locale_ms = _moment__default.defineLocale('ms', {
7596 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
7597 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
7598 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
7599 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
7600 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
7601 longDateFormat : {
7602 LT : 'HH.mm',
7603 LTS : 'HH.mm.ss',
7604 L : 'DD/MM/YYYY',
7605 LL : 'D MMMM YYYY',
7606 LLL : 'D MMMM YYYY [pukul] HH.mm',
7607 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
7608 },
7609 meridiemParse: /pagi|tengahari|petang|malam/,
7610 meridiemHour: function (hour, meridiem) {
7611 if (hour === 12) {
7612 hour = 0;
7613 }
7614 if (meridiem === 'pagi') {
7615 return hour;
7616 } else if (meridiem === 'tengahari') {
7617 return hour >= 11 ? hour : hour + 12;
7618 } else if (meridiem === 'petang' || meridiem === 'malam') {
7619 return hour + 12;
7620 }
7621 },
7622 meridiem : function (hours, minutes, isLower) {
7623 if (hours < 11) {
7624 return 'pagi';
7625 } else if (hours < 15) {
7626 return 'tengahari';
7627 } else if (hours < 19) {
7628 return 'petang';
7629 } else {
7630 return 'malam';
7631 }
7632 },
7633 calendar : {
7634 sameDay : '[Hari ini pukul] LT',
7635 nextDay : '[Esok pukul] LT',
7636 nextWeek : 'dddd [pukul] LT',
7637 lastDay : '[Kelmarin pukul] LT',
7638 lastWeek : 'dddd [lepas pukul] LT',
7639 sameElse : 'L'
7640 },
7641 relativeTime : {
7642 future : 'dalam %s',
7643 past : '%s yang lepas',
7644 s : 'beberapa saat',
7645 m : 'seminit',
7646 mm : '%d minit',
7647 h : 'sejam',
7648 hh : '%d jam',
7649 d : 'sehari',
7650 dd : '%d hari',
7651 M : 'sebulan',
7652 MM : '%d bulan',
7653 y : 'setahun',
7654 yy : '%d tahun'
7655 },
7656 week : {
7657 dow : 1, // Monday is the first day of the week.
7658 doy : 7 // The week that contains Jan 1st is the first week of the year.
7659 }
7660 });
7661
7662 //! moment.js locale configuration
7663 //! locale : Burmese (my)
7664 //! author : Squar team, mysquar.com
7665
7666 var my__symbolMap = {
7667 '1': '၁',
7668 '2': '၂',
7669 '3': '၃',
7670 '4': '၄',
7671 '5': '၅',
7672 '6': '၆',
7673 '7': '၇',
7674 '8': '၈',
7675 '9': '၉',
7676 '0': '၀'
7677 }, my__numberMap = {
7678 '၁': '1',
7679 '၂': '2',
7680 '၃': '3',
7681 '၄': '4',
7682 '၅': '5',
7683 '၆': '6',
7684 '၇': '7',
7685 '၈': '8',
7686 '၉': '9',
7687 '၀': '0'
7688 };
7689
7690 var my = _moment__default.defineLocale('my', {
7691 months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
7692 monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
7693 weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
7694 weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
7695 weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
7696
7697 longDateFormat: {
7698 LT: 'HH:mm',
7699 LTS: 'HH:mm:ss',
7700 L: 'DD/MM/YYYY',
7701 LL: 'D MMMM YYYY',
7702 LLL: 'D MMMM YYYY HH:mm',
7703 LLLL: 'dddd D MMMM YYYY HH:mm'
7704 },
7705 calendar: {
7706 sameDay: '[ယနေ.] LT [မှာ]',
7707 nextDay: '[မနက်ဖြန်] LT [မှာ]',
7708 nextWeek: 'dddd LT [မှာ]',
7709 lastDay: '[မနေ.က] LT [မှာ]',
7710 lastWeek: '[ပြီးခဲ့သော] dddd LT [မှာ]',
7711 sameElse: 'L'
7712 },
7713 relativeTime: {
7714 future: 'လာမည့် %s မှာ',
7715 past: 'လွန်ခဲ့သော %s က',
7716 s: 'စက္ကန်.အနည်းငယ်',
7717 m: 'တစ်မိနစ်',
7718 mm: '%d မိနစ်',
7719 h: 'တစ်နာရီ',
7720 hh: '%d နာရီ',
7721 d: 'တစ်ရက်',
7722 dd: '%d ရက်',
7723 M: 'တစ်လ',
7724 MM: '%d လ',
7725 y: 'တစ်နှစ်',
7726 yy: '%d နှစ်'
7727 },
7728 preparse: function (string) {
7729 return string.replace(/[၁၂၃၄၅၆၇၈၉၀]/g, function (match) {
7730 return my__numberMap[match];
7731 });
7732 },
7733 postformat: function (string) {
7734 return string.replace(/\d/g, function (match) {
7735 return my__symbolMap[match];
7736 });
7737 },
7738 week: {
7739 dow: 1, // Monday is the first day of the week.
7740 doy: 4 // The week that contains Jan 1st is the first week of the year.
7741 }
7742 });
7743
7744 //! moment.js locale configuration
7745 //! locale : norwegian bokmål (nb)
7746 //! authors : Espen Hovlandsdal : https://github.com/rexxars
7747 //! Sigurd Gartmann : https://github.com/sigurdga
7748
7749 var nb = _moment__default.defineLocale('nb', {
7750 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
7751 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
7752 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
7753 weekdaysShort : 'søn_man_tirs_ons_tors_fre_lør'.split('_'),
7754 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
7755 longDateFormat : {
7756 LT : 'H.mm',
7757 LTS : 'H.mm.ss',
7758 L : 'DD.MM.YYYY',
7759 LL : 'D. MMMM YYYY',
7760 LLL : 'D. MMMM YYYY [kl.] H.mm',
7761 LLLL : 'dddd D. MMMM YYYY [kl.] H.mm'
7762 },
7763 calendar : {
7764 sameDay: '[i dag kl.] LT',
7765 nextDay: '[i morgen kl.] LT',
7766 nextWeek: 'dddd [kl.] LT',
7767 lastDay: '[i går kl.] LT',
7768 lastWeek: '[forrige] dddd [kl.] LT',
7769 sameElse: 'L'
7770 },
7771 relativeTime : {
7772 future : 'om %s',
7773 past : 'for %s siden',
7774 s : 'noen sekunder',
7775 m : 'ett minutt',
7776 mm : '%d minutter',
7777 h : 'en time',
7778 hh : '%d timer',
7779 d : 'en dag',
7780 dd : '%d dager',
7781 M : 'en måned',
7782 MM : '%d måneder',
7783 y : 'ett år',
7784 yy : '%d år'
7785 },
7786 ordinalParse: /\d{1,2}\./,
7787 ordinal : '%d.',
7788 week : {
7789 dow : 1, // Monday is the first day of the week.
7790 doy : 4 // The week that contains Jan 4th is the first week of the year.
7791 }
7792 });
7793
7794 //! moment.js locale configuration
7795 //! locale : nepali/nepalese
7796 //! author : suvash : https://github.com/suvash
7797
7798 var ne__symbolMap = {
7799 '1': '१',
7800 '2': '२',
7801 '3': '३',
7802 '4': '४',
7803 '5': '५',
7804 '6': '६',
7805 '7': '७',
7806 '8': '८',
7807 '9': '९',
7808 '0': '०'
7809 },
7810 ne__numberMap = {
7811 '१': '1',
7812 '२': '2',
7813 '३': '3',
7814 '४': '4',
7815 '५': '5',
7816 '६': '6',
7817 '७': '7',
7818 '८': '8',
7819 '९': '9',
7820 '०': '0'
7821 };
7822
7823 var ne = _moment__default.defineLocale('ne', {
7824 months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
7825 monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
7826 weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
7827 weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
7828 weekdaysMin : 'आइ._सो._मङ्_बु._बि._शु._श.'.split('_'),
7829 longDateFormat : {
7830 LT : 'Aको h:mm बजे',
7831 LTS : 'Aको h:mm:ss बजे',
7832 L : 'DD/MM/YYYY',
7833 LL : 'D MMMM YYYY',
7834 LLL : 'D MMMM YYYY, Aको h:mm बजे',
7835 LLLL : 'dddd, D MMMM YYYY, Aको h:mm बजे'
7836 },
7837 preparse: function (string) {
7838 return string.replace(/[१२३४५६७८९०]/g, function (match) {
7839 return ne__numberMap[match];
7840 });
7841 },
7842 postformat: function (string) {
7843 return string.replace(/\d/g, function (match) {
7844 return ne__symbolMap[match];
7845 });
7846 },
7847 meridiemParse: /राती|बिहान|दिउँसो|बेलुका|साँझ|राती/,
7848 meridiemHour : function (hour, meridiem) {
7849 if (hour === 12) {
7850 hour = 0;
7851 }
7852 if (meridiem === 'राती') {
7853 return hour < 3 ? hour : hour + 12;
7854 } else if (meridiem === 'बिहान') {
7855 return hour;
7856 } else if (meridiem === 'दिउँसो') {
7857 return hour >= 10 ? hour : hour + 12;
7858 } else if (meridiem === 'बेलुका' || meridiem === 'साँझ') {
7859 return hour + 12;
7860 }
7861 },
7862 meridiem : function (hour, minute, isLower) {
7863 if (hour < 3) {
7864 return 'राती';
7865 } else if (hour < 10) {
7866 return 'बिहान';
7867 } else if (hour < 15) {
7868 return 'दिउँसो';
7869 } else if (hour < 18) {
7870 return 'बेलुका';
7871 } else if (hour < 20) {
7872 return 'साँझ';
7873 } else {
7874 return 'राती';
7875 }
7876 },
7877 calendar : {
7878 sameDay : '[आज] LT',
7879 nextDay : '[भोली] LT',
7880 nextWeek : '[आउँदो] dddd[,] LT',
7881 lastDay : '[हिजो] LT',
7882 lastWeek : '[गएको] dddd[,] LT',
7883 sameElse : 'L'
7884 },
7885 relativeTime : {
7886 future : '%sमा',
7887 past : '%s अगाडी',
7888 s : 'केही समय',
7889 m : 'एक मिनेट',
7890 mm : '%d मिनेट',
7891 h : 'एक घण्टा',
7892 hh : '%d घण्टा',
7893 d : 'एक दिन',
7894 dd : '%d दिन',
7895 M : 'एक महिना',
7896 MM : '%d महिना',
7897 y : 'एक बर्ष',
7898 yy : '%d बर्ष'
7899 },
7900 week : {
7901 dow : 1, // Monday is the first day of the week.
7902 doy : 7 // The week that contains Jan 1st is the first week of the year.
7903 }
7904 });
7905
7906 //! moment.js locale configuration
7907 //! locale : dutch (nl)
7908 //! author : Joris Röling : https://github.com/jjupiter
7909
7910 var nl__monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'),
7911 nl__monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
7912
7913 var nl = _moment__default.defineLocale('nl', {
7914 months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
7915 monthsShort : function (m, format) {
7916 if (/-MMM-/.test(format)) {
7917 return nl__monthsShortWithoutDots[m.month()];
7918 } else {
7919 return nl__monthsShortWithDots[m.month()];
7920 }
7921 },
7922 weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
7923 weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
7924 weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
7925 longDateFormat : {
7926 LT : 'HH:mm',
7927 LTS : 'HH:mm:ss',
7928 L : 'DD-MM-YYYY',
7929 LL : 'D MMMM YYYY',
7930 LLL : 'D MMMM YYYY HH:mm',
7931 LLLL : 'dddd D MMMM YYYY HH:mm'
7932 },
7933 calendar : {
7934 sameDay: '[vandaag om] LT',
7935 nextDay: '[morgen om] LT',
7936 nextWeek: 'dddd [om] LT',
7937 lastDay: '[gisteren om] LT',
7938 lastWeek: '[afgelopen] dddd [om] LT',
7939 sameElse: 'L'
7940 },
7941 relativeTime : {
7942 future : 'over %s',
7943 past : '%s geleden',
7944 s : 'een paar seconden',
7945 m : 'één minuut',
7946 mm : '%d minuten',
7947 h : 'één uur',
7948 hh : '%d uur',
7949 d : 'één dag',
7950 dd : '%d dagen',
7951 M : 'één maand',
7952 MM : '%d maanden',
7953 y : 'één jaar',
7954 yy : '%d jaar'
7955 },
7956 ordinalParse: /\d{1,2}(ste|de)/,
7957 ordinal : function (number) {
7958 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
7959 },
7960 week : {
7961 dow : 1, // Monday is the first day of the week.
7962 doy : 4 // The week that contains Jan 4th is the first week of the year.
7963 }
7964 });
7965
7966 //! moment.js locale configuration
7967 //! locale : norwegian nynorsk (nn)
7968 //! author : https://github.com/mechuwind
7969
7970 var nn = _moment__default.defineLocale('nn', {
7971 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
7972 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
7973 weekdays : 'sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag'.split('_'),
7974 weekdaysShort : 'sun_mån_tys_ons_tor_fre_lau'.split('_'),
7975 weekdaysMin : 'su_må_ty_on_to_fr_lø'.split('_'),
7976 longDateFormat : {
7977 LT : 'HH:mm',
7978 LTS : 'HH:mm:ss',
7979 L : 'DD.MM.YYYY',
7980 LL : 'D MMMM YYYY',
7981 LLL : 'D MMMM YYYY HH:mm',
7982 LLLL : 'dddd D MMMM YYYY HH:mm'
7983 },
7984 calendar : {
7985 sameDay: '[I dag klokka] LT',
7986 nextDay: '[I morgon klokka] LT',
7987 nextWeek: 'dddd [klokka] LT',
7988 lastDay: '[I går klokka] LT',
7989 lastWeek: '[Føregåande] dddd [klokka] LT',
7990 sameElse: 'L'
7991 },
7992 relativeTime : {
7993 future : 'om %s',
7994 past : 'for %s sidan',
7995 s : 'nokre sekund',
7996 m : 'eit minutt',
7997 mm : '%d minutt',
7998 h : 'ein time',
7999 hh : '%d timar',
8000 d : 'ein dag',
8001 dd : '%d dagar',
8002 M : 'ein månad',
8003 MM : '%d månader',
8004 y : 'eit år',
8005 yy : '%d år'
8006 },
8007 ordinalParse: /\d{1,2}\./,
8008 ordinal : '%d.',
8009 week : {
8010 dow : 1, // Monday is the first day of the week.
8011 doy : 4 // The week that contains Jan 4th is the first week of the year.
8012 }
8013 });
8014
8015 //! moment.js locale configuration
8016 //! locale : polish (pl)
8017 //! author : Rafal Hirsz : https://github.com/evoL
8018
8019 var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_'),
8020 monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
8021 function pl__plural(n) {
8022 return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1);
8023 }
8024 function pl__translate(number, withoutSuffix, key) {
8025 var result = number + ' ';
8026 switch (key) {
8027 case 'm':
8028 return withoutSuffix ? 'minuta' : 'minutę';
8029 case 'mm':
8030 return result + (pl__plural(number) ? 'minuty' : 'minut');
8031 case 'h':
8032 return withoutSuffix ? 'godzina' : 'godzinę';
8033 case 'hh':
8034 return result + (pl__plural(number) ? 'godziny' : 'godzin');
8035 case 'MM':
8036 return result + (pl__plural(number) ? 'miesiące' : 'miesięcy');
8037 case 'yy':
8038 return result + (pl__plural(number) ? 'lata' : 'lat');
8039 }
8040 }
8041
8042 var pl = _moment__default.defineLocale('pl', {
8043 months : function (momentToFormat, format) {
8044 if (format === '') {
8045 // Hack: if format empty we know this is used to generate
8046 // RegExp by moment. Give then back both valid forms of months
8047 // in RegExp ready format.
8048 return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
8049 } else if (/D MMMM/.test(format)) {
8050 return monthsSubjective[momentToFormat.month()];
8051 } else {
8052 return monthsNominative[momentToFormat.month()];
8053 }
8054 },
8055 monthsShort : 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
8056 weekdays : 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
8057 weekdaysShort : 'nie_pon_wt_śr_czw_pt_sb'.split('_'),
8058 weekdaysMin : 'N_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
8059 longDateFormat : {
8060 LT : 'HH:mm',
8061 LTS : 'HH:mm:ss',
8062 L : 'DD.MM.YYYY',
8063 LL : 'D MMMM YYYY',
8064 LLL : 'D MMMM YYYY HH:mm',
8065 LLLL : 'dddd, D MMMM YYYY HH:mm'
8066 },
8067 calendar : {
8068 sameDay: '[Dziś o] LT',
8069 nextDay: '[Jutro o] LT',
8070 nextWeek: '[W] dddd [o] LT',
8071 lastDay: '[Wczoraj o] LT',
8072 lastWeek: function () {
8073 switch (this.day()) {
8074 case 0:
8075 return '[W zeszłą niedzielę o] LT';
8076 case 3:
8077 return '[W zeszłą środę o] LT';
8078 case 6:
8079 return '[W zeszłą sobotę o] LT';
8080 default:
8081 return '[W zeszły] dddd [o] LT';
8082 }
8083 },
8084 sameElse: 'L'
8085 },
8086 relativeTime : {
8087 future : 'za %s',
8088 past : '%s temu',
8089 s : 'kilka sekund',
8090 m : pl__translate,
8091 mm : pl__translate,
8092 h : pl__translate,
8093 hh : pl__translate,
8094 d : '1 dzień',
8095 dd : '%d dni',
8096 M : 'miesiąc',
8097 MM : pl__translate,
8098 y : 'rok',
8099 yy : pl__translate
8100 },
8101 ordinalParse: /\d{1,2}\./,
8102 ordinal : '%d.',
8103 week : {
8104 dow : 1, // Monday is the first day of the week.
8105 doy : 4 // The week that contains Jan 4th is the first week of the year.
8106 }
8107 });
8108
8109 //! moment.js locale configuration
8110 //! locale : brazilian portuguese (pt-br)
8111 //! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
8112
8113 var pt_br = _moment__default.defineLocale('pt-br', {
8114 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
8115 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
8116 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
8117 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
8118 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
8119 longDateFormat : {
8120 LT : 'HH:mm',
8121 LTS : 'HH:mm:ss',
8122 L : 'DD/MM/YYYY',
8123 LL : 'D [de] MMMM [de] YYYY',
8124 LLL : 'D [de] MMMM [de] YYYY [às] HH:mm',
8125 LLLL : 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'
8126 },
8127 calendar : {
8128 sameDay: '[Hoje às] LT',
8129 nextDay: '[Amanhã às] LT',
8130 nextWeek: 'dddd [às] LT',
8131 lastDay: '[Ontem às] LT',
8132 lastWeek: function () {
8133 return (this.day() === 0 || this.day() === 6) ?
8134 '[Último] dddd [às] LT' : // Saturday + Sunday
8135 '[Última] dddd [às] LT'; // Monday - Friday
8136 },
8137 sameElse: 'L'
8138 },
8139 relativeTime : {
8140 future : 'em %s',
8141 past : '%s atrás',
8142 s : 'poucos segundos',
8143 m : 'um minuto',
8144 mm : '%d minutos',
8145 h : 'uma hora',
8146 hh : '%d horas',
8147 d : 'um dia',
8148 dd : '%d dias',
8149 M : 'um mês',
8150 MM : '%d meses',
8151 y : 'um ano',
8152 yy : '%d anos'
8153 },
8154 ordinalParse: /\d{1,2}º/,
8155 ordinal : '%dº'
8156 });
8157
8158 //! moment.js locale configuration
8159 //! locale : portuguese (pt)
8160 //! author : Jefferson : https://github.com/jalex79
8161
8162 var pt = _moment__default.defineLocale('pt', {
8163 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
8164 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
8165 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
8166 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
8167 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
8168 longDateFormat : {
8169 LT : 'HH:mm',
8170 LTS : 'HH:mm:ss',
8171 L : 'DD/MM/YYYY',
8172 LL : 'D [de] MMMM [de] YYYY',
8173 LLL : 'D [de] MMMM [de] YYYY HH:mm',
8174 LLLL : 'dddd, D [de] MMMM [de] YYYY HH:mm'
8175 },
8176 calendar : {
8177 sameDay: '[Hoje às] LT',
8178 nextDay: '[Amanhã às] LT',
8179 nextWeek: 'dddd [às] LT',
8180 lastDay: '[Ontem às] LT',
8181 lastWeek: function () {
8182 return (this.day() === 0 || this.day() === 6) ?
8183 '[Último] dddd [às] LT' : // Saturday + Sunday
8184 '[Última] dddd [às] LT'; // Monday - Friday
8185 },
8186 sameElse: 'L'
8187 },
8188 relativeTime : {
8189 future : 'em %s',
8190 past : 'há %s',
8191 s : 'segundos',
8192 m : 'um minuto',
8193 mm : '%d minutos',
8194 h : 'uma hora',
8195 hh : '%d horas',
8196 d : 'um dia',
8197 dd : '%d dias',
8198 M : 'um mês',
8199 MM : '%d meses',
8200 y : 'um ano',
8201 yy : '%d anos'
8202 },
8203 ordinalParse: /\d{1,2}º/,
8204 ordinal : '%dº',
8205 week : {
8206 dow : 1, // Monday is the first day of the week.
8207 doy : 4 // The week that contains Jan 4th is the first week of the year.
8208 }
8209 });
8210
8211 //! moment.js locale configuration
8212 //! locale : romanian (ro)
8213 //! author : Vlad Gurdiga : https://github.com/gurdiga
8214 //! author : Valentin Agachi : https://github.com/avaly
8215
8216 function ro__relativeTimeWithPlural(number, withoutSuffix, key) {
8217 var format = {
8218 'mm': 'minute',
8219 'hh': 'ore',
8220 'dd': 'zile',
8221 'MM': 'luni',
8222 'yy': 'ani'
8223 },
8224 separator = ' ';
8225 if (number % 100 >= 20 || (number >= 100 && number % 100 === 0)) {
8226 separator = ' de ';
8227 }
8228 return number + separator + format[key];
8229 }
8230
8231 var ro = _moment__default.defineLocale('ro', {
8232 months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
8233 monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
8234 weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
8235 weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
8236 weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
8237 longDateFormat : {
8238 LT : 'H:mm',
8239 LTS : 'H:mm:ss',
8240 L : 'DD.MM.YYYY',
8241 LL : 'D MMMM YYYY',
8242 LLL : 'D MMMM YYYY H:mm',
8243 LLLL : 'dddd, D MMMM YYYY H:mm'
8244 },
8245 calendar : {
8246 sameDay: '[azi la] LT',
8247 nextDay: '[mâine la] LT',
8248 nextWeek: 'dddd [la] LT',
8249 lastDay: '[ieri la] LT',
8250 lastWeek: '[fosta] dddd [la] LT',
8251 sameElse: 'L'
8252 },
8253 relativeTime : {
8254 future : 'peste %s',
8255 past : '%s în urmă',
8256 s : 'câteva secunde',
8257 m : 'un minut',
8258 mm : ro__relativeTimeWithPlural,
8259 h : 'o oră',
8260 hh : ro__relativeTimeWithPlural,
8261 d : 'o zi',
8262 dd : ro__relativeTimeWithPlural,
8263 M : 'o lună',
8264 MM : ro__relativeTimeWithPlural,
8265 y : 'un an',
8266 yy : ro__relativeTimeWithPlural
8267 },
8268 week : {
8269 dow : 1, // Monday is the first day of the week.
8270 doy : 7 // The week that contains Jan 1st is the first week of the year.
8271 }
8272 });
8273
8274 //! moment.js locale configuration
8275 //! locale : russian (ru)
8276 //! author : Viktorminator : https://github.com/Viktorminator
8277 //! Author : Menelion Elensúle : https://github.com/Oire
8278
8279 function ru__plural(word, num) {
8280 var forms = word.split('_');
8281 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
8282 }
8283 function ru__relativeTimeWithPlural(number, withoutSuffix, key) {
8284 var format = {
8285 'mm': withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
8286 'hh': 'час_часа_часов',
8287 'dd': 'день_дня_дней',
8288 'MM': 'месяц_месяца_месяцев',
8289 'yy': 'год_года_лет'
8290 };
8291 if (key === 'm') {
8292 return withoutSuffix ? 'минута' : 'минуту';
8293 }
8294 else {
8295 return number + ' ' + ru__plural(format[key], +number);
8296 }
8297 }
8298 function ru__monthsCaseReplace(m, format) {
8299 var months = {
8300 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
8301 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
8302 },
8303 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
8304 'accusative' :
8305 'nominative';
8306 return months[nounCase][m.month()];
8307 }
8308 function ru__monthsShortCaseReplace(m, format) {
8309 var monthsShort = {
8310 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
8311 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
8312 },
8313 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
8314 'accusative' :
8315 'nominative';
8316 return monthsShort[nounCase][m.month()];
8317 }
8318 function ru__weekdaysCaseReplace(m, format) {
8319 var weekdays = {
8320 'nominative': 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
8321 'accusative': 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_')
8322 },
8323 nounCase = (/\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/).test(format) ?
8324 'accusative' :
8325 'nominative';
8326 return weekdays[nounCase][m.day()];
8327 }
8328
8329 var ru = _moment__default.defineLocale('ru', {
8330 months : ru__monthsCaseReplace,
8331 monthsShort : ru__monthsShortCaseReplace,
8332 weekdays : ru__weekdaysCaseReplace,
8333 weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
8334 weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
8335 monthsParse : [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i],
8336 longDateFormat : {
8337 LT : 'HH:mm',
8338 LTS : 'HH:mm:ss',
8339 L : 'DD.MM.YYYY',
8340 LL : 'D MMMM YYYY г.',
8341 LLL : 'D MMMM YYYY г., HH:mm',
8342 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
8343 },
8344 calendar : {
8345 sameDay: '[Сегодня в] LT',
8346 nextDay: '[Завтра в] LT',
8347 lastDay: '[Вчера в] LT',
8348 nextWeek: function () {
8349 return this.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
8350 },
8351 lastWeek: function (now) {
8352 if (now.week() !== this.week()) {
8353 switch (this.day()) {
8354 case 0:
8355 return '[В прошлое] dddd [в] LT';
8356 case 1:
8357 case 2:
8358 case 4:
8359 return '[В прошлый] dddd [в] LT';
8360 case 3:
8361 case 5:
8362 case 6:
8363 return '[В прошлую] dddd [в] LT';
8364 }
8365 } else {
8366 if (this.day() === 2) {
8367 return '[Во] dddd [в] LT';
8368 } else {
8369 return '[В] dddd [в] LT';
8370 }
8371 }
8372 },
8373 sameElse: 'L'
8374 },
8375 relativeTime : {
8376 future : 'через %s',
8377 past : '%s назад',
8378 s : 'несколько секунд',
8379 m : ru__relativeTimeWithPlural,
8380 mm : ru__relativeTimeWithPlural,
8381 h : 'час',
8382 hh : ru__relativeTimeWithPlural,
8383 d : 'день',
8384 dd : ru__relativeTimeWithPlural,
8385 M : 'месяц',
8386 MM : ru__relativeTimeWithPlural,
8387 y : 'год',
8388 yy : ru__relativeTimeWithPlural
8389 },
8390 meridiemParse: /ночи|утра|дня|вечера/i,
8391 isPM : function (input) {
8392 return /^(дня|вечера)$/.test(input);
8393 },
8394 meridiem : function (hour, minute, isLower) {
8395 if (hour < 4) {
8396 return 'ночи';
8397 } else if (hour < 12) {
8398 return 'утра';
8399 } else if (hour < 17) {
8400 return 'дня';
8401 } else {
8402 return 'вечера';
8403 }
8404 },
8405 ordinalParse: /\d{1,2}-(й|го|я)/,
8406 ordinal: function (number, period) {
8407 switch (period) {
8408 case 'M':
8409 case 'd':
8410 case 'DDD':
8411 return number + '-й';
8412 case 'D':
8413 return number + '-го';
8414 case 'w':
8415 case 'W':
8416 return number + '-я';
8417 default:
8418 return number;
8419 }
8420 },
8421 week : {
8422 dow : 1, // Monday is the first day of the week.
8423 doy : 7 // The week that contains Jan 1st is the first week of the year.
8424 }
8425 });
8426
8427 //! moment.js locale configuration
8428 //! locale : Sinhalese (si)
8429 //! author : Sampath Sitinamaluwa : https://github.com/sampathsris
8430
8431 var si = _moment__default.defineLocale('si', {
8432 months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්‍රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
8433 monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
8434 weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
8435 weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'),
8436 weekdaysMin : 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'),
8437 longDateFormat : {
8438 LT : 'a h:mm',
8439 LTS : 'a h:mm:ss',
8440 L : 'YYYY/MM/DD',
8441 LL : 'YYYY MMMM D',
8442 LLL : 'YYYY MMMM D, a h:mm',
8443 LLLL : 'YYYY MMMM D [වැනි] dddd, a h:mm:ss'
8444 },
8445 calendar : {
8446 sameDay : '[අද] LT[ට]',
8447 nextDay : '[හෙට] LT[ට]',
8448 nextWeek : 'dddd LT[ට]',
8449 lastDay : '[ඊයේ] LT[ට]',
8450 lastWeek : '[පසුගිය] dddd LT[ට]',
8451 sameElse : 'L'
8452 },
8453 relativeTime : {
8454 future : '%sකින්',
8455 past : '%sකට පෙර',
8456 s : 'තත්පර කිහිපය',
8457 m : 'මිනිත්තුව',
8458 mm : 'මිනිත්තු %d',
8459 h : 'පැය',
8460 hh : 'පැය %d',
8461 d : 'දිනය',
8462 dd : 'දින %d',
8463 M : 'මාසය',
8464 MM : 'මාස %d',
8465 y : 'වසර',
8466 yy : 'වසර %d'
8467 },
8468 ordinalParse: /\d{1,2} වැනි/,
8469 ordinal : function (number) {
8470 return number + ' වැනි';
8471 },
8472 meridiem : function (hours, minutes, isLower) {
8473 if (hours > 11) {
8474 return isLower ? 'ප.ව.' : 'පස් වරු';
8475 } else {
8476 return isLower ? 'පෙ.ව.' : 'පෙර වරු';
8477 }
8478 }
8479 });
8480
8481 //! moment.js locale configuration
8482 //! locale : slovak (sk)
8483 //! author : Martin Minka : https://github.com/k2s
8484 //! based on work of petrbela : https://github.com/petrbela
8485
8486 var sk__months = 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_'),
8487 sk__monthsShort = 'jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec'.split('_');
8488 function sk__plural(n) {
8489 return (n > 1) && (n < 5);
8490 }
8491 function sk__translate(number, withoutSuffix, key, isFuture) {
8492 var result = number + ' ';
8493 switch (key) {
8494 case 's': // a few seconds / in a few seconds / a few seconds ago
8495 return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
8496 case 'm': // a minute / in a minute / a minute ago
8497 return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou');
8498 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
8499 if (withoutSuffix || isFuture) {
8500 return result + (sk__plural(number) ? 'minúty' : 'minút');
8501 } else {
8502 return result + 'minútami';
8503 }
8504 break;
8505 case 'h': // an hour / in an hour / an hour ago
8506 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
8507 case 'hh': // 9 hours / in 9 hours / 9 hours ago
8508 if (withoutSuffix || isFuture) {
8509 return result + (sk__plural(number) ? 'hodiny' : 'hodín');
8510 } else {
8511 return result + 'hodinami';
8512 }
8513 break;
8514 case 'd': // a day / in a day / a day ago
8515 return (withoutSuffix || isFuture) ? 'deň' : 'dňom';
8516 case 'dd': // 9 days / in 9 days / 9 days ago
8517 if (withoutSuffix || isFuture) {
8518 return result + (sk__plural(number) ? 'dni' : 'dní');
8519 } else {
8520 return result + 'dňami';
8521 }
8522 break;
8523 case 'M': // a month / in a month / a month ago
8524 return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom';
8525 case 'MM': // 9 months / in 9 months / 9 months ago
8526 if (withoutSuffix || isFuture) {
8527 return result + (sk__plural(number) ? 'mesiace' : 'mesiacov');
8528 } else {
8529 return result + 'mesiacmi';
8530 }
8531 break;
8532 case 'y': // a year / in a year / a year ago
8533 return (withoutSuffix || isFuture) ? 'rok' : 'rokom';
8534 case 'yy': // 9 years / in 9 years / 9 years ago
8535 if (withoutSuffix || isFuture) {
8536 return result + (sk__plural(number) ? 'roky' : 'rokov');
8537 } else {
8538 return result + 'rokmi';
8539 }
8540 break;
8541 }
8542 }
8543
8544 var sk = _moment__default.defineLocale('sk', {
8545 months : sk__months,
8546 monthsShort : sk__monthsShort,
8547 monthsParse : (function (months, monthsShort) {
8548 var i, _monthsParse = [];
8549 for (i = 0; i < 12; i++) {
8550 // use custom parser to solve problem with July (červenec)
8551 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
8552 }
8553 return _monthsParse;
8554 }(sk__months, sk__monthsShort)),
8555 weekdays : 'nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota'.split('_'),
8556 weekdaysShort : 'ne_po_ut_st_št_pi_so'.split('_'),
8557 weekdaysMin : 'ne_po_ut_st_št_pi_so'.split('_'),
8558 longDateFormat : {
8559 LT: 'H:mm',
8560 LTS : 'H:mm:ss',
8561 L : 'DD.MM.YYYY',
8562 LL : 'D. MMMM YYYY',
8563 LLL : 'D. MMMM YYYY H:mm',
8564 LLLL : 'dddd D. MMMM YYYY H:mm'
8565 },
8566 calendar : {
8567 sameDay: '[dnes o] LT',
8568 nextDay: '[zajtra o] LT',
8569 nextWeek: function () {
8570 switch (this.day()) {
8571 case 0:
8572 return '[v nedeľu o] LT';
8573 case 1:
8574 case 2:
8575 return '[v] dddd [o] LT';
8576 case 3:
8577 return '[v stredu o] LT';
8578 case 4:
8579 return '[vo štvrtok o] LT';
8580 case 5:
8581 return '[v piatok o] LT';
8582 case 6:
8583 return '[v sobotu o] LT';
8584 }
8585 },
8586 lastDay: '[včera o] LT',
8587 lastWeek: function () {
8588 switch (this.day()) {
8589 case 0:
8590 return '[minulú nedeľu o] LT';
8591 case 1:
8592 case 2:
8593 return '[minulý] dddd [o] LT';
8594 case 3:
8595 return '[minulú stredu o] LT';
8596 case 4:
8597 case 5:
8598 return '[minulý] dddd [o] LT';
8599 case 6:
8600 return '[minulú sobotu o] LT';
8601 }
8602 },
8603 sameElse: 'L'
8604 },
8605 relativeTime : {
8606 future : 'za %s',
8607 past : 'pred %s',
8608 s : sk__translate,
8609 m : sk__translate,
8610 mm : sk__translate,
8611 h : sk__translate,
8612 hh : sk__translate,
8613 d : sk__translate,
8614 dd : sk__translate,
8615 M : sk__translate,
8616 MM : sk__translate,
8617 y : sk__translate,
8618 yy : sk__translate
8619 },
8620 ordinalParse: /\d{1,2}\./,
8621 ordinal : '%d.',
8622 week : {
8623 dow : 1, // Monday is the first day of the week.
8624 doy : 4 // The week that contains Jan 4th is the first week of the year.
8625 }
8626 });
8627
8628 //! moment.js locale configuration
8629 //! locale : slovenian (sl)
8630 //! author : Robert Sedovšek : https://github.com/sedovsek
8631
8632 function sl__processRelativeTime(number, withoutSuffix, key, isFuture) {
8633 var result = number + ' ';
8634 switch (key) {
8635 case 's':
8636 return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
8637 case 'm':
8638 return withoutSuffix ? 'ena minuta' : 'eno minuto';
8639 case 'mm':
8640 if (number === 1) {
8641 result += withoutSuffix ? 'minuta' : 'minuto';
8642 } else if (number === 2) {
8643 result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
8644 } else if (number < 5) {
8645 result += withoutSuffix || isFuture ? 'minute' : 'minutami';
8646 } else {
8647 result += withoutSuffix || isFuture ? 'minut' : 'minutami';
8648 }
8649 return result;
8650 case 'h':
8651 return withoutSuffix ? 'ena ura' : 'eno uro';
8652 case 'hh':
8653 if (number === 1) {
8654 result += withoutSuffix ? 'ura' : 'uro';
8655 } else if (number === 2) {
8656 result += withoutSuffix || isFuture ? 'uri' : 'urama';
8657 } else if (number < 5) {
8658 result += withoutSuffix || isFuture ? 'ure' : 'urami';
8659 } else {
8660 result += withoutSuffix || isFuture ? 'ur' : 'urami';
8661 }
8662 return result;
8663 case 'd':
8664 return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
8665 case 'dd':
8666 if (number === 1) {
8667 result += withoutSuffix || isFuture ? 'dan' : 'dnem';
8668 } else if (number === 2) {
8669 result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
8670 } else {
8671 result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
8672 }
8673 return result;
8674 case 'M':
8675 return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
8676 case 'MM':
8677 if (number === 1) {
8678 result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
8679 } else if (number === 2) {
8680 result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
8681 } else if (number < 5) {
8682 result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
8683 } else {
8684 result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
8685 }
8686 return result;
8687 case 'y':
8688 return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
8689 case 'yy':
8690 if (number === 1) {
8691 result += withoutSuffix || isFuture ? 'leto' : 'letom';
8692 } else if (number === 2) {
8693 result += withoutSuffix || isFuture ? 'leti' : 'letoma';
8694 } else if (number < 5) {
8695 result += withoutSuffix || isFuture ? 'leta' : 'leti';
8696 } else {
8697 result += withoutSuffix || isFuture ? 'let' : 'leti';
8698 }
8699 return result;
8700 }
8701 }
8702
8703 var sl = _moment__default.defineLocale('sl', {
8704 months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
8705 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
8706 weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
8707 weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
8708 weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
8709 longDateFormat : {
8710 LT : 'H:mm',
8711 LTS : 'H:mm:ss',
8712 L : 'DD. MM. YYYY',
8713 LL : 'D. MMMM YYYY',
8714 LLL : 'D. MMMM YYYY H:mm',
8715 LLLL : 'dddd, D. MMMM YYYY H:mm'
8716 },
8717 calendar : {
8718 sameDay : '[danes ob] LT',
8719 nextDay : '[jutri ob] LT',
8720
8721 nextWeek : function () {
8722 switch (this.day()) {
8723 case 0:
8724 return '[v] [nedeljo] [ob] LT';
8725 case 3:
8726 return '[v] [sredo] [ob] LT';
8727 case 6:
8728 return '[v] [soboto] [ob] LT';
8729 case 1:
8730 case 2:
8731 case 4:
8732 case 5:
8733 return '[v] dddd [ob] LT';
8734 }
8735 },
8736 lastDay : '[včeraj ob] LT',
8737 lastWeek : function () {
8738 switch (this.day()) {
8739 case 0:
8740 return '[prejšnjo] [nedeljo] [ob] LT';
8741 case 3:
8742 return '[prejšnjo] [sredo] [ob] LT';
8743 case 6:
8744 return '[prejšnjo] [soboto] [ob] LT';
8745 case 1:
8746 case 2:
8747 case 4:
8748 case 5:
8749 return '[prejšnji] dddd [ob] LT';
8750 }
8751 },
8752 sameElse : 'L'
8753 },
8754 relativeTime : {
8755 future : 'čez %s',
8756 past : 'pred %s',
8757 s : sl__processRelativeTime,
8758 m : sl__processRelativeTime,
8759 mm : sl__processRelativeTime,
8760 h : sl__processRelativeTime,
8761 hh : sl__processRelativeTime,
8762 d : sl__processRelativeTime,
8763 dd : sl__processRelativeTime,
8764 M : sl__processRelativeTime,
8765 MM : sl__processRelativeTime,
8766 y : sl__processRelativeTime,
8767 yy : sl__processRelativeTime
8768 },
8769 ordinalParse: /\d{1,2}\./,
8770 ordinal : '%d.',
8771 week : {
8772 dow : 1, // Monday is the first day of the week.
8773 doy : 7 // The week that contains Jan 1st is the first week of the year.
8774 }
8775 });
8776
8777 //! moment.js locale configuration
8778 //! locale : Albanian (sq)
8779 //! author : Flakërim Ismani : https://github.com/flakerimi
8780 //! author: Menelion Elensúle: https://github.com/Oire (tests)
8781 //! author : Oerd Cukalla : https://github.com/oerd (fixes)
8782
8783 var sq = _moment__default.defineLocale('sq', {
8784 months : 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'),
8785 monthsShort : 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'),
8786 weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
8787 weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
8788 weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
8789 meridiemParse: /PD|MD/,
8790 isPM: function (input) {
8791 return input.charAt(0) === 'M';
8792 },
8793 meridiem : function (hours, minutes, isLower) {
8794 return hours < 12 ? 'PD' : 'MD';
8795 },
8796 longDateFormat : {
8797 LT : 'HH:mm',
8798 LTS : 'HH:mm:ss',
8799 L : 'DD/MM/YYYY',
8800 LL : 'D MMMM YYYY',
8801 LLL : 'D MMMM YYYY HH:mm',
8802 LLLL : 'dddd, D MMMM YYYY HH:mm'
8803 },
8804 calendar : {
8805 sameDay : '[Sot në] LT',
8806 nextDay : '[Nesër në] LT',
8807 nextWeek : 'dddd [në] LT',
8808 lastDay : '[Dje në] LT',
8809 lastWeek : 'dddd [e kaluar në] LT',
8810 sameElse : 'L'
8811 },
8812 relativeTime : {
8813 future : 'në %s',
8814 past : '%s më parë',
8815 s : 'disa sekonda',
8816 m : 'një minutë',
8817 mm : '%d minuta',
8818 h : 'një orë',
8819 hh : '%d orë',
8820 d : 'një ditë',
8821 dd : '%d ditë',
8822 M : 'një muaj',
8823 MM : '%d muaj',
8824 y : 'një vit',
8825 yy : '%d vite'
8826 },
8827 ordinalParse: /\d{1,2}\./,
8828 ordinal : '%d.',
8829 week : {
8830 dow : 1, // Monday is the first day of the week.
8831 doy : 4 // The week that contains Jan 4th is the first week of the year.
8832 }
8833 });
8834
8835 //! moment.js locale configuration
8836 //! locale : Serbian-cyrillic (sr-cyrl)
8837 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
8838
8839 var sr_cyrl__translator = {
8840 words: { //Different grammatical cases
8841 m: ['један минут', 'једне минуте'],
8842 mm: ['минут', 'минуте', 'минута'],
8843 h: ['један сат', 'једног сата'],
8844 hh: ['сат', 'сата', 'сати'],
8845 dd: ['дан', 'дана', 'дана'],
8846 MM: ['месец', 'месеца', 'месеци'],
8847 yy: ['година', 'године', 'година']
8848 },
8849 correctGrammaticalCase: function (number, wordKey) {
8850 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
8851 },
8852 translate: function (number, withoutSuffix, key) {
8853 var wordKey = sr_cyrl__translator.words[key];
8854 if (key.length === 1) {
8855 return withoutSuffix ? wordKey[0] : wordKey[1];
8856 } else {
8857 return number + ' ' + sr_cyrl__translator.correctGrammaticalCase(number, wordKey);
8858 }
8859 }
8860 };
8861
8862 var sr_cyrl = _moment__default.defineLocale('sr-cyrl', {
8863 months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
8864 monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
8865 weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
8866 weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
8867 weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
8868 longDateFormat: {
8869 LT: 'H:mm',
8870 LTS : 'H:mm:ss',
8871 L: 'DD. MM. YYYY',
8872 LL: 'D. MMMM YYYY',
8873 LLL: 'D. MMMM YYYY H:mm',
8874 LLLL: 'dddd, D. MMMM YYYY H:mm'
8875 },
8876 calendar: {
8877 sameDay: '[данас у] LT',
8878 nextDay: '[сутра у] LT',
8879 nextWeek: function () {
8880 switch (this.day()) {
8881 case 0:
8882 return '[у] [недељу] [у] LT';
8883 case 3:
8884 return '[у] [среду] [у] LT';
8885 case 6:
8886 return '[у] [суботу] [у] LT';
8887 case 1:
8888 case 2:
8889 case 4:
8890 case 5:
8891 return '[у] dddd [у] LT';
8892 }
8893 },
8894 lastDay : '[јуче у] LT',
8895 lastWeek : function () {
8896 var lastWeekDays = [
8897 '[прошле] [недеље] [у] LT',
8898 '[прошлог] [понедељка] [у] LT',
8899 '[прошлог] [уторка] [у] LT',
8900 '[прошле] [среде] [у] LT',
8901 '[прошлог] [четвртка] [у] LT',
8902 '[прошлог] [петка] [у] LT',
8903 '[прошле] [суботе] [у] LT'
8904 ];
8905 return lastWeekDays[this.day()];
8906 },
8907 sameElse : 'L'
8908 },
8909 relativeTime : {
8910 future : 'за %s',
8911 past : 'пре %s',
8912 s : 'неколико секунди',
8913 m : sr_cyrl__translator.translate,
8914 mm : sr_cyrl__translator.translate,
8915 h : sr_cyrl__translator.translate,
8916 hh : sr_cyrl__translator.translate,
8917 d : 'дан',
8918 dd : sr_cyrl__translator.translate,
8919 M : 'месец',
8920 MM : sr_cyrl__translator.translate,
8921 y : 'годину',
8922 yy : sr_cyrl__translator.translate
8923 },
8924 ordinalParse: /\d{1,2}\./,
8925 ordinal : '%d.',
8926 week : {
8927 dow : 1, // Monday is the first day of the week.
8928 doy : 7 // The week that contains Jan 1st is the first week of the year.
8929 }
8930 });
8931
8932 //! moment.js locale configuration
8933 //! locale : Serbian-latin (sr)
8934 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
8935
8936 var sr__translator = {
8937 words: { //Different grammatical cases
8938 m: ['jedan minut', 'jedne minute'],
8939 mm: ['minut', 'minute', 'minuta'],
8940 h: ['jedan sat', 'jednog sata'],
8941 hh: ['sat', 'sata', 'sati'],
8942 dd: ['dan', 'dana', 'dana'],
8943 MM: ['mesec', 'meseca', 'meseci'],
8944 yy: ['godina', 'godine', 'godina']
8945 },
8946 correctGrammaticalCase: function (number, wordKey) {
8947 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
8948 },
8949 translate: function (number, withoutSuffix, key) {
8950 var wordKey = sr__translator.words[key];
8951 if (key.length === 1) {
8952 return withoutSuffix ? wordKey[0] : wordKey[1];
8953 } else {
8954 return number + ' ' + sr__translator.correctGrammaticalCase(number, wordKey);
8955 }
8956 }
8957 };
8958
8959 var sr = _moment__default.defineLocale('sr', {
8960 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
8961 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
8962 weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
8963 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
8964 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
8965 longDateFormat: {
8966 LT: 'H:mm',
8967 LTS : 'H:mm:ss',
8968 L: 'DD. MM. YYYY',
8969 LL: 'D. MMMM YYYY',
8970 LLL: 'D. MMMM YYYY H:mm',
8971 LLLL: 'dddd, D. MMMM YYYY H:mm'
8972 },
8973 calendar: {
8974 sameDay: '[danas u] LT',
8975 nextDay: '[sutra u] LT',
8976 nextWeek: function () {
8977 switch (this.day()) {
8978 case 0:
8979 return '[u] [nedelju] [u] LT';
8980 case 3:
8981 return '[u] [sredu] [u] LT';
8982 case 6:
8983 return '[u] [subotu] [u] LT';
8984 case 1:
8985 case 2:
8986 case 4:
8987 case 5:
8988 return '[u] dddd [u] LT';
8989 }
8990 },
8991 lastDay : '[juče u] LT',
8992 lastWeek : function () {
8993 var lastWeekDays = [
8994 '[prošle] [nedelje] [u] LT',
8995 '[prošlog] [ponedeljka] [u] LT',
8996 '[prošlog] [utorka] [u] LT',
8997 '[prošle] [srede] [u] LT',
8998 '[prošlog] [četvrtka] [u] LT',
8999 '[prošlog] [petka] [u] LT',
9000 '[prošle] [subote] [u] LT'
9001 ];
9002 return lastWeekDays[this.day()];
9003 },
9004 sameElse : 'L'
9005 },
9006 relativeTime : {
9007 future : 'za %s',
9008 past : 'pre %s',
9009 s : 'nekoliko sekundi',
9010 m : sr__translator.translate,
9011 mm : sr__translator.translate,
9012 h : sr__translator.translate,
9013 hh : sr__translator.translate,
9014 d : 'dan',
9015 dd : sr__translator.translate,
9016 M : 'mesec',
9017 MM : sr__translator.translate,
9018 y : 'godinu',
9019 yy : sr__translator.translate
9020 },
9021 ordinalParse: /\d{1,2}\./,
9022 ordinal : '%d.',
9023 week : {
9024 dow : 1, // Monday is the first day of the week.
9025 doy : 7 // The week that contains Jan 1st is the first week of the year.
9026 }
9027 });
9028
9029 //! moment.js locale configuration
9030 //! locale : swedish (sv)
9031 //! author : Jens Alm : https://github.com/ulmus
9032
9033 var sv = _moment__default.defineLocale('sv', {
9034 months : 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
9035 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
9036 weekdays : 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
9037 weekdaysShort : 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
9038 weekdaysMin : 'sö_må_ti_on_to_fr_lö'.split('_'),
9039 longDateFormat : {
9040 LT : 'HH:mm',
9041 LTS : 'HH:mm:ss',
9042 L : 'YYYY-MM-DD',
9043 LL : 'D MMMM YYYY',
9044 LLL : 'D MMMM YYYY HH:mm',
9045 LLLL : 'dddd D MMMM YYYY HH:mm'
9046 },
9047 calendar : {
9048 sameDay: '[Idag] LT',
9049 nextDay: '[Imorgon] LT',
9050 lastDay: '[Igår] LT',
9051 nextWeek: '[På] dddd LT',
9052 lastWeek: '[I] dddd[s] LT',
9053 sameElse: 'L'
9054 },
9055 relativeTime : {
9056 future : 'om %s',
9057 past : 'för %s sedan',
9058 s : 'några sekunder',
9059 m : 'en minut',
9060 mm : '%d minuter',
9061 h : 'en timme',
9062 hh : '%d timmar',
9063 d : 'en dag',
9064 dd : '%d dagar',
9065 M : 'en månad',
9066 MM : '%d månader',
9067 y : 'ett år',
9068 yy : '%d år'
9069 },
9070 ordinalParse: /\d{1,2}(e|a)/,
9071 ordinal : function (number) {
9072 var b = number % 10,
9073 output = (~~(number % 100 / 10) === 1) ? 'e' :
9074 (b === 1) ? 'a' :
9075 (b === 2) ? 'a' :
9076 (b === 3) ? 'e' : 'e';
9077 return number + output;
9078 },
9079 week : {
9080 dow : 1, // Monday is the first day of the week.
9081 doy : 4 // The week that contains Jan 4th is the first week of the year.
9082 }
9083 });
9084
9085 //! moment.js locale configuration
9086 //! locale : tamil (ta)
9087 //! author : Arjunkumar Krishnamoorthy : https://github.com/tk120404
9088
9089 var ta = _moment__default.defineLocale('ta', {
9090 months : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
9091 monthsShort : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
9092 weekdays : 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'),
9093 weekdaysShort : 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'),
9094 weekdaysMin : 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'),
9095 longDateFormat : {
9096 LT : 'HH:mm',
9097 LTS : 'HH:mm:ss',
9098 L : 'DD/MM/YYYY',
9099 LL : 'D MMMM YYYY',
9100 LLL : 'D MMMM YYYY, HH:mm',
9101 LLLL : 'dddd, D MMMM YYYY, HH:mm'
9102 },
9103 calendar : {
9104 sameDay : '[இன்று] LT',
9105 nextDay : '[நாளை] LT',
9106 nextWeek : 'dddd, LT',
9107 lastDay : '[நேற்று] LT',
9108 lastWeek : '[கடந்த வாரம்] dddd, LT',
9109 sameElse : 'L'
9110 },
9111 relativeTime : {
9112 future : '%s இல்',
9113 past : '%s முன்',
9114 s : 'ஒரு சில விநாடிகள்',
9115 m : 'ஒரு நிமிடம்',
9116 mm : '%d நிமிடங்கள்',
9117 h : 'ஒரு மணி நேரம்',
9118 hh : '%d மணி நேரம்',
9119 d : 'ஒரு நாள்',
9120 dd : '%d நாட்கள்',
9121 M : 'ஒரு மாதம்',
9122 MM : '%d மாதங்கள்',
9123 y : 'ஒரு வருடம்',
9124 yy : '%d ஆண்டுகள்'
9125 },
9126 ordinalParse: /\d{1,2}வது/,
9127 ordinal : function (number) {
9128 return number + 'வது';
9129 },
9130 // refer http://ta.wikipedia.org/s/1er1
9131 meridiemParse: /யாமம்|வைகறை|காலை|நண்பகல்|எற்பாடு|மாலை/,
9132 meridiem : function (hour, minute, isLower) {
9133 if (hour < 2) {
9134 return ' யாமம்';
9135 } else if (hour < 6) {
9136 return ' வைகறை'; // வைகறை
9137 } else if (hour < 10) {
9138 return ' காலை'; // காலை
9139 } else if (hour < 14) {
9140 return ' நண்பகல்'; // நண்பகல்
9141 } else if (hour < 18) {
9142 return ' எற்பாடு'; // எற்பாடு
9143 } else if (hour < 22) {
9144 return ' மாலை'; // மாலை
9145 } else {
9146 return ' யாமம்';
9147 }
9148 },
9149 meridiemHour : function (hour, meridiem) {
9150 if (hour === 12) {
9151 hour = 0;
9152 }
9153 if (meridiem === 'யாமம்') {
9154 return hour < 2 ? hour : hour + 12;
9155 } else if (meridiem === 'வைகறை' || meridiem === 'காலை') {
9156 return hour;
9157 } else if (meridiem === 'நண்பகல்') {
9158 return hour >= 10 ? hour : hour + 12;
9159 } else {
9160 return hour + 12;
9161 }
9162 },
9163 week : {
9164 dow : 0, // Sunday is the first day of the week.
9165 doy : 6 // The week that contains Jan 1st is the first week of the year.
9166 }
9167 });
9168
9169 //! moment.js locale configuration
9170 //! locale : thai (th)
9171 //! author : Kridsada Thanabulpong : https://github.com/sirn
9172
9173 var th = _moment__default.defineLocale('th', {
9174 months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
9175 monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
9176 weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
9177 weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
9178 weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
9179 longDateFormat : {
9180 LT : 'H นาฬิกา m นาที',
9181 LTS : 'H นาฬิกา m นาที s วินาที',
9182 L : 'YYYY/MM/DD',
9183 LL : 'D MMMM YYYY',
9184 LLL : 'D MMMM YYYY เวลา H นาฬิกา m นาที',
9185 LLLL : 'วันddddที่ D MMMM YYYY เวลา H นาฬิกา m นาที'
9186 },
9187 meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
9188 isPM: function (input) {
9189 return input === 'หลังเที่ยง';
9190 },
9191 meridiem : function (hour, minute, isLower) {
9192 if (hour < 12) {
9193 return 'ก่อนเที่ยง';
9194 } else {
9195 return 'หลังเที่ยง';
9196 }
9197 },
9198 calendar : {
9199 sameDay : '[วันนี้ เวลา] LT',
9200 nextDay : '[พรุ่งนี้ เวลา] LT',
9201 nextWeek : 'dddd[หน้า เวลา] LT',
9202 lastDay : '[เมื่อวานนี้ เวลา] LT',
9203 lastWeek : '[วัน]dddd[ที่แล้ว เวลา] LT',
9204 sameElse : 'L'
9205 },
9206 relativeTime : {
9207 future : 'อีก %s',
9208 past : '%sที่แล้ว',
9209 s : 'ไม่กี่วินาที',
9210 m : '1 นาที',
9211 mm : '%d นาที',
9212 h : '1 ชั่วโมง',
9213 hh : '%d ชั่วโมง',
9214 d : '1 วัน',
9215 dd : '%d วัน',
9216 M : '1 เดือน',
9217 MM : '%d เดือน',
9218 y : '1 ปี',
9219 yy : '%d ปี'
9220 }
9221 });
9222
9223 //! moment.js locale configuration
9224 //! locale : Tagalog/Filipino (tl-ph)
9225 //! author : Dan Hagman
9226
9227 var tl_ph = _moment__default.defineLocale('tl-ph', {
9228 months : 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'),
9229 monthsShort : 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'),
9230 weekdays : 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'),
9231 weekdaysShort : 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'),
9232 weekdaysMin : 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'),
9233 longDateFormat : {
9234 LT : 'HH:mm',
9235 LTS : 'HH:mm:ss',
9236 L : 'MM/D/YYYY',
9237 LL : 'MMMM D, YYYY',
9238 LLL : 'MMMM D, YYYY HH:mm',
9239 LLLL : 'dddd, MMMM DD, YYYY HH:mm'
9240 },
9241 calendar : {
9242 sameDay: '[Ngayon sa] LT',
9243 nextDay: '[Bukas sa] LT',
9244 nextWeek: 'dddd [sa] LT',
9245 lastDay: '[Kahapon sa] LT',
9246 lastWeek: 'dddd [huling linggo] LT',
9247 sameElse: 'L'
9248 },
9249 relativeTime : {
9250 future : 'sa loob ng %s',
9251 past : '%s ang nakalipas',
9252 s : 'ilang segundo',
9253 m : 'isang minuto',
9254 mm : '%d minuto',
9255 h : 'isang oras',
9256 hh : '%d oras',
9257 d : 'isang araw',
9258 dd : '%d araw',
9259 M : 'isang buwan',
9260 MM : '%d buwan',
9261 y : 'isang taon',
9262 yy : '%d taon'
9263 },
9264 ordinalParse: /\d{1,2}/,
9265 ordinal : function (number) {
9266 return number;
9267 },
9268 week : {
9269 dow : 1, // Monday is the first day of the week.
9270 doy : 4 // The week that contains Jan 4th is the first week of the year.
9271 }
9272 });
9273
9274 //! moment.js locale configuration
9275 //! locale : turkish (tr)
9276 //! authors : Erhan Gundogan : https://github.com/erhangundogan,
9277 //! Burak Yiğit Kaya: https://github.com/BYK
9278
9279 var tr__suffixes = {
9280 1: '\'inci',
9281 5: '\'inci',
9282 8: '\'inci',
9283 70: '\'inci',
9284 80: '\'inci',
9285 2: '\'nci',
9286 7: '\'nci',
9287 20: '\'nci',
9288 50: '\'nci',
9289 3: '\'üncü',
9290 4: '\'üncü',
9291 100: '\'üncü',
9292 6: '\'ncı',
9293 9: '\'uncu',
9294 10: '\'uncu',
9295 30: '\'uncu',
9296 60: '\'ıncı',
9297 90: '\'ıncı'
9298 };
9299
9300 var tr = _moment__default.defineLocale('tr', {
9301 months : 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
9302 monthsShort : 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'),
9303 weekdays : 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
9304 weekdaysShort : 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'),
9305 weekdaysMin : 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'),
9306 longDateFormat : {
9307 LT : 'HH:mm',
9308 LTS : 'HH:mm:ss',
9309 L : 'DD.MM.YYYY',
9310 LL : 'D MMMM YYYY',
9311 LLL : 'D MMMM YYYY HH:mm',
9312 LLLL : 'dddd, D MMMM YYYY HH:mm'
9313 },
9314 calendar : {
9315 sameDay : '[bugün saat] LT',
9316 nextDay : '[yarın saat] LT',
9317 nextWeek : '[haftaya] dddd [saat] LT',
9318 lastDay : '[dün] LT',
9319 lastWeek : '[geçen hafta] dddd [saat] LT',
9320 sameElse : 'L'
9321 },
9322 relativeTime : {
9323 future : '%s sonra',
9324 past : '%s önce',
9325 s : 'birkaç saniye',
9326 m : 'bir dakika',
9327 mm : '%d dakika',
9328 h : 'bir saat',
9329 hh : '%d saat',
9330 d : 'bir gün',
9331 dd : '%d gün',
9332 M : 'bir ay',
9333 MM : '%d ay',
9334 y : 'bir yıl',
9335 yy : '%d yıl'
9336 },
9337 ordinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
9338 ordinal : function (number) {
9339 if (number === 0) { // special case for zero
9340 return number + '\'ıncı';
9341 }
9342 var a = number % 10,
9343 b = number % 100 - a,
9344 c = number >= 100 ? 100 : null;
9345 return number + (tr__suffixes[a] || tr__suffixes[b] || tr__suffixes[c]);
9346 },
9347 week : {
9348 dow : 1, // Monday is the first day of the week.
9349 doy : 7 // The week that contains Jan 1st is the first week of the year.
9350 }
9351 });
9352
9353 //! moment.js locale configuration
9354 //! locale : talossan (tzl)
9355 //! author : Robin van der Vliet : https://github.com/robin0van0der0v with the help of Iustì Canun
9356
9357
9358 var tzl = _moment__default.defineLocale('tzl', {
9359 months : 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'),
9360 monthsShort : 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'),
9361 weekdays : 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'),
9362 weekdaysShort : 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'),
9363 weekdaysMin : 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'),
9364 longDateFormat : {
9365 LT : 'HH.mm',
9366 LTS : 'LT.ss',
9367 L : 'DD.MM.YYYY',
9368 LL : 'D. MMMM [dallas] YYYY',
9369 LLL : 'D. MMMM [dallas] YYYY LT',
9370 LLLL : 'dddd, [li] D. MMMM [dallas] YYYY LT'
9371 },
9372 meridiem : function (hours, minutes, isLower) {
9373 if (hours > 11) {
9374 return isLower ? 'd\'o' : 'D\'O';
9375 } else {
9376 return isLower ? 'd\'a' : 'D\'A';
9377 }
9378 },
9379 calendar : {
9380 sameDay : '[oxhi à] LT',
9381 nextDay : '[demà à] LT',
9382 nextWeek : 'dddd [à] LT',
9383 lastDay : '[ieiri à] LT',
9384 lastWeek : '[sür el] dddd [lasteu à] LT',
9385 sameElse : 'L'
9386 },
9387 relativeTime : {
9388 future : 'osprei %s',
9389 past : 'ja%s',
9390 s : tzl__processRelativeTime,
9391 m : tzl__processRelativeTime,
9392 mm : tzl__processRelativeTime,
9393 h : tzl__processRelativeTime,
9394 hh : tzl__processRelativeTime,
9395 d : tzl__processRelativeTime,
9396 dd : tzl__processRelativeTime,
9397 M : tzl__processRelativeTime,
9398 MM : tzl__processRelativeTime,
9399 y : tzl__processRelativeTime,
9400 yy : tzl__processRelativeTime
9401 },
9402 ordinalParse: /\d{1,2}\./,
9403 ordinal : '%d.',
9404 week : {
9405 dow : 1, // Monday is the first day of the week.
9406 doy : 4 // The week that contains Jan 4th is the first week of the year.
9407 }
9408 });
9409
9410 function tzl__processRelativeTime(number, withoutSuffix, key, isFuture) {
9411 var format = {
9412 's': ['viensas secunds', '\'iensas secunds'],
9413 'm': ['\'n míut', '\'iens míut'],
9414 'mm': [number + ' míuts', ' ' + number + ' míuts'],
9415 'h': ['\'n þora', '\'iensa þora'],
9416 'hh': [number + ' þoras', ' ' + number + ' þoras'],
9417 'd': ['\'n ziua', '\'iensa ziua'],
9418 'dd': [number + ' ziuas', ' ' + number + ' ziuas'],
9419 'M': ['\'n mes', '\'iens mes'],
9420 'MM': [number + ' mesen', ' ' + number + ' mesen'],
9421 'y': ['\'n ar', '\'iens ar'],
9422 'yy': [number + ' ars', ' ' + number + ' ars']
9423 };
9424 return isFuture ? format[key][0] : (withoutSuffix ? format[key][0] : format[key][1].trim());
9425 }
9426
9427 //! moment.js locale configuration
9428 //! locale : Morocco Central Atlas Tamaziɣt in Latin (tzm-latn)
9429 //! author : Abdel Said : https://github.com/abdelsaid
9430
9431 var tzm_latn = _moment__default.defineLocale('tzm-latn', {
9432 months : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
9433 monthsShort : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
9434 weekdays : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
9435 weekdaysShort : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
9436 weekdaysMin : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
9437 longDateFormat : {
9438 LT : 'HH:mm',
9439 LTS : 'HH:mm:ss',
9440 L : 'DD/MM/YYYY',
9441 LL : 'D MMMM YYYY',
9442 LLL : 'D MMMM YYYY HH:mm',
9443 LLLL : 'dddd D MMMM YYYY HH:mm'
9444 },
9445 calendar : {
9446 sameDay: '[asdkh g] LT',
9447 nextDay: '[aska g] LT',
9448 nextWeek: 'dddd [g] LT',
9449 lastDay: '[assant g] LT',
9450 lastWeek: 'dddd [g] LT',
9451 sameElse: 'L'
9452 },
9453 relativeTime : {
9454 future : 'dadkh s yan %s',
9455 past : 'yan %s',
9456 s : 'imik',
9457 m : 'minuḍ',
9458 mm : '%d minuḍ',
9459 h : 'saɛa',
9460 hh : '%d tassaɛin',
9461 d : 'ass',
9462 dd : '%d ossan',
9463 M : 'ayowr',
9464 MM : '%d iyyirn',
9465 y : 'asgas',
9466 yy : '%d isgasn'
9467 },
9468 week : {
9469 dow : 6, // Saturday is the first day of the week.
9470 doy : 12 // The week that contains Jan 1st is the first week of the year.
9471 }
9472 });
9473
9474 //! moment.js locale configuration
9475 //! locale : Morocco Central Atlas Tamaziɣt (tzm)
9476 //! author : Abdel Said : https://github.com/abdelsaid
9477
9478 var tzm = _moment__default.defineLocale('tzm', {
9479 months : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
9480 monthsShort : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
9481 weekdays : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
9482 weekdaysShort : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
9483 weekdaysMin : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
9484 longDateFormat : {
9485 LT : 'HH:mm',
9486 LTS: 'HH:mm:ss',
9487 L : 'DD/MM/YYYY',
9488 LL : 'D MMMM YYYY',
9489 LLL : 'D MMMM YYYY HH:mm',
9490 LLLL : 'dddd D MMMM YYYY HH:mm'
9491 },
9492 calendar : {
9493 sameDay: '[ⴰⵙⴷⵅ ⴴ] LT',
9494 nextDay: '[ⴰⵙⴽⴰ ⴴ] LT',
9495 nextWeek: 'dddd [ⴴ] LT',
9496 lastDay: '[ⴰⵚⴰⵏⵜ ⴴ] LT',
9497 lastWeek: 'dddd [ⴴ] LT',
9498 sameElse: 'L'
9499 },
9500 relativeTime : {
9501 future : 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s',
9502 past : 'ⵢⴰⵏ %s',
9503 s : 'ⵉⵎⵉⴽ',
9504 m : 'ⵎⵉⵏⵓⴺ',
9505 mm : '%d ⵎⵉⵏⵓⴺ',
9506 h : 'ⵙⴰⵄⴰ',
9507 hh : '%d ⵜⴰⵙⵙⴰⵄⵉⵏ',
9508 d : 'ⴰⵙⵙ',
9509 dd : '%d oⵙⵙⴰⵏ',
9510 M : 'ⴰⵢoⵓⵔ',
9511 MM : '%d ⵉⵢⵢⵉⵔⵏ',
9512 y : 'ⴰⵙⴳⴰⵙ',
9513 yy : '%d ⵉⵙⴳⴰⵙⵏ'
9514 },
9515 week : {
9516 dow : 6, // Saturday is the first day of the week.
9517 doy : 12 // The week that contains Jan 1st is the first week of the year.
9518 }
9519 });
9520
9521 //! moment.js locale configuration
9522 //! locale : ukrainian (uk)
9523 //! author : zemlanin : https://github.com/zemlanin
9524 //! Author : Menelion Elensúle : https://github.com/Oire
9525
9526 function uk__plural(word, num) {
9527 var forms = word.split('_');
9528 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
9529 }
9530 function uk__relativeTimeWithPlural(number, withoutSuffix, key) {
9531 var format = {
9532 'mm': 'хвилина_хвилини_хвилин',
9533 'hh': 'година_години_годин',
9534 'dd': 'день_дні_днів',
9535 'MM': 'місяць_місяці_місяців',
9536 'yy': 'рік_роки_років'
9537 };
9538 if (key === 'm') {
9539 return withoutSuffix ? 'хвилина' : 'хвилину';
9540 }
9541 else if (key === 'h') {
9542 return withoutSuffix ? 'година' : 'годину';
9543 }
9544 else {
9545 return number + ' ' + uk__plural(format[key], +number);
9546 }
9547 }
9548 function uk__monthsCaseReplace(m, format) {
9549 var months = {
9550 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
9551 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
9552 },
9553 nounCase = (/D[oD]? *MMMM?/).test(format) ?
9554 'accusative' :
9555 'nominative';
9556 return months[nounCase][m.month()];
9557 }
9558 function uk__weekdaysCaseReplace(m, format) {
9559 var weekdays = {
9560 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
9561 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
9562 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
9563 },
9564 nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
9565 'accusative' :
9566 ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
9567 'genitive' :
9568 'nominative');
9569 return weekdays[nounCase][m.day()];
9570 }
9571 function processHoursFunction(str) {
9572 return function () {
9573 return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
9574 };
9575 }
9576
9577 var uk = _moment__default.defineLocale('uk', {
9578 months : uk__monthsCaseReplace,
9579 monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
9580 weekdays : uk__weekdaysCaseReplace,
9581 weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
9582 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
9583 longDateFormat : {
9584 LT : 'HH:mm',
9585 LTS : 'HH:mm:ss',
9586 L : 'DD.MM.YYYY',
9587 LL : 'D MMMM YYYY р.',
9588 LLL : 'D MMMM YYYY р., HH:mm',
9589 LLLL : 'dddd, D MMMM YYYY р., HH:mm'
9590 },
9591 calendar : {
9592 sameDay: processHoursFunction('[Сьогодні '),
9593 nextDay: processHoursFunction('[Завтра '),
9594 lastDay: processHoursFunction('[Вчора '),
9595 nextWeek: processHoursFunction('[У] dddd ['),
9596 lastWeek: function () {
9597 switch (this.day()) {
9598 case 0:
9599 case 3:
9600 case 5:
9601 case 6:
9602 return processHoursFunction('[Минулої] dddd [').call(this);
9603 case 1:
9604 case 2:
9605 case 4:
9606 return processHoursFunction('[Минулого] dddd [').call(this);
9607 }
9608 },
9609 sameElse: 'L'
9610 },
9611 relativeTime : {
9612 future : 'за %s',
9613 past : '%s тому',
9614 s : 'декілька секунд',
9615 m : uk__relativeTimeWithPlural,
9616 mm : uk__relativeTimeWithPlural,
9617 h : 'годину',
9618 hh : uk__relativeTimeWithPlural,
9619 d : 'день',
9620 dd : uk__relativeTimeWithPlural,
9621 M : 'місяць',
9622 MM : uk__relativeTimeWithPlural,
9623 y : 'рік',
9624 yy : uk__relativeTimeWithPlural
9625 },
9626 // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
9627 meridiemParse: /ночі|ранку|дня|вечора/,
9628 isPM: function (input) {
9629 return /^(дня|вечора)$/.test(input);
9630 },
9631 meridiem : function (hour, minute, isLower) {
9632 if (hour < 4) {
9633 return 'ночі';
9634 } else if (hour < 12) {
9635 return 'ранку';
9636 } else if (hour < 17) {
9637 return 'дня';
9638 } else {
9639 return 'вечора';
9640 }
9641 },
9642 ordinalParse: /\d{1,2}-(й|го)/,
9643 ordinal: function (number, period) {
9644 switch (period) {
9645 case 'M':
9646 case 'd':
9647 case 'DDD':
9648 case 'w':
9649 case 'W':
9650 return number + '-й';
9651 case 'D':
9652 return number + '-го';
9653 default:
9654 return number;
9655 }
9656 },
9657 week : {
9658 dow : 1, // Monday is the first day of the week.
9659 doy : 7 // The week that contains Jan 1st is the first week of the year.
9660 }
9661 });
9662
9663 //! moment.js locale configuration
9664 //! locale : uzbek (uz)
9665 //! author : Sardor Muminov : https://github.com/muminoff
9666
9667 var uz = _moment__default.defineLocale('uz', {
9668 months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
9669 monthsShort : 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'),
9670 weekdays : 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'),
9671 weekdaysShort : 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'),
9672 weekdaysMin : 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'),
9673 longDateFormat : {
9674 LT : 'HH:mm',
9675 LTS : 'HH:mm:ss',
9676 L : 'DD/MM/YYYY',
9677 LL : 'D MMMM YYYY',
9678 LLL : 'D MMMM YYYY HH:mm',
9679 LLLL : 'D MMMM YYYY, dddd HH:mm'
9680 },
9681 calendar : {
9682 sameDay : '[Бугун соат] LT [да]',
9683 nextDay : '[Эртага] LT [да]',
9684 nextWeek : 'dddd [куни соат] LT [да]',
9685 lastDay : '[Кеча соат] LT [да]',
9686 lastWeek : '[Утган] dddd [куни соат] LT [да]',
9687 sameElse : 'L'
9688 },
9689 relativeTime : {
9690 future : 'Якин %s ичида',
9691 past : 'Бир неча %s олдин',
9692 s : 'фурсат',
9693 m : 'бир дакика',
9694 mm : '%d дакика',
9695 h : 'бир соат',
9696 hh : '%d соат',
9697 d : 'бир кун',
9698 dd : '%d кун',
9699 M : 'бир ой',
9700 MM : '%d ой',
9701 y : 'бир йил',
9702 yy : '%d йил'
9703 },
9704 week : {
9705 dow : 1, // Monday is the first day of the week.
9706 doy : 7 // The week that contains Jan 4th is the first week of the year.
9707 }
9708 });
9709
9710 //! moment.js locale configuration
9711 //! locale : vietnamese (vi)
9712 //! author : Bang Nguyen : https://github.com/bangnk
9713
9714 var vi = _moment__default.defineLocale('vi', {
9715 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('_'),
9716 monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
9717 weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
9718 weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
9719 weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
9720 longDateFormat : {
9721 LT : 'HH:mm',
9722 LTS : 'HH:mm:ss',
9723 L : 'DD/MM/YYYY',
9724 LL : 'D MMMM [năm] YYYY',
9725 LLL : 'D MMMM [năm] YYYY HH:mm',
9726 LLLL : 'dddd, D MMMM [năm] YYYY HH:mm',
9727 l : 'DD/M/YYYY',
9728 ll : 'D MMM YYYY',
9729 lll : 'D MMM YYYY HH:mm',
9730 llll : 'ddd, D MMM YYYY HH:mm'
9731 },
9732 calendar : {
9733 sameDay: '[Hôm nay lúc] LT',
9734 nextDay: '[Ngày mai lúc] LT',
9735 nextWeek: 'dddd [tuần tới lúc] LT',
9736 lastDay: '[Hôm qua lúc] LT',
9737 lastWeek: 'dddd [tuần rồi lúc] LT',
9738 sameElse: 'L'
9739 },
9740 relativeTime : {
9741 future : '%s tới',
9742 past : '%s trước',
9743 s : 'vài giây',
9744 m : 'một phút',
9745 mm : '%d phút',
9746 h : 'một giờ',
9747 hh : '%d giờ',
9748 d : 'một ngày',
9749 dd : '%d ngày',
9750 M : 'một tháng',
9751 MM : '%d tháng',
9752 y : 'một năm',
9753 yy : '%d năm'
9754 },
9755 ordinalParse: /\d{1,2}/,
9756 ordinal : function (number) {
9757 return number;
9758 },
9759 week : {
9760 dow : 1, // Monday is the first day of the week.
9761 doy : 4 // The week that contains Jan 4th is the first week of the year.
9762 }
9763 });
9764
9765 //! moment.js locale configuration
9766 //! locale : chinese (zh-cn)
9767 //! author : suupic : https://github.com/suupic
9768 //! author : Zeno Zeng : https://github.com/zenozeng
9769
9770 var zh_cn = _moment__default.defineLocale('zh-cn', {
9771 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
9772 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
9773 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
9774 weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
9775 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
9776 longDateFormat : {
9777 LT : 'Ah点mm分',
9778 LTS : 'Ah点m分s秒',
9779 L : 'YYYY-MM-DD',
9780 LL : 'YYYY年MMMD日',
9781 LLL : 'YYYY年MMMD日Ah点mm分',
9782 LLLL : 'YYYY年MMMD日ddddAh点mm分',
9783 l : 'YYYY-MM-DD',
9784 ll : 'YYYY年MMMD日',
9785 lll : 'YYYY年MMMD日Ah点mm分',
9786 llll : 'YYYY年MMMD日ddddAh点mm分'
9787 },
9788 meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
9789 meridiemHour: function (hour, meridiem) {
9790 if (hour === 12) {
9791 hour = 0;
9792 }
9793 if (meridiem === '凌晨' || meridiem === '早上' ||
9794 meridiem === '上午') {
9795 return hour;
9796 } else if (meridiem === '下午' || meridiem === '晚上') {
9797 return hour + 12;
9798 } else {
9799 // '中午'
9800 return hour >= 11 ? hour : hour + 12;
9801 }
9802 },
9803 meridiem : function (hour, minute, isLower) {
9804 var hm = hour * 100 + minute;
9805 if (hm < 600) {
9806 return '凌晨';
9807 } else if (hm < 900) {
9808 return '早上';
9809 } else if (hm < 1130) {
9810 return '上午';
9811 } else if (hm < 1230) {
9812 return '中午';
9813 } else if (hm < 1800) {
9814 return '下午';
9815 } else {
9816 return '晚上';
9817 }
9818 },
9819 calendar : {
9820 sameDay : function () {
9821 return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
9822 },
9823 nextDay : function () {
9824 return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
9825 },
9826 lastDay : function () {
9827 return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
9828 },
9829 nextWeek : function () {
9830 var startOfWeek, prefix;
9831 startOfWeek = _moment__default().startOf('week');
9832 prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
9833 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
9834 },
9835 lastWeek : function () {
9836 var startOfWeek, prefix;
9837 startOfWeek = _moment__default().startOf('week');
9838 prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
9839 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
9840 },
9841 sameElse : 'LL'
9842 },
9843 ordinalParse: /\d{1,2}(日|月|周)/,
9844 ordinal : function (number, period) {
9845 switch (period) {
9846 case 'd':
9847 case 'D':
9848 case 'DDD':
9849 return number + '日';
9850 case 'M':
9851 return number + '月';
9852 case 'w':
9853 case 'W':
9854 return number + '周';
9855 default:
9856 return number;
9857 }
9858 },
9859 relativeTime : {
9860 future : '%s内',
9861 past : '%s前',
9862 s : '几秒',
9863 m : '1 分钟',
9864 mm : '%d 分钟',
9865 h : '1 小时',
9866 hh : '%d 小时',
9867 d : '1 天',
9868 dd : '%d 天',
9869 M : '1 个月',
9870 MM : '%d 个月',
9871 y : '1 年',
9872 yy : '%d 年'
9873 },
9874 week : {
9875 // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
9876 dow : 1, // Monday is the first day of the week.
9877 doy : 4 // The week that contains Jan 4th is the first week of the year.
9878 }
9879 });
9880
9881 //! moment.js locale configuration
9882 //! locale : traditional chinese (zh-tw)
9883 //! author : Ben : https://github.com/ben-lin
9884
9885 var zh_tw = _moment__default.defineLocale('zh-tw', {
9886 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
9887 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
9888 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
9889 weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
9890 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
9891 longDateFormat : {
9892 LT : 'Ah點mm分',
9893 LTS : 'Ah點m分s秒',
9894 L : 'YYYY年MMMD日',
9895 LL : 'YYYY年MMMD日',
9896 LLL : 'YYYY年MMMD日Ah點mm分',
9897 LLLL : 'YYYY年MMMD日ddddAh點mm分',
9898 l : 'YYYY年MMMD日',
9899 ll : 'YYYY年MMMD日',
9900 lll : 'YYYY年MMMD日Ah點mm分',
9901 llll : 'YYYY年MMMD日ddddAh點mm分'
9902 },
9903 meridiemParse: /早上|上午|中午|下午|晚上/,
9904 meridiemHour : function (hour, meridiem) {
9905 if (hour === 12) {
9906 hour = 0;
9907 }
9908 if (meridiem === '早上' || meridiem === '上午') {
9909 return hour;
9910 } else if (meridiem === '中午') {
9911 return hour >= 11 ? hour : hour + 12;
9912 } else if (meridiem === '下午' || meridiem === '晚上') {
9913 return hour + 12;
9914 }
9915 },
9916 meridiem : function (hour, minute, isLower) {
9917 var hm = hour * 100 + minute;
9918 if (hm < 900) {
9919 return '早上';
9920 } else if (hm < 1130) {
9921 return '上午';
9922 } else if (hm < 1230) {
9923 return '中午';
9924 } else if (hm < 1800) {
9925 return '下午';
9926 } else {
9927 return '晚上';
9928 }
9929 },
9930 calendar : {
9931 sameDay : '[今天]LT',
9932 nextDay : '[明天]LT',
9933 nextWeek : '[下]ddddLT',
9934 lastDay : '[昨天]LT',
9935 lastWeek : '[上]ddddLT',
9936 sameElse : 'L'
9937 },
9938 ordinalParse: /\d{1,2}(日|月|週)/,
9939 ordinal : function (number, period) {
9940 switch (period) {
9941 case 'd' :
9942 case 'D' :
9943 case 'DDD' :
9944 return number + '日';
9945 case 'M' :
9946 return number + '月';
9947 case 'w' :
9948 case 'W' :
9949 return number + '週';
9950 default :
9951 return number;
9952 }
9953 },
9954 relativeTime : {
9955 future : '%s內',
9956 past : '%s前',
9957 s : '幾秒',
9958 m : '一分鐘',
9959 mm : '%d分鐘',
9960 h : '一小時',
9961 hh : '%d小時',
9962 d : '一天',
9963 dd : '%d天',
9964 M : '一個月',
9965 MM : '%d個月',
9966 y : '一年',
9967 yy : '%d年'
9968 }
9969 });
9970
9971 var moment_with_locales = _moment__default;
9972 moment_with_locales.locale('en');
9973
9974 return moment_with_locales;
9975
9976 }));
0
1 (function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
3 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
4 factory(global.moment)
5 }(this, function (moment) { 'use strict';
6
7 /*global QUnit:false*/
8
9 var test = QUnit.test;
10
11 function module (name, lifecycle) {
12 QUnit.module(name, {
13 setup : function () {
14 moment.locale('en');
15 moment.createFromInputFallback = function () {
16 throw new Error('input not handled by moment');
17 };
18 if (lifecycle && lifecycle.setup) {
19 lifecycle.setup();
20 }
21 },
22 teardown : function () {
23 if (lifecycle && lifecycle.teardown) {
24 lifecycle.teardown();
25 }
26 }
27 });
28 }
29
30 function localeModule (name, lifecycle) {
31 QUnit.module('locale:' + name, {
32 setup : function () {
33 moment.locale(name);
34 moment.createFromInputFallback = function () {
35 throw new Error('input not handled by moment');
36 };
37 if (lifecycle && lifecycle.setup) {
38 lifecycle.setup();
39 }
40 },
41 teardown : function () {
42 moment.locale('en');
43 if (lifecycle && lifecycle.teardown) {
44 lifecycle.teardown();
45 }
46 }
47 });
48 }
49
50 localeModule('af');
51
52 test('parse', function (assert) {
53 var tests = 'Januarie Jan_Februarie Feb_Maart Mar_April Apr_Mei Mei_Junie Jun_Julie Jul_Augustus Aug_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
54 function equalTest(input, mmm, i) {
55 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
56 }
57 for (i = 0; i < 12; i++) {
58 tests[i] = tests[i].split(' ');
59 equalTest(tests[i][0], 'MMM', i);
60 equalTest(tests[i][1], 'MMM', i);
61 equalTest(tests[i][0], 'MMMM', i);
62 equalTest(tests[i][1], 'MMMM', i);
63 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
64 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
65 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
66 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
67 }
68 });
69
70 test('format', function (assert) {
71 var a = [
72 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sondag, Februarie 14de 2010, 3:25:50 nm'],
73 ['ddd, hA', 'Son, 3NM'],
74 ['M Mo MM MMMM MMM', '2 2de 02 Februarie Feb'],
75 ['YYYY YY', '2010 10'],
76 ['D Do DD', '14 14de 14'],
77 ['d do dddd ddd dd', '0 0de Sondag Son So'],
78 ['DDD DDDo DDDD', '45 45ste 045'],
79 ['w wo ww', '6 6de 06'],
80 ['h hh', '3 03'],
81 ['H HH', '15 15'],
82 ['m mm', '25 25'],
83 ['s ss', '50 50'],
84 ['a A', 'nm NM'],
85 ['[the] DDDo [day of the year]', 'the 45ste day of the year'],
86 ['LT', '15:25'],
87 ['LTS', '15:25:50'],
88 ['L', '14/02/2010'],
89 ['LL', '14 Februarie 2010'],
90 ['LLL', '14 Februarie 2010 15:25'],
91 ['LLLL', 'Sondag, 14 Februarie 2010 15:25'],
92 ['l', '14/2/2010'],
93 ['ll', '14 Feb 2010'],
94 ['lll', '14 Feb 2010 15:25'],
95 ['llll', 'Son, 14 Feb 2010 15:25']
96 ],
97 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
98 i;
99 for (i = 0; i < a.length; i++) {
100 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
101 }
102 });
103
104 test('format ordinal', function (assert) {
105 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
106 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
107 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
108 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4de', '4de');
109 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5de', '5de');
110 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6de', '6de');
111 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7de', '7de');
112 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
113 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
114 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
115
116 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
117 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
118 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
119 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14de', '14de');
120 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15de', '15de');
121 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16de', '16de');
122 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17de', '17de');
123 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
124 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
125 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
126
127 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
128 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
129 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
130 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ste', '24ste');
131 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ste', '25ste');
132 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ste', '26ste');
133 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ste', '27ste');
134 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
135 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
136 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
137
138 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
139 });
140
141 test('format month', function (assert) {
142 var expected = 'Januarie Jan_Februarie Feb_Maart Mar_April Apr_Mei Mei_Junie Jun_Julie Jul_Augustus Aug_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
143 for (i = 0; i < expected.length; i++) {
144 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
145 }
146 });
147
148 test('format week', function (assert) {
149 var expected = 'Sondag Son So_Maandag Maa Ma_Dinsdag Din Di_Woensdag Woe Wo_Donderdag Don Do_Vrydag Vry Vr_Saterdag Sat Sa'.split('_'), i;
150 for (i = 0; i < expected.length; i++) {
151 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
152 }
153 });
154
155 test('from', function (assert) {
156 var start = moment([2007, 1, 28]);
157 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '\'n paar sekondes', '44 seconds = a few seconds');
158 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '\'n minuut', '45 seconds = a minute');
159 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '\'n minuut', '89 seconds = a minute');
160 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
161 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minute', '44 minutes = 44 minutes');
162 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '\'n uur', '45 minutes = an hour');
163 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '\'n uur', '89 minutes = an hour');
164 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ure', '90 minutes = 2 hours');
165 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ure', '5 hours = 5 hours');
166 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ure', '21 hours = 21 hours');
167 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '\'n dag', '22 hours = a day');
168 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '\'n dag', '35 hours = a day');
169 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dae', '36 hours = 2 days');
170 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '\'n dag', '1 day = a day');
171 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dae', '5 days = 5 days');
172 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dae', '25 days = 25 days');
173 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '\'n maand', '26 days = a month');
174 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '\'n maand', '30 days = a month');
175 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '\'n maand', '43 days = a month');
176 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 maande', '46 days = 2 months');
177 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 maande', '75 days = 2 months');
178 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 maande', '76 days = 3 months');
179 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '\'n maand', '1 month = a month');
180 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 maande', '5 months = 5 months');
181 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '\'n jaar', '345 days = a year');
182 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jaar', '548 days = 2 years');
183 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '\'n jaar', '1 year = a year');
184 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jaar', '5 years = 5 years');
185 });
186
187 test('suffix', function (assert) {
188 assert.equal(moment(30000).from(0), 'oor \'n paar sekondes', 'prefix');
189 assert.equal(moment(0).from(30000), '\'n paar sekondes gelede', 'suffix');
190 });
191
192 test('now from now', function (assert) {
193 assert.equal(moment().fromNow(), '\'n paar sekondes gelede', 'now from now should display as in the past');
194 });
195
196 test('fromNow', function (assert) {
197 assert.equal(moment().add({s: 30}).fromNow(), 'oor \'n paar sekondes', 'in a few seconds');
198 assert.equal(moment().add({d: 5}).fromNow(), 'oor 5 dae', 'in 5 days');
199 });
200
201 test('calendar day', function (assert) {
202 var a = moment().hours(2).minutes(0).seconds(0);
203
204 assert.equal(moment(a).calendar(), 'Vandag om 02:00', 'today at the same time');
205 assert.equal(moment(a).add({m: 25}).calendar(), 'Vandag om 02:25', 'Now plus 25 min');
206 assert.equal(moment(a).add({h: 1}).calendar(), 'Vandag om 03:00', 'Now plus 1 hour');
207 assert.equal(moment(a).add({d: 1}).calendar(), 'Môre om 02:00', 'tomorrow at the same time');
208 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Vandag om 01:00', 'Now minus 1 hour');
209 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gister om 02:00', 'yesterday at the same time');
210 });
211
212 test('calendar next week', function (assert) {
213 var i, m;
214 for (i = 2; i < 7; i++) {
215 m = moment().add({d: i});
216 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days current time');
217 m.hours(0).minutes(0).seconds(0).milliseconds(0);
218 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days beginning of day');
219 m.hours(23).minutes(59).seconds(59).milliseconds(999);
220 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days end of day');
221 }
222 });
223
224 test('calendar last week', function (assert) {
225 var i, m;
226 for (i = 2; i < 7; i++) {
227 m = moment().subtract({d: i});
228 assert.equal(m.calendar(), m.format('[Laas] dddd [om] LT'), 'Today - ' + i + ' days current time');
229 m.hours(0).minutes(0).seconds(0).milliseconds(0);
230 assert.equal(m.calendar(), m.format('[Laas] dddd [om] LT'), 'Today - ' + i + ' days beginning of day');
231 m.hours(23).minutes(59).seconds(59).milliseconds(999);
232 assert.equal(m.calendar(), m.format('[Laas] dddd [om] LT'), 'Today - ' + i + ' days end of day');
233 }
234 });
235
236 test('calendar all else', function (assert) {
237 var weeksAgo = moment().subtract({w: 1}),
238 weeksFromNow = moment().add({w: 1});
239
240 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
241 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
242
243 weeksAgo = moment().subtract({w: 2});
244 weeksFromNow = moment().add({w: 2});
245
246 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
247 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
248 });
249
250 test('weeks year starting sunday', function (assert) {
251 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
252 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
253 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
254 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
255 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
256 });
257
258 test('weeks year starting monday', function (assert) {
259 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
260 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
261 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
262 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
263 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
264 });
265
266 test('weeks year starting tuesday', function (assert) {
267 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
268 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
269 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
270 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
271 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
272 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
273 });
274
275 test('weeks year starting wednesday', function (assert) {
276 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
277 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
278 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
279 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
280 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
281 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
282 });
283
284 test('weeks year starting thursday', function (assert) {
285 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
286 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
287 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
288 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
289 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
290 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
291 });
292
293 test('weeks year starting friday', function (assert) {
294 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
295 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
296 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
297 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
298 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
299 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
300 });
301
302 test('weeks year starting saturday', function (assert) {
303 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
304 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
305 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
306 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
307 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
308 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
309 });
310
311 test('weeks year starting sunday formatted', function (assert) {
312 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
313 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
314 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1ste', 'Jan 8 2012 should be week 1');
315 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2');
316 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
317 });
318
319 test('lenient ordinal parsing', function (assert) {
320 var i, ordinalStr, testMoment;
321 for (i = 1; i <= 31; ++i) {
322 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
323 testMoment = moment(ordinalStr, 'YYYY MM Do');
324 assert.equal(testMoment.year(), 2014,
325 'lenient ordinal parsing ' + i + ' year check');
326 assert.equal(testMoment.month(), 0,
327 'lenient ordinal parsing ' + i + ' month check');
328 assert.equal(testMoment.date(), i,
329 'lenient ordinal parsing ' + i + ' date check');
330 }
331 });
332
333 test('lenient ordinal parsing of number', function (assert) {
334 var i, testMoment;
335 for (i = 1; i <= 31; ++i) {
336 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
337 assert.equal(testMoment.year(), 2014,
338 'lenient ordinal parsing of number ' + i + ' year check');
339 assert.equal(testMoment.month(), 0,
340 'lenient ordinal parsing of number ' + i + ' month check');
341 assert.equal(testMoment.date(), i,
342 'lenient ordinal parsing of number ' + i + ' date check');
343 }
344 });
345
346 test('strict ordinal parsing', function (assert) {
347 var i, ordinalStr, testMoment;
348 for (i = 1; i <= 31; ++i) {
349 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
350 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
351 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
352 }
353 });
354
355 }));
356
357 (function (global, factory) {
358 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
359 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
360 factory(global.moment)
361 }(this, function (moment) { 'use strict';
362
363 /*global QUnit:false*/
364
365 var test = QUnit.test;
366
367 function module (name, lifecycle) {
368 QUnit.module(name, {
369 setup : function () {
370 moment.locale('en');
371 moment.createFromInputFallback = function () {
372 throw new Error('input not handled by moment');
373 };
374 if (lifecycle && lifecycle.setup) {
375 lifecycle.setup();
376 }
377 },
378 teardown : function () {
379 if (lifecycle && lifecycle.teardown) {
380 lifecycle.teardown();
381 }
382 }
383 });
384 }
385
386 function localeModule (name, lifecycle) {
387 QUnit.module('locale:' + name, {
388 setup : function () {
389 moment.locale(name);
390 moment.createFromInputFallback = function () {
391 throw new Error('input not handled by moment');
392 };
393 if (lifecycle && lifecycle.setup) {
394 lifecycle.setup();
395 }
396 },
397 teardown : function () {
398 moment.locale('en');
399 if (lifecycle && lifecycle.teardown) {
400 lifecycle.teardown();
401 }
402 }
403 });
404 }
405
406 localeModule('ar-ma');
407
408 test('parse', function (assert) {
409 var tests = 'يناير:يناير_فبراير:فبراير_مارس:مارس_أبريل:أبريل_ماي:ماي_يونيو:يونيو_يوليوز:يوليوز_غشت:غشت_شتنبر:شتنبر_أكتوبر:أكتوبر_نونبر:نونبر_دجنبر:دجنبر'.split('_'), i;
410 function equalTest(input, mmm, i) {
411 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
412 }
413 for (i = 0; i < 12; i++) {
414 tests[i] = tests[i].split(':');
415 equalTest(tests[i][0], 'MMM', i);
416 equalTest(tests[i][1], 'MMM', i);
417 equalTest(tests[i][0], 'MMMM', i);
418 equalTest(tests[i][1], 'MMMM', i);
419 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
420 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
421 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
422 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
423 }
424 });
425
426 test('format', function (assert) {
427 var a = [
428 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فبراير 14 2010, 3:25:50 pm'],
429 ['ddd, hA', 'احد, 3PM'],
430 ['M Mo MM MMMM MMM', '2 2 02 فبراير فبراير'],
431 ['YYYY YY', '2010 10'],
432 ['D Do DD', '14 14 14'],
433 ['d do dddd ddd dd', '0 0 الأحد احد ح'],
434 ['DDD DDDo DDDD', '45 45 045'],
435 ['w wo ww', '8 8 08'],
436 ['h hh', '3 03'],
437 ['H HH', '15 15'],
438 ['m mm', '25 25'],
439 ['s ss', '50 50'],
440 ['a A', 'pm PM'],
441 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
442 ['LT', '15:25'],
443 ['LTS', '15:25:50'],
444 ['L', '14/02/2010'],
445 ['LL', '14 فبراير 2010'],
446 ['LLL', '14 فبراير 2010 15:25'],
447 ['LLLL', 'الأحد 14 فبراير 2010 15:25'],
448 ['l', '14/2/2010'],
449 ['ll', '14 فبراير 2010'],
450 ['lll', '14 فبراير 2010 15:25'],
451 ['llll', 'احد 14 فبراير 2010 15:25']
452 ],
453 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
454 i;
455 for (i = 0; i < a.length; i++) {
456 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
457 }
458 });
459
460 test('format ordinal', function (assert) {
461 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
462 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
463 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
464 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
465 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
466 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
467 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
468 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
469 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
470 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
471
472 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
473 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
474 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
475 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
476 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
477 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
478 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
479 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
480 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
481 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
482
483 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
484 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
485 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
486 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
487 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
488 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
489 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
490 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
491 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
492 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
493
494 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
495 });
496
497 test('format month', function (assert) {
498 var expected = 'يناير يناير_فبراير فبراير_مارس مارس_أبريل أبريل_ماي ماي_يونيو يونيو_يوليوز يوليوز_غشت غشت_شتنبر شتنبر_أكتوبر أكتوبر_نونبر نونبر_دجنبر دجنبر'.split('_'), i;
499 for (i = 0; i < expected.length; i++) {
500 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
501 }
502 });
503
504 test('format week', function (assert) {
505 var expected = 'الأحد احد ح_الإتنين اتنين ن_الثلاثاء ثلاثاء ث_الأربعاء اربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'), i;
506 for (i = 0; i < expected.length; i++) {
507 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
508 }
509 });
510
511 test('from', function (assert) {
512 var start = moment([2007, 1, 28]);
513 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ثوان', '44 seconds = a few seconds');
514 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'دقيقة', '45 seconds = a minute');
515 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'دقيقة', '89 seconds = a minute');
516 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 دقائق', '90 seconds = 2 minutes');
517 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 دقائق', '44 minutes = 44 minutes');
518 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ساعة', '45 minutes = an hour');
519 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ساعة', '89 minutes = an hour');
520 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ساعات', '90 minutes = 2 hours');
521 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ساعات', '5 hours = 5 hours');
522 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ساعات', '21 hours = 21 hours');
523 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'يوم', '22 hours = a day');
524 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'يوم', '35 hours = a day');
525 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 أيام', '36 hours = 2 days');
526 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'يوم', '1 day = a day');
527 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 أيام', '5 days = 5 days');
528 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 أيام', '25 days = 25 days');
529 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'شهر', '26 days = a month');
530 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'شهر', '30 days = a month');
531 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'شهر', '43 days = a month');
532 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 أشهر', '46 days = 2 months');
533 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 أشهر', '75 days = 2 months');
534 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 أشهر', '76 days = 3 months');
535 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'شهر', '1 month = a month');
536 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 أشهر', '5 months = 5 months');
537 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'سنة', '345 days = a year');
538 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 سنوات', '548 days = 2 years');
539 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'سنة', '1 year = a year');
540 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 سنوات', '5 years = 5 years');
541 });
542
543 test('suffix', function (assert) {
544 assert.equal(moment(30000).from(0), 'في ثوان', 'prefix');
545 assert.equal(moment(0).from(30000), 'منذ ثوان', 'suffix');
546 });
547
548 test('now from now', function (assert) {
549 assert.equal(moment().fromNow(), 'منذ ثوان', 'now from now should display as in the past');
550 });
551
552 test('fromNow', function (assert) {
553 assert.equal(moment().add({s: 30}).fromNow(), 'في ثوان', 'in a few seconds');
554 assert.equal(moment().add({d: 5}).fromNow(), 'في 5 أيام', 'in 5 days');
555 });
556
557 test('calendar day', function (assert) {
558 var a = moment().hours(2).minutes(0).seconds(0);
559
560 assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
561 assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
562 assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
563 assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
564 assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
565 assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
566 });
567
568 test('calendar next week', function (assert) {
569 var i, m;
570 for (i = 2; i < 7; i++) {
571 m = moment().add({d: i});
572 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days current time');
573 m.hours(0).minutes(0).seconds(0).milliseconds(0);
574 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days beginning of day');
575 m.hours(23).minutes(59).seconds(59).milliseconds(999);
576 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days end of day');
577 }
578 });
579
580 test('calendar last week', function (assert) {
581 var i, m;
582 for (i = 2; i < 7; i++) {
583 m = moment().subtract({d: i});
584 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days current time');
585 m.hours(0).minutes(0).seconds(0).milliseconds(0);
586 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days beginning of day');
587 m.hours(23).minutes(59).seconds(59).milliseconds(999);
588 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days end of day');
589 }
590 });
591
592 test('calendar all else', function (assert) {
593 var weeksAgo = moment().subtract({w: 1}),
594 weeksFromNow = moment().add({w: 1});
595
596 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
597 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
598
599 weeksAgo = moment().subtract({w: 2});
600 weeksFromNow = moment().add({w: 2});
601
602 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
603 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
604 });
605
606 test('weeks year starting sunday', function (assert) {
607 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
608 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
609 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
610 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
611 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
612 });
613
614 test('weeks year starting monday', function (assert) {
615 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
616 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
617 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
618 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
619 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
620 });
621
622 test('weeks year starting tuesday', function (assert) {
623 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
624 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
625 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
626 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
627 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
628 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
629 });
630
631 test('weeks year starting wednesday', function (assert) {
632 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
633 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
634 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
635 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
636 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
637 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
638 });
639
640 test('weeks year starting thursday', function (assert) {
641 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
642 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
643 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
644 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
645 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
646 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
647 });
648
649 test('weeks year starting friday', function (assert) {
650 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
651 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
652 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
653 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
654 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
655 });
656
657 test('weeks year starting saturday', function (assert) {
658 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
659 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
660 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
661 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
662 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
663 });
664
665 test('weeks year starting sunday formatted', function (assert) {
666 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
667 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
668 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 should be week 2');
669 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2');
670 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
671 });
672
673 test('lenient ordinal parsing', function (assert) {
674 var i, ordinalStr, testMoment;
675 for (i = 1; i <= 31; ++i) {
676 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
677 testMoment = moment(ordinalStr, 'YYYY MM Do');
678 assert.equal(testMoment.year(), 2014,
679 'lenient ordinal parsing ' + i + ' year check');
680 assert.equal(testMoment.month(), 0,
681 'lenient ordinal parsing ' + i + ' month check');
682 assert.equal(testMoment.date(), i,
683 'lenient ordinal parsing ' + i + ' date check');
684 }
685 });
686
687 test('lenient ordinal parsing of number', function (assert) {
688 var i, testMoment;
689 for (i = 1; i <= 31; ++i) {
690 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
691 assert.equal(testMoment.year(), 2014,
692 'lenient ordinal parsing of number ' + i + ' year check');
693 assert.equal(testMoment.month(), 0,
694 'lenient ordinal parsing of number ' + i + ' month check');
695 assert.equal(testMoment.date(), i,
696 'lenient ordinal parsing of number ' + i + ' date check');
697 }
698 });
699
700 test('strict ordinal parsing', function (assert) {
701 var i, ordinalStr, testMoment;
702 for (i = 1; i <= 31; ++i) {
703 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
704 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
705 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
706 }
707 });
708
709 }));
710
711 (function (global, factory) {
712 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
713 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
714 factory(global.moment)
715 }(this, function (moment) { 'use strict';
716
717 /*global QUnit:false*/
718
719 var test = QUnit.test;
720
721 function module (name, lifecycle) {
722 QUnit.module(name, {
723 setup : function () {
724 moment.locale('en');
725 moment.createFromInputFallback = function () {
726 throw new Error('input not handled by moment');
727 };
728 if (lifecycle && lifecycle.setup) {
729 lifecycle.setup();
730 }
731 },
732 teardown : function () {
733 if (lifecycle && lifecycle.teardown) {
734 lifecycle.teardown();
735 }
736 }
737 });
738 }
739
740 function localeModule (name, lifecycle) {
741 QUnit.module('locale:' + name, {
742 setup : function () {
743 moment.locale(name);
744 moment.createFromInputFallback = function () {
745 throw new Error('input not handled by moment');
746 };
747 if (lifecycle && lifecycle.setup) {
748 lifecycle.setup();
749 }
750 },
751 teardown : function () {
752 moment.locale('en');
753 if (lifecycle && lifecycle.teardown) {
754 lifecycle.teardown();
755 }
756 }
757 });
758 }
759
760 localeModule('ar-sa');
761
762 test('parse', function (assert) {
763 var tests = 'يناير:يناير_فبراير:فبراير_مارس:مارس_أبريل:أبريل_مايو:مايو_يونيو:يونيو_يوليو:يوليو_أغسطس:أغسطس_سبتمبر:سبتمبر_أكتوبر:أكتوبر_نوفمبر:نوفمبر_ديسمبر:ديسمبر'.split('_'), i;
764 function equalTest(input, mmm, i) {
765 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
766 }
767 for (i = 0; i < 12; i++) {
768 tests[i] = tests[i].split(':');
769 equalTest(tests[i][0], 'MMM', i);
770 equalTest(tests[i][1], 'MMM', i);
771 equalTest(tests[i][0], 'MMMM', i);
772 equalTest(tests[i][1], 'MMMM', i);
773 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
774 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
775 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
776 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
777 }
778 });
779
780 test('format', function (assert) {
781 var a = [
782 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد، فبراير ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'],
783 ['ddd, hA', 'أحد، ٣م'],
784 ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ فبراير فبراير'],
785 ['YYYY YY', '٢٠١٠ ١٠'],
786 ['D Do DD', '١٤ ١٤ ١٤'],
787 ['d do dddd ddd dd', '٠ ٠ الأحد أحد ح'],
788 ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'],
789 ['w wo ww', '٨ ٨ ٠٨'],
790 ['h hh', '٣ ٠٣'],
791 ['H HH', '١٥ ١٥'],
792 ['m mm', '٢٥ ٢٥'],
793 ['s ss', '٥٠ ٥٠'],
794 ['a A', 'م م'],
795 ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'],
796 ['LT', '١٥:٢٥'],
797 ['LTS', '١٥:٢٥:٥٠'],
798 ['L', '١٤/٠٢/٢٠١٠'],
799 ['LL', '١٤ فبراير ٢٠١٠'],
800 ['LLL', '١٤ فبراير ٢٠١٠ ١٥:٢٥'],
801 ['LLLL', 'الأحد ١٤ فبراير ٢٠١٠ ١٥:٢٥'],
802 ['l', '١٤/٢/٢٠١٠'],
803 ['ll', '١٤ فبراير ٢٠١٠'],
804 ['lll', '١٤ فبراير ٢٠١٠ ١٥:٢٥'],
805 ['llll', 'أحد ١٤ فبراير ٢٠١٠ ١٥:٢٥']
806 ],
807 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
808 i;
809 for (i = 0; i < a.length; i++) {
810 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
811 }
812 });
813
814 test('format ordinal', function (assert) {
815 assert.equal(moment([2011, 0, 1]).format('DDDo'), '١', '1');
816 assert.equal(moment([2011, 0, 2]).format('DDDo'), '٢', '2');
817 assert.equal(moment([2011, 0, 3]).format('DDDo'), '٣', '3');
818 assert.equal(moment([2011, 0, 4]).format('DDDo'), '٤', '4');
819 assert.equal(moment([2011, 0, 5]).format('DDDo'), '٥', '5');
820 assert.equal(moment([2011, 0, 6]).format('DDDo'), '٦', '6');
821 assert.equal(moment([2011, 0, 7]).format('DDDo'), '٧', '7');
822 assert.equal(moment([2011, 0, 8]).format('DDDo'), '٨', '8');
823 assert.equal(moment([2011, 0, 9]).format('DDDo'), '٩', '9');
824 assert.equal(moment([2011, 0, 10]).format('DDDo'), '١٠', '10');
825
826 assert.equal(moment([2011, 0, 11]).format('DDDo'), '١١', '11');
827 assert.equal(moment([2011, 0, 12]).format('DDDo'), '١٢', '12');
828 assert.equal(moment([2011, 0, 13]).format('DDDo'), '١٣', '13');
829 assert.equal(moment([2011, 0, 14]).format('DDDo'), '١٤', '14');
830 assert.equal(moment([2011, 0, 15]).format('DDDo'), '١٥', '15');
831 assert.equal(moment([2011, 0, 16]).format('DDDo'), '١٦', '16');
832 assert.equal(moment([2011, 0, 17]).format('DDDo'), '١٧', '17');
833 assert.equal(moment([2011, 0, 18]).format('DDDo'), '١٨', '18');
834 assert.equal(moment([2011, 0, 19]).format('DDDo'), '١٩', '19');
835 assert.equal(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20');
836
837 assert.equal(moment([2011, 0, 21]).format('DDDo'), '٢١', '21');
838 assert.equal(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22');
839 assert.equal(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23');
840 assert.equal(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24');
841 assert.equal(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25');
842 assert.equal(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26');
843 assert.equal(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27');
844 assert.equal(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28');
845 assert.equal(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29');
846 assert.equal(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30');
847
848 assert.equal(moment([2011, 0, 31]).format('DDDo'), '٣١', '31');
849 });
850
851 test('format month', function (assert) {
852 var expected = 'يناير يناير_فبراير فبراير_مارس مارس_أبريل أبريل_مايو مايو_يونيو يونيو_يوليو يوليو_أغسطس أغسطس_سبتمبر سبتمبر_أكتوبر أكتوبر_نوفمبر نوفمبر_ديسمبر ديسمبر'.split('_'), i;
853 for (i = 0; i < expected.length; i++) {
854 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
855 }
856 });
857
858 test('format week', function (assert) {
859 var expected = 'الأحد أحد ح_الإثنين إثنين ن_الثلاثاء ثلاثاء ث_الأربعاء أربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'), i;
860 for (i = 0; i < expected.length; i++) {
861 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
862 }
863 });
864
865 test('from', function (assert) {
866 var start = moment([2007, 1, 28]);
867 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ثوان', '44 seconds = a few seconds');
868 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'دقيقة', '45 seconds = a minute');
869 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'دقيقة', '89 seconds = a minute');
870 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '٢ دقائق', '90 seconds = 2 minutes');
871 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '٤٤ دقائق', '44 minutes = 44 minutes');
872 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ساعة', '45 minutes = an hour');
873 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ساعة', '89 minutes = an hour');
874 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '٢ ساعات', '90 minutes = 2 hours');
875 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '٥ ساعات', '5 hours = 5 hours');
876 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '٢١ ساعات', '21 hours = 21 hours');
877 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'يوم', '22 hours = a day');
878 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'يوم', '35 hours = a day');
879 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '٢ أيام', '36 hours = 2 days');
880 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'يوم', '1 day = a day');
881 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '٥ أيام', '5 days = 5 days');
882 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '٢٥ أيام', '25 days = 25 days');
883 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'شهر', '26 days = a month');
884 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'شهر', '30 days = a month');
885 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'شهر', '43 days = a month');
886 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '٢ أشهر', '46 days = 2 months');
887 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '٢ أشهر', '75 days = 2 months');
888 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '٣ أشهر', '76 days = 3 months');
889 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'شهر', '1 month = a month');
890 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '٥ أشهر', '5 months = 5 months');
891 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'سنة', '345 days = a year');
892 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '٢ سنوات', '548 days = 2 years');
893 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'سنة', '1 year = a year');
894 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '٥ سنوات', '5 years = 5 years');
895 });
896
897 test('suffix', function (assert) {
898 assert.equal(moment(30000).from(0), 'في ثوان', 'prefix');
899 assert.equal(moment(0).from(30000), 'منذ ثوان', 'suffix');
900 });
901
902 test('now from now', function (assert) {
903 assert.equal(moment().fromNow(), 'منذ ثوان', 'now from now should display as in the past');
904 });
905
906 test('fromNow', function (assert) {
907 assert.equal(moment().add({s: 30}).fromNow(), 'في ثوان', 'in a few seconds');
908 assert.equal(moment().add({d: 5}).fromNow(), 'في ٥ أيام', 'in 5 days');
909 });
910
911 test('calendar day', function (assert) {
912 var a = moment().hours(2).minutes(0).seconds(0);
913
914 assert.equal(moment(a).calendar(), 'اليوم على الساعة ٠٢:٠٠', 'today at the same time');
915 assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة ٠٢:٢٥', 'Now plus 25 min');
916 assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة ٠٣:٠٠', 'Now plus 1 hour');
917 assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة ٠٢:٠٠', 'tomorrow at the same time');
918 assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة ٠١:٠٠', 'Now minus 1 hour');
919 assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة ٠٢:٠٠', 'yesterday at the same time');
920 });
921
922 test('calendar next week', function (assert) {
923 var i, m;
924 for (i = 2; i < 7; i++) {
925 m = moment().add({d: i});
926 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days current time');
927 m.hours(0).minutes(0).seconds(0).milliseconds(0);
928 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days beginning of day');
929 m.hours(23).minutes(59).seconds(59).milliseconds(999);
930 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days end of day');
931 }
932 });
933
934 test('calendar last week', function (assert) {
935 var i, m;
936 for (i = 2; i < 7; i++) {
937 m = moment().subtract({d: i});
938 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days current time');
939 m.hours(0).minutes(0).seconds(0).milliseconds(0);
940 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days beginning of day');
941 m.hours(23).minutes(59).seconds(59).milliseconds(999);
942 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days end of day');
943 }
944 });
945
946 test('calendar all else', function (assert) {
947 var weeksAgo = moment().subtract({w: 1}),
948 weeksFromNow = moment().add({w: 1});
949
950 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
951 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
952
953 weeksAgo = moment().subtract({w: 2});
954 weeksFromNow = moment().add({w: 2});
955
956 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
957 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
958 });
959
960 test('weeks year starting sunday', function (assert) {
961 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
962 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
963 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
964 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
965 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
966 });
967
968 test('weeks year starting monday', function (assert) {
969 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
970 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
971 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
972 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
973 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
974 });
975
976 test('weeks year starting tuesday', function (assert) {
977 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
978 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
979 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
980 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
981 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
982 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
983 });
984
985 test('weeks year starting wednesday', function (assert) {
986 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
987 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
988 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
989 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
990 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
991 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
992
993 assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
994 assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
995 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');
996 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');
997 });
998
999 test('weeks year starting thursday', function (assert) {
1000 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
1001 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
1002 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
1003 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
1004 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
1005 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
1006 });
1007
1008 test('weeks year starting friday', function (assert) {
1009 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
1010 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
1011 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
1012 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
1013 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
1014 });
1015
1016 test('weeks year starting saturday', function (assert) {
1017 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
1018 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
1019 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
1020 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
1021 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
1022 });
1023
1024 test('weeks year starting sunday formatted', function (assert) {
1025 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', 'Dec 31 2011 should be week 1');
1026 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', 'Jan 6 2012 should be week 1');
1027 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2');
1028 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2');
1029 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
1030 });
1031
1032 test('lenient ordinal parsing', function (assert) {
1033 var i, ordinalStr, testMoment;
1034 for (i = 1; i <= 31; ++i) {
1035 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
1036 testMoment = moment(ordinalStr, 'YYYY MM Do');
1037 assert.equal(testMoment.year(), 2014,
1038 'lenient ordinal parsing ' + i + ' year check');
1039 assert.equal(testMoment.month(), 0,
1040 'lenient ordinal parsing ' + i + ' month check');
1041 assert.equal(testMoment.date(), i,
1042 'lenient ordinal parsing ' + i + ' date check');
1043 }
1044 });
1045
1046 test('lenient ordinal parsing of number', function (assert) {
1047 var i, testMoment;
1048 for (i = 1; i <= 31; ++i) {
1049 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
1050 assert.equal(testMoment.year(), 2014,
1051 'lenient ordinal parsing of number ' + i + ' year check');
1052 assert.equal(testMoment.month(), 0,
1053 'lenient ordinal parsing of number ' + i + ' month check');
1054 assert.equal(testMoment.date(), i,
1055 'lenient ordinal parsing of number ' + i + ' date check');
1056 }
1057 });
1058
1059 test('strict ordinal parsing', function (assert) {
1060 var i, ordinalStr, testMoment;
1061 for (i = 1; i <= 31; ++i) {
1062 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
1063 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
1064 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
1065 }
1066 });
1067
1068 }));
1069
1070 (function (global, factory) {
1071 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
1072 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
1073 factory(global.moment)
1074 }(this, function (moment) { 'use strict';
1075
1076 /*global QUnit:false*/
1077
1078 var test = QUnit.test;
1079
1080 function module (name, lifecycle) {
1081 QUnit.module(name, {
1082 setup : function () {
1083 moment.locale('en');
1084 moment.createFromInputFallback = function () {
1085 throw new Error('input not handled by moment');
1086 };
1087 if (lifecycle && lifecycle.setup) {
1088 lifecycle.setup();
1089 }
1090 },
1091 teardown : function () {
1092 if (lifecycle && lifecycle.teardown) {
1093 lifecycle.teardown();
1094 }
1095 }
1096 });
1097 }
1098
1099 function localeModule (name, lifecycle) {
1100 QUnit.module('locale:' + name, {
1101 setup : function () {
1102 moment.locale(name);
1103 moment.createFromInputFallback = function () {
1104 throw new Error('input not handled by moment');
1105 };
1106 if (lifecycle && lifecycle.setup) {
1107 lifecycle.setup();
1108 }
1109 },
1110 teardown : function () {
1111 moment.locale('en');
1112 if (lifecycle && lifecycle.teardown) {
1113 lifecycle.teardown();
1114 }
1115 }
1116 });
1117 }
1118
1119 localeModule('ar-tn');
1120
1121 test('parse', function (assert) {
1122 var tests = 'جانفي:جانفي_فيفري:فيفري_مارس:مارس_أفريل:أفريل_ماي:ماي_جوان:جوان_جويلية:جويلية_أوت:أوت_سبتمبر:سبتمبر_أكتوبر:أكتوبر_نوفمبر:نوفمبر_ديسمبر:ديسمبر'.split('_'),
1123 i;
1124
1125 function equalTest(input, mmm, i) {
1126 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
1127 }
1128 for (i = 0; i < 12; i++) {
1129 tests[i] = tests[i].split(':');
1130 equalTest(tests[i][0], 'MMM', i);
1131 equalTest(tests[i][1], 'MMM', i);
1132 equalTest(tests[i][0], 'MMMM', i);
1133 equalTest(tests[i][1], 'MMMM', i);
1134 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
1135 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
1136 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
1137 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
1138 }
1139 });
1140
1141 test('format', function (assert) {
1142 var a = [
1143 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فيفري 14 2010, 3:25:50 pm'],
1144 ['ddd, hA', 'أحد, 3PM'],
1145 ['M Mo MM MMMM MMM', '2 2 02 فيفري فيفري'],
1146 ['YYYY YY', '2010 10'],
1147 ['D Do DD', '14 14 14'],
1148 ['d do dddd ddd dd', '0 0 الأحد أحد ح'],
1149 ['DDD DDDo DDDD', '45 45 045'],
1150 ['w wo ww', '6 6 06'],
1151 ['h hh', '3 03'],
1152 ['H HH', '15 15'],
1153 ['m mm', '25 25'],
1154 ['s ss', '50 50'],
1155 ['a A', 'pm PM'],
1156 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
1157 ['LT', '15:25'],
1158 ['LTS', '15:25:50'],
1159 ['L', '14/02/2010'],
1160 ['LL', '14 فيفري 2010'],
1161 ['LLL', '14 فيفري 2010 15:25'],
1162 ['LLLL', 'الأحد 14 فيفري 2010 15:25'],
1163 ['l', '14/2/2010'],
1164 ['ll', '14 فيفري 2010'],
1165 ['lll', '14 فيفري 2010 15:25'],
1166 ['llll', 'أحد 14 فيفري 2010 15:25']
1167 ],
1168 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
1169 i;
1170 for (i = 0; i < a.length; i++) {
1171 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
1172 }
1173 });
1174
1175 test('format ordinal', function (assert) {
1176 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
1177 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
1178 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
1179 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
1180 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
1181 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
1182 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
1183 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
1184 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
1185 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
1186
1187 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
1188 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
1189 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
1190 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
1191 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
1192 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
1193 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
1194 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
1195 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
1196 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
1197
1198 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
1199 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
1200 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
1201 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
1202 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
1203 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
1204 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
1205 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
1206 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
1207 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
1208
1209 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
1210 });
1211
1212 test('format month', function (assert) {
1213 var expected = 'جانفي جانفي_فيفري فيفري_مارس مارس_أفريل أفريل_ماي ماي_جوان جوان_جويلية جويلية_أوت أوت_سبتمبر سبتمبر_أكتوبر أكتوبر_نوفمبر نوفمبر_ديسمبر ديسمبر'.split('_'),
1214 i;
1215 for (i = 0; i < expected.length; i++) {
1216 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
1217 }
1218 });
1219
1220 test('format week', function (assert) {
1221 var expected = 'الأحد أحد ح_الإثنين إثنين ن_الثلاثاء ثلاثاء ث_الأربعاء أربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'),
1222 i;
1223 for (i = 0; i < expected.length; i++) {
1224 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
1225 }
1226 });
1227
1228 test('from', function (assert) {
1229 var start = moment([2007, 1, 28]);
1230 assert.equal(start.from(moment([2007, 1, 28]).add({
1231 s: 44
1232 }), true), 'ثوان', '44 seconds = a few seconds');
1233 assert.equal(start.from(moment([2007, 1, 28]).add({
1234 s: 45
1235 }), true), 'دقيقة', '45 seconds = a minute');
1236 assert.equal(start.from(moment([2007, 1, 28]).add({
1237 s: 89
1238 }), true), 'دقيقة', '89 seconds = a minute');
1239 assert.equal(start.from(moment([2007, 1, 28]).add({
1240 s: 90
1241 }), true), '2 دقائق', '90 seconds = 2 minutes');
1242 assert.equal(start.from(moment([2007, 1, 28]).add({
1243 m: 44
1244 }), true), '44 دقائق', '44 minutes = 44 minutes');
1245 assert.equal(start.from(moment([2007, 1, 28]).add({
1246 m: 45
1247 }), true), 'ساعة', '45 minutes = an hour');
1248 assert.equal(start.from(moment([2007, 1, 28]).add({
1249 m: 89
1250 }), true), 'ساعة', '89 minutes = an hour');
1251 assert.equal(start.from(moment([2007, 1, 28]).add({
1252 m: 90
1253 }), true), '2 ساعات', '90 minutes = 2 hours');
1254 assert.equal(start.from(moment([2007, 1, 28]).add({
1255 h: 5
1256 }), true), '5 ساعات', '5 hours = 5 hours');
1257 assert.equal(start.from(moment([2007, 1, 28]).add({
1258 h: 21
1259 }), true), '21 ساعات', '21 hours = 21 hours');
1260 assert.equal(start.from(moment([2007, 1, 28]).add({
1261 h: 22
1262 }), true), 'يوم', '22 hours = a day');
1263 assert.equal(start.from(moment([2007, 1, 28]).add({
1264 h: 35
1265 }), true), 'يوم', '35 hours = a day');
1266 assert.equal(start.from(moment([2007, 1, 28]).add({
1267 h: 36
1268 }), true), '2 أيام', '36 hours = 2 days');
1269 assert.equal(start.from(moment([2007, 1, 28]).add({
1270 d: 1
1271 }), true), 'يوم', '1 day = a day');
1272 assert.equal(start.from(moment([2007, 1, 28]).add({
1273 d: 5
1274 }), true), '5 أيام', '5 days = 5 days');
1275 assert.equal(start.from(moment([2007, 1, 28]).add({
1276 d: 25
1277 }), true), '25 أيام', '25 days = 25 days');
1278 assert.equal(start.from(moment([2007, 1, 28]).add({
1279 d: 26
1280 }), true), 'شهر', '26 days = a month');
1281 assert.equal(start.from(moment([2007, 1, 28]).add({
1282 d: 30
1283 }), true), 'شهر', '30 days = a month');
1284 assert.equal(start.from(moment([2007, 1, 28]).add({
1285 d: 43
1286 }), true), 'شهر', '43 days = a month');
1287 assert.equal(start.from(moment([2007, 1, 28]).add({
1288 d: 46
1289 }), true), '2 أشهر', '46 days = 2 months');
1290 assert.equal(start.from(moment([2007, 1, 28]).add({
1291 d: 74
1292 }), true), '2 أشهر', '75 days = 2 months');
1293 assert.equal(start.from(moment([2007, 1, 28]).add({
1294 d: 76
1295 }), true), '3 أشهر', '76 days = 3 months');
1296 assert.equal(start.from(moment([2007, 1, 28]).add({
1297 M: 1
1298 }), true), 'شهر', '1 month = a month');
1299 assert.equal(start.from(moment([2007, 1, 28]).add({
1300 M: 5
1301 }), true), '5 أشهر', '5 months = 5 months');
1302 assert.equal(start.from(moment([2007, 1, 28]).add({
1303 d: 345
1304 }), true), 'سنة', '345 days = a year');
1305 assert.equal(start.from(moment([2007, 1, 28]).add({
1306 d: 548
1307 }), true), '2 سنوات', '548 days = 2 years');
1308 assert.equal(start.from(moment([2007, 1, 28]).add({
1309 y: 1
1310 }), true), 'سنة', '1 year = a year');
1311 assert.equal(start.from(moment([2007, 1, 28]).add({
1312 y: 5
1313 }), true), '5 سنوات', '5 years = 5 years');
1314 });
1315
1316 test('suffix', function (assert) {
1317 assert.equal(moment(30000).from(0), 'في ثوان', 'prefix');
1318 assert.equal(moment(0).from(30000), 'منذ ثوان', 'suffix');
1319 });
1320
1321 test('now from now', function (assert) {
1322 assert.equal(moment().fromNow(), 'منذ ثوان', 'now from now should display as in the past');
1323 });
1324
1325 test('fromNow', function (assert) {
1326 assert.equal(moment().add({
1327 s: 30
1328 }).fromNow(), 'في ثوان', 'in a few seconds');
1329 assert.equal(moment().add({
1330 d: 5
1331 }).fromNow(), 'في 5 أيام', 'in 5 days');
1332 });
1333
1334 test('calendar day', function (assert) {
1335 var a = moment().hours(2).minutes(0).seconds(0);
1336
1337 assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
1338 assert.equal(moment(a).add({
1339 m: 25
1340 }).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
1341 assert.equal(moment(a).add({
1342 h: 1
1343 }).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
1344 assert.equal(moment(a).add({
1345 d: 1
1346 }).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
1347 assert.equal(moment(a).subtract({
1348 h: 1
1349 }).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
1350 assert.equal(moment(a).subtract({
1351 d: 1
1352 }).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
1353 });
1354
1355 test('calendar next week', function (assert) {
1356 var i, m;
1357 for (i = 2; i < 7; i++) {
1358 m = moment().add({
1359 d: i
1360 });
1361 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days current time');
1362 m.hours(0).minutes(0).seconds(0).milliseconds(0);
1363 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days beginning of day');
1364 m.hours(23).minutes(59).seconds(59).milliseconds(999);
1365 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days end of day');
1366 }
1367 });
1368
1369 test('calendar last week', function (assert) {
1370 var i, m;
1371 for (i = 2; i < 7; i++) {
1372 m = moment().subtract({
1373 d: i
1374 });
1375 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days current time');
1376 m.hours(0).minutes(0).seconds(0).milliseconds(0);
1377 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days beginning of day');
1378 m.hours(23).minutes(59).seconds(59).milliseconds(999);
1379 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days end of day');
1380 }
1381 });
1382
1383 test('calendar all else', function (assert) {
1384 var weeksAgo = moment().subtract({
1385 w: 1
1386 }),
1387 weeksFromNow = moment().add({
1388 w: 1
1389 });
1390
1391 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
1392 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
1393
1394 weeksAgo = moment().subtract({
1395 w: 2
1396 });
1397 weeksFromNow = moment().add({
1398 w: 2
1399 });
1400
1401 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
1402 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
1403 });
1404
1405 test('weeks year starting sunday', function (assert) {
1406 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
1407 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
1408 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
1409 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
1410 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
1411 });
1412
1413 test('weeks year starting monday', function (assert) {
1414 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
1415 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
1416 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
1417 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
1418 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
1419 });
1420
1421 test('weeks year starting tuesday', function (assert) {
1422 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
1423 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
1424 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
1425 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
1426 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
1427 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
1428 });
1429
1430 test('weeks year starting wednesday', function (assert) {
1431 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
1432 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
1433 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
1434 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
1435 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
1436 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
1437 });
1438
1439 test('weeks year starting thursday', function (assert) {
1440 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
1441 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
1442 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
1443 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
1444 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
1445 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
1446 });
1447
1448 test('weeks year starting friday', function (assert) {
1449 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
1450 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
1451 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
1452 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
1453 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
1454 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
1455 });
1456
1457 test('weeks year starting saturday', function (assert) {
1458 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
1459 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
1460 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
1461 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
1462 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
1463 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
1464 });
1465
1466 test('weeks year starting sunday formatted', function (assert) {
1467 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
1468 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
1469 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
1470 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
1471 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
1472 });
1473
1474 test('lenient ordinal parsing', function (assert) {
1475 var i, ordinalStr, testMoment;
1476 for (i = 1; i <= 31; ++i) {
1477 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
1478 testMoment = moment(ordinalStr, 'YYYY MM Do');
1479 assert.equal(testMoment.year(), 2014,
1480 'lenient ordinal parsing ' + i + ' year check');
1481 assert.equal(testMoment.month(), 0,
1482 'lenient ordinal parsing ' + i + ' month check');
1483 assert.equal(testMoment.date(), i,
1484 'lenient ordinal parsing ' + i + ' date check');
1485 }
1486 });
1487
1488 test('lenient ordinal parsing of number', function (assert) {
1489 var i, testMoment;
1490 for (i = 1; i <= 31; ++i) {
1491 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
1492 assert.equal(testMoment.year(), 2014,
1493 'lenient ordinal parsing of number ' + i + ' year check');
1494 assert.equal(testMoment.month(), 0,
1495 'lenient ordinal parsing of number ' + i + ' month check');
1496 assert.equal(testMoment.date(), i,
1497 'lenient ordinal parsing of number ' + i + ' date check');
1498 }
1499 });
1500
1501 test('strict ordinal parsing', function (assert) {
1502 var i, ordinalStr, testMoment;
1503 for (i = 1; i <= 31; ++i) {
1504 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
1505 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
1506 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
1507 }
1508 });
1509
1510 }));
1511
1512 (function (global, factory) {
1513 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
1514 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
1515 factory(global.moment)
1516 }(this, function (moment) { 'use strict';
1517
1518 /*global QUnit:false*/
1519
1520 var test = QUnit.test;
1521
1522 function module (name, lifecycle) {
1523 QUnit.module(name, {
1524 setup : function () {
1525 moment.locale('en');
1526 moment.createFromInputFallback = function () {
1527 throw new Error('input not handled by moment');
1528 };
1529 if (lifecycle && lifecycle.setup) {
1530 lifecycle.setup();
1531 }
1532 },
1533 teardown : function () {
1534 if (lifecycle && lifecycle.teardown) {
1535 lifecycle.teardown();
1536 }
1537 }
1538 });
1539 }
1540
1541 function localeModule (name, lifecycle) {
1542 QUnit.module('locale:' + name, {
1543 setup : function () {
1544 moment.locale(name);
1545 moment.createFromInputFallback = function () {
1546 throw new Error('input not handled by moment');
1547 };
1548 if (lifecycle && lifecycle.setup) {
1549 lifecycle.setup();
1550 }
1551 },
1552 teardown : function () {
1553 moment.locale('en');
1554 if (lifecycle && lifecycle.teardown) {
1555 lifecycle.teardown();
1556 }
1557 }
1558 });
1559 }
1560
1561 localeModule('ar');
1562
1563 var months = [
1564 'كانون الثاني يناير',
1565 'شباط فبراير',
1566 'آذار مارس',
1567 'نيسان أبريل',
1568 'أيار مايو',
1569 'حزيران يونيو',
1570 'تموز يوليو',
1571 'آب أغسطس',
1572 'أيلول سبتمبر',
1573 'تشرين الأول أكتوبر',
1574 'تشرين الثاني نوفمبر',
1575 'كانون الأول ديسمبر'
1576 ];
1577
1578 test('parse', function (assert) {
1579 var tests = months, i;
1580 function equalTest(input, mmm, i) {
1581 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
1582 }
1583 for (i = 0; i < 12; i++) {
1584 equalTest(tests[i], 'MMM', i);
1585 equalTest(tests[i], 'MMM', i);
1586 equalTest(tests[i], 'MMMM', i);
1587 equalTest(tests[i], 'MMMM', i);
1588 equalTest(tests[i].toLocaleLowerCase(), 'MMMM', i);
1589 equalTest(tests[i].toLocaleLowerCase(), 'MMMM', i);
1590 equalTest(tests[i].toLocaleUpperCase(), 'MMMM', i);
1591 equalTest(tests[i].toLocaleUpperCase(), 'MMMM', i);
1592 }
1593 });
1594
1595 test('format', function (assert) {
1596 var a = [
1597 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد، شباط فبراير ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'],
1598 ['ddd, hA', 'أحد، ٣م'],
1599 ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ شباط فبراير شباط فبراير'],
1600 ['YYYY YY', '٢٠١٠ ١٠'],
1601 ['D Do DD', '١٤ ١٤ ١٤'],
1602 ['d do dddd ddd dd', '٠ ٠ الأحد أحد ح'],
1603 ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'],
1604 ['w wo ww', '٨ ٨ ٠٨'],
1605 ['h hh', '٣ ٠٣'],
1606 ['H HH', '١٥ ١٥'],
1607 ['m mm', '٢٥ ٢٥'],
1608 ['s ss', '٥٠ ٥٠'],
1609 ['a A', 'م م'],
1610 ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'],
1611 ['LT', '١٥:٢٥'],
1612 ['LTS', '١٥:٢٥:٥٠'],
1613 ['L', '١٤/\u200f٢/\u200f٢٠١٠'],
1614 ['LL', '١٤ شباط فبراير ٢٠١٠'],
1615 ['LLL', '١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'],
1616 ['LLLL', 'الأحد ١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'],
1617 ['l', '١٤/\u200f٢/\u200f٢٠١٠'],
1618 ['ll', '١٤ شباط فبراير ٢٠١٠'],
1619 ['lll', '١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'],
1620 ['llll', 'أحد ١٤ شباط فبراير ٢٠١٠ ١٥:٢٥']
1621 ],
1622 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
1623 i;
1624 for (i = 0; i < a.length; i++) {
1625 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
1626 }
1627 });
1628
1629 test('format ordinal', function (assert) {
1630 assert.equal(moment([2011, 0, 1]).format('DDDo'), '١', '1');
1631 assert.equal(moment([2011, 0, 2]).format('DDDo'), '٢', '2');
1632 assert.equal(moment([2011, 0, 3]).format('DDDo'), '٣', '3');
1633 assert.equal(moment([2011, 0, 4]).format('DDDo'), '٤', '4');
1634 assert.equal(moment([2011, 0, 5]).format('DDDo'), '٥', '5');
1635 assert.equal(moment([2011, 0, 6]).format('DDDo'), '٦', '6');
1636 assert.equal(moment([2011, 0, 7]).format('DDDo'), '٧', '7');
1637 assert.equal(moment([2011, 0, 8]).format('DDDo'), '٨', '8');
1638 assert.equal(moment([2011, 0, 9]).format('DDDo'), '٩', '9');
1639 assert.equal(moment([2011, 0, 10]).format('DDDo'), '١٠', '10');
1640
1641 assert.equal(moment([2011, 0, 11]).format('DDDo'), '١١', '11');
1642 assert.equal(moment([2011, 0, 12]).format('DDDo'), '١٢', '12');
1643 assert.equal(moment([2011, 0, 13]).format('DDDo'), '١٣', '13');
1644 assert.equal(moment([2011, 0, 14]).format('DDDo'), '١٤', '14');
1645 assert.equal(moment([2011, 0, 15]).format('DDDo'), '١٥', '15');
1646 assert.equal(moment([2011, 0, 16]).format('DDDo'), '١٦', '16');
1647 assert.equal(moment([2011, 0, 17]).format('DDDo'), '١٧', '17');
1648 assert.equal(moment([2011, 0, 18]).format('DDDo'), '١٨', '18');
1649 assert.equal(moment([2011, 0, 19]).format('DDDo'), '١٩', '19');
1650 assert.equal(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20');
1651
1652 assert.equal(moment([2011, 0, 21]).format('DDDo'), '٢١', '21');
1653 assert.equal(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22');
1654 assert.equal(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23');
1655 assert.equal(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24');
1656 assert.equal(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25');
1657 assert.equal(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26');
1658 assert.equal(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27');
1659 assert.equal(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28');
1660 assert.equal(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29');
1661 assert.equal(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30');
1662
1663 assert.equal(moment([2011, 0, 31]).format('DDDo'), '٣١', '31');
1664 });
1665
1666 test('format month', function (assert) {
1667 var expected = months, i;
1668 for (i = 0; i < expected.length; i++) {
1669 assert.equal(moment([2011, i, 1]).format('MMMM'), expected[i], expected[i]);
1670 assert.equal(moment([2011, i, 1]).format('MMM'), expected[i], expected[i]);
1671 }
1672 });
1673
1674 test('format week', function (assert) {
1675 var expected = 'الأحد أحد ح_الإثنين إثنين ن_الثلاثاء ثلاثاء ث_الأربعاء أربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'), i;
1676 for (i = 0; i < expected.length; i++) {
1677 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
1678 }
1679 });
1680
1681 test('from', function (assert) {
1682 var start = moment([2007, 1, 28]);
1683 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '٤٤ ثانية', '44 seconds = a few seconds');
1684 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'دقيقة واحدة', '45 seconds = a minute');
1685 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'دقيقة واحدة', '89 seconds = a minute');
1686 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'دقيقتان', '90 seconds = 2 minutes');
1687 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '٤٤ دقيقة', '44 minutes = 44 minutes');
1688 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ساعة واحدة', '45 minutes = an hour');
1689 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ساعة واحدة', '89 minutes = an hour');
1690 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'ساعتان', '90 minutes = 2 hours');
1691 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '٥ ساعات', '5 hours = 5 hours');
1692 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '٢١ ساعة', '21 hours = 21 hours');
1693 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'يوم واحد', '22 hours = a day');
1694 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'يوم واحد', '35 hours = a day');
1695 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'يومان', '36 hours = 2 days');
1696 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'يوم واحد', '1 day = a day');
1697 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '٥ أيام', '5 days = 5 days');
1698 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '٢٥ يومًا', '25 days = 25 days');
1699 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'شهر واحد', '26 days = a month');
1700 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'شهر واحد', '30 days = a month');
1701 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'شهر واحد', '43 days = a month');
1702 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'شهران', '46 days = 2 months');
1703 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'شهران', '75 days = 2 months');
1704 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '٣ أشهر', '76 days = 3 months');
1705 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'شهر واحد', '1 month = a month');
1706 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '٥ أشهر', '5 months = 5 months');
1707 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'عام واحد', '345 days = a year');
1708 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'عامان', '548 days = 2 years');
1709 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'عام واحد', '1 year = a year');
1710 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '٥ أعوام', '5 years = 5 years');
1711 });
1712
1713 test('suffix', function (assert) {
1714 assert.equal(moment(30000).from(0), 'بعد ٣٠ ثانية', 'prefix');
1715 assert.equal(moment(0).from(30000), 'منذ ٣٠ ثانية', 'suffix');
1716 });
1717
1718 test('now from now', function (assert) {
1719 assert.equal(moment().fromNow(), 'منذ ثانية واحدة', 'now from now should display as in the past');
1720 });
1721
1722 test('fromNow', function (assert) {
1723 assert.equal(moment().add({s: 30}).fromNow(), 'بعد ٣٠ ثانية', 'in a few seconds');
1724 assert.equal(moment().add({d: 5}).fromNow(), 'بعد ٥ أيام', 'in 5 days');
1725 });
1726
1727 test('calendar day', function (assert) {
1728 var a = moment().hours(2).minutes(0).seconds(0);
1729
1730 assert.equal(moment(a).calendar(), 'اليوم عند الساعة ٠٢:٠٠', 'today at the same time');
1731 assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم عند الساعة ٠٢:٢٥', 'Now plus 25 min');
1732 assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم عند الساعة ٠٣:٠٠', 'Now plus 1 hour');
1733 assert.equal(moment(a).add({d: 1}).calendar(), 'غدًا عند الساعة ٠٢:٠٠', 'tomorrow at the same time');
1734 assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم عند الساعة ٠١:٠٠', 'Now minus 1 hour');
1735 assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس عند الساعة ٠٢:٠٠', 'yesterday at the same time');
1736 });
1737
1738 test('calendar next week', function (assert) {
1739 var i, m;
1740 for (i = 2; i < 7; i++) {
1741 m = moment().add({d: i});
1742 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today + ' + i + ' days current time');
1743 m.hours(0).minutes(0).seconds(0).milliseconds(0);
1744 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today + ' + i + ' days beginning of day');
1745 m.hours(23).minutes(59).seconds(59).milliseconds(999);
1746 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today + ' + i + ' days end of day');
1747 }
1748 });
1749
1750 test('calendar last week', function (assert) {
1751 var i, m;
1752 for (i = 2; i < 7; i++) {
1753 m = moment().subtract({d: i});
1754 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today - ' + i + ' days current time');
1755 m.hours(0).minutes(0).seconds(0).milliseconds(0);
1756 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today - ' + i + ' days beginning of day');
1757 m.hours(23).minutes(59).seconds(59).milliseconds(999);
1758 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today - ' + i + ' days end of day');
1759 }
1760 });
1761
1762 test('calendar all else', function (assert) {
1763 var weeksAgo = moment().subtract({w: 1}),
1764 weeksFromNow = moment().add({w: 1});
1765
1766 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
1767 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
1768
1769 weeksAgo = moment().subtract({w: 2});
1770 weeksFromNow = moment().add({w: 2});
1771
1772 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
1773 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
1774 });
1775
1776 test('weeks year starting sunday', function (assert) {
1777 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
1778 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
1779 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
1780 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
1781 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
1782 });
1783
1784 test('weeks year starting monday', function (assert) {
1785 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
1786 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
1787 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
1788 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
1789 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
1790 });
1791
1792 test('weeks year starting tuesday', function (assert) {
1793 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
1794 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
1795 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
1796 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
1797 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
1798 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
1799 });
1800
1801 test('weeks year starting wednesday', function (assert) {
1802 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
1803 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
1804 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
1805 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
1806 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
1807 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
1808
1809 assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
1810 assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
1811 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');
1812 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');
1813 });
1814
1815 test('weeks year starting thursday', function (assert) {
1816 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
1817 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
1818 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
1819 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
1820 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
1821 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
1822 });
1823
1824 test('weeks year starting friday', function (assert) {
1825 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
1826 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
1827 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
1828 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
1829 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
1830 });
1831
1832 test('weeks year starting saturday', function (assert) {
1833 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
1834 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
1835 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
1836 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
1837 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
1838 });
1839
1840 test('weeks year starting sunday formatted', function (assert) {
1841 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', 'Dec 31 2011 should be week 1');
1842 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', 'Jan 6 2012 should be week 1');
1843 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2');
1844 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2');
1845 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
1846 });
1847
1848 test('lenient ordinal parsing', function (assert) {
1849 var i, ordinalStr, testMoment;
1850 for (i = 1; i <= 31; ++i) {
1851 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
1852 testMoment = moment(ordinalStr, 'YYYY MM Do');
1853 assert.equal(testMoment.year(), 2014,
1854 'lenient ordinal parsing ' + i + ' year check');
1855 assert.equal(testMoment.month(), 0,
1856 'lenient ordinal parsing ' + i + ' month check');
1857 assert.equal(testMoment.date(), i,
1858 'lenient ordinal parsing ' + i + ' date check');
1859 }
1860 });
1861
1862 test('lenient ordinal parsing of number', function (assert) {
1863 var i, testMoment;
1864 for (i = 1; i <= 31; ++i) {
1865 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
1866 assert.equal(testMoment.year(), 2014,
1867 'lenient ordinal parsing of number ' + i + ' year check');
1868 assert.equal(testMoment.month(), 0,
1869 'lenient ordinal parsing of number ' + i + ' month check');
1870 assert.equal(testMoment.date(), i,
1871 'lenient ordinal parsing of number ' + i + ' date check');
1872 }
1873 });
1874
1875 test('strict ordinal parsing', function (assert) {
1876 var i, ordinalStr, testMoment;
1877 for (i = 1; i <= 31; ++i) {
1878 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
1879 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
1880 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
1881 }
1882 });
1883
1884 test('no leading zeros in long date formats', function (assert) {
1885 var i, j, longDateStr, shortDateStr;
1886 for (i = 1; i <= 9; ++i) {
1887 for (j = 1; j <= 9; ++j) {
1888 longDateStr = moment([2014, i, j]).format('L');
1889 shortDateStr = moment([2014, i, j]).format('l');
1890 assert.equal(longDateStr, shortDateStr, 'should not have leading zeros in month or day');
1891 }
1892 }
1893 });
1894
1895 }));
1896
1897 (function (global, factory) {
1898 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
1899 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
1900 factory(global.moment)
1901 }(this, function (moment) { 'use strict';
1902
1903 /*global QUnit:false*/
1904
1905 var test = QUnit.test;
1906
1907 function module (name, lifecycle) {
1908 QUnit.module(name, {
1909 setup : function () {
1910 moment.locale('en');
1911 moment.createFromInputFallback = function () {
1912 throw new Error('input not handled by moment');
1913 };
1914 if (lifecycle && lifecycle.setup) {
1915 lifecycle.setup();
1916 }
1917 },
1918 teardown : function () {
1919 if (lifecycle && lifecycle.teardown) {
1920 lifecycle.teardown();
1921 }
1922 }
1923 });
1924 }
1925
1926 function localeModule (name, lifecycle) {
1927 QUnit.module('locale:' + name, {
1928 setup : function () {
1929 moment.locale(name);
1930 moment.createFromInputFallback = function () {
1931 throw new Error('input not handled by moment');
1932 };
1933 if (lifecycle && lifecycle.setup) {
1934 lifecycle.setup();
1935 }
1936 },
1937 teardown : function () {
1938 moment.locale('en');
1939 if (lifecycle && lifecycle.teardown) {
1940 lifecycle.teardown();
1941 }
1942 }
1943 });
1944 }
1945
1946 localeModule('az');
1947
1948 test('parse', function (assert) {
1949 var tests = 'yanvar yan_fevral fev_mart mar_Aprel apr_may may_iyun iyn_iyul iyl_Avqust avq_sentyabr sen_oktyabr okt_noyabr noy_dekabr dek'.split('_'), i;
1950 function equalTest(input, mmm, i) {
1951 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
1952 }
1953 for (i = 0; i < 12; i++) {
1954 tests[i] = tests[i].split(' ');
1955 equalTest(tests[i][0], 'MMM', i);
1956 equalTest(tests[i][1], 'MMM', i);
1957 equalTest(tests[i][0], 'MMMM', i);
1958 equalTest(tests[i][1], 'MMMM', i);
1959 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
1960 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
1961 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
1962 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
1963 }
1964 });
1965
1966 test('format', function (assert) {
1967 var a = [
1968 ['dddd, D MMMM YYYY, HH:mm:ss', 'Bazar, 14 fevral 2010, 15:25:50'],
1969 ['ddd, A h', 'Baz, gündüz 3'],
1970 ['M Mo MM MMMM MMM', '2 2-nci 02 fevral fev'],
1971 ['YYYY YY', '2010 10'],
1972 ['D Do DD', '14 14-üncü 14'],
1973 ['d do dddd ddd dd', '0 0-ıncı Bazar Baz Bz'],
1974 ['DDD DDDo DDDD', '45 45-inci 045'],
1975 ['w wo ww', '7 7-nci 07'],
1976 ['h hh', '3 03'],
1977 ['H HH', '15 15'],
1978 ['m mm', '25 25'],
1979 ['s ss', '50 50'],
1980 ['a A', 'gündüz gündüz'],
1981 ['[ilin] DDDo [günü]', 'ilin 45-inci günü'],
1982 ['LT', '15:25'],
1983 ['LTS', '15:25:50'],
1984 ['L', '14.02.2010'],
1985 ['LL', '14 fevral 2010'],
1986 ['LLL', '14 fevral 2010 15:25'],
1987 ['LLLL', 'Bazar, 14 fevral 2010 15:25'],
1988 ['l', '14.2.2010'],
1989 ['ll', '14 fev 2010'],
1990 ['lll', '14 fev 2010 15:25'],
1991 ['llll', 'Baz, 14 fev 2010 15:25']
1992 ],
1993 DDDo = [
1994 [359, '360-ıncı'],
1995 [199, '200-üncü'],
1996 [149, '150-nci']
1997 ],
1998 dt = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
1999 DDDoDt,
2000 i;
2001
2002 for (i = 0; i < a.length; i++) {
2003 assert.equal(dt.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
2004 }
2005 for (i = 0; i < DDDo.length; i++) {
2006 DDDoDt = moment([2010]);
2007 assert.equal(DDDoDt.add(DDDo[i][0], 'days').format('DDDo'), DDDo[i][1], DDDo[i][0] + ' ---> ' + DDDo[i][1]);
2008 }
2009 });
2010
2011 test('format ordinal', function (assert) {
2012 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-inci', '1st');
2013 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-nci', '2nd');
2014 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-üncü', '3rd');
2015 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-üncü', '4th');
2016 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-inci', '5th');
2017 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ncı', '6th');
2018 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-nci', '7th');
2019 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-inci', '8th');
2020 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-uncu', '9th');
2021 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-uncu', '10th');
2022
2023 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-inci', '11th');
2024 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-nci', '12th');
2025 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-üncü', '13th');
2026 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-üncü', '14th');
2027 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-inci', '15th');
2028 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ncı', '16th');
2029 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-nci', '17th');
2030 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-inci', '18th');
2031 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-uncu', '19th');
2032 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-nci', '20th');
2033
2034 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-inci', '21th');
2035 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-nci', '22th');
2036 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-üncü', '23th');
2037 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-üncü', '24th');
2038 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-inci', '25th');
2039 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ncı', '26th');
2040 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-nci', '27th');
2041 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-inci', '28th');
2042 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-uncu', '29th');
2043 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-uncu', '30th');
2044
2045 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-inci', '31st');
2046 });
2047
2048 test('format month', function (assert) {
2049 var expected = 'yanvar yan_fevral fev_mart mar_aprel apr_may may_iyun iyn_iyul iyl_avqust avq_sentyabr sen_oktyabr okt_noyabr noy_dekabr dek'.split('_'), i;
2050 for (i = 0; i < expected.length; i++) {
2051 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
2052 }
2053 });
2054
2055 test('format week', function (assert) {
2056 var expected = 'Bazar Baz Bz_Bazar ertəsi BzE BE_Çərşənbə axşamı ÇAx ÇA_Çərşənbə Çər Çə_Cümə axşamı CAx CA_Cümə Cüm Cü_Şənbə Şən Şə'.split('_'), i;
2057 for (i = 0; i < expected.length; i++) {
2058 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
2059 }
2060 });
2061
2062 test('from', function (assert) {
2063 var start = moment([2007, 1, 28]);
2064 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'birneçə saniyyə', '44 seconds = a few seconds');
2065 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'bir dəqiqə', '45 seconds = a minute');
2066 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'bir dəqiqə', '89 seconds = a minute');
2067 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 dəqiqə', '90 seconds = 2 minutes');
2068 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 dəqiqə', '44 minutes = 44 minutes');
2069 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'bir saat', '45 minutes = an hour');
2070 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'bir saat', '89 minutes = an hour');
2071 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 saat', '90 minutes = 2 hours');
2072 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 saat', '5 hours = 5 hours');
2073 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 saat', '21 hours = 21 hours');
2074 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'bir gün', '22 hours = a day');
2075 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'bir gün', '35 hours = a day');
2076 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 gün', '36 hours = 2 days');
2077 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'bir gün', '1 day = a day');
2078 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 gün', '5 days = 5 days');
2079 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 gün', '25 days = 25 days');
2080 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'bir ay', '26 days = a month');
2081 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'bir ay', '30 days = a month');
2082 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ay', '46 days = 2 months');
2083 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ay', '75 days = 2 months');
2084 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ay', '76 days = 3 months');
2085 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'bir ay', '1 month = a month');
2086 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ay', '5 months = 5 months');
2087 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'bir il', '345 days = a year');
2088 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 il', '548 days = 2 years');
2089 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'bir il', '1 year = a year');
2090 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 il', '5 years = 5 years');
2091 });
2092
2093 test('suffix', function (assert) {
2094 assert.equal(moment(30000).from(0), 'birneçə saniyyə sonra', 'prefix');
2095 assert.equal(moment(0).from(30000), 'birneçə saniyyə əvvəl', 'suffix');
2096 });
2097
2098 test('now from now', function (assert) {
2099 assert.equal(moment().fromNow(), 'birneçə saniyyə əvvəl', 'now from now should display as in the past');
2100 });
2101
2102 test('fromNow', function (assert) {
2103 assert.equal(moment().add({s: 30}).fromNow(), 'birneçə saniyyə sonra', 'in a few seconds');
2104 assert.equal(moment().add({d: 5}).fromNow(), '5 gün sonra', 'in 5 days');
2105 });
2106
2107 test('calendar day', function (assert) {
2108 var a = moment().hours(2).minutes(0).seconds(0);
2109
2110 assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
2111 assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
2112 assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
2113 assert.equal(moment(a).add({d: 1}).calendar(), 'sabah saat 02:00', 'tomorrow at the same time');
2114 assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
2115 assert.equal(moment(a).subtract({d: 1}).calendar(), 'dünən 02:00', 'yesterday at the same time');
2116 });
2117
2118 test('calendar next week', function (assert) {
2119 var i, m;
2120 for (i = 2; i < 7; i++) {
2121 m = moment().add({d: i});
2122 assert.equal(m.calendar(), m.format('[gələn həftə] dddd [saat] LT'), 'Today + ' + i + ' days current time');
2123 m.hours(0).minutes(0).seconds(0).milliseconds(0);
2124 assert.equal(m.calendar(), m.format('[gələn həftə] dddd [saat] LT'), 'Today + ' + i + ' days beginning of day');
2125 m.hours(23).minutes(59).seconds(59).milliseconds(999);
2126 assert.equal(m.calendar(), m.format('[gələn həftə] dddd [saat] LT'), 'Today + ' + i + ' days end of day');
2127 }
2128 });
2129
2130 test('calendar last week', function (assert) {
2131 var i, m;
2132 for (i = 2; i < 7; i++) {
2133 m = moment().subtract({d: i});
2134 assert.equal(m.calendar(), m.format('[keçən həftə] dddd [saat] LT'), 'Today - ' + i + ' days current time');
2135 m.hours(0).minutes(0).seconds(0).milliseconds(0);
2136 assert.equal(m.calendar(), m.format('[keçən həftə] dddd [saat] LT'), 'Today - ' + i + ' days beginning of day');
2137 m.hours(23).minutes(59).seconds(59).milliseconds(999);
2138 assert.equal(m.calendar(), m.format('[keçən həftə] dddd [saat] LT'), 'Today - ' + i + ' days end of day');
2139 }
2140 });
2141
2142 test('calendar all else', function (assert) {
2143 var weeksAgo = moment().subtract({w: 1}),
2144 weeksFromNow = moment().add({w: 1});
2145
2146 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
2147 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
2148
2149 weeksAgo = moment().subtract({w: 2});
2150 weeksFromNow = moment().add({w: 2});
2151
2152 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
2153 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
2154 });
2155
2156 test('weeks year starting sunday', function (assert) {
2157 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
2158 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
2159 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
2160 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
2161 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
2162 });
2163
2164 test('weeks year starting monday', function (assert) {
2165 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
2166 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
2167 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
2168 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
2169 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
2170 });
2171
2172 test('weeks year starting tuesday', function (assert) {
2173 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
2174 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
2175 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
2176 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
2177 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
2178 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
2179 });
2180
2181 test('weeks year starting wednesday', function (assert) {
2182 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
2183 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
2184 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
2185 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
2186 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
2187 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
2188 });
2189
2190 test('weeks year starting thursday', function (assert) {
2191 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
2192 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
2193 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
2194 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
2195 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
2196 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
2197 });
2198
2199 test('weeks year starting friday', function (assert) {
2200 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
2201 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
2202 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
2203 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
2204 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
2205 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
2206 });
2207
2208 test('weeks year starting saturday', function (assert) {
2209 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
2210 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
2211 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
2212 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
2213 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
2214 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
2215 });
2216
2217 test('weeks year starting sunday formatted', function (assert) {
2218 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-inci', 'Dec 26 2011 should be week 1');
2219 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-inci', 'Jan 1 2012 should be week 1');
2220 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-nci', 'Jan 2 2012 should be week 2');
2221 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-nci', 'Jan 8 2012 should be week 2');
2222 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-üncü', 'Jan 9 2012 should be week 3');
2223 });
2224
2225 test('lenient ordinal parsing', function (assert) {
2226 var i, ordinalStr, testMoment;
2227 for (i = 1; i <= 31; ++i) {
2228 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
2229 testMoment = moment(ordinalStr, 'YYYY MM Do');
2230 assert.equal(testMoment.year(), 2014,
2231 'lenient ordinal parsing ' + i + ' year check');
2232 assert.equal(testMoment.month(), 0,
2233 'lenient ordinal parsing ' + i + ' month check');
2234 assert.equal(testMoment.date(), i,
2235 'lenient ordinal parsing ' + i + ' date check');
2236 }
2237 });
2238
2239 test('lenient ordinal parsing of number', function (assert) {
2240 var i, testMoment;
2241 for (i = 1; i <= 31; ++i) {
2242 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
2243 assert.equal(testMoment.year(), 2014,
2244 'lenient ordinal parsing of number ' + i + ' year check');
2245 assert.equal(testMoment.month(), 0,
2246 'lenient ordinal parsing of number ' + i + ' month check');
2247 assert.equal(testMoment.date(), i,
2248 'lenient ordinal parsing of number ' + i + ' date check');
2249 }
2250 });
2251
2252 test('strict ordinal parsing', function (assert) {
2253 var i, ordinalStr, testMoment;
2254 for (i = 1; i <= 31; ++i) {
2255 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
2256 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
2257 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
2258 }
2259 });
2260
2261 }));
2262
2263 (function (global, factory) {
2264 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
2265 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
2266 factory(global.moment)
2267 }(this, function (moment) { 'use strict';
2268
2269 /*global QUnit:false*/
2270
2271 var test = QUnit.test;
2272
2273 function module (name, lifecycle) {
2274 QUnit.module(name, {
2275 setup : function () {
2276 moment.locale('en');
2277 moment.createFromInputFallback = function () {
2278 throw new Error('input not handled by moment');
2279 };
2280 if (lifecycle && lifecycle.setup) {
2281 lifecycle.setup();
2282 }
2283 },
2284 teardown : function () {
2285 if (lifecycle && lifecycle.teardown) {
2286 lifecycle.teardown();
2287 }
2288 }
2289 });
2290 }
2291
2292 function localeModule (name, lifecycle) {
2293 QUnit.module('locale:' + name, {
2294 setup : function () {
2295 moment.locale(name);
2296 moment.createFromInputFallback = function () {
2297 throw new Error('input not handled by moment');
2298 };
2299 if (lifecycle && lifecycle.setup) {
2300 lifecycle.setup();
2301 }
2302 },
2303 teardown : function () {
2304 moment.locale('en');
2305 if (lifecycle && lifecycle.teardown) {
2306 lifecycle.teardown();
2307 }
2308 }
2309 });
2310 }
2311
2312 localeModule('be');
2313
2314 test('parse', function (assert) {
2315 var tests = 'студзень студ_люты лют_сакавік сак_красавік крас_травень трав_чэрвень чэрв_ліпень ліп_жнівень жнів_верасень вер_кастрычнік каст_лістапад ліст_снежань снеж'.split('_'), i;
2316 function equalTest(input, mmm, i) {
2317 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
2318 }
2319 for (i = 0; i < 12; i++) {
2320 tests[i] = tests[i].split(' ');
2321 equalTest(tests[i][0], 'MMM', i);
2322 equalTest(tests[i][1], 'MMM', i);
2323 equalTest(tests[i][0], 'MMMM', i);
2324 equalTest(tests[i][1], 'MMMM', i);
2325 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
2326 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
2327 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
2328 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
2329 }
2330 });
2331
2332 test('format', function (assert) {
2333 var a = [
2334 ['dddd, Do MMMM YYYY, HH:mm:ss', 'нядзеля, 14-га лютага 2010, 15:25:50'],
2335 ['ddd, h A', 'нд, 3 дня'],
2336 ['M Mo MM MMMM MMM', '2 2-і 02 люты лют'],
2337 ['YYYY YY', '2010 10'],
2338 ['D Do DD', '14 14-га 14'],
2339 ['d do dddd ddd dd', '0 0-ы нядзеля нд нд'],
2340 ['DDD DDDo DDDD', '45 45-ы 045'],
2341 ['w wo ww', '7 7-ы 07'],
2342 ['h hh', '3 03'],
2343 ['H HH', '15 15'],
2344 ['m mm', '25 25'],
2345 ['s ss', '50 50'],
2346 ['a A', 'дня дня'],
2347 ['DDDo [дзень года]', '45-ы дзень года'],
2348 ['LT', '15:25'],
2349 ['LTS', '15:25:50'],
2350 ['L', '14.02.2010'],
2351 ['LL', '14 лютага 2010 г.'],
2352 ['LLL', '14 лютага 2010 г., 15:25'],
2353 ['LLLL', 'нядзеля, 14 лютага 2010 г., 15:25'],
2354 ['l', '14.2.2010'],
2355 ['ll', '14 лют 2010 г.'],
2356 ['lll', '14 лют 2010 г., 15:25'],
2357 ['llll', 'нд, 14 лют 2010 г., 15:25']
2358 ],
2359 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
2360 i;
2361 for (i = 0; i < a.length; i++) {
2362 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
2363 }
2364 });
2365
2366 test('format meridiem', function (assert) {
2367 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'ночы', 'night');
2368 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'ночы', 'night');
2369 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'раніцы', 'morning');
2370 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'раніцы', 'morning');
2371 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'дня', 'afternoon');
2372 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'дня', 'afternoon');
2373 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'вечара', 'evening');
2374 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'вечара', 'evening');
2375 });
2376
2377 test('format ordinal', function (assert) {
2378 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ы', '1-ы');
2379 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-і', '2-і');
2380 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-і', '3-і');
2381 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-ы', '4-ы');
2382 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-ы', '5-ы');
2383 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ы', '6-ы');
2384 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-ы', '7-ы');
2385 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-ы', '8-ы');
2386 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-ы', '9-ы');
2387 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-ы', '10-ы');
2388
2389 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-ы', '11-ы');
2390 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-ы', '12-ы');
2391 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-ы', '13-ы');
2392 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-ы', '14-ы');
2393 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-ы', '15-ы');
2394 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ы', '16-ы');
2395 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-ы', '17-ы');
2396 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-ы', '18-ы');
2397 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-ы', '19-ы');
2398 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-ы', '20-ы');
2399
2400 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ы', '21-ы');
2401 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-і', '22-і');
2402 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-і', '23-і');
2403 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ы', '24-ы');
2404 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ы', '25-ы');
2405 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ы', '26-ы');
2406 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ы', '27-ы');
2407 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ы', '28-ы');
2408 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ы', '29-ы');
2409 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ы', '30-ы');
2410
2411 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-ы', '31-ы');
2412 });
2413
2414 test('format month', function (assert) {
2415 var expected = 'студзень студ_люты лют_сакавік сак_красавік крас_травень трав_чэрвень чэрв_ліпень ліп_жнівень жнів_верасень вер_кастрычнік каст_лістапад ліст_снежань снеж'.split('_'), i;
2416 for (i = 0; i < expected.length; i++) {
2417 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
2418 }
2419 });
2420
2421 test('format month case', function (assert) {
2422 var months = {
2423 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
2424 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
2425 }, i;
2426 for (i = 0; i < 12; i++) {
2427 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
2428 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
2429 }
2430 });
2431
2432 test('format month case with escaped symbols', function (assert) {
2433 var months = {
2434 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
2435 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
2436 }, i;
2437 for (i = 0; i < 12; i++) {
2438 assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
2439 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMMM[</b>]'), '<i>1</i> <b>' + months.accusative[i] + '</b>', '1 <b>' + months.accusative[i] + '</b>');
2440 assert.equal(moment([2013, i, 1]).format('D[-ы дзень] MMMM'), '1-ы дзень ' + months.accusative[i], '1-ы дзень ' + months.accusative[i]);
2441 assert.equal(moment([2013, i, 1]).format('D, MMMM'), '1, ' + months.nominative[i], '1, ' + months.nominative[i]);
2442 }
2443 });
2444
2445 test('format week', function (assert) {
2446 var expected = 'нядзеля нд нд_панядзелак пн пн_аўторак ат ат_серада ср ср_чацвер чц чц_пятніца пт пт_субота сб сб'.split('_'), i;
2447 for (i = 0; i < expected.length; i++) {
2448 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
2449 }
2450 });
2451
2452 test('from', function (assert) {
2453 var start = moment([2007, 1, 28]);
2454 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'некалькі секунд', '44 seconds = a few seconds');
2455 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'хвіліна', '45 seconds = a minute');
2456 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'хвіліна', '89 seconds = a minute');
2457 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 хвіліны', '90 seconds = 2 minutes');
2458 assert.equal(start.from(moment([2007, 1, 28]).add({m: 31}), true), '31 хвіліна', '31 minutes = 31 minutes');
2459 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 хвіліны', '44 minutes = 44 minutes');
2460 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'гадзіна', '45 minutes = an hour');
2461 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'гадзіна', '89 minutes = an hour');
2462 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 гадзіны', '90 minutes = 2 hours');
2463 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 гадзін', '5 hours = 5 hours');
2464 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 гадзіна', '21 hours = 21 hours');
2465 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'дзень', '22 hours = a day');
2466 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'дзень', '35 hours = a day');
2467 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дні', '36 hours = 2 days');
2468 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'дзень', '1 day = a day');
2469 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дзён', '5 days = 5 days');
2470 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 дзён', '11 days = 11 days');
2471 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 дзень', '21 days = 21 days');
2472 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дзён', '25 days = 25 days');
2473 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месяц', '26 days = a month');
2474 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месяц', '30 days = a month');
2475 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месяц', '43 days = a month');
2476 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месяцы', '46 days = 2 months');
2477 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месяцы', '75 days = 2 months');
2478 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месяцы', '76 days = 3 months');
2479 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месяц', '1 month = a month');
2480 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месяцаў', '5 months = 5 months');
2481 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'год', '345 days = a year');
2482 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 гады', '548 days = 2 years');
2483 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'год', '1 year = a year');
2484 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 гадоў', '5 years = 5 years');
2485 });
2486
2487 test('suffix', function (assert) {
2488 assert.equal(moment(30000).from(0), 'праз некалькі секунд', 'prefix');
2489 assert.equal(moment(0).from(30000), 'некалькі секунд таму', 'suffix');
2490 });
2491
2492 test('fromNow', function (assert) {
2493 assert.equal(moment().add({s: 30}).fromNow(), 'праз некалькі секунд', 'in a few seconds');
2494 assert.equal(moment().add({d: 5}).fromNow(), 'праз 5 дзён', 'in 5 days');
2495 assert.equal(moment().add({m: 31}).fromNow(), 'праз 31 хвіліну', 'in 31 minutes = in 31 minutes');
2496 assert.equal(moment().subtract({m: 31}).fromNow(), '31 хвіліну таму', '31 minutes ago = 31 minutes ago');
2497 });
2498
2499 test('calendar day', function (assert) {
2500 var a = moment().hours(2).minutes(0).seconds(0);
2501
2502 assert.equal(moment(a).calendar(), 'Сёння ў 02:00', 'today at the same time');
2503 assert.equal(moment(a).add({m: 25}).calendar(), 'Сёння ў 02:25', 'Now plus 25 min');
2504 assert.equal(moment(a).add({h: 1}).calendar(), 'Сёння ў 03:00', 'Now plus 1 hour');
2505 assert.equal(moment(a).add({d: 1}).calendar(), 'Заўтра ў 02:00', 'tomorrow at the same time');
2506 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сёння ў 01:00', 'Now minus 1 hour');
2507 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Учора ў 02:00', 'yesterday at the same time');
2508 });
2509
2510 test('calendar next week', function (assert) {
2511 var i, m;
2512 function makeFormat(d) {
2513 return '[У] dddd [ў] LT';
2514 }
2515
2516 for (i = 2; i < 7; i++) {
2517 m = moment().add({d: i});
2518 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
2519 m.hours(0).minutes(0).seconds(0).milliseconds(0);
2520 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
2521 m.hours(23).minutes(59).seconds(59).milliseconds(999);
2522 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
2523 }
2524 });
2525
2526 test('calendar last week', function (assert) {
2527 var i, m;
2528
2529 function makeFormat(d) {
2530 switch (d.day()) {
2531 case 0:
2532 case 3:
2533 case 5:
2534 case 6:
2535 return '[У мінулую] dddd [ў] LT';
2536 case 1:
2537 case 2:
2538 case 4:
2539 return '[У мінулы] dddd [ў] LT';
2540 }
2541 }
2542
2543 for (i = 2; i < 7; i++) {
2544 m = moment().subtract({d: i});
2545 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
2546 m.hours(0).minutes(0).seconds(0).milliseconds(0);
2547 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
2548 m.hours(23).minutes(59).seconds(59).milliseconds(999);
2549 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
2550 }
2551 });
2552
2553 test('calendar all else', function (assert) {
2554 var weeksAgo = moment().subtract({w: 1}),
2555 weeksFromNow = moment().add({w: 1});
2556
2557 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
2558 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
2559
2560 weeksAgo = moment().subtract({w: 2});
2561 weeksFromNow = moment().add({w: 2});
2562
2563 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
2564 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
2565 });
2566
2567 test('weeks year starting sunday', function (assert) {
2568 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
2569 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
2570 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
2571 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
2572 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
2573 });
2574
2575 test('weeks year starting monday', function (assert) {
2576 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
2577 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
2578 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
2579 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
2580 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
2581 });
2582
2583 test('weeks year starting tuesday', function (assert) {
2584 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
2585 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
2586 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
2587 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
2588 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
2589 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
2590 });
2591
2592 test('weeks year starting wednesday', function (assert) {
2593 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
2594 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
2595 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
2596 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
2597 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
2598 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
2599 });
2600
2601 test('weeks year starting thursday', function (assert) {
2602 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
2603 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
2604 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
2605 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
2606 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
2607 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
2608 });
2609
2610 test('weeks year starting friday', function (assert) {
2611 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
2612 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
2613 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
2614 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
2615 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
2616 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
2617 });
2618
2619 test('weeks year starting saturday', function (assert) {
2620 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
2621 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
2622 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
2623 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
2624 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
2625 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
2626 });
2627
2628 test('weeks year starting sunday formatted', function (assert) {
2629 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ы', 'Dec 26 2011 should be week 1');
2630 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ы', 'Jan 1 2012 should be week 1');
2631 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-і', 'Jan 2 2012 should be week 2');
2632 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-і', 'Jan 8 2012 should be week 2');
2633 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-і', 'Jan 9 2012 should be week 3');
2634 });
2635
2636 test('lenient ordinal parsing', function (assert) {
2637 var i, ordinalStr, testMoment;
2638 for (i = 1; i <= 31; ++i) {
2639 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
2640 testMoment = moment(ordinalStr, 'YYYY MM Do');
2641 assert.equal(testMoment.year(), 2014,
2642 'lenient ordinal parsing ' + i + ' year check');
2643 assert.equal(testMoment.month(), 0,
2644 'lenient ordinal parsing ' + i + ' month check');
2645 assert.equal(testMoment.date(), i,
2646 'lenient ordinal parsing ' + i + ' date check');
2647 }
2648 });
2649
2650 test('lenient ordinal parsing of number', function (assert) {
2651 var i, testMoment;
2652 for (i = 1; i <= 31; ++i) {
2653 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
2654 assert.equal(testMoment.year(), 2014,
2655 'lenient ordinal parsing of number ' + i + ' year check');
2656 assert.equal(testMoment.month(), 0,
2657 'lenient ordinal parsing of number ' + i + ' month check');
2658 assert.equal(testMoment.date(), i,
2659 'lenient ordinal parsing of number ' + i + ' date check');
2660 }
2661 });
2662
2663 test('strict ordinal parsing', function (assert) {
2664 var i, ordinalStr, testMoment;
2665 for (i = 1; i <= 31; ++i) {
2666 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
2667 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
2668 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
2669 }
2670 });
2671
2672 }));
2673
2674 (function (global, factory) {
2675 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
2676 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
2677 factory(global.moment)
2678 }(this, function (moment) { 'use strict';
2679
2680 /*global QUnit:false*/
2681
2682 var test = QUnit.test;
2683
2684 function module (name, lifecycle) {
2685 QUnit.module(name, {
2686 setup : function () {
2687 moment.locale('en');
2688 moment.createFromInputFallback = function () {
2689 throw new Error('input not handled by moment');
2690 };
2691 if (lifecycle && lifecycle.setup) {
2692 lifecycle.setup();
2693 }
2694 },
2695 teardown : function () {
2696 if (lifecycle && lifecycle.teardown) {
2697 lifecycle.teardown();
2698 }
2699 }
2700 });
2701 }
2702
2703 function localeModule (name, lifecycle) {
2704 QUnit.module('locale:' + name, {
2705 setup : function () {
2706 moment.locale(name);
2707 moment.createFromInputFallback = function () {
2708 throw new Error('input not handled by moment');
2709 };
2710 if (lifecycle && lifecycle.setup) {
2711 lifecycle.setup();
2712 }
2713 },
2714 teardown : function () {
2715 moment.locale('en');
2716 if (lifecycle && lifecycle.teardown) {
2717 lifecycle.teardown();
2718 }
2719 }
2720 });
2721 }
2722
2723 localeModule('bg');
2724
2725 test('parse', function (assert) {
2726 var tests = 'януари янр_февруари фев_март мар_април апр_май май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
2727 function equalTest(input, mmm, i) {
2728 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
2729 }
2730 for (i = 0; i < 12; i++) {
2731 tests[i] = tests[i].split(' ');
2732 equalTest(tests[i][0], 'MMM', i);
2733 equalTest(tests[i][1], 'MMM', i);
2734 equalTest(tests[i][0], 'MMMM', i);
2735 equalTest(tests[i][1], 'MMMM', i);
2736 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
2737 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
2738 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
2739 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
2740 }
2741 });
2742
2743 test('format', function (assert) {
2744 var a = [
2745 ['dddd, MMMM Do YYYY, H:mm:ss', 'неделя, февруари 14-ти 2010, 15:25:50'],
2746 ['ddd, hA', 'нед, 3PM'],
2747 ['M Mo MM MMMM MMM', '2 2-ри 02 февруари фев'],
2748 ['YYYY YY', '2010 10'],
2749 ['D Do DD', '14 14-ти 14'],
2750 ['d do dddd ddd dd', '0 0-ев неделя нед нд'],
2751 ['DDD DDDo DDDD', '45 45-ти 045'],
2752 ['w wo ww', '7 7-ми 07'],
2753 ['h hh', '3 03'],
2754 ['H HH', '15 15'],
2755 ['m mm', '25 25'],
2756 ['s ss', '50 50'],
2757 ['a A', 'pm PM'],
2758 ['[the] DDDo [day of the year]', 'the 45-ти day of the year'],
2759 ['LT', '15:25'],
2760 ['LTS', '15:25:50'],
2761 ['L', '14.02.2010'],
2762 ['LL', '14 февруари 2010'],
2763 ['LLL', '14 февруари 2010 15:25'],
2764 ['LLLL', 'неделя, 14 февруари 2010 15:25'],
2765 ['l', '14.2.2010'],
2766 ['ll', '14 фев 2010'],
2767 ['lll', '14 фев 2010 15:25'],
2768 ['llll', 'нед, 14 фев 2010 15:25']
2769 ],
2770 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
2771 i;
2772 for (i = 0; i < a.length; i++) {
2773 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
2774 }
2775 });
2776
2777 test('format ordinal', function (assert) {
2778 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ви', '1-ви');
2779 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-ри', '2-ри');
2780 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-ти', '3-ти');
2781 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-ти', '4-ти');
2782 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-ти', '5-ти');
2783 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ти', '6-ти');
2784 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-ми', '7-ми');
2785 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-ми', '8-ми');
2786 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-ти', '9-ти');
2787 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-ти', '10-ти');
2788
2789 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-ти', '11-ти');
2790 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-ти', '12-ти');
2791 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-ти', '13-ти');
2792 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-ти', '14-ти');
2793 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-ти', '15-ти');
2794 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ти', '16-ти');
2795 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-ти', '17-ти');
2796 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-ти', '18-ти');
2797 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-ти', '19-ти');
2798 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-ти', '20-ти');
2799
2800 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ви', '21-ви');
2801 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-ри', '22-ри');
2802 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-ти', '23-ти');
2803 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ти', '24-ти');
2804 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ти', '25-ти');
2805 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ти', '26-ти');
2806 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ми', '27-ми');
2807 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ми', '28-ми');
2808 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ти', '29-ти');
2809 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ти', '30-ти');
2810
2811 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-ви', '31-ви');
2812 });
2813
2814 test('format month', function (assert) {
2815 var expected = 'януари янр_февруари фев_март мар_април апр_май май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
2816 for (i = 0; i < expected.length; i++) {
2817 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
2818 }
2819 });
2820
2821 test('format week', function (assert) {
2822 var expected = 'неделя нед нд_понеделник пон пн_вторник вто вт_сряда сря ср_четвъртък чет чт_петък пет пт_събота съб сб'.split('_'), i;
2823 for (i = 0; i < expected.length; i++) {
2824 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
2825 }
2826 });
2827
2828 test('from', function (assert) {
2829 var start = moment([2007, 1, 28]);
2830 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'няколко секунди', '44 seconds = a few seconds');
2831 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'минута', '45 seconds = a minute');
2832 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'минута', '89 seconds = a minute');
2833 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минути', '90 seconds = 2 minutes');
2834 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минути', '44 minutes = 44 minutes');
2835 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'час', '45 minutes = an hour');
2836 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'час', '89 minutes = an hour');
2837 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 часа', '90 minutes = 2 hours');
2838 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 часа', '5 hours = 5 hours');
2839 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 часа', '21 hours = 21 hours');
2840 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ден', '22 hours = a day');
2841 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ден', '35 hours = a day');
2842 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дни', '36 hours = 2 days');
2843 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ден', '1 day = a day');
2844 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дни', '5 days = 5 days');
2845 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дни', '25 days = 25 days');
2846 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месец', '26 days = a month');
2847 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месец', '30 days = a month');
2848 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месец', '43 days = a month');
2849 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месеца', '46 days = 2 months');
2850 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месеца', '75 days = 2 months');
2851 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месеца', '76 days = 3 months');
2852 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месец', '1 month = a month');
2853 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месеца', '5 months = 5 months');
2854 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'година', '345 days = a year');
2855 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 години', '548 days = 2 years');
2856 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'година', '1 year = a year');
2857 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 години', '5 years = 5 years');
2858 });
2859
2860 test('suffix', function (assert) {
2861 assert.equal(moment(30000).from(0), 'след няколко секунди', 'prefix');
2862 assert.equal(moment(0).from(30000), 'преди няколко секунди', 'suffix');
2863 });
2864
2865 test('now from now', function (assert) {
2866 assert.equal(moment().fromNow(), 'преди няколко секунди', 'now from now should display as in the past');
2867 });
2868
2869 test('fromNow', function (assert) {
2870 assert.equal(moment().add({s: 30}).fromNow(), 'след няколко секунди', 'in a few seconds');
2871 assert.equal(moment().add({d: 5}).fromNow(), 'след 5 дни', 'in 5 days');
2872 });
2873
2874 test('calendar day', function (assert) {
2875 var a = moment().hours(2).minutes(0).seconds(0);
2876
2877 assert.equal(moment(a).calendar(), 'Днес в 2:00', 'today at the same time');
2878 assert.equal(moment(a).add({m: 25}).calendar(), 'Днес в 2:25', 'Now plus 25 min');
2879 assert.equal(moment(a).add({h: 1}).calendar(), 'Днес в 3:00', 'Now plus 1 hour');
2880 assert.equal(moment(a).add({d: 1}).calendar(), 'Утре в 2:00', 'tomorrow at the same time');
2881 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Днес в 1:00', 'Now minus 1 hour');
2882 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 2:00', 'yesterday at the same time');
2883 });
2884
2885 test('calendar next week', function (assert) {
2886 var i, m;
2887 for (i = 2; i < 7; i++) {
2888 m = moment().add({d: i});
2889 assert.equal(m.calendar(), m.format('dddd [в] LT'), 'Today + ' + i + ' days current time');
2890 m.hours(0).minutes(0).seconds(0).milliseconds(0);
2891 assert.equal(m.calendar(), m.format('dddd [в] LT'), 'Today + ' + i + ' days beginning of day');
2892 m.hours(23).minutes(59).seconds(59).milliseconds(999);
2893 assert.equal(m.calendar(), m.format('dddd [в] LT'), 'Today + ' + i + ' days end of day');
2894 }
2895 });
2896
2897 test('calendar last week', function (assert) {
2898 var i, m;
2899
2900 function makeFormat(d) {
2901 switch (d.day()) {
2902 case 0:
2903 case 3:
2904 case 6:
2905 return '[В изминалата] dddd [в] LT';
2906 case 1:
2907 case 2:
2908 case 4:
2909 case 5:
2910 return '[В изминалия] dddd [в] LT';
2911 }
2912 }
2913
2914 for (i = 2; i < 7; i++) {
2915 m = moment().subtract({d: i});
2916 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
2917 m.hours(0).minutes(0).seconds(0).milliseconds(0);
2918 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
2919 m.hours(23).minutes(59).seconds(59).milliseconds(999);
2920 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
2921 }
2922 });
2923
2924 test('calendar all else', function (assert) {
2925 var weeksAgo = moment().subtract({w: 1}),
2926 weeksFromNow = moment().add({w: 1});
2927
2928 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
2929 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
2930
2931 weeksAgo = moment().subtract({w: 2});
2932 weeksFromNow = moment().add({w: 2});
2933
2934 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
2935 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
2936 });
2937
2938 test('weeks year starting sunday', function (assert) {
2939 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
2940 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
2941 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
2942 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
2943 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
2944 });
2945
2946 test('weeks year starting monday', function (assert) {
2947 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
2948 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
2949 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
2950 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
2951 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
2952 });
2953
2954 test('weeks year starting tuesday', function (assert) {
2955 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
2956 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
2957 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
2958 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
2959 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
2960 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
2961 });
2962
2963 test('weeks year starting wednesday', function (assert) {
2964 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
2965 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
2966 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
2967 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
2968 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
2969 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
2970 });
2971
2972 test('weeks year starting thursday', function (assert) {
2973 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
2974 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
2975 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
2976 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
2977 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
2978 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
2979 });
2980
2981 test('weeks year starting friday', function (assert) {
2982 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
2983 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
2984 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
2985 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
2986 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
2987 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
2988 });
2989
2990 test('weeks year starting saturday', function (assert) {
2991 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
2992 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
2993 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
2994 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
2995 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
2996 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
2997 });
2998
2999 test('weeks year starting sunday formatted', function (assert) {
3000 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
3001 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
3002 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-ри', 'Jan 2 2012 should be week 2');
3003 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-ри', 'Jan 8 2012 should be week 2');
3004 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
3005 });
3006
3007 test('lenient ordinal parsing', function (assert) {
3008 var i, ordinalStr, testMoment;
3009 for (i = 1; i <= 31; ++i) {
3010 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
3011 testMoment = moment(ordinalStr, 'YYYY MM Do');
3012 assert.equal(testMoment.year(), 2014,
3013 'lenient ordinal parsing ' + i + ' year check');
3014 assert.equal(testMoment.month(), 0,
3015 'lenient ordinal parsing ' + i + ' month check');
3016 assert.equal(testMoment.date(), i,
3017 'lenient ordinal parsing ' + i + ' date check');
3018 }
3019 });
3020
3021 test('lenient ordinal parsing of number', function (assert) {
3022 var i, testMoment;
3023 for (i = 1; i <= 31; ++i) {
3024 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
3025 assert.equal(testMoment.year(), 2014,
3026 'lenient ordinal parsing of number ' + i + ' year check');
3027 assert.equal(testMoment.month(), 0,
3028 'lenient ordinal parsing of number ' + i + ' month check');
3029 assert.equal(testMoment.date(), i,
3030 'lenient ordinal parsing of number ' + i + ' date check');
3031 }
3032 });
3033
3034 test('strict ordinal parsing', function (assert) {
3035 var i, ordinalStr, testMoment;
3036 for (i = 1; i <= 31; ++i) {
3037 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
3038 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
3039 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
3040 }
3041 });
3042
3043 }));
3044
3045 (function (global, factory) {
3046 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
3047 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
3048 factory(global.moment)
3049 }(this, function (moment) { 'use strict';
3050
3051 /*global QUnit:false*/
3052
3053 var test = QUnit.test;
3054
3055 function module (name, lifecycle) {
3056 QUnit.module(name, {
3057 setup : function () {
3058 moment.locale('en');
3059 moment.createFromInputFallback = function () {
3060 throw new Error('input not handled by moment');
3061 };
3062 if (lifecycle && lifecycle.setup) {
3063 lifecycle.setup();
3064 }
3065 },
3066 teardown : function () {
3067 if (lifecycle && lifecycle.teardown) {
3068 lifecycle.teardown();
3069 }
3070 }
3071 });
3072 }
3073
3074 function localeModule (name, lifecycle) {
3075 QUnit.module('locale:' + name, {
3076 setup : function () {
3077 moment.locale(name);
3078 moment.createFromInputFallback = function () {
3079 throw new Error('input not handled by moment');
3080 };
3081 if (lifecycle && lifecycle.setup) {
3082 lifecycle.setup();
3083 }
3084 },
3085 teardown : function () {
3086 moment.locale('en');
3087 if (lifecycle && lifecycle.teardown) {
3088 lifecycle.teardown();
3089 }
3090 }
3091 });
3092 }
3093
3094 localeModule('bn');
3095
3096 test('parse', function (assert) {
3097 var tests = 'জানুয়ারী জানু_ফেবুয়ারী ফেব_মার্চ মার্চ_এপ্রিল এপর_মে মে_জুন জুন_জুলাই জুল_অগাস্ট অগ_সেপ্টেম্বর সেপ্ট_অক্টোবর অক্টো_নভেম্বর নভ_ডিসেম্বর ডিসেম্'.split('_'), i;
3098 function equalTest(input, mmm, i) {
3099 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
3100 }
3101 for (i = 0; i < 12; i++) {
3102 tests[i] = tests[i].split(' ');
3103 equalTest(tests[i][0], 'MMM', i);
3104 equalTest(tests[i][1], 'MMM', i);
3105 equalTest(tests[i][0], 'MMMM', i);
3106 equalTest(tests[i][1], 'MMMM', i);
3107 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
3108 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
3109 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
3110 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
3111 }
3112 });
3113
3114 test('format', function (assert) {
3115 var a = [
3116 ['dddd, Do MMMM YYYY, a h:mm:ss সময়', 'রবিবার, ১৪ ফেবুয়ারী ২০১০, দুপুর ৩:২৫:৫০ সময়'],
3117 ['ddd, a h সময়', 'রবি, দুপুর ৩ সময়'],
3118 ['M Mo MM MMMM MMM', '২ ২ ০২ ফেবুয়ারী ফেব'],
3119 ['YYYY YY', '২০১০ ১০'],
3120 ['D Do DD', '১৪ ১৪ ১৪'],
3121 ['d do dddd ddd dd', '০ ০ রবিবার রবি রব'],
3122 ['DDD DDDo DDDD', '৪৫ ৪৫ ০৪৫'],
3123 ['w wo ww', '৮ ৮ ০৮'],
3124 ['h hh', '৩ ০৩'],
3125 ['H HH', '১৫ ১৫'],
3126 ['m mm', '২৫ ২৫'],
3127 ['s ss', '৫০ ৫০'],
3128 ['a A', 'দুপুর দুপুর'],
3129 ['LT', 'দুপুর ৩:২৫ সময়'],
3130 ['LTS', 'দুপুর ৩:২৫:৫০ সময়'],
3131 ['L', '১৪/০২/২০১০'],
3132 ['LL', '১৪ ফেবুয়ারী ২০১০'],
3133 ['LLL', '১৪ ফেবুয়ারী ২০১০, দুপুর ৩:২৫ সময়'],
3134 ['LLLL', 'রবিবার, ১৪ ফেবুয়ারী ২০১০, দুপুর ৩:২৫ সময়'],
3135 ['l', '১৪/২/২০১০'],
3136 ['ll', '১৪ ফেব ২০১০'],
3137 ['lll', '১৪ ফেব ২০১০, দুপুর ৩:২৫ সময়'],
3138 ['llll', 'রবি, ১৪ ফেব ২০১০, দুপুর ৩:২৫ সময়']
3139 ],
3140 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
3141 i;
3142 for (i = 0; i < a.length; i++) {
3143 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
3144 }
3145 });
3146
3147 test('format ordinal', function (assert) {
3148 assert.equal(moment([2011, 0, 1]).format('DDDo'), '১', '১');
3149 assert.equal(moment([2011, 0, 2]).format('DDDo'), '২', '২');
3150 assert.equal(moment([2011, 0, 3]).format('DDDo'), '৩', '৩');
3151 assert.equal(moment([2011, 0, 4]).format('DDDo'), '৪', '৪');
3152 assert.equal(moment([2011, 0, 5]).format('DDDo'), '৫', '৫');
3153 assert.equal(moment([2011, 0, 6]).format('DDDo'), '৬', '৬');
3154 assert.equal(moment([2011, 0, 7]).format('DDDo'), '৭', '৭');
3155 assert.equal(moment([2011, 0, 8]).format('DDDo'), '৮', '৮');
3156 assert.equal(moment([2011, 0, 9]).format('DDDo'), '৯', '৯');
3157 assert.equal(moment([2011, 0, 10]).format('DDDo'), '১০', '১০');
3158
3159 assert.equal(moment([2011, 0, 11]).format('DDDo'), '১১', '১১');
3160 assert.equal(moment([2011, 0, 12]).format('DDDo'), '১২', '১২');
3161 assert.equal(moment([2011, 0, 13]).format('DDDo'), '১৩', '১৩');
3162 assert.equal(moment([2011, 0, 14]).format('DDDo'), '১৪', '১৪');
3163 assert.equal(moment([2011, 0, 15]).format('DDDo'), '১৫', '১৫');
3164 assert.equal(moment([2011, 0, 16]).format('DDDo'), '১৬', '১৬');
3165 assert.equal(moment([2011, 0, 17]).format('DDDo'), '১৭', '১৭');
3166 assert.equal(moment([2011, 0, 18]).format('DDDo'), '১৮', '১৮');
3167 assert.equal(moment([2011, 0, 19]).format('DDDo'), '১৯', '১৯');
3168 assert.equal(moment([2011, 0, 20]).format('DDDo'), '২০', '২০');
3169
3170 assert.equal(moment([2011, 0, 21]).format('DDDo'), '২১', '২১');
3171 assert.equal(moment([2011, 0, 22]).format('DDDo'), '২২', '২২');
3172 assert.equal(moment([2011, 0, 23]).format('DDDo'), '২৩', '২৩');
3173 assert.equal(moment([2011, 0, 24]).format('DDDo'), '২৪', '২৪');
3174 assert.equal(moment([2011, 0, 25]).format('DDDo'), '২৫', '২৫');
3175 assert.equal(moment([2011, 0, 26]).format('DDDo'), '২৬', '২৬');
3176 assert.equal(moment([2011, 0, 27]).format('DDDo'), '২৭', '২৭');
3177 assert.equal(moment([2011, 0, 28]).format('DDDo'), '২৮', '२৮');
3178 assert.equal(moment([2011, 0, 29]).format('DDDo'), '২৯', '২৯');
3179 assert.equal(moment([2011, 0, 30]).format('DDDo'), '৩০', '৩০');
3180
3181 assert.equal(moment([2011, 0, 31]).format('DDDo'), '৩১', '৩১');
3182 });
3183
3184 test('format month', function (assert) {
3185 var expected = 'জানুয়ারী জানু_ফেবুয়ারী ফেব_মার্চ মার্চ_এপ্রিল এপর_মে মে_জুন জুন_জুলাই জুল_অগাস্ট অগ_সেপ্টেম্বর সেপ্ট_অক্টোবর অক্টো_নভেম্বর নভ_ডিসেম্বর ডিসেম্'.split('_'), i;
3186 for (i = 0; i < expected.length; i++) {
3187 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
3188 }
3189 });
3190
3191 test('format week', function (assert) {
3192 var expected = 'রবিবার রবি রব_সোমবার সোম সম_মঙ্গলবার মঙ্গল মঙ্গ_বুধবার বুধ বু_বৃহস্পত্তিবার বৃহস্পত্তি ব্রিহ_শুক্রুবার শুক্রু শু_শনিবার শনি শনি'.split('_'), i;
3193 for (i = 0; i < expected.length; i++) {
3194 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
3195 }
3196 });
3197
3198 test('from', function (assert) {
3199 var start = moment([2007, 1, 28]);
3200 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'কএক সেকেন্ড', '44 seconds = a few seconds');
3201 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'এক মিনিট', '45 seconds = a minute');
3202 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'এক মিনিট', '89 seconds = a minute');
3203 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '২ মিনিট', '90 seconds = 2 minutes');
3204 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '৪৪ মিনিট', '44 minutes = 44 minutes');
3205 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'এক ঘন্টা', '45 minutes = an hour');
3206 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'এক ঘন্টা', '89 minutes = an hour');
3207 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '২ ঘন্টা', '90 minutes = 2 hours');
3208 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '৫ ঘন্টা', '5 hours = 5 hours');
3209 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '২১ ঘন্টা', '21 hours = 21 hours');
3210 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'এক দিন', '22 hours = a day');
3211 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'এক দিন', '35 hours = a day');
3212 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '২ দিন', '36 hours = 2 days');
3213 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'এক দিন', '1 day = a day');
3214 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '৫ দিন', '5 days = 5 days');
3215 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '২৫ দিন', '25 days = 25 days');
3216 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'এক মাস', '26 days = a month');
3217 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'এক মাস', '30 days = a month');
3218 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '২ মাস', '46 days = 2 months');
3219 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '২ মাস', '75 days = 2 months');
3220 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '৩ মাস', '76 days = 3 months');
3221 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'এক মাস', '1 month = a month');
3222 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '৫ মাস', '5 months = 5 months');
3223 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'এক বছর', '345 days = a year');
3224 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '২ বছর', '548 days = 2 years');
3225 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'এক বছর', '1 year = a year');
3226 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '৫ বছর', '5 years = 5 years');
3227 });
3228
3229 test('suffix', function (assert) {
3230 assert.equal(moment(30000).from(0), 'কএক সেকেন্ড পরে', 'prefix');
3231 assert.equal(moment(0).from(30000), 'কএক সেকেন্ড আগে', 'suffix');
3232 });
3233
3234 test('now from now', function (assert) {
3235 assert.equal(moment().fromNow(), 'কএক সেকেন্ড আগে', 'now from now should display as in the past');
3236 });
3237
3238 test('fromNow', function (assert) {
3239 assert.equal(moment().add({s: 30}).fromNow(), 'কএক সেকেন্ড পরে', 'কএক সেকেন্ড পরে');
3240 assert.equal(moment().add({d: 5}).fromNow(), '৫ দিন পরে', '৫ দিন পরে');
3241 });
3242
3243 test('calendar day', function (assert) {
3244 var a = moment().hours(2).minutes(0).seconds(0);
3245
3246 assert.equal(moment(a).calendar(), 'আজ রাত ২:০০ সময়', 'today at the same time');
3247 assert.equal(moment(a).add({m: 25}).calendar(), 'আজ রাত ২:২৫ সময়', 'Now plus 25 min');
3248 assert.equal(moment(a).add({h: 3}).calendar(), 'আজ সকাল ৫:০০ সময়', 'Now plus 3 hour');
3249 assert.equal(moment(a).add({d: 1}).calendar(), 'আগামীকাল রাত ২:০০ সময়', 'tomorrow at the same time');
3250 assert.equal(moment(a).subtract({h: 1}).calendar(), 'আজ রাত ১:০০ সময়', 'Now minus 1 hour');
3251 assert.equal(moment(a).subtract({d: 1}).calendar(), 'গতকাল রাত ২:০০ সময়', 'yesterday at the same time');
3252 });
3253
3254 test('calendar next week', function (assert) {
3255 var i, m;
3256 for (i = 2; i < 7; i++) {
3257 m = moment().add({d: i});
3258 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
3259 m.hours(0).minutes(0).seconds(0).milliseconds(0);
3260 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
3261 m.hours(23).minutes(59).seconds(59).milliseconds(999);
3262 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
3263 }
3264 });
3265
3266 test('calendar last week', function (assert) {
3267 var i, m;
3268
3269 for (i = 2; i < 7; i++) {
3270 m = moment().subtract({d: i});
3271 assert.equal(m.calendar(), m.format('[গত] dddd[,] LT'), 'Today - ' + i + ' days current time');
3272 m.hours(0).minutes(0).seconds(0).milliseconds(0);
3273 assert.equal(m.calendar(), m.format('[গত] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
3274 m.hours(23).minutes(59).seconds(59).milliseconds(999);
3275 assert.equal(m.calendar(), m.format('[গত] dddd[,] LT'), 'Today - ' + i + ' days end of day');
3276 }
3277 });
3278
3279 test('calendar all else', function (assert) {
3280 var weeksAgo = moment().subtract({w: 1}),
3281 weeksFromNow = moment().add({w: 1});
3282
3283 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
3284 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
3285
3286 weeksAgo = moment().subtract({w: 2});
3287 weeksFromNow = moment().add({w: 2});
3288
3289 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
3290 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
3291 });
3292
3293 test('meridiem', function (assert) {
3294 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'রাত', 'before dawn');
3295 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'সকাল', 'morning');
3296 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'দুপুর', 'during day');
3297 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'বিকেল', 'evening');
3298 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'বিকেল', 'late evening');
3299 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'রাত', 'night');
3300
3301 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'রাত', 'before dawn');
3302 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'সকাল', 'morning');
3303 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'দুপুর', ' during day');
3304 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'বিকেল', 'evening');
3305 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'বিকেল', 'late evening');
3306 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'রাত', 'night');
3307 });
3308
3309 test('weeks year starting sunday', function (assert) {
3310 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
3311 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
3312 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
3313 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
3314 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
3315 });
3316
3317 test('weeks year starting monday', function (assert) {
3318 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
3319 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
3320 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
3321 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
3322 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
3323 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
3324 });
3325
3326 test('weeks year starting tuesday', function (assert) {
3327 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
3328 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
3329 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
3330 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
3331 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
3332 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
3333 });
3334
3335 test('weeks year starting wednesday', function (assert) {
3336 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
3337 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
3338 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
3339 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
3340 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
3341 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
3342 });
3343
3344 test('weeks year starting thursday', function (assert) {
3345 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
3346 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
3347 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
3348 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
3349 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
3350 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
3351 });
3352
3353 test('weeks year starting friday', function (assert) {
3354 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
3355 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
3356 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
3357 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
3358 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
3359 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
3360 });
3361
3362 test('weeks year starting saturday', function (assert) {
3363 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
3364 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
3365 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
3366 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
3367 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
3368 });
3369
3370 test('weeks year starting sunday formatted', function (assert) {
3371 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '১ ০১ ১', 'Jan 1 2012 should be week 1');
3372 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '১ ০১ ১', 'Jan 7 2012 should be week 1');
3373 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '২ ০২ ২', 'Jan 8 2012 should be week 2');
3374 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '২ ০২ ২', 'Jan 14 2012 should be week 2');
3375 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '৩ ০৩ ৩', 'Jan 15 2012 should be week 3');
3376 });
3377
3378 test('lenient ordinal parsing', function (assert) {
3379 var i, ordinalStr, testMoment;
3380 for (i = 1; i <= 31; ++i) {
3381 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
3382 testMoment = moment(ordinalStr, 'YYYY MM Do');
3383 assert.equal(testMoment.year(), 2014,
3384 'lenient ordinal parsing ' + i + ' year check');
3385 assert.equal(testMoment.month(), 0,
3386 'lenient ordinal parsing ' + i + ' month check');
3387 assert.equal(testMoment.date(), i,
3388 'lenient ordinal parsing ' + i + ' date check');
3389 }
3390 });
3391
3392 test('lenient ordinal parsing of number', function (assert) {
3393 var i, testMoment;
3394 for (i = 1; i <= 31; ++i) {
3395 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
3396 assert.equal(testMoment.year(), 2014,
3397 'lenient ordinal parsing of number ' + i + ' year check');
3398 assert.equal(testMoment.month(), 0,
3399 'lenient ordinal parsing of number ' + i + ' month check');
3400 assert.equal(testMoment.date(), i,
3401 'lenient ordinal parsing of number ' + i + ' date check');
3402 }
3403 });
3404
3405 test('strict ordinal parsing', function (assert) {
3406 var i, ordinalStr, testMoment;
3407 for (i = 1; i <= 31; ++i) {
3408 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
3409 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
3410 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
3411 }
3412 });
3413
3414 }));
3415
3416 (function (global, factory) {
3417 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
3418 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
3419 factory(global.moment)
3420 }(this, function (moment) { 'use strict';
3421
3422 /*global QUnit:false*/
3423
3424 var test = QUnit.test;
3425
3426 function module (name, lifecycle) {
3427 QUnit.module(name, {
3428 setup : function () {
3429 moment.locale('en');
3430 moment.createFromInputFallback = function () {
3431 throw new Error('input not handled by moment');
3432 };
3433 if (lifecycle && lifecycle.setup) {
3434 lifecycle.setup();
3435 }
3436 },
3437 teardown : function () {
3438 if (lifecycle && lifecycle.teardown) {
3439 lifecycle.teardown();
3440 }
3441 }
3442 });
3443 }
3444
3445 function localeModule (name, lifecycle) {
3446 QUnit.module('locale:' + name, {
3447 setup : function () {
3448 moment.locale(name);
3449 moment.createFromInputFallback = function () {
3450 throw new Error('input not handled by moment');
3451 };
3452 if (lifecycle && lifecycle.setup) {
3453 lifecycle.setup();
3454 }
3455 },
3456 teardown : function () {
3457 moment.locale('en');
3458 if (lifecycle && lifecycle.teardown) {
3459 lifecycle.teardown();
3460 }
3461 }
3462 });
3463 }
3464
3465 localeModule('bo');
3466
3467 test('parse', function (assert) {
3468 var tests = 'ཟླ་བ་དང་པོ ཟླ་བ་དང་པོ._ཟླ་བ་གཉིས་པ ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ ཟླ་བ་བཅུ་གཉིས་པ'.split('_'), i;
3469 function equalTest(input, mmm, i) {
3470 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
3471 }
3472 for (i = 0; i < 12; i++) {
3473 tests[i] = tests[i].split(' ');
3474 equalTest(tests[i][0], 'MMM', i);
3475 equalTest(tests[i][1], 'MMM', i);
3476 equalTest(tests[i][0], 'MMMM', i);
3477 equalTest(tests[i][1], 'MMMM', i);
3478 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
3479 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
3480 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
3481 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
3482 }
3483 });
3484
3485 test('format', function (assert) {
3486 var a = [
3487 ['dddd, Do MMMM YYYY, a h:mm:ss ལ་', 'གཟའ་ཉི་མ་, ༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥:༥༠ ལ་'],
3488 ['ddd, a h ལ་', 'ཉི་མ་, ཉིན་གུང ༣ ལ་'],
3489 ['M Mo MM MMMM MMM', '༢ ༢ ༠༢ ཟླ་བ་གཉིས་པ ཟླ་བ་གཉིས་པ'],
3490 ['YYYY YY', '༢༠༡༠ ༡༠'],
3491 ['D Do DD', '༡༤ ༡༤ ༡༤'],
3492 ['d do dddd ddd dd', '༠ ༠ གཟའ་ཉི་མ་ ཉི་མ་ ཉི་མ་'],
3493 ['DDD DDDo DDDD', '༤༥ ༤༥ ༠༤༥'],
3494 ['w wo ww', '༨ ༨ ༠༨'],
3495 ['h hh', '༣ ༠༣'],
3496 ['H HH', '༡༥ ༡༥'],
3497 ['m mm', '༢༥ ༢༥'],
3498 ['s ss', '༥༠ ༥༠'],
3499 ['a A', 'ཉིན་གུང ཉིན་གུང'],
3500 ['LT', 'ཉིན་གུང ༣:༢༥'],
3501 ['LTS', 'ཉིན་གུང ༣:༢༥:༥༠'],
3502 ['L', '༡༤/༠༢/༢༠༡༠'],
3503 ['LL', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠'],
3504 ['LLL', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥'],
3505 ['LLLL', 'གཟའ་ཉི་མ་, ༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥'],
3506 ['l', '༡༤/༢/༢༠༡༠'],
3507 ['ll', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠'],
3508 ['lll', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥'],
3509 ['llll', 'ཉི་མ་, ༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥']
3510 ],
3511 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
3512 i;
3513 for (i = 0; i < a.length; i++) {
3514 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
3515 }
3516 });
3517
3518 test('format ordinal', function (assert) {
3519 assert.equal(moment([2011, 0, 1]).format('DDDo'), '༡', '༡');
3520 assert.equal(moment([2011, 0, 2]).format('DDDo'), '༢', '༢');
3521 assert.equal(moment([2011, 0, 3]).format('DDDo'), '༣', '༣');
3522 assert.equal(moment([2011, 0, 4]).format('DDDo'), '༤', '༤');
3523 assert.equal(moment([2011, 0, 5]).format('DDDo'), '༥', '༥');
3524 assert.equal(moment([2011, 0, 6]).format('DDDo'), '༦', '༦');
3525 assert.equal(moment([2011, 0, 7]).format('DDDo'), '༧', '༧');
3526 assert.equal(moment([2011, 0, 8]).format('DDDo'), '༨', '༨');
3527 assert.equal(moment([2011, 0, 9]).format('DDDo'), '༩', '༩');
3528 assert.equal(moment([2011, 0, 10]).format('DDDo'), '༡༠', '༡༠');
3529
3530 assert.equal(moment([2011, 0, 11]).format('DDDo'), '༡༡', '༡༡');
3531 assert.equal(moment([2011, 0, 12]).format('DDDo'), '༡༢', '༡༢');
3532 assert.equal(moment([2011, 0, 13]).format('DDDo'), '༡༣', '༡༣');
3533 assert.equal(moment([2011, 0, 14]).format('DDDo'), '༡༤', '༡༤');
3534 assert.equal(moment([2011, 0, 15]).format('DDDo'), '༡༥', '༡༥');
3535 assert.equal(moment([2011, 0, 16]).format('DDDo'), '༡༦', '༡༦');
3536 assert.equal(moment([2011, 0, 17]).format('DDDo'), '༡༧', '༡༧');
3537 assert.equal(moment([2011, 0, 18]).format('DDDo'), '༡༨', '༡༨');
3538 assert.equal(moment([2011, 0, 19]).format('DDDo'), '༡༩', '༡༩');
3539 assert.equal(moment([2011, 0, 20]).format('DDDo'), '༢༠', '༢༠');
3540
3541 assert.equal(moment([2011, 0, 21]).format('DDDo'), '༢༡', '༢༡');
3542 assert.equal(moment([2011, 0, 22]).format('DDDo'), '༢༢', '༢༢');
3543 assert.equal(moment([2011, 0, 23]).format('DDDo'), '༢༣', '༢༣');
3544 assert.equal(moment([2011, 0, 24]).format('DDDo'), '༢༤', '༢༤');
3545 assert.equal(moment([2011, 0, 25]).format('DDDo'), '༢༥', '༢༥');
3546 assert.equal(moment([2011, 0, 26]).format('DDDo'), '༢༦', '༢༦');
3547 assert.equal(moment([2011, 0, 27]).format('DDDo'), '༢༧', '༢༧');
3548 assert.equal(moment([2011, 0, 28]).format('DDDo'), '༢༨', '༢༨');
3549 assert.equal(moment([2011, 0, 29]).format('DDDo'), '༢༩', '༢༩');
3550 assert.equal(moment([2011, 0, 30]).format('DDDo'), '༣༠', '༣༠');
3551
3552 assert.equal(moment([2011, 0, 31]).format('DDDo'), '༣༡', '༣༡');
3553 });
3554
3555 test('format month', function (assert) {
3556 var expected = 'ཟླ་བ་དང་པོ ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ ཟླ་བ་བཅུ་གཉིས་པ'.split('_'), i;
3557 for (i = 0; i < expected.length; i++) {
3558 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
3559 }
3560 });
3561
3562 test('format week', function (assert) {
3563 var expected = 'གཟའ་ཉི་མ་ ཉི་མ་ ཉི་མ་_གཟའ་ཟླ་བ་ ཟླ་བ་ ཟླ་བ་_གཟའ་མིག་དམར་ མིག་དམར་ མིག་དམར་_གཟའ་ལྷག་པ་ ལྷག་པ་ ལྷག་པ་_གཟའ་ཕུར་བུ ཕུར་བུ ཕུར་བུ_གཟའ་པ་སངས་ པ་སངས་ པ་སངས་_གཟའ་སྤེན་པ་ སྤེན་པ་ སྤེན་པ་'.split('_'), i;
3564 for (i = 0; i < expected.length; i++) {
3565 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
3566 }
3567 });
3568
3569 test('from', function (assert) {
3570 var start = moment([2007, 1, 28]);
3571 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ལམ་སང', '44 seconds = a few seconds');
3572 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'སྐར་མ་གཅིག', '45 seconds = a minute');
3573 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'སྐར་མ་གཅིག', '89 seconds = a minute');
3574 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '༢ སྐར་མ', '90 seconds = 2 minutes');
3575 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '༤༤ སྐར་མ', '44 minutes = 44 minutes');
3576 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ཆུ་ཚོད་གཅིག', '45 minutes = an hour');
3577 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ཆུ་ཚོད་གཅིག', '89 minutes = an hour');
3578 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '༢ ཆུ་ཚོད', '90 minutes = 2 hours');
3579 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '༥ ཆུ་ཚོད', '5 hours = 5 hours');
3580 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '༢༡ ཆུ་ཚོད', '21 hours = 21 hours');
3581 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ཉིན་གཅིག', '22 hours = a day');
3582 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ཉིན་གཅིག', '35 hours = a day');
3583 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '༢ ཉིན་', '36 hours = 2 days');
3584 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ཉིན་གཅིག', '1 day = a day');
3585 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '༥ ཉིན་', '5 days = 5 days');
3586 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '༢༥ ཉིན་', '25 days = 25 days');
3587 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ཟླ་བ་གཅིག', '26 days = a month');
3588 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ཟླ་བ་གཅིག', '30 days = a month');
3589 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ཟླ་བ་གཅིག', '43 days = a month');
3590 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '༢ ཟླ་བ', '46 days = 2 months');
3591 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '༢ ཟླ་བ', '75 days = 2 months');
3592 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '༣ ཟླ་བ', '76 days = 3 months');
3593 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ཟླ་བ་གཅིག', '1 month = a month');
3594 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '༥ ཟླ་བ', '5 months = 5 months');
3595 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ལོ་གཅིག', '345 days = a year');
3596 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '༢ ལོ', '548 days = 2 years');
3597 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ལོ་གཅིག', '1 year = a year');
3598 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '༥ ལོ', '5 years = 5 years');
3599 });
3600
3601 test('suffix', function (assert) {
3602 assert.equal(moment(30000).from(0), 'ལམ་སང ལ་', 'prefix');
3603 assert.equal(moment(0).from(30000), 'ལམ་སང སྔན་ལ', 'suffix');
3604 });
3605
3606 test('now from now', function (assert) {
3607 assert.equal(moment().fromNow(), 'ལམ་སང སྔན་ལ', 'now from now should display as in the past');
3608 });
3609
3610 test('fromNow', function (assert) {
3611 assert.equal(moment().add({s: 30}).fromNow(), 'ལམ་སང ལ་', 'ལམ་སང ལ་');
3612 assert.equal(moment().add({d: 5}).fromNow(), '༥ ཉིན་ ལ་', '༥ ཉིན་ ལ་');
3613 });
3614
3615 test('calendar day', function (assert) {
3616 var a = moment().hours(2).minutes(0).seconds(0);
3617
3618 assert.equal(moment(a).calendar(), 'དི་རིང མཚན་མོ ༢:༠༠', 'today at the same time');
3619 assert.equal(moment(a).add({m: 25}).calendar(), 'དི་རིང མཚན་མོ ༢:༢༥', 'Now plus 25 min');
3620 assert.equal(moment(a).add({h: 3}).calendar(), 'དི་རིང ཞོགས་ཀས ༥:༠༠', 'Now plus 3 hour');
3621 assert.equal(moment(a).add({d: 1}).calendar(), 'སང་ཉིན མཚན་མོ ༢:༠༠', 'tomorrow at the same time');
3622 assert.equal(moment(a).subtract({h: 1}).calendar(), 'དི་རིང མཚན་མོ ༡:༠༠', 'Now minus 1 hour');
3623 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ཁ་སང མཚན་མོ ༢:༠༠', 'yesterday at the same time');
3624 });
3625
3626 test('calendar next week', function (assert) {
3627 var i, m;
3628 for (i = 2; i < 7; i++) {
3629 m = moment().add({d: i});
3630 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་རྗེས་མ][,] LT'), 'Today + ' + i + ' days current time');
3631 m.hours(0).minutes(0).seconds(0).milliseconds(0);
3632 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་རྗེས་མ][,] LT'), 'Today + ' + i + ' days beginning of day');
3633 m.hours(23).minutes(59).seconds(59).milliseconds(999);
3634 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་རྗེས་མ][,] LT'), 'Today + ' + i + ' days end of day');
3635 }
3636 });
3637
3638 test('calendar last week', function (assert) {
3639 var i, m;
3640
3641 for (i = 2; i < 7; i++) {
3642 m = moment().subtract({d: i});
3643 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་མཐའ་མ] dddd[,] LT'), 'Today - ' + i + ' days current time');
3644 m.hours(0).minutes(0).seconds(0).milliseconds(0);
3645 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་མཐའ་མ] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
3646 m.hours(23).minutes(59).seconds(59).milliseconds(999);
3647 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་མཐའ་མ] dddd[,] LT'), 'Today - ' + i + ' days end of day');
3648 }
3649 });
3650
3651 test('calendar all else', function (assert) {
3652 var weeksAgo = moment().subtract({w: 1}),
3653 weeksFromNow = moment().add({w: 1});
3654
3655 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
3656 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
3657
3658 weeksAgo = moment().subtract({w: 2});
3659 weeksFromNow = moment().add({w: 2});
3660
3661 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
3662 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
3663 });
3664
3665 test('meridiem', function (assert) {
3666 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'མཚན་མོ', 'before dawn');
3667 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'ཞོགས་ཀས', 'morning');
3668 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'ཉིན་གུང', 'during day');
3669 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'དགོང་དག', 'evening');
3670 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'དགོང་དག', 'late evening');
3671 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'མཚན་མོ', 'night');
3672
3673 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'མཚན་མོ', 'before dawn');
3674 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'ཞོགས་ཀས', 'morning');
3675 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'ཉིན་གུང', ' during day');
3676 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'དགོང་དག', 'evening');
3677 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'དགོང་དག', 'late evening');
3678 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'མཚན་མོ', 'night');
3679 });
3680
3681 test('weeks year starting sunday', function (assert) {
3682 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
3683 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
3684 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
3685 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
3686 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
3687 });
3688
3689 test('weeks year starting monday', function (assert) {
3690 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
3691 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
3692 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
3693 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
3694 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
3695 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
3696 });
3697
3698 test('weeks year starting tuesday', function (assert) {
3699 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
3700 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
3701 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
3702 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
3703 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
3704 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
3705 });
3706
3707 test('weeks year starting wednesday', function (assert) {
3708 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
3709 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
3710 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
3711 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
3712 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
3713 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
3714 });
3715
3716 test('weeks year starting thursday', function (assert) {
3717 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
3718 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
3719 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
3720 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
3721 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
3722 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
3723 });
3724
3725 test('weeks year starting friday', function (assert) {
3726 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
3727 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
3728 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
3729 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
3730 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
3731 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
3732 });
3733
3734 test('weeks year starting saturday', function (assert) {
3735 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
3736 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
3737 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
3738 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
3739 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
3740 });
3741
3742 test('weeks year starting sunday formatted', function (assert) {
3743 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 1 2012 should be week 1');
3744 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 7 2012 should be week 1');
3745 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '༢ ༠༢ ༢', 'Jan 8 2012 should be week 2');
3746 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '༢ ༠༢ ༢', 'Jan 14 2012 should be week 2');
3747 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '༣ ༠༣ ༣', 'Jan 15 2012 should be week 3');
3748 });
3749
3750 test('lenient ordinal parsing', function (assert) {
3751 var i, ordinalStr, testMoment;
3752 for (i = 1; i <= 31; ++i) {
3753 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
3754 testMoment = moment(ordinalStr, 'YYYY MM Do');
3755 assert.equal(testMoment.year(), 2014,
3756 'lenient ordinal parsing ' + i + ' year check');
3757 assert.equal(testMoment.month(), 0,
3758 'lenient ordinal parsing ' + i + ' month check');
3759 assert.equal(testMoment.date(), i,
3760 'lenient ordinal parsing ' + i + ' date check');
3761 }
3762 });
3763
3764 test('lenient ordinal parsing of number', function (assert) {
3765 var i, testMoment;
3766 for (i = 1; i <= 31; ++i) {
3767 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
3768 assert.equal(testMoment.year(), 2014,
3769 'lenient ordinal parsing of number ' + i + ' year check');
3770 assert.equal(testMoment.month(), 0,
3771 'lenient ordinal parsing of number ' + i + ' month check');
3772 assert.equal(testMoment.date(), i,
3773 'lenient ordinal parsing of number ' + i + ' date check');
3774 }
3775 });
3776
3777 test('strict ordinal parsing', function (assert) {
3778 var i, ordinalStr, testMoment;
3779 for (i = 1; i <= 31; ++i) {
3780 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
3781 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
3782 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
3783 }
3784 });
3785
3786 }));
3787
3788 (function (global, factory) {
3789 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
3790 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
3791 factory(global.moment)
3792 }(this, function (moment) { 'use strict';
3793
3794 /*global QUnit:false*/
3795
3796 var test = QUnit.test;
3797
3798 function module (name, lifecycle) {
3799 QUnit.module(name, {
3800 setup : function () {
3801 moment.locale('en');
3802 moment.createFromInputFallback = function () {
3803 throw new Error('input not handled by moment');
3804 };
3805 if (lifecycle && lifecycle.setup) {
3806 lifecycle.setup();
3807 }
3808 },
3809 teardown : function () {
3810 if (lifecycle && lifecycle.teardown) {
3811 lifecycle.teardown();
3812 }
3813 }
3814 });
3815 }
3816
3817 function localeModule (name, lifecycle) {
3818 QUnit.module('locale:' + name, {
3819 setup : function () {
3820 moment.locale(name);
3821 moment.createFromInputFallback = function () {
3822 throw new Error('input not handled by moment');
3823 };
3824 if (lifecycle && lifecycle.setup) {
3825 lifecycle.setup();
3826 }
3827 },
3828 teardown : function () {
3829 moment.locale('en');
3830 if (lifecycle && lifecycle.teardown) {
3831 lifecycle.teardown();
3832 }
3833 }
3834 });
3835 }
3836
3837 localeModule('br');
3838
3839 test('parse', function (assert) {
3840 var tests = 'Genver Gen_C\'hwevrer C\'hwe_Meurzh Meu_Ebrel Ebr_Mae Mae_Mezheven Eve_Gouere Gou_Eost Eos_Gwengolo Gwe_Here Her_Du Du_Kerzu Ker'.split('_'), i;
3841 function equalTest(input, mmm, i) {
3842 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
3843 }
3844 for (i = 0; i < 12; i++) {
3845 tests[i] = tests[i].split(' ');
3846 equalTest(tests[i][0], 'MMM', i);
3847 equalTest(tests[i][1], 'MMM', i);
3848 equalTest(tests[i][0], 'MMMM', i);
3849 equalTest(tests[i][1], 'MMMM', i);
3850 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
3851 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
3852 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
3853 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
3854 }
3855 });
3856
3857 test('format', function (assert) {
3858 moment.locale('br');
3859 var a = [
3860 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sul, C\'hwevrer 14vet 2010, 3:25:50 pm'],
3861 ['ddd, h A', 'Sul, 3 PM'],
3862 ['M Mo MM MMMM MMM', '2 2vet 02 C\'hwevrer C\'hwe'],
3863 ['YYYY YY', '2010 10'],
3864 ['D Do DD', '14 14vet 14'],
3865 ['d do dddd ddd dd', '0 0vet Sul Sul Su'],
3866 ['DDD DDDo DDDD', '45 45vet 045'],
3867 ['w wo ww', '6 6vet 06'],
3868 ['h hh', '3 03'],
3869 ['H HH', '15 15'],
3870 ['m mm', '25 25'],
3871 ['s ss', '50 50'],
3872 ['DDDo [devezh] [ar] [vloaz]', '45vet devezh ar vloaz'],
3873 ['L', '14/02/2010'],
3874 ['LL', '14 a viz C\'hwevrer 2010'],
3875 ['LLL', '14 a viz C\'hwevrer 2010 3e25 PM'],
3876 ['LLLL', 'Sul, 14 a viz C\'hwevrer 2010 3e25 PM']
3877 ],
3878 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
3879 i;
3880 for (i = 0; i < a.length; i++) {
3881 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
3882 }
3883 });
3884
3885 test('format ordinal', function (assert) {
3886 moment.locale('br');
3887 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1añ', '1añ');
3888 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2vet', '2vet');
3889 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3vet', '3vet');
3890 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4vet', '4vet');
3891 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5vet', '5vet');
3892 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6vet', '6vet');
3893 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7vet', '7vet');
3894 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8vet', '8vet');
3895 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9vet', '9vet');
3896 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10vet', '10vet');
3897
3898 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11vet', '11vet');
3899 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12vet', '12vet');
3900 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13vet', '13vet');
3901 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14vet', '14vet');
3902 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15vet', '15vet');
3903 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16vet', '16vet');
3904 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17vet', '17vet');
3905 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18vet', '18vet');
3906 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19vet', '19vet');
3907 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20vet', '20vet');
3908
3909 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21vet', '21vet');
3910 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22vet', '22vet');
3911 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23vet', '23vet');
3912 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24vet', '24vet');
3913 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25vet', '25vet');
3914 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26vet', '26vet');
3915 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27vet', '27vet');
3916 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28vet', '28vet');
3917 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29vet', '29vet');
3918 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30vet', '30vet');
3919
3920 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31vet', '31vet');
3921 });
3922
3923 test('format month', function (assert) {
3924 moment.locale('br');
3925 var expected = 'Genver Gen_C\'hwevrer C\'hwe_Meurzh Meu_Ebrel Ebr_Mae Mae_Mezheven Eve_Gouere Gou_Eost Eos_Gwengolo Gwe_Here Her_Du Du_Kerzu Ker'.split('_'), i;
3926 for (i = 0; i < expected.length; i++) {
3927 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
3928 }
3929 });
3930
3931 test('format week', function (assert) {
3932 moment.locale('br');
3933 var expected = 'Sul Sul Su_Lun Lun Lu_Meurzh Meu Me_Merc\'her Mer Mer_Yaou Yao Ya_Gwener Gwe Gw_Sadorn Sad Sa'.split('_'), i;
3934 for (i = 0; i < expected.length; i++) {
3935 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
3936 }
3937 });
3938
3939 test('from', function (assert) {
3940 moment.locale('br');
3941 var start = moment([2007, 1, 28]);
3942 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'un nebeud segondennoù', '44 seconds = a few seconds');
3943 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ur vunutenn', '45 seconds = a minute');
3944 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ur vunutenn', '89 seconds = a minute');
3945 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 vunutenn', '90 seconds = 2 minutes');
3946 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 munutenn', '44 minutes = 44 minutes');
3947 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'un eur', '45 minutes = an hour');
3948 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'un eur', '89 minutes = an hour');
3949 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 eur', '90 minutes = 2 hours');
3950 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 eur', '5 hours = 5 hours');
3951 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 eur', '21 hours = 21 hours');
3952 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un devezh', '22 hours = a day');
3953 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un devezh', '35 hours = a day');
3954 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 zevezh', '36 hours = 2 days');
3955 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un devezh', '1 day = a day');
3956 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 devezh', '5 days = 5 days');
3957 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 devezh', '25 days = 25 days');
3958 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ur miz', '26 days = a month');
3959 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ur miz', '30 days = a month');
3960 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ur miz', '43 days = a month');
3961 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 viz', '46 days = 2 months');
3962 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 viz', '75 days = 2 months');
3963 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 miz', '76 days = 3 months');
3964 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ur miz', '1 month = a month');
3965 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 miz', '5 months = 5 months');
3966 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ur bloaz', '345 days = a year');
3967 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 vloaz', '548 days = 2 years');
3968 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ur bloaz', '1 year = a year');
3969 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 bloaz', '5 years = 5 years');
3970 });
3971
3972 test('suffix', function (assert) {
3973 moment.locale('br');
3974 assert.equal(moment(30000).from(0), 'a-benn un nebeud segondennoù', 'prefix');
3975 assert.equal(moment(0).from(30000), 'un nebeud segondennoù \'zo', 'suffix');
3976 });
3977
3978 test('now from now', function (assert) {
3979 moment.locale('br');
3980 assert.equal(moment().fromNow(), 'un nebeud segondennoù \'zo', 'now from now should display as in the past');
3981 });
3982
3983 test('fromNow', function (assert) {
3984 moment.locale('br');
3985 assert.equal(moment().add({s: 30}).fromNow(), 'a-benn un nebeud segondennoù', 'in a few seconds');
3986 assert.equal(moment().add({d: 5}).fromNow(), 'a-benn 5 devezh', 'in 5 days');
3987 });
3988
3989 test('calendar day', function (assert) {
3990 moment.locale('br');
3991
3992 var a = moment().hours(2).minutes(0).seconds(0);
3993
3994 assert.equal(moment(a).calendar(), 'Hiziv da 2e00 AM', 'today at the same time');
3995 assert.equal(moment(a).add({m: 25}).calendar(), 'Hiziv da 2e25 AM', 'Now plus 25 min');
3996 assert.equal(moment(a).add({h: 1}).calendar(), 'Hiziv da 3e00 AM', 'Now plus 1 hour');
3997 assert.equal(moment(a).add({d: 1}).calendar(), 'Warc\'hoazh da 2e00 AM', 'tomorrow at the same time');
3998 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hiziv da 1e00 AM', 'Now minus 1 hour');
3999 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dec\'h da 2e00 AM', 'yesterday at the same time');
4000 });
4001
4002 test('calendar next week', function (assert) {
4003 moment.locale('br');
4004
4005 var i, m;
4006 for (i = 2; i < 7; i++) {
4007 m = moment().add({d: i});
4008 assert.equal(m.calendar(), m.format('dddd [da] LT'), 'Today + ' + i + ' days current time');
4009 m.hours(0).minutes(0).seconds(0).milliseconds(0);
4010 assert.equal(m.calendar(), m.format('dddd [da] LT'), 'Today + ' + i + ' days beginning of day');
4011 m.hours(23).minutes(59).seconds(59).milliseconds(999);
4012 assert.equal(m.calendar(), m.format('dddd [da] LT'), 'Today + ' + i + ' days end of day');
4013 }
4014 });
4015
4016 test('calendar last week', function (assert) {
4017 moment.locale('br');
4018
4019 var i, m;
4020 for (i = 2; i < 7; i++) {
4021 m = moment().subtract({d: i});
4022 assert.equal(m.calendar(), m.format('dddd [paset da] LT'), 'Today - ' + i + ' days current time');
4023 m.hours(0).minutes(0).seconds(0).milliseconds(0);
4024 assert.equal(m.calendar(), m.format('dddd [paset da] LT'), 'Today - ' + i + ' days beginning of day');
4025 m.hours(23).minutes(59).seconds(59).milliseconds(999);
4026 assert.equal(m.calendar(), m.format('dddd [paset da] LT'), 'Today - ' + i + ' days end of day');
4027 }
4028 });
4029
4030 test('calendar all else', function (assert) {
4031 moment.locale('br');
4032 var weeksAgo = moment().subtract({w: 1}),
4033 weeksFromNow = moment().add({w: 1});
4034
4035 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
4036 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
4037
4038 weeksAgo = moment().subtract({w: 2});
4039 weeksFromNow = moment().add({w: 2});
4040
4041 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
4042 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
4043 });
4044
4045 test('special mutations for years', function (assert) {
4046 moment.locale('br');
4047 var start = moment([2007, 1, 28]);
4048 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ur bloaz', 'mutation 1 year');
4049 assert.equal(start.from(moment([2007, 1, 28]).add({y: 2}), true), '2 vloaz', 'mutation 2 years');
4050 assert.equal(start.from(moment([2007, 1, 28]).add({y: 3}), true), '3 bloaz', 'mutation 3 years');
4051 assert.equal(start.from(moment([2007, 1, 28]).add({y: 4}), true), '4 bloaz', 'mutation 4 years');
4052 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 bloaz', 'mutation 5 years');
4053 assert.equal(start.from(moment([2007, 1, 28]).add({y: 9}), true), '9 bloaz', 'mutation 9 years');
4054 assert.equal(start.from(moment([2007, 1, 28]).add({y: 10}), true), '10 vloaz', 'mutation 10 years');
4055 assert.equal(start.from(moment([2007, 1, 28]).add({y: 21}), true), '21 bloaz', 'mutation 21 years');
4056 assert.equal(start.from(moment([2007, 1, 28]).add({y: 22}), true), '22 vloaz', 'mutation 22 years');
4057 assert.equal(start.from(moment([2007, 1, 28]).add({y: 133}), true), '133 bloaz', 'mutation 133 years');
4058 assert.equal(start.from(moment([2007, 1, 28]).add({y: 148}), true), '148 vloaz', 'mutation 148 years');
4059 assert.equal(start.from(moment([2007, 1, 28]).add({y: 261}), true), '261 bloaz', 'mutation 261 years');
4060 });
4061
4062 test('lenient ordinal parsing', function (assert) {
4063 var i, ordinalStr, testMoment;
4064 for (i = 1; i <= 31; ++i) {
4065 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
4066 testMoment = moment(ordinalStr, 'YYYY MM Do');
4067 assert.equal(testMoment.year(), 2014,
4068 'lenient ordinal parsing ' + i + ' year check');
4069 assert.equal(testMoment.month(), 0,
4070 'lenient ordinal parsing ' + i + ' month check');
4071 assert.equal(testMoment.date(), i,
4072 'lenient ordinal parsing ' + i + ' date check');
4073 }
4074 });
4075
4076 test('lenient ordinal parsing of number', function (assert) {
4077 var i, testMoment;
4078 for (i = 1; i <= 31; ++i) {
4079 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
4080 assert.equal(testMoment.year(), 2014,
4081 'lenient ordinal parsing of number ' + i + ' year check');
4082 assert.equal(testMoment.month(), 0,
4083 'lenient ordinal parsing of number ' + i + ' month check');
4084 assert.equal(testMoment.date(), i,
4085 'lenient ordinal parsing of number ' + i + ' date check');
4086 }
4087 });
4088
4089 test('strict ordinal parsing', function (assert) {
4090 var i, ordinalStr, testMoment;
4091 for (i = 1; i <= 31; ++i) {
4092 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
4093 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
4094 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
4095 }
4096 });
4097
4098 }));
4099
4100 (function (global, factory) {
4101 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
4102 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
4103 factory(global.moment)
4104 }(this, function (moment) { 'use strict';
4105
4106 /*global QUnit:false*/
4107
4108 var test = QUnit.test;
4109
4110 function module (name, lifecycle) {
4111 QUnit.module(name, {
4112 setup : function () {
4113 moment.locale('en');
4114 moment.createFromInputFallback = function () {
4115 throw new Error('input not handled by moment');
4116 };
4117 if (lifecycle && lifecycle.setup) {
4118 lifecycle.setup();
4119 }
4120 },
4121 teardown : function () {
4122 if (lifecycle && lifecycle.teardown) {
4123 lifecycle.teardown();
4124 }
4125 }
4126 });
4127 }
4128
4129 function localeModule (name, lifecycle) {
4130 QUnit.module('locale:' + name, {
4131 setup : function () {
4132 moment.locale(name);
4133 moment.createFromInputFallback = function () {
4134 throw new Error('input not handled by moment');
4135 };
4136 if (lifecycle && lifecycle.setup) {
4137 lifecycle.setup();
4138 }
4139 },
4140 teardown : function () {
4141 moment.locale('en');
4142 if (lifecycle && lifecycle.teardown) {
4143 lifecycle.teardown();
4144 }
4145 }
4146 });
4147 }
4148
4149 localeModule('bs');
4150
4151 test('parse', function (assert) {
4152 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;
4153 function equalTest(input, mmm, i) {
4154 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
4155 }
4156 for (i = 0; i < 12; i++) {
4157 tests[i] = tests[i].split(' ');
4158 equalTest(tests[i][0], 'MMM', i);
4159 equalTest(tests[i][1], 'MMM', i);
4160 equalTest(tests[i][0], 'MMMM', i);
4161 equalTest(tests[i][1], 'MMMM', i);
4162 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
4163 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
4164 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
4165 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
4166 }
4167 });
4168
4169 test('format', function (assert) {
4170 var a = [
4171 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedjelja, 14. februar 2010, 3:25:50 pm'],
4172 ['ddd, hA', 'ned., 3PM'],
4173 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
4174 ['YYYY YY', '2010 10'],
4175 ['D Do DD', '14 14. 14'],
4176 ['d do dddd ddd dd', '0 0. nedjelja ned. ne'],
4177 ['DDD DDDo DDDD', '45 45. 045'],
4178 ['w wo ww', '7 7. 07'],
4179 ['h hh', '3 03'],
4180 ['H HH', '15 15'],
4181 ['m mm', '25 25'],
4182 ['s ss', '50 50'],
4183 ['a A', 'pm PM'],
4184 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
4185 ['LTS', '15:25:50'],
4186 ['L', '14. 02. 2010'],
4187 ['LL', '14. februar 2010'],
4188 ['LLL', '14. februar 2010 15:25'],
4189 ['LLLL', 'nedjelja, 14. februar 2010 15:25'],
4190 ['l', '14. 2. 2010'],
4191 ['ll', '14. feb. 2010'],
4192 ['lll', '14. feb. 2010 15:25'],
4193 ['llll', 'ned., 14. feb. 2010 15:25']
4194 ],
4195 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
4196 i;
4197 for (i = 0; i < a.length; i++) {
4198 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
4199 }
4200 });
4201
4202 test('format ordinal', function (assert) {
4203 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
4204 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
4205 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
4206 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
4207 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
4208 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
4209 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
4210 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
4211 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
4212 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
4213
4214 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
4215 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
4216 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
4217 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
4218 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
4219 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
4220 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
4221 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
4222 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
4223 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
4224
4225 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
4226 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
4227 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
4228 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
4229 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
4230 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
4231 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
4232 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
4233 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
4234 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
4235
4236 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
4237 });
4238
4239 test('format month', function (assert) {
4240 var expected = '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;
4241 for (i = 0; i < expected.length; i++) {
4242 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
4243 }
4244 });
4245
4246 test('format week', function (assert) {
4247 var expected = 'nedjelja ned. ne_ponedjeljak pon. po_utorak uto. ut_srijeda sri. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'), i;
4248 for (i = 0; i < expected.length; i++) {
4249 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
4250 }
4251 });
4252
4253 test('from', function (assert) {
4254 var start = moment([2007, 1, 28]);
4255 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'par sekundi', '44 seconds = a few seconds');
4256 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedna minuta', '45 seconds = a minute');
4257 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedna minuta', '89 seconds = a minute');
4258 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
4259 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
4260 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
4261 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
4262 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
4263 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
4264 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
4265 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
4266 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
4267 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
4268 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
4269 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
4270 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
4271 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mjesec', '26 days = a month');
4272 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mjesec', '30 days = a month');
4273 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mjesec', '43 days = a month');
4274 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mjeseca', '46 days = 2 months');
4275 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mjeseca', '75 days = 2 months');
4276 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mjeseca', '76 days = 3 months');
4277 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mjesec', '1 month = a month');
4278 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mjeseci', '5 months = 5 months');
4279 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
4280 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
4281 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
4282 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
4283 });
4284
4285 test('suffix', function (assert) {
4286 assert.equal(moment(30000).from(0), 'za par sekundi', 'prefix');
4287 assert.equal(moment(0).from(30000), 'prije par sekundi', 'prefix');
4288 });
4289
4290 test('now from now', function (assert) {
4291 assert.equal(moment().fromNow(), 'prije par sekundi', 'now from now should display as in the past');
4292 });
4293
4294 test('fromNow', function (assert) {
4295 assert.equal(moment().add({s: 30}).fromNow(), 'za par sekundi', 'in a few seconds');
4296 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
4297 });
4298
4299 test('calendar day', function (assert) {
4300 var a = moment().hours(2).minutes(0).seconds(0);
4301
4302 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
4303 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
4304 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
4305 assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
4306 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
4307 assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
4308 });
4309
4310 test('calendar next week', function (assert) {
4311 var i, m;
4312
4313 function makeFormat(d) {
4314 switch (d.day()) {
4315 case 0:
4316 return '[u] [nedjelju] [u] LT';
4317 case 3:
4318 return '[u] [srijedu] [u] LT';
4319 case 6:
4320 return '[u] [subotu] [u] LT';
4321 case 1:
4322 case 2:
4323 case 4:
4324 case 5:
4325 return '[u] dddd [u] LT';
4326 }
4327 }
4328
4329 for (i = 2; i < 7; i++) {
4330 m = moment().add({d: i});
4331 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
4332 m.hours(0).minutes(0).seconds(0).milliseconds(0);
4333 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
4334 m.hours(23).minutes(59).seconds(59).milliseconds(999);
4335 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
4336 }
4337 });
4338
4339 test('calendar last week', function (assert) {
4340 var i, m;
4341
4342 function makeFormat(d) {
4343 switch (d.day()) {
4344 case 0:
4345 case 3:
4346 return '[prošlu] dddd [u] LT';
4347 case 6:
4348 return '[prošle] [subote] [u] LT';
4349 case 1:
4350 case 2:
4351 case 4:
4352 case 5:
4353 return '[prošli] dddd [u] LT';
4354 }
4355 }
4356
4357 for (i = 2; i < 7; i++) {
4358 m = moment().subtract({d: i});
4359 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
4360 m.hours(0).minutes(0).seconds(0).milliseconds(0);
4361 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
4362 m.hours(23).minutes(59).seconds(59).milliseconds(999);
4363 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
4364 }
4365 });
4366
4367 test('calendar all else', function (assert) {
4368 var weeksAgo = moment().subtract({w: 1}),
4369 weeksFromNow = moment().add({w: 1});
4370
4371 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
4372 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
4373
4374 weeksAgo = moment().subtract({w: 2});
4375 weeksFromNow = moment().add({w: 2});
4376
4377 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
4378 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
4379 });
4380
4381 test('weeks year starting sunday', function (assert) {
4382 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
4383 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
4384 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
4385 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
4386 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
4387 });
4388
4389 test('weeks year starting monday', function (assert) {
4390 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
4391 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
4392 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
4393 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
4394 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
4395 });
4396
4397 test('weeks year starting tuesday', function (assert) {
4398 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
4399 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
4400 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
4401 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
4402 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
4403 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
4404 });
4405
4406 test('weeks year starting wednesday', function (assert) {
4407 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
4408 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
4409 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
4410 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
4411 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
4412 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
4413 });
4414
4415 test('weeks year starting thursday', function (assert) {
4416 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
4417 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
4418 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
4419 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
4420 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
4421 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
4422 });
4423
4424 test('weeks year starting friday', function (assert) {
4425 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
4426 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
4427 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
4428 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
4429 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
4430 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
4431 });
4432
4433 test('weeks year starting saturday', function (assert) {
4434 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
4435 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
4436 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
4437 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
4438 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
4439 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
4440 });
4441
4442 test('weeks year starting sunday formatted', function (assert) {
4443 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
4444 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
4445 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
4446 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
4447 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
4448 });
4449
4450 test('lenient ordinal parsing', function (assert) {
4451 var i, ordinalStr, testMoment;
4452 for (i = 1; i <= 31; ++i) {
4453 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
4454 testMoment = moment(ordinalStr, 'YYYY MM Do');
4455 assert.equal(testMoment.year(), 2014,
4456 'lenient ordinal parsing ' + i + ' year check');
4457 assert.equal(testMoment.month(), 0,
4458 'lenient ordinal parsing ' + i + ' month check');
4459 assert.equal(testMoment.date(), i,
4460 'lenient ordinal parsing ' + i + ' date check');
4461 }
4462 });
4463
4464 test('lenient ordinal parsing of number', function (assert) {
4465 var i, testMoment;
4466 for (i = 1; i <= 31; ++i) {
4467 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
4468 assert.equal(testMoment.year(), 2014,
4469 'lenient ordinal parsing of number ' + i + ' year check');
4470 assert.equal(testMoment.month(), 0,
4471 'lenient ordinal parsing of number ' + i + ' month check');
4472 assert.equal(testMoment.date(), i,
4473 'lenient ordinal parsing of number ' + i + ' date check');
4474 }
4475 });
4476
4477 test('strict ordinal parsing', function (assert) {
4478 var i, ordinalStr, testMoment;
4479 for (i = 1; i <= 31; ++i) {
4480 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
4481 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
4482 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
4483 }
4484 });
4485
4486 }));
4487
4488 (function (global, factory) {
4489 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
4490 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
4491 factory(global.moment)
4492 }(this, function (moment) { 'use strict';
4493
4494 /*global QUnit:false*/
4495
4496 var test = QUnit.test;
4497
4498 function module (name, lifecycle) {
4499 QUnit.module(name, {
4500 setup : function () {
4501 moment.locale('en');
4502 moment.createFromInputFallback = function () {
4503 throw new Error('input not handled by moment');
4504 };
4505 if (lifecycle && lifecycle.setup) {
4506 lifecycle.setup();
4507 }
4508 },
4509 teardown : function () {
4510 if (lifecycle && lifecycle.teardown) {
4511 lifecycle.teardown();
4512 }
4513 }
4514 });
4515 }
4516
4517 function localeModule (name, lifecycle) {
4518 QUnit.module('locale:' + name, {
4519 setup : function () {
4520 moment.locale(name);
4521 moment.createFromInputFallback = function () {
4522 throw new Error('input not handled by moment');
4523 };
4524 if (lifecycle && lifecycle.setup) {
4525 lifecycle.setup();
4526 }
4527 },
4528 teardown : function () {
4529 moment.locale('en');
4530 if (lifecycle && lifecycle.teardown) {
4531 lifecycle.teardown();
4532 }
4533 }
4534 });
4535 }
4536
4537 localeModule('ca');
4538
4539 test('parse', function (assert) {
4540 var tests = 'gener gen._febrer febr._març mar._abril abr._maig mai._juny jun._juliol jul._agost ag._setembre set._octubre oct._novembre nov._desembre des.'.split('_'), i;
4541 function equalTest(input, mmm, i) {
4542 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
4543 }
4544 for (i = 0; i < 12; i++) {
4545 tests[i] = tests[i].split(' ');
4546 equalTest(tests[i][0], 'MMM', i);
4547 equalTest(tests[i][1], 'MMM', i);
4548 equalTest(tests[i][0], 'MMMM', i);
4549 equalTest(tests[i][1], 'MMMM', i);
4550 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
4551 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
4552 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
4553 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
4554 }
4555 });
4556
4557 test('format', function (assert) {
4558 var a = [
4559 ['dddd, Do MMMM YYYY, h:mm:ss a', 'diumenge, 14è febrer 2010, 3:25:50 pm'],
4560 ['ddd, hA', 'dg., 3PM'],
4561 ['M Mo MM MMMM MMM', '2 2n 02 febrer febr.'],
4562 ['YYYY YY', '2010 10'],
4563 ['D Do DD', '14 14è 14'],
4564 ['d do dddd ddd dd', '0 0è diumenge dg. Dg'],
4565 ['DDD DDDo DDDD', '45 45è 045'],
4566 ['w wo ww', '6 6a 06'],
4567 ['h hh', '3 03'],
4568 ['H HH', '15 15'],
4569 ['m mm', '25 25'],
4570 ['s ss', '50 50'],
4571 ['a A', 'pm PM'],
4572 ['[the] DDDo [day of the year]', 'the 45è day of the year'],
4573 ['LTS', '15:25:50'],
4574 ['L', '14/02/2010'],
4575 ['LL', '14 febrer 2010'],
4576 ['LLL', '14 febrer 2010 15:25'],
4577 ['LLLL', 'diumenge 14 febrer 2010 15:25'],
4578 ['l', '14/2/2010'],
4579 ['ll', '14 febr. 2010'],
4580 ['lll', '14 febr. 2010 15:25'],
4581 ['llll', 'dg. 14 febr. 2010 15:25']
4582 ],
4583 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
4584 i;
4585 for (i = 0; i < a.length; i++) {
4586 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
4587 }
4588 });
4589
4590 test('format ordinal', function (assert) {
4591 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1r', '1r');
4592 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2n', '2n');
4593 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3r', '3r');
4594 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4t', '4t');
4595 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5è', '5è');
4596 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6è', '6è');
4597 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7è', '7è');
4598 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8è', '8è');
4599 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9è', '9è');
4600 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10è', '10è');
4601
4602 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11è', '11è');
4603 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12è', '12è');
4604 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13è', '13è');
4605 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14è', '14è');
4606 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15è', '15è');
4607 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16è', '16è');
4608 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17è', '17è');
4609 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18è', '18è');
4610 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19è', '19è');
4611 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20è', '20è');
4612
4613 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21è', '21è');
4614 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22è', '22è');
4615 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23è', '23è');
4616 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24è', '24è');
4617 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25è', '25è');
4618 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26è', '26è');
4619 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27è', '27è');
4620 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28è', '28è');
4621 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29è', '29è');
4622 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30è', '30è');
4623
4624 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31è', '31è');
4625 });
4626
4627 test('format month', function (assert) {
4628 var expected = 'gener gen._febrer febr._març mar._abril abr._maig mai._juny jun._juliol jul._agost ag._setembre set._octubre oct._novembre nov._desembre des.'.split('_'), i;
4629 for (i = 0; i < expected.length; i++) {
4630 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
4631 }
4632 });
4633
4634 test('format week', function (assert) {
4635 var expected = 'diumenge dg. Dg_dilluns dl. Dl_dimarts dt. Dt_dimecres dc. Dc_dijous dj. Dj_divendres dv. Dv_dissabte ds. Ds'.split('_'), i;
4636 for (i = 0; i < expected.length; i++) {
4637 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
4638 }
4639 });
4640
4641 test('from', function (assert) {
4642 var start = moment([2007, 1, 28]);
4643 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'uns segons', '44 seconds = a few seconds');
4644 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minut', '45 seconds = a minute');
4645 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minut', '89 seconds = a minute');
4646 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuts', '90 seconds = 2 minutes');
4647 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuts', '44 minutes = 44 minutes');
4648 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'una hora', '45 minutes = an hour');
4649 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'una hora', '89 minutes = an hour');
4650 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hores', '90 minutes = 2 hours');
4651 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hores', '5 hours = 5 hours');
4652 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hores', '21 hours = 21 hours');
4653 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un dia', '22 hours = a day');
4654 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un dia', '35 hours = a day');
4655 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dies', '36 hours = 2 days');
4656 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un dia', '1 day = a day');
4657 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dies', '5 days = 5 days');
4658 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dies', '25 days = 25 days');
4659 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mes', '26 days = a month');
4660 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mes', '30 days = a month');
4661 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mes', '43 days = a month');
4662 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesos', '46 days = 2 months');
4663 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesos', '75 days = 2 months');
4664 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesos', '76 days = 3 months');
4665 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mes', '1 month = a month');
4666 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesos', '5 months = 5 months');
4667 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un any', '345 days = a year');
4668 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anys', '548 days = 2 years');
4669 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un any', '1 year = a year');
4670 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anys', '5 years = 5 years');
4671 });
4672
4673 test('suffix', function (assert) {
4674 assert.equal(moment(30000).from(0), 'en uns segons', 'prefix');
4675 assert.equal(moment(0).from(30000), 'fa uns segons', 'suffix');
4676 });
4677
4678 test('now from now', function (assert) {
4679 assert.equal(moment().fromNow(), 'fa uns segons', 'now from now should display as in the past');
4680 });
4681
4682 test('fromNow', function (assert) {
4683 assert.equal(moment().add({s: 30}).fromNow(), 'en uns segons', 'en uns segons');
4684 assert.equal(moment().add({d: 5}).fromNow(), 'en 5 dies', 'en 5 dies');
4685 });
4686
4687 test('calendar day', function (assert) {
4688 var a = moment().hours(2).minutes(0).seconds(0);
4689
4690 assert.equal(moment(a).calendar(), 'avui a les 2:00', 'today at the same time');
4691 assert.equal(moment(a).add({m: 25}).calendar(), 'avui a les 2:25', 'Now plus 25 min');
4692 assert.equal(moment(a).add({h: 1}).calendar(), 'avui a les 3:00', 'Now plus 1 hour');
4693 assert.equal(moment(a).add({d: 1}).calendar(), 'demà a les 2:00', 'tomorrow at the same time');
4694 assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'demà a la 1:00', 'tomorrow minus 1 hour');
4695 assert.equal(moment(a).subtract({h: 1}).calendar(), 'avui a la 1:00', 'Now minus 1 hour');
4696 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ahir a les 2:00', 'yesterday at the same time');
4697 });
4698
4699 test('calendar next week', function (assert) {
4700 var i, m;
4701 for (i = 2; i < 7; i++) {
4702 m = moment().add({d: i});
4703 assert.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today + ' + i + ' days current time');
4704 m.hours(0).minutes(0).seconds(0).milliseconds(0);
4705 assert.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today + ' + i + ' days beginning of day');
4706 m.hours(23).minutes(59).seconds(59).milliseconds(999);
4707 assert.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today + ' + i + ' days end of day');
4708 }
4709 });
4710
4711 test('calendar last week', function (assert) {
4712 var i, m;
4713 for (i = 2; i < 7; i++) {
4714 m = moment().subtract({d: i});
4715 assert.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today - ' + i + ' days current time');
4716 m.hours(0).minutes(0).seconds(0).milliseconds(0);
4717 assert.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today - ' + i + ' days beginning of day');
4718 m.hours(23).minutes(59).seconds(59).milliseconds(999);
4719 assert.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today - ' + i + ' days end of day');
4720 }
4721 });
4722
4723 test('calendar all else', function (assert) {
4724 var weeksAgo = moment().subtract({w: 1}),
4725 weeksFromNow = moment().add({w: 1});
4726
4727 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
4728 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
4729
4730 weeksAgo = moment().subtract({w: 2});
4731 weeksFromNow = moment().add({w: 2});
4732
4733 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
4734 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
4735 });
4736
4737 test('weeks year starting sunday', function (assert) {
4738 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
4739 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
4740 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
4741 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
4742 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
4743 });
4744
4745 test('weeks year starting monday', function (assert) {
4746 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
4747 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
4748 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
4749 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
4750 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
4751 });
4752
4753 test('weeks year starting tuesday', function (assert) {
4754 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
4755 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
4756 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
4757 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
4758 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
4759 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
4760 });
4761
4762 test('weeks year starting wednesday', function (assert) {
4763 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
4764 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
4765 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
4766 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
4767 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
4768 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
4769 });
4770
4771 test('weeks year starting thursday', function (assert) {
4772 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
4773 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
4774 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
4775 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
4776 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
4777 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
4778 });
4779
4780 test('weeks year starting friday', function (assert) {
4781 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
4782 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
4783 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
4784 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
4785 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
4786 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
4787 });
4788
4789 test('weeks year starting saturday', function (assert) {
4790 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
4791 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
4792 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
4793 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
4794 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
4795 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
4796 });
4797
4798 test('weeks year starting sunday formatted', function (assert) {
4799 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
4800 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
4801 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1a', 'Jan 8 2012 should be week 1');
4802 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2a', 'Jan 9 2012 should be week 2');
4803 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
4804 });
4805
4806 test('lenient ordinal parsing', function (assert) {
4807 var i, ordinalStr, testMoment;
4808 for (i = 1; i <= 31; ++i) {
4809 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
4810 testMoment = moment(ordinalStr, 'YYYY MM Do');
4811 assert.equal(testMoment.year(), 2014,
4812 'lenient ordinal parsing ' + i + ' year check');
4813 assert.equal(testMoment.month(), 0,
4814 'lenient ordinal parsing ' + i + ' month check');
4815 assert.equal(testMoment.date(), i,
4816 'lenient ordinal parsing ' + i + ' date check');
4817 }
4818 });
4819
4820 test('lenient ordinal parsing of number', function (assert) {
4821 var i, testMoment;
4822 for (i = 1; i <= 31; ++i) {
4823 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
4824 assert.equal(testMoment.year(), 2014,
4825 'lenient ordinal parsing of number ' + i + ' year check');
4826 assert.equal(testMoment.month(), 0,
4827 'lenient ordinal parsing of number ' + i + ' month check');
4828 assert.equal(testMoment.date(), i,
4829 'lenient ordinal parsing of number ' + i + ' date check');
4830 }
4831 });
4832
4833 test('strict ordinal parsing', function (assert) {
4834 var i, ordinalStr, testMoment;
4835 for (i = 1; i <= 31; ++i) {
4836 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
4837 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
4838 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
4839 }
4840 });
4841
4842 }));
4843
4844 (function (global, factory) {
4845 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
4846 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
4847 factory(global.moment)
4848 }(this, function (moment) { 'use strict';
4849
4850 /*global QUnit:false*/
4851
4852 var test = QUnit.test;
4853
4854 function module (name, lifecycle) {
4855 QUnit.module(name, {
4856 setup : function () {
4857 moment.locale('en');
4858 moment.createFromInputFallback = function () {
4859 throw new Error('input not handled by moment');
4860 };
4861 if (lifecycle && lifecycle.setup) {
4862 lifecycle.setup();
4863 }
4864 },
4865 teardown : function () {
4866 if (lifecycle && lifecycle.teardown) {
4867 lifecycle.teardown();
4868 }
4869 }
4870 });
4871 }
4872
4873 function localeModule (name, lifecycle) {
4874 QUnit.module('locale:' + name, {
4875 setup : function () {
4876 moment.locale(name);
4877 moment.createFromInputFallback = function () {
4878 throw new Error('input not handled by moment');
4879 };
4880 if (lifecycle && lifecycle.setup) {
4881 lifecycle.setup();
4882 }
4883 },
4884 teardown : function () {
4885 moment.locale('en');
4886 if (lifecycle && lifecycle.teardown) {
4887 lifecycle.teardown();
4888 }
4889 }
4890 });
4891 }
4892
4893 localeModule('cs');
4894
4895 test('parse', function (assert) {
4896 var tests = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split('_'), i;
4897 function equalTest(input, mmm, monthIndex) {
4898 assert.equal(moment(input, mmm).month(), monthIndex, input + ' should be month ' + (monthIndex + 1));
4899 }
4900 for (i = 0; i < 12; i++) {
4901 tests[i] = tests[i].split(' ');
4902 equalTest(tests[i][0], 'MMM', i);
4903 equalTest(tests[i][1], 'MMM', i);
4904 equalTest(tests[i][0], 'MMMM', i);
4905 equalTest(tests[i][1], 'MMMM', i);
4906 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
4907 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
4908 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
4909 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
4910 }
4911 });
4912
4913 test('format', function (assert) {
4914 var a = [
4915 ['dddd, MMMM Do YYYY, h:mm:ss', 'neděle, únor 14. 2010, 3:25:50'],
4916 ['ddd, h', 'ne, 3'],
4917 ['M Mo MM MMMM MMM', '2 2. 02 únor úno'],
4918 ['YYYY YY', '2010 10'],
4919 ['D Do DD', '14 14. 14'],
4920 ['d do dddd ddd dd', '0 0. neděle ne ne'],
4921 ['DDD DDDo DDDD', '45 45. 045'],
4922 ['w wo ww', '6 6. 06'],
4923 ['h hh', '3 03'],
4924 ['H HH', '15 15'],
4925 ['m mm', '25 25'],
4926 ['s ss', '50 50'],
4927 ['a A', 'pm PM'],
4928 ['DDDo [den v roce]', '45. den v roce'],
4929 ['LTS', '15:25:50'],
4930 ['L', '14.02.2010'],
4931 ['LL', '14. únor 2010'],
4932 ['LLL', '14. únor 2010 15:25'],
4933 ['LLLL', 'neděle 14. únor 2010 15:25'],
4934 ['l', '14.2.2010'],
4935 ['ll', '14. úno 2010'],
4936 ['lll', '14. úno 2010 15:25'],
4937 ['llll', 'ne 14. úno 2010 15:25']
4938 ],
4939 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
4940 i;
4941 for (i = 0; i < a.length; i++) {
4942 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
4943 }
4944 });
4945
4946 test('format ordinal', function (assert) {
4947 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
4948 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
4949 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
4950 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
4951 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
4952 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
4953 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
4954 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
4955 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
4956 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
4957
4958 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
4959 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
4960 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
4961 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
4962 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
4963 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
4964 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
4965 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
4966 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
4967 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
4968
4969 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
4970 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
4971 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
4972 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
4973 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
4974 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
4975 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
4976 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
4977 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
4978 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
4979
4980 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
4981 });
4982
4983 test('format month', function (assert) {
4984 var expected = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split('_'), i;
4985 for (i = 0; i < expected.length; i++) {
4986 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
4987 }
4988 });
4989
4990 test('format week', function (assert) {
4991 var expected = 'neděle ne ne_pondělí po po_úterý út út_středa st st_čtvrtek čt čt_pátek pá pá_sobota so so'.split('_'), i;
4992 for (i = 0; i < expected.length; i++) {
4993 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
4994 }
4995 });
4996
4997 test('from', function (assert) {
4998 var start = moment([2007, 1, 28]);
4999 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'pár sekund', '44 seconds = a few seconds');
5000 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuta', '45 seconds = a minute');
5001 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuta', '89 seconds = a minute');
5002 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuty', '90 seconds = 2 minutes');
5003 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minut', '44 minutes = 44 minutes');
5004 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'hodina', '45 minutes = an hour');
5005 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'hodina', '89 minutes = an hour');
5006 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hodiny', '90 minutes = 2 hours');
5007 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hodin', '5 hours = 5 hours');
5008 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hodin', '21 hours = 21 hours');
5009 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'den', '22 hours = a day');
5010 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'den', '35 hours = a day');
5011 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dny', '36 hours = 2 days');
5012 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'den', '1 day = a day');
5013 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dní', '5 days = 5 days');
5014 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dní', '25 days = 25 days');
5015 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'měsíc', '26 days = a month');
5016 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'měsíc', '30 days = a month');
5017 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'měsíc', '43 days = a month');
5018 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 měsíce', '46 days = 2 months');
5019 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 měsíce', '75 days = 2 months');
5020 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 měsíce', '76 days = 3 months');
5021 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'měsíc', '1 month = a month');
5022 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 měsíců', '5 months = 5 months');
5023 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'rok', '345 days = a year');
5024 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 roky', '548 days = 2 years');
5025 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'rok', '1 year = a year');
5026 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 let', '5 years = 5 years');
5027 });
5028
5029 test('suffix', function (assert) {
5030 assert.equal(moment(30000).from(0), 'za pár sekund', 'prefix');
5031 assert.equal(moment(0).from(30000), 'před pár sekundami', 'suffix');
5032 });
5033
5034 test('now from now', function (assert) {
5035 assert.equal(moment().fromNow(), 'před pár sekundami', 'now from now should display as in the past');
5036 });
5037
5038 test('fromNow (future)', function (assert) {
5039 assert.equal(moment().add({s: 30}).fromNow(), 'za pár sekund', 'in a few seconds');
5040 assert.equal(moment().add({m: 1}).fromNow(), 'za minutu', 'in a minute');
5041 assert.equal(moment().add({m: 3}).fromNow(), 'za 3 minuty', 'in 3 minutes');
5042 assert.equal(moment().add({m: 10}).fromNow(), 'za 10 minut', 'in 10 minutes');
5043 assert.equal(moment().add({h: 1}).fromNow(), 'za hodinu', 'in an hour');
5044 assert.equal(moment().add({h: 3}).fromNow(), 'za 3 hodiny', 'in 3 hours');
5045 assert.equal(moment().add({h: 10}).fromNow(), 'za 10 hodin', 'in 10 hours');
5046 assert.equal(moment().add({d: 1}).fromNow(), 'za den', 'in a day');
5047 assert.equal(moment().add({d: 3}).fromNow(), 'za 3 dny', 'in 3 days');
5048 assert.equal(moment().add({d: 10}).fromNow(), 'za 10 dní', 'in 10 days');
5049 assert.equal(moment().add({M: 1}).fromNow(), 'za měsíc', 'in a month');
5050 assert.equal(moment().add({M: 3}).fromNow(), 'za 3 měsíce', 'in 3 months');
5051 assert.equal(moment().add({M: 10}).fromNow(), 'za 10 měsíců', 'in 10 months');
5052 assert.equal(moment().add({y: 1}).fromNow(), 'za rok', 'in a year');
5053 assert.equal(moment().add({y: 3}).fromNow(), 'za 3 roky', 'in 3 years');
5054 assert.equal(moment().add({y: 10}).fromNow(), 'za 10 let', 'in 10 years');
5055 });
5056
5057 test('fromNow (past)', function (assert) {
5058 assert.equal(moment().subtract({s: 30}).fromNow(), 'před pár sekundami', 'a few seconds ago');
5059 assert.equal(moment().subtract({m: 1}).fromNow(), 'před minutou', 'a minute ago');
5060 assert.equal(moment().subtract({m: 3}).fromNow(), 'před 3 minutami', '3 minutes ago');
5061 assert.equal(moment().subtract({m: 10}).fromNow(), 'před 10 minutami', '10 minutes ago');
5062 assert.equal(moment().subtract({h: 1}).fromNow(), 'před hodinou', 'an hour ago');
5063 assert.equal(moment().subtract({h: 3}).fromNow(), 'před 3 hodinami', '3 hours ago');
5064 assert.equal(moment().subtract({h: 10}).fromNow(), 'před 10 hodinami', '10 hours ago');
5065 assert.equal(moment().subtract({d: 1}).fromNow(), 'před dnem', 'a day ago');
5066 assert.equal(moment().subtract({d: 3}).fromNow(), 'před 3 dny', '3 days ago');
5067 assert.equal(moment().subtract({d: 10}).fromNow(), 'před 10 dny', '10 days ago');
5068 assert.equal(moment().subtract({M: 1}).fromNow(), 'před měsícem', 'a month ago');
5069 assert.equal(moment().subtract({M: 3}).fromNow(), 'před 3 měsíci', '3 months ago');
5070 assert.equal(moment().subtract({M: 10}).fromNow(), 'před 10 měsíci', '10 months ago');
5071 assert.equal(moment().subtract({y: 1}).fromNow(), 'před rokem', 'a year ago');
5072 assert.equal(moment().subtract({y: 3}).fromNow(), 'před 3 lety', '3 years ago');
5073 assert.equal(moment().subtract({y: 10}).fromNow(), 'před 10 lety', '10 years ago');
5074 });
5075
5076 test('calendar day', function (assert) {
5077 var a = moment().hours(2).minutes(0).seconds(0);
5078
5079 assert.equal(moment(a).calendar(), 'dnes v 2:00', 'today at the same time');
5080 assert.equal(moment(a).add({m: 25}).calendar(), 'dnes v 2:25', 'Now plus 25 min');
5081 assert.equal(moment(a).add({h: 1}).calendar(), 'dnes v 3:00', 'Now plus 1 hour');
5082 assert.equal(moment(a).add({d: 1}).calendar(), 'zítra v 2:00', 'tomorrow at the same time');
5083 assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes v 1:00', 'Now minus 1 hour');
5084 assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera v 2:00', 'yesterday at the same time');
5085 });
5086
5087 test('calendar next week', function (assert) {
5088 var i, m, nextDay;
5089 for (i = 2; i < 7; i++) {
5090 m = moment().add({d: i});
5091 nextDay = '';
5092 switch (m.day()) {
5093 case 0:
5094 nextDay = 'v neděli';
5095 break;
5096 case 1:
5097 nextDay = 'v pondělí';
5098 break;
5099 case 2:
5100 nextDay = 'v úterý';
5101 break;
5102 case 3:
5103 nextDay = 've středu';
5104 break;
5105 case 4:
5106 nextDay = 've čtvrtek';
5107 break;
5108 case 5:
5109 nextDay = 'v pátek';
5110 break;
5111 case 6:
5112 nextDay = 'v sobotu';
5113 break;
5114 }
5115 assert.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), 'Today + ' + i + ' days current time');
5116 m.hours(0).minutes(0).seconds(0).milliseconds(0);
5117 assert.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), 'Today + ' + i + ' days beginning of day');
5118 m.hours(23).minutes(59).seconds(59).milliseconds(999);
5119 assert.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), 'Today + ' + i + ' days end of day');
5120 }
5121 });
5122
5123 test('calendar last week', function (assert) {
5124 var i, m, lastDay;
5125 for (i = 2; i < 7; i++) {
5126 m = moment().subtract({d: i});
5127 lastDay = '';
5128 switch (m.day()) {
5129 case 0:
5130 lastDay = 'minulou neděli';
5131 break;
5132 case 1:
5133 lastDay = 'minulé pondělí';
5134 break;
5135 case 2:
5136 lastDay = 'minulé úterý';
5137 break;
5138 case 3:
5139 lastDay = 'minulou středu';
5140 break;
5141 case 4:
5142 lastDay = 'minulý čtvrtek';
5143 break;
5144 case 5:
5145 lastDay = 'minulý pátek';
5146 break;
5147 case 6:
5148 lastDay = 'minulou sobotu';
5149 break;
5150 }
5151 assert.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), 'Today - ' + i + ' days current time');
5152 m.hours(0).minutes(0).seconds(0).milliseconds(0);
5153 assert.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), 'Today - ' + i + ' days beginning of day');
5154 m.hours(23).minutes(59).seconds(59).milliseconds(999);
5155 assert.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), 'Today - ' + i + ' days end of day');
5156 }
5157 });
5158
5159 test('calendar all else', function (assert) {
5160 var weeksAgo = moment().subtract({w: 1}),
5161 weeksFromNow = moment().add({w: 1});
5162
5163 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
5164 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
5165
5166 weeksAgo = moment().subtract({w: 2});
5167 weeksFromNow = moment().add({w: 2});
5168
5169 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
5170 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
5171 });
5172
5173 test('humanize duration', function (assert) {
5174 assert.equal(moment.duration(1, 'minutes').humanize(), 'minuta', 'a minute (future)');
5175 assert.equal(moment.duration(1, 'minutes').humanize(true), 'za minutu', 'in a minute');
5176 assert.equal(moment.duration(-1, 'minutes').humanize(), 'minuta', 'a minute (past)');
5177 assert.equal(moment.duration(-1, 'minutes').humanize(true), 'před minutou', 'a minute ago');
5178 });
5179
5180 test('weeks year starting sunday', function (assert) {
5181 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
5182 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
5183 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
5184 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
5185 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
5186 });
5187
5188 test('weeks year starting monday', function (assert) {
5189 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
5190 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
5191 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
5192 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
5193 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
5194 });
5195
5196 test('weeks year starting tuesday', function (assert) {
5197 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
5198 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
5199 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
5200 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
5201 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
5202 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
5203 });
5204
5205 test('weeks year starting wednesday', function (assert) {
5206 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
5207 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
5208 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
5209 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
5210 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
5211 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
5212 });
5213
5214 test('weeks year starting thursday', function (assert) {
5215 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
5216 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
5217 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
5218 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
5219 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
5220 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
5221 });
5222
5223 test('weeks year starting friday', function (assert) {
5224 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
5225 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
5226 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
5227 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
5228 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
5229 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
5230 });
5231
5232 test('weeks year starting saturday', function (assert) {
5233 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
5234 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
5235 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
5236 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
5237 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
5238 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
5239 });
5240
5241 test('weeks year starting sunday formatted', function (assert) {
5242 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
5243 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
5244 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
5245 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
5246 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
5247 });
5248
5249 test('lenient ordinal parsing', function (assert) {
5250 var i, ordinalStr, testMoment;
5251 for (i = 1; i <= 31; ++i) {
5252 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
5253 testMoment = moment(ordinalStr, 'YYYY MM Do');
5254 assert.equal(testMoment.year(), 2014,
5255 'lenient ordinal parsing ' + i + ' year check');
5256 assert.equal(testMoment.month(), 0,
5257 'lenient ordinal parsing ' + i + ' month check');
5258 assert.equal(testMoment.date(), i,
5259 'lenient ordinal parsing ' + i + ' date check');
5260 }
5261 });
5262
5263 test('lenient ordinal parsing of number', function (assert) {
5264 var i, testMoment;
5265 for (i = 1; i <= 31; ++i) {
5266 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
5267 assert.equal(testMoment.year(), 2014,
5268 'lenient ordinal parsing of number ' + i + ' year check');
5269 assert.equal(testMoment.month(), 0,
5270 'lenient ordinal parsing of number ' + i + ' month check');
5271 assert.equal(testMoment.date(), i,
5272 'lenient ordinal parsing of number ' + i + ' date check');
5273 }
5274 });
5275
5276 test('strict ordinal parsing', function (assert) {
5277 var i, ordinalStr, testMoment;
5278 for (i = 1; i <= 31; ++i) {
5279 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
5280 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
5281 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
5282 }
5283 });
5284
5285 }));
5286
5287 (function (global, factory) {
5288 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
5289 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
5290 factory(global.moment)
5291 }(this, function (moment) { 'use strict';
5292
5293 /*global QUnit:false*/
5294
5295 var test = QUnit.test;
5296
5297 function module (name, lifecycle) {
5298 QUnit.module(name, {
5299 setup : function () {
5300 moment.locale('en');
5301 moment.createFromInputFallback = function () {
5302 throw new Error('input not handled by moment');
5303 };
5304 if (lifecycle && lifecycle.setup) {
5305 lifecycle.setup();
5306 }
5307 },
5308 teardown : function () {
5309 if (lifecycle && lifecycle.teardown) {
5310 lifecycle.teardown();
5311 }
5312 }
5313 });
5314 }
5315
5316 function localeModule (name, lifecycle) {
5317 QUnit.module('locale:' + name, {
5318 setup : function () {
5319 moment.locale(name);
5320 moment.createFromInputFallback = function () {
5321 throw new Error('input not handled by moment');
5322 };
5323 if (lifecycle && lifecycle.setup) {
5324 lifecycle.setup();
5325 }
5326 },
5327 teardown : function () {
5328 moment.locale('en');
5329 if (lifecycle && lifecycle.teardown) {
5330 lifecycle.teardown();
5331 }
5332 }
5333 });
5334 }
5335
5336 localeModule('cv');
5337
5338 test('parse', function (assert) {
5339 var tests = 'кӑрлач кӑр_нарӑс нар_пуш пуш_ака ака_май май_ҫӗртме ҫӗр_утӑ утӑ_ҫурла ҫур_авӑн авн_юпа юпа_чӳк чӳк_раштав раш'.split('_'), i;
5340 function equalTest(input, mmm, i) {
5341 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
5342 }
5343 for (i = 0; i < 12; i++) {
5344 tests[i] = tests[i].split(' ');
5345 equalTest(tests[i][0], 'MMM', i);
5346 equalTest(tests[i][1], 'MMM', i);
5347 equalTest(tests[i][0], 'MMMM', i);
5348 equalTest(tests[i][1], 'MMMM', i);
5349 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
5350 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
5351 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
5352 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
5353 }
5354 });
5355
5356 test('format', function (assert) {
5357 var a = [
5358 ['dddd, MMMM Do YYYY, h:mm:ss a', 'вырсарникун, нарӑс 14-мӗш 2010, 3:25:50 pm'],
5359 ['ddd, hA', 'выр, 3PM'],
5360 ['M Mo MM MMMM MMM', '2 2-мӗш 02 нарӑс нар'],
5361 ['YYYY YY', '2010 10'],
5362 ['D Do DD', '14 14-мӗш 14'],
5363 ['d do dddd ddd dd', '0 0-мӗш вырсарникун выр вр'],
5364 ['DDD DDDo DDDD', '45 45-мӗш 045'],
5365 ['w wo ww', '7 7-мӗш 07'],
5366 ['h hh', '3 03'],
5367 ['H HH', '15 15'],
5368 ['m mm', '25 25'],
5369 ['s ss', '50 50'],
5370 ['a A', 'pm PM'],
5371 ['Ҫулӑн DDDo кунӗ', 'Ҫулӑн 45-мӗш кунӗ'],
5372 ['LTS', '15:25:50'],
5373 ['L', '14-02-2010'],
5374 ['LL', '2010 ҫулхи нарӑс уйӑхӗн 14-мӗшӗ'],
5375 ['LLL', '2010 ҫулхи нарӑс уйӑхӗн 14-мӗшӗ, 15:25'],
5376 ['LLLL', 'вырсарникун, 2010 ҫулхи нарӑс уйӑхӗн 14-мӗшӗ, 15:25'],
5377 ['l', '14-2-2010'],
5378 ['ll', '2010 ҫулхи нар уйӑхӗн 14-мӗшӗ'],
5379 ['lll', '2010 ҫулхи нар уйӑхӗн 14-мӗшӗ, 15:25'],
5380 ['llll', 'выр, 2010 ҫулхи нар уйӑхӗн 14-мӗшӗ, 15:25']
5381 ],
5382 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
5383 i;
5384 for (i = 0; i < a.length; i++) {
5385 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
5386 }
5387 });
5388
5389 test('format ordinal', function (assert) {
5390 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-мӗш', '1-мӗш');
5391 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-мӗш', '2-мӗш');
5392 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-мӗш', '3-мӗш');
5393 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-мӗш', '4-мӗш');
5394 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-мӗш', '5-мӗш');
5395 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-мӗш', '6-мӗш');
5396 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-мӗш', '7-мӗш');
5397 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-мӗш', '8-мӗш');
5398 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-мӗш', '9-мӗш');
5399 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-мӗш', '10-мӗш');
5400
5401 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-мӗш', '11-мӗш');
5402 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-мӗш', '12-мӗш');
5403 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-мӗш', '13-мӗш');
5404 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-мӗш', '14-мӗш');
5405 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-мӗш', '15-мӗш');
5406 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-мӗш', '16-мӗш');
5407 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-мӗш', '17-мӗш');
5408 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-мӗш', '18-мӗш');
5409 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-мӗш', '19-мӗш');
5410 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-мӗш', '20-мӗш');
5411
5412 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-мӗш', '21-мӗш');
5413 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-мӗш', '22-мӗш');
5414 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-мӗш', '23-мӗш');
5415 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-мӗш', '24-мӗш');
5416 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-мӗш', '25-мӗш');
5417 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-мӗш', '26-мӗш');
5418 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-мӗш', '27-мӗш');
5419 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-мӗш', '28-мӗш');
5420 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-мӗш', '29-мӗш');
5421 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-мӗш', '30-мӗш');
5422
5423 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-мӗш', '31-мӗш');
5424 });
5425
5426 test('format month', function (assert) {
5427 var expected = 'кӑрлач кӑр_нарӑс нар_пуш пуш_ака ака_май май_ҫӗртме ҫӗр_утӑ утӑ_ҫурла ҫур_авӑн авн_юпа юпа_чӳк чӳк_раштав раш'.split('_'), i;
5428 for (i = 0; i < expected.length; i++) {
5429 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
5430 }
5431 });
5432
5433 test('format week', function (assert) {
5434 var expected = 'вырсарникун выр вр_тунтикун тун тн_ытларикун ытл ыт_юнкун юн юн_кӗҫнерникун кӗҫ кҫ_эрнекун эрн эр_шӑматкун шӑм шм'.split('_'), i;
5435 for (i = 0; i < expected.length; i++) {
5436 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
5437 }
5438 });
5439
5440 test('from', function (assert) {
5441 var start = moment([2007, 1, 28]);
5442 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'пӗр-ик ҫеккунт', '44 sekunder = a few seconds');
5443 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'пӗр минут', '45 seconds = a minute');
5444 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'пӗр минут', '89 seconds = a minute');
5445 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минут', '90 seconds = 2 minutes');
5446 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минут', '44 minutes = 44 minutes');
5447 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'пӗр сехет', '45 minutes = an hour');
5448 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'пӗр сехет', '89 minutes = an hour');
5449 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 сехет', '90 minutes = 2 hours');
5450 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 сехет', '5 hours = 5 hours');
5451 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 сехет', '21 hours = 21 hours');
5452 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'пӗр кун', '22 hours = a day');
5453 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'пӗр кун', '35 hours = a day');
5454 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 кун', '36 hours = 2 days');
5455 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'пӗр кун', '1 day = a day');
5456 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 кун', '5 days = 5 days');
5457 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 кун', '25 days = 25 days');
5458 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'пӗр уйӑх', '26 days = a month');
5459 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'пӗр уйӑх', '30 days = a month');
5460 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'пӗр уйӑх', '43 days = a month');
5461 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 уйӑх', '46 days = 2 months');
5462 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 уйӑх', '75 days = 2 months');
5463 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 уйӑх', '76 days = 3 months');
5464 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'пӗр уйӑх', '1 month = a month');
5465 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 уйӑх', '5 months = 5 months');
5466 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'пӗр ҫул', '345 days = a year');
5467 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ҫул', '548 days = 2 years');
5468 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'пӗр ҫул', '1 year = a year');
5469 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ҫул', '5 years = 5 years');
5470 });
5471
5472 test('suffix', function (assert) {
5473 assert.equal(moment(30000).from(0), 'пӗр-ик ҫеккунтран', 'prefix');
5474 assert.equal(moment(0).from(30000), 'пӗр-ик ҫеккунт каялла', 'suffix');
5475 });
5476
5477 test('now from now', function (assert) {
5478 assert.equal(moment().fromNow(), 'пӗр-ик ҫеккунт каялла', 'now from now should display as in the past');
5479 });
5480
5481 test('fromNow', function (assert) {
5482 assert.equal(moment().add({s: 30}).fromNow(), 'пӗр-ик ҫеккунтран', 'in a few seconds');
5483 assert.equal(moment().add({d: 5}).fromNow(), '5 кунран', 'in 5 days');
5484 assert.equal(moment().add({h: 2}).fromNow(), '2 сехетрен', 'in 2 hours, the right suffix!');
5485 assert.equal(moment().add({y: 3}).fromNow(), '3 ҫултан', 'in 3 years, the right suffix!');
5486 });
5487
5488 test('calendar day', function (assert) {
5489 var a = moment().hours(2).minutes(0).seconds(0);
5490 assert.equal(moment(a).calendar(), 'Паян 02:00 сехетре', 'today at the same time');
5491 assert.equal(moment(a).add({m: 25}).calendar(), 'Паян 02:25 сехетре', 'Now plus 25 min');
5492 assert.equal(moment(a).add({h: 1}).calendar(), 'Паян 03:00 сехетре', 'Now plus 1 hour');
5493 assert.equal(moment(a).add({d: 1}).calendar(), 'Ыран 02:00 сехетре', 'tomorrow at the same time');
5494 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Паян 01:00 сехетре', 'Now minus 1 hour');
5495 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ӗнер 02:00 сехетре', 'yesterday at the same time');
5496 });
5497
5498 test('calendar next week', function (assert) {
5499 var i, m;
5500
5501 for (i = 2; i < 7; i++) {
5502 m = moment().add({d: i});
5503 assert.equal(m.calendar(), m.format('[Ҫитес] dddd LT [сехетре]'), 'Today + ' + i + ' days current time');
5504 m.hours(0).minutes(0).seconds(0).milliseconds(0);
5505 assert.equal(m.calendar(), m.format('[Ҫитес] dddd LT [сехетре]'), 'Today + ' + i + ' days beginning of day');
5506 m.hours(23).minutes(59).seconds(59).milliseconds(999);
5507 assert.equal(m.calendar(), m.format('[Ҫитес] dddd LT [сехетре]'), 'Today + ' + i + ' days end of day');
5508 }
5509 });
5510
5511 test('calendar last week', function (assert) {
5512 var i, m;
5513
5514 for (i = 2; i < 7; i++) {
5515 m = moment().subtract({d: i});
5516 assert.equal(m.calendar(), m.format('[Иртнӗ] dddd LT [сехетре]'), 'Today - ' + i + ' days current time');
5517 m.hours(0).minutes(0).seconds(0).milliseconds(0);
5518 assert.equal(m.calendar(), m.format('[Иртнӗ] dddd LT [сехетре]'), 'Today - ' + i + ' days beginning of day');
5519 m.hours(23).minutes(59).seconds(59).milliseconds(999);
5520 assert.equal(m.calendar(), m.format('[Иртнӗ] dddd LT [сехетре]'), 'Today - ' + i + ' days end of day');
5521 }
5522 });
5523
5524 test('calendar all else', function (assert) {
5525 var weeksAgo = moment().subtract({w: 1}),
5526 weeksFromNow = moment().add({w: 1});
5527
5528 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
5529 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
5530
5531 weeksAgo = moment().subtract({w: 2});
5532 weeksFromNow = moment().add({w: 2});
5533
5534 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
5535 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
5536 });
5537
5538 // Monday is the first day of the week.
5539 // The week that contains Jan 1st is the first week of the year.
5540
5541 test('weeks year starting sunday', function (assert) {
5542 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
5543 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
5544 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
5545 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
5546 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
5547 });
5548
5549 test('weeks year starting monday', function (assert) {
5550 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
5551 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
5552 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
5553 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
5554 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
5555 });
5556
5557 test('weeks year starting tuesday', function (assert) {
5558 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
5559 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
5560 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
5561 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
5562 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
5563 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
5564 });
5565
5566 test('weeks year starting wednesday', function (assert) {
5567 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
5568 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
5569 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
5570 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
5571 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
5572 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
5573 });
5574
5575 test('weeks year starting thursday', function (assert) {
5576 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
5577 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
5578 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
5579 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
5580 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
5581 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
5582 });
5583
5584 test('weeks year starting friday', function (assert) {
5585 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
5586 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
5587 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
5588 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
5589 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
5590 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
5591 });
5592
5593 test('weeks year starting saturday', function (assert) {
5594 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
5595 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
5596 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
5597 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
5598 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
5599 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
5600 });
5601
5602 test('weeks year starting sunday formatted', function (assert) {
5603 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-мӗш', 'Dec 26 2011 should be week 1');
5604 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-мӗш', 'Jan 1 2012 should be week 1');
5605 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-мӗш', 'Jan 2 2012 should be week 2');
5606 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-мӗш', 'Jan 8 2012 should be week 2');
5607 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-мӗш', 'Jan 9 2012 should be week 3');
5608 });
5609
5610 test('lenient ordinal parsing', function (assert) {
5611 var i, ordinalStr, testMoment;
5612 for (i = 1; i <= 31; ++i) {
5613 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
5614 testMoment = moment(ordinalStr, 'YYYY MM Do');
5615 assert.equal(testMoment.year(), 2014,
5616 'lenient ordinal parsing ' + i + ' year check');
5617 assert.equal(testMoment.month(), 0,
5618 'lenient ordinal parsing ' + i + ' month check');
5619 assert.equal(testMoment.date(), i,
5620 'lenient ordinal parsing ' + i + ' date check');
5621 }
5622 });
5623
5624 test('lenient ordinal parsing of number', function (assert) {
5625 var i, testMoment;
5626 for (i = 1; i <= 31; ++i) {
5627 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
5628 assert.equal(testMoment.year(), 2014,
5629 'lenient ordinal parsing of number ' + i + ' year check');
5630 assert.equal(testMoment.month(), 0,
5631 'lenient ordinal parsing of number ' + i + ' month check');
5632 assert.equal(testMoment.date(), i,
5633 'lenient ordinal parsing of number ' + i + ' date check');
5634 }
5635 });
5636
5637 test('strict ordinal parsing', function (assert) {
5638 var i, ordinalStr, testMoment;
5639 for (i = 1; i <= 31; ++i) {
5640 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
5641 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
5642 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
5643 }
5644 });
5645
5646 }));
5647
5648 (function (global, factory) {
5649 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
5650 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
5651 factory(global.moment)
5652 }(this, function (moment) { 'use strict';
5653
5654 /*global QUnit:false*/
5655
5656 var test = QUnit.test;
5657
5658 function module (name, lifecycle) {
5659 QUnit.module(name, {
5660 setup : function () {
5661 moment.locale('en');
5662 moment.createFromInputFallback = function () {
5663 throw new Error('input not handled by moment');
5664 };
5665 if (lifecycle && lifecycle.setup) {
5666 lifecycle.setup();
5667 }
5668 },
5669 teardown : function () {
5670 if (lifecycle && lifecycle.teardown) {
5671 lifecycle.teardown();
5672 }
5673 }
5674 });
5675 }
5676
5677 function localeModule (name, lifecycle) {
5678 QUnit.module('locale:' + name, {
5679 setup : function () {
5680 moment.locale(name);
5681 moment.createFromInputFallback = function () {
5682 throw new Error('input not handled by moment');
5683 };
5684 if (lifecycle && lifecycle.setup) {
5685 lifecycle.setup();
5686 }
5687 },
5688 teardown : function () {
5689 moment.locale('en');
5690 if (lifecycle && lifecycle.teardown) {
5691 lifecycle.teardown();
5692 }
5693 }
5694 });
5695 }
5696
5697 localeModule('cy');
5698
5699 test('parse', function (assert) {
5700 var tests = 'Ionawr Ion_Chwefror Chwe_Mawrth Maw_Ebrill Ebr_Mai Mai_Mehefin Meh_Gorffennaf Gor_Awst Aws_Medi Med_Hydref Hyd_Tachwedd Tach_Rhagfyr Rhag'.split('_'),
5701 i;
5702 function equalTest(input, mmm, i) {
5703 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
5704 }
5705 for (i = 0; i < 12; i++) {
5706 tests[i] = tests[i].split(' ');
5707 equalTest(tests[i][0], 'MMM', i);
5708 equalTest(tests[i][1], 'MMM', i);
5709 equalTest(tests[i][0], 'MMMM', i);
5710 equalTest(tests[i][1], 'MMMM', i);
5711 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
5712 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
5713 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
5714 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
5715 }
5716 });
5717
5718 test('format', function (assert) {
5719 var a = [
5720 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Dydd Sul, Chwefror 14eg 2010, 3:25:50 pm'],
5721 ['ddd, hA', 'Sul, 3PM'],
5722 ['M Mo MM MMMM MMM', '2 2il 02 Chwefror Chwe'],
5723 ['YYYY YY', '2010 10'],
5724 ['D Do DD', '14 14eg 14'],
5725 ['d do dddd ddd dd', '0 0 Dydd Sul Sul Su'],
5726 ['DDD DDDo DDDD', '45 45ain 045'],
5727 ['w wo ww', '6 6ed 06'],
5728 ['h hh', '3 03'],
5729 ['H HH', '15 15'],
5730 ['m mm', '25 25'],
5731 ['s ss', '50 50'],
5732 ['a A', 'pm PM'],
5733 ['[the] DDDo [day of the year]', 'the 45ain day of the year'],
5734 ['LTS', '15:25:50'],
5735 ['L', '14/02/2010'],
5736 ['LL', '14 Chwefror 2010'],
5737 ['LLL', '14 Chwefror 2010 15:25'],
5738 ['LLLL', 'Dydd Sul, 14 Chwefror 2010 15:25'],
5739 ['l', '14/2/2010'],
5740 ['ll', '14 Chwe 2010'],
5741 ['lll', '14 Chwe 2010 15:25'],
5742 ['llll', 'Sul, 14 Chwe 2010 15:25']
5743 ],
5744 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
5745 i;
5746 for (i = 0; i < a.length; i++) {
5747 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
5748 }
5749 });
5750
5751 test('format ordinal', function (assert) {
5752 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1af', '1af');
5753 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2il', '2il');
5754 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3ydd', '3ydd');
5755 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4ydd', '4ydd');
5756 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5ed', '5ed');
5757 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6ed', '6ed');
5758 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7ed', '7ed');
5759 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8fed', '8fed');
5760 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9fed', '9fed');
5761 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10fed', '10fed');
5762
5763 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11eg', '11eg');
5764 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12fed', '12fed');
5765 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13eg', '13eg');
5766 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14eg', '14eg');
5767 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15fed', '15fed');
5768 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16eg', '16eg');
5769 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17eg', '17eg');
5770 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18fed', '18fed');
5771 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19eg', '19eg');
5772 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20fed', '20fed');
5773
5774 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ain', '21ain');
5775 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ain', '22ain');
5776 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ain', '23ain');
5777 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ain', '24ain');
5778 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ain', '25ain');
5779 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ain', '26ain');
5780 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ain', '27ain');
5781 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ain', '28ain');
5782 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ain', '29ain');
5783 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ain', '30ain');
5784
5785 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ain', '31ain');
5786 });
5787
5788 test('format month', function (assert) {
5789 var expected = 'Ionawr Ion_Chwefror Chwe_Mawrth Maw_Ebrill Ebr_Mai Mai_Mehefin Meh_Gorffennaf Gor_Awst Aws_Medi Med_Hydref Hyd_Tachwedd Tach_Rhagfyr Rhag'.split('_'), i;
5790 for (i = 0; i < expected.length; i++) {
5791 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
5792 }
5793 });
5794
5795 test('format week', function (assert) {
5796 var expected = 'Dydd Sul Sul Su_Dydd Llun Llun Ll_Dydd Mawrth Maw Ma_Dydd Mercher Mer Me_Dydd Iau Iau Ia_Dydd Gwener Gwe Gw_Dydd Sadwrn Sad Sa'.split('_'), i;
5797 for (i = 0; i < expected.length; i++) {
5798 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
5799 }
5800 });
5801
5802 test('from', function (assert) {
5803 var start = moment([2007, 1, 28]);
5804 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ychydig eiliadau', '44 seconds = a few seconds');
5805 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'munud', '45 seconds = a minute');
5806 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'munud', '89 seconds = a minute');
5807 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 munud', '90 seconds = 2 minutes');
5808 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 munud', '44 minutes = 44 minutes');
5809 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'awr', '45 minutes = an hour');
5810 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'awr', '89 minutes = an hour');
5811 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 awr', '90 minutes = 2 hours');
5812 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 awr', '5 hours = 5 hours');
5813 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 awr', '21 hours = 21 hours');
5814 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'diwrnod', '22 hours = a day');
5815 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'diwrnod', '35 hours = a day');
5816 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 diwrnod', '36 hours = 2 days');
5817 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'diwrnod', '1 day = a day');
5818 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 diwrnod', '5 days = 5 days');
5819 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 diwrnod', '25 days = 25 days');
5820 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mis', '26 days = a month');
5821 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mis', '30 days = a month');
5822 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mis', '43 days = a month');
5823 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mis', '46 days = 2 months');
5824 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mis', '75 days = 2 months');
5825 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mis', '76 days = 3 months');
5826 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mis', '1 month = a month');
5827 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mis', '5 months = 5 months');
5828 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'blwyddyn', '345 days = a year');
5829 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 flynedd', '548 days = 2 years');
5830 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'blwyddyn', '1 year = a year');
5831 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 flynedd', '5 years = 5 years');
5832 });
5833
5834 test('suffix', function (assert) {
5835 assert.equal(moment(30000).from(0), 'mewn ychydig eiliadau', 'prefix');
5836 assert.equal(moment(0).from(30000), 'ychydig eiliadau yn ôl', 'suffix');
5837 });
5838
5839 test('fromNow', function (assert) {
5840 assert.equal(moment().add({s: 30}).fromNow(), 'mewn ychydig eiliadau', 'in a few seconds');
5841 assert.equal(moment().add({d: 5}).fromNow(), 'mewn 5 diwrnod', 'in 5 days');
5842 });
5843
5844 test('same day', function (assert) {
5845 var a = moment().hours(2).minutes(0).seconds(0);
5846
5847 assert.equal(moment(a).calendar(), 'Heddiw am 02:00', 'today at the same time');
5848 assert.equal(moment(a).add({m: 25}).calendar(), 'Heddiw am 02:25', 'Now plus 25 min');
5849 assert.equal(moment(a).add({h: 1}).calendar(), 'Heddiw am 03:00', 'Now plus 1 hour');
5850 assert.equal(moment(a).add({d: 1}).calendar(), 'Yfory am 02:00', 'tomorrow at the same time');
5851 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heddiw am 01:00', 'Now minus 1 hour');
5852 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ddoe am 02:00', 'yesterday at the same time');
5853 });
5854
5855 test('same next week', function (assert) {
5856 var i, m;
5857
5858 for (i = 2; i < 7; i++) {
5859 m = moment().add({d: i});
5860 assert.equal(m.calendar(), m.format('dddd [am] LT'), 'Today + ' + i + ' days current time');
5861 m.hours(0).minutes(0).seconds(0).milliseconds(0);
5862 assert.equal(m.calendar(), m.format('dddd [am] LT'), 'Today + ' + i + ' days beginning of day');
5863 m.hours(23).minutes(59).seconds(59).milliseconds(999);
5864 assert.equal(m.calendar(), m.format('dddd [am] LT'), 'Today + ' + i + ' days end of day');
5865 }
5866 });
5867
5868 test('same last week', function (assert) {
5869 var i, m;
5870
5871 for (i = 2; i < 7; i++) {
5872 m = moment().subtract({d: i});
5873 assert.equal(m.calendar(), m.format('dddd [diwethaf am] LT'), 'Today - ' + i + ' days current time');
5874 m.hours(0).minutes(0).seconds(0).milliseconds(0);
5875 assert.equal(m.calendar(), m.format('dddd [diwethaf am] LT'), 'Today - ' + i + ' days beginning of day');
5876 m.hours(23).minutes(59).seconds(59).milliseconds(999);
5877 assert.equal(m.calendar(), m.format('dddd [diwethaf am] LT'), 'Today - ' + i + ' days end of day');
5878 }
5879 });
5880
5881 test('same all else', function (assert) {
5882 var weeksAgo = moment().subtract({w: 1}),
5883 weeksFromNow = moment().add({w: 1});
5884
5885 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
5886 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
5887
5888 weeksAgo = moment().subtract({w: 2});
5889 weeksFromNow = moment().add({w: 2});
5890
5891 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
5892 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
5893 });
5894
5895 test('weeks year starting sunday', function (assert) {
5896 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
5897 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
5898 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
5899 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
5900 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
5901 });
5902
5903 test('weeks year starting monday', function (assert) {
5904 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
5905 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
5906 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
5907 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
5908 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
5909 });
5910
5911 test('weeks year starting tuesday', function (assert) {
5912 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
5913 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
5914 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
5915 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
5916 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
5917 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
5918 });
5919
5920 test('weeks year starting wednesday', function (assert) {
5921 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
5922 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
5923 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
5924 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
5925 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
5926 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
5927 });
5928
5929 test('weeks year starting thursday', function (assert) {
5930 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
5931 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
5932 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
5933 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
5934 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
5935 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
5936 });
5937
5938 test('weeks year starting friday', function (assert) {
5939 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
5940 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
5941 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
5942 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
5943 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
5944 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
5945 });
5946
5947 test('weeks year starting saturday', function (assert) {
5948 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
5949 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
5950 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
5951 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
5952 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
5953 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
5954 });
5955
5956 test('weeks year starting sunday formatted', function (assert) {
5957 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ain', 'Jan 1 2012 should be week 52');
5958 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1af', 'Jan 2 2012 should be week 1');
5959 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1af', 'Jan 8 2012 should be week 1');
5960 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2il', 'Jan 9 2012 should be week 2');
5961 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2il', 'Jan 15 2012 should be week 2');
5962 });
5963
5964 test('lenient ordinal parsing', function (assert) {
5965 var i, ordinalStr, testMoment;
5966 for (i = 1; i <= 31; ++i) {
5967 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
5968 testMoment = moment(ordinalStr, 'YYYY MM Do');
5969 assert.equal(testMoment.year(), 2014,
5970 'lenient ordinal parsing ' + i + ' year check');
5971 assert.equal(testMoment.month(), 0,
5972 'lenient ordinal parsing ' + i + ' month check');
5973 assert.equal(testMoment.date(), i,
5974 'lenient ordinal parsing ' + i + ' date check');
5975 }
5976 });
5977
5978 test('lenient ordinal parsing of number', function (assert) {
5979 var i, testMoment;
5980 for (i = 1; i <= 31; ++i) {
5981 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
5982 assert.equal(testMoment.year(), 2014,
5983 'lenient ordinal parsing of number ' + i + ' year check');
5984 assert.equal(testMoment.month(), 0,
5985 'lenient ordinal parsing of number ' + i + ' month check');
5986 assert.equal(testMoment.date(), i,
5987 'lenient ordinal parsing of number ' + i + ' date check');
5988 }
5989 });
5990
5991 test('strict ordinal parsing', function (assert) {
5992 var i, ordinalStr, testMoment;
5993 for (i = 1; i <= 31; ++i) {
5994 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
5995 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
5996 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
5997 }
5998 });
5999
6000 }));
6001
6002 (function (global, factory) {
6003 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
6004 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
6005 factory(global.moment)
6006 }(this, function (moment) { 'use strict';
6007
6008 /*global QUnit:false*/
6009
6010 var test = QUnit.test;
6011
6012 function module (name, lifecycle) {
6013 QUnit.module(name, {
6014 setup : function () {
6015 moment.locale('en');
6016 moment.createFromInputFallback = function () {
6017 throw new Error('input not handled by moment');
6018 };
6019 if (lifecycle && lifecycle.setup) {
6020 lifecycle.setup();
6021 }
6022 },
6023 teardown : function () {
6024 if (lifecycle && lifecycle.teardown) {
6025 lifecycle.teardown();
6026 }
6027 }
6028 });
6029 }
6030
6031 function localeModule (name, lifecycle) {
6032 QUnit.module('locale:' + name, {
6033 setup : function () {
6034 moment.locale(name);
6035 moment.createFromInputFallback = function () {
6036 throw new Error('input not handled by moment');
6037 };
6038 if (lifecycle && lifecycle.setup) {
6039 lifecycle.setup();
6040 }
6041 },
6042 teardown : function () {
6043 moment.locale('en');
6044 if (lifecycle && lifecycle.teardown) {
6045 lifecycle.teardown();
6046 }
6047 }
6048 });
6049 }
6050
6051 localeModule('da');
6052
6053 test('parse', function (assert) {
6054 var tests = 'januar jan_februar feb_marts mar_april apr_maj maj_juni jun_juli jul_august aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
6055 function equalTest(input, mmm, i) {
6056 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
6057 }
6058 for (i = 0; i < 12; i++) {
6059 tests[i] = tests[i].split(' ');
6060 equalTest(tests[i][0], 'MMM', i);
6061 equalTest(tests[i][1], 'MMM', i);
6062 equalTest(tests[i][0], 'MMMM', i);
6063 equalTest(tests[i][1], 'MMMM', i);
6064 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
6065 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
6066 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
6067 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
6068 }
6069 });
6070
6071 test('format', function (assert) {
6072 var a = [
6073 ['dddd [den] Do MMMM YYYY, h:mm:ss a', 'søndag den 14. februar 2010, 3:25:50 pm'],
6074 ['ddd hA', 'søn 3PM'],
6075 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
6076 ['YYYY YY', '2010 10'],
6077 ['D Do DD', '14 14. 14'],
6078 ['d do dddd ddd dd', '0 0. søndag søn sø'],
6079 ['DDD DDDo DDDD', '45 45. 045'],
6080 ['w wo ww', '6 6. 06'],
6081 ['h hh', '3 03'],
6082 ['H HH', '15 15'],
6083 ['m mm', '25 25'],
6084 ['s ss', '50 50'],
6085 ['a A', 'pm PM'],
6086 ['[den] DDDo [dag på året]', 'den 45. dag på året'],
6087 ['LTS', '15:25:50'],
6088 ['L', '14/02/2010'],
6089 ['LL', '14. februar 2010'],
6090 ['LLL', '14. februar 2010 15:25'],
6091 ['LLLL', 'søndag d. 14. februar 2010 15:25'],
6092 ['l', '14/2/2010'],
6093 ['ll', '14. feb 2010'],
6094 ['lll', '14. feb 2010 15:25'],
6095 ['llll', 'søn d. 14. feb 2010 15:25']
6096 ],
6097 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
6098 i;
6099 for (i = 0; i < a.length; i++) {
6100 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
6101 }
6102 });
6103
6104 test('format ordinal', function (assert) {
6105 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
6106 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
6107 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
6108 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
6109 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
6110 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
6111 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
6112 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
6113 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
6114 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
6115
6116 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
6117 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
6118 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
6119 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
6120 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
6121 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
6122 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
6123 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
6124 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
6125 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
6126
6127 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
6128 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
6129 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
6130 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
6131 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
6132 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
6133 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
6134 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
6135 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
6136 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
6137
6138 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
6139 });
6140
6141 test('format month', function (assert) {
6142 var expected = 'januar jan_februar feb_marts mar_april apr_maj maj_juni jun_juli jul_august aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
6143 for (i = 0; i < expected.length; i++) {
6144 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
6145 }
6146 });
6147
6148 test('format week', function (assert) {
6149 var expected = 'søndag søn sø_mandag man ma_tirsdag tir ti_onsdag ons on_torsdag tor to_fredag fre fr_lørdag lør lø'.split('_'), i;
6150 for (i = 0; i < expected.length; i++) {
6151 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
6152 }
6153 });
6154
6155 test('from', function (assert) {
6156 var start = moment([2007, 1, 28]);
6157 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'få sekunder', '44 seconds = a few seconds');
6158 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'et minut', '45 seconds = a minute');
6159 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'et minut', '89 seconds = a minute');
6160 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutter', '90 seconds = 2 minutes');
6161 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutter', '44 minutes = 44 minutes');
6162 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'en time', '45 minutes = an hour');
6163 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'en time', '89 minutes = an hour');
6164 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timer', '90 minutes = 2 hours');
6165 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timer', '5 hours = 5 hours');
6166 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timer', '21 hours = 21 hours');
6167 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dag', '22 hours = a day');
6168 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dag', '35 hours = a day');
6169 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dage', '36 hours = 2 days');
6170 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dag', '1 day = a day');
6171 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dage', '5 days = 5 days');
6172 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dage', '25 days = 25 days');
6173 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en måned', '26 days = a month');
6174 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en måned', '30 days = a month');
6175 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en måned', '43 days = a month');
6176 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 måneder', '46 days = 2 months');
6177 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 måneder', '75 days = 2 months');
6178 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 måneder', '76 days = 3 months');
6179 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en måned', '1 month = a month');
6180 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 måneder', '5 months = 5 months');
6181 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'et år', '345 days = a year');
6182 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
6183 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'et år', '1 year = a year');
6184 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
6185 });
6186
6187 test('suffix', function (assert) {
6188 assert.equal(moment(30000).from(0), 'om få sekunder', 'prefix');
6189 assert.equal(moment(0).from(30000), 'få sekunder siden', 'suffix');
6190 });
6191
6192 test('now from now', function (assert) {
6193 assert.equal(moment().fromNow(), 'få sekunder siden', 'now from now should display as in the past');
6194 });
6195
6196 test('fromNow', function (assert) {
6197 assert.equal(moment().add({s: 30}).fromNow(), 'om få sekunder', 'in a few seconds');
6198 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dage', 'in 5 days');
6199 });
6200
6201 test('weeks year starting sunday', function (assert) {
6202 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
6203 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
6204 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
6205 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
6206 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
6207 });
6208
6209 test('weeks year starting monday', function (assert) {
6210 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
6211 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
6212 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
6213 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
6214 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
6215 });
6216
6217 test('weeks year starting tuesday', function (assert) {
6218 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
6219 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
6220 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
6221 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
6222 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
6223 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
6224 });
6225
6226 test('weeks year starting wednesday', function (assert) {
6227 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
6228 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
6229 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
6230 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
6231 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
6232 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
6233 });
6234
6235 test('weeks year starting thursday', function (assert) {
6236 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
6237 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
6238 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
6239 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
6240 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
6241 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
6242 });
6243
6244 test('weeks year starting friday', function (assert) {
6245 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
6246 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
6247 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
6248 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
6249 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
6250 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
6251 });
6252
6253 test('weeks year starting saturday', function (assert) {
6254 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
6255 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
6256 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
6257 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
6258 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
6259 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
6260 });
6261
6262 test('weeks year starting sunday formatted', function (assert) {
6263 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
6264 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
6265 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
6266 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
6267 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
6268 });
6269
6270 test('lenient ordinal parsing', function (assert) {
6271 var i, ordinalStr, testMoment;
6272 for (i = 1; i <= 31; ++i) {
6273 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
6274 testMoment = moment(ordinalStr, 'YYYY MM Do');
6275 assert.equal(testMoment.year(), 2014,
6276 'lenient ordinal parsing ' + i + ' year check');
6277 assert.equal(testMoment.month(), 0,
6278 'lenient ordinal parsing ' + i + ' month check');
6279 assert.equal(testMoment.date(), i,
6280 'lenient ordinal parsing ' + i + ' date check');
6281 }
6282 });
6283
6284 test('lenient ordinal parsing of number', function (assert) {
6285 var i, testMoment;
6286 for (i = 1; i <= 31; ++i) {
6287 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
6288 assert.equal(testMoment.year(), 2014,
6289 'lenient ordinal parsing of number ' + i + ' year check');
6290 assert.equal(testMoment.month(), 0,
6291 'lenient ordinal parsing of number ' + i + ' month check');
6292 assert.equal(testMoment.date(), i,
6293 'lenient ordinal parsing of number ' + i + ' date check');
6294 }
6295 });
6296
6297 test('strict ordinal parsing', function (assert) {
6298 var i, ordinalStr, testMoment;
6299 for (i = 1; i <= 31; ++i) {
6300 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
6301 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
6302 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
6303 }
6304 });
6305
6306 }));
6307
6308 (function (global, factory) {
6309 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
6310 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
6311 factory(global.moment)
6312 }(this, function (moment) { 'use strict';
6313
6314 /*global QUnit:false*/
6315
6316 var test = QUnit.test;
6317
6318 function module (name, lifecycle) {
6319 QUnit.module(name, {
6320 setup : function () {
6321 moment.locale('en');
6322 moment.createFromInputFallback = function () {
6323 throw new Error('input not handled by moment');
6324 };
6325 if (lifecycle && lifecycle.setup) {
6326 lifecycle.setup();
6327 }
6328 },
6329 teardown : function () {
6330 if (lifecycle && lifecycle.teardown) {
6331 lifecycle.teardown();
6332 }
6333 }
6334 });
6335 }
6336
6337 function localeModule (name, lifecycle) {
6338 QUnit.module('locale:' + name, {
6339 setup : function () {
6340 moment.locale(name);
6341 moment.createFromInputFallback = function () {
6342 throw new Error('input not handled by moment');
6343 };
6344 if (lifecycle && lifecycle.setup) {
6345 lifecycle.setup();
6346 }
6347 },
6348 teardown : function () {
6349 moment.locale('en');
6350 if (lifecycle && lifecycle.teardown) {
6351 lifecycle.teardown();
6352 }
6353 }
6354 });
6355 }
6356
6357 localeModule('de-at');
6358
6359 test('parse', function (assert) {
6360 var tests = 'Jänner Jän._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
6361
6362 function equalTest(input, mmm, i) {
6363 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
6364 }
6365
6366 for (i = 0; i < 12; i++) {
6367 tests[i] = tests[i].split(' ');
6368 equalTest(tests[i][0], 'MMM', i);
6369 equalTest(tests[i][1], 'MMM', i);
6370 equalTest(tests[i][0], 'MMMM', i);
6371 equalTest(tests[i][1], 'MMMM', i);
6372 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
6373 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
6374 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
6375 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
6376 }
6377 });
6378
6379 test('format', function (assert) {
6380 var a = [
6381 ['dddd, Do MMMM YYYY, h:mm:ss a', 'Sonntag, 14. Februar 2010, 3:25:50 pm'],
6382 ['ddd, hA', 'So., 3PM'],
6383 ['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
6384 ['YYYY YY', '2010 10'],
6385 ['D Do DD', '14 14. 14'],
6386 ['d do dddd ddd dd', '0 0. Sonntag So. So'],
6387 ['DDD DDDo DDDD', '45 45. 045'],
6388 ['w wo ww', '6 6. 06'],
6389 ['h hh', '3 03'],
6390 ['H HH', '15 15'],
6391 ['m mm', '25 25'],
6392 ['s ss', '50 50'],
6393 ['a A', 'pm PM'],
6394 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
6395 ['LTS', '15:25:50'],
6396 ['L', '14.02.2010'],
6397 ['LL', '14. Februar 2010'],
6398 ['LLL', '14. Februar 2010 15:25'],
6399 ['LLLL', 'Sonntag, 14. Februar 2010 15:25'],
6400 ['l', '14.2.2010'],
6401 ['ll', '14. Febr. 2010'],
6402 ['lll', '14. Febr. 2010 15:25'],
6403 ['llll', 'So., 14. Febr. 2010 15:25']
6404 ],
6405 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
6406 i;
6407 for (i = 0; i < a.length; i++) {
6408 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
6409 }
6410 });
6411
6412 test('format ordinal', function (assert) {
6413 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
6414 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
6415 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
6416 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
6417 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
6418 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
6419 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
6420 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
6421 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
6422 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
6423
6424 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
6425 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
6426 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
6427 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
6428 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
6429 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
6430 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
6431 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
6432 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
6433 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
6434
6435 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
6436 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
6437 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
6438 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
6439 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
6440 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
6441 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
6442 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
6443 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
6444 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
6445
6446 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
6447 });
6448
6449 test('format month', function (assert) {
6450 var expected = 'Jänner Jän._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
6451 for (i = 0; i < expected.length; i++) {
6452 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
6453 }
6454 });
6455
6456 test('format week', function (assert) {
6457 var expected = 'Sonntag So. So_Montag Mo. Mo_Dienstag Di. Di_Mittwoch Mi. Mi_Donnerstag Do. Do_Freitag Fr. Fr_Samstag Sa. Sa'.split('_'), i;
6458 for (i = 0; i < expected.length; i++) {
6459 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
6460 }
6461 });
6462
6463 test('from', function (assert) {
6464 var start = moment([2007, 1, 28]);
6465 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ein paar Sekunden', '44 seconds = a few seconds');
6466 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eine Minute', '45 seconds = a minute');
6467 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eine Minute', '89 seconds = a minute');
6468 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 Minuten', '90 seconds = 2 minutes');
6469 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 Minuten', '44 minutes = 44 minutes');
6470 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'eine Stunde', '45 minutes = an hour');
6471 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'eine Stunde', '89 minutes = an hour');
6472 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 Stunden', '90 minutes = 2 hours');
6473 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 Stunden', '5 hours = 5 hours');
6474 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 Stunden', '21 hours = 21 hours');
6475 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein Tag', '22 hours = a day');
6476 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein Tag', '35 hours = a day');
6477 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 Tage', '36 hours = 2 days');
6478 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein Tag', '1 day = a day');
6479 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 Tage', '5 days = 5 days');
6480 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 Tage', '25 days = 25 days');
6481 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein Monat', '26 days = a month');
6482 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein Monat', '30 days = a month');
6483 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 Monate', '46 days = 2 months');
6484 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 Monate', '75 days = 2 months');
6485 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 Monate', '76 days = 3 months');
6486 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein Monat', '1 month = a month');
6487 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 Monate', '5 months = 5 months');
6488 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ein Jahr', '345 days = a year');
6489 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 Jahre', '548 days = 2 years');
6490 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ein Jahr', '1 year = a year');
6491 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 Jahre', '5 years = 5 years');
6492 });
6493
6494 test('suffix', function (assert) {
6495 assert.equal(moment(30000).from(0), 'in ein paar Sekunden', 'prefix');
6496 assert.equal(moment(0).from(30000), 'vor ein paar Sekunden', 'suffix');
6497 });
6498
6499 test('fromNow', function (assert) {
6500 assert.equal(moment().add({s: 30}).fromNow(), 'in ein paar Sekunden', 'in a few seconds');
6501 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 Tagen', 'in 5 days');
6502 });
6503
6504 test('calendar day', function (assert) {
6505 var a = moment().hours(2).minutes(0).seconds(0);
6506
6507 assert.equal(moment(a).calendar(), 'Heute um 02:00 Uhr', 'today at the same time');
6508 assert.equal(moment(a).add({m: 25}).calendar(), 'Heute um 02:25 Uhr', 'Now plus 25 min');
6509 assert.equal(moment(a).add({h: 1}).calendar(), 'Heute um 03:00 Uhr', 'Now plus 1 hour');
6510 assert.equal(moment(a).add({d: 1}).calendar(), 'Morgen um 02:00 Uhr', 'tomorrow at the same time');
6511 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heute um 01:00 Uhr', 'Now minus 1 hour');
6512 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gestern um 02:00 Uhr', 'yesterday at the same time');
6513 });
6514
6515 test('calendar next week', function (assert) {
6516 var i, m;
6517 for (i = 2; i < 7; i++) {
6518 m = moment().add({d: i});
6519 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
6520 m.hours(0).minutes(0).seconds(0).milliseconds(0);
6521 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
6522 m.hours(23).minutes(59).seconds(59).milliseconds(999);
6523 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
6524 }
6525 });
6526
6527 test('calendar last week', function (assert) {
6528 var i, m;
6529 for (i = 2; i < 7; i++) {
6530 m = moment().subtract({d: i});
6531 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
6532 m.hours(0).minutes(0).seconds(0).milliseconds(0);
6533 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
6534 m.hours(23).minutes(59).seconds(59).milliseconds(999);
6535 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
6536 }
6537 });
6538
6539 test('calendar all else', function (assert) {
6540 var weeksAgo = moment().subtract({w: 1}),
6541 weeksFromNow = moment().add({w: 1});
6542
6543 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
6544 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
6545
6546 weeksAgo = moment().subtract({w: 2});
6547 weeksFromNow = moment().add({w: 2});
6548
6549 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
6550 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
6551 });
6552
6553 test('weeks year starting sunday', function (assert) {
6554 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
6555 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
6556 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
6557 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
6558 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
6559 });
6560
6561 test('weeks year starting monday', function (assert) {
6562 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
6563 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
6564 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
6565 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
6566 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
6567 });
6568
6569 test('weeks year starting tuesday', function (assert) {
6570 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
6571 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
6572 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
6573 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
6574 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
6575 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
6576 });
6577
6578 test('weeks year starting wednesday', function (assert) {
6579 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
6580 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
6581 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
6582 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
6583 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
6584 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
6585 });
6586
6587 test('weeks year starting thursday', function (assert) {
6588 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
6589 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
6590 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
6591 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
6592 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
6593 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
6594 });
6595
6596 test('weeks year starting friday', function (assert) {
6597 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
6598 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
6599 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
6600 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
6601 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
6602 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
6603 });
6604
6605 test('weeks year starting saturday', function (assert) {
6606 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
6607 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
6608 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
6609 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
6610 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
6611 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
6612 });
6613
6614 test('weeks year starting sunday formatted', function (assert) {
6615 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
6616 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
6617 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
6618 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
6619 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
6620 });
6621
6622 test('lenient ordinal parsing', function (assert) {
6623 var i, ordinalStr, testMoment;
6624 for (i = 1; i <= 31; ++i) {
6625 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
6626 testMoment = moment(ordinalStr, 'YYYY MM Do');
6627 assert.equal(testMoment.year(), 2014,
6628 'lenient ordinal parsing ' + i + ' year check');
6629 assert.equal(testMoment.month(), 0,
6630 'lenient ordinal parsing ' + i + ' month check');
6631 assert.equal(testMoment.date(), i,
6632 'lenient ordinal parsing ' + i + ' date check');
6633 }
6634 });
6635
6636 test('lenient ordinal parsing of number', function (assert) {
6637 var i, testMoment;
6638 for (i = 1; i <= 31; ++i) {
6639 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
6640 assert.equal(testMoment.year(), 2014,
6641 'lenient ordinal parsing of number ' + i + ' year check');
6642 assert.equal(testMoment.month(), 0,
6643 'lenient ordinal parsing of number ' + i + ' month check');
6644 assert.equal(testMoment.date(), i,
6645 'lenient ordinal parsing of number ' + i + ' date check');
6646 }
6647 });
6648
6649 test('strict ordinal parsing', function (assert) {
6650 var i, ordinalStr, testMoment;
6651 for (i = 1; i <= 31; ++i) {
6652 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
6653 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
6654 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
6655 }
6656 });
6657
6658 }));
6659
6660 (function (global, factory) {
6661 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
6662 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
6663 factory(global.moment)
6664 }(this, function (moment) { 'use strict';
6665
6666 /*global QUnit:false*/
6667
6668 var test = QUnit.test;
6669
6670 function module (name, lifecycle) {
6671 QUnit.module(name, {
6672 setup : function () {
6673 moment.locale('en');
6674 moment.createFromInputFallback = function () {
6675 throw new Error('input not handled by moment');
6676 };
6677 if (lifecycle && lifecycle.setup) {
6678 lifecycle.setup();
6679 }
6680 },
6681 teardown : function () {
6682 if (lifecycle && lifecycle.teardown) {
6683 lifecycle.teardown();
6684 }
6685 }
6686 });
6687 }
6688
6689 function localeModule (name, lifecycle) {
6690 QUnit.module('locale:' + name, {
6691 setup : function () {
6692 moment.locale(name);
6693 moment.createFromInputFallback = function () {
6694 throw new Error('input not handled by moment');
6695 };
6696 if (lifecycle && lifecycle.setup) {
6697 lifecycle.setup();
6698 }
6699 },
6700 teardown : function () {
6701 moment.locale('en');
6702 if (lifecycle && lifecycle.teardown) {
6703 lifecycle.teardown();
6704 }
6705 }
6706 });
6707 }
6708
6709 localeModule('de');
6710
6711 test('parse', function (assert) {
6712 var tests = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
6713 function equalTest(input, mmm, i) {
6714 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
6715 }
6716 for (i = 0; i < 12; i++) {
6717 tests[i] = tests[i].split(' ');
6718 equalTest(tests[i][0], 'MMM', i);
6719 equalTest(tests[i][1], 'MMM', i);
6720 equalTest(tests[i][0], 'MMMM', i);
6721 equalTest(tests[i][1], 'MMMM', i);
6722 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
6723 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
6724 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
6725 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
6726 }
6727 });
6728
6729 test('format', function (assert) {
6730 var a = [
6731 ['dddd, Do MMMM YYYY, h:mm:ss a', 'Sonntag, 14. Februar 2010, 3:25:50 pm'],
6732 ['ddd, hA', 'So., 3PM'],
6733 ['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
6734 ['YYYY YY', '2010 10'],
6735 ['D Do DD', '14 14. 14'],
6736 ['d do dddd ddd dd', '0 0. Sonntag So. So'],
6737 ['DDD DDDo DDDD', '45 45. 045'],
6738 ['w wo ww', '6 6. 06'],
6739 ['h hh', '3 03'],
6740 ['H HH', '15 15'],
6741 ['m mm', '25 25'],
6742 ['s ss', '50 50'],
6743 ['a A', 'pm PM'],
6744 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
6745 ['LTS', '15:25:50'],
6746 ['L', '14.02.2010'],
6747 ['LL', '14. Februar 2010'],
6748 ['LLL', '14. Februar 2010 15:25'],
6749 ['LLLL', 'Sonntag, 14. Februar 2010 15:25'],
6750 ['l', '14.2.2010'],
6751 ['ll', '14. Febr. 2010'],
6752 ['lll', '14. Febr. 2010 15:25'],
6753 ['llll', 'So., 14. Febr. 2010 15:25']
6754 ],
6755 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
6756 i;
6757 for (i = 0; i < a.length; i++) {
6758 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
6759 }
6760 });
6761
6762 test('format ordinal', function (assert) {
6763 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
6764 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
6765 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
6766 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
6767 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
6768 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
6769 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
6770 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
6771 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
6772 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
6773
6774 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
6775 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
6776 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
6777 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
6778 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
6779 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
6780 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
6781 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
6782 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
6783 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
6784
6785 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
6786 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
6787 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
6788 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
6789 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
6790 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
6791 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
6792 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
6793 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
6794 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
6795
6796 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
6797 });
6798
6799 test('format month', function (assert) {
6800 var expected = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
6801 for (i = 0; i < expected.length; i++) {
6802 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
6803 }
6804 });
6805
6806 test('format week', function (assert) {
6807 var expected = 'Sonntag So. So_Montag Mo. Mo_Dienstag Di. Di_Mittwoch Mi. Mi_Donnerstag Do. Do_Freitag Fr. Fr_Samstag Sa. Sa'.split('_'), i;
6808 for (i = 0; i < expected.length; i++) {
6809 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
6810 }
6811 });
6812
6813 test('from', function (assert) {
6814 var start = moment([2007, 1, 28]);
6815 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ein paar Sekunden', '44 seconds = a few seconds');
6816 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eine Minute', '45 seconds = a minute');
6817 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eine Minute', '89 seconds = a minute');
6818 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 Minuten', '90 seconds = 2 minutes');
6819 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 Minuten', '44 minutes = 44 minutes');
6820 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'eine Stunde', '45 minutes = an hour');
6821 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'eine Stunde', '89 minutes = an hour');
6822 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 Stunden', '90 minutes = 2 hours');
6823 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 Stunden', '5 hours = 5 hours');
6824 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 Stunden', '21 hours = 21 hours');
6825 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein Tag', '22 hours = a day');
6826 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein Tag', '35 hours = a day');
6827 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 Tage', '36 hours = 2 days');
6828 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein Tag', '1 day = a day');
6829 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 Tage', '5 days = 5 days');
6830 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 Tage', '25 days = 25 days');
6831 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein Monat', '26 days = a month');
6832 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein Monat', '30 days = a month');
6833 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ein Monat', '43 days = a month');
6834 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 Monate', '46 days = 2 months');
6835 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 Monate', '75 days = 2 months');
6836 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 Monate', '76 days = 3 months');
6837 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein Monat', '1 month = a month');
6838 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 Monate', '5 months = 5 months');
6839 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ein Jahr', '345 days = a year');
6840 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 Jahre', '548 days = 2 years');
6841 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ein Jahr', '1 year = a year');
6842 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 Jahre', '5 years = 5 years');
6843 });
6844
6845 test('suffix', function (assert) {
6846 assert.equal(moment(30000).from(0), 'in ein paar Sekunden', 'prefix');
6847 assert.equal(moment(0).from(30000), 'vor ein paar Sekunden', 'suffix');
6848 });
6849
6850 test('fromNow', function (assert) {
6851 assert.equal(moment().add({s: 30}).fromNow(), 'in ein paar Sekunden', 'in a few seconds');
6852 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 Tagen', 'in 5 days');
6853 });
6854
6855 test('calendar day', function (assert) {
6856 var a = moment().hours(2).minutes(0).seconds(0);
6857
6858 assert.equal(moment(a).calendar(), 'Heute um 02:00 Uhr', 'today at the same time');
6859 assert.equal(moment(a).add({m: 25}).calendar(), 'Heute um 02:25 Uhr', 'Now plus 25 min');
6860 assert.equal(moment(a).add({h: 1}).calendar(), 'Heute um 03:00 Uhr', 'Now plus 1 hour');
6861 assert.equal(moment(a).add({d: 1}).calendar(), 'Morgen um 02:00 Uhr', 'tomorrow at the same time');
6862 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heute um 01:00 Uhr', 'Now minus 1 hour');
6863 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gestern um 02:00 Uhr', 'yesterday at the same time');
6864 });
6865
6866 test('calendar next week', function (assert) {
6867 var i, m;
6868 for (i = 2; i < 7; i++) {
6869 m = moment().add({d: i});
6870 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
6871 m.hours(0).minutes(0).seconds(0).milliseconds(0);
6872 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
6873 m.hours(23).minutes(59).seconds(59).milliseconds(999);
6874 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
6875 }
6876 });
6877
6878 test('calendar last week', function (assert) {
6879 var i, m;
6880 for (i = 2; i < 7; i++) {
6881 m = moment().subtract({d: i});
6882 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
6883 m.hours(0).minutes(0).seconds(0).milliseconds(0);
6884 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
6885 m.hours(23).minutes(59).seconds(59).milliseconds(999);
6886 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
6887 }
6888 });
6889
6890 test('calendar all else', function (assert) {
6891 var weeksAgo = moment().subtract({w: 1}),
6892 weeksFromNow = moment().add({w: 1});
6893
6894 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
6895 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
6896
6897 weeksAgo = moment().subtract({w: 2});
6898 weeksFromNow = moment().add({w: 2});
6899
6900 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
6901 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
6902 });
6903
6904 test('weeks year starting sunday', function (assert) {
6905 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
6906 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
6907 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
6908 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
6909 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
6910 });
6911
6912 test('weeks year starting monday', function (assert) {
6913 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
6914 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
6915 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
6916 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
6917 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
6918 });
6919
6920 test('weeks year starting tuesday', function (assert) {
6921 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
6922 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
6923 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
6924 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
6925 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
6926 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
6927 });
6928
6929 test('weeks year starting wednesday', function (assert) {
6930 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
6931 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
6932 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
6933 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
6934 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
6935 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
6936 });
6937
6938 test('weeks year starting thursday', function (assert) {
6939 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
6940 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
6941 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
6942 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
6943 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
6944 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
6945 });
6946
6947 test('weeks year starting friday', function (assert) {
6948 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
6949 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
6950 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
6951 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
6952 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
6953 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
6954 });
6955
6956 test('weeks year starting saturday', function (assert) {
6957 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
6958 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
6959 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
6960 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
6961 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
6962 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
6963 });
6964
6965 test('weeks year starting sunday formatted', function (assert) {
6966 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
6967 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
6968 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
6969 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
6970 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
6971 });
6972
6973 test('lenient ordinal parsing', function (assert) {
6974 var i, ordinalStr, testMoment;
6975 for (i = 1; i <= 31; ++i) {
6976 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
6977 testMoment = moment(ordinalStr, 'YYYY MM Do');
6978 assert.equal(testMoment.year(), 2014,
6979 'lenient ordinal parsing ' + i + ' year check');
6980 assert.equal(testMoment.month(), 0,
6981 'lenient ordinal parsing ' + i + ' month check');
6982 assert.equal(testMoment.date(), i,
6983 'lenient ordinal parsing ' + i + ' date check');
6984 }
6985 });
6986
6987 test('lenient ordinal parsing of number', function (assert) {
6988 var i, testMoment;
6989 for (i = 1; i <= 31; ++i) {
6990 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
6991 assert.equal(testMoment.year(), 2014,
6992 'lenient ordinal parsing of number ' + i + ' year check');
6993 assert.equal(testMoment.month(), 0,
6994 'lenient ordinal parsing of number ' + i + ' month check');
6995 assert.equal(testMoment.date(), i,
6996 'lenient ordinal parsing of number ' + i + ' date check');
6997 }
6998 });
6999
7000 test('strict ordinal parsing', function (assert) {
7001 var i, ordinalStr, testMoment;
7002 for (i = 1; i <= 31; ++i) {
7003 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
7004 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
7005 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
7006 }
7007 });
7008
7009 }));
7010
7011 (function (global, factory) {
7012 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
7013 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
7014 factory(global.moment)
7015 }(this, function (moment) { 'use strict';
7016
7017 /*global QUnit:false*/
7018
7019 var test = QUnit.test;
7020
7021 function module (name, lifecycle) {
7022 QUnit.module(name, {
7023 setup : function () {
7024 moment.locale('en');
7025 moment.createFromInputFallback = function () {
7026 throw new Error('input not handled by moment');
7027 };
7028 if (lifecycle && lifecycle.setup) {
7029 lifecycle.setup();
7030 }
7031 },
7032 teardown : function () {
7033 if (lifecycle && lifecycle.teardown) {
7034 lifecycle.teardown();
7035 }
7036 }
7037 });
7038 }
7039
7040 function localeModule (name, lifecycle) {
7041 QUnit.module('locale:' + name, {
7042 setup : function () {
7043 moment.locale(name);
7044 moment.createFromInputFallback = function () {
7045 throw new Error('input not handled by moment');
7046 };
7047 if (lifecycle && lifecycle.setup) {
7048 lifecycle.setup();
7049 }
7050 },
7051 teardown : function () {
7052 moment.locale('en');
7053 if (lifecycle && lifecycle.teardown) {
7054 lifecycle.teardown();
7055 }
7056 }
7057 });
7058 }
7059
7060 localeModule('el');
7061
7062 test('parse', function (assert) {
7063 var i,
7064 tests = 'Ιανουάριος Ιαν_Φεβρουάριος Φεβ_Μάρτιος Μαρ_Απρίλιος Απρ_Μάιος Μαϊ_Ιούνιος Ιουν_Ιούλιος Ιουλ_Αύγουστος Αυγ_Σεπτέμβριος Σεπ_Οκτώβριος Οκτ_Νοέμβριος Νοε_Δεκέμβριος Δεκ'.split('_');
7065
7066 function equalTest(input, mmm, i) {
7067 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
7068 }
7069
7070 for (i = 0; i < 12; i++) {
7071 tests[i] = tests[i].split(' ');
7072 equalTest(tests[i][0], 'MMM', i);
7073 equalTest(tests[i][1], 'MMM', i);
7074 equalTest(tests[i][0], 'MMMM', i);
7075 equalTest(tests[i][1], 'MMMM', i);
7076 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
7077 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
7078 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
7079 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
7080 }
7081 });
7082
7083 test('parse meridiem', function (assert) {
7084 var i,
7085 b = moment(),
7086 meridiemTests = [
7087 // h a patterns, expected hours, isValid
7088 ['10 πμ', 10, true],
7089 ['10 μμ', 22, true],
7090 ['10 π.μ.', 10, true],
7091 ['10 μ.μ.', 22, true],
7092 ['10 π', 10, true],
7093 ['10 μ', 22, true],
7094 ['10 ΠΜ', 10, true],
7095 ['10 ΜΜ', 22, true],
7096 ['10 Π.Μ.', 10, true],
7097 ['10 Μ.Μ.', 22, true],
7098 ['10 Π', 10, true],
7099 ['10 Μ', 22, true],
7100 ['10 am', 10, false],
7101 ['10 pm', 10, false]
7102 ];
7103
7104 // test that a formatted moment including meridiem string can be parsed back to the same moment
7105 assert.ok(b.isSame(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'el', true), 'seconds'), b.format('h:mm:ss a') + ' should be equal to ' + moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'el', true).format('h:mm:ss a'));
7106
7107 // test that a formatted moment having a meridiem string can be parsed with strict flag
7108 assert.ok(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'el', true).isValid(), b.format('h:mm:ss a') + ' should be parsed as valid');
7109
7110 for (i = 0; i < meridiemTests.length; i++) {
7111 assert.equal(moment(meridiemTests[i][0], 'h a', 'el', true).hours(), meridiemTests[i][1], moment(meridiemTests[i][0], 'h a', 'el', true).hours() + ' should be ' + meridiemTests[i][1]);
7112 assert.ok(moment(meridiemTests[i][0], 'h a', 'el', true).isValid() === meridiemTests[i][2], meridiemTests[i][0] + ' ----> ' + meridiemTests[i][2]);
7113 }
7114 });
7115
7116 test('format', function (assert) {
7117 var a = [
7118 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Κυριακή, Φεβρουάριος 14η 2010, 3:25:50 μμ'],
7119 ['dddd, D MMMM YYYY, h:mm:ss a', 'Κυριακή, 14 Φεβρουαρίου 2010, 3:25:50 μμ'],
7120 ['ddd, hA', 'Κυρ, 3ΜΜ'],
7121 ['dddd, MMMM YYYY', 'Κυριακή, Φεβρουάριος 2010'],
7122 ['M Mo MM MMMM MMM', '2 2η 02 Φεβρουάριος Φεβ'],
7123 ['YYYY YY', '2010 10'],
7124 ['D Do DD', '14 14η 14'],
7125 ['d do dddd ddd dd', '0 0η Κυριακή Κυρ Κυ'],
7126 ['DDD DDDo DDDD', '45 45η 045'],
7127 ['w wo ww', '6 6η 06'],
7128 ['h hh', '3 03'],
7129 ['H HH', '15 15'],
7130 ['m mm', '25 25'],
7131 ['s ss', '50 50'],
7132 ['a A', 'μμ ΜΜ'],
7133 ['[the] DDDo [day of the year]', 'the 45η day of the year'],
7134 ['LTS', '3:25:50 ΜΜ'],
7135 ['L', '14/02/2010'],
7136 ['LL', '14 Φεβρουαρίου 2010'],
7137 ['LLL', '14 Φεβρουαρίου 2010 3:25 ΜΜ'],
7138 ['LLLL', 'Κυριακή, 14 Φεβρουαρίου 2010 3:25 ΜΜ'],
7139 ['l', '14/2/2010'],
7140 ['ll', '14 Φεβ 2010'],
7141 ['lll', '14 Φεβ 2010 3:25 ΜΜ'],
7142 ['llll', 'Κυρ, 14 Φεβ 2010 3:25 ΜΜ']
7143 ],
7144 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
7145 i;
7146
7147 for (i = 0; i < a.length; i++) {
7148 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
7149 }
7150 });
7151
7152 test('format ordinal', function (assert) {
7153 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1η', '1η');
7154 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2η', '2η');
7155 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3η', '3η');
7156 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4η', '4η');
7157 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5η', '5η');
7158 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6η', '6η');
7159 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7η', '7η');
7160 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8η', '8η');
7161 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9η', '9η');
7162 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10η', '10η');
7163
7164 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11η', '11η');
7165 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12η', '12η');
7166 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13η', '13η');
7167 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14η', '14η');
7168 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15η', '15η');
7169 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16η', '16η');
7170 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17η', '17η');
7171 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18η', '18η');
7172 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19η', '19η');
7173 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20η', '20η');
7174
7175 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21η', '21η');
7176 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22η', '22η');
7177 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23η', '23η');
7178 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24η', '24η');
7179 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25η', '25η');
7180 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26η', '26η');
7181 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27η', '27η');
7182 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28η', '28η');
7183 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29η', '29η');
7184 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30η', '30η');
7185
7186 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31η', '31η');
7187 });
7188
7189 test('format month', function (assert) {
7190 var i,
7191 expected = 'Ιανουάριος Ιαν_Φεβρουάριος Φεβ_Μάρτιος Μαρ_Απρίλιος Απρ_Μάιος Μαϊ_Ιούνιος Ιουν_Ιούλιος Ιουλ_Αύγουστος Αυγ_Σεπτέμβριος Σεπ_Οκτώβριος Οκτ_Νοέμβριος Νοε_Δεκέμβριος Δεκ'.split('_');
7192
7193 for (i = 0; i < expected.length; i++) {
7194 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
7195 }
7196 });
7197
7198 test('format week', function (assert) {
7199 var i,
7200 expected = 'Κυριακή Κυρ Κυ_Δευτέρα Δευ Δε_Τρίτη Τρι Τρ_Τετάρτη Τετ Τε_Πέμπτη Πεμ Πε_Παρασκευή Παρ Πα_Σάββατο Σαβ Σα'.split('_');
7201
7202 for (i = 0; i < expected.length; i++) {
7203 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
7204 }
7205 });
7206
7207 test('from', function (assert) {
7208 var start = moment([2007, 1, 28]);
7209
7210 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'λίγα δευτερόλεπτα', '44 seconds = a few seconds');
7211 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ένα λεπτό', '45 seconds = a minute');
7212 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ένα λεπτό', '89 seconds = a minute');
7213 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 λεπτά', '90 seconds = 2 minutes');
7214 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 λεπτά', '44 minutes = 44 minutes');
7215 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'μία ώρα', '45 minutes = an hour');
7216 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'μία ώρα', '89 minutes = an hour');
7217 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ώρες', '90 minutes = 2 hours');
7218 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ώρες', '5 hours = 5 hours');
7219 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ώρες', '21 hours = 21 hours');
7220 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'μία μέρα', '22 hours = a day');
7221 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'μία μέρα', '35 hours = a day');
7222 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 μέρες', '36 hours = 2 days');
7223 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'μία μέρα', '1 day = a day');
7224 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 μέρες', '5 days = 5 days');
7225 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 μέρες', '25 days = 25 days');
7226 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ένας μήνας', '26 days = a month');
7227 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ένας μήνας', '30 days = a month');
7228 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ένας μήνας', '43 days = a month');
7229 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 μήνες', '46 days = 2 months');
7230 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 μήνες', '75 days = 2 months');
7231 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 μήνες', '76 days = 3 months');
7232 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ένας μήνας', '1 month = a month');
7233 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 μήνες', '5 months = 5 months');
7234 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ένας χρόνος', '345 days = a year');
7235 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 χρόνια', '548 days = 2 years');
7236 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ένας χρόνος', '1 year = a year');
7237 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 χρόνια', '5 years = 5 years');
7238 });
7239
7240 test('suffix', function (assert) {
7241 assert.equal(moment(30000).from(0), 'σε λίγα δευτερόλεπτα', 'prefix');
7242 assert.equal(moment(0).from(30000), 'λίγα δευτερόλεπτα πριν', 'suffix');
7243 });
7244
7245 test('now from now', function (assert) {
7246 assert.equal(moment().fromNow(), 'λίγα δευτερόλεπτα πριν', 'now from now should display as in the past');
7247 });
7248
7249 test('fromNow', function (assert) {
7250 assert.equal(moment().add({s: 30}).fromNow(), 'σε λίγα δευτερόλεπτα', 'in a few seconds');
7251 assert.equal(moment().add({d: 5}).fromNow(), 'σε 5 μέρες', 'in 5 days');
7252 });
7253
7254 test('calendar day', function (assert) {
7255 var a = moment().hours(2).minutes(0).seconds(0);
7256
7257 assert.equal(moment(a).calendar(), 'Σήμερα στις 2:00 ΠΜ', 'today at the same time');
7258 assert.equal(moment(a).add({m: 25}).calendar(), 'Σήμερα στις 2:25 ΠΜ', 'Now plus 25 min');
7259 assert.equal(moment(a).add({h: 1}).calendar(), 'Σήμερα στις 3:00 ΠΜ', 'Now plus 1 hour');
7260 assert.equal(moment(a).add({d: 1}).calendar(), 'Αύριο στις 2:00 ΠΜ', 'tomorrow at the same time');
7261 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Σήμερα στη 1:00 ΠΜ', 'Now minus 1 hour');
7262 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Χθες στις 2:00 ΠΜ', 'yesterday at the same time');
7263 });
7264
7265 test('calendar next week', function (assert) {
7266 var i, m;
7267 for (i = 2; i < 7; i++) {
7268 m = moment().add({d: i});
7269 assert.equal(m.calendar(), m.format('dddd [' + (m.hours() % 12 === 1 ? 'στη' : 'στις') + '] LT'), 'Today + ' + i + ' days current time');
7270 m.hours(0).minutes(0).seconds(0).milliseconds(0);
7271 assert.equal(m.calendar(), m.format('dddd [στις] LT'), 'Today + ' + i + ' days beginning of day');
7272 m.hours(23).minutes(59).seconds(59).milliseconds(999);
7273 assert.equal(m.calendar(), m.format('dddd [στις] LT'), 'Today + ' + i + ' days end of day');
7274 }
7275 });
7276
7277 test('calendar last week', function (assert) {
7278 var i, m, dayString;
7279 for (i = 2; i < 7; i++) {
7280 m = moment().subtract({d: i});
7281 dayString = m.day() === 6 ? '[το προηγούμενο Σάββατο]' : '[την προηγούμενη] dddd';
7282 assert.equal(m.calendar(), m.format(dayString + ' [' + (m.hours() % 12 === 1 ? 'στη' : 'στις') + '] LT'), 'Today - ' + i + ' days current time');
7283 m.hours(1).minutes(30).seconds(0).milliseconds(0);
7284 assert.equal(m.calendar(), m.format(dayString + ' [στη] LT'), 'Today - ' + i + ' days one o clock');
7285 m.hours(0).minutes(0).seconds(0).milliseconds(0);
7286 assert.equal(m.calendar(), m.format(dayString + ' [στις] LT'), 'Today - ' + i + ' days beginning of day');
7287 m.hours(23).minutes(59).seconds(59).milliseconds(999);
7288 assert.equal(m.calendar(), m.format(dayString + ' [στις] LT'), 'Today - ' + i + ' days end of day');
7289 }
7290 });
7291
7292 test('calendar all else', function (assert) {
7293 var weeksAgo = moment().subtract({w: 1}),
7294 weeksFromNow = moment().add({w: 1});
7295
7296 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
7297 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
7298
7299 weeksAgo = moment().subtract({w: 2});
7300 weeksFromNow = moment().add({w: 2});
7301
7302 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
7303 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
7304 });
7305
7306 test('weeks year starting sunday', function (assert) {
7307 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
7308 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
7309 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
7310 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
7311 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
7312 });
7313
7314 test('weeks year starting monday', function (assert) {
7315 assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
7316 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
7317 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
7318 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
7319 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
7320 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
7321 });
7322
7323 test('weeks year starting tuesday', function (assert) {
7324 assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 should be week 52');
7325 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
7326 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
7327 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
7328 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
7329 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
7330 });
7331
7332 test('weeks year starting wednesday', function (assert) {
7333 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
7334 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
7335 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
7336 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
7337 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
7338 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
7339 });
7340
7341 test('weeks year starting thursday', function (assert) {
7342 assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 should be week 52');
7343 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
7344 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
7345 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
7346 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
7347 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
7348 });
7349
7350 test('weeks year starting friday', function (assert) {
7351 assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 should be week 52');
7352 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
7353 assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
7354 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 1');
7355 assert.equal(moment([2010, 0, 9]).week(), 1, 'Jan 9 2010 should be week 1');
7356 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
7357 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
7358 });
7359
7360 test('weeks year starting saturday', function (assert) {
7361 assert.equal(moment([2010, 11, 26]).week(), 51, 'Dec 26 2010 should be week 51');
7362 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
7363 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
7364 assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
7365 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
7366 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
7367 });
7368
7369 test('weeks year starting sunday format', function (assert) {
7370 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52η', 'Jan 1 2012 should be week 52');
7371 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1η', 'Jan 7 2012 should be week 1');
7372 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1η', 'Jan 8 2012 should be week 1');
7373 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2η', 'Jan 14 2012 should be week 2');
7374 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2η', 'Jan 15 2012 should be week 2');
7375 });
7376
7377 test('lenient ordinal parsing', function (assert) {
7378 var i, ordinalStr, testMoment;
7379 for (i = 1; i <= 31; ++i) {
7380 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
7381 testMoment = moment(ordinalStr, 'YYYY MM Do');
7382 assert.equal(testMoment.year(), 2014,
7383 'lenient ordinal parsing ' + i + ' year check');
7384 assert.equal(testMoment.month(), 0,
7385 'lenient ordinal parsing ' + i + ' month check');
7386 assert.equal(testMoment.date(), i,
7387 'lenient ordinal parsing ' + i + ' date check');
7388 }
7389 });
7390
7391 test('lenient ordinal parsing of number', function (assert) {
7392 var i, testMoment;
7393 for (i = 1; i <= 31; ++i) {
7394 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
7395 assert.equal(testMoment.year(), 2014,
7396 'lenient ordinal parsing of number ' + i + ' year check');
7397 assert.equal(testMoment.month(), 0,
7398 'lenient ordinal parsing of number ' + i + ' month check');
7399 assert.equal(testMoment.date(), i,
7400 'lenient ordinal parsing of number ' + i + ' date check');
7401 }
7402 });
7403
7404 test('strict ordinal parsing', function (assert) {
7405 var i, ordinalStr, testMoment;
7406 for (i = 1; i <= 31; ++i) {
7407 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
7408 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
7409 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
7410 }
7411 });
7412
7413 }));
7414
7415 (function (global, factory) {
7416 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
7417 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
7418 factory(global.moment)
7419 }(this, function (moment) { 'use strict';
7420
7421 /*global QUnit:false*/
7422
7423 var test = QUnit.test;
7424
7425 function module (name, lifecycle) {
7426 QUnit.module(name, {
7427 setup : function () {
7428 moment.locale('en');
7429 moment.createFromInputFallback = function () {
7430 throw new Error('input not handled by moment');
7431 };
7432 if (lifecycle && lifecycle.setup) {
7433 lifecycle.setup();
7434 }
7435 },
7436 teardown : function () {
7437 if (lifecycle && lifecycle.teardown) {
7438 lifecycle.teardown();
7439 }
7440 }
7441 });
7442 }
7443
7444 function localeModule (name, lifecycle) {
7445 QUnit.module('locale:' + name, {
7446 setup : function () {
7447 moment.locale(name);
7448 moment.createFromInputFallback = function () {
7449 throw new Error('input not handled by moment');
7450 };
7451 if (lifecycle && lifecycle.setup) {
7452 lifecycle.setup();
7453 }
7454 },
7455 teardown : function () {
7456 moment.locale('en');
7457 if (lifecycle && lifecycle.teardown) {
7458 lifecycle.teardown();
7459 }
7460 }
7461 });
7462 }
7463
7464 localeModule('en-au');
7465
7466 test('parse', function (assert) {
7467 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;
7468 function equalTest(input, mmm, i) {
7469 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
7470 }
7471 for (i = 0; i < 12; i++) {
7472 tests[i] = tests[i].split(' ');
7473 equalTest(tests[i][0], 'MMM', i);
7474 equalTest(tests[i][1], 'MMM', i);
7475 equalTest(tests[i][0], 'MMMM', i);
7476 equalTest(tests[i][1], 'MMMM', i);
7477 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
7478 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
7479 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
7480 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
7481 }
7482 });
7483
7484 test('format', function (assert) {
7485 var a = [
7486 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
7487 ['ddd, hA', 'Sun, 3PM'],
7488 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
7489 ['YYYY YY', '2010 10'],
7490 ['D Do DD', '14 14th 14'],
7491 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
7492 ['DDD DDDo DDDD', '45 45th 045'],
7493 ['w wo ww', '6 6th 06'],
7494 ['h hh', '3 03'],
7495 ['H HH', '15 15'],
7496 ['m mm', '25 25'],
7497 ['s ss', '50 50'],
7498 ['a A', 'pm PM'],
7499 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
7500 ['LTS', '3:25:50 PM'],
7501 ['L', '14/02/2010'],
7502 ['LL', '14 February 2010'],
7503 ['LLL', '14 February 2010 3:25 PM'],
7504 ['LLLL', 'Sunday, 14 February 2010 3:25 PM'],
7505 ['l', '14/2/2010'],
7506 ['ll', '14 Feb 2010'],
7507 ['lll', '14 Feb 2010 3:25 PM'],
7508 ['llll', 'Sun, 14 Feb 2010 3:25 PM']
7509 ],
7510 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
7511 i;
7512 for (i = 0; i < a.length; i++) {
7513 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
7514 }
7515 });
7516
7517 test('format ordinal', function (assert) {
7518 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
7519 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
7520 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
7521 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
7522 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
7523 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
7524 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
7525 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
7526 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
7527 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
7528
7529 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
7530 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
7531 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
7532 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
7533 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
7534 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
7535 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
7536 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
7537 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
7538 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
7539
7540 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
7541 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
7542 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
7543 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
7544 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
7545 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
7546 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
7547 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
7548 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
7549 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
7550
7551 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
7552 });
7553
7554 test('format month', function (assert) {
7555 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;
7556 for (i = 0; i < expected.length; i++) {
7557 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
7558 }
7559 });
7560
7561 test('format week', function (assert) {
7562 var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_'), i;
7563 for (i = 0; i < expected.length; i++) {
7564 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
7565 }
7566 });
7567
7568 test('from', function (assert) {
7569 var start = moment([2007, 1, 28]);
7570 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
7571 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
7572 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
7573 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
7574 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
7575 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
7576 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
7577 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
7578 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
7579 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
7580 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
7581 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
7582 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
7583 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
7584 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
7585 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
7586 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
7587 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
7588 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
7589 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
7590 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
7591 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
7592 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
7593 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
7594 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
7595 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
7596 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
7597 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
7598 });
7599
7600 test('suffix', function (assert) {
7601 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
7602 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
7603 });
7604
7605 test('now from now', function (assert) {
7606 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
7607 });
7608
7609 test('fromNow', function (assert) {
7610 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
7611 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
7612 });
7613
7614 test('calendar day', function (assert) {
7615 var a = moment().hours(2).minutes(0).seconds(0);
7616
7617 assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
7618 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
7619 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
7620 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
7621 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
7622 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
7623 });
7624
7625 test('calendar next week', function (assert) {
7626 var i, m;
7627 for (i = 2; i < 7; i++) {
7628 m = moment().add({d: i});
7629 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
7630 m.hours(0).minutes(0).seconds(0).milliseconds(0);
7631 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
7632 m.hours(23).minutes(59).seconds(59).milliseconds(999);
7633 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
7634 }
7635 });
7636
7637 test('calendar last week', function (assert) {
7638 var i, m;
7639
7640 for (i = 2; i < 7; i++) {
7641 m = moment().subtract({d: i});
7642 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
7643 m.hours(0).minutes(0).seconds(0).milliseconds(0);
7644 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
7645 m.hours(23).minutes(59).seconds(59).milliseconds(999);
7646 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
7647 }
7648 });
7649
7650 test('calendar all else', function (assert) {
7651 var weeksAgo = moment().subtract({w: 1}),
7652 weeksFromNow = moment().add({w: 1});
7653
7654 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
7655 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
7656
7657 weeksAgo = moment().subtract({w: 2});
7658 weeksFromNow = moment().add({w: 2});
7659
7660 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
7661 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
7662 });
7663
7664 test('weeks year starting sunday', function (assert) {
7665 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
7666 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
7667 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
7668 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
7669 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
7670 });
7671
7672 test('weeks year starting monday', function (assert) {
7673 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
7674 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
7675 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
7676 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
7677 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
7678 });
7679
7680 test('weeks year starting tuesday', function (assert) {
7681 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
7682 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
7683 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
7684 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
7685 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
7686 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
7687 });
7688
7689 test('weeks year starting wednesday', function (assert) {
7690 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
7691 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
7692 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
7693 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
7694 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
7695 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
7696 });
7697
7698 test('weeks year starting thursday', function (assert) {
7699 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
7700 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
7701 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
7702 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
7703 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
7704 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
7705 });
7706
7707 test('weeks year starting friday', function (assert) {
7708 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
7709 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
7710 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
7711 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
7712 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
7713 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
7714 });
7715
7716 test('weeks year starting saturday', function (assert) {
7717 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
7718 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
7719 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
7720 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
7721 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
7722 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
7723 });
7724
7725 test('weeks year starting sunday formatted', function (assert) {
7726 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
7727 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
7728 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', 'Jan 8 2012 should be week 1');
7729 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
7730 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
7731 });
7732
7733 test('lenient ordinal parsing', function (assert) {
7734 var i, ordinalStr, testStr;
7735 for (i = 1; i <= 31; ++i) {
7736 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
7737 testStr = moment(ordinalStr, 'YYYY MM Do').format('YYYY MM D');
7738 assert.equal(testStr, '2014 01 ' + i, 'lenient ordinal parsing ' + i);
7739 }
7740 });
7741
7742 test('lenient ordinal parsing of number', function (assert) {
7743 var i, testStr;
7744 for (i = 1; i <= 31; ++i) {
7745 testStr = moment('2014 01 ' + i, 'YYYY MM Do').format('YYYY MM D');
7746 assert.equal(testStr, '2014 01 ' + i,
7747 'lenient ordinal parsing of number ' + i);
7748 }
7749 });
7750
7751 test('strict ordinal parsing', function (assert) {
7752 var i, ordinalStr, testMoment;
7753 for (i = 1; i <= 31; ++i) {
7754 ordinalStr = moment([2014, 0, i]).format('YYYY MMM Do');
7755 testMoment = moment(ordinalStr, 'YYYY MMM Do', true);
7756 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
7757 }
7758 });
7759
7760 }));
7761
7762 (function (global, factory) {
7763 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
7764 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
7765 factory(global.moment)
7766 }(this, function (moment) { 'use strict';
7767
7768 /*global QUnit:false*/
7769
7770 var test = QUnit.test;
7771
7772 function module (name, lifecycle) {
7773 QUnit.module(name, {
7774 setup : function () {
7775 moment.locale('en');
7776 moment.createFromInputFallback = function () {
7777 throw new Error('input not handled by moment');
7778 };
7779 if (lifecycle && lifecycle.setup) {
7780 lifecycle.setup();
7781 }
7782 },
7783 teardown : function () {
7784 if (lifecycle && lifecycle.teardown) {
7785 lifecycle.teardown();
7786 }
7787 }
7788 });
7789 }
7790
7791 function localeModule (name, lifecycle) {
7792 QUnit.module('locale:' + name, {
7793 setup : function () {
7794 moment.locale(name);
7795 moment.createFromInputFallback = function () {
7796 throw new Error('input not handled by moment');
7797 };
7798 if (lifecycle && lifecycle.setup) {
7799 lifecycle.setup();
7800 }
7801 },
7802 teardown : function () {
7803 moment.locale('en');
7804 if (lifecycle && lifecycle.teardown) {
7805 lifecycle.teardown();
7806 }
7807 }
7808 });
7809 }
7810
7811 localeModule('en-ca');
7812
7813 test('parse', function (assert) {
7814 var i,
7815 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('_');
7816
7817 function equalTest(input, mmm, i) {
7818 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
7819 }
7820
7821 for (i = 0; i < 12; i++) {
7822 tests[i] = tests[i].split(' ');
7823 equalTest(tests[i][0], 'MMM', i);
7824 equalTest(tests[i][1], 'MMM', i);
7825 equalTest(tests[i][0], 'MMMM', i);
7826 equalTest(tests[i][1], 'MMMM', i);
7827 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
7828 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
7829 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
7830 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
7831 }
7832 });
7833
7834 test('format', function (assert) {
7835 var a = [
7836 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
7837 ['ddd, hA', 'Sun, 3PM'],
7838 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
7839 ['YYYY YY', '2010 10'],
7840 ['D Do DD', '14 14th 14'],
7841 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
7842 ['DDD DDDo DDDD', '45 45th 045'],
7843 ['w wo ww', '8 8th 08'],
7844 ['h hh', '3 03'],
7845 ['H HH', '15 15'],
7846 ['m mm', '25 25'],
7847 ['s ss', '50 50'],
7848 ['a A', 'pm PM'],
7849 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
7850 ['L', '2010-02-14'],
7851 ['LTS', '3:25:50 PM'],
7852 ['LL', '14 February, 2010'],
7853 ['LLL', '14 February, 2010 3:25 PM'],
7854 ['LLLL', 'Sunday, 14 February, 2010 3:25 PM'],
7855 ['l', '2010-2-14'],
7856 ['ll', '14 Feb, 2010'],
7857 ['lll', '14 Feb, 2010 3:25 PM'],
7858 ['llll', 'Sun, 14 Feb, 2010 3:25 PM']
7859 ],
7860 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
7861 i;
7862
7863 for (i = 0; i < a.length; i++) {
7864 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
7865 }
7866 });
7867
7868 test('format ordinal', function (assert) {
7869 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
7870 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
7871 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
7872 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
7873 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
7874 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
7875 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
7876 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
7877 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
7878 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
7879
7880 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
7881 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
7882 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
7883 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
7884 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
7885 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
7886 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
7887 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
7888 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
7889 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
7890
7891 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
7892 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
7893 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
7894 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
7895 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
7896 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
7897 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
7898 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
7899 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
7900 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
7901
7902 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
7903 });
7904
7905 test('format month', function (assert) {
7906 var i,
7907 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('_');
7908
7909 for (i = 0; i < expected.length; i++) {
7910 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
7911 }
7912 });
7913
7914 test('format week', function (assert) {
7915 var i,
7916 expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_');
7917
7918 for (i = 0; i < expected.length; i++) {
7919 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
7920 }
7921 });
7922
7923 test('from', function (assert) {
7924 var start = moment([2007, 1, 28]);
7925 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
7926 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
7927 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
7928 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
7929 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
7930 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
7931 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
7932 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
7933 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
7934 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
7935 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
7936 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
7937 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
7938 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
7939 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
7940 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
7941 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
7942 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
7943 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
7944 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
7945 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
7946 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
7947 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
7948 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
7949 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
7950 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
7951 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
7952 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
7953 });
7954
7955 test('suffix', function (assert) {
7956 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
7957 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
7958 });
7959
7960 test('now from now', function (assert) {
7961 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
7962 });
7963
7964 test('fromNow', function (assert) {
7965 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
7966 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
7967 });
7968
7969 test('calendar day', function (assert) {
7970 var a = moment().hours(2).minutes(0).seconds(0);
7971
7972 assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
7973 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
7974 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
7975 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
7976 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
7977 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
7978 });
7979
7980 test('calendar next week', function (assert) {
7981 var i, m;
7982
7983 for (i = 2; i < 7; i++) {
7984 m = moment().add({d: i});
7985 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
7986 m.hours(0).minutes(0).seconds(0).milliseconds(0);
7987 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
7988 m.hours(23).minutes(59).seconds(59).milliseconds(999);
7989 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
7990 }
7991 });
7992
7993 test('calendar last week', function (assert) {
7994 var i, m;
7995
7996 for (i = 2; i < 7; i++) {
7997 m = moment().subtract({d: i});
7998 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
7999 m.hours(0).minutes(0).seconds(0).milliseconds(0);
8000 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
8001 m.hours(23).minutes(59).seconds(59).milliseconds(999);
8002 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
8003 }
8004 });
8005
8006 test('calendar all else', function (assert) {
8007 var weeksAgo = moment().subtract({w: 1}),
8008 weeksFromNow = moment().add({w: 1});
8009
8010 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
8011 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
8012
8013 weeksAgo = moment().subtract({w: 2});
8014 weeksFromNow = moment().add({w: 2});
8015
8016 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
8017 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
8018 });
8019
8020 test('weeks year starting sunday', function (assert) {
8021 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
8022 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
8023 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
8024 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
8025 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
8026 });
8027
8028 test('weeks year starting monday', function (assert) {
8029 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
8030 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
8031 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
8032 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
8033 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
8034 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
8035 });
8036
8037 test('weeks year starting tuesday', function (assert) {
8038 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
8039 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
8040 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
8041 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
8042 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
8043 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
8044 });
8045
8046 test('weeks year starting wednesday', function (assert) {
8047 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
8048 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
8049 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
8050 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
8051 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
8052 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
8053 });
8054
8055 test('weeks year starting thursday', function (assert) {
8056 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
8057 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
8058 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
8059 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
8060 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
8061 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
8062 });
8063
8064 test('weeks year starting friday', function (assert) {
8065 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
8066 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
8067 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
8068 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
8069 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
8070 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
8071 });
8072
8073 test('weeks year starting saturday', function (assert) {
8074 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
8075 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
8076 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
8077 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
8078 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
8079 });
8080
8081 test('weeks year starting sunday format', function (assert) {
8082 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
8083 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
8084 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2nd', 'Jan 8 2012 should be week 2');
8085 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', 'Jan 14 2012 should be week 2');
8086 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
8087 });
8088
8089 test('lenient ordinal parsing', function (assert) {
8090 var i, ordinalStr, testMoment;
8091 for (i = 1; i <= 31; ++i) {
8092 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
8093 testMoment = moment(ordinalStr, 'YYYY MM Do');
8094 assert.equal(testMoment.year(), 2014,
8095 'lenient ordinal parsing ' + i + ' year check');
8096 assert.equal(testMoment.month(), 0,
8097 'lenient ordinal parsing ' + i + ' month check');
8098 assert.equal(testMoment.date(), i,
8099 'lenient ordinal parsing ' + i + ' date check');
8100 }
8101 });
8102
8103 test('lenient ordinal parsing of number', function (assert) {
8104 var i, testMoment;
8105 for (i = 1; i <= 31; ++i) {
8106 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
8107 assert.equal(testMoment.year(), 2014,
8108 'lenient ordinal parsing of number ' + i + ' year check');
8109 assert.equal(testMoment.month(), 0,
8110 'lenient ordinal parsing of number ' + i + ' month check');
8111 assert.equal(testMoment.date(), i,
8112 'lenient ordinal parsing of number ' + i + ' date check');
8113 }
8114 });
8115
8116 test('strict ordinal parsing', function (assert) {
8117 var i, ordinalStr, testMoment;
8118 for (i = 1; i <= 31; ++i) {
8119 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
8120 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
8121 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
8122 }
8123 });
8124
8125 }));
8126
8127 (function (global, factory) {
8128 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
8129 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
8130 factory(global.moment)
8131 }(this, function (moment) { 'use strict';
8132
8133 /*global QUnit:false*/
8134
8135 var test = QUnit.test;
8136
8137 function module (name, lifecycle) {
8138 QUnit.module(name, {
8139 setup : function () {
8140 moment.locale('en');
8141 moment.createFromInputFallback = function () {
8142 throw new Error('input not handled by moment');
8143 };
8144 if (lifecycle && lifecycle.setup) {
8145 lifecycle.setup();
8146 }
8147 },
8148 teardown : function () {
8149 if (lifecycle && lifecycle.teardown) {
8150 lifecycle.teardown();
8151 }
8152 }
8153 });
8154 }
8155
8156 function localeModule (name, lifecycle) {
8157 QUnit.module('locale:' + name, {
8158 setup : function () {
8159 moment.locale(name);
8160 moment.createFromInputFallback = function () {
8161 throw new Error('input not handled by moment');
8162 };
8163 if (lifecycle && lifecycle.setup) {
8164 lifecycle.setup();
8165 }
8166 },
8167 teardown : function () {
8168 moment.locale('en');
8169 if (lifecycle && lifecycle.teardown) {
8170 lifecycle.teardown();
8171 }
8172 }
8173 });
8174 }
8175
8176 localeModule('en-gb');
8177
8178 test('parse', function (assert) {
8179 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;
8180 function equalTest(input, mmm, i) {
8181 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8182 }
8183 for (i = 0; i < 12; i++) {
8184 tests[i] = tests[i].split(' ');
8185 equalTest(tests[i][0], 'MMM', i);
8186 equalTest(tests[i][1], 'MMM', i);
8187 equalTest(tests[i][0], 'MMMM', i);
8188 equalTest(tests[i][1], 'MMMM', i);
8189 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
8190 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
8191 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
8192 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
8193 }
8194 });
8195
8196 test('format', function (assert) {
8197 var a = [
8198 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
8199 ['ddd, hA', 'Sun, 3PM'],
8200 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
8201 ['YYYY YY', '2010 10'],
8202 ['D Do DD', '14 14th 14'],
8203 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
8204 ['DDD DDDo DDDD', '45 45th 045'],
8205 ['w wo ww', '6 6th 06'],
8206 ['h hh', '3 03'],
8207 ['H HH', '15 15'],
8208 ['m mm', '25 25'],
8209 ['s ss', '50 50'],
8210 ['a A', 'pm PM'],
8211 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
8212 ['LTS', '15:25:50'],
8213 ['L', '14/02/2010'],
8214 ['LL', '14 February 2010'],
8215 ['LLL', '14 February 2010 15:25'],
8216 ['LLLL', 'Sunday, 14 February 2010 15:25'],
8217 ['l', '14/2/2010'],
8218 ['ll', '14 Feb 2010'],
8219 ['lll', '14 Feb 2010 15:25'],
8220 ['llll', 'Sun, 14 Feb 2010 15:25']
8221 ],
8222 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
8223 i;
8224 for (i = 0; i < a.length; i++) {
8225 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
8226 }
8227 });
8228
8229 test('format ordinal', function (assert) {
8230 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
8231 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
8232 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
8233 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
8234 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
8235 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
8236 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
8237 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
8238 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
8239 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
8240
8241 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
8242 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
8243 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
8244 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
8245 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
8246 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
8247 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
8248 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
8249 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
8250 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
8251
8252 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
8253 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
8254 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
8255 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
8256 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
8257 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
8258 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
8259 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
8260 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
8261 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
8262
8263 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
8264 });
8265
8266 test('format month', function (assert) {
8267 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;
8268 for (i = 0; i < expected.length; i++) {
8269 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
8270 }
8271 });
8272
8273 test('format week', function (assert) {
8274 var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_'), i;
8275 for (i = 0; i < expected.length; i++) {
8276 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
8277 }
8278 });
8279
8280 test('from', function (assert) {
8281 var start = moment([2007, 1, 28]);
8282 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
8283 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
8284 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
8285 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
8286 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
8287 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
8288 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
8289 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
8290 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
8291 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
8292 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
8293 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
8294 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
8295 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
8296 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
8297 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
8298 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
8299 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
8300 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
8301 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
8302 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
8303 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
8304 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
8305 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
8306 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
8307 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
8308 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
8309 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
8310 });
8311
8312 test('suffix', function (assert) {
8313 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
8314 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
8315 });
8316
8317 test('now from now', function (assert) {
8318 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
8319 });
8320
8321 test('fromNow', function (assert) {
8322 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
8323 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
8324 });
8325
8326 test('calendar day', function (assert) {
8327 var a = moment().hours(2).minutes(0).seconds(0);
8328
8329 assert.equal(moment(a).calendar(), 'Today at 02:00', 'today at the same time');
8330 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 02:25', 'Now plus 25 min');
8331 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 03:00', 'Now plus 1 hour');
8332 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 02:00', 'tomorrow at the same time');
8333 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 01:00', 'Now minus 1 hour');
8334 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 02:00', 'yesterday at the same time');
8335 });
8336
8337 test('calendar next week', function (assert) {
8338 var i, m;
8339 for (i = 2; i < 7; i++) {
8340 m = moment().add({d: i});
8341 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
8342 m.hours(0).minutes(0).seconds(0).milliseconds(0);
8343 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
8344 m.hours(23).minutes(59).seconds(59).milliseconds(999);
8345 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
8346 }
8347 });
8348
8349 test('calendar last week', function (assert) {
8350 var i, m;
8351
8352 for (i = 2; i < 7; i++) {
8353 m = moment().subtract({d: i});
8354 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
8355 m.hours(0).minutes(0).seconds(0).milliseconds(0);
8356 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
8357 m.hours(23).minutes(59).seconds(59).milliseconds(999);
8358 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
8359 }
8360 });
8361
8362 test('calendar all else', function (assert) {
8363 var weeksAgo = moment().subtract({w: 1}),
8364 weeksFromNow = moment().add({w: 1});
8365
8366 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
8367 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
8368
8369 weeksAgo = moment().subtract({w: 2});
8370 weeksFromNow = moment().add({w: 2});
8371
8372 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
8373 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
8374 });
8375
8376 test('weeks year starting sunday', function (assert) {
8377 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
8378 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
8379 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
8380 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
8381 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
8382 });
8383
8384 test('weeks year starting monday', function (assert) {
8385 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
8386 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
8387 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
8388 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
8389 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
8390 });
8391
8392 test('weeks year starting tuesday', function (assert) {
8393 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
8394 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
8395 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
8396 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
8397 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
8398 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
8399 });
8400
8401 test('weeks year starting wednesday', function (assert) {
8402 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
8403 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
8404 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
8405 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
8406 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
8407 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
8408 });
8409
8410 test('weeks year starting thursday', function (assert) {
8411 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
8412 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
8413 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
8414 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
8415 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
8416 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
8417 });
8418
8419 test('weeks year starting friday', function (assert) {
8420 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
8421 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
8422 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
8423 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
8424 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
8425 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
8426 });
8427
8428 test('weeks year starting saturday', function (assert) {
8429 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
8430 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
8431 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
8432 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
8433 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
8434 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
8435 });
8436
8437 test('weeks year starting sunday formatted', function (assert) {
8438 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
8439 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
8440 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', 'Jan 8 2012 should be week 1');
8441 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
8442 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
8443 });
8444
8445 test('lenient ordinal parsing', function (assert) {
8446 var i, ordinalStr, testMoment;
8447 for (i = 1; i <= 31; ++i) {
8448 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
8449 testMoment = moment(ordinalStr, 'YYYY MM Do');
8450 assert.equal(testMoment.year(), 2014,
8451 'lenient ordinal parsing ' + i + ' year check');
8452 assert.equal(testMoment.month(), 0,
8453 'lenient ordinal parsing ' + i + ' month check');
8454 assert.equal(testMoment.date(), i,
8455 'lenient ordinal parsing ' + i + ' date check');
8456 }
8457 });
8458
8459 test('lenient ordinal parsing of number', function (assert) {
8460 var i, testMoment;
8461 for (i = 1; i <= 31; ++i) {
8462 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
8463 assert.equal(testMoment.year(), 2014,
8464 'lenient ordinal parsing of number ' + i + ' year check');
8465 assert.equal(testMoment.month(), 0,
8466 'lenient ordinal parsing of number ' + i + ' month check');
8467 assert.equal(testMoment.date(), i,
8468 'lenient ordinal parsing of number ' + i + ' date check');
8469 }
8470 });
8471
8472 test('strict ordinal parsing', function (assert) {
8473 var i, ordinalStr, testMoment;
8474 for (i = 1; i <= 31; ++i) {
8475 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
8476 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
8477 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
8478 }
8479 });
8480
8481 }));
8482
8483 (function (global, factory) {
8484 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
8485 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
8486 factory(global.moment)
8487 }(this, function (moment) { 'use strict';
8488
8489 /*global QUnit:false*/
8490
8491 var test = QUnit.test;
8492
8493 function module (name, lifecycle) {
8494 QUnit.module(name, {
8495 setup : function () {
8496 moment.locale('en');
8497 moment.createFromInputFallback = function () {
8498 throw new Error('input not handled by moment');
8499 };
8500 if (lifecycle && lifecycle.setup) {
8501 lifecycle.setup();
8502 }
8503 },
8504 teardown : function () {
8505 if (lifecycle && lifecycle.teardown) {
8506 lifecycle.teardown();
8507 }
8508 }
8509 });
8510 }
8511
8512 function localeModule (name, lifecycle) {
8513 QUnit.module('locale:' + name, {
8514 setup : function () {
8515 moment.locale(name);
8516 moment.createFromInputFallback = function () {
8517 throw new Error('input not handled by moment');
8518 };
8519 if (lifecycle && lifecycle.setup) {
8520 lifecycle.setup();
8521 }
8522 },
8523 teardown : function () {
8524 moment.locale('en');
8525 if (lifecycle && lifecycle.teardown) {
8526 lifecycle.teardown();
8527 }
8528 }
8529 });
8530 }
8531
8532 localeModule('en');
8533
8534 test('parse', function (assert) {
8535 var i,
8536 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('_');
8537
8538 function equalTest(input, mmm, i) {
8539 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8540 }
8541
8542 for (i = 0; i < 12; i++) {
8543 tests[i] = tests[i].split(' ');
8544 equalTest(tests[i][0], 'MMM', i);
8545 equalTest(tests[i][1], 'MMM', i);
8546 equalTest(tests[i][0], 'MMMM', i);
8547 equalTest(tests[i][1], 'MMMM', i);
8548 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
8549 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
8550 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
8551 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
8552 }
8553 });
8554
8555 test('format', function (assert) {
8556 var a = [
8557 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
8558 ['ddd, hA', 'Sun, 3PM'],
8559 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
8560 ['YYYY YY', '2010 10'],
8561 ['D Do DD', '14 14th 14'],
8562 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
8563 ['DDD DDDo DDDD', '45 45th 045'],
8564 ['w wo ww', '8 8th 08'],
8565 ['h hh', '3 03'],
8566 ['H HH', '15 15'],
8567 ['m mm', '25 25'],
8568 ['s ss', '50 50'],
8569 ['a A', 'pm PM'],
8570 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
8571 ['LTS', '3:25:50 PM'],
8572 ['L', '02/14/2010'],
8573 ['LL', 'February 14, 2010'],
8574 ['LLL', 'February 14, 2010 3:25 PM'],
8575 ['LLLL', 'Sunday, February 14, 2010 3:25 PM'],
8576 ['l', '2/14/2010'],
8577 ['ll', 'Feb 14, 2010'],
8578 ['lll', 'Feb 14, 2010 3:25 PM'],
8579 ['llll', 'Sun, Feb 14, 2010 3:25 PM']
8580 ],
8581 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
8582 i;
8583
8584 for (i = 0; i < a.length; i++) {
8585 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
8586 }
8587 });
8588
8589 test('format ordinal', function (assert) {
8590 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
8591 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
8592 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
8593 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
8594 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
8595 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
8596 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
8597 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
8598 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
8599 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
8600
8601 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
8602 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
8603 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
8604 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
8605 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
8606 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
8607 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
8608 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
8609 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
8610 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
8611
8612 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
8613 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
8614 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
8615 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
8616 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
8617 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
8618 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
8619 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
8620 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
8621 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
8622
8623 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
8624 });
8625
8626 test('format month', function (assert) {
8627 var i,
8628 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('_');
8629
8630 for (i = 0; i < expected.length; i++) {
8631 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
8632 }
8633 });
8634
8635 test('format week', function (assert) {
8636 var i,
8637 expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_');
8638
8639 for (i = 0; i < expected.length; i++) {
8640 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
8641 }
8642 });
8643
8644 test('from', function (assert) {
8645 var start = moment([2007, 1, 28]);
8646
8647 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
8648 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
8649 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
8650 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
8651 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
8652 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
8653 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
8654 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
8655 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
8656 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
8657 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
8658 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
8659 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
8660 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
8661 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
8662 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
8663 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
8664 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
8665 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
8666 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
8667 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
8668 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
8669 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
8670 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
8671 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
8672 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
8673 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
8674 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
8675 });
8676
8677 test('suffix', function (assert) {
8678 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
8679 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
8680 });
8681
8682 test('now from now', function (assert) {
8683 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
8684 });
8685
8686 test('fromNow', function (assert) {
8687 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
8688 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
8689 });
8690
8691 test('calendar day', function (assert) {
8692 var a = moment().hours(2).minutes(0).seconds(0);
8693
8694 assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
8695 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
8696 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
8697 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
8698 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
8699 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
8700 });
8701
8702 test('calendar next week', function (assert) {
8703 var i, m;
8704
8705 for (i = 2; i < 7; i++) {
8706 m = moment().add({d: i});
8707 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
8708 m.hours(0).minutes(0).seconds(0).milliseconds(0);
8709 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
8710 m.hours(23).minutes(59).seconds(59).milliseconds(999);
8711 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
8712 }
8713 });
8714
8715 test('calendar last week', function (assert) {
8716 var i, m;
8717
8718 for (i = 2; i < 7; i++) {
8719 m = moment().subtract({d: i});
8720 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
8721 m.hours(0).minutes(0).seconds(0).milliseconds(0);
8722 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
8723 m.hours(23).minutes(59).seconds(59).milliseconds(999);
8724 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
8725 }
8726 });
8727
8728 test('calendar all else', function (assert) {
8729 var weeksAgo = moment().subtract({w: 1}),
8730 weeksFromNow = moment().add({w: 1});
8731
8732 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
8733 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
8734
8735 weeksAgo = moment().subtract({w: 2});
8736 weeksFromNow = moment().add({w: 2});
8737
8738 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
8739 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
8740 });
8741
8742 test('weeks year starting sunday', function (assert) {
8743 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
8744 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
8745 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
8746 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
8747 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
8748 });
8749
8750 test('weeks year starting monday', function (assert) {
8751 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
8752 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
8753 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
8754 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
8755 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
8756 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
8757 });
8758
8759 test('weeks year starting tuesday', function (assert) {
8760 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
8761 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
8762 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
8763 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
8764 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
8765 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
8766 });
8767
8768 test('weeks year starting wednesday', function (assert) {
8769 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
8770 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
8771 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
8772 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
8773 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
8774 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
8775 });
8776
8777 test('weeks year starting thursday', function (assert) {
8778 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
8779 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
8780 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
8781 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
8782 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
8783 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
8784 });
8785
8786 test('weeks year starting friday', function (assert) {
8787 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
8788 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
8789 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
8790 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
8791 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
8792 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
8793 });
8794
8795 test('weeks year starting saturday', function (assert) {
8796 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
8797 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
8798 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
8799 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
8800 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
8801 });
8802
8803 test('weeks year starting sunday format', function (assert) {
8804 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
8805 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
8806 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2nd', 'Jan 8 2012 should be week 2');
8807 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', 'Jan 14 2012 should be week 2');
8808 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
8809 });
8810
8811 test('lenient ordinal parsing', function (assert) {
8812 var i, ordinalStr, testMoment;
8813 for (i = 1; i <= 31; ++i) {
8814 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
8815 testMoment = moment(ordinalStr, 'YYYY MM Do');
8816 assert.equal(testMoment.year(), 2014,
8817 'lenient ordinal parsing ' + i + ' year check');
8818 assert.equal(testMoment.month(), 0,
8819 'lenient ordinal parsing ' + i + ' month check');
8820 assert.equal(testMoment.date(), i,
8821 'lenient ordinal parsing ' + i + ' date check');
8822 }
8823 });
8824
8825 test('lenient ordinal parsing of number', function (assert) {
8826 var i, testMoment;
8827 for (i = 1; i <= 31; ++i) {
8828 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
8829 assert.equal(testMoment.year(), 2014,
8830 'lenient ordinal parsing of number ' + i + ' year check');
8831 assert.equal(testMoment.month(), 0,
8832 'lenient ordinal parsing of number ' + i + ' month check');
8833 assert.equal(testMoment.date(), i,
8834 'lenient ordinal parsing of number ' + i + ' date check');
8835 }
8836 });
8837
8838 test('strict ordinal parsing', function (assert) {
8839 var i, ordinalStr, testMoment;
8840 for (i = 1; i <= 31; ++i) {
8841 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
8842 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
8843 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
8844 }
8845 });
8846
8847 }));
8848
8849 (function (global, factory) {
8850 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
8851 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
8852 factory(global.moment)
8853 }(this, function (moment) { 'use strict';
8854
8855 /*global QUnit:false*/
8856
8857 var test = QUnit.test;
8858
8859 function module (name, lifecycle) {
8860 QUnit.module(name, {
8861 setup : function () {
8862 moment.locale('en');
8863 moment.createFromInputFallback = function () {
8864 throw new Error('input not handled by moment');
8865 };
8866 if (lifecycle && lifecycle.setup) {
8867 lifecycle.setup();
8868 }
8869 },
8870 teardown : function () {
8871 if (lifecycle && lifecycle.teardown) {
8872 lifecycle.teardown();
8873 }
8874 }
8875 });
8876 }
8877
8878 function localeModule (name, lifecycle) {
8879 QUnit.module('locale:' + name, {
8880 setup : function () {
8881 moment.locale(name);
8882 moment.createFromInputFallback = function () {
8883 throw new Error('input not handled by moment');
8884 };
8885 if (lifecycle && lifecycle.setup) {
8886 lifecycle.setup();
8887 }
8888 },
8889 teardown : function () {
8890 moment.locale('en');
8891 if (lifecycle && lifecycle.teardown) {
8892 lifecycle.teardown();
8893 }
8894 }
8895 });
8896 }
8897
8898 localeModule('eo');
8899
8900 test('parse', function (assert) {
8901 var tests = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split('_'), i;
8902 function equalTest(input, mmm, i) {
8903 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8904 }
8905 for (i = 0; i < 12; i++) {
8906 tests[i] = tests[i].split(' ');
8907 equalTest(tests[i][0], 'MMM', i);
8908 equalTest(tests[i][1], 'MMM', i);
8909 equalTest(tests[i][0], 'MMMM', i);
8910 equalTest(tests[i][1], 'MMMM', i);
8911 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
8912 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
8913 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
8914 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
8915 }
8916 });
8917
8918 test('format', function (assert) {
8919 var a = [
8920 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Dimanĉo, februaro 14a 2010, 3:25:50 p.t.m.'],
8921 ['ddd, hA', 'Dim, 3P.T.M.'],
8922 ['M Mo MM MMMM MMM', '2 2a 02 februaro feb'],
8923 ['YYYY YY', '2010 10'],
8924 ['D Do DD', '14 14a 14'],
8925 ['d do dddd ddd dd', '0 0a Dimanĉo Dim Di'],
8926 ['DDD DDDo DDDD', '45 45a 045'],
8927 ['w wo ww', '7 7a 07'],
8928 ['h hh', '3 03'],
8929 ['H HH', '15 15'],
8930 ['m mm', '25 25'],
8931 ['s ss', '50 50'],
8932 ['a A', 'p.t.m. P.T.M.'],
8933 ['[la] DDDo [tago] [de] [la] [jaro]', 'la 45a tago de la jaro'],
8934 ['LTS', '15:25:50'],
8935 ['L', '2010-02-14'],
8936 ['LL', '14-an de februaro, 2010'],
8937 ['LLL', '14-an de februaro, 2010 15:25'],
8938 ['LLLL', 'Dimanĉo, la 14-an de februaro, 2010 15:25'],
8939 ['l', '2010-2-14'],
8940 ['ll', '14-an de feb, 2010'],
8941 ['lll', '14-an de feb, 2010 15:25'],
8942 ['llll', 'Dim, la 14-an de feb, 2010 15:25']
8943 ],
8944 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
8945 i;
8946 for (i = 0; i < a.length; i++) {
8947 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
8948 }
8949 });
8950
8951 test('format ordinal', function (assert) {
8952 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
8953 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
8954 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3a', '3a');
8955 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4a', '4a');
8956 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5a', '5a');
8957 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6a', '6a');
8958 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7a', '7a');
8959 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8a', '8a');
8960 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9a', '9a');
8961 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10a', '10a');
8962
8963 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11a', '11a');
8964 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12a', '12a');
8965 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13a', '13a');
8966 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14a', '14a');
8967 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15a', '15a');
8968 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16a', '16a');
8969 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17a', '17a');
8970 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18a', '18a');
8971 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19a', '19a');
8972 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20a', '20a');
8973
8974 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
8975 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
8976 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23a', '23a');
8977 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24a', '24a');
8978 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25a', '25a');
8979 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26a', '26a');
8980 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27a', '27a');
8981 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28a', '28a');
8982 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29a', '29a');
8983 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30a', '30a');
8984
8985 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
8986 });
8987
8988 test('format month', function (assert) {
8989 var expected = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split('_'), i;
8990 for (i = 0; i < expected.length; i++) {
8991 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
8992 }
8993 });
8994
8995 test('format week', function (assert) {
8996 var expected = 'Dimanĉo Dim Di_Lundo Lun Lu_Mardo Mard Ma_Merkredo Merk Me_Ĵaŭdo Ĵaŭ Ĵa_Vendredo Ven Ve_Sabato Sab Sa'.split('_'), i;
8997 for (i = 0; i < expected.length; i++) {
8998 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
8999 }
9000 });
9001
9002 test('from', function (assert) {
9003 var start = moment([2007, 1, 28]);
9004 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'sekundoj', '44 seconds = a few seconds');
9005 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuto', '45 seconds = a minute');
9006 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuto', '89 seconds = a minute');
9007 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutoj', '90 seconds = 2 minutes');
9008 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutoj', '44 minutes = 44 minutes');
9009 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'horo', '45 minutes = an hour');
9010 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'horo', '89 minutes = an hour');
9011 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horoj', '90 minutes = 2 hours');
9012 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horoj', '5 hours = 5 hours');
9013 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horoj', '21 hours = 21 hours');
9014 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'tago', '22 hours = a day');
9015 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'tago', '35 hours = a day');
9016 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 tagoj', '36 hours = 2 days');
9017 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'tago', '1 day = a day');
9018 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 tagoj', '5 days = 5 days');
9019 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 tagoj', '25 days = 25 days');
9020 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'monato', '26 days = a month');
9021 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'monato', '30 days = a month');
9022 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'monato', '43 days = a month');
9023 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 monatoj', '46 days = 2 months');
9024 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 monatoj', '75 days = 2 months');
9025 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 monatoj', '76 days = 3 months');
9026 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'monato', '1 month = a month');
9027 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 monatoj', '5 months = 5 months');
9028 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'jaro', '345 days = a year');
9029 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jaroj', '548 days = 2 years');
9030 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'jaro', '1 year = a year');
9031 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jaroj', '5 years = 5 years');
9032 });
9033
9034 test('suffix', function (assert) {
9035 assert.equal(moment(30000).from(0), 'je sekundoj', 'je prefix');
9036 assert.equal(moment(0).from(30000), 'antaŭ sekundoj', 'antaŭ prefix');
9037 });
9038
9039 test('now from now', function (assert) {
9040 assert.equal(moment().fromNow(), 'antaŭ sekundoj', 'now from now should display as in the past');
9041 });
9042
9043 test('fromNow', function (assert) {
9044 assert.equal(moment().add({s: 30}).fromNow(), 'je sekundoj', 'je sekundoj');
9045 assert.equal(moment().add({d: 5}).fromNow(), 'je 5 tagoj', 'je 5 tagoj');
9046 });
9047
9048 test('calendar day', function (assert) {
9049 var a = moment().hours(2).minutes(0).seconds(0);
9050
9051 assert.equal(moment(a).calendar(), 'Hodiaŭ je 02:00', 'today at the same time');
9052 assert.equal(moment(a).add({m: 25}).calendar(), 'Hodiaŭ je 02:25', 'Now plus 25 min');
9053 assert.equal(moment(a).add({h: 1}).calendar(), 'Hodiaŭ je 03:00', 'Now plus 1 hour');
9054 assert.equal(moment(a).add({d: 1}).calendar(), 'Morgaŭ je 02:00', 'tomorrow at the same time');
9055 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hodiaŭ je 01:00', 'Now minus 1 hour');
9056 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hieraŭ je 02:00', 'yesterday at the same time');
9057 });
9058
9059 test('calendar next week', function (assert) {
9060 var i, m;
9061
9062 for (i = 2; i < 7; i++) {
9063 m = moment().add({d: i});
9064 assert.equal(m.calendar(), m.format('dddd [je] LT'), 'Today + ' + i + ' days current time');
9065 m.hours(0).minutes(0).seconds(0).milliseconds(0);
9066 assert.equal(m.calendar(), m.format('dddd [je] LT'), 'Today + ' + i + ' days beginning of day');
9067 m.hours(23).minutes(59).seconds(59).milliseconds(999);
9068 assert.equal(m.calendar(), m.format('dddd [je] LT'), 'Today + ' + i + ' days end of day');
9069 }
9070 });
9071
9072 test('calendar last week', function (assert) {
9073 var i, m;
9074
9075 for (i = 2; i < 7; i++) {
9076 m = moment().subtract({d: i});
9077 assert.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), 'Today - ' + i + ' days current time');
9078 m.hours(0).minutes(0).seconds(0).milliseconds(0);
9079 assert.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), 'Today - ' + i + ' days beginning of day');
9080 m.hours(23).minutes(59).seconds(59).milliseconds(999);
9081 assert.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), 'Today - ' + i + ' days end of day');
9082 }
9083 });
9084
9085 test('calendar all else', function (assert) {
9086 var weeksAgo = moment().subtract({w: 1}),
9087 weeksFromNow = moment().add({w: 1});
9088
9089 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
9090 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
9091
9092 weeksAgo = moment().subtract({w: 2});
9093 weeksFromNow = moment().add({w: 2});
9094
9095 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
9096 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
9097 });
9098
9099 test('weeks year starting sunday', function (assert) {
9100 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
9101 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
9102 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
9103 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
9104 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
9105 });
9106
9107 test('weeks year starting monday', function (assert) {
9108 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
9109 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
9110 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
9111 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
9112 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
9113 });
9114
9115 test('weeks year starting tuesday', function (assert) {
9116 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
9117 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
9118 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
9119 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
9120 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
9121 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
9122 });
9123
9124 test('weeks year starting wednesday', function (assert) {
9125 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
9126 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
9127 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
9128 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
9129 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
9130 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
9131 });
9132
9133 test('weeks year starting thursday', function (assert) {
9134 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
9135 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
9136 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
9137 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
9138 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
9139 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
9140 });
9141
9142 test('weeks year starting friday', function (assert) {
9143 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
9144 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
9145 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
9146 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
9147 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
9148 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
9149 });
9150
9151 test('weeks year starting saturday', function (assert) {
9152 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
9153 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
9154 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
9155 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
9156 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
9157 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
9158 });
9159
9160 test('weeks year starting sunday formatted', function (assert) {
9161 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1a', 'Dec 26 2011 should be week 1');
9162 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1a', 'Jan 1 2012 should be week 1');
9163 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2a', 'Jan 2 2012 should be week 2');
9164 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2a', 'Jan 8 2012 should be week 2');
9165 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3a', 'Jan 9 2012 should be week 3');
9166 });
9167
9168 test('lenient ordinal parsing', function (assert) {
9169 var i, ordinalStr, testMoment;
9170 for (i = 1; i <= 31; ++i) {
9171 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
9172 testMoment = moment(ordinalStr, 'YYYY MM Do');
9173 assert.equal(testMoment.year(), 2014,
9174 'lenient ordinal parsing ' + i + ' year check');
9175 assert.equal(testMoment.month(), 0,
9176 'lenient ordinal parsing ' + i + ' month check');
9177 assert.equal(testMoment.date(), i,
9178 'lenient ordinal parsing ' + i + ' date check');
9179 }
9180 });
9181
9182 test('lenient ordinal parsing of number', function (assert) {
9183 var i, testMoment;
9184 for (i = 1; i <= 31; ++i) {
9185 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
9186 assert.equal(testMoment.year(), 2014,
9187 'lenient ordinal parsing of number ' + i + ' year check');
9188 assert.equal(testMoment.month(), 0,
9189 'lenient ordinal parsing of number ' + i + ' month check');
9190 assert.equal(testMoment.date(), i,
9191 'lenient ordinal parsing of number ' + i + ' date check');
9192 }
9193 });
9194
9195 test('strict ordinal parsing', function (assert) {
9196 var i, ordinalStr, testMoment;
9197 for (i = 1; i <= 31; ++i) {
9198 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
9199 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
9200 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
9201 }
9202 });
9203
9204 }));
9205
9206 (function (global, factory) {
9207 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
9208 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
9209 factory(global.moment)
9210 }(this, function (moment) { 'use strict';
9211
9212 /*global QUnit:false*/
9213
9214 var test = QUnit.test;
9215
9216 function module (name, lifecycle) {
9217 QUnit.module(name, {
9218 setup : function () {
9219 moment.locale('en');
9220 moment.createFromInputFallback = function () {
9221 throw new Error('input not handled by moment');
9222 };
9223 if (lifecycle && lifecycle.setup) {
9224 lifecycle.setup();
9225 }
9226 },
9227 teardown : function () {
9228 if (lifecycle && lifecycle.teardown) {
9229 lifecycle.teardown();
9230 }
9231 }
9232 });
9233 }
9234
9235 function localeModule (name, lifecycle) {
9236 QUnit.module('locale:' + name, {
9237 setup : function () {
9238 moment.locale(name);
9239 moment.createFromInputFallback = function () {
9240 throw new Error('input not handled by moment');
9241 };
9242 if (lifecycle && lifecycle.setup) {
9243 lifecycle.setup();
9244 }
9245 },
9246 teardown : function () {
9247 moment.locale('en');
9248 if (lifecycle && lifecycle.teardown) {
9249 lifecycle.teardown();
9250 }
9251 }
9252 });
9253 }
9254
9255 localeModule('es');
9256
9257 test('parse', function (assert) {
9258 var tests = 'enero ene._febrero feb._marzo mar._abril abr._mayo may._junio jun._julio jul._agosto ago._septiembre sep._octubre oct._noviembre nov._diciembre dic.'.split('_'), i;
9259 function equalTest(input, mmm, i) {
9260 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9261 }
9262 for (i = 0; i < 12; i++) {
9263 tests[i] = tests[i].split(' ');
9264 equalTest(tests[i][0], 'MMM', i);
9265 equalTest(tests[i][1], 'MMM', i);
9266 equalTest(tests[i][0], 'MMMM', i);
9267 equalTest(tests[i][1], 'MMMM', i);
9268 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
9269 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
9270 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
9271 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
9272 }
9273 });
9274
9275 test('format', function (assert) {
9276 var a = [
9277 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Febrero 14º 2010, 3:25:50 pm'],
9278 ['ddd, hA', 'Dom., 3PM'],
9279 ['M Mo MM MMMM MMM', '2 2º 02 Febrero Feb.'],
9280 ['YYYY YY', '2010 10'],
9281 ['D Do DD', '14 14º 14'],
9282 ['d do dddd ddd dd', '0 0º Domingo Dom. Do'],
9283 ['DDD DDDo DDDD', '45 45º 045'],
9284 ['w wo ww', '6 6º 06'],
9285 ['YYYY-MMM-DD', '2010-Feb-14'],
9286 ['h hh', '3 03'],
9287 ['H HH', '15 15'],
9288 ['m mm', '25 25'],
9289 ['s ss', '50 50'],
9290 ['a A', 'pm PM'],
9291 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
9292 ['LTS', '15:25:50'],
9293 ['L', '14/02/2010'],
9294 ['LL', '14 de Febrero de 2010'],
9295 ['LLL', '14 de Febrero de 2010 15:25'],
9296 ['LLLL', 'Domingo, 14 de Febrero de 2010 15:25'],
9297 ['l', '14/2/2010'],
9298 ['ll', '14 de Feb. de 2010'],
9299 ['lll', '14 de Feb. de 2010 15:25'],
9300 ['llll', 'Dom., 14 de Feb. de 2010 15:25']
9301 ],
9302 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
9303 i;
9304 for (i = 0; i < a.length; i++) {
9305 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
9306 }
9307 });
9308
9309 test('format ordinal', function (assert) {
9310 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
9311 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
9312 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
9313 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
9314 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
9315 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
9316 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
9317 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
9318 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
9319 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
9320
9321 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
9322 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
9323 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
9324 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
9325 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
9326 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
9327 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
9328 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
9329 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
9330 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
9331
9332 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
9333 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
9334 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
9335 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
9336 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
9337 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
9338 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
9339 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
9340 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
9341 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
9342
9343 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
9344 });
9345
9346 test('format month', function (assert) {
9347 var expected = 'Enero Ene._Febrero Feb._Marzo Mar._Abril Abr._Mayo May._Junio Jun._Julio Jul._Agosto Ago._Septiembre Sep._Octubre Oct._Noviembre Nov._Diciembre Dic.'.split('_'), i;
9348 for (i = 0; i < expected.length; i++) {
9349 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
9350 }
9351 });
9352
9353 test('format week', function (assert) {
9354 var expected = 'Domingo Dom. Do_Lunes Lun. Lu_Martes Mar. Ma_Miércoles Mié. Mi_Jueves Jue. Ju_Viernes Vie. Vi_Sábado Sáb. Sá'.split('_'), i;
9355 for (i = 0; i < expected.length; i++) {
9356 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
9357 }
9358 });
9359
9360 test('from', function (assert) {
9361 var start = moment([2007, 1, 28]);
9362 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'unos segundos', '44 seconds = a few seconds');
9363 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minuto', '45 seconds = a minute');
9364 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minuto', '89 seconds = a minute');
9365 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
9366 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
9367 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'una hora', '45 minutes = an hour');
9368 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'una hora', '89 minutes = an hour');
9369 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
9370 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
9371 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
9372 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un día', '22 hours = a day');
9373 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un día', '35 hours = a day');
9374 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 días', '36 hours = 2 days');
9375 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un día', '1 day = a day');
9376 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 días', '5 days = 5 days');
9377 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 días', '25 days = 25 days');
9378 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mes', '26 days = a month');
9379 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mes', '30 days = a month');
9380 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mes', '43 days = a month');
9381 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
9382 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
9383 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
9384 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mes', '1 month = a month');
9385 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
9386 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un año', '345 days = a year');
9387 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 años', '548 days = 2 years');
9388 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un año', '1 year = a year');
9389 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 años', '5 years = 5 years');
9390 });
9391
9392 test('suffix', function (assert) {
9393 assert.equal(moment(30000).from(0), 'en unos segundos', 'prefix');
9394 assert.equal(moment(0).from(30000), 'hace unos segundos', 'suffix');
9395 });
9396
9397 test('now from now', function (assert) {
9398 assert.equal(moment().fromNow(), 'hace unos segundos', 'now from now should display as in the past');
9399 });
9400
9401 test('fromNow', function (assert) {
9402 assert.equal(moment().add({s: 30}).fromNow(), 'en unos segundos', 'en unos segundos');
9403 assert.equal(moment().add({d: 5}).fromNow(), 'en 5 días', 'en 5 días');
9404 });
9405
9406 test('calendar day', function (assert) {
9407 var a = moment().hours(2).minutes(0).seconds(0);
9408
9409 assert.equal(moment(a).calendar(), 'hoy a las 2:00', 'today at the same time');
9410 assert.equal(moment(a).add({m: 25}).calendar(), 'hoy a las 2:25', 'Now plus 25 min');
9411 assert.equal(moment(a).add({h: 1}).calendar(), 'hoy a las 3:00', 'Now plus 1 hour');
9412 assert.equal(moment(a).add({d: 1}).calendar(), 'mañana a las 2:00', 'tomorrow at the same time');
9413 assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañana a la 1:00', 'tomorrow minus 1 hour');
9414 assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoy a la 1:00', 'Now minus 1 hour');
9415 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ayer a las 2:00', 'yesterday at the same time');
9416 });
9417
9418 test('calendar next week', function (assert) {
9419 var i, m;
9420
9421 for (i = 2; i < 7; i++) {
9422 m = moment().add({d: i});
9423 assert.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today + ' + i + ' days current time');
9424 m.hours(0).minutes(0).seconds(0).milliseconds(0);
9425 assert.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today + ' + i + ' days beginning of day');
9426 m.hours(23).minutes(59).seconds(59).milliseconds(999);
9427 assert.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today + ' + i + ' days end of day');
9428 }
9429 });
9430
9431 test('calendar last week', function (assert) {
9432 var i, m;
9433
9434 for (i = 2; i < 7; i++) {
9435 m = moment().subtract({d: i});
9436 assert.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today - ' + i + ' days current time');
9437 m.hours(0).minutes(0).seconds(0).milliseconds(0);
9438 assert.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today - ' + i + ' days beginning of day');
9439 m.hours(23).minutes(59).seconds(59).milliseconds(999);
9440 assert.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today - ' + i + ' days end of day');
9441 }
9442 });
9443
9444 test('calendar all else', function (assert) {
9445 var weeksAgo = moment().subtract({w: 1}),
9446 weeksFromNow = moment().add({w: 1});
9447
9448 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
9449 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
9450
9451 weeksAgo = moment().subtract({w: 2});
9452 weeksFromNow = moment().add({w: 2});
9453
9454 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
9455 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
9456 });
9457
9458 test('weeks year starting sunday', function (assert) {
9459 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
9460 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
9461 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
9462 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
9463 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
9464 });
9465
9466 test('weeks year starting monday', function (assert) {
9467 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
9468 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
9469 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
9470 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
9471 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
9472 });
9473
9474 test('weeks year starting tuesday', function (assert) {
9475 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
9476 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
9477 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
9478 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
9479 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
9480 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
9481 });
9482
9483 test('weeks year starting wednesday', function (assert) {
9484 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
9485 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
9486 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
9487 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
9488 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
9489 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
9490 });
9491
9492 test('weeks year starting thursday', function (assert) {
9493 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
9494 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
9495 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
9496 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
9497 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
9498 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
9499 });
9500
9501 test('weeks year starting friday', function (assert) {
9502 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
9503 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
9504 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
9505 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
9506 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
9507 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
9508 });
9509
9510 test('weeks year starting saturday', function (assert) {
9511 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
9512 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
9513 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
9514 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
9515 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
9516 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
9517 });
9518
9519 test('weeks year starting sunday formatted', function (assert) {
9520 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
9521 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
9522 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', 'Jan 8 2012 should be week 1');
9523 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2');
9524 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
9525 });
9526
9527 test('lenient ordinal parsing', function (assert) {
9528 var i, ordinalStr, testMoment;
9529 for (i = 1; i <= 31; ++i) {
9530 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
9531 testMoment = moment(ordinalStr, 'YYYY MM Do');
9532 assert.equal(testMoment.year(), 2014,
9533 'lenient ordinal parsing ' + i + ' year check');
9534 assert.equal(testMoment.month(), 0,
9535 'lenient ordinal parsing ' + i + ' month check');
9536 assert.equal(testMoment.date(), i,
9537 'lenient ordinal parsing ' + i + ' date check');
9538 }
9539 });
9540
9541 test('lenient ordinal parsing of number', function (assert) {
9542 var i, testMoment;
9543 for (i = 1; i <= 31; ++i) {
9544 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
9545 assert.equal(testMoment.year(), 2014,
9546 'lenient ordinal parsing of number ' + i + ' year check');
9547 assert.equal(testMoment.month(), 0,
9548 'lenient ordinal parsing of number ' + i + ' month check');
9549 assert.equal(testMoment.date(), i,
9550 'lenient ordinal parsing of number ' + i + ' date check');
9551 }
9552 });
9553
9554 test('strict ordinal parsing', function (assert) {
9555 var i, ordinalStr, testMoment;
9556 for (i = 1; i <= 31; ++i) {
9557 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
9558 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
9559 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
9560 }
9561 });
9562
9563 }));
9564
9565 (function (global, factory) {
9566 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
9567 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
9568 factory(global.moment)
9569 }(this, function (moment) { 'use strict';
9570
9571 /*global QUnit:false*/
9572
9573 var test = QUnit.test;
9574
9575 function module (name, lifecycle) {
9576 QUnit.module(name, {
9577 setup : function () {
9578 moment.locale('en');
9579 moment.createFromInputFallback = function () {
9580 throw new Error('input not handled by moment');
9581 };
9582 if (lifecycle && lifecycle.setup) {
9583 lifecycle.setup();
9584 }
9585 },
9586 teardown : function () {
9587 if (lifecycle && lifecycle.teardown) {
9588 lifecycle.teardown();
9589 }
9590 }
9591 });
9592 }
9593
9594 function localeModule (name, lifecycle) {
9595 QUnit.module('locale:' + name, {
9596 setup : function () {
9597 moment.locale(name);
9598 moment.createFromInputFallback = function () {
9599 throw new Error('input not handled by moment');
9600 };
9601 if (lifecycle && lifecycle.setup) {
9602 lifecycle.setup();
9603 }
9604 },
9605 teardown : function () {
9606 moment.locale('en');
9607 if (lifecycle && lifecycle.teardown) {
9608 lifecycle.teardown();
9609 }
9610 }
9611 });
9612 }
9613
9614 localeModule('et');
9615
9616 test('parse', function (assert) {
9617 var tests = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split('_'), i;
9618 function equalTest(input, mmm, i) {
9619 assert.equal(moment(input, mmm).month(), i, input + ' peaks olema kuu ' + (i + 1));
9620 }
9621 for (i = 0; i < 12; i++) {
9622 tests[i] = tests[i].split(' ');
9623 equalTest(tests[i][0], 'MMM', i);
9624 equalTest(tests[i][1], 'MMM', i);
9625 equalTest(tests[i][0], 'MMMM', i);
9626 equalTest(tests[i][1], 'MMMM', i);
9627 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
9628 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
9629 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
9630 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
9631 }
9632 });
9633
9634 test('format', function (assert) {
9635 var a = [
9636 ['dddd, Do MMMM YYYY, H:mm:ss', 'pühapäev, 14. veebruar 2010, 15:25:50'],
9637 ['ddd, h', 'P, 3'],
9638 ['M Mo MM MMMM MMM', '2 2. 02 veebruar veebr'],
9639 ['YYYY YY', '2010 10'],
9640 ['D Do DD', '14 14. 14'],
9641 ['d do dddd ddd dd', '0 0. pühapäev P P'],
9642 ['DDD DDDo DDDD', '45 45. 045'],
9643 ['w wo ww', '6 6. 06'],
9644 ['h hh', '3 03'],
9645 ['H HH', '15 15'],
9646 ['m mm', '25 25'],
9647 ['s ss', '50 50'],
9648 ['a A', 'pm PM'],
9649 ['[aasta] DDDo [päev]', 'aasta 45. päev'],
9650 ['LTS', '15:25:50'],
9651 ['L', '14.02.2010'],
9652 ['LL', '14. veebruar 2010'],
9653 ['LLL', '14. veebruar 2010 15:25'],
9654 ['LLLL', 'pühapäev, 14. veebruar 2010 15:25'],
9655 ['l', '14.2.2010'],
9656 ['ll', '14. veebr 2010'],
9657 ['lll', '14. veebr 2010 15:25'],
9658 ['llll', 'P, 14. veebr 2010 15:25']
9659 ],
9660 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
9661 i;
9662 for (i = 0; i < a.length; i++) {
9663 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
9664 }
9665 });
9666
9667 test('format ordinal', function (assert) {
9668 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
9669 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
9670 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
9671 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
9672 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
9673 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
9674 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
9675 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
9676 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
9677 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
9678
9679 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
9680 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
9681 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
9682 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
9683 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
9684 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
9685 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
9686 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
9687 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
9688 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
9689
9690 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
9691 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
9692 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
9693 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
9694 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
9695 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
9696 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
9697 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
9698 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
9699 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
9700
9701 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
9702 });
9703
9704 test('format month', function (assert) {
9705 var expected = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split('_'), i;
9706 for (i = 0; i < expected.length; i++) {
9707 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
9708 }
9709 });
9710
9711 test('format week', function (assert) {
9712 var expected = 'pühapäev P P_esmaspäev E E_teisipäev T T_kolmapäev K K_neljapäev N N_reede R R_laupäev L L'.split('_'), i;
9713 for (i = 0; i < expected.length; i++) {
9714 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
9715 }
9716 });
9717
9718 test('from', function (assert) {
9719 var start = moment([2007, 1, 28]);
9720 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'paar sekundit', '44 seconds = paar sekundit');
9721 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'üks minut', '45 seconds = üks minut');
9722 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'üks minut', '89 seconds = üks minut');
9723 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutit', '90 seconds = 2 minutit');
9724 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutit', '44 minutes = 44 minutit');
9725 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'üks tund', '45 minutes = tund aega');
9726 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'üks tund', '89 minutes = üks tund');
9727 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 tundi', '90 minutes = 2 tundi');
9728 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 tundi', '5 hours = 5 tundi');
9729 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tundi', '21 hours = 21 tundi');
9730 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'üks päev', '22 hours = üks päev');
9731 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'üks päev', '35 hours = üks päev');
9732 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 päeva', '36 hours = 2 päeva');
9733 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'üks päev', '1 day = üks päev');
9734 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 päeva', '5 days = 5 päeva');
9735 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 päeva', '25 days = 25 päeva');
9736 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'üks kuu', '26 days = üks kuu');
9737 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'üks kuu', '30 days = üks kuu');
9738 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'üks kuu', '43 days = üks kuu');
9739 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 kuud', '46 days = 2 kuud');
9740 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 kuud', '75 days = 2 kuud');
9741 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 kuud', '76 days = 3 kuud');
9742 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'üks kuu', '1 month = üks kuu');
9743 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 kuud', '5 months = 5 kuud');
9744 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'üks aasta', '345 days = üks aasta');
9745 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 aastat', '548 days = 2 aastat');
9746 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'üks aasta', '1 year = üks aasta');
9747 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 aastat', '5 years = 5 aastat');
9748 });
9749
9750 test('suffix', function (assert) {
9751 assert.equal(moment(30000).from(0), 'mõne sekundi pärast', 'prefix');
9752 assert.equal(moment(0).from(30000), 'mõni sekund tagasi', 'suffix');
9753 });
9754
9755 test('now from now', function (assert) {
9756 assert.equal(moment().fromNow(), 'mõni sekund tagasi', 'now from now should display as in the past');
9757 });
9758
9759 test('fromNow', function (assert) {
9760 assert.equal(moment().add({s: 30}).fromNow(), 'mõne sekundi pärast', 'in a few seconds');
9761 assert.equal(moment().subtract({s: 30}).fromNow(), 'mõni sekund tagasi', 'a few seconds ago');
9762
9763 assert.equal(moment().add({m: 1}).fromNow(), 'ühe minuti pärast', 'in a minute');
9764 assert.equal(moment().subtract({m: 1}).fromNow(), 'üks minut tagasi', 'a minute ago');
9765
9766 assert.equal(moment().add({m: 5}).fromNow(), '5 minuti pärast', 'in 5 minutes');
9767 assert.equal(moment().subtract({m: 5}).fromNow(), '5 minutit tagasi', '5 minutes ago');
9768
9769 assert.equal(moment().add({d: 1}).fromNow(), 'ühe päeva pärast', 'in one day');
9770 assert.equal(moment().subtract({d: 1}).fromNow(), 'üks päev tagasi', 'one day ago');
9771
9772 assert.equal(moment().add({d: 5}).fromNow(), '5 päeva pärast', 'in 5 days');
9773 assert.equal(moment().subtract({d: 5}).fromNow(), '5 päeva tagasi', '5 days ago');
9774
9775 assert.equal(moment().add({M: 1}).fromNow(), 'kuu aja pärast', 'in a month');
9776 assert.equal(moment().subtract({M: 1}).fromNow(), 'kuu aega tagasi', 'a month ago');
9777
9778 assert.equal(moment().add({M: 5}).fromNow(), '5 kuu pärast', 'in 5 months');
9779 assert.equal(moment().subtract({M: 5}).fromNow(), '5 kuud tagasi', '5 months ago');
9780
9781 assert.equal(moment().add({y: 1}).fromNow(), 'ühe aasta pärast', 'in a year');
9782 assert.equal(moment().subtract({y: 1}).fromNow(), 'aasta tagasi', 'a year ago');
9783
9784 assert.equal(moment().add({y: 5}).fromNow(), '5 aasta pärast', 'in 5 years');
9785 assert.equal(moment().subtract({y: 5}).fromNow(), '5 aastat tagasi', '5 years ago');
9786 });
9787
9788 test('calendar day', function (assert) {
9789 var a = moment().hours(2).minutes(0).seconds(0);
9790
9791 assert.equal(moment(a).calendar(), 'Täna, 2:00', 'today at the same time');
9792 assert.equal(moment(a).add({m: 25}).calendar(), 'Täna, 2:25', 'Now plus 25 min');
9793 assert.equal(moment(a).add({h: 1}).calendar(), 'Täna, 3:00', 'Now plus 1 hour');
9794 assert.equal(moment(a).add({d: 1}).calendar(), 'Homme, 2:00', 'tomorrow at the same time');
9795 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Täna, 1:00', 'Now minus 1 hour');
9796 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Eile, 2:00', 'yesterday at the same time');
9797 });
9798
9799 test('calendar next week', function (assert) {
9800 var i, m;
9801 for (i = 2; i < 7; i++) {
9802 m = moment().add({d: i});
9803 assert.equal(m.calendar(), m.format('[Järgmine] dddd LT'), 'Today + ' + i + ' days current time');
9804 m.hours(0).minutes(0).seconds(0).milliseconds(0);
9805 assert.equal(m.calendar(), m.format('[Järgmine] dddd LT'), 'Today + ' + i + ' days beginning of day');
9806 m.hours(23).minutes(59).seconds(59).milliseconds(999);
9807 assert.equal(m.calendar(), m.format('[Järgmine] dddd LT'), 'Today + ' + i + ' days end of day');
9808 }
9809 });
9810
9811 test('calendar last week', function (assert) {
9812 var i, m;
9813 for (i = 2; i < 7; i++) {
9814 m = moment().subtract({d: i});
9815 assert.equal(m.calendar(), m.format('[Eelmine] dddd LT'), 'Today - ' + i + ' days current time');
9816 m.hours(0).minutes(0).seconds(0).milliseconds(0);
9817 assert.equal(m.calendar(), m.format('[Eelmine] dddd LT'), 'Today - ' + i + ' days beginning of day');
9818 m.hours(23).minutes(59).seconds(59).milliseconds(999);
9819 assert.equal(m.calendar(), m.format('[Eelmine] dddd LT'), 'Today - ' + i + ' days end of day');
9820 }
9821 });
9822
9823 test('calendar all else', function (assert) {
9824 var weeksAgo = moment().subtract({w: 1}),
9825 weeksFromNow = moment().add({w: 1});
9826
9827 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 nädal tagasi');
9828 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '1 nädala pärast');
9829
9830 weeksAgo = moment().subtract({w: 2});
9831 weeksFromNow = moment().add({w: 2});
9832
9833 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 nädalat tagasi');
9834 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 nädala pärast');
9835 });
9836
9837 test('weeks year starting sunday', function (assert) {
9838 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
9839 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
9840 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
9841 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
9842 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
9843 });
9844
9845 test('weeks year starting monday', function (assert) {
9846 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
9847 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
9848 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
9849 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
9850 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
9851 });
9852
9853 test('weeks year starting tuesday', function (assert) {
9854 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
9855 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
9856 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
9857 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
9858 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
9859 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
9860 });
9861
9862 test('weeks year starting wednesday', function (assert) {
9863 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
9864 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
9865 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
9866 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
9867 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
9868 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
9869 });
9870
9871 test('weeks year starting thursday', function (assert) {
9872 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
9873 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
9874 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
9875 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
9876 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
9877 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
9878 });
9879
9880 test('weeks year starting friday', function (assert) {
9881 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
9882 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
9883 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
9884 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
9885 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
9886 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
9887 });
9888
9889 test('weeks year starting saturday', function (assert) {
9890 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
9891 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
9892 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
9893 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
9894 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
9895 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
9896 });
9897
9898 test('weeks year starting sunday formatted', function (assert) {
9899 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
9900 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
9901 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
9902 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
9903 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
9904 });
9905
9906 test('lenient ordinal parsing', function (assert) {
9907 var i, ordinalStr, testMoment;
9908 for (i = 1; i <= 31; ++i) {
9909 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
9910 testMoment = moment(ordinalStr, 'YYYY MM Do');
9911 assert.equal(testMoment.year(), 2014,
9912 'lenient ordinal parsing ' + i + ' year check');
9913 assert.equal(testMoment.month(), 0,
9914 'lenient ordinal parsing ' + i + ' month check');
9915 assert.equal(testMoment.date(), i,
9916 'lenient ordinal parsing ' + i + ' date check');
9917 }
9918 });
9919
9920 test('lenient ordinal parsing of number', function (assert) {
9921 var i, testMoment;
9922 for (i = 1; i <= 31; ++i) {
9923 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
9924 assert.equal(testMoment.year(), 2014,
9925 'lenient ordinal parsing of number ' + i + ' year check');
9926 assert.equal(testMoment.month(), 0,
9927 'lenient ordinal parsing of number ' + i + ' month check');
9928 assert.equal(testMoment.date(), i,
9929 'lenient ordinal parsing of number ' + i + ' date check');
9930 }
9931 });
9932
9933 test('strict ordinal parsing', function (assert) {
9934 var i, ordinalStr, testMoment;
9935 for (i = 1; i <= 31; ++i) {
9936 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
9937 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
9938 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
9939 }
9940 });
9941
9942 }));
9943
9944 (function (global, factory) {
9945 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
9946 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
9947 factory(global.moment)
9948 }(this, function (moment) { 'use strict';
9949
9950 /*global QUnit:false*/
9951
9952 var test = QUnit.test;
9953
9954 function module (name, lifecycle) {
9955 QUnit.module(name, {
9956 setup : function () {
9957 moment.locale('en');
9958 moment.createFromInputFallback = function () {
9959 throw new Error('input not handled by moment');
9960 };
9961 if (lifecycle && lifecycle.setup) {
9962 lifecycle.setup();
9963 }
9964 },
9965 teardown : function () {
9966 if (lifecycle && lifecycle.teardown) {
9967 lifecycle.teardown();
9968 }
9969 }
9970 });
9971 }
9972
9973 function localeModule (name, lifecycle) {
9974 QUnit.module('locale:' + name, {
9975 setup : function () {
9976 moment.locale(name);
9977 moment.createFromInputFallback = function () {
9978 throw new Error('input not handled by moment');
9979 };
9980 if (lifecycle && lifecycle.setup) {
9981 lifecycle.setup();
9982 }
9983 },
9984 teardown : function () {
9985 moment.locale('en');
9986 if (lifecycle && lifecycle.teardown) {
9987 lifecycle.teardown();
9988 }
9989 }
9990 });
9991 }
9992
9993 localeModule('eu');
9994
9995 test('parse', function (assert) {
9996 var tests = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split('_'), i;
9997 function equalTest(input, mmm, i) {
9998 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9999 }
10000 for (i = 0; i < 12; i++) {
10001 tests[i] = tests[i].split(' ');
10002 equalTest(tests[i][0], 'MMM', i);
10003 equalTest(tests[i][1], 'MMM', i);
10004 equalTest(tests[i][0], 'MMMM', i);
10005 equalTest(tests[i][1], 'MMMM', i);
10006 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
10007 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
10008 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
10009 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
10010 }
10011 });
10012
10013 test('format', function (assert) {
10014 var a = [
10015 ['dddd, MMMM Do YYYY, h:mm:ss a', 'igandea, otsaila 14. 2010, 3:25:50 pm'],
10016 ['ddd, hA', 'ig., 3PM'],
10017 ['M Mo MM MMMM MMM', '2 2. 02 otsaila ots.'],
10018 ['YYYY YY', '2010 10'],
10019 ['D Do DD', '14 14. 14'],
10020 ['d do dddd ddd dd', '0 0. igandea ig. ig'],
10021 ['DDD DDDo DDDD', '45 45. 045'],
10022 ['w wo ww', '7 7. 07'],
10023 ['h hh', '3 03'],
10024 ['H HH', '15 15'],
10025 ['m mm', '25 25'],
10026 ['s ss', '50 50'],
10027 ['a A', 'pm PM'],
10028 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
10029 ['LTS', '15:25:50'],
10030 ['L', '2010-02-14'],
10031 ['LL', '2010ko otsailaren 14a'],
10032 ['LLL', '2010ko otsailaren 14a 15:25'],
10033 ['LLLL', 'igandea, 2010ko otsailaren 14a 15:25'],
10034 ['l', '2010-2-14'],
10035 ['ll', '2010ko ots. 14a'],
10036 ['lll', '2010ko ots. 14a 15:25'],
10037 ['llll', 'ig., 2010ko ots. 14a 15:25']
10038 ],
10039 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
10040 i;
10041 for (i = 0; i < a.length; i++) {
10042 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
10043 }
10044 });
10045
10046 test('format ordinal', function (assert) {
10047 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
10048 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
10049 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
10050 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
10051 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
10052 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
10053 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
10054 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
10055 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
10056 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
10057
10058 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
10059 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
10060 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
10061 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
10062 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
10063 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
10064 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
10065 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
10066 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
10067 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
10068
10069 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
10070 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
10071 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
10072 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
10073 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
10074 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
10075 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
10076 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
10077 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
10078 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
10079
10080 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
10081 });
10082
10083 test('format month', function (assert) {
10084 var expected = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split('_'), i;
10085 for (i = 0; i < expected.length; i++) {
10086 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
10087 }
10088 });
10089
10090 test('format week', function (assert) {
10091 var expected = 'igandea ig. ig_astelehena al. al_asteartea ar. ar_asteazkena az. az_osteguna og. og_ostirala ol. ol_larunbata lr. lr'.split('_'), i;
10092 for (i = 0; i < expected.length; i++) {
10093 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
10094 }
10095 });
10096
10097 test('from', function (assert) {
10098 var start = moment([2007, 1, 28]);
10099 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'segundo batzuk', '44 seconds = a few seconds');
10100 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minutu bat', '45 seconds = a minute');
10101 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minutu bat', '89 seconds = a minute');
10102 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutu', '90 seconds = 2 minutes');
10103 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutu', '44 minutes = 44 minutes');
10104 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ordu bat', '45 minutes = an hour');
10105 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ordu bat', '89 minutes = an hour');
10106 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ordu', '90 minutes = 2 hours');
10107 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ordu', '5 hours = 5 hours');
10108 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ordu', '21 hours = 21 hours');
10109 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'egun bat', '22 hours = a day');
10110 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'egun bat', '35 hours = a day');
10111 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 egun', '36 hours = 2 days');
10112 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'egun bat', '1 day = a day');
10113 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 egun', '5 days = 5 days');
10114 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 egun', '25 days = 25 days');
10115 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'hilabete bat', '26 days = a month');
10116 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'hilabete bat', '30 days = a month');
10117 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'hilabete bat', '43 days = a month');
10118 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 hilabete', '46 days = 2 months');
10119 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 hilabete', '75 days = 2 months');
10120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 hilabete', '76 days = 3 months');
10121 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'hilabete bat', '1 month = a month');
10122 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 hilabete', '5 months = 5 months');
10123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'urte bat', '345 days = a year');
10124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 urte', '548 days = 2 years');
10125 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'urte bat', '1 year = a year');
10126 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 urte', '5 years = 5 years');
10127 });
10128
10129 test('suffix', function (assert) {
10130 assert.equal(moment(30000).from(0), 'segundo batzuk barru', 'prefix');
10131 assert.equal(moment(0).from(30000), 'duela segundo batzuk', 'suffix');
10132 });
10133
10134 test('now from now', function (assert) {
10135 assert.equal(moment().fromNow(), 'duela segundo batzuk', 'now from now should display as in the past');
10136 });
10137
10138 test('fromNow', function (assert) {
10139 assert.equal(moment().add({s: 30}).fromNow(), 'segundo batzuk barru', 'in seconds');
10140 assert.equal(moment().add({d: 5}).fromNow(), '5 egun barru', 'in 5 days');
10141 });
10142
10143 test('calendar day', function (assert) {
10144 var a = moment().hours(2).minutes(0).seconds(0);
10145
10146 assert.equal(moment(a).calendar(), 'gaur 02:00etan', 'today at the same time');
10147 assert.equal(moment(a).add({m: 25}).calendar(), 'gaur 02:25etan', 'now plus 25 min');
10148 assert.equal(moment(a).add({h: 1}).calendar(), 'gaur 03:00etan', 'now plus 1 hour');
10149 assert.equal(moment(a).add({d: 1}).calendar(), 'bihar 02:00etan', 'tomorrow at the same time');
10150 assert.equal(moment(a).subtract({h: 1}).calendar(), 'gaur 01:00etan', 'now minus 1 hour');
10151 assert.equal(moment(a).subtract({d: 1}).calendar(), 'atzo 02:00etan', 'yesterday at the same time');
10152 });
10153
10154 test('calendar next week', function (assert) {
10155 var i, m;
10156 for (i = 2; i < 7; i++) {
10157 m = moment().add({d: i});
10158 assert.equal(m.calendar(), m.format('dddd LT[etan]'), 'Today + ' + i + ' days current time');
10159 m.hours(0).minutes(0).seconds(0).milliseconds(0);
10160 assert.equal(m.calendar(), m.format('dddd LT[etan]'), 'Today + ' + i + ' days beginning of day');
10161 m.hours(23).minutes(59).seconds(59).milliseconds(999);
10162 assert.equal(m.calendar(), m.format('dddd LT[etan]'), 'Today + ' + i + ' days end of day');
10163 }
10164 });
10165
10166 test('calendar last week', function (assert) {
10167 var i, m;
10168 for (i = 2; i < 7; i++) {
10169 m = moment().subtract({d: i});
10170 assert.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), 'Today - ' + i + ' days current time');
10171 m.hours(0).minutes(0).seconds(0).milliseconds(0);
10172 assert.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), 'Today - ' + i + ' days beginning of day');
10173 m.hours(23).minutes(59).seconds(59).milliseconds(999);
10174 assert.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), 'Today - ' + i + ' days end of day');
10175 }
10176 });
10177
10178 test('calendar all else', function (assert) {
10179 var weeksAgo = moment().subtract({w: 1}),
10180 weeksFromNow = moment().add({w: 1});
10181
10182 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
10183 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
10184
10185 weeksAgo = moment().subtract({w: 2});
10186 weeksFromNow = moment().add({w: 2});
10187
10188 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
10189 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
10190 });
10191
10192 test('weeks year starting sunday', function (assert) {
10193 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
10194 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
10195 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
10196 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
10197 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
10198 });
10199
10200 test('weeks year starting monday', function (assert) {
10201 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
10202 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
10203 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
10204 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
10205 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
10206 });
10207
10208 test('weeks year starting tuesday', function (assert) {
10209 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
10210 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
10211 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
10212 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
10213 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
10214 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
10215 });
10216
10217 test('weeks year starting wednesday', function (assert) {
10218 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
10219 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
10220 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
10221 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
10222 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
10223 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
10224 });
10225
10226 test('weeks year starting thursday', function (assert) {
10227 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
10228 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
10229 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
10230 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
10231 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
10232 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
10233 });
10234
10235 test('weeks year starting friday', function (assert) {
10236 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
10237 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
10238 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
10239 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
10240 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
10241 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
10242 });
10243
10244 test('weeks year starting saturday', function (assert) {
10245 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
10246 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
10247 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
10248 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
10249 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
10250 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
10251 });
10252
10253 test('weeks year starting sunday formatted', function (assert) {
10254 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
10255 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
10256 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
10257 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
10258 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
10259 });
10260
10261 test('lenient ordinal parsing', function (assert) {
10262 var i, ordinalStr, testMoment;
10263 for (i = 1; i <= 31; ++i) {
10264 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
10265 testMoment = moment(ordinalStr, 'YYYY MM Do');
10266 assert.equal(testMoment.year(), 2014,
10267 'lenient ordinal parsing ' + i + ' year check');
10268 assert.equal(testMoment.month(), 0,
10269 'lenient ordinal parsing ' + i + ' month check');
10270 assert.equal(testMoment.date(), i,
10271 'lenient ordinal parsing ' + i + ' date check');
10272 }
10273 });
10274
10275 test('lenient ordinal parsing of number', function (assert) {
10276 var i, testMoment;
10277 for (i = 1; i <= 31; ++i) {
10278 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
10279 assert.equal(testMoment.year(), 2014,
10280 'lenient ordinal parsing of number ' + i + ' year check');
10281 assert.equal(testMoment.month(), 0,
10282 'lenient ordinal parsing of number ' + i + ' month check');
10283 assert.equal(testMoment.date(), i,
10284 'lenient ordinal parsing of number ' + i + ' date check');
10285 }
10286 });
10287
10288 test('strict ordinal parsing', function (assert) {
10289 var i, ordinalStr, testMoment;
10290 for (i = 1; i <= 31; ++i) {
10291 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
10292 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
10293 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
10294 }
10295 });
10296
10297 }));
10298
10299 (function (global, factory) {
10300 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
10301 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
10302 factory(global.moment)
10303 }(this, function (moment) { 'use strict';
10304
10305 /*global QUnit:false*/
10306
10307 var test = QUnit.test;
10308
10309 function module (name, lifecycle) {
10310 QUnit.module(name, {
10311 setup : function () {
10312 moment.locale('en');
10313 moment.createFromInputFallback = function () {
10314 throw new Error('input not handled by moment');
10315 };
10316 if (lifecycle && lifecycle.setup) {
10317 lifecycle.setup();
10318 }
10319 },
10320 teardown : function () {
10321 if (lifecycle && lifecycle.teardown) {
10322 lifecycle.teardown();
10323 }
10324 }
10325 });
10326 }
10327
10328 function localeModule (name, lifecycle) {
10329 QUnit.module('locale:' + name, {
10330 setup : function () {
10331 moment.locale(name);
10332 moment.createFromInputFallback = function () {
10333 throw new Error('input not handled by moment');
10334 };
10335 if (lifecycle && lifecycle.setup) {
10336 lifecycle.setup();
10337 }
10338 },
10339 teardown : function () {
10340 moment.locale('en');
10341 if (lifecycle && lifecycle.teardown) {
10342 lifecycle.teardown();
10343 }
10344 }
10345 });
10346 }
10347
10348 localeModule('fa');
10349
10350 test('parse', function (assert) {
10351 var tests = 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'), i;
10352 function equalTest(input, mmm, i) {
10353 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
10354 }
10355 for (i = 0; i < 12; i++) {
10356 equalTest(tests[i], 'MMM', i);
10357 equalTest(tests[i], 'MMMM', i);
10358 }
10359 });
10360
10361 test('format', function (assert) {
10362 var a = [
10363 ['dddd, MMMM Do YYYY, h:mm:ss a', 'یک\u200cشنبه، فوریه ۱۴م ۲۰۱۰، ۳:۲۵:۵۰ بعد از ظهر'],
10364 ['ddd, hA', 'یک\u200cشنبه، ۳بعد از ظهر'],
10365 ['M Mo MM MMMM MMM', '۲ ۲م ۰۲ فوریه فوریه'],
10366 ['YYYY YY', '۲۰۱۰ ۱۰'],
10367 ['D Do DD', '۱۴ ۱۴م ۱۴'],
10368 ['d do dddd ddd dd', '۰ ۰م یک\u200cشنبه یک\u200cشنبه ی'],
10369 ['DDD DDDo DDDD', '۴۵ ۴۵م ۰۴۵'],
10370 ['w wo ww', '۸ ۸م ۰۸'],
10371 ['h hh', '۳ ۰۳'],
10372 ['H HH', '۱۵ ۱۵'],
10373 ['m mm', '۲۵ ۲۵'],
10374 ['s ss', '۵۰ ۵۰'],
10375 ['a A', 'بعد از ظهر بعد از ظهر'],
10376 ['DDDo [روز سال]', '۴۵م روز سال'],
10377 ['LTS', '۱۵:۲۵:۵۰'],
10378 ['L', '۱۴/۰۲/۲۰۱۰'],
10379 ['LL', '۱۴ فوریه ۲۰۱۰'],
10380 ['LLL', '۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
10381 ['LLLL', 'یک\u200cشنبه، ۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
10382 ['l', '۱۴/۲/۲۰۱۰'],
10383 ['ll', '۱۴ فوریه ۲۰۱۰'],
10384 ['lll', '۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
10385 ['llll', 'یک\u200cشنبه، ۱۴ فوریه ۲۰۱۰ ۱۵:۲۵']
10386 ],
10387 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
10388 i;
10389 for (i = 0; i < a.length; i++) {
10390 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
10391 }
10392 });
10393
10394 test('format ordinal', function (assert) {
10395 assert.equal(moment([2011, 0, 1]).format('DDDo'), '۱م', '1');
10396 assert.equal(moment([2011, 0, 2]).format('DDDo'), '۲م', '2');
10397 assert.equal(moment([2011, 0, 3]).format('DDDo'), '۳م', '3');
10398 assert.equal(moment([2011, 0, 4]).format('DDDo'), '۴م', '4');
10399 assert.equal(moment([2011, 0, 5]).format('DDDo'), '۵م', '5');
10400 assert.equal(moment([2011, 0, 6]).format('DDDo'), '۶م', '6');
10401 assert.equal(moment([2011, 0, 7]).format('DDDo'), '۷م', '7');
10402 assert.equal(moment([2011, 0, 8]).format('DDDo'), '۸م', '8');
10403 assert.equal(moment([2011, 0, 9]).format('DDDo'), '۹م', '9');
10404 assert.equal(moment([2011, 0, 10]).format('DDDo'), '۱۰م', '10');
10405
10406 assert.equal(moment([2011, 0, 11]).format('DDDo'), '۱۱م', '11');
10407 assert.equal(moment([2011, 0, 12]).format('DDDo'), '۱۲م', '12');
10408 assert.equal(moment([2011, 0, 13]).format('DDDo'), '۱۳م', '13');
10409 assert.equal(moment([2011, 0, 14]).format('DDDo'), '۱۴م', '14');
10410 assert.equal(moment([2011, 0, 15]).format('DDDo'), '۱۵م', '15');
10411 assert.equal(moment([2011, 0, 16]).format('DDDo'), '۱۶م', '16');
10412 assert.equal(moment([2011, 0, 17]).format('DDDo'), '۱۷م', '17');
10413 assert.equal(moment([2011, 0, 18]).format('DDDo'), '۱۸م', '18');
10414 assert.equal(moment([2011, 0, 19]).format('DDDo'), '۱۹م', '19');
10415 assert.equal(moment([2011, 0, 20]).format('DDDo'), '۲۰م', '20');
10416
10417 assert.equal(moment([2011, 0, 21]).format('DDDo'), '۲۱م', '21');
10418 assert.equal(moment([2011, 0, 22]).format('DDDo'), '۲۲م', '22');
10419 assert.equal(moment([2011, 0, 23]).format('DDDo'), '۲۳م', '23');
10420 assert.equal(moment([2011, 0, 24]).format('DDDo'), '۲۴م', '24');
10421 assert.equal(moment([2011, 0, 25]).format('DDDo'), '۲۵م', '25');
10422 assert.equal(moment([2011, 0, 26]).format('DDDo'), '۲۶م', '26');
10423 assert.equal(moment([2011, 0, 27]).format('DDDo'), '۲۷م', '27');
10424 assert.equal(moment([2011, 0, 28]).format('DDDo'), '۲۸م', '28');
10425 assert.equal(moment([2011, 0, 29]).format('DDDo'), '۲۹م', '29');
10426 assert.equal(moment([2011, 0, 30]).format('DDDo'), '۳۰م', '30');
10427
10428 assert.equal(moment([2011, 0, 31]).format('DDDo'), '۳۱م', '31');
10429 });
10430
10431 test('format month', function (assert) {
10432 var expected = 'ژانویه ژانویه_فوریه فوریه_مارس مارس_آوریل آوریل_مه مه_ژوئن ژوئن_ژوئیه ژوئیه_اوت اوت_سپتامبر سپتامبر_اکتبر اکتبر_نوامبر نوامبر_دسامبر دسامبر'.split('_'), i;
10433 for (i = 0; i < expected.length; i++) {
10434 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
10435 }
10436 });
10437
10438 test('format week', function (assert) {
10439 var expected = 'یک\u200cشنبه یک\u200cشنبه ی_دوشنبه دوشنبه د_سه\u200cشنبه سه\u200cشنبه س_چهارشنبه چهارشنبه چ_پنج\u200cشنبه پنج\u200cشنبه پ_جمعه جمعه ج_شنبه شنبه ش'.split('_'), i;
10440 for (i = 0; i < expected.length; i++) {
10441 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
10442 }
10443 });
10444
10445 test('from', function (assert) {
10446 var start = moment([2007, 1, 28]);
10447 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'چندین ثانیه', '44 seconds = a few seconds');
10448 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'یک دقیقه', '45 seconds = a minute');
10449 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'یک دقیقه', '89 seconds = a minute');
10450 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '۲ دقیقه', '90 seconds = 2 minutes');
10451 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '۴۴ دقیقه', '44 minutes = 44 minutes');
10452 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'یک ساعت', '45 minutes = an hour');
10453 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'یک ساعت', '89 minutes = an hour');
10454 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '۲ ساعت', '90 minutes = 2 hours');
10455 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '۵ ساعت', '5 hours = 5 hours');
10456 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '۲۱ ساعت', '21 hours = 21 hours');
10457 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'یک روز', '22 hours = a day');
10458 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'یک روز', '35 hours = a day');
10459 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '۲ روز', '36 hours = 2 days');
10460 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'یک روز', '1 day = a day');
10461 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '۵ روز', '5 days = 5 days');
10462 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '۲۵ روز', '25 days = 25 days');
10463 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'یک ماه', '26 days = a month');
10464 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'یک ماه', '30 days = a month');
10465 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'یک ماه', '43 days = a month');
10466 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '۲ ماه', '46 days = 2 months');
10467 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '۲ ماه', '75 days = 2 months');
10468 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '۳ ماه', '76 days = 3 months');
10469 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'یک ماه', '1 month = a month');
10470 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '۵ ماه', '5 months = 5 months');
10471 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'یک سال', '345 days = a year');
10472 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '۲ سال', '548 days = 2 years');
10473 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'یک سال', '1 year = a year');
10474 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '۵ سال', '5 years = 5 years');
10475 });
10476
10477 test('suffix', function (assert) {
10478 assert.equal(moment(30000).from(0), 'در چندین ثانیه', 'prefix');
10479 assert.equal(moment(0).from(30000), 'چندین ثانیه پیش', 'suffix');
10480 });
10481
10482 test('now from now', function (assert) {
10483 assert.equal(moment().fromNow(), 'چندین ثانیه پیش', 'now from now should display as in the past');
10484 });
10485
10486 test('fromNow', function (assert) {
10487 assert.equal(moment().add({s: 30}).fromNow(), 'در چندین ثانیه', 'in a few seconds');
10488 assert.equal(moment().add({d: 5}).fromNow(), 'در ۵ روز', 'in 5 days');
10489 });
10490
10491 test('calendar day', function (assert) {
10492 var a = moment().hours(2).minutes(0).seconds(0);
10493
10494 assert.equal(moment(a).calendar(), 'امروز ساعت ۰۲:۰۰', 'today at the same time');
10495 assert.equal(moment(a).add({m: 25}).calendar(), 'امروز ساعت ۰۲:۲۵', 'Now plus 25 min');
10496 assert.equal(moment(a).add({h: 1}).calendar(), 'امروز ساعت ۰۳:۰۰', 'Now plus 1 hour');
10497 assert.equal(moment(a).add({d: 1}).calendar(), 'فردا ساعت ۰۲:۰۰', 'tomorrow at the same time');
10498 assert.equal(moment(a).subtract({h: 1}).calendar(), 'امروز ساعت ۰۱:۰۰', 'Now minus 1 hour');
10499 assert.equal(moment(a).subtract({d: 1}).calendar(), 'دیروز ساعت ۰۲:۰۰', 'yesterday at the same time');
10500 });
10501
10502 test('calendar next week', function (assert) {
10503 var i, m;
10504 for (i = 2; i < 7; i++) {
10505 m = moment().add({d: i});
10506 assert.equal(m.calendar(), m.format('dddd [ساعت] LT'), 'Today + ' + i + ' days current time');
10507 m.hours(0).minutes(0).seconds(0).milliseconds(0);
10508 assert.equal(m.calendar(), m.format('dddd [ساعت] LT'), 'Today + ' + i + ' days beginning of day');
10509 m.hours(23).minutes(59).seconds(59).milliseconds(999);
10510 assert.equal(m.calendar(), m.format('dddd [ساعت] LT'), 'Today + ' + i + ' days end of day');
10511 }
10512 });
10513
10514 test('calendar last week', function (assert) {
10515 var i, m;
10516 for (i = 2; i < 7; i++) {
10517 m = moment().subtract({d: i});
10518 assert.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), 'Today - ' + i + ' days current time');
10519 m.hours(0).minutes(0).seconds(0).milliseconds(0);
10520 assert.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), 'Today - ' + i + ' days beginning of day');
10521 m.hours(23).minutes(59).seconds(59).milliseconds(999);
10522 assert.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), 'Today - ' + i + ' days end of day');
10523 }
10524 });
10525
10526 test('calendar all else', function (assert) {
10527 var weeksAgo = moment().subtract({w: 1}),
10528 weeksFromNow = moment().add({w: 1});
10529
10530 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
10531 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
10532
10533 weeksAgo = moment().subtract({w: 2});
10534 weeksFromNow = moment().add({w: 2});
10535
10536 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
10537 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
10538 });
10539
10540 test('weeks year starting sunday', function (assert) {
10541 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
10542 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
10543 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
10544 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
10545 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
10546 });
10547
10548 test('weeks year starting monday', function (assert) {
10549 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
10550 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
10551 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
10552 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
10553 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
10554 });
10555
10556 test('weeks year starting tuesday', function (assert) {
10557 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
10558 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
10559 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
10560 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
10561 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
10562 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
10563 });
10564
10565 test('weeks year starting wednesday', function (assert) {
10566 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
10567 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
10568 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
10569 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
10570 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
10571 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
10572 });
10573
10574 test('weeks year starting thursday', function (assert) {
10575 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
10576 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
10577 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
10578 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
10579 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
10580 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
10581 });
10582
10583 test('weeks year starting friday', function (assert) {
10584 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
10585 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
10586 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
10587 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
10588 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
10589 });
10590
10591 test('weeks year starting saturday', function (assert) {
10592 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
10593 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
10594 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
10595 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
10596 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
10597 });
10598
10599 test('weeks year starting sunday formatted', function (assert) {
10600 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '۱ ۰۱ ۱م', 'Dec 31 2011 should be week 1');
10601 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '۱ ۰۱ ۱م', 'Jan 6 2012 should be week 1');
10602 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '۲ ۰۲ ۲م', 'Jan 7 2012 should be week 2');
10603 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '۲ ۰۲ ۲م', 'Jan 13 2012 should be week 2');
10604 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '۳ ۰۳ ۳م', 'Jan 14 2012 should be week 3');
10605 });
10606
10607 test('lenient ordinal parsing', function (assert) {
10608 var i, ordinalStr, testMoment;
10609 for (i = 1; i <= 31; ++i) {
10610 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
10611 testMoment = moment(ordinalStr, 'YYYY MM Do');
10612 assert.equal(testMoment.year(), 2014,
10613 'lenient ordinal parsing ' + i + ' year check');
10614 assert.equal(testMoment.month(), 0,
10615 'lenient ordinal parsing ' + i + ' month check');
10616 assert.equal(testMoment.date(), i,
10617 'lenient ordinal parsing ' + i + ' date check');
10618 }
10619 });
10620
10621 test('lenient ordinal parsing of number', function (assert) {
10622 var i, testMoment;
10623 for (i = 1; i <= 31; ++i) {
10624 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
10625 assert.equal(testMoment.year(), 2014,
10626 'lenient ordinal parsing of number ' + i + ' year check');
10627 assert.equal(testMoment.month(), 0,
10628 'lenient ordinal parsing of number ' + i + ' month check');
10629 assert.equal(testMoment.date(), i,
10630 'lenient ordinal parsing of number ' + i + ' date check');
10631 }
10632 });
10633
10634 test('strict ordinal parsing', function (assert) {
10635 var i, ordinalStr, testMoment;
10636 for (i = 1; i <= 31; ++i) {
10637 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
10638 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
10639 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
10640 }
10641 });
10642
10643 }));
10644
10645 (function (global, factory) {
10646 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
10647 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
10648 factory(global.moment)
10649 }(this, function (moment) { 'use strict';
10650
10651 /*global QUnit:false*/
10652
10653 var test = QUnit.test;
10654
10655 function module (name, lifecycle) {
10656 QUnit.module(name, {
10657 setup : function () {
10658 moment.locale('en');
10659 moment.createFromInputFallback = function () {
10660 throw new Error('input not handled by moment');
10661 };
10662 if (lifecycle && lifecycle.setup) {
10663 lifecycle.setup();
10664 }
10665 },
10666 teardown : function () {
10667 if (lifecycle && lifecycle.teardown) {
10668 lifecycle.teardown();
10669 }
10670 }
10671 });
10672 }
10673
10674 function localeModule (name, lifecycle) {
10675 QUnit.module('locale:' + name, {
10676 setup : function () {
10677 moment.locale(name);
10678 moment.createFromInputFallback = function () {
10679 throw new Error('input not handled by moment');
10680 };
10681 if (lifecycle && lifecycle.setup) {
10682 lifecycle.setup();
10683 }
10684 },
10685 teardown : function () {
10686 moment.locale('en');
10687 if (lifecycle && lifecycle.teardown) {
10688 lifecycle.teardown();
10689 }
10690 }
10691 });
10692 }
10693
10694 localeModule('fi');
10695
10696 test('parse', function (assert) {
10697 var tests = 'tammikuu tammi_helmikuu helmi_maaliskuu maalis_huhtikuu huhti_toukokuu touko_kesäkuu kesä_heinäkuu heinä_elokuu elo_syyskuu syys_lokakuu loka_marraskuu marras_joulukuu joulu'.split('_'), i;
10698 function equalTest(input, mmm, i) {
10699 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10700 }
10701 for (i = 0; i < 12; i++) {
10702 tests[i] = tests[i].split(' ');
10703 equalTest(tests[i][0], 'MMM', i);
10704 equalTest(tests[i][1], 'MMM', i);
10705 equalTest(tests[i][0], 'MMMM', i);
10706 equalTest(tests[i][1], 'MMMM', i);
10707 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
10708 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
10709 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
10710 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
10711 }
10712 });
10713
10714 test('format', function (assert) {
10715 var a = [
10716 ['dddd, MMMM Do YYYY, h:mm:ss a', 'sunnuntai, helmikuu 14. 2010, 3:25:50 pm'],
10717 ['ddd, hA', 'su, 3PM'],
10718 ['M Mo MM MMMM MMM', '2 2. 02 helmikuu helmi'],
10719 ['YYYY YY', '2010 10'],
10720 ['D Do DD', '14 14. 14'],
10721 ['d do dddd ddd dd', '0 0. sunnuntai su su'],
10722 ['DDD DDDo DDDD', '45 45. 045'],
10723 ['w wo ww', '6 6. 06'],
10724 ['h hh', '3 03'],
10725 ['H HH', '15 15'],
10726 ['m mm', '25 25'],
10727 ['s ss', '50 50'],
10728 ['a A', 'pm PM'],
10729 ['[vuoden] DDDo [päivä]', 'vuoden 45. päivä'],
10730 ['LTS', '15.25.50'],
10731 ['L', '14.02.2010'],
10732 ['LL', '14. helmikuuta 2010'],
10733 ['LLL', '14. helmikuuta 2010, klo 15.25'],
10734 ['LLLL', 'sunnuntai, 14. helmikuuta 2010, klo 15.25'],
10735 ['l', '14.2.2010'],
10736 ['ll', '14. helmi 2010'],
10737 ['lll', '14. helmi 2010, klo 15.25'],
10738 ['llll', 'su, 14. helmi 2010, klo 15.25']
10739 ],
10740 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
10741 i;
10742 for (i = 0; i < a.length; i++) {
10743 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
10744 }
10745 });
10746
10747 test('format ordinal', function (assert) {
10748 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1st');
10749 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2nd');
10750 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3rd');
10751 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4th');
10752 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5th');
10753 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6th');
10754 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7th');
10755 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8th');
10756 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9th');
10757 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10th');
10758
10759 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11th');
10760 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12th');
10761 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13th');
10762 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14th');
10763 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15th');
10764 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16th');
10765 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17th');
10766 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18th');
10767 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19th');
10768 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20th');
10769
10770 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21st');
10771 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22nd');
10772 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23rd');
10773 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24th');
10774 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25th');
10775 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26th');
10776 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27th');
10777 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28th');
10778 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29th');
10779 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30th');
10780
10781 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31st');
10782 });
10783
10784 test('format month', function (assert) {
10785 var expected = 'tammikuu tammi_helmikuu helmi_maaliskuu maalis_huhtikuu huhti_toukokuu touko_kesäkuu kesä_heinäkuu heinä_elokuu elo_syyskuu syys_lokakuu loka_marraskuu marras_joulukuu joulu'.split('_'), i;
10786 for (i = 0; i < expected.length; i++) {
10787 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
10788 }
10789 });
10790
10791 test('format week', function (assert) {
10792 var expected = 'sunnuntai su su_maanantai ma ma_tiistai ti ti_keskiviikko ke ke_torstai to to_perjantai pe pe_lauantai la la'.split('_'), i;
10793 for (i = 0; i < expected.length; i++) {
10794 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
10795 }
10796 });
10797
10798 test('from', function (assert) {
10799 var start = moment([2007, 1, 28]);
10800 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'muutama sekunti', '44 seconds = few seconds');
10801 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuutti', '45 seconds = a minute');
10802 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuutti', '89 seconds = a minute');
10803 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'kaksi minuuttia', '90 seconds = 2 minutes');
10804 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuuttia', '44 minutes = 44 minutes');
10805 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'tunti', '45 minutes = an hour');
10806 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'tunti', '89 minutes = an hour');
10807 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'kaksi tuntia', '90 minutes = 2 hours');
10808 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'viisi tuntia', '5 hours = 5 hours');
10809 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tuntia', '21 hours = 21 hours');
10810 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'päivä', '22 hours = a day');
10811 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'päivä', '35 hours = a day');
10812 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'kaksi päivää', '36 hours = 2 days');
10813 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'päivä', '1 day = a day');
10814 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'viisi päivää', '5 days = 5 days');
10815 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 päivää', '25 days = 25 days');
10816 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'kuukausi', '26 days = a month');
10817 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'kuukausi', '30 days = a month');
10818 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'kuukausi', '43 days = a month');
10819 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'kaksi kuukautta', '46 days = 2 months');
10820 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'kaksi kuukautta', '75 days = 2 months');
10821 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'kolme kuukautta', '76 days = 3 months');
10822 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'kuukausi', '1 month = a month');
10823 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'viisi kuukautta', '5 months = 5 months');
10824 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'vuosi', '345 days = a year');
10825 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'kaksi vuotta', '548 days = 2 years');
10826 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'vuosi', '1 year = a year');
10827 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'viisi vuotta', '5 years = 5 years');
10828 });
10829
10830 test('suffix', function (assert) {
10831 assert.equal(moment(30000).from(0), 'muutaman sekunnin päästä', 'prefix');
10832 assert.equal(moment(0).from(30000), 'muutama sekunti sitten', 'suffix');
10833 });
10834
10835 test('now from now', function (assert) {
10836 assert.equal(moment().fromNow(), 'muutama sekunti sitten', 'now from now should display as in the past');
10837 });
10838
10839 test('fromNow', function (assert) {
10840 assert.equal(moment().add({s: 30}).fromNow(), 'muutaman sekunnin päästä', 'in a few seconds');
10841 assert.equal(moment().add({d: 5}).fromNow(), 'viiden päivän päästä', 'in 5 days');
10842 });
10843
10844 test('calendar day', function (assert) {
10845 var a = moment().hours(2).minutes(0).seconds(0);
10846
10847 assert.equal(moment(a).calendar(), 'tänään klo 02.00', 'today at the same time');
10848 assert.equal(moment(a).add({m: 25}).calendar(), 'tänään klo 02.25', 'Now plus 25 min');
10849 assert.equal(moment(a).add({h: 1}).calendar(), 'tänään klo 03.00', 'Now plus 1 hour');
10850 assert.equal(moment(a).add({d: 1}).calendar(), 'huomenna klo 02.00', 'tomorrow at the same time');
10851 assert.equal(moment(a).subtract({h: 1}).calendar(), 'tänään klo 01.00', 'Now minus 1 hour');
10852 assert.equal(moment(a).subtract({d: 1}).calendar(), 'eilen klo 02.00', 'yesterday at the same time');
10853 });
10854
10855 test('calendar next week', function (assert) {
10856 var i, m;
10857
10858 for (i = 2; i < 7; i++) {
10859 m = moment().add({d: i});
10860 assert.equal(m.calendar(), m.format('dddd [klo] LT'), 'today + ' + i + ' days current time');
10861 m.hours(0).minutes(0).seconds(0).milliseconds(0);
10862 assert.equal(m.calendar(), m.format('dddd [klo] LT'), 'today + ' + i + ' days beginning of day');
10863 m.hours(23).minutes(59).seconds(59).milliseconds(999);
10864 assert.equal(m.calendar(), m.format('dddd [klo] LT'), 'today + ' + i + ' days end of day');
10865 }
10866 });
10867
10868 test('calendar last week', function (assert) {
10869 var i, m;
10870 for (i = 2; i < 7; i++) {
10871 m = moment().subtract({d: i});
10872 assert.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), 'today - ' + i + ' days current time');
10873 m.hours(0).minutes(0).seconds(0).milliseconds(0);
10874 assert.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), 'today - ' + i + ' days beginning of day');
10875 m.hours(23).minutes(59).seconds(59).milliseconds(999);
10876 assert.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), 'today - ' + i + ' days end of day');
10877 }
10878 });
10879
10880 test('calendar all else', function (assert) {
10881 var weeksAgo = moment().subtract({w: 1}),
10882 weeksFromNow = moment().add({w: 1});
10883
10884 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'yksi viikko sitten');
10885 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'yhden viikon päästä');
10886
10887 weeksAgo = moment().subtract({w: 2});
10888 weeksFromNow = moment().add({w: 2});
10889
10890 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'kaksi viikkoa sitten');
10891 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'kaden viikon päästä');
10892 });
10893
10894 test('weeks year starting sunday', function (assert) {
10895 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
10896 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
10897 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
10898 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
10899 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
10900 });
10901
10902 test('weeks year starting monday', function (assert) {
10903 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
10904 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
10905 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
10906 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
10907 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
10908 });
10909
10910 test('weeks year starting tuesday', function (assert) {
10911 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
10912 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
10913 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
10914 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
10915 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
10916 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
10917 });
10918
10919 test('weeks year starting wednesday', function (assert) {
10920 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
10921 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
10922 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
10923 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
10924 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
10925 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
10926 });
10927
10928 test('weeks year starting thursday', function (assert) {
10929 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
10930 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
10931 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
10932 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
10933 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
10934 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
10935 });
10936
10937 test('weeks year starting friday', function (assert) {
10938 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
10939 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
10940 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
10941 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
10942 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
10943 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
10944 });
10945
10946 test('weeks year starting saturday', function (assert) {
10947 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
10948 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
10949 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
10950 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
10951 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
10952 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
10953 });
10954
10955 test('weeks year starting sunday formatted', function (assert) {
10956 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
10957 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
10958 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
10959 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
10960 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
10961 });
10962
10963 test('lenient ordinal parsing', function (assert) {
10964 var i, ordinalStr, testMoment;
10965 for (i = 1; i <= 31; ++i) {
10966 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
10967 testMoment = moment(ordinalStr, 'YYYY MM Do');
10968 assert.equal(testMoment.year(), 2014,
10969 'lenient ordinal parsing ' + i + ' year check');
10970 assert.equal(testMoment.month(), 0,
10971 'lenient ordinal parsing ' + i + ' month check');
10972 assert.equal(testMoment.date(), i,
10973 'lenient ordinal parsing ' + i + ' date check');
10974 }
10975 });
10976
10977 test('lenient ordinal parsing of number', function (assert) {
10978 var i, testMoment;
10979 for (i = 1; i <= 31; ++i) {
10980 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
10981 assert.equal(testMoment.year(), 2014,
10982 'lenient ordinal parsing of number ' + i + ' year check');
10983 assert.equal(testMoment.month(), 0,
10984 'lenient ordinal parsing of number ' + i + ' month check');
10985 assert.equal(testMoment.date(), i,
10986 'lenient ordinal parsing of number ' + i + ' date check');
10987 }
10988 });
10989
10990 test('strict ordinal parsing', function (assert) {
10991 var i, ordinalStr, testMoment;
10992 for (i = 1; i <= 31; ++i) {
10993 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
10994 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
10995 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
10996 }
10997 });
10998
10999 }));
11000
11001 (function (global, factory) {
11002 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
11003 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
11004 factory(global.moment)
11005 }(this, function (moment) { 'use strict';
11006
11007 /*global QUnit:false*/
11008
11009 var test = QUnit.test;
11010
11011 function module (name, lifecycle) {
11012 QUnit.module(name, {
11013 setup : function () {
11014 moment.locale('en');
11015 moment.createFromInputFallback = function () {
11016 throw new Error('input not handled by moment');
11017 };
11018 if (lifecycle && lifecycle.setup) {
11019 lifecycle.setup();
11020 }
11021 },
11022 teardown : function () {
11023 if (lifecycle && lifecycle.teardown) {
11024 lifecycle.teardown();
11025 }
11026 }
11027 });
11028 }
11029
11030 function localeModule (name, lifecycle) {
11031 QUnit.module('locale:' + name, {
11032 setup : function () {
11033 moment.locale(name);
11034 moment.createFromInputFallback = function () {
11035 throw new Error('input not handled by moment');
11036 };
11037 if (lifecycle && lifecycle.setup) {
11038 lifecycle.setup();
11039 }
11040 },
11041 teardown : function () {
11042 moment.locale('en');
11043 if (lifecycle && lifecycle.teardown) {
11044 lifecycle.teardown();
11045 }
11046 }
11047 });
11048 }
11049
11050 localeModule('fo');
11051
11052 test('parse', function (assert) {
11053 var tests = 'januar jan_februar feb_mars mar_apríl apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
11054 function equalTest(input, mmm, i) {
11055 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
11056 }
11057 for (i = 0; i < 12; i++) {
11058 tests[i] = tests[i].split(' ');
11059 equalTest(tests[i][0], 'MMM', i);
11060 equalTest(tests[i][1], 'MMM', i);
11061 equalTest(tests[i][0], 'MMMM', i);
11062 equalTest(tests[i][1], 'MMMM', i);
11063 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
11064 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
11065 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
11066 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
11067 }
11068 });
11069
11070 test('format', function (assert) {
11071 var a = [
11072 ['dddd [tann] Do MMMM YYYY, h:mm:ss a', 'sunnudagur tann 14. februar 2010, 3:25:50 pm'],
11073 ['ddd hA', 'sun 3PM'],
11074 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
11075 ['YYYY YY', '2010 10'],
11076 ['D Do DD', '14 14. 14'],
11077 ['d do dddd ddd dd', '0 0. sunnudagur sun su'],
11078 ['DDD DDDo DDDD', '45 45. 045'],
11079 ['w wo ww', '6 6. 06'],
11080 ['h hh', '3 03'],
11081 ['H HH', '15 15'],
11082 ['m mm', '25 25'],
11083 ['s ss', '50 50'],
11084 ['a A', 'pm PM'],
11085 ['[tann] DDDo [dagin á árinum]', 'tann 45. dagin á árinum'],
11086 ['LTS', '15:25:50'],
11087 ['L', '14/02/2010'],
11088 ['LL', '14 februar 2010'],
11089 ['LLL', '14 februar 2010 15:25'],
11090 ['LLLL', 'sunnudagur 14. februar, 2010 15:25'],
11091 ['l', '14/2/2010'],
11092 ['ll', '14 feb 2010'],
11093 ['lll', '14 feb 2010 15:25'],
11094 ['llll', 'sun 14. feb, 2010 15:25']
11095 ],
11096 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
11097 i;
11098 for (i = 0; i < a.length; i++) {
11099 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
11100 }
11101 });
11102
11103 test('format ordinal', function (assert) {
11104 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
11105 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
11106 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
11107 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
11108 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
11109 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
11110 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
11111 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
11112 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
11113 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
11114
11115 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
11116 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
11117 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
11118 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
11119 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
11120 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
11121 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
11122 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
11123 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
11124 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
11125
11126 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
11127 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
11128 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
11129 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
11130 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
11131 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
11132 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
11133 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
11134 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
11135 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
11136
11137 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
11138 });
11139
11140 test('format month', function (assert) {
11141 var expected = 'januar jan_februar feb_mars mar_apríl apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
11142 for (i = 0; i < expected.length; i++) {
11143 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
11144 }
11145 });
11146
11147 test('format week', function (assert) {
11148 var expected = 'sunnudagur sun su_mánadagur mán má_týsdagur týs tý_mikudagur mik mi_hósdagur hós hó_fríggjadagur frí fr_leygardagur ley le'.split('_'), i;
11149 for (i = 0; i < expected.length; i++) {
11150 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
11151 }
11152 });
11153
11154 test('from', function (assert) {
11155 var start = moment([2007, 1, 28]);
11156 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'fá sekund', '44 seconds = a few seconds');
11157 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ein minutt', '45 seconds = a minute');
11158 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ein minutt', '89 seconds = a minute');
11159 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuttir', '90 seconds = 2 minutes');
11160 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuttir', '44 minutes = 44 minutes');
11161 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ein tími', '45 minutes = an hour');
11162 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ein tími', '89 minutes = an hour');
11163 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 tímar', '90 minutes = 2 hours');
11164 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 tímar', '5 hours = 5 hours');
11165 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tímar', '21 hours = 21 hours');
11166 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein dagur', '22 hours = a day');
11167 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein dagur', '35 hours = a day');
11168 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
11169 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein dagur', '1 day = a day');
11170 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
11171 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
11172 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein mánaði', '26 days = a month');
11173 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein mánaði', '30 days = a month');
11174 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ein mánaði', '43 days = a month');
11175 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mánaðir', '46 days = 2 months');
11176 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mánaðir', '75 days = 2 months');
11177 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mánaðir', '76 days = 3 months');
11178 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein mánaði', '1 month = a month');
11179 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mánaðir', '5 months = 5 months');
11180 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'eitt ár', '345 days = a year');
11181 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ár', '548 days = 2 years');
11182 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eitt ár', '1 year = a year');
11183 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ár', '5 years = 5 years');
11184 });
11185
11186 test('suffix', function (assert) {
11187 assert.equal(moment(30000).from(0), 'um fá sekund', 'prefix');
11188 assert.equal(moment(0).from(30000), 'fá sekund síðani', 'suffix');
11189 });
11190
11191 test('now from now', function (assert) {
11192 assert.equal(moment().fromNow(), 'fá sekund síðani', 'now from now should display as in the past');
11193 });
11194
11195 test('fromNow', function (assert) {
11196 assert.equal(moment().add({s: 30}).fromNow(), 'um fá sekund', 'in a few seconds');
11197 assert.equal(moment().add({d: 5}).fromNow(), 'um 5 dagar', 'in 5 days');
11198 });
11199
11200 test('weeks year starting sunday', function (assert) {
11201 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
11202 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
11203 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
11204 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
11205 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
11206 });
11207
11208 test('weeks year starting monday', function (assert) {
11209 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
11210 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
11211 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
11212 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
11213 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
11214 });
11215
11216 test('weeks year starting tuesday', function (assert) {
11217 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
11218 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
11219 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
11220 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
11221 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
11222 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
11223 });
11224
11225 test('weeks year starting wednesday', function (assert) {
11226 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
11227 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
11228 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
11229 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
11230 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
11231 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
11232 });
11233
11234 test('weeks year starting thursday', function (assert) {
11235 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
11236 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
11237 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
11238 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
11239 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
11240 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
11241 });
11242
11243 test('weeks year starting friday', function (assert) {
11244 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
11245 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
11246 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
11247 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
11248 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
11249 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
11250 });
11251
11252 test('weeks year starting saturday', function (assert) {
11253 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
11254 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
11255 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
11256 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
11257 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
11258 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
11259 });
11260
11261 test('weeks year starting sunday formatted', function (assert) {
11262 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
11263 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
11264 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
11265 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
11266 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
11267 });
11268
11269 test('lenient ordinal parsing', function (assert) {
11270 var i, ordinalStr, testMoment;
11271 for (i = 1; i <= 31; ++i) {
11272 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
11273 testMoment = moment(ordinalStr, 'YYYY MM Do');
11274 assert.equal(testMoment.year(), 2014,
11275 'lenient ordinal parsing ' + i + ' year check');
11276 assert.equal(testMoment.month(), 0,
11277 'lenient ordinal parsing ' + i + ' month check');
11278 assert.equal(testMoment.date(), i,
11279 'lenient ordinal parsing ' + i + ' date check');
11280 }
11281 });
11282
11283 test('lenient ordinal parsing of number', function (assert) {
11284 var i, testMoment;
11285 for (i = 1; i <= 31; ++i) {
11286 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
11287 assert.equal(testMoment.year(), 2014,
11288 'lenient ordinal parsing of number ' + i + ' year check');
11289 assert.equal(testMoment.month(), 0,
11290 'lenient ordinal parsing of number ' + i + ' month check');
11291 assert.equal(testMoment.date(), i,
11292 'lenient ordinal parsing of number ' + i + ' date check');
11293 }
11294 });
11295
11296 test('strict ordinal parsing', function (assert) {
11297 var i, ordinalStr, testMoment;
11298 for (i = 1; i <= 31; ++i) {
11299 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
11300 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
11301 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
11302 }
11303 });
11304
11305 }));
11306
11307 (function (global, factory) {
11308 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
11309 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
11310 factory(global.moment)
11311 }(this, function (moment) { 'use strict';
11312
11313 /*global QUnit:false*/
11314
11315 var test = QUnit.test;
11316
11317 function module (name, lifecycle) {
11318 QUnit.module(name, {
11319 setup : function () {
11320 moment.locale('en');
11321 moment.createFromInputFallback = function () {
11322 throw new Error('input not handled by moment');
11323 };
11324 if (lifecycle && lifecycle.setup) {
11325 lifecycle.setup();
11326 }
11327 },
11328 teardown : function () {
11329 if (lifecycle && lifecycle.teardown) {
11330 lifecycle.teardown();
11331 }
11332 }
11333 });
11334 }
11335
11336 function localeModule (name, lifecycle) {
11337 QUnit.module('locale:' + name, {
11338 setup : function () {
11339 moment.locale(name);
11340 moment.createFromInputFallback = function () {
11341 throw new Error('input not handled by moment');
11342 };
11343 if (lifecycle && lifecycle.setup) {
11344 lifecycle.setup();
11345 }
11346 },
11347 teardown : function () {
11348 moment.locale('en');
11349 if (lifecycle && lifecycle.teardown) {
11350 lifecycle.teardown();
11351 }
11352 }
11353 });
11354 }
11355
11356 localeModule('fr-ca');
11357
11358 test('parse', function (assert) {
11359 var i,
11360 tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_');
11361
11362 function equalTest(input, mmm, i) {
11363 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
11364 }
11365
11366 for (i = 0; i < 12; i++) {
11367 tests[i] = tests[i].split(' ');
11368 equalTest(tests[i][0], 'MMM', i);
11369 equalTest(tests[i][1], 'MMM', i);
11370 equalTest(tests[i][0], 'MMMM', i);
11371 equalTest(tests[i][1], 'MMMM', i);
11372 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
11373 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
11374 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
11375 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
11376 }
11377 });
11378
11379 test('format', function (assert) {
11380 var a = [
11381 ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14e 2010, 3:25:50 pm'],
11382 ['ddd, hA', 'dim., 3PM'],
11383 ['M Mo MM MMMM MMM', '2 2e 02 février févr.'],
11384 ['YYYY YY', '2010 10'],
11385 ['D Do DD', '14 14e 14'],
11386 ['d do dddd ddd dd', '0 0e dimanche dim. Di'],
11387 ['DDD DDDo DDDD', '45 45e 045'],
11388 ['w wo ww', '8 8e 08'],
11389 ['h hh', '3 03'],
11390 ['H HH', '15 15'],
11391 ['m mm', '25 25'],
11392 ['s ss', '50 50'],
11393 ['a A', 'pm PM'],
11394 ['[the] DDDo [day of the year]', 'the 45e day of the year'],
11395 ['LTS', '15:25:50'],
11396 ['L', '2010-02-14'],
11397 ['LL', '14 février 2010'],
11398 ['LLL', '14 février 2010 15:25'],
11399 ['LLLL', 'dimanche 14 février 2010 15:25'],
11400 ['l', '2010-2-14'],
11401 ['ll', '14 févr. 2010'],
11402 ['lll', '14 févr. 2010 15:25'],
11403 ['llll', 'dim. 14 févr. 2010 15:25']
11404 ],
11405 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
11406 i;
11407
11408 for (i = 0; i < a.length; i++) {
11409 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
11410 }
11411 });
11412
11413 test('format ordinal', function (assert) {
11414 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
11415 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2e', '2e');
11416 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3e', '3e');
11417 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4e', '4e');
11418 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5e', '5e');
11419 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6e', '6e');
11420 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7e', '7e');
11421 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8e', '8e');
11422 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9e', '9e');
11423 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10e', '10e');
11424
11425 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11e', '11e');
11426 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12e', '12e');
11427 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13e', '13e');
11428 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14e', '14e');
11429 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15e', '15e');
11430 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16e', '16e');
11431 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17e', '17e');
11432 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18e', '18e');
11433 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19e', '19e');
11434 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20e', '20e');
11435
11436 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21e', '21e');
11437 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22e', '22e');
11438 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23e', '23e');
11439 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24e', '24e');
11440 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25e', '25e');
11441 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26e', '26e');
11442 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27e', '27e');
11443 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28e', '28e');
11444 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29e', '29e');
11445 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30e', '30e');
11446
11447 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31e', '31e');
11448 });
11449
11450 test('format month', function (assert) {
11451 var i,
11452 expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_');
11453
11454 for (i = 0; i < expected.length; i++) {
11455 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
11456 }
11457 });
11458
11459 test('format week', function (assert) {
11460 var i,
11461 expected = 'dimanche dim. Di_lundi lun. Lu_mardi mar. Ma_mercredi mer. Me_jeudi jeu. Je_vendredi ven. Ve_samedi sam. Sa'.split('_');
11462
11463 for (i = 0; i < expected.length; i++) {
11464 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
11465 }
11466 });
11467
11468 test('from', function (assert) {
11469 var start = moment([2007, 1, 28]);
11470
11471 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'quelques secondes', '44 seconds = a few seconds');
11472 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'une minute', '45 seconds = a minute');
11473 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'une minute', '89 seconds = a minute');
11474 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
11475 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
11476 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'une heure', '45 minutes = an hour');
11477 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'une heure', '89 minutes = an hour');
11478 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 heures', '90 minutes = 2 hours');
11479 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 heures', '5 hours = 5 hours');
11480 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 heures', '21 hours = 21 hours');
11481 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un jour', '22 hours = a day');
11482 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un jour', '35 hours = a day');
11483 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 jours', '36 hours = 2 days');
11484 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un jour', '1 day = a day');
11485 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 jours', '5 days = 5 days');
11486 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 jours', '25 days = 25 days');
11487 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mois', '26 days = a month');
11488 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mois', '30 days = a month');
11489 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mois', '43 days = a month');
11490 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mois', '46 days = 2 months');
11491 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mois', '75 days = 2 months');
11492 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mois', '76 days = 3 months');
11493 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mois', '1 month = a month');
11494 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mois', '5 months = 5 months');
11495 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un an', '345 days = a year');
11496 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ans', '548 days = 2 years');
11497 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un an', '1 year = a year');
11498 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ans', '5 years = 5 years');
11499 });
11500
11501 test('suffix', function (assert) {
11502 assert.equal(moment(30000).from(0), 'dans quelques secondes', 'prefix');
11503 assert.equal(moment(0).from(30000), 'il y a quelques secondes', 'suffix');
11504 });
11505
11506 test('fromNow', function (assert) {
11507 assert.equal(moment().add({s: 30}).fromNow(), 'dans quelques secondes', 'in a few seconds');
11508 assert.equal(moment().add({d: 5}).fromNow(), 'dans 5 jours', 'in 5 days');
11509 });
11510
11511 test('same day', function (assert) {
11512 var a = moment().hours(2).minutes(0).seconds(0);
11513
11514 assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
11515 assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
11516 assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
11517 assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
11518 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
11519 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
11520 });
11521
11522 test('same next week', function (assert) {
11523 var i, m;
11524
11525 for (i = 2; i < 7; i++) {
11526 m = moment().add({d: i});
11527 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time');
11528 m.hours(0).minutes(0).seconds(0).milliseconds(0);
11529 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day');
11530 m.hours(23).minutes(59).seconds(59).milliseconds(999);
11531 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day');
11532 }
11533 });
11534
11535 test('same last week', function (assert) {
11536 var i, m;
11537
11538 for (i = 2; i < 7; i++) {
11539 m = moment().subtract({d: i});
11540 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days current time');
11541 m.hours(0).minutes(0).seconds(0).milliseconds(0);
11542 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days beginning of day');
11543 m.hours(23).minutes(59).seconds(59).milliseconds(999);
11544 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days end of day');
11545 }
11546 });
11547
11548 test('same all else', function (assert) {
11549 var weeksAgo = moment().subtract({w: 1}),
11550 weeksFromNow = moment().add({w: 1});
11551
11552 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
11553 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
11554
11555 weeksAgo = moment().subtract({w: 2});
11556 weeksFromNow = moment().add({w: 2});
11557
11558 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
11559 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
11560 });
11561
11562 test('weeks year starting sunday', function (assert) {
11563 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
11564 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
11565 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
11566 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
11567 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
11568 });
11569
11570 test('weeks year starting monday', function (assert) {
11571 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
11572 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
11573 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
11574 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
11575 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
11576 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
11577 });
11578
11579 test('weeks year starting tuesday', function (assert) {
11580 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
11581 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
11582 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
11583 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
11584 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
11585 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
11586 });
11587
11588 test('weeks year starting wednesday', function (assert) {
11589 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
11590 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
11591 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
11592 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
11593 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
11594 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
11595 });
11596
11597 test('weeks year starting thursday', function (assert) {
11598 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
11599 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
11600 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
11601 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
11602 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
11603 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
11604 });
11605
11606 test('weeks year starting friday', function (assert) {
11607 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
11608 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
11609 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
11610 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
11611 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
11612 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
11613 });
11614
11615 test('weeks year starting saturday', function (assert) {
11616 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
11617 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
11618 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
11619 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
11620 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
11621 });
11622
11623 test('weeks year starting sunday format', function (assert) {
11624 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1er', 'Jan 1 2012 should be week 1');
11625 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1er', 'Jan 7 2012 should be week 1');
11626 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2e', 'Jan 8 2012 should be week 2');
11627 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2e', 'Jan 14 2012 should be week 2');
11628 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3e', 'Jan 15 2012 should be week 3');
11629 });
11630
11631 test('lenient ordinal parsing', function (assert) {
11632 var i, ordinalStr, testMoment;
11633 for (i = 1; i <= 31; ++i) {
11634 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
11635 testMoment = moment(ordinalStr, 'YYYY MM Do');
11636 assert.equal(testMoment.year(), 2014,
11637 'lenient ordinal parsing ' + i + ' year check');
11638 assert.equal(testMoment.month(), 0,
11639 'lenient ordinal parsing ' + i + ' month check');
11640 assert.equal(testMoment.date(), i,
11641 'lenient ordinal parsing ' + i + ' date check');
11642 }
11643 });
11644
11645 test('lenient ordinal parsing of number', function (assert) {
11646 var i, testMoment;
11647 for (i = 1; i <= 31; ++i) {
11648 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
11649 assert.equal(testMoment.year(), 2014,
11650 'lenient ordinal parsing of number ' + i + ' year check');
11651 assert.equal(testMoment.month(), 0,
11652 'lenient ordinal parsing of number ' + i + ' month check');
11653 assert.equal(testMoment.date(), i,
11654 'lenient ordinal parsing of number ' + i + ' date check');
11655 }
11656 });
11657
11658 test('strict ordinal parsing', function (assert) {
11659 var i, ordinalStr, testMoment;
11660 for (i = 1; i <= 31; ++i) {
11661 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
11662 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
11663 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
11664 }
11665 });
11666
11667 }));
11668
11669 (function (global, factory) {
11670 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
11671 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
11672 factory(global.moment)
11673 }(this, function (moment) { 'use strict';
11674
11675 /*global QUnit:false*/
11676
11677 var test = QUnit.test;
11678
11679 function module (name, lifecycle) {
11680 QUnit.module(name, {
11681 setup : function () {
11682 moment.locale('en');
11683 moment.createFromInputFallback = function () {
11684 throw new Error('input not handled by moment');
11685 };
11686 if (lifecycle && lifecycle.setup) {
11687 lifecycle.setup();
11688 }
11689 },
11690 teardown : function () {
11691 if (lifecycle && lifecycle.teardown) {
11692 lifecycle.teardown();
11693 }
11694 }
11695 });
11696 }
11697
11698 function localeModule (name, lifecycle) {
11699 QUnit.module('locale:' + name, {
11700 setup : function () {
11701 moment.locale(name);
11702 moment.createFromInputFallback = function () {
11703 throw new Error('input not handled by moment');
11704 };
11705 if (lifecycle && lifecycle.setup) {
11706 lifecycle.setup();
11707 }
11708 },
11709 teardown : function () {
11710 moment.locale('en');
11711 if (lifecycle && lifecycle.teardown) {
11712 lifecycle.teardown();
11713 }
11714 }
11715 });
11716 }
11717
11718 localeModule('fr');
11719
11720 test('parse', function (assert) {
11721 var tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_'),
11722 i;
11723 function equalTest(input, mmm, i) {
11724 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
11725 }
11726 for (i = 0; i < 12; i++) {
11727 tests[i] = tests[i].split(' ');
11728 equalTest(tests[i][0], 'MMM', i);
11729 equalTest(tests[i][1], 'MMM', i);
11730 equalTest(tests[i][0], 'MMMM', i);
11731 equalTest(tests[i][1], 'MMMM', i);
11732 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
11733 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
11734 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
11735 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
11736 }
11737 });
11738
11739 test('format', function (assert) {
11740 var a = [
11741 ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14 2010, 3:25:50 pm'],
11742 ['ddd, hA', 'dim., 3PM'],
11743 ['M Mo MM MMMM MMM', '2 2 02 février févr.'],
11744 ['YYYY YY', '2010 10'],
11745 ['D Do DD', '14 14 14'],
11746 ['d do dddd ddd dd', '0 0 dimanche dim. Di'],
11747 ['DDD DDDo DDDD', '45 45 045'],
11748 ['w wo ww', '6 6 06'],
11749 ['h hh', '3 03'],
11750 ['H HH', '15 15'],
11751 ['m mm', '25 25'],
11752 ['s ss', '50 50'],
11753 ['a A', 'pm PM'],
11754 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
11755 ['LTS', '15:25:50'],
11756 ['L', '14/02/2010'],
11757 ['LL', '14 février 2010'],
11758 ['LLL', '14 février 2010 15:25'],
11759 ['LLLL', 'dimanche 14 février 2010 15:25'],
11760 ['l', '14/2/2010'],
11761 ['ll', '14 févr. 2010'],
11762 ['lll', '14 févr. 2010 15:25'],
11763 ['llll', 'dim. 14 févr. 2010 15:25']
11764 ],
11765 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
11766 i;
11767 for (i = 0; i < a.length; i++) {
11768 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
11769 }
11770 });
11771
11772 test('format ordinal', function (assert) {
11773 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
11774 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
11775 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
11776 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
11777 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
11778 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
11779 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
11780 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
11781 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
11782 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
11783
11784 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
11785 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
11786 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
11787 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
11788 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
11789 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
11790 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
11791 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
11792 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
11793 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
11794
11795 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
11796 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
11797 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
11798 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
11799 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
11800 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
11801 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
11802 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
11803 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
11804 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
11805
11806 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
11807 });
11808
11809 test('format month', function (assert) {
11810 var expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_'), i;
11811 for (i = 0; i < expected.length; i++) {
11812 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
11813 }
11814 });
11815
11816 test('format week', function (assert) {
11817 var expected = 'dimanche dim. Di_lundi lun. Lu_mardi mar. Ma_mercredi mer. Me_jeudi jeu. Je_vendredi ven. Ve_samedi sam. Sa'.split('_'), i;
11818 for (i = 0; i < expected.length; i++) {
11819 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
11820 }
11821 });
11822
11823 test('from', function (assert) {
11824 var start = moment([2007, 1, 28]);
11825 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'quelques secondes', '44 seconds = a few seconds');
11826 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'une minute', '45 seconds = a minute');
11827 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'une minute', '89 seconds = a minute');
11828 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
11829 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
11830 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'une heure', '45 minutes = an hour');
11831 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'une heure', '89 minutes = an hour');
11832 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 heures', '90 minutes = 2 hours');
11833 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 heures', '5 hours = 5 hours');
11834 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 heures', '21 hours = 21 hours');
11835 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un jour', '22 hours = a day');
11836 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un jour', '35 hours = a day');
11837 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 jours', '36 hours = 2 days');
11838 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un jour', '1 day = a day');
11839 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 jours', '5 days = 5 days');
11840 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 jours', '25 days = 25 days');
11841 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mois', '26 days = a month');
11842 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mois', '30 days = a month');
11843 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mois', '43 days = a month');
11844 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mois', '46 days = 2 months');
11845 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mois', '75 days = 2 months');
11846 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mois', '76 days = 3 months');
11847 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mois', '1 month = a month');
11848 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mois', '5 months = 5 months');
11849 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un an', '345 days = a year');
11850 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ans', '548 days = 2 years');
11851 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un an', '1 year = a year');
11852 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ans', '5 years = 5 years');
11853 });
11854
11855 test('suffix', function (assert) {
11856 assert.equal(moment(30000).from(0), 'dans quelques secondes', 'prefix');
11857 assert.equal(moment(0).from(30000), 'il y a quelques secondes', 'suffix');
11858 });
11859
11860 test('fromNow', function (assert) {
11861 assert.equal(moment().add({s: 30}).fromNow(), 'dans quelques secondes', 'in a few seconds');
11862 assert.equal(moment().add({d: 5}).fromNow(), 'dans 5 jours', 'in 5 days');
11863 });
11864
11865 test('same day', function (assert) {
11866 var a = moment().hours(2).minutes(0).seconds(0);
11867
11868 assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
11869 assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
11870 assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
11871 assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
11872 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
11873 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
11874 });
11875
11876 test('same next week', function (assert) {
11877 var i, m;
11878
11879 for (i = 2; i < 7; i++) {
11880 m = moment().add({d: i});
11881 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time');
11882 m.hours(0).minutes(0).seconds(0).milliseconds(0);
11883 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day');
11884 m.hours(23).minutes(59).seconds(59).milliseconds(999);
11885 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day');
11886 }
11887 });
11888
11889 test('same last week', function (assert) {
11890 var i, m;
11891
11892 for (i = 2; i < 7; i++) {
11893 m = moment().subtract({d: i});
11894 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days current time');
11895 m.hours(0).minutes(0).seconds(0).milliseconds(0);
11896 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days beginning of day');
11897 m.hours(23).minutes(59).seconds(59).milliseconds(999);
11898 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days end of day');
11899 }
11900 });
11901
11902 test('same all else', function (assert) {
11903 var weeksAgo = moment().subtract({w: 1}),
11904 weeksFromNow = moment().add({w: 1});
11905
11906 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
11907 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
11908
11909 weeksAgo = moment().subtract({w: 2});
11910 weeksFromNow = moment().add({w: 2});
11911
11912 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
11913 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
11914 });
11915
11916 test('weeks year starting sunday', function (assert) {
11917 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
11918 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
11919 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
11920 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
11921 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
11922 });
11923
11924 test('weeks year starting monday', function (assert) {
11925 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
11926 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
11927 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
11928 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
11929 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
11930 });
11931
11932 test('weeks year starting tuesday', function (assert) {
11933 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
11934 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
11935 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
11936 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
11937 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
11938 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
11939 });
11940
11941 test('weeks year starting wednesday', function (assert) {
11942 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
11943 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
11944 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
11945 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
11946 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
11947 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
11948 });
11949
11950 test('weeks year starting thursday', function (assert) {
11951 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
11952 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
11953 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
11954 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
11955 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
11956 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
11957 });
11958
11959 test('weeks year starting friday', function (assert) {
11960 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
11961 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
11962 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
11963 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
11964 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
11965 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
11966 });
11967
11968 test('weeks year starting saturday', function (assert) {
11969 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
11970 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
11971 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
11972 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
11973 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
11974 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
11975 });
11976
11977 test('weeks year starting sunday formatted', function (assert) {
11978 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
11979 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1er', 'Jan 2 2012 should be week 1');
11980 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1er', 'Jan 8 2012 should be week 1');
11981 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
11982 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
11983 });
11984
11985 test('lenient ordinal parsing', function (assert) {
11986 var i, ordinalStr, testMoment;
11987 for (i = 1; i <= 31; ++i) {
11988 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
11989 testMoment = moment(ordinalStr, 'YYYY MM Do');
11990 assert.equal(testMoment.year(), 2014,
11991 'lenient ordinal parsing ' + i + ' year check');
11992 assert.equal(testMoment.month(), 0,
11993 'lenient ordinal parsing ' + i + ' month check');
11994 assert.equal(testMoment.date(), i,
11995 'lenient ordinal parsing ' + i + ' date check');
11996 }
11997 });
11998
11999 test('lenient ordinal parsing of number', function (assert) {
12000 var i, testMoment;
12001 for (i = 1; i <= 31; ++i) {
12002 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
12003 assert.equal(testMoment.year(), 2014,
12004 'lenient ordinal parsing of number ' + i + ' year check');
12005 assert.equal(testMoment.month(), 0,
12006 'lenient ordinal parsing of number ' + i + ' month check');
12007 assert.equal(testMoment.date(), i,
12008 'lenient ordinal parsing of number ' + i + ' date check');
12009 }
12010 });
12011
12012 test('strict ordinal parsing', function (assert) {
12013 var i, ordinalStr, testMoment;
12014 for (i = 1; i <= 31; ++i) {
12015 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
12016 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
12017 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
12018 }
12019 });
12020
12021 }));
12022
12023 (function (global, factory) {
12024 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
12025 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
12026 factory(global.moment)
12027 }(this, function (moment) { 'use strict';
12028
12029 /*global QUnit:false*/
12030
12031 var test = QUnit.test;
12032
12033 function module (name, lifecycle) {
12034 QUnit.module(name, {
12035 setup : function () {
12036 moment.locale('en');
12037 moment.createFromInputFallback = function () {
12038 throw new Error('input not handled by moment');
12039 };
12040 if (lifecycle && lifecycle.setup) {
12041 lifecycle.setup();
12042 }
12043 },
12044 teardown : function () {
12045 if (lifecycle && lifecycle.teardown) {
12046 lifecycle.teardown();
12047 }
12048 }
12049 });
12050 }
12051
12052 function localeModule (name, lifecycle) {
12053 QUnit.module('locale:' + name, {
12054 setup : function () {
12055 moment.locale(name);
12056 moment.createFromInputFallback = function () {
12057 throw new Error('input not handled by moment');
12058 };
12059 if (lifecycle && lifecycle.setup) {
12060 lifecycle.setup();
12061 }
12062 },
12063 teardown : function () {
12064 moment.locale('en');
12065 if (lifecycle && lifecycle.teardown) {
12066 lifecycle.teardown();
12067 }
12068 }
12069 });
12070 }
12071
12072 localeModule('fy');
12073
12074 test('parse', function (assert) {
12075 var tests = 'jannewaris jan._febrewaris feb._maart mrt._april apr._maaie mai._juny jun._july jul._augustus aug._septimber sep._oktober okt._novimber nov._desimber des.'.split('_'), i;
12076 function equalTest(input, mmm, i) {
12077 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
12078 }
12079 for (i = 0; i < 12; i++) {
12080 tests[i] = tests[i].split(' ');
12081 equalTest(tests[i][0], 'MMM', i);
12082 equalTest(tests[i][1], 'MMM', i);
12083 equalTest(tests[i][0], 'MMMM', i);
12084 equalTest(tests[i][1], 'MMMM', i);
12085 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
12086 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
12087 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
12088 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
12089 }
12090 });
12091
12092 test('format', function (assert) {
12093 var a = [
12094 ['dddd, MMMM Do YYYY, HH:mm:ss', 'snein, febrewaris 14de 2010, 15:25:50'],
12095 ['ddd, HH', 'si., 15'],
12096 ['M Mo MM MMMM MMM', '2 2de 02 febrewaris feb.'],
12097 ['YYYY YY', '2010 10'],
12098 ['D Do DD', '14 14de 14'],
12099 ['d do dddd ddd dd', '0 0de snein si. Si'],
12100 ['DDD DDDo DDDD', '45 45ste 045'],
12101 ['w wo ww', '6 6de 06'],
12102 ['h hh', '3 03'],
12103 ['H HH', '15 15'],
12104 ['m mm', '25 25'],
12105 ['s ss', '50 50'],
12106 ['a A', 'pm PM'],
12107 ['[the] DDDo [day of the year]', 'the 45ste day of the year'],
12108 ['LTS', '15:25:50'],
12109 ['L', '14-02-2010'],
12110 ['LL', '14 febrewaris 2010'],
12111 ['LLL', '14 febrewaris 2010 15:25'],
12112 ['LLLL', 'snein 14 febrewaris 2010 15:25'],
12113 ['l', '14-2-2010'],
12114 ['ll', '14 feb. 2010'],
12115 ['lll', '14 feb. 2010 15:25'],
12116 ['llll', 'si. 14 feb. 2010 15:25']
12117 ],
12118 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
12119 i;
12120 for (i = 0; i < a.length; i++) {
12121 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
12122 }
12123 });
12124
12125 test('format ordinal', function (assert) {
12126 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
12127 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
12128 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
12129 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4de', '4de');
12130 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5de', '5de');
12131 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6de', '6de');
12132 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7de', '7de');
12133 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
12134 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
12135 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
12136
12137 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
12138 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
12139 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
12140 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14de', '14de');
12141 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15de', '15de');
12142 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16de', '16de');
12143 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17de', '17de');
12144 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
12145 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
12146 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
12147
12148 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
12149 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
12150 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
12151 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ste', '24ste');
12152 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ste', '25ste');
12153 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ste', '26ste');
12154 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ste', '27ste');
12155 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
12156 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
12157 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
12158
12159 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
12160 });
12161
12162 test('format month', function (assert) {
12163 var expected = 'jannewaris jan._febrewaris feb._maart mrt._april apr._maaie mai_juny jun._july jul._augustus aug._septimber sep._oktober okt._novimber nov._desimber des.'.split('_'), i;
12164 for (i = 0; i < expected.length; i++) {
12165 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
12166 }
12167 });
12168
12169 test('format week', function (assert) {
12170 var expected = 'snein si. Si_moandei mo. Mo_tiisdei ti. Ti_woansdei wo. Wo_tongersdei to. To_freed fr. Fr_sneon so. So'.split('_'), i;
12171 for (i = 0; i < expected.length; i++) {
12172 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
12173 }
12174 });
12175
12176 test('from', function (assert) {
12177 var start = moment([2007, 1, 28]);
12178 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'in pear sekonden', '44 seconds = a few seconds');
12179 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ien minút', '45 seconds = a minute');
12180 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ien minút', '89 seconds = a minute');
12181 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuten', '90 seconds = 2 minutes');
12182 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuten', '44 minutes = 44 minutes');
12183 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ien oere', '45 minutes = an hour');
12184 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ien oere', '89 minutes = an hour');
12185 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 oeren', '90 minutes = 2 hours');
12186 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 oeren', '5 hours = 5 hours');
12187 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 oeren', '21 hours = 21 hours');
12188 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ien dei', '22 hours = a day');
12189 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ien dei', '35 hours = a day');
12190 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagen', '36 hours = 2 days');
12191 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ien dei', '1 day = a day');
12192 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagen', '5 days = 5 days');
12193 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagen', '25 days = 25 days');
12194 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ien moanne', '26 days = a month');
12195 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ien moanne', '30 days = a month');
12196 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ien moanne', '43 days = a month');
12197 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 moannen', '46 days = 2 months');
12198 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 moannen', '75 days = 2 months');
12199 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 moannen', '76 days = 3 months');
12200 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ien moanne', '1 month = a month');
12201 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 moannen', '5 months = 5 months');
12202 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ien jier', '345 days = a year');
12203 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jierren', '548 days = 2 years');
12204 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ien jier', '1 year = a year');
12205 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jierren', '5 years = 5 years');
12206 });
12207
12208 test('suffix', function (assert) {
12209 assert.equal(moment(30000).from(0), 'oer in pear sekonden', 'prefix');
12210 assert.equal(moment(0).from(30000), 'in pear sekonden lyn', 'suffix');
12211 });
12212
12213 test('now from now', function (assert) {
12214 assert.equal(moment().fromNow(), 'in pear sekonden lyn', 'now from now should display as in the past');
12215 });
12216
12217 test('fromNow', function (assert) {
12218 assert.equal(moment().add({s: 30}).fromNow(), 'oer in pear sekonden', 'in a few seconds');
12219 assert.equal(moment().add({d: 5}).fromNow(), 'oer 5 dagen', 'in 5 days');
12220 });
12221
12222 test('calendar day', function (assert) {
12223 var a = moment().hours(2).minutes(0).seconds(0);
12224
12225 assert.equal(moment(a).calendar(), 'hjoed om 02:00', 'today at the same time');
12226 assert.equal(moment(a).add({m: 25}).calendar(), 'hjoed om 02:25', 'Now plus 25 min');
12227 assert.equal(moment(a).add({h: 1}).calendar(), 'hjoed om 03:00', 'Now plus 1 hour');
12228 assert.equal(moment(a).add({d: 1}).calendar(), 'moarn om 02:00', 'tomorrow at the same time');
12229 assert.equal(moment(a).subtract({h: 1}).calendar(), 'hjoed om 01:00', 'Now minus 1 hour');
12230 assert.equal(moment(a).subtract({d: 1}).calendar(), 'juster om 02:00', 'yesterday at the same time');
12231 });
12232
12233 test('calendar next week', function (assert) {
12234 var i, m;
12235 for (i = 2; i < 7; i++) {
12236 m = moment().add({d: i});
12237 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days current time');
12238 m.hours(0).minutes(0).seconds(0).milliseconds(0);
12239 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days beginning of day');
12240 m.hours(23).minutes(59).seconds(59).milliseconds(999);
12241 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days end of day');
12242 }
12243 });
12244
12245 test('calendar last week', function (assert) {
12246 var i, m;
12247 for (i = 2; i < 7; i++) {
12248 m = moment().subtract({d: i});
12249 assert.equal(m.calendar(), m.format('[ôfrûne] dddd [om] LT'), 'Today - ' + i + ' days current time');
12250 m.hours(0).minutes(0).seconds(0).milliseconds(0);
12251 assert.equal(m.calendar(), m.format('[ôfrûne] dddd [om] LT'), 'Today - ' + i + ' days beginning of day');
12252 m.hours(23).minutes(59).seconds(59).milliseconds(999);
12253 assert.equal(m.calendar(), m.format('[ôfrûne] dddd [om] LT'), 'Today - ' + i + ' days end of day');
12254 }
12255 });
12256
12257 test('calendar all else', function (assert) {
12258 var weeksAgo = moment().subtract({w: 1}),
12259 weeksFromNow = moment().add({w: 1});
12260
12261 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
12262 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
12263
12264 weeksAgo = moment().subtract({w: 2});
12265 weeksFromNow = moment().add({w: 2});
12266
12267 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
12268 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
12269 });
12270
12271 test('month abbreviation', function (assert) {
12272 assert.equal(moment([2012, 5, 23]).format('D-MMM-YYYY'), '23-jun-2012', 'format month abbreviation surrounded by dashes should not include a dot');
12273 assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
12274 });
12275
12276 test('weeks year starting sunday', function (assert) {
12277 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
12278 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
12279 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
12280 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
12281 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
12282 });
12283
12284 test('weeks year starting monday', function (assert) {
12285 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
12286 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
12287 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
12288 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
12289 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
12290 });
12291
12292 test('weeks year starting tuesday', function (assert) {
12293 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
12294 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
12295 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
12296 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
12297 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
12298 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
12299 });
12300
12301 test('weeks year starting wednesday', function (assert) {
12302 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
12303 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
12304 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
12305 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
12306 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
12307 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
12308 });
12309
12310 test('weeks year starting thursday', function (assert) {
12311 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
12312 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
12313 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
12314 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
12315 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
12316 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
12317 });
12318
12319 test('weeks year starting friday', function (assert) {
12320 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
12321 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
12322 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
12323 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
12324 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
12325 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
12326 });
12327
12328 test('weeks year starting saturday', function (assert) {
12329 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
12330 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
12331 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
12332 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
12333 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
12334 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
12335 });
12336
12337 test('weeks year starting sunday formatted', function (assert) {
12338 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
12339 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
12340 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1ste', 'Jan 8 2012 should be week 1');
12341 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2');
12342 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
12343 });
12344
12345 test('lenient ordinal parsing', function (assert) {
12346 var i, ordinalStr, testMoment;
12347 for (i = 1; i <= 31; ++i) {
12348 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
12349 testMoment = moment(ordinalStr, 'YYYY MM Do');
12350 assert.equal(testMoment.year(), 2014,
12351 'lenient ordinal parsing ' + i + ' year check');
12352 assert.equal(testMoment.month(), 0,
12353 'lenient ordinal parsing ' + i + ' month check');
12354 assert.equal(testMoment.date(), i,
12355 'lenient ordinal parsing ' + i + ' date check');
12356 }
12357 });
12358
12359 test('lenient ordinal parsing of number', function (assert) {
12360 var i, testMoment;
12361 for (i = 1; i <= 31; ++i) {
12362 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
12363 assert.equal(testMoment.year(), 2014,
12364 'lenient ordinal parsing of number ' + i + ' year check');
12365 assert.equal(testMoment.month(), 0,
12366 'lenient ordinal parsing of number ' + i + ' month check');
12367 assert.equal(testMoment.date(), i,
12368 'lenient ordinal parsing of number ' + i + ' date check');
12369 }
12370 });
12371
12372 test('strict ordinal parsing', function (assert) {
12373 var i, ordinalStr, testMoment;
12374 for (i = 1; i <= 31; ++i) {
12375 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
12376 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
12377 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
12378 }
12379 });
12380
12381 }));
12382
12383 (function (global, factory) {
12384 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
12385 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
12386 factory(global.moment)
12387 }(this, function (moment) { 'use strict';
12388
12389 /*global QUnit:false*/
12390
12391 var test = QUnit.test;
12392
12393 function module (name, lifecycle) {
12394 QUnit.module(name, {
12395 setup : function () {
12396 moment.locale('en');
12397 moment.createFromInputFallback = function () {
12398 throw new Error('input not handled by moment');
12399 };
12400 if (lifecycle && lifecycle.setup) {
12401 lifecycle.setup();
12402 }
12403 },
12404 teardown : function () {
12405 if (lifecycle && lifecycle.teardown) {
12406 lifecycle.teardown();
12407 }
12408 }
12409 });
12410 }
12411
12412 function localeModule (name, lifecycle) {
12413 QUnit.module('locale:' + name, {
12414 setup : function () {
12415 moment.locale(name);
12416 moment.createFromInputFallback = function () {
12417 throw new Error('input not handled by moment');
12418 };
12419 if (lifecycle && lifecycle.setup) {
12420 lifecycle.setup();
12421 }
12422 },
12423 teardown : function () {
12424 moment.locale('en');
12425 if (lifecycle && lifecycle.teardown) {
12426 lifecycle.teardown();
12427 }
12428 }
12429 });
12430 }
12431
12432 localeModule('gl');
12433
12434 test('parse', function (assert) {
12435 var tests = 'Xaneiro Xan._Febreiro Feb._Marzo Mar._Abril Abr._Maio Mai._Xuño Xuñ._Xullo Xul._Agosto Ago._Setembro Set._Outubro Out._Novembro Nov._Decembro Dec.'.split('_'), i;
12436 function equalTest(input, mmm, i) {
12437 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
12438 }
12439 for (i = 0; i < 12; i++) {
12440 tests[i] = tests[i].split(' ');
12441 equalTest(tests[i][0], 'MMM', i);
12442 equalTest(tests[i][1], 'MMM', i);
12443 equalTest(tests[i][0], 'MMMM', i);
12444 equalTest(tests[i][1], 'MMMM', i);
12445 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
12446 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
12447 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
12448 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
12449 }
12450 });
12451
12452 test('format', function (assert) {
12453 var a = [
12454 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Febreiro 14º 2010, 3:25:50 pm'],
12455 ['ddd, hA', 'Dom., 3PM'],
12456 ['M Mo MM MMMM MMM', '2 2º 02 Febreiro Feb.'],
12457 ['YYYY YY', '2010 10'],
12458 ['D Do DD', '14 14º 14'],
12459 ['d do dddd ddd dd', '0 0º Domingo Dom. Do'],
12460 ['DDD DDDo DDDD', '45 45º 045'],
12461 ['w wo ww', '7 7º 07'],
12462 ['h hh', '3 03'],
12463 ['H HH', '15 15'],
12464 ['m mm', '25 25'],
12465 ['s ss', '50 50'],
12466 ['a A', 'pm PM'],
12467 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
12468 ['LTS', '15:25:50'],
12469 ['L', '14/02/2010'],
12470 ['LL', '14 Febreiro 2010'],
12471 ['LLL', '14 Febreiro 2010 15:25'],
12472 ['LLLL', 'Domingo 14 Febreiro 2010 15:25'],
12473 ['l', '14/2/2010'],
12474 ['ll', '14 Feb. 2010'],
12475 ['lll', '14 Feb. 2010 15:25'],
12476 ['llll', 'Dom. 14 Feb. 2010 15:25']
12477 ],
12478 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
12479 i;
12480 for (i = 0; i < a.length; i++) {
12481 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
12482 }
12483 });
12484
12485 test('format ordinal', function (assert) {
12486 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
12487 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
12488 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
12489 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
12490 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
12491 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
12492 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
12493 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
12494 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
12495 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
12496
12497 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
12498 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
12499 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
12500 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
12501 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
12502 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
12503 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
12504 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
12505 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
12506 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
12507
12508 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
12509 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
12510 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
12511 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
12512 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
12513 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
12514 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
12515 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
12516 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
12517 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
12518
12519 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
12520 });
12521
12522 test('format month', function (assert) {
12523 var expected = 'Xaneiro Xan._Febreiro Feb._Marzo Mar._Abril Abr._Maio Mai._Xuño Xuñ._Xullo Xul._Agosto Ago._Setembro Set._Outubro Out._Novembro Nov._Decembro Dec.'.split('_'), i;
12524 for (i = 0; i < expected.length; i++) {
12525 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
12526 }
12527 });
12528
12529 test('format week', function (assert) {
12530 var expected = 'Domingo Dom. Do_Luns Lun. Lu_Martes Mar. Ma_Mércores Mér. Mé_Xoves Xov. Xo_Venres Ven. Ve_Sábado Sáb. Sá'.split('_'),
12531 i;
12532 for (i = 0; i < expected.length; i++) {
12533 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
12534 }
12535 });
12536
12537 test('from', function (assert) {
12538 var start = moment([2007, 1, 28]);
12539
12540 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'uns segundos', '44 seconds = a few seconds');
12541 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minuto', '45 seconds = a minute');
12542 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minuto', '89 seconds = a minute');
12543 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
12544 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
12545 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'unha hora', '45 minutes = an hour');
12546 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'unha hora', '89 minutes = an hour');
12547 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
12548 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
12549 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
12550 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un día', '22 hours = a day');
12551 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un día', '35 hours = a day');
12552 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 días', '36 hours = 2 days');
12553 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un día', '1 day = a day');
12554 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 días', '5 days = 5 days');
12555 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 días', '25 days = 25 days');
12556 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mes', '26 days = a month');
12557 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mes', '30 days = a month');
12558 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mes', '43 days = a month');
12559 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
12560 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
12561 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
12562 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mes', '1 month = a month');
12563 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
12564 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un ano', '345 days = a year');
12565 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anos', '548 days = 2 years');
12566 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un ano', '1 year = a year');
12567 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anos', '5 years = 5 years');
12568 });
12569
12570 test('suffix', function (assert) {
12571 assert.equal(moment(30000).from(0), 'nuns segundos', 'prefix');
12572 assert.equal(moment(0).from(30000), 'hai uns segundos', 'suffix');
12573 });
12574
12575 test('now from now', function (assert) {
12576 assert.equal(moment().fromNow(), 'hai uns segundos', 'now from now should display as in the past');
12577 });
12578
12579 test('fromNow', function (assert) {
12580 assert.equal(moment().add({s: 30}).fromNow(), 'nuns segundos', 'en unos segundos');
12581 assert.equal(moment().add({d: 5}).fromNow(), 'en 5 días', 'en 5 días');
12582 });
12583
12584 test('calendar day', function (assert) {
12585 var a = moment().hours(2).minutes(0).seconds(0);
12586
12587 assert.equal(moment(a).calendar(), 'hoxe ás 2:00', 'today at the same time');
12588 assert.equal(moment(a).add({m: 25}).calendar(), 'hoxe ás 2:25', 'Now plus 25 min');
12589 assert.equal(moment(a).add({h: 1}).calendar(), 'hoxe ás 3:00', 'Now plus 1 hour');
12590 assert.equal(moment(a).add({d: 1}).calendar(), 'mañá ás 2:00', 'tomorrow at the same time');
12591 assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañá á 1:00', 'tomorrow minus 1 hour');
12592 assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoxe á 1:00', 'Now minus 1 hour');
12593 assert.equal(moment(a).subtract({d: 1}).calendar(), 'onte á 2:00', 'yesterday at the same time');
12594 });
12595
12596 test('calendar next week', function (assert) {
12597 var i, m;
12598
12599 for (i = 2; i < 7; i++) {
12600 m = moment().add({d: i});
12601 assert.equal(m.calendar(), m.format('dddd [' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today + ' + i + ' days current time');
12602 m.hours(0).minutes(0).seconds(0).milliseconds(0);
12603 assert.equal(m.calendar(), m.format('dddd [' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today + ' + i + ' days beginning of day');
12604 m.hours(23).minutes(59).seconds(59).milliseconds(999);
12605 assert.equal(m.calendar(), m.format('dddd [' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today + ' + i + ' days end of day');
12606 }
12607 });
12608
12609 test('calendar last week', function (assert) {
12610 var i, m;
12611 for (i = 2; i < 7; i++) {
12612 m = moment().subtract({d: i});
12613 assert.equal(m.calendar(), m.format('[o] dddd [pasado ' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today - ' + i + ' days current time');
12614 m.hours(0).minutes(0).seconds(0).milliseconds(0);
12615 assert.equal(m.calendar(), m.format('[o] dddd [pasado ' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today - ' + i + ' days beginning of day');
12616 m.hours(23).minutes(59).seconds(59).milliseconds(999);
12617 assert.equal(m.calendar(), m.format('[o] dddd [pasado ' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today - ' + i + ' days end of day');
12618 }
12619 });
12620
12621 test('calendar all else', function (assert) {
12622 var weeksAgo = moment().subtract({w: 1}),
12623 weeksFromNow = moment().add({w: 1});
12624
12625 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
12626 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
12627
12628 weeksAgo = moment().subtract({w: 2});
12629 weeksFromNow = moment().add({w: 2});
12630
12631 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
12632 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
12633 });
12634
12635 test('regression tests', function (assert) {
12636 var lastWeek = moment().subtract({d: 4}).hours(1);
12637 assert.equal(lastWeek.calendar(), lastWeek.format('[o] dddd [pasado a] LT'), '1 o\'clock bug');
12638 });
12639
12640 test('weeks year starting sunday', function (assert) {
12641 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
12642 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
12643 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
12644 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
12645 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
12646 });
12647
12648 test('weeks year starting monday', function (assert) {
12649 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
12650 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
12651 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
12652 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
12653 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
12654 });
12655
12656 test('weeks year starting tuesday', function (assert) {
12657 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
12658 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
12659 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
12660 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
12661 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
12662 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
12663 });
12664
12665 test('weeks year starting wednesday', function (assert) {
12666 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
12667 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
12668 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
12669 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
12670 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
12671 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
12672 });
12673
12674 test('weeks year starting thursday', function (assert) {
12675 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
12676 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
12677 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
12678 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
12679 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
12680 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
12681 });
12682
12683 test('weeks year starting friday', function (assert) {
12684 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
12685 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
12686 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
12687 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
12688 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
12689 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
12690 });
12691
12692 test('weeks year starting saturday', function (assert) {
12693 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
12694 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
12695 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
12696 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
12697 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
12698 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
12699 });
12700
12701 test('weeks year starting sunday formatted', function (assert) {
12702 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1º', 'Dec 26 2011 should be week 1');
12703 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
12704 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2º', 'Jan 2 2012 should be week 2');
12705 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2º', 'Jan 8 2012 should be week 2');
12706 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3º', 'Jan 9 2012 should be week 3');
12707 });
12708
12709 test('lenient ordinal parsing', function (assert) {
12710 var i, ordinalStr, testMoment;
12711 for (i = 1; i <= 31; ++i) {
12712 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
12713 testMoment = moment(ordinalStr, 'YYYY MM Do');
12714 assert.equal(testMoment.year(), 2014,
12715 'lenient ordinal parsing ' + i + ' year check');
12716 assert.equal(testMoment.month(), 0,
12717 'lenient ordinal parsing ' + i + ' month check');
12718 assert.equal(testMoment.date(), i,
12719 'lenient ordinal parsing ' + i + ' date check');
12720 }
12721 });
12722
12723 test('lenient ordinal parsing of number', function (assert) {
12724 var i, testMoment;
12725 for (i = 1; i <= 31; ++i) {
12726 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
12727 assert.equal(testMoment.year(), 2014,
12728 'lenient ordinal parsing of number ' + i + ' year check');
12729 assert.equal(testMoment.month(), 0,
12730 'lenient ordinal parsing of number ' + i + ' month check');
12731 assert.equal(testMoment.date(), i,
12732 'lenient ordinal parsing of number ' + i + ' date check');
12733 }
12734 });
12735
12736 test('strict ordinal parsing', function (assert) {
12737 var i, ordinalStr, testMoment;
12738 for (i = 1; i <= 31; ++i) {
12739 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
12740 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
12741 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
12742 }
12743 });
12744
12745 }));
12746
12747 (function (global, factory) {
12748 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
12749 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
12750 factory(global.moment)
12751 }(this, function (moment) { 'use strict';
12752
12753 /*global QUnit:false*/
12754
12755 var test = QUnit.test;
12756
12757 function module (name, lifecycle) {
12758 QUnit.module(name, {
12759 setup : function () {
12760 moment.locale('en');
12761 moment.createFromInputFallback = function () {
12762 throw new Error('input not handled by moment');
12763 };
12764 if (lifecycle && lifecycle.setup) {
12765 lifecycle.setup();
12766 }
12767 },
12768 teardown : function () {
12769 if (lifecycle && lifecycle.teardown) {
12770 lifecycle.teardown();
12771 }
12772 }
12773 });
12774 }
12775
12776 function localeModule (name, lifecycle) {
12777 QUnit.module('locale:' + name, {
12778 setup : function () {
12779 moment.locale(name);
12780 moment.createFromInputFallback = function () {
12781 throw new Error('input not handled by moment');
12782 };
12783 if (lifecycle && lifecycle.setup) {
12784 lifecycle.setup();
12785 }
12786 },
12787 teardown : function () {
12788 moment.locale('en');
12789 if (lifecycle && lifecycle.teardown) {
12790 lifecycle.teardown();
12791 }
12792 }
12793 });
12794 }
12795
12796 localeModule('he');
12797
12798 test('parse', function (assert) {
12799 var tests = 'ינואר ינו׳_פברואר פבר׳_מרץ מרץ_אפריל אפר׳_מאי מאי_יוני יוני_יולי יולי_אוגוסט אוג׳_ספטמבר ספט׳_אוקטובר אוק׳_נובמבר נוב׳_דצמבר דצמ׳'.split('_'), i;
12800 function equalTest(input, mmm, i) {
12801 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
12802 }
12803 for (i = 0; i < 12; i++) {
12804 tests[i] = tests[i].split(' ');
12805 equalTest(tests[i][0], 'MMM', i);
12806 equalTest(tests[i][1], 'MMM', i);
12807 equalTest(tests[i][0], 'MMMM', i);
12808 equalTest(tests[i][1], 'MMMM', i);
12809 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
12810 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
12811 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
12812 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
12813 }
12814 });
12815
12816 test('format', function (assert) {
12817 var a = [
12818 ['dddd, MMMM Do YYYY, h:mm:ss a', 'ראשון, פברואר 14 2010, 3:25:50 pm'],
12819 ['ddd, hA', 'א׳, 3PM'],
12820 ['M Mo MM MMMM MMM', '2 2 02 פברואר פבר׳'],
12821 ['YYYY YY', '2010 10'],
12822 ['D Do DD', '14 14 14'],
12823 ['d do dddd ddd dd', '0 0 ראשון א׳ א'],
12824 ['DDD DDDo DDDD', '45 45 045'],
12825 ['w wo ww', '8 8 08'],
12826 ['h hh', '3 03'],
12827 ['H HH', '15 15'],
12828 ['m mm', '25 25'],
12829 ['s ss', '50 50'],
12830 ['a A', 'pm PM'],
12831 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
12832 ['LTS', '15:25:50'],
12833 ['L', '14/02/2010'],
12834 ['LL', '14 בפברואר 2010'],
12835 ['LLL', '14 בפברואר 2010 15:25'],
12836 ['LLLL', 'ראשון, 14 בפברואר 2010 15:25'],
12837 ['l', '14/2/2010'],
12838 ['ll', '14 פבר׳ 2010'],
12839 ['lll', '14 פבר׳ 2010 15:25'],
12840 ['llll', 'א׳, 14 פבר׳ 2010 15:25']
12841 ],
12842 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
12843 i;
12844 for (i = 0; i < a.length; i++) {
12845 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
12846 }
12847 });
12848
12849 test('format month', function (assert) {
12850 var expected = 'ינואר ינו׳_פברואר פבר׳_מרץ מרץ_אפריל אפר׳_מאי מאי_יוני יוני_יולי יולי_אוגוסט אוג׳_ספטמבר ספט׳_אוקטובר אוק׳_נובמבר נוב׳_דצמבר דצמ׳'.split('_'), i;
12851 for (i = 0; i < expected.length; i++) {
12852 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
12853 }
12854 });
12855
12856 test('format week', function (assert) {
12857 var expected = 'ראשון א׳ א|שני ב׳ ב|שלישי ג׳ ג|רביעי ד׳ ד|חמישי ה׳ ה|שישי ו׳ ו|שבת ש׳ ש'.split('|'), i;
12858 for (i = 0; i < expected.length; i++) {
12859 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
12860 }
12861 });
12862
12863 test('from', function (assert) {
12864 var start = moment([2007, 1, 28]);
12865 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'מספר שניות', '44 seconds = a few seconds');
12866 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'דקה', '45 seconds = a minute');
12867 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'דקה', '89 seconds = a minute');
12868 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 דקות', '90 seconds = 2 minutes');
12869 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 דקות', '44 minutes = 44 minutes');
12870 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'שעה', '45 minutes = an hour');
12871 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'שעה', '89 minutes = an hour');
12872 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'שעתיים', '90 minutes = 2 hours');
12873 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 שעות', '5 hours = 5 hours');
12874 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 שעות', '21 hours = 21 hours');
12875 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'יום', '22 hours = a day');
12876 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'יום', '35 hours = a day');
12877 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'יומיים', '36 hours = 2 days');
12878 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'יום', '1 day = a day');
12879 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ימים', '5 days = 5 days');
12880 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ימים', '25 days = 25 days');
12881 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'חודש', '26 days = a month');
12882 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'חודש', '30 days = a month');
12883 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'חודש', '43 days = a month');
12884 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'חודשיים', '46 days = 2 months');
12885 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'חודשיים', '75 days = 2 months');
12886 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 חודשים', '76 days = 3 months');
12887 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'חודש', '1 month = a month');
12888 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 חודשים', '5 months = 5 months');
12889 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'שנה', '345 days = a year');
12890 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'שנתיים', '548 days = 2 years');
12891 assert.equal(start.from(moment([2007, 1, 28]).add({d: 3699}), true), '10 שנים', '345 days = 10 years');
12892 assert.equal(start.from(moment([2007, 1, 28]).add({d: 7340}), true), '20 שנה', '548 days = 20 years');
12893 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'שנה', '1 year = a year');
12894 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 שנים', '5 years = 5 years');
12895 });
12896
12897 test('suffix', function (assert) {
12898 assert.equal(moment(30000).from(0), 'בעוד מספר שניות', 'prefix');
12899 assert.equal(moment(0).from(30000), 'לפני מספר שניות', 'suffix');
12900 });
12901
12902 test('now from now', function (assert) {
12903 assert.equal(moment().fromNow(), 'לפני מספר שניות', 'now from now should display as in the past');
12904 });
12905
12906 test('fromNow', function (assert) {
12907 assert.equal(moment().add({s: 30}).fromNow(), 'בעוד מספר שניות', 'in a few seconds');
12908 assert.equal(moment().add({d: 5}).fromNow(), 'בעוד 5 ימים', 'in 5 days');
12909 });
12910
12911 test('calendar day', function (assert) {
12912 var a = moment().hours(2).minutes(0).seconds(0);
12913
12914 assert.equal(moment(a).calendar(), 'היום ב־02:00', 'today at the same time');
12915 assert.equal(moment(a).add({m: 25}).calendar(), 'היום ב־02:25', 'Now plus 25 min');
12916 assert.equal(moment(a).add({h: 1}).calendar(), 'היום ב־03:00', 'Now plus 1 hour');
12917 assert.equal(moment(a).add({d: 1}).calendar(), 'מחר ב־02:00', 'tomorrow at the same time');
12918 assert.equal(moment(a).subtract({h: 1}).calendar(), 'היום ב־01:00', 'Now minus 1 hour');
12919 assert.equal(moment(a).subtract({d: 1}).calendar(), 'אתמול ב־02:00', 'yesterday at the same time');
12920 });
12921
12922 test('calendar next week', function (assert) {
12923 var i, m;
12924 for (i = 2; i < 7; i++) {
12925 m = moment().add({d: i});
12926 assert.equal(m.calendar(), m.format('dddd [בשעה] LT'), 'Today + ' + i + ' days current time');
12927 m.hours(0).minutes(0).seconds(0).milliseconds(0);
12928 assert.equal(m.calendar(), m.format('dddd [בשעה] LT'), 'Today + ' + i + ' days beginning of day');
12929 m.hours(23).minutes(59).seconds(59).milliseconds(999);
12930 assert.equal(m.calendar(), m.format('dddd [בשעה] LT'), 'Today + ' + i + ' days end of day');
12931 }
12932 });
12933
12934 test('calendar last week', function (assert) {
12935 var i, m;
12936 for (i = 2; i < 7; i++) {
12937 m = moment().subtract({d: i});
12938 assert.equal(m.calendar(), m.format('[ביום] dddd [האחרון בשעה] LT'), 'Today - ' + i + ' days current time');
12939 m.hours(0).minutes(0).seconds(0).milliseconds(0);
12940 assert.equal(m.calendar(), m.format('[ביום] dddd [האחרון בשעה] LT'), 'Today - ' + i + ' days beginning of day');
12941 m.hours(23).minutes(59).seconds(59).milliseconds(999);
12942 assert.equal(m.calendar(), m.format('[ביום] dddd [האחרון בשעה] LT'), 'Today - ' + i + ' days end of day');
12943 }
12944 });
12945
12946 test('calendar all else', function (assert) {
12947 var weeksAgo = moment().subtract({w: 1}),
12948 weeksFromNow = moment().add({w: 1});
12949
12950 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
12951 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
12952
12953 weeksAgo = moment().subtract({w: 2});
12954 weeksFromNow = moment().add({w: 2});
12955
12956 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
12957 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
12958 });
12959
12960 test('weeks year starting sunday', function (assert) {
12961 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
12962 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
12963 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
12964 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
12965 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
12966 });
12967
12968 test('weeks year starting monday', function (assert) {
12969 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
12970 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
12971 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
12972 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
12973 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
12974 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
12975 });
12976
12977 test('weeks year starting tuesday', function (assert) {
12978 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
12979 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
12980 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
12981 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
12982 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
12983 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
12984 });
12985
12986 test('weeks year starting wednesday', function (assert) {
12987 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
12988 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
12989 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
12990 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
12991 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
12992 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
12993 });
12994
12995 test('weeks year starting thursday', function (assert) {
12996 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
12997 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
12998 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
12999 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
13000 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
13001 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
13002 });
13003
13004 test('weeks year starting friday', function (assert) {
13005 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
13006 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
13007 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
13008 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
13009 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
13010 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
13011 });
13012
13013 test('weeks year starting saturday', function (assert) {
13014 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
13015 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
13016 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
13017 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
13018 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
13019 });
13020
13021 test('weeks year starting sunday format', function (assert) {
13022 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
13023 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
13024 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
13025 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
13026 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
13027 });
13028
13029 test('lenient ordinal parsing', function (assert) {
13030 var i, ordinalStr, testMoment;
13031 for (i = 1; i <= 31; ++i) {
13032 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
13033 testMoment = moment(ordinalStr, 'YYYY MM Do');
13034 assert.equal(testMoment.year(), 2014,
13035 'lenient ordinal parsing ' + i + ' year check');
13036 assert.equal(testMoment.month(), 0,
13037 'lenient ordinal parsing ' + i + ' month check');
13038 assert.equal(testMoment.date(), i,
13039 'lenient ordinal parsing ' + i + ' date check');
13040 }
13041 });
13042
13043 test('lenient ordinal parsing of number', function (assert) {
13044 var i, testMoment;
13045 for (i = 1; i <= 31; ++i) {
13046 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
13047 assert.equal(testMoment.year(), 2014,
13048 'lenient ordinal parsing of number ' + i + ' year check');
13049 assert.equal(testMoment.month(), 0,
13050 'lenient ordinal parsing of number ' + i + ' month check');
13051 assert.equal(testMoment.date(), i,
13052 'lenient ordinal parsing of number ' + i + ' date check');
13053 }
13054 });
13055
13056 test('strict ordinal parsing', function (assert) {
13057 var i, ordinalStr, testMoment;
13058 for (i = 1; i <= 31; ++i) {
13059 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
13060 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
13061 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
13062 }
13063 });
13064
13065 }));
13066
13067 (function (global, factory) {
13068 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
13069 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
13070 factory(global.moment)
13071 }(this, function (moment) { 'use strict';
13072
13073 /*global QUnit:false*/
13074
13075 var test = QUnit.test;
13076
13077 function module (name, lifecycle) {
13078 QUnit.module(name, {
13079 setup : function () {
13080 moment.locale('en');
13081 moment.createFromInputFallback = function () {
13082 throw new Error('input not handled by moment');
13083 };
13084 if (lifecycle && lifecycle.setup) {
13085 lifecycle.setup();
13086 }
13087 },
13088 teardown : function () {
13089 if (lifecycle && lifecycle.teardown) {
13090 lifecycle.teardown();
13091 }
13092 }
13093 });
13094 }
13095
13096 function localeModule (name, lifecycle) {
13097 QUnit.module('locale:' + name, {
13098 setup : function () {
13099 moment.locale(name);
13100 moment.createFromInputFallback = function () {
13101 throw new Error('input not handled by moment');
13102 };
13103 if (lifecycle && lifecycle.setup) {
13104 lifecycle.setup();
13105 }
13106 },
13107 teardown : function () {
13108 moment.locale('en');
13109 if (lifecycle && lifecycle.teardown) {
13110 lifecycle.teardown();
13111 }
13112 }
13113 });
13114 }
13115
13116 localeModule('hi');
13117
13118 test('parse', function (assert) {
13119 var tests = 'जनवरी जन._फ़रवरी फ़र._मार्च मार्च_अप्रैल अप्रै._मई मई_जून जून_जुलाई जुल._अगस्त अग._सितम्बर सित._अक्टूबर अक्टू._नवम्बर नव._दिसम्बर दिस.'.split('_'), i;
13120 function equalTest(input, mmm, i) {
13121 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
13122 }
13123 for (i = 0; i < 12; i++) {
13124 tests[i] = tests[i].split(' ');
13125 equalTest(tests[i][0], 'MMM', i);
13126 equalTest(tests[i][1], 'MMM', i);
13127 equalTest(tests[i][0], 'MMMM', i);
13128 equalTest(tests[i][1], 'MMMM', i);
13129 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
13130 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
13131 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
13132 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
13133 }
13134 });
13135
13136 test('format', function (assert) {
13137 var a = [
13138 ['dddd, Do MMMM YYYY, a h:mm:ss बजे', 'रविवार, १४ फ़रवरी २०१०, दोपहर ३:२५:५० बजे'],
13139 ['ddd, a h बजे', 'रवि, दोपहर ३ बजे'],
13140 ['M Mo MM MMMM MMM', '२ २ ०२ फ़रवरी फ़र.'],
13141 ['YYYY YY', '२०१० १०'],
13142 ['D Do DD', '१४ १४ १४'],
13143 ['d do dddd ddd dd', '० ० रविवार रवि र'],
13144 ['DDD DDDo DDDD', '४५ ४५ ०४५'],
13145 ['w wo ww', '८ ८ ०८'],
13146 ['h hh', '३ ०३'],
13147 ['H HH', '१५ १५'],
13148 ['m mm', '२५ २५'],
13149 ['s ss', '५० ५०'],
13150 ['a A', 'दोपहर दोपहर'],
13151 ['LTS', 'दोपहर ३:२५:५० बजे'],
13152 ['L', '१४/०२/२०१०'],
13153 ['LL', '१४ फ़रवरी २०१०'],
13154 ['LLL', '१४ फ़रवरी २०१०, दोपहर ३:२५ बजे'],
13155 ['LLLL', 'रविवार, १४ फ़रवरी २०१०, दोपहर ३:२५ बजे'],
13156 ['l', '१४/२/२०१०'],
13157 ['ll', '१४ फ़र. २०१०'],
13158 ['lll', '१४ फ़र. २०१०, दोपहर ३:२५ बजे'],
13159 ['llll', 'रवि, १४ फ़र. २०१०, दोपहर ३:२५ बजे']
13160 ],
13161 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
13162 i;
13163 for (i = 0; i < a.length; i++) {
13164 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
13165 }
13166 });
13167
13168 test('format ordinal', function (assert) {
13169 assert.equal(moment([2011, 0, 1]).format('DDDo'), '१', '१');
13170 assert.equal(moment([2011, 0, 2]).format('DDDo'), '२', '२');
13171 assert.equal(moment([2011, 0, 3]).format('DDDo'), '३', '३');
13172 assert.equal(moment([2011, 0, 4]).format('DDDo'), '४', '४');
13173 assert.equal(moment([2011, 0, 5]).format('DDDo'), '५', '५');
13174 assert.equal(moment([2011, 0, 6]).format('DDDo'), '६', '६');
13175 assert.equal(moment([2011, 0, 7]).format('DDDo'), '७', '७');
13176 assert.equal(moment([2011, 0, 8]).format('DDDo'), '८', '८');
13177 assert.equal(moment([2011, 0, 9]).format('DDDo'), '९', '९');
13178 assert.equal(moment([2011, 0, 10]).format('DDDo'), '१०', '१०');
13179
13180 assert.equal(moment([2011, 0, 11]).format('DDDo'), '११', '११');
13181 assert.equal(moment([2011, 0, 12]).format('DDDo'), '१२', '१२');
13182 assert.equal(moment([2011, 0, 13]).format('DDDo'), '१३', '१३');
13183 assert.equal(moment([2011, 0, 14]).format('DDDo'), '१४', '१४');
13184 assert.equal(moment([2011, 0, 15]).format('DDDo'), '१५', '१५');
13185 assert.equal(moment([2011, 0, 16]).format('DDDo'), '१६', '१६');
13186 assert.equal(moment([2011, 0, 17]).format('DDDo'), '१७', '१७');
13187 assert.equal(moment([2011, 0, 18]).format('DDDo'), '१८', '१८');
13188 assert.equal(moment([2011, 0, 19]).format('DDDo'), '१९', '१९');
13189 assert.equal(moment([2011, 0, 20]).format('DDDo'), '२०', '२०');
13190
13191 assert.equal(moment([2011, 0, 21]).format('DDDo'), '२१', '२१');
13192 assert.equal(moment([2011, 0, 22]).format('DDDo'), '२२', '२२');
13193 assert.equal(moment([2011, 0, 23]).format('DDDo'), '२३', '२३');
13194 assert.equal(moment([2011, 0, 24]).format('DDDo'), '२४', '२४');
13195 assert.equal(moment([2011, 0, 25]).format('DDDo'), '२५', '२५');
13196 assert.equal(moment([2011, 0, 26]).format('DDDo'), '२६', '२६');
13197 assert.equal(moment([2011, 0, 27]).format('DDDo'), '२७', '२७');
13198 assert.equal(moment([2011, 0, 28]).format('DDDo'), '२८', '२८');
13199 assert.equal(moment([2011, 0, 29]).format('DDDo'), '२९', '२९');
13200 assert.equal(moment([2011, 0, 30]).format('DDDo'), '३०', '३०');
13201
13202 assert.equal(moment([2011, 0, 31]).format('DDDo'), '३१', '३१');
13203 });
13204
13205 test('format month', function (assert) {
13206 var expected = 'जनवरी जन._फ़रवरी फ़र._मार्च मार्च_अप्रैल अप्रै._मई मई_जून जून_जुलाई जुल._अगस्त अग._सितम्बर सित._अक्टूबर अक्टू._नवम्बर नव._दिसम्बर दिस.'.split('_'), i;
13207 for (i = 0; i < expected.length; i++) {
13208 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
13209 }
13210 });
13211
13212 test('format week', function (assert) {
13213 var expected = 'रविवार रवि र_सोमवार सोम सो_मंगलवार मंगल मं_बुधवार बुध बु_गुरूवार गुरू गु_शुक्रवार शुक्र शु_शनिवार शनि श'.split('_'), i;
13214 for (i = 0; i < expected.length; i++) {
13215 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
13216 }
13217 });
13218
13219 test('from', function (assert) {
13220 var start = moment([2007, 1, 28]);
13221 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'कुछ ही क्षण', '44 seconds = a few seconds');
13222 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'एक मिनट', '45 seconds = a minute');
13223 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'एक मिनट', '89 seconds = a minute');
13224 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '२ मिनट', '90 seconds = 2 minutes');
13225 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '४४ मिनट', '44 minutes = 44 minutes');
13226 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'एक घंटा', '45 minutes = an hour');
13227 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'एक घंटा', '89 minutes = an hour');
13228 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '२ घंटे', '90 minutes = 2 hours');
13229 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '५ घंटे', '5 hours = 5 hours');
13230 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '२१ घंटे', '21 hours = 21 hours');
13231 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'एक दिन', '22 hours = a day');
13232 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'एक दिन', '35 hours = a day');
13233 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '२ दिन', '36 hours = 2 days');
13234 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'एक दिन', '1 day = a day');
13235 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '५ दिन', '5 days = 5 days');
13236 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '२५ दिन', '25 days = 25 days');
13237 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'एक महीने', '26 days = a month');
13238 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'एक महीने', '30 days = a month');
13239 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'एक महीने', '43 days = a month');
13240 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '२ महीने', '46 days = 2 months');
13241 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '२ महीने', '75 days = 2 months');
13242 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '३ महीने', '76 days = 3 months');
13243 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'एक महीने', '1 month = a month');
13244 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '५ महीने', '5 months = 5 months');
13245 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'एक वर्ष', '345 days = a year');
13246 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '२ वर्ष', '548 days = 2 years');
13247 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'एक वर्ष', '1 year = a year');
13248 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '५ वर्ष', '5 years = 5 years');
13249 });
13250
13251 test('suffix', function (assert) {
13252 assert.equal(moment(30000).from(0), 'कुछ ही क्षण में', 'prefix');
13253 assert.equal(moment(0).from(30000), 'कुछ ही क्षण पहले', 'suffix');
13254 });
13255
13256 test('now from now', function (assert) {
13257 assert.equal(moment().fromNow(), 'कुछ ही क्षण पहले', 'now from now should display as in the past');
13258 });
13259
13260 test('fromNow', function (assert) {
13261 assert.equal(moment().add({s: 30}).fromNow(), 'कुछ ही क्षण में', 'कुछ ही क्षण में');
13262 assert.equal(moment().add({d: 5}).fromNow(), '५ दिन में', '५ दिन में');
13263 });
13264
13265 test('calendar day', function (assert) {
13266 var a = moment().hours(2).minutes(0).seconds(0);
13267
13268 assert.equal(moment(a).calendar(), 'आज रात २:०० बजे', 'today at the same time');
13269 assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात २:२५ बजे', 'Now plus 25 min');
13270 assert.equal(moment(a).add({h: 3}).calendar(), 'आज सुबह ५:०० बजे', 'Now plus 3 hour');
13271 assert.equal(moment(a).add({d: 1}).calendar(), 'कल रात २:०० बजे', 'tomorrow at the same time');
13272 assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात १:०० बजे', 'Now minus 1 hour');
13273 assert.equal(moment(a).subtract({d: 1}).calendar(), 'कल रात २:०० बजे', 'yesterday at the same time');
13274 });
13275
13276 test('calendar next week', function (assert) {
13277 var i, m;
13278 for (i = 2; i < 7; i++) {
13279 m = moment().add({d: i});
13280 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
13281 m.hours(0).minutes(0).seconds(0).milliseconds(0);
13282 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
13283 m.hours(23).minutes(59).seconds(59).milliseconds(999);
13284 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
13285 }
13286 });
13287
13288 test('calendar last week', function (assert) {
13289 var i, m;
13290
13291 for (i = 2; i < 7; i++) {
13292 m = moment().subtract({d: i});
13293 assert.equal(m.calendar(), m.format('[पिछले] dddd[,] LT'), 'Today - ' + i + ' days current time');
13294 m.hours(0).minutes(0).seconds(0).milliseconds(0);
13295 assert.equal(m.calendar(), m.format('[पिछले] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
13296 m.hours(23).minutes(59).seconds(59).milliseconds(999);
13297 assert.equal(m.calendar(), m.format('[पिछले] dddd[,] LT'), 'Today - ' + i + ' days end of day');
13298 }
13299 });
13300
13301 test('calendar all else', function (assert) {
13302 var weeksAgo = moment().subtract({w: 1}),
13303 weeksFromNow = moment().add({w: 1});
13304
13305 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
13306 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
13307
13308 weeksAgo = moment().subtract({w: 2});
13309 weeksFromNow = moment().add({w: 2});
13310
13311 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
13312 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
13313 });
13314
13315 test('meridiem invariant', function (assert) {
13316 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'रात', 'before dawn');
13317 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'सुबह', 'morning');
13318 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दोपहर', 'during day');
13319 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'शाम', 'evening');
13320 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'शाम', 'late evening');
13321 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'रात', 'night');
13322
13323 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'रात', 'before dawn');
13324 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'सुबह', 'morning');
13325 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'दोपहर', ' during day');
13326 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'शाम', 'evening');
13327 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'शाम', 'late evening');
13328 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात', 'night');
13329 });
13330
13331 test('weeks year starting sunday', function (assert) {
13332 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
13333 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
13334 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
13335 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
13336 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
13337 });
13338
13339 test('weeks year starting monday', function (assert) {
13340 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
13341 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
13342 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
13343 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
13344 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
13345 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
13346 });
13347
13348 test('weeks year starting tuesday', function (assert) {
13349 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
13350 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
13351 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
13352 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
13353 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
13354 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
13355 });
13356
13357 test('weeks year starting wednesday', function (assert) {
13358 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
13359 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
13360 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
13361 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
13362 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
13363 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
13364 });
13365
13366 test('weeks year starting thursday', function (assert) {
13367 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
13368 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
13369 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
13370 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
13371 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
13372 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
13373 });
13374
13375 test('weeks year starting friday', function (assert) {
13376 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
13377 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
13378 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
13379 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
13380 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
13381 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
13382 });
13383
13384 test('weeks year starting saturday', function (assert) {
13385 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
13386 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
13387 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
13388 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
13389 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
13390 });
13391
13392 test('weeks year starting sunday formatted', function (assert) {
13393 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
13394 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
13395 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '२ ०२ २', 'Jan 8 2012 should be week 2');
13396 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '२ ०२ २', 'Jan 14 2012 should be week 2');
13397 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
13398 });
13399
13400 test('lenient ordinal parsing', function (assert) {
13401 var i, ordinalStr, testMoment;
13402 for (i = 1; i <= 31; ++i) {
13403 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
13404 testMoment = moment(ordinalStr, 'YYYY MM Do');
13405 assert.equal(testMoment.year(), 2014,
13406 'lenient ordinal parsing ' + i + ' year check');
13407 assert.equal(testMoment.month(), 0,
13408 'lenient ordinal parsing ' + i + ' month check');
13409 assert.equal(testMoment.date(), i,
13410 'lenient ordinal parsing ' + i + ' date check');
13411 }
13412 });
13413
13414 test('lenient ordinal parsing of number', function (assert) {
13415 var i, testMoment;
13416 for (i = 1; i <= 31; ++i) {
13417 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
13418 assert.equal(testMoment.year(), 2014,
13419 'lenient ordinal parsing of number ' + i + ' year check');
13420 assert.equal(testMoment.month(), 0,
13421 'lenient ordinal parsing of number ' + i + ' month check');
13422 assert.equal(testMoment.date(), i,
13423 'lenient ordinal parsing of number ' + i + ' date check');
13424 }
13425 });
13426
13427 test('meridiem', function (assert) {
13428 var h, m, t1, t2;
13429 for (h = 0; h < 24; ++h) {
13430 for (m = 0; m < 60; m += 15) {
13431 t1 = moment.utc([2000, 0, 1, h, m]);
13432 t2 = moment(t1.format('A h:mm'), 'A h:mm');
13433 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
13434 'meridiem at ' + t1.format('HH:mm'));
13435 }
13436 }
13437 });
13438
13439 test('strict ordinal parsing', function (assert) {
13440 var i, ordinalStr, testMoment;
13441 for (i = 1; i <= 31; ++i) {
13442 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
13443 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
13444 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
13445 }
13446 });
13447
13448 }));
13449
13450 (function (global, factory) {
13451 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
13452 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
13453 factory(global.moment)
13454 }(this, function (moment) { 'use strict';
13455
13456 /*global QUnit:false*/
13457
13458 var test = QUnit.test;
13459
13460 function module (name, lifecycle) {
13461 QUnit.module(name, {
13462 setup : function () {
13463 moment.locale('en');
13464 moment.createFromInputFallback = function () {
13465 throw new Error('input not handled by moment');
13466 };
13467 if (lifecycle && lifecycle.setup) {
13468 lifecycle.setup();
13469 }
13470 },
13471 teardown : function () {
13472 if (lifecycle && lifecycle.teardown) {
13473 lifecycle.teardown();
13474 }
13475 }
13476 });
13477 }
13478
13479 function localeModule (name, lifecycle) {
13480 QUnit.module('locale:' + name, {
13481 setup : function () {
13482 moment.locale(name);
13483 moment.createFromInputFallback = function () {
13484 throw new Error('input not handled by moment');
13485 };
13486 if (lifecycle && lifecycle.setup) {
13487 lifecycle.setup();
13488 }
13489 },
13490 teardown : function () {
13491 moment.locale('en');
13492 if (lifecycle && lifecycle.teardown) {
13493 lifecycle.teardown();
13494 }
13495 }
13496 });
13497 }
13498
13499 localeModule('hr');
13500
13501 test('parse', function (assert) {
13502 var tests = 'siječanj sij._veljača velj._ožujak ožu._travanj tra._svibanj svi._lipanj lip._srpanj srp._kolovoz kol._rujan ruj._listopad lis._studeni stu._prosinac pro.'.split('_'), i;
13503 function equalTest(input, mmm, i) {
13504 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
13505 }
13506 for (i = 0; i < 12; i++) {
13507 tests[i] = tests[i].split(' ');
13508 equalTest(tests[i][0], 'MMM', i);
13509 equalTest(tests[i][1], 'MMM', i);
13510 equalTest(tests[i][0], 'MMMM', i);
13511 equalTest(tests[i][1], 'MMMM', i);
13512 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
13513 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
13514 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
13515 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
13516 }
13517 });
13518
13519 test('format', function (assert) {
13520 var a = [
13521 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedjelja, 14. veljača 2010, 3:25:50 pm'],
13522 ['ddd, hA', 'ned., 3PM'],
13523 ['M Mo MM MMMM MMM', '2 2. 02 veljača velj.'],
13524 ['YYYY YY', '2010 10'],
13525 ['D Do DD', '14 14. 14'],
13526 ['d do dddd ddd dd', '0 0. nedjelja ned. ne'],
13527 ['DDD DDDo DDDD', '45 45. 045'],
13528 ['w wo ww', '7 7. 07'],
13529 ['h hh', '3 03'],
13530 ['H HH', '15 15'],
13531 ['m mm', '25 25'],
13532 ['s ss', '50 50'],
13533 ['a A', 'pm PM'],
13534 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
13535 ['LTS', '15:25:50'],
13536 ['L', '14. 02. 2010'],
13537 ['LL', '14. veljača 2010'],
13538 ['LLL', '14. veljača 2010 15:25'],
13539 ['LLLL', 'nedjelja, 14. veljača 2010 15:25'],
13540 ['l', '14. 2. 2010'],
13541 ['ll', '14. velj. 2010'],
13542 ['lll', '14. velj. 2010 15:25'],
13543 ['llll', 'ned., 14. velj. 2010 15:25']
13544 ],
13545 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
13546 i;
13547 for (i = 0; i < a.length; i++) {
13548 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
13549 }
13550 });
13551
13552 test('format ordinal', function (assert) {
13553 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
13554 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
13555 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
13556 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
13557 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
13558 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
13559 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
13560 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
13561 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
13562 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
13563
13564 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
13565 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
13566 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
13567 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
13568 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
13569 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
13570 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
13571 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
13572 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
13573 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
13574
13575 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
13576 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
13577 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
13578 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
13579 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
13580 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
13581 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
13582 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
13583 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
13584 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
13585
13586 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
13587 });
13588
13589 test('format month', function (assert) {
13590 var expected = 'siječanj sij._veljača velj._ožujak ožu._travanj tra._svibanj svi._lipanj lip._srpanj srp._kolovoz kol._rujan ruj._listopad lis._studeni stu._prosinac pro.'.split('_'), i;
13591 for (i = 0; i < expected.length; i++) {
13592 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
13593 }
13594 });
13595
13596 test('format week', function (assert) {
13597 var expected = 'nedjelja ned. ne_ponedjeljak pon. po_utorak uto. ut_srijeda sri. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'), i;
13598 for (i = 0; i < expected.length; i++) {
13599 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
13600 }
13601 });
13602
13603 test('from', function (assert) {
13604 var start = moment([2007, 1, 28]);
13605 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'par sekundi', '44 seconds = a few seconds');
13606 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedna minuta', '45 seconds = a minute');
13607 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedna minuta', '89 seconds = a minute');
13608 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
13609 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
13610 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
13611 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
13612 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
13613 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
13614 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
13615 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
13616 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
13617 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
13618 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
13619 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
13620 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
13621 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mjesec', '26 days = a month');
13622 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mjesec', '30 days = a month');
13623 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mjesec', '43 days = a month');
13624 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mjeseca', '46 days = 2 months');
13625 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mjeseca', '75 days = 2 months');
13626 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mjeseca', '76 days = 3 months');
13627 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mjesec', '1 month = a month');
13628 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mjeseci', '5 months = 5 months');
13629 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
13630 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
13631 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
13632 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
13633 });
13634
13635 test('suffix', function (assert) {
13636 assert.equal(moment(30000).from(0), 'za par sekundi', 'prefix');
13637 assert.equal(moment(0).from(30000), 'prije par sekundi', 'prefix');
13638 });
13639
13640 test('now from now', function (assert) {
13641 assert.equal(moment().fromNow(), 'prije par sekundi', 'now from now should display as in the past');
13642 });
13643
13644 test('fromNow', function (assert) {
13645 assert.equal(moment().add({s: 30}).fromNow(), 'za par sekundi', 'in a few seconds');
13646 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
13647 });
13648
13649 test('calendar day', function (assert) {
13650 var a = moment().hours(2).minutes(0).seconds(0);
13651
13652 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
13653 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
13654 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
13655 assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
13656 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
13657 assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
13658 });
13659
13660 test('calendar next week', function (assert) {
13661 var i, m;
13662
13663 function makeFormat(d) {
13664 switch (d.day()) {
13665 case 0:
13666 return '[u] [nedjelju] [u] LT';
13667 case 3:
13668 return '[u] [srijedu] [u] LT';
13669 case 6:
13670 return '[u] [subotu] [u] LT';
13671 case 1:
13672 case 2:
13673 case 4:
13674 case 5:
13675 return '[u] dddd [u] LT';
13676 }
13677 }
13678
13679 for (i = 2; i < 7; i++) {
13680 m = moment().add({d: i});
13681 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
13682 m.hours(0).minutes(0).seconds(0).milliseconds(0);
13683 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
13684 m.hours(23).minutes(59).seconds(59).milliseconds(999);
13685 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
13686 }
13687 });
13688
13689 test('calendar last week', function (assert) {
13690 var i, m;
13691
13692 function makeFormat(d) {
13693 switch (d.day()) {
13694 case 0:
13695 case 3:
13696 return '[prošlu] dddd [u] LT';
13697 case 6:
13698 return '[prošle] [subote] [u] LT';
13699 case 1:
13700 case 2:
13701 case 4:
13702 case 5:
13703 return '[prošli] dddd [u] LT';
13704 }
13705 }
13706
13707 for (i = 2; i < 7; i++) {
13708 m = moment().subtract({d: i});
13709 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
13710 m.hours(0).minutes(0).seconds(0).milliseconds(0);
13711 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
13712 m.hours(23).minutes(59).seconds(59).milliseconds(999);
13713 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
13714 }
13715 });
13716
13717 test('calendar all else', function (assert) {
13718 var weeksAgo = moment().subtract({w: 1}),
13719 weeksFromNow = moment().add({w: 1});
13720
13721 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
13722 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
13723
13724 weeksAgo = moment().subtract({w: 2});
13725 weeksFromNow = moment().add({w: 2});
13726
13727 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
13728 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
13729 });
13730
13731 test('weeks year starting sunday', function (assert) {
13732 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
13733 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
13734 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
13735 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
13736 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
13737 });
13738
13739 test('weeks year starting monday', function (assert) {
13740 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
13741 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
13742 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
13743 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
13744 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
13745 });
13746
13747 test('weeks year starting tuesday', function (assert) {
13748 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
13749 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
13750 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
13751 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
13752 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
13753 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
13754 });
13755
13756 test('weeks year starting wednesday', function (assert) {
13757 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
13758 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
13759 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
13760 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
13761 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
13762 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
13763 });
13764
13765 test('weeks year starting thursday', function (assert) {
13766 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
13767 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
13768 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
13769 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
13770 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
13771 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
13772 });
13773
13774 test('weeks year starting friday', function (assert) {
13775 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
13776 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
13777 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
13778 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
13779 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
13780 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
13781 });
13782
13783 test('weeks year starting saturday', function (assert) {
13784 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
13785 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
13786 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
13787 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
13788 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
13789 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
13790 });
13791
13792 test('weeks year starting sunday formatted', function (assert) {
13793 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
13794 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
13795 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
13796 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
13797 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
13798 });
13799
13800 test('lenient ordinal parsing', function (assert) {
13801 var i, ordinalStr, testMoment;
13802 for (i = 1; i <= 31; ++i) {
13803 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
13804 testMoment = moment(ordinalStr, 'YYYY MM Do');
13805 assert.equal(testMoment.year(), 2014,
13806 'lenient ordinal parsing ' + i + ' year check');
13807 assert.equal(testMoment.month(), 0,
13808 'lenient ordinal parsing ' + i + ' month check');
13809 assert.equal(testMoment.date(), i,
13810 'lenient ordinal parsing ' + i + ' date check');
13811 }
13812 });
13813
13814 test('lenient ordinal parsing of number', function (assert) {
13815 var i, testMoment;
13816 for (i = 1; i <= 31; ++i) {
13817 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
13818 assert.equal(testMoment.year(), 2014,
13819 'lenient ordinal parsing of number ' + i + ' year check');
13820 assert.equal(testMoment.month(), 0,
13821 'lenient ordinal parsing of number ' + i + ' month check');
13822 assert.equal(testMoment.date(), i,
13823 'lenient ordinal parsing of number ' + i + ' date check');
13824 }
13825 });
13826
13827 test('strict ordinal parsing', function (assert) {
13828 var i, ordinalStr, testMoment;
13829 for (i = 1; i <= 31; ++i) {
13830 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
13831 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
13832 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
13833 }
13834 });
13835
13836 }));
13837
13838 (function (global, factory) {
13839 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
13840 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
13841 factory(global.moment)
13842 }(this, function (moment) { 'use strict';
13843
13844 /*global QUnit:false*/
13845
13846 var test = QUnit.test;
13847
13848 function module (name, lifecycle) {
13849 QUnit.module(name, {
13850 setup : function () {
13851 moment.locale('en');
13852 moment.createFromInputFallback = function () {
13853 throw new Error('input not handled by moment');
13854 };
13855 if (lifecycle && lifecycle.setup) {
13856 lifecycle.setup();
13857 }
13858 },
13859 teardown : function () {
13860 if (lifecycle && lifecycle.teardown) {
13861 lifecycle.teardown();
13862 }
13863 }
13864 });
13865 }
13866
13867 function localeModule (name, lifecycle) {
13868 QUnit.module('locale:' + name, {
13869 setup : function () {
13870 moment.locale(name);
13871 moment.createFromInputFallback = function () {
13872 throw new Error('input not handled by moment');
13873 };
13874 if (lifecycle && lifecycle.setup) {
13875 lifecycle.setup();
13876 }
13877 },
13878 teardown : function () {
13879 moment.locale('en');
13880 if (lifecycle && lifecycle.teardown) {
13881 lifecycle.teardown();
13882 }
13883 }
13884 });
13885 }
13886
13887 localeModule('hu');
13888
13889 test('parse', function (assert) {
13890 var tests = 'január jan_február feb_március márc_április ápr_május máj_június jún_július júl_augusztus aug_szeptember szept_október okt_november nov_december dec'.split('_'),
13891 i;
13892 function equalTest(input, mmm, i) {
13893 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
13894 }
13895 for (i = 0; i < 12; i++) {
13896 tests[i] = tests[i].split(' ');
13897 equalTest(tests[i][0], 'MMM', i);
13898 equalTest(tests[i][1], 'MMM', i);
13899 equalTest(tests[i][0], 'MMMM', i);
13900 equalTest(tests[i][1], 'MMMM', i);
13901 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
13902 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
13903 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
13904 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
13905 }
13906 });
13907
13908 test('format', function (assert) {
13909 var a = [
13910 ['dddd, MMMM Do YYYY, HH:mm:ss', 'vasárnap, február 14. 2010, 15:25:50'],
13911 ['ddd, HH', 'vas, 15'],
13912 ['M Mo MM MMMM MMM', '2 2. 02 február feb'],
13913 ['YYYY YY', '2010 10'],
13914 ['D Do DD', '14 14. 14'],
13915 ['d do dddd ddd dd', '0 0. vasárnap vas v'],
13916 ['DDD DDDo DDDD', '45 45. 045'],
13917 ['w wo ww', '7 7. 07'],
13918 ['H HH', '15 15'],
13919 ['m mm', '25 25'],
13920 ['s ss', '50 50'],
13921 ['[az év] DDDo [napja]', 'az év 45. napja'],
13922 ['LTS', '15:25:50'],
13923 ['L', '2010.02.14.'],
13924 ['LL', '2010. február 14.'],
13925 ['LLL', '2010. február 14. 15:25'],
13926 ['LLLL', '2010. február 14., vasárnap 15:25'],
13927 ['l', '2010.2.14.'],
13928 ['ll', '2010. feb 14.'],
13929 ['lll', '2010. feb 14. 15:25'],
13930 ['llll', '2010. feb 14., vas 15:25']
13931 ],
13932 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
13933 i;
13934 for (i = 0; i < a.length; i++) {
13935 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
13936 }
13937 });
13938
13939 test('meridiem', function (assert) {
13940 assert.equal(moment([2011, 2, 23, 0, 0]).format('a'), 'de', 'am');
13941 assert.equal(moment([2011, 2, 23, 11, 59]).format('a'), 'de', 'am');
13942 assert.equal(moment([2011, 2, 23, 12, 0]).format('a'), 'du', 'pm');
13943 assert.equal(moment([2011, 2, 23, 23, 59]).format('a'), 'du', 'pm');
13944
13945 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), 'DE', 'AM');
13946 assert.equal(moment([2011, 2, 23, 11, 59]).format('A'), 'DE', 'AM');
13947 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), 'DU', 'PM');
13948 assert.equal(moment([2011, 2, 23, 23, 59]).format('A'), 'DU', 'PM');
13949 });
13950
13951 test('format ordinal', function (assert) {
13952 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
13953 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
13954 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
13955 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
13956 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
13957 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
13958 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
13959 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
13960 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
13961 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
13962
13963 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
13964 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
13965 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
13966 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
13967 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
13968 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
13969 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
13970 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
13971 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
13972 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
13973
13974 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
13975 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
13976 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
13977 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
13978 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
13979 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
13980 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
13981 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
13982 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
13983 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
13984
13985 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
13986 });
13987
13988 test('format month', function (assert) {
13989 var expected = 'január jan_február feb_március márc_április ápr_május máj_június jún_július júl_augusztus aug_szeptember szept_október okt_november nov_december dec'.split('_'),
13990 i;
13991 for (i = 0; i < expected.length; i++) {
13992 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
13993 }
13994 });
13995
13996 test('format week', function (assert) {
13997 var expected = 'vasárnap vas_hétfő hét_kedd kedd_szerda sze_csütörtök csüt_péntek pén_szombat szo'.split('_'),
13998 i;
13999 for (i = 0; i < expected.length; i++) {
14000 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
14001 }
14002 });
14003
14004 test('from', function (assert) {
14005 var start = moment([2007, 1, 28]);
14006 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'néhány másodperc', '44 másodperc = néhány másodperc');
14007 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'egy perc', '45 másodperc = egy perc');
14008 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'egy perc', '89 másodperc = egy perc');
14009 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 perc', '90 másodperc = 2 perc');
14010 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 perc', '44 perc = 44 perc');
14011 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'egy óra', '45 perc = egy óra');
14012 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'egy óra', '89 perc = egy óra');
14013 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 óra', '90 perc = 2 óra');
14014 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 óra', '5 óra = 5 óra');
14015 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 óra', '21 óra = 21 óra');
14016 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'egy nap', '22 óra = egy nap');
14017 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'egy nap', '35 óra = egy nap');
14018 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 nap', '36 óra = 2 nap');
14019 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'egy nap', '1 nap = egy nap');
14020 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 nap', '5 nap = 5 nap');
14021 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 nap', '25 nap = 25 nap');
14022 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'egy hónap', '26 nap = egy hónap');
14023 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'egy hónap', '30 nap = egy hónap');
14024 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'egy hónap', '45 nap = egy hónap');
14025 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 hónap', '46 nap = 2 hónap');
14026 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 hónap', '75 nap = 2 hónap');
14027 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 hónap', '76 nap = 3 hónap');
14028 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'egy hónap', '1 hónap = egy hónap');
14029 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 hónap', '5 hónap = 5 hónap');
14030 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'egy év', '345 nap = egy év');
14031 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 év', '548 nap = 2 év');
14032 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'egy év', '1 év = egy év');
14033 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 év', '5 év = 5 év');
14034 });
14035
14036 test('suffix', function (assert) {
14037 assert.equal(moment(30000).from(0), 'néhány másodperc múlva', 'prefix');
14038 assert.equal(moment(0).from(30000), 'néhány másodperce', 'suffix');
14039 });
14040
14041 test('now from now', function (assert) {
14042 assert.equal(moment().fromNow(), 'néhány másodperce', 'now from now should display as in the past');
14043 });
14044
14045 test('fromNow', function (assert) {
14046 assert.equal(moment().add({s: 30}).fromNow(), 'néhány másodperc múlva', 'néhány másodperc múlva');
14047 assert.equal(moment().add({d: 5}).fromNow(), '5 nap múlva', '5 nap múlva');
14048 });
14049
14050 test('calendar day', function (assert) {
14051 var a = moment().hours(2).minutes(0).seconds(0);
14052
14053 assert.equal(moment(a).calendar(), 'ma 2:00-kor', 'today at the same time');
14054 assert.equal(moment(a).add({m: 25}).calendar(), 'ma 2:25-kor', 'Now plus 25 min');
14055 assert.equal(moment(a).add({h: 1}).calendar(), 'ma 3:00-kor', 'Now plus 1 hour');
14056 assert.equal(moment(a).add({d: 1}).calendar(), 'holnap 2:00-kor', 'tomorrow at the same time');
14057 assert.equal(moment(a).subtract({h: 1}).calendar(), 'ma 1:00-kor', 'Now minus 1 hour');
14058 assert.equal(moment(a).subtract({d: 1}).calendar(), 'tegnap 2:00-kor', 'yesterday at the same time');
14059 });
14060
14061 test('calendar next week', function (assert) {
14062 var i, m, days = 'vasárnap_hétfőn_kedden_szerdán_csütörtökön_pénteken_szombaton'.split('_');
14063 for (i = 2; i < 7; i++) {
14064 m = moment().add({d: i});
14065 assert.equal(m.calendar(), m.format('[' + days[m.day()] + '] LT[-kor]'), 'today + ' + i + ' days current time');
14066 m.hours(0).minutes(0).seconds(0).milliseconds(0);
14067 assert.equal(m.calendar(), m.format('[' + days[m.day()] + '] LT[-kor]'), 'today + ' + i + ' days beginning of day');
14068 m.hours(23).minutes(59).seconds(59).milliseconds(999);
14069 assert.equal(m.calendar(), m.format('[' + days[m.day()] + '] LT[-kor]'), 'today + ' + i + ' days end of day');
14070 }
14071 });
14072
14073 test('calendar last week', function (assert) {
14074 var i, m, days = 'vasárnap_hétfőn_kedden_szerdán_csütörtökön_pénteken_szombaton'.split('_');
14075
14076 for (i = 2; i < 7; i++) {
14077 m = moment().subtract({d: i});
14078 assert.equal(m.calendar(), m.format('[múlt ' + days[m.day()] + '] LT[-kor]'), 'today - ' + i + ' days current time');
14079 m.hours(0).minutes(0).seconds(0).milliseconds(0);
14080 assert.equal(m.calendar(), m.format('[múlt ' + days[m.day()] + '] LT[-kor]'), 'today - ' + i + ' days beginning of day');
14081 m.hours(23).minutes(59).seconds(59).milliseconds(999);
14082 assert.equal(m.calendar(), m.format('[múlt ' + days[m.day()] + '] LT[-kor]'), 'today - ' + i + ' days end of day');
14083 }
14084 });
14085
14086 test('calendar all else', function (assert) {
14087 var weeksAgo = moment().subtract({w: 1}),
14088 weeksFromNow = moment().add({w: 1});
14089
14090 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'egy héte');
14091 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'egy hét múlva');
14092
14093 weeksAgo = moment().subtract({w: 2});
14094 weeksFromNow = moment().add({w: 2});
14095
14096 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 hete');
14097 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 hét múlva');
14098 });
14099
14100 test('weeks year starting sunday', function (assert) {
14101 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
14102 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
14103 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
14104 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
14105 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
14106 });
14107
14108 test('weeks year starting monday', function (assert) {
14109 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
14110 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
14111 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
14112 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
14113 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
14114 });
14115
14116 test('weeks year starting tuesday', function (assert) {
14117 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
14118 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
14119 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
14120 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
14121 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
14122 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
14123 });
14124
14125 test('weeks year starting wednesday', function (assert) {
14126 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
14127 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
14128 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
14129 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
14130 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
14131 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
14132 });
14133
14134 test('weeks year starting thursday', function (assert) {
14135 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
14136 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
14137 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
14138 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
14139 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
14140 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
14141 });
14142
14143 test('weeks year starting friday', function (assert) {
14144 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
14145 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
14146 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
14147 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
14148 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
14149 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
14150 });
14151
14152 test('weeks year starting saturday', function (assert) {
14153 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
14154 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
14155 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
14156 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
14157 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
14158 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
14159 });
14160
14161 test('weeks year starting sunday formatted', function (assert) {
14162 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
14163 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
14164 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
14165 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
14166 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
14167 });
14168
14169 test('lenient ordinal parsing', function (assert) {
14170 var i, ordinalStr, testMoment;
14171 for (i = 1; i <= 31; ++i) {
14172 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
14173 testMoment = moment(ordinalStr, 'YYYY MM Do');
14174 assert.equal(testMoment.year(), 2014,
14175 'lenient ordinal parsing ' + i + ' year check');
14176 assert.equal(testMoment.month(), 0,
14177 'lenient ordinal parsing ' + i + ' month check');
14178 assert.equal(testMoment.date(), i,
14179 'lenient ordinal parsing ' + i + ' date check');
14180 }
14181 });
14182
14183 test('lenient ordinal parsing of number', function (assert) {
14184 var i, testMoment;
14185 for (i = 1; i <= 31; ++i) {
14186 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
14187 assert.equal(testMoment.year(), 2014,
14188 'lenient ordinal parsing of number ' + i + ' year check');
14189 assert.equal(testMoment.month(), 0,
14190 'lenient ordinal parsing of number ' + i + ' month check');
14191 assert.equal(testMoment.date(), i,
14192 'lenient ordinal parsing of number ' + i + ' date check');
14193 }
14194 });
14195
14196 test('strict ordinal parsing', function (assert) {
14197 var i, ordinalStr, testMoment;
14198 for (i = 1; i <= 31; ++i) {
14199 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
14200 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
14201 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
14202 }
14203 });
14204
14205 }));
14206
14207 (function (global, factory) {
14208 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
14209 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
14210 factory(global.moment)
14211 }(this, function (moment) { 'use strict';
14212
14213 /*global QUnit:false*/
14214
14215 var test = QUnit.test;
14216
14217 function module (name, lifecycle) {
14218 QUnit.module(name, {
14219 setup : function () {
14220 moment.locale('en');
14221 moment.createFromInputFallback = function () {
14222 throw new Error('input not handled by moment');
14223 };
14224 if (lifecycle && lifecycle.setup) {
14225 lifecycle.setup();
14226 }
14227 },
14228 teardown : function () {
14229 if (lifecycle && lifecycle.teardown) {
14230 lifecycle.teardown();
14231 }
14232 }
14233 });
14234 }
14235
14236 function localeModule (name, lifecycle) {
14237 QUnit.module('locale:' + name, {
14238 setup : function () {
14239 moment.locale(name);
14240 moment.createFromInputFallback = function () {
14241 throw new Error('input not handled by moment');
14242 };
14243 if (lifecycle && lifecycle.setup) {
14244 lifecycle.setup();
14245 }
14246 },
14247 teardown : function () {
14248 moment.locale('en');
14249 if (lifecycle && lifecycle.teardown) {
14250 lifecycle.teardown();
14251 }
14252 }
14253 });
14254 }
14255
14256 localeModule('hy-am');
14257
14258 test('parse', function (assert) {
14259 var tests = 'հունվար հնվ_փետրվար փտր_մարտ մրտ_ապրիլ ապր_մայիս մյս_հունիս հնս_հուլիս հլս_օգոստոս օգս_սեպտեմբեր սպտ_հոկտեմբեր հկտ_նոյեմբեր նմբ_դեկտեմբեր դկտ'.split('_'), i;
14260 function equalTest(input, mmm, i) {
14261 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
14262 }
14263 for (i = 0; i < 12; i++) {
14264 tests[i] = tests[i].split(' ');
14265 equalTest(tests[i][0], 'MMM', i);
14266 equalTest(tests[i][1], 'MMM', i);
14267 equalTest(tests[i][0], 'MMMM', i);
14268 equalTest(tests[i][1], 'MMMM', i);
14269 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
14270 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
14271 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
14272 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
14273 }
14274 });
14275
14276 test('parse exceptional case', function (assert) {
14277 assert.equal(moment('11 մայիսի 1989', ['DD MMMM YYYY']).format('DD-MM-YYYY'), '11-05-1989');
14278 });
14279
14280 test('format', function (assert) {
14281 var a = [
14282 ['dddd, Do MMMM YYYY, HH:mm:ss', 'կիրակի, 14 փետրվարի 2010, 15:25:50'],
14283 ['ddd, h A', 'կրկ, 3 ցերեկվա'],
14284 ['M Mo MM MMMM MMM', '2 2 02 փետրվար փտր'],
14285 ['YYYY YY', '2010 10'],
14286 ['D Do DD', '14 14 14'],
14287 ['d do dddd ddd dd', '0 0 կիրակի կրկ կրկ'],
14288 ['DDD DDDo DDDD', '45 45-րդ 045'],
14289 ['w wo ww', '7 7-րդ 07'],
14290 ['h hh', '3 03'],
14291 ['H HH', '15 15'],
14292 ['m mm', '25 25'],
14293 ['s ss', '50 50'],
14294 ['a A', 'ցերեկվա ցերեկվա'],
14295 ['[տարվա] DDDo [օրը]', 'տարվա 45-րդ օրը'],
14296 ['LTS', '15:25:50'],
14297 ['L', '14.02.2010'],
14298 ['LL', '14 փետրվարի 2010 թ.'],
14299 ['LLL', '14 փետրվարի 2010 թ., 15:25'],
14300 ['LLLL', 'կիրակի, 14 փետրվարի 2010 թ., 15:25'],
14301 ['l', '14.2.2010'],
14302 ['ll', '14 փտր 2010 թ.'],
14303 ['lll', '14 փտր 2010 թ., 15:25'],
14304 ['llll', 'կրկ, 14 փտր 2010 թ., 15:25']
14305 ],
14306 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
14307 i;
14308 for (i = 0; i < a.length; i++) {
14309 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
14310 }
14311 });
14312
14313 test('format meridiem', function (assert) {
14314 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'գիշերվա', 'night');
14315 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'գիշերվա', 'night');
14316 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'առավոտվա', 'morning');
14317 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'առավոտվա', 'morning');
14318 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'ցերեկվա', 'afternoon');
14319 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'ցերեկվա', 'afternoon');
14320 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'երեկոյան', 'evening');
14321 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'երեկոյան', 'evening');
14322 });
14323
14324 test('format ordinal', function (assert) {
14325 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ին', '1-ին');
14326 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-րդ', '2-րդ');
14327 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-րդ', '3-րդ');
14328 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-րդ', '4-րդ');
14329 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-րդ', '5-րդ');
14330 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-րդ', '6-րդ');
14331 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-րդ', '7-րդ');
14332 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-րդ', '8-րդ');
14333 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-րդ', '9-րդ');
14334 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-րդ', '10-րդ');
14335
14336 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-րդ', '11-րդ');
14337 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-րդ', '12-րդ');
14338 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-րդ', '13-րդ');
14339 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-րդ', '14-րդ');
14340 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-րդ', '15-րդ');
14341 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-րդ', '16-րդ');
14342 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-րդ', '17-րդ');
14343 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-րդ', '18-րդ');
14344 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-րդ', '19-րդ');
14345 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-րդ', '20-րդ');
14346
14347 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-րդ', '21-րդ');
14348 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-րդ', '22-րդ');
14349 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-րդ', '23-րդ');
14350 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-րդ', '24-րդ');
14351 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-րդ', '25-րդ');
14352 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-րդ', '26-րդ');
14353 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-րդ', '27-րդ');
14354 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-րդ', '28-րդ');
14355 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-րդ', '29-րդ');
14356 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-րդ', '30-րդ');
14357
14358 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-րդ', '31-րդ');
14359 });
14360
14361 test('format month', function (assert) {
14362 var expected = 'հունվար հնվ_փետրվար փտր_մարտ մրտ_ապրիլ ապր_մայիս մյս_հունիս հնս_հուլիս հլս_օգոստոս օգս_սեպտեմբեր սպտ_հոկտեմբեր հկտ_նոյեմբեր նմբ_դեկտեմբեր դկտ'.split('_'), i;
14363 for (i = 0; i < expected.length; i++) {
14364 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
14365 }
14366 });
14367
14368 test('format month case', function (assert) {
14369 var months = {
14370 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
14371 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
14372 }, i;
14373 for (i = 0; i < 12; i++) {
14374 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
14375 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
14376 }
14377 });
14378
14379 test('format month short case', function (assert) {
14380 var monthsShort = {
14381 'nominative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'),
14382 'accusative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_')
14383 }, i;
14384 for (i = 0; i < 12; i++) {
14385 assert.equal(moment([2011, i, 1]).format('D MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
14386 assert.equal(moment([2011, i, 1]).format('MMM'), monthsShort.nominative[i], '1 ' + monthsShort.nominative[i]);
14387 }
14388 });
14389
14390 test('format month case with escaped symbols', function (assert) {
14391 var months = {
14392 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
14393 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
14394 }, i;
14395 for (i = 0; i < 12; i++) {
14396 assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
14397 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMMM[</b>]'), '<i>1</i> <b>' + months.accusative[i] + '</b>', '1 <b>' + months.accusative[i] + '</b>');
14398 assert.equal(moment([2013, i, 1]).format('D[-ին օրը] MMMM'), '1-ին օրը ' + months.accusative[i], '1-ին օրը ' + months.accusative[i]);
14399 assert.equal(moment([2013, i, 1]).format('D, MMMM'), '1, ' + months.nominative[i], '1, ' + months.nominative[i]);
14400 }
14401 });
14402
14403 test('format month short case with escaped symbols', function (assert) {
14404 var monthsShort = {
14405 'nominative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'),
14406 'accusative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_')
14407 }, i;
14408 for (i = 0; i < 12; i++) {
14409 assert.equal(moment([2013, i, 1]).format('D[] MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
14410 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMM[</b>]'), '<i>1</i> <b>' + monthsShort.accusative[i] + '</b>', '1 <b>' + monthsShort.accusative[i] + '</b>');
14411 assert.equal(moment([2013, i, 1]).format('D[-ին օրը] MMM'), '1-ին օրը ' + monthsShort.accusative[i], '1-ին օրը ' + monthsShort.accusative[i]);
14412 assert.equal(moment([2013, i, 1]).format('D, MMM'), '1, ' + monthsShort.nominative[i], '1, ' + monthsShort.nominative[i]);
14413 }
14414 });
14415
14416 test('format week', function (assert) {
14417 var expected = 'կիրակի կրկ կրկ_երկուշաբթի երկ երկ_երեքշաբթի երք երք_չորեքշաբթի չրք չրք_հինգշաբթի հնգ հնգ_ուրբաթ ուրբ ուրբ_շաբաթ շբթ շբթ'.split('_'), i;
14418 for (i = 0; i < expected.length; i++) {
14419 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
14420 }
14421 });
14422
14423 test('from', function (assert) {
14424 var start = moment([2007, 1, 28]);
14425 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'մի քանի վայրկյան', '44 seconds = seconds');
14426 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'րոպե', '45 seconds = a minute');
14427 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'րոպե', '89 seconds = a minute');
14428 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 րոպե', '90 seconds = 2 minutes');
14429 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 րոպե', '44 minutes = 44 minutes');
14430 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ժամ', '45 minutes = an hour');
14431 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ժամ', '89 minutes = an hour');
14432 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ժամ', '90 minutes = 2 hours');
14433 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ժամ', '5 hours = 5 hours');
14434 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ժամ', '21 hours = 21 hours');
14435 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'օր', '22 hours = a day');
14436 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'օր', '35 hours = a day');
14437 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 օր', '36 hours = 2 days');
14438 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'օր', '1 day = a day');
14439 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 օր', '5 days = 5 days');
14440 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 օր', '11 days = 11 days');
14441 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 օր', '21 days = 21 days');
14442 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 օր', '25 days = 25 days');
14443 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ամիս', '26 days = a month');
14444 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ամիս', '30 days = a month');
14445 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ամիս', '43 days = a month');
14446 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ամիս', '46 days = 2 months');
14447 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ամիս', '75 days = 2 months');
14448 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ամիս', '76 days = 3 months');
14449 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ամիս', '1 month = a month');
14450 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ամիս', '5 months = 5 months');
14451 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'տարի', '345 days = a year');
14452 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 տարի', '548 days = 2 years');
14453 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'տարի', '1 year = a year');
14454 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 տարի', '5 years = 5 years');
14455 });
14456
14457 test('suffix', function (assert) {
14458 assert.equal(moment(30000).from(0), 'մի քանի վայրկյան հետո', 'prefix');
14459 assert.equal(moment(0).from(30000), 'մի քանի վայրկյան առաջ', 'suffix');
14460 });
14461
14462 test('fromNow', function (assert) {
14463 assert.equal(moment().add({s: 30}).fromNow(), 'մի քանի վայրկյան հետո', 'in seconds');
14464 assert.equal(moment().add({d: 5}).fromNow(), '5 օր հետո', 'in 5 days');
14465 });
14466
14467 test('calendar day', function (assert) {
14468 var a = moment().hours(2).minutes(0).seconds(0);
14469
14470 assert.equal(moment(a).calendar(), 'այսօր 02:00', 'today at the same time');
14471 assert.equal(moment(a).add({m: 25}).calendar(), 'այսօր 02:25', 'Now plus 25 min');
14472 assert.equal(moment(a).add({h: 1}).calendar(), 'այսօր 03:00', 'Now plus 1 hour');
14473 assert.equal(moment(a).add({d: 1}).calendar(), 'վաղը 02:00', 'tomorrow at the same time');
14474 assert.equal(moment(a).subtract({h: 1}).calendar(), 'այսօր 01:00', 'Now minus 1 hour');
14475 assert.equal(moment(a).subtract({d: 1}).calendar(), 'երեկ 02:00', 'yesterday at the same time');
14476 });
14477
14478 test('calendar next week', function (assert) {
14479 var i, m;
14480 function makeFormat(d) {
14481 return 'dddd [օրը ժամը] LT';
14482 }
14483
14484 for (i = 2; i < 7; i++) {
14485 m = moment().add({d: i});
14486 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
14487 m.hours(0).minutes(0).seconds(0).milliseconds(0);
14488 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
14489 m.hours(23).minutes(59).seconds(59).milliseconds(999);
14490 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
14491 }
14492 });
14493
14494 test('calendar last week', function (assert) {
14495 var i, m;
14496
14497 function makeFormat(d) {
14498 return '[անցած] dddd [օրը ժամը] LT';
14499 }
14500
14501 for (i = 2; i < 7; i++) {
14502 m = moment().subtract({d: i});
14503 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
14504 m.hours(0).minutes(0).seconds(0).milliseconds(0);
14505 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
14506 m.hours(23).minutes(59).seconds(59).milliseconds(999);
14507 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
14508 }
14509 });
14510
14511 test('calendar all else', function (assert) {
14512 var weeksAgo = moment().subtract({w: 1}),
14513 weeksFromNow = moment().add({w: 1});
14514
14515 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
14516 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
14517
14518 weeksAgo = moment().subtract({w: 2});
14519 weeksFromNow = moment().add({w: 2});
14520
14521 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
14522 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
14523 });
14524
14525 test('weeks year starting sunday', function (assert) {
14526 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
14527 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
14528 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
14529 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
14530 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
14531 });
14532
14533 test('weeks year starting monday', function (assert) {
14534 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
14535 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
14536 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
14537 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
14538 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
14539 });
14540
14541 test('weeks year starting tuesday', function (assert) {
14542 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
14543 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
14544 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
14545 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
14546 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
14547 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
14548 });
14549
14550 test('weeks year starting wednesday', function (assert) {
14551 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
14552 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
14553 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
14554 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
14555 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
14556 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
14557 });
14558
14559 test('weeks year starting thursday', function (assert) {
14560 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
14561 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
14562 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
14563 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
14564 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
14565 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
14566 });
14567
14568 test('weeks year starting friday', function (assert) {
14569 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
14570 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
14571 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
14572 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
14573 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
14574 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
14575 });
14576
14577 test('weeks year starting saturday', function (assert) {
14578 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
14579 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
14580 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
14581 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
14582 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
14583 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
14584 });
14585
14586 test('weeks year starting sunday formatted', function (assert) {
14587 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ին', 'Dec 26 2011 should be week 1');
14588 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ին', 'Jan 1 2012 should be week 1');
14589 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-րդ', 'Jan 2 2012 should be week 2');
14590 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-րդ', 'Jan 8 2012 should be week 2');
14591 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-րդ', 'Jan 9 2012 should be week 3');
14592 });
14593
14594 test('lenient ordinal parsing', function (assert) {
14595 var i, ordinalStr, testMoment;
14596 for (i = 1; i <= 31; ++i) {
14597 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
14598 testMoment = moment(ordinalStr, 'YYYY MM Do');
14599 assert.equal(testMoment.year(), 2014,
14600 'lenient ordinal parsing ' + i + ' year check');
14601 assert.equal(testMoment.month(), 0,
14602 'lenient ordinal parsing ' + i + ' month check');
14603 assert.equal(testMoment.date(), i,
14604 'lenient ordinal parsing ' + i + ' date check');
14605 }
14606 });
14607
14608 test('lenient ordinal parsing of number', function (assert) {
14609 var i, testMoment;
14610 for (i = 1; i <= 31; ++i) {
14611 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
14612 assert.equal(testMoment.year(), 2014,
14613 'lenient ordinal parsing of number ' + i + ' year check');
14614 assert.equal(testMoment.month(), 0,
14615 'lenient ordinal parsing of number ' + i + ' month check');
14616 assert.equal(testMoment.date(), i,
14617 'lenient ordinal parsing of number ' + i + ' date check');
14618 }
14619 });
14620
14621 test('strict ordinal parsing', function (assert) {
14622 var i, ordinalStr, testMoment;
14623 for (i = 1; i <= 31; ++i) {
14624 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
14625 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
14626 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
14627 }
14628 });
14629
14630 }));
14631
14632 (function (global, factory) {
14633 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
14634 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
14635 factory(global.moment)
14636 }(this, function (moment) { 'use strict';
14637
14638 /*global QUnit:false*/
14639
14640 var test = QUnit.test;
14641
14642 function module (name, lifecycle) {
14643 QUnit.module(name, {
14644 setup : function () {
14645 moment.locale('en');
14646 moment.createFromInputFallback = function () {
14647 throw new Error('input not handled by moment');
14648 };
14649 if (lifecycle && lifecycle.setup) {
14650 lifecycle.setup();
14651 }
14652 },
14653 teardown : function () {
14654 if (lifecycle && lifecycle.teardown) {
14655 lifecycle.teardown();
14656 }
14657 }
14658 });
14659 }
14660
14661 function localeModule (name, lifecycle) {
14662 QUnit.module('locale:' + name, {
14663 setup : function () {
14664 moment.locale(name);
14665 moment.createFromInputFallback = function () {
14666 throw new Error('input not handled by moment');
14667 };
14668 if (lifecycle && lifecycle.setup) {
14669 lifecycle.setup();
14670 }
14671 },
14672 teardown : function () {
14673 moment.locale('en');
14674 if (lifecycle && lifecycle.teardown) {
14675 lifecycle.teardown();
14676 }
14677 }
14678 });
14679 }
14680
14681 localeModule('id');
14682
14683 test('parse', function (assert) {
14684 var tests = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
14685 function equalTest(input, mmm, i) {
14686 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
14687 }
14688 for (i = 0; i < 12; i++) {
14689 tests[i] = tests[i].split(' ');
14690 equalTest(tests[i][0], 'MMM', i);
14691 equalTest(tests[i][1], 'MMM', i);
14692 equalTest(tests[i][0], 'MMMM', i);
14693 equalTest(tests[i][1], 'MMMM', i);
14694 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
14695 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
14696 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
14697 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
14698 }
14699 });
14700
14701 test('format', function (assert) {
14702 var a = [
14703 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Minggu, Februari 14 2010, 3:25:50 sore'],
14704 ['ddd, hA', 'Min, 3sore'],
14705 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
14706 ['YYYY YY', '2010 10'],
14707 ['D Do DD', '14 14 14'],
14708 ['d do dddd ddd dd', '0 0 Minggu Min Mg'],
14709 ['DDD DDDo DDDD', '45 45 045'],
14710 ['w wo ww', '7 7 07'],
14711 ['h hh', '3 03'],
14712 ['H HH', '15 15'],
14713 ['m mm', '25 25'],
14714 ['s ss', '50 50'],
14715 ['a A', 'sore sore'],
14716 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
14717 ['LTS', '15.25.50'],
14718 ['L', '14/02/2010'],
14719 ['LL', '14 Februari 2010'],
14720 ['LLL', '14 Februari 2010 pukul 15.25'],
14721 ['LLLL', 'Minggu, 14 Februari 2010 pukul 15.25'],
14722 ['l', '14/2/2010'],
14723 ['ll', '14 Feb 2010'],
14724 ['lll', '14 Feb 2010 pukul 15.25'],
14725 ['llll', 'Min, 14 Feb 2010 pukul 15.25']
14726 ],
14727 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
14728 i;
14729 for (i = 0; i < a.length; i++) {
14730 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
14731 }
14732 });
14733
14734 test('format month', function (assert) {
14735 var expected = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
14736 for (i = 0; i < expected.length; i++) {
14737 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
14738 }
14739 });
14740
14741 test('format week', function (assert) {
14742 var expected = 'Minggu Min Mg_Senin Sen Sn_Selasa Sel Sl_Rabu Rab Rb_Kamis Kam Km_Jumat Jum Jm_Sabtu Sab Sb'.split('_'), i;
14743 for (i = 0; i < expected.length; i++) {
14744 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
14745 }
14746 });
14747
14748 test('from', function (assert) {
14749 var start = moment([2007, 1, 28]);
14750 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'beberapa detik', '44 seconds = a few seconds');
14751 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'semenit', '45 seconds = a minute');
14752 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'semenit', '89 seconds = a minute');
14753 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 menit', '90 seconds = 2 minutes');
14754 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 menit', '44 minutes = 44 minutes');
14755 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'sejam', '45 minutes = an hour');
14756 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'sejam', '89 minutes = an hour');
14757 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minutes = 2 hours');
14758 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 hours = 5 hours');
14759 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 hours = 21 hours');
14760 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sehari', '22 hours = a day');
14761 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sehari', '35 hours = a day');
14762 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 hari', '36 hours = 2 days');
14763 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sehari', '1 day = a day');
14764 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 hari', '5 days = 5 days');
14765 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 hari', '25 days = 25 days');
14766 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sebulan', '26 days = a month');
14767 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sebulan', '30 days = a month');
14768 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sebulan', '43 days = a month');
14769 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 bulan', '46 days = 2 months');
14770 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 bulan', '75 days = 2 months');
14771 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 bulan', '76 days = 3 months');
14772 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sebulan', '1 month = a month');
14773 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 bulan', '5 months = 5 months');
14774 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setahun', '345 days = a year');
14775 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 tahun', '548 days = 2 years');
14776 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setahun', '1 year = a year');
14777 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 tahun', '5 years = 5 years');
14778 });
14779
14780 test('suffix', function (assert) {
14781 assert.equal(moment(30000).from(0), 'dalam beberapa detik', 'prefix');
14782 assert.equal(moment(0).from(30000), 'beberapa detik yang lalu', 'suffix');
14783 });
14784
14785 test('now from now', function (assert) {
14786 assert.equal(moment().fromNow(), 'beberapa detik yang lalu', 'now from now should display as in the past');
14787 });
14788
14789 test('fromNow', function (assert) {
14790 assert.equal(moment().add({s: 30}).fromNow(), 'dalam beberapa detik', 'in a few seconds');
14791 assert.equal(moment().add({d: 5}).fromNow(), 'dalam 5 hari', 'in 5 days');
14792 });
14793
14794 test('calendar day', function (assert) {
14795 var a = moment().hours(2).minutes(0).seconds(0);
14796
14797 assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'today at the same time');
14798 assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Now plus 25 min');
14799 assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Now plus 1 hour');
14800 assert.equal(moment(a).add({d: 1}).calendar(), 'Besok pukul 02.00', 'tomorrow at the same time');
14801 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Now minus 1 hour');
14802 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kemarin pukul 02.00', 'yesterday at the same time');
14803 });
14804
14805 test('calendar next week', function (assert) {
14806 var i, m;
14807 for (i = 2; i < 7; i++) {
14808 m = moment().add({d: i});
14809 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days current time');
14810 m.hours(0).minutes(0).seconds(0).milliseconds(0);
14811 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days beginning of day');
14812 m.hours(23).minutes(59).seconds(59).milliseconds(999);
14813 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days end of day');
14814 }
14815 });
14816
14817 test('calendar last week', function (assert) {
14818 var i, m;
14819 for (i = 2; i < 7; i++) {
14820 m = moment().subtract({d: i});
14821 assert.equal(m.calendar(), m.format('dddd [lalu pukul] LT'), 'Today - ' + i + ' days current time');
14822 m.hours(0).minutes(0).seconds(0).milliseconds(0);
14823 assert.equal(m.calendar(), m.format('dddd [lalu pukul] LT'), 'Today - ' + i + ' days beginning of day');
14824 m.hours(23).minutes(59).seconds(59).milliseconds(999);
14825 assert.equal(m.calendar(), m.format('dddd [lalu pukul] LT'), 'Today - ' + i + ' days end of day');
14826 }
14827 });
14828
14829 test('calendar all else', function (assert) {
14830 var weeksAgo = moment().subtract({w: 1}),
14831 weeksFromNow = moment().add({w: 1});
14832
14833 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
14834 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
14835
14836 weeksAgo = moment().subtract({w: 2});
14837 weeksFromNow = moment().add({w: 2});
14838
14839 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
14840 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
14841 });
14842
14843 test('weeks year starting sunday', function (assert) {
14844 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
14845 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
14846 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
14847 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
14848 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
14849 });
14850
14851 test('weeks year starting monday', function (assert) {
14852 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
14853 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
14854 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
14855 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
14856 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
14857 });
14858
14859 test('weeks year starting tuesday', function (assert) {
14860 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
14861 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
14862 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
14863 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
14864 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
14865 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
14866 });
14867
14868 test('weeks year starting wednesday', function (assert) {
14869 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
14870 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
14871 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
14872 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
14873 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
14874 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
14875 });
14876
14877 test('weeks year starting thursday', function (assert) {
14878 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
14879 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
14880 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
14881 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
14882 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
14883 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
14884 });
14885
14886 test('weeks year starting friday', function (assert) {
14887 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
14888 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
14889 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
14890 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
14891 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
14892 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
14893 });
14894
14895 test('weeks year starting saturday', function (assert) {
14896 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
14897 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
14898 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
14899 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
14900 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
14901 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
14902 });
14903
14904 test('weeks year starting sunday formatted', function (assert) {
14905 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
14906 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
14907 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 2');
14908 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
14909 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
14910 });
14911
14912 test('lenient ordinal parsing', function (assert) {
14913 var i, ordinalStr, testMoment;
14914 for (i = 1; i <= 31; ++i) {
14915 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
14916 testMoment = moment(ordinalStr, 'YYYY MM Do');
14917 assert.equal(testMoment.year(), 2014,
14918 'lenient ordinal parsing ' + i + ' year check');
14919 assert.equal(testMoment.month(), 0,
14920 'lenient ordinal parsing ' + i + ' month check');
14921 assert.equal(testMoment.date(), i,
14922 'lenient ordinal parsing ' + i + ' date check');
14923 }
14924 });
14925
14926 test('lenient ordinal parsing of number', function (assert) {
14927 var i, testMoment;
14928 for (i = 1; i <= 31; ++i) {
14929 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
14930 assert.equal(testMoment.year(), 2014,
14931 'lenient ordinal parsing of number ' + i + ' year check');
14932 assert.equal(testMoment.month(), 0,
14933 'lenient ordinal parsing of number ' + i + ' month check');
14934 assert.equal(testMoment.date(), i,
14935 'lenient ordinal parsing of number ' + i + ' date check');
14936 }
14937 });
14938
14939 test('meridiem invariant', function (assert) {
14940 var h, m, t1, t2;
14941 for (h = 0; h < 24; ++h) {
14942 for (m = 0; m < 60; m += 15) {
14943 t1 = moment.utc([2000, 0, 1, h, m]);
14944 t2 = moment(t1.format('A h:mm'), 'A h:mm');
14945 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
14946 'meridiem at ' + t1.format('HH:mm'));
14947 }
14948 }
14949 });
14950
14951 test('strict ordinal parsing', function (assert) {
14952 var i, ordinalStr, testMoment;
14953 for (i = 1; i <= 31; ++i) {
14954 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
14955 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
14956 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
14957 }
14958 });
14959
14960 }));
14961
14962 (function (global, factory) {
14963 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
14964 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
14965 factory(global.moment)
14966 }(this, function (moment) { 'use strict';
14967
14968 /*global QUnit:false*/
14969
14970 var test = QUnit.test;
14971
14972 function module (name, lifecycle) {
14973 QUnit.module(name, {
14974 setup : function () {
14975 moment.locale('en');
14976 moment.createFromInputFallback = function () {
14977 throw new Error('input not handled by moment');
14978 };
14979 if (lifecycle && lifecycle.setup) {
14980 lifecycle.setup();
14981 }
14982 },
14983 teardown : function () {
14984 if (lifecycle && lifecycle.teardown) {
14985 lifecycle.teardown();
14986 }
14987 }
14988 });
14989 }
14990
14991 function localeModule (name, lifecycle) {
14992 QUnit.module('locale:' + name, {
14993 setup : function () {
14994 moment.locale(name);
14995 moment.createFromInputFallback = function () {
14996 throw new Error('input not handled by moment');
14997 };
14998 if (lifecycle && lifecycle.setup) {
14999 lifecycle.setup();
15000 }
15001 },
15002 teardown : function () {
15003 moment.locale('en');
15004 if (lifecycle && lifecycle.teardown) {
15005 lifecycle.teardown();
15006 }
15007 }
15008 });
15009 }
15010
15011 localeModule('is');
15012
15013 test('parse', function (assert) {
15014 var tests = 'janúar jan_febrúar feb_mars mar_apríl apr_maí maí_júní jún_júlí júl_ágúst ágú_september sep_október okt_nóvember nóv_desember des'.split('_'), i;
15015 function equalTest(input, mmm, i) {
15016 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
15017 }
15018 for (i = 0; i < 12; i++) {
15019 tests[i] = tests[i].split(' ');
15020 equalTest(tests[i][0], 'MMM', i);
15021 equalTest(tests[i][1], 'MMM', i);
15022 equalTest(tests[i][0], 'MMMM', i);
15023 equalTest(tests[i][1], 'MMMM', i);
15024 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
15025 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
15026 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
15027 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
15028 }
15029 });
15030
15031 test('format', function (assert) {
15032 var a = [
15033 ['dddd, Do MMMM YYYY, h:mm:ss a', 'sunnudagur, 14. febrúar 2010, 3:25:50 pm'],
15034 ['ddd, hA', 'sun, 3PM'],
15035 ['M Mo MM MMMM MMM', '2 2. 02 febrúar feb'],
15036 ['YYYY YY', '2010 10'],
15037 ['D Do DD', '14 14. 14'],
15038 ['d do dddd ddd dd', '0 0. sunnudagur sun Su'],
15039 ['DDD DDDo DDDD', '45 45. 045'],
15040 ['w wo ww', '6 6. 06'],
15041 ['h hh', '3 03'],
15042 ['H HH', '15 15'],
15043 ['m mm', '25 25'],
15044 ['s ss', '50 50'],
15045 ['a A', 'pm PM'],
15046 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
15047 ['LTS', '15:25:50'],
15048 ['L', '14/02/2010'],
15049 ['LL', '14. febrúar 2010'],
15050 ['LLL', '14. febrúar 2010 kl. 15:25'],
15051 ['LLLL', 'sunnudagur, 14. febrúar 2010 kl. 15:25'],
15052 ['l', '14/2/2010'],
15053 ['ll', '14. feb 2010'],
15054 ['lll', '14. feb 2010 kl. 15:25'],
15055 ['llll', 'sun, 14. feb 2010 kl. 15:25']
15056 ],
15057 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
15058 i;
15059 for (i = 0; i < a.length; i++) {
15060 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
15061 }
15062 });
15063
15064 test('format ordinal', function (assert) {
15065 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
15066 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
15067 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
15068 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
15069 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
15070 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
15071 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
15072 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
15073 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
15074 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
15075
15076 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
15077 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
15078 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
15079 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
15080 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
15081 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
15082 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
15083 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
15084 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
15085 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
15086
15087 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
15088 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
15089 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
15090 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
15091 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
15092 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
15093 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
15094 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
15095 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
15096 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
15097
15098 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
15099 });
15100
15101 test('format month', function (assert) {
15102 var expected = 'janúar jan_febrúar feb_mars mar_apríl apr_maí maí_júní jún_júlí júl_ágúst ágú_september sep_október okt_nóvember nóv_desember des'.split('_'), i;
15103 for (i = 0; i < expected.length; i++) {
15104 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
15105 }
15106 });
15107
15108 test('format week', function (assert) {
15109 var expected = 'sunnudagur sun Su_mánudagur mán Má_þriðjudagur þri Þr_miðvikudagur mið Mi_fimmtudagur fim Fi_föstudagur fös Fö_laugardagur lau La'.split('_'), i;
15110 for (i = 0; i < expected.length; i++) {
15111 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
15112 }
15113 });
15114
15115 test('from', function (assert) {
15116 var start = moment([2007, 1, 28]);
15117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nokkrar sekúndur', '44 seconds = a few seconds');
15118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'mínúta', '45 seconds = a minute');
15119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'mínúta', '89 seconds = a minute');
15120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 mínútur', '90 seconds = 2 minutes');
15121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 mínútur', '44 minutes = 44 minutes');
15122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 21}), true), '21 mínúta', '21 minutes = 21 minutes');
15123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'klukkustund', '45 minutes = an hour');
15124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'klukkustund', '89 minutes = an hour');
15125 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 klukkustundir', '90 minutes = 2 hours');
15126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 klukkustundir', '5 hours = 5 hours');
15127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 klukkustund', '21 hours = 21 hours');
15128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dagur', '22 hours = a day');
15129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dagur', '35 hours = a day');
15130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
15131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dagur', '1 day = a day');
15132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
15133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
15134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 dagar', '11 days = 11 days');
15135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 dagur', '21 days = 21 days');
15136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mánuður', '26 days = a month');
15137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mánuður', '30 days = a month');
15138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mánuður', '43 days = a month');
15139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mánuðir', '46 days = 2 months');
15140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mánuðir', '75 days = 2 months');
15141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mánuðir', '76 days = 3 months');
15142 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mánuður', '1 month = a month');
15143 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mánuðir', '5 months = 5 months');
15144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ár', '345 days = a year');
15145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ár', '548 days = 2 years');
15146 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ár', '1 year = a year');
15147 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ár', '5 years = 5 years');
15148 assert.equal(start.from(moment([2007, 1, 28]).add({y: 21}), true), '21 ár', '21 years = 21 years');
15149 });
15150
15151 test('suffix', function (assert) {
15152 assert.equal(moment(30000).from(0), 'eftir nokkrar sekúndur', 'prefix');
15153 assert.equal(moment(0).from(30000), 'fyrir nokkrum sekúndum síðan', 'suffix');
15154 assert.equal(moment().subtract({m: 1}).fromNow(), 'fyrir mínútu síðan', 'a minute ago');
15155 });
15156
15157 test('now from now', function (assert) {
15158 assert.equal(moment().fromNow(), 'fyrir nokkrum sekúndum síðan', 'now from now should display as in the past');
15159 });
15160
15161 test('fromNow', function (assert) {
15162 assert.equal(moment().add({s: 30}).fromNow(), 'eftir nokkrar sekúndur', 'in a few seconds');
15163 assert.equal(moment().add({m: 1}).fromNow(), 'eftir mínútu', 'in a minute');
15164 assert.equal(moment().add({d: 5}).fromNow(), 'eftir 5 daga', 'in 5 days');
15165 });
15166
15167 test('calendar day', function (assert) {
15168 var a = moment().hours(2).minutes(0).seconds(0);
15169
15170 assert.equal(moment(a).calendar(), 'í dag kl. 2:00', 'today at the same time');
15171 assert.equal(moment(a).add({m: 25}).calendar(), 'í dag kl. 2:25', 'Now plus 25 min');
15172 assert.equal(moment(a).add({h: 1}).calendar(), 'í dag kl. 3:00', 'Now plus 1 hour');
15173 assert.equal(moment(a).add({d: 1}).calendar(), 'á morgun kl. 2:00', 'tomorrow at the same time');
15174 assert.equal(moment(a).subtract({h: 1}).calendar(), 'í dag kl. 1:00', 'Now minus 1 hour');
15175 assert.equal(moment(a).subtract({d: 1}).calendar(), 'í gær kl. 2:00', 'yesterday at the same time');
15176 });
15177
15178 test('calendar next week', function (assert) {
15179 var i, m;
15180 for (i = 2; i < 7; i++) {
15181 m = moment().add({d: i});
15182 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days current time');
15183 m.hours(0).minutes(0).seconds(0).milliseconds(0);
15184 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days beginning of day');
15185 m.hours(23).minutes(59).seconds(59).milliseconds(999);
15186 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days end of day');
15187 }
15188 });
15189
15190 test('calendar last week', function (assert) {
15191 var i, m;
15192
15193 for (i = 2; i < 7; i++) {
15194 m = moment().subtract({d: i});
15195 assert.equal(m.calendar(), m.format('[síðasta] dddd [kl.] LT'), 'Today - ' + i + ' days current time');
15196 m.hours(0).minutes(0).seconds(0).milliseconds(0);
15197 assert.equal(m.calendar(), m.format('[síðasta] dddd [kl.] LT'), 'Today - ' + i + ' days beginning of day');
15198 m.hours(23).minutes(59).seconds(59).milliseconds(999);
15199 assert.equal(m.calendar(), m.format('[síðasta] dddd [kl.] LT'), 'Today - ' + i + ' days end of day');
15200 }
15201 });
15202
15203 test('calendar all else', function (assert) {
15204 var weeksAgo = moment().subtract({w: 1}),
15205 weeksFromNow = moment().add({w: 1});
15206
15207 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
15208 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
15209
15210 weeksAgo = moment().subtract({w: 2});
15211 weeksFromNow = moment().add({w: 2});
15212
15213 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
15214 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
15215 });
15216
15217 test('weeks year starting sunday', function (assert) {
15218 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
15219 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
15220 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
15221 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
15222 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
15223 });
15224
15225 test('weeks year starting monday', function (assert) {
15226 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
15227 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
15228 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
15229 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
15230 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
15231 });
15232
15233 test('weeks year starting tuesday', function (assert) {
15234 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
15235 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
15236 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
15237 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
15238 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
15239 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
15240 });
15241
15242 test('weeks year starting wednesday', function (assert) {
15243 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
15244 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
15245 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
15246 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
15247 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
15248 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
15249 });
15250
15251 test('weeks year starting thursday', function (assert) {
15252 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
15253 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
15254 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
15255 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
15256 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
15257 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
15258 });
15259
15260 test('weeks year starting friday', function (assert) {
15261 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
15262 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
15263 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
15264 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
15265 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
15266 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
15267 });
15268
15269 test('weeks year starting saturday', function (assert) {
15270 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
15271 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
15272 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
15273 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
15274 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
15275 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
15276 });
15277
15278 test('weeks year starting sunday formatted', function (assert) {
15279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
15280 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
15281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
15282 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
15283 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
15284 });
15285
15286 test('lenient ordinal parsing', function (assert) {
15287 var i, ordinalStr, testMoment;
15288 for (i = 1; i <= 31; ++i) {
15289 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
15290 testMoment = moment(ordinalStr, 'YYYY MM Do');
15291 assert.equal(testMoment.year(), 2014,
15292 'lenient ordinal parsing ' + i + ' year check');
15293 assert.equal(testMoment.month(), 0,
15294 'lenient ordinal parsing ' + i + ' month check');
15295 assert.equal(testMoment.date(), i,
15296 'lenient ordinal parsing ' + i + ' date check');
15297 }
15298 });
15299
15300 test('lenient ordinal parsing of number', function (assert) {
15301 var i, testMoment;
15302 for (i = 1; i <= 31; ++i) {
15303 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
15304 assert.equal(testMoment.year(), 2014,
15305 'lenient ordinal parsing of number ' + i + ' year check');
15306 assert.equal(testMoment.month(), 0,
15307 'lenient ordinal parsing of number ' + i + ' month check');
15308 assert.equal(testMoment.date(), i,
15309 'lenient ordinal parsing of number ' + i + ' date check');
15310 }
15311 });
15312
15313 test('strict ordinal parsing', function (assert) {
15314 var i, ordinalStr, testMoment;
15315 for (i = 1; i <= 31; ++i) {
15316 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
15317 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
15318 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
15319 }
15320 });
15321
15322 }));
15323
15324 (function (global, factory) {
15325 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
15326 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
15327 factory(global.moment)
15328 }(this, function (moment) { 'use strict';
15329
15330 /*global QUnit:false*/
15331
15332 var test = QUnit.test;
15333
15334 function module (name, lifecycle) {
15335 QUnit.module(name, {
15336 setup : function () {
15337 moment.locale('en');
15338 moment.createFromInputFallback = function () {
15339 throw new Error('input not handled by moment');
15340 };
15341 if (lifecycle && lifecycle.setup) {
15342 lifecycle.setup();
15343 }
15344 },
15345 teardown : function () {
15346 if (lifecycle && lifecycle.teardown) {
15347 lifecycle.teardown();
15348 }
15349 }
15350 });
15351 }
15352
15353 function localeModule (name, lifecycle) {
15354 QUnit.module('locale:' + name, {
15355 setup : function () {
15356 moment.locale(name);
15357 moment.createFromInputFallback = function () {
15358 throw new Error('input not handled by moment');
15359 };
15360 if (lifecycle && lifecycle.setup) {
15361 lifecycle.setup();
15362 }
15363 },
15364 teardown : function () {
15365 moment.locale('en');
15366 if (lifecycle && lifecycle.teardown) {
15367 lifecycle.teardown();
15368 }
15369 }
15370 });
15371 }
15372
15373 localeModule('it');
15374
15375 test('parse', function (assert) {
15376 var tests = 'gennaio gen_febbraio feb_marzo mar_aprile apr_maggio mag_giugno giu_luglio lug_agosto ago_settembre set_ottobre ott_novembre nov_dicembre dic'.split('_'), i;
15377 function equalTest(input, mmm, i) {
15378 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
15379 }
15380 for (i = 0; i < 12; i++) {
15381 tests[i] = tests[i].split(' ');
15382 equalTest(tests[i][0], 'MMM', i);
15383 equalTest(tests[i][1], 'MMM', i);
15384 equalTest(tests[i][0], 'MMMM', i);
15385 equalTest(tests[i][1], 'MMMM', i);
15386 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
15387 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
15388 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
15389 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
15390 }
15391 });
15392
15393 test('format', function (assert) {
15394 var a = [
15395 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domenica, febbraio 14º 2010, 3:25:50 pm'],
15396 ['ddd, hA', 'Dom, 3PM'],
15397 ['M Mo MM MMMM MMM', '2 2º 02 febbraio feb'],
15398 ['YYYY YY', '2010 10'],
15399 ['D Do DD', '14 14º 14'],
15400 ['d do dddd ddd dd', '0 0º Domenica Dom D'],
15401 ['DDD DDDo DDDD', '45 45º 045'],
15402 ['w wo ww', '6 6º 06'],
15403 ['h hh', '3 03'],
15404 ['H HH', '15 15'],
15405 ['m mm', '25 25'],
15406 ['s ss', '50 50'],
15407 ['a A', 'pm PM'],
15408 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
15409 ['LTS', '15:25:50'],
15410 ['L', '14/02/2010'],
15411 ['LL', '14 febbraio 2010'],
15412 ['LLL', '14 febbraio 2010 15:25'],
15413 ['LLLL', 'Domenica, 14 febbraio 2010 15:25'],
15414 ['l', '14/2/2010'],
15415 ['ll', '14 feb 2010'],
15416 ['lll', '14 feb 2010 15:25'],
15417 ['llll', 'Dom, 14 feb 2010 15:25']
15418 ],
15419 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
15420 i;
15421 for (i = 0; i < a.length; i++) {
15422 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
15423 }
15424 });
15425
15426 test('format ordinal', function (assert) {
15427 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
15428 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
15429 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
15430 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
15431 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
15432 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
15433 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
15434 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
15435 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
15436 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
15437
15438 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
15439 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
15440 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
15441 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
15442 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
15443 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
15444 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
15445 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
15446 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
15447 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
15448
15449 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
15450 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
15451 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
15452 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
15453 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
15454 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
15455 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
15456 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
15457 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
15458 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
15459
15460 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
15461 });
15462
15463 test('format month', function (assert) {
15464 var expected = 'gennaio gen_febbraio feb_marzo mar_aprile apr_maggio mag_giugno giu_luglio lug_agosto ago_settembre set_ottobre ott_novembre nov_dicembre dic'.split('_'), i;
15465 for (i = 0; i < expected.length; i++) {
15466 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
15467 }
15468 });
15469
15470 test('format week', function (assert) {
15471 var expected = 'Domenica Dom D_Lunedì Lun L_Martedì Mar Ma_Mercoledì Mer Me_Giovedì Gio G_Venerdì Ven V_Sabato Sab S'.split('_'), i;
15472 for (i = 0; i < expected.length; i++) {
15473 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
15474 }
15475 });
15476
15477 test('from', function (assert) {
15478 var start = moment([2007, 1, 28]);
15479 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'alcuni secondi', '44 seconds = seconds');
15480 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minuto', '45 seconds = a minute');
15481 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minuto', '89 seconds = a minute');
15482 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuti', '90 seconds = 2 minutes');
15483 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuti', '44 minutes = 44 minutes');
15484 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'un\'ora', '45 minutes = an hour');
15485 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'un\'ora', '89 minutes = an hour');
15486 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ore', '90 minutes = 2 hours');
15487 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ore', '5 hours = 5 hours');
15488 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ore', '21 hours = 21 hours');
15489 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un giorno', '22 hours = a day');
15490 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un giorno', '35 hours = a day');
15491 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 giorni', '36 hours = 2 days');
15492 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un giorno', '1 day = a day');
15493 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 giorni', '5 days = 5 days');
15494 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 giorni', '25 days = 25 days');
15495 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mese', '26 days = a month');
15496 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mese', '30 days = a month');
15497 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mese', '43 days = a month');
15498 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesi', '46 days = 2 months');
15499 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesi', '75 days = 2 months');
15500 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesi', '76 days = 3 months');
15501 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mese', '1 month = a month');
15502 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesi', '5 months = 5 months');
15503 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un anno', '345 days = a year');
15504 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anni', '548 days = 2 years');
15505 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un anno', '1 year = a year');
15506 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anni', '5 years = 5 years');
15507 });
15508
15509 test('suffix', function (assert) {
15510 assert.equal(moment(30000).from(0), 'in alcuni secondi', 'prefix');
15511 assert.equal(moment(0).from(30000), 'alcuni secondi fa', 'suffix');
15512 });
15513
15514 test('fromNow', function (assert) {
15515 assert.equal(moment().add({s: 30}).fromNow(), 'in alcuni secondi', 'in seconds');
15516 assert.equal(moment().add({d: 5}).fromNow(), 'tra 5 giorni', 'in 5 days');
15517 });
15518
15519 test('calendar day', function (assert) {
15520 var a = moment().hours(2).minutes(0).seconds(0);
15521
15522 assert.equal(moment(a).calendar(), 'Oggi alle 02:00', 'today at the same time');
15523 assert.equal(moment(a).add({m: 25}).calendar(), 'Oggi alle 02:25', 'Now plus 25 min');
15524 assert.equal(moment(a).add({h: 1}).calendar(), 'Oggi alle 03:00', 'Now plus 1 hour');
15525 assert.equal(moment(a).add({d: 1}).calendar(), 'Domani alle 02:00', 'tomorrow at the same time');
15526 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Oggi alle 01:00', 'Now minus 1 hour');
15527 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ieri alle 02:00', 'yesterday at the same time');
15528 });
15529
15530 test('calendar next week', function (assert) {
15531 var i, m;
15532 for (i = 2; i < 7; i++) {
15533 m = moment().add({d: i});
15534 assert.equal(m.calendar(), m.format('dddd [alle] LT'), 'Today + ' + i + ' days current time');
15535 m.hours(0).minutes(0).seconds(0).milliseconds(0);
15536 assert.equal(m.calendar(), m.format('dddd [alle] LT'), 'Today + ' + i + ' days beginning of day');
15537 m.hours(23).minutes(59).seconds(59).milliseconds(999);
15538 assert.equal(m.calendar(), m.format('dddd [alle] LT'), 'Today + ' + i + ' days end of day');
15539 }
15540 });
15541
15542 test('calendar last week', function (assert) {
15543 var i, m, weekday, datestring;
15544 for (i = 2; i < 7; i++) {
15545 m = moment().subtract({d: i});
15546 // Different date string
15547 weekday = parseInt(m.format('d'), 10);
15548 datestring = (weekday === 0) ? '[la scorsa] dddd [alle] LT' : '[lo scorso] dddd [alle] LT';
15549 assert.equal(m.calendar(), m.format(datestring), 'Today - ' + i + ' days current time');
15550 m.hours(0).minutes(0).seconds(0).milliseconds(0);
15551 assert.equal(m.calendar(), m.format(datestring), 'Today - ' + i + ' days beginning of day');
15552 m.hours(23).minutes(59).seconds(59).milliseconds(999);
15553 assert.equal(m.calendar(), m.format(datestring), 'Today - ' + i + ' days end of day');
15554 }
15555 });
15556
15557 test('calendar all else', function (assert) {
15558 var weeksAgo = moment().subtract({w: 1}),
15559 weeksFromNow = moment().add({w: 1});
15560
15561 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
15562 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
15563
15564 weeksAgo = moment().subtract({w: 2});
15565 weeksFromNow = moment().add({w: 2});
15566
15567 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
15568 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
15569 });
15570
15571 test('weeks year starting sunday', function (assert) {
15572 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
15573 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
15574 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
15575 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
15576 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
15577 });
15578
15579 test('weeks year starting monday', function (assert) {
15580 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
15581 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
15582 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
15583 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
15584 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
15585 });
15586
15587 test('weeks year starting tuesday', function (assert) {
15588 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
15589 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
15590 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
15591 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
15592 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
15593 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
15594 });
15595
15596 test('weeks year starting wednesday', function (assert) {
15597 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
15598 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
15599 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
15600 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
15601 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
15602 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
15603 });
15604
15605 test('weeks year starting thursday', function (assert) {
15606 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
15607 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
15608 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
15609 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
15610 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
15611 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
15612 });
15613
15614 test('weeks year starting friday', function (assert) {
15615 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
15616 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
15617 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
15618 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
15619 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
15620 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
15621 });
15622
15623 test('weeks year starting saturday', function (assert) {
15624 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
15625 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
15626 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
15627 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
15628 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
15629 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
15630 });
15631
15632 test('weeks year starting sunday formatted', function (assert) {
15633 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
15634 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
15635 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', 'Jan 8 2012 should be week 1');
15636 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2');
15637 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
15638 });
15639
15640 test('lenient ordinal parsing', function (assert) {
15641 var i, ordinalStr, testMoment;
15642 for (i = 1; i <= 31; ++i) {
15643 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
15644 testMoment = moment(ordinalStr, 'YYYY MM Do');
15645 assert.equal(testMoment.year(), 2014,
15646 'lenient ordinal parsing ' + i + ' year check');
15647 assert.equal(testMoment.month(), 0,
15648 'lenient ordinal parsing ' + i + ' month check');
15649 assert.equal(testMoment.date(), i,
15650 'lenient ordinal parsing ' + i + ' date check');
15651 }
15652 });
15653
15654 test('lenient ordinal parsing of number', function (assert) {
15655 var i, testMoment;
15656 for (i = 1; i <= 31; ++i) {
15657 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
15658 assert.equal(testMoment.year(), 2014,
15659 'lenient ordinal parsing of number ' + i + ' year check');
15660 assert.equal(testMoment.month(), 0,
15661 'lenient ordinal parsing of number ' + i + ' month check');
15662 assert.equal(testMoment.date(), i,
15663 'lenient ordinal parsing of number ' + i + ' date check');
15664 }
15665 });
15666
15667 test('strict ordinal parsing', function (assert) {
15668 var i, ordinalStr, testMoment;
15669 for (i = 1; i <= 31; ++i) {
15670 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
15671 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
15672 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
15673 }
15674 });
15675
15676 }));
15677
15678 (function (global, factory) {
15679 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
15680 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
15681 factory(global.moment)
15682 }(this, function (moment) { 'use strict';
15683
15684 /*global QUnit:false*/
15685
15686 var test = QUnit.test;
15687
15688 function module (name, lifecycle) {
15689 QUnit.module(name, {
15690 setup : function () {
15691 moment.locale('en');
15692 moment.createFromInputFallback = function () {
15693 throw new Error('input not handled by moment');
15694 };
15695 if (lifecycle && lifecycle.setup) {
15696 lifecycle.setup();
15697 }
15698 },
15699 teardown : function () {
15700 if (lifecycle && lifecycle.teardown) {
15701 lifecycle.teardown();
15702 }
15703 }
15704 });
15705 }
15706
15707 function localeModule (name, lifecycle) {
15708 QUnit.module('locale:' + name, {
15709 setup : function () {
15710 moment.locale(name);
15711 moment.createFromInputFallback = function () {
15712 throw new Error('input not handled by moment');
15713 };
15714 if (lifecycle && lifecycle.setup) {
15715 lifecycle.setup();
15716 }
15717 },
15718 teardown : function () {
15719 moment.locale('en');
15720 if (lifecycle && lifecycle.teardown) {
15721 lifecycle.teardown();
15722 }
15723 }
15724 });
15725 }
15726
15727 localeModule('ja');
15728
15729 test('parse', function (assert) {
15730 var tests = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split('_'), i;
15731 function equalTest(input, mmm, i) {
15732 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
15733 }
15734 for (i = 0; i < 12; i++) {
15735 tests[i] = tests[i].split(' ');
15736 equalTest(tests[i][0], 'MMM', i);
15737 equalTest(tests[i][1], 'MMM', i);
15738 equalTest(tests[i][0], 'MMMM', i);
15739 equalTest(tests[i][1], 'MMMM', i);
15740 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
15741 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
15742 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
15743 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
15744 }
15745 });
15746
15747 test('format', function (assert) {
15748 var a = [
15749 ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14 2010, 午後 3:25:50'],
15750 ['ddd, Ah', '日, 午後3'],
15751 ['M Mo MM MMMM MMM', '2 2 02 2月 2月'],
15752 ['YYYY YY', '2010 10'],
15753 ['D Do DD', '14 14 14'],
15754 ['d do dddd ddd dd', '0 0 日曜日 日 日'],
15755 ['DDD DDDo DDDD', '45 45 045'],
15756 ['w wo ww', '8 8 08'],
15757 ['h hh', '3 03'],
15758 ['H HH', '15 15'],
15759 ['m mm', '25 25'],
15760 ['s ss', '50 50'],
15761 ['a A', '午後 午後'],
15762 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
15763 ['LTS', '午後3時25分50秒'],
15764 ['L', '2010/02/14'],
15765 ['LL', '2010年2月14日'],
15766 ['LLL', '2010年2月14日午後3時25分'],
15767 ['LLLL', '2010年2月14日午後3時25分 日曜日'],
15768 ['l', '2010/2/14'],
15769 ['ll', '2010年2月14日'],
15770 ['lll', '2010年2月14日午後3時25分'],
15771 ['llll', '2010年2月14日午後3時25分 日']
15772 ],
15773 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
15774 i;
15775 for (i = 0; i < a.length; i++) {
15776 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
15777 }
15778 });
15779
15780 test('format month', function (assert) {
15781 var expected = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split('_'), i;
15782 for (i = 0; i < expected.length; i++) {
15783 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
15784 }
15785 });
15786
15787 test('format week', function (assert) {
15788 var expected = '日曜日 日 日_月曜日 月 月_火曜日 火 火_水曜日 水 水_木曜日 木 木_金曜日 金 金_土曜日 土 土'.split('_'), i;
15789 for (i = 0; i < expected.length; i++) {
15790 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
15791 }
15792 });
15793
15794 test('from', function (assert) {
15795 var start = moment([2007, 1, 28]);
15796 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '数秒', '44 seconds = a few seconds');
15797 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1分', '45 seconds = a minute');
15798 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1分', '89 seconds = a minute');
15799 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2分', '90 seconds = 2 minutes');
15800 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44分', '44 minutes = 44 minutes');
15801 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1時間', '45 minutes = an hour');
15802 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1時間', '89 minutes = an hour');
15803 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2時間', '90 minutes = 2 hours');
15804 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5時間', '5 hours = 5 hours');
15805 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21時間', '21 hours = 21 hours');
15806 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1日', '22 hours = a day');
15807 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1日', '35 hours = a day');
15808 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2日', '36 hours = 2 days');
15809 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1日', '1 day = a day');
15810 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5日', '5 days = 5 days');
15811 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25日', '25 days = 25 days');
15812 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1ヶ月', '26 days = a month');
15813 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1ヶ月', '30 days = a month');
15814 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1ヶ月', '43 days = a month');
15815 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2ヶ月', '46 days = 2 months');
15816 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2ヶ月', '75 days = 2 months');
15817 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3ヶ月', '76 days = 3 months');
15818 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1ヶ月', '1 month = a month');
15819 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5ヶ月', '5 months = 5 months');
15820 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1年', '345 days = a year');
15821 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2年', '548 days = 2 years');
15822 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1年', '1 year = a year');
15823 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5年', '5 years = 5 years');
15824 });
15825
15826 test('suffix', function (assert) {
15827 assert.equal(moment(30000).from(0), '数秒後', 'prefix');
15828 assert.equal(moment(0).from(30000), '数秒前', 'suffix');
15829 });
15830
15831 test('now from now', function (assert) {
15832 assert.equal(moment().fromNow(), '数秒前', 'now from now should display as in the past');
15833 });
15834
15835 test('fromNow', function (assert) {
15836 assert.equal(moment().add({s: 30}).fromNow(), '数秒後', 'in a few seconds');
15837 assert.equal(moment().add({d: 5}).fromNow(), '5日後', 'in 5 days');
15838 });
15839
15840 test('calendar day', function (assert) {
15841 var a = moment().hours(2).minutes(0).seconds(0);
15842
15843 assert.equal(moment(a).calendar(), '今日 午前2時0分', 'today at the same time');
15844 assert.equal(moment(a).add({m: 25}).calendar(), '今日 午前2時25分', 'Now plus 25 min');
15845 assert.equal(moment(a).add({h: 1}).calendar(), '今日 午前3時0分', 'Now plus 1 hour');
15846 assert.equal(moment(a).add({d: 1}).calendar(), '明日 午前2時0分', 'tomorrow at the same time');
15847 assert.equal(moment(a).subtract({h: 1}).calendar(), '今日 午前1時0分', 'Now minus 1 hour');
15848 assert.equal(moment(a).subtract({d: 1}).calendar(), '昨日 午前2時0分', 'yesterday at the same time');
15849 });
15850
15851 test('calendar next week', function (assert) {
15852 var i, m;
15853 for (i = 2; i < 7; i++) {
15854 m = moment().add({d: i});
15855 assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days current time');
15856 m.hours(0).minutes(0).seconds(0).milliseconds(0);
15857 assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days beginning of day');
15858 m.hours(23).minutes(59).seconds(59).milliseconds(999);
15859 assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days end of day');
15860 }
15861 });
15862
15863 test('calendar last week', function (assert) {
15864 var i, m;
15865 for (i = 2; i < 7; i++) {
15866 m = moment().subtract({d: i});
15867 assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days current time');
15868 m.hours(0).minutes(0).seconds(0).milliseconds(0);
15869 assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days beginning of day');
15870 m.hours(23).minutes(59).seconds(59).milliseconds(999);
15871 assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days end of day');
15872 }
15873 });
15874
15875 test('calendar all else', function (assert) {
15876 var weeksAgo = moment().subtract({w: 1}),
15877 weeksFromNow = moment().add({w: 1});
15878
15879 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
15880 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
15881
15882 weeksAgo = moment().subtract({w: 2});
15883 weeksFromNow = moment().add({w: 2});
15884
15885 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
15886 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
15887 });
15888
15889 test('weeks year starting sunday', function (assert) {
15890 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
15891 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
15892 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
15893 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
15894 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
15895 });
15896
15897 test('weeks year starting monday', function (assert) {
15898 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
15899 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
15900 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
15901 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
15902 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
15903 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
15904 });
15905
15906 test('weeks year starting tuesday', function (assert) {
15907 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
15908 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
15909 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
15910 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
15911 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
15912 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
15913 });
15914
15915 test('weeks year starting wednesday', function (assert) {
15916 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
15917 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
15918 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
15919 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
15920 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
15921 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
15922 });
15923
15924 test('weeks year starting thursday', function (assert) {
15925 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
15926 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
15927 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
15928 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
15929 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
15930 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
15931 });
15932
15933 test('weeks year starting friday', function (assert) {
15934 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
15935 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
15936 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
15937 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
15938 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
15939 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
15940 });
15941
15942 test('weeks year starting saturday', function (assert) {
15943 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
15944 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
15945 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
15946 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
15947 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
15948 });
15949
15950 test('weeks year starting sunday format', function (assert) {
15951 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
15952 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
15953 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
15954 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
15955 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
15956 });
15957
15958 test('lenient ordinal parsing', function (assert) {
15959 var i, ordinalStr, testMoment;
15960 for (i = 1; i <= 31; ++i) {
15961 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
15962 testMoment = moment(ordinalStr, 'YYYY MM Do');
15963 assert.equal(testMoment.year(), 2014,
15964 'lenient ordinal parsing ' + i + ' year check');
15965 assert.equal(testMoment.month(), 0,
15966 'lenient ordinal parsing ' + i + ' month check');
15967 assert.equal(testMoment.date(), i,
15968 'lenient ordinal parsing ' + i + ' date check');
15969 }
15970 });
15971
15972 test('lenient ordinal parsing of number', function (assert) {
15973 var i, testMoment;
15974 for (i = 1; i <= 31; ++i) {
15975 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
15976 assert.equal(testMoment.year(), 2014,
15977 'lenient ordinal parsing of number ' + i + ' year check');
15978 assert.equal(testMoment.month(), 0,
15979 'lenient ordinal parsing of number ' + i + ' month check');
15980 assert.equal(testMoment.date(), i,
15981 'lenient ordinal parsing of number ' + i + ' date check');
15982 }
15983 });
15984
15985 test('strict ordinal parsing', function (assert) {
15986 var i, ordinalStr, testMoment;
15987 for (i = 1; i <= 31; ++i) {
15988 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
15989 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
15990 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
15991 }
15992 });
15993
15994 }));
15995
15996 (function (global, factory) {
15997 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
15998 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
15999 factory(global.moment)
16000 }(this, function (moment) { 'use strict';
16001
16002 /*global QUnit:false*/
16003
16004 var test = QUnit.test;
16005
16006 function module (name, lifecycle) {
16007 QUnit.module(name, {
16008 setup : function () {
16009 moment.locale('en');
16010 moment.createFromInputFallback = function () {
16011 throw new Error('input not handled by moment');
16012 };
16013 if (lifecycle && lifecycle.setup) {
16014 lifecycle.setup();
16015 }
16016 },
16017 teardown : function () {
16018 if (lifecycle && lifecycle.teardown) {
16019 lifecycle.teardown();
16020 }
16021 }
16022 });
16023 }
16024
16025 function localeModule (name, lifecycle) {
16026 QUnit.module('locale:' + name, {
16027 setup : function () {
16028 moment.locale(name);
16029 moment.createFromInputFallback = function () {
16030 throw new Error('input not handled by moment');
16031 };
16032 if (lifecycle && lifecycle.setup) {
16033 lifecycle.setup();
16034 }
16035 },
16036 teardown : function () {
16037 moment.locale('en');
16038 if (lifecycle && lifecycle.teardown) {
16039 lifecycle.teardown();
16040 }
16041 }
16042 });
16043 }
16044
16045 localeModule('jv');
16046
16047
16048 test('parse', function (assert) {
16049 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;
16050 function equalTest(input, mmm, i) {
16051 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
16052 }
16053 for (i = 0; i < 12; i++) {
16054 tests[i] = tests[i].split(' ');
16055 equalTest(tests[i][0], 'MMM', i);
16056 equalTest(tests[i][1], 'MMM', i);
16057 equalTest(tests[i][0], 'MMMM', i);
16058 equalTest(tests[i][1], 'MMMM', i);
16059 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16060 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
16061 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
16062 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
16063 }
16064 });
16065
16066 test('format', function (assert) {
16067 var a = [
16068 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Minggu, Februari 14 2010, 3:25:50 sonten'],
16069 ['ddd, hA', 'Min, 3sonten'],
16070 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
16071 ['YYYY YY', '2010 10'],
16072 ['D Do DD', '14 14 14'],
16073 ['d do dddd ddd dd', '0 0 Minggu Min Mg'],
16074 ['DDD DDDo DDDD', '45 45 045'],
16075 ['w wo ww', '7 7 07'],
16076 ['h hh', '3 03'],
16077 ['H HH', '15 15'],
16078 ['m mm', '25 25'],
16079 ['s ss', '50 50'],
16080 ['a A', 'sonten sonten'],
16081 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
16082 ['LTS', '15.25.50'],
16083 ['L', '14/02/2010'],
16084 ['LL', '14 Februari 2010'],
16085 ['LLL', '14 Februari 2010 pukul 15.25'],
16086 ['LLLL', 'Minggu, 14 Februari 2010 pukul 15.25'],
16087 ['l', '14/2/2010'],
16088 ['ll', '14 Feb 2010'],
16089 ['lll', '14 Feb 2010 pukul 15.25'],
16090 ['llll', 'Min, 14 Feb 2010 pukul 15.25']
16091 ],
16092 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
16093 i;
16094 for (i = 0; i < a.length; i++) {
16095 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
16096 }
16097 });
16098
16099 test('format month', function (assert) {
16100 var expected = '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;
16101 for (i = 0; i < expected.length; i++) {
16102 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
16103 }
16104 });
16105
16106 test('format week', function (assert) {
16107 var expected = 'Minggu Min Mg_Senen Sen Sn_Seloso Sel Sl_Rebu Reb Rb_Kemis Kem Km_Jemuwah Jem Jm_Septu Sep Sp'.split('_'), i;
16108 for (i = 0; i < expected.length; i++) {
16109 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
16110 }
16111 });
16112
16113 test('from', function (assert) {
16114 var start = moment([2007, 1, 28]);
16115 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'sawetawis detik', '44 seconds = a few seconds');
16116 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'setunggal menit', '45 seconds = a minute');
16117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'setunggal menit', '89 seconds = a minute');
16118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 menit', '90 seconds = 2 minutes');
16119 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 menit', '44 minutes = 44 minutes');
16120 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'setunggal jam', '45 minutes = an hour');
16121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'setunggal jam', '89 minutes = an hour');
16122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minutes = 2 hours');
16123 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 hours = 5 hours');
16124 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 hours = 21 hours');
16125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sedinten', '22 hours = a day');
16126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sedinten', '35 hours = a day');
16127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dinten', '36 hours = 2 days');
16128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sedinten', '1 day = a day');
16129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dinten', '5 days = 5 days');
16130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dinten', '25 days = 25 days');
16131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sewulan', '26 days = a month');
16132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sewulan', '30 days = a month');
16133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sewulan', '43 days = a month');
16134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 wulan', '46 days = 2 months');
16135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 wulan', '75 days = 2 months');
16136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 wulan', '76 days = 3 months');
16137 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sewulan', '1 month = a month');
16138 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 wulan', '5 months = 5 months');
16139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setaun', '345 days = a year');
16140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 taun', '548 days = 2 years');
16141 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setaun', '1 year = a year');
16142 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 taun', '5 years = 5 years');
16143 });
16144
16145 test('suffix', function (assert) {
16146 assert.equal(moment(30000).from(0), 'wonten ing sawetawis detik', 'prefix');
16147 assert.equal(moment(0).from(30000), 'sawetawis detik ingkang kepengker', 'suffix');
16148 });
16149
16150 test('now from now', function (assert) {
16151 assert.equal(moment().fromNow(), 'sawetawis detik ingkang kepengker', 'now from now should display as in the past');
16152 });
16153
16154 test('fromNow', function (assert) {
16155 assert.equal(moment().add({s: 30}).fromNow(), 'wonten ing sawetawis detik', 'in a few seconds');
16156 assert.equal(moment().add({d: 5}).fromNow(), 'wonten ing 5 dinten', 'in 5 days');
16157 });
16158
16159 test('calendar day', function (assert) {
16160 var a = moment().hours(2).minutes(0).seconds(0);
16161
16162 assert.equal(moment(a).calendar(), 'Dinten puniko pukul 02.00', 'today at the same time');
16163 assert.equal(moment(a).add({m: 25}).calendar(), 'Dinten puniko pukul 02.25', 'Now plus 25 min');
16164 assert.equal(moment(a).add({h: 1}).calendar(), 'Dinten puniko pukul 03.00', 'Now plus 1 hour');
16165 assert.equal(moment(a).add({d: 1}).calendar(), 'Mbenjang pukul 02.00', 'tomorrow at the same time');
16166 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dinten puniko pukul 01.00', 'Now minus 1 hour');
16167 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kala wingi pukul 02.00', 'yesterday at the same time');
16168 });
16169
16170 test('calendar next week', function (assert) {
16171 var i, m;
16172 for (i = 2; i < 7; i++) {
16173 m = moment().add({d: i});
16174 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days current time');
16175 m.hours(0).minutes(0).seconds(0).milliseconds(0);
16176 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days beginning of day');
16177 m.hours(23).minutes(59).seconds(59).milliseconds(999);
16178 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days end of day');
16179 }
16180 });
16181
16182 test('calendar last week', function (assert) {
16183 var i, m;
16184 for (i = 2; i < 7; i++) {
16185 m = moment().subtract({d: i});
16186 assert.equal(m.calendar(), m.format('dddd [kepengker pukul] LT'), 'Today - ' + i + ' days current time');
16187 m.hours(0).minutes(0).seconds(0).milliseconds(0);
16188 assert.equal(m.calendar(), m.format('dddd [kepengker pukul] LT'), 'Today - ' + i + ' days beginning of day');
16189 m.hours(23).minutes(59).seconds(59).milliseconds(999);
16190 assert.equal(m.calendar(), m.format('dddd [kepengker pukul] LT'), 'Today - ' + i + ' days end of day');
16191 }
16192 });
16193
16194 test('calendar all else', function (assert) {
16195 var weeksAgo = moment().subtract({w: 1}),
16196 weeksFromNow = moment().add({w: 1});
16197
16198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
16199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
16200
16201 weeksAgo = moment().subtract({w: 2});
16202 weeksFromNow = moment().add({w: 2});
16203
16204 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
16205 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
16206 });
16207
16208 // Monday is the first day of the week.
16209 // The week that contains Jan 1st is the first week of the year.
16210
16211 test('weeks year starting sunday', function (assert) {
16212 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
16213 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
16214 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
16215 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
16216 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
16217 });
16218
16219 test('weeks year starting monday', function (assert) {
16220 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
16221 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
16222 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
16223 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
16224 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
16225 });
16226
16227 test('weeks year starting tuesday', function (assert) {
16228 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
16229 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
16230 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
16231 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
16232 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
16233 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
16234 });
16235
16236 test('weeks year starting wednesday', function (assert) {
16237 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
16238 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
16239 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
16240 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
16241 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
16242 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
16243 });
16244
16245 test('weeks year starting thursday', function (assert) {
16246 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
16247 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
16248 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
16249 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
16250 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
16251 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
16252 });
16253
16254 test('weeks year starting friday', function (assert) {
16255 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
16256 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
16257 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
16258 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
16259 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
16260 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
16261 });
16262
16263 test('weeks year starting saturday', function (assert) {
16264 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
16265 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
16266 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
16267 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
16268 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
16269 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
16270 });
16271
16272 test('weeks year starting sunday formatted', function (assert) {
16273 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
16274 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
16275 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 2');
16276 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
16277 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
16278 });
16279
16280 test('lenient ordinal parsing', function (assert) {
16281 var i, ordinalStr, testMoment;
16282 for (i = 1; i <= 31; ++i) {
16283 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
16284 testMoment = moment(ordinalStr, 'YYYY MM Do');
16285 assert.equal(testMoment.year(), 2014,
16286 'lenient ordinal parsing ' + i + ' year check');
16287 assert.equal(testMoment.month(), 0,
16288 'lenient ordinal parsing ' + i + ' month check');
16289 assert.equal(testMoment.date(), i,
16290 'lenient ordinal parsing ' + i + ' date check');
16291 }
16292 });
16293
16294 test('lenient ordinal parsing of number', function (assert) {
16295 var i, testMoment;
16296 for (i = 1; i <= 31; ++i) {
16297 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
16298 assert.equal(testMoment.year(), 2014,
16299 'lenient ordinal parsing of number ' + i + ' year check');
16300 assert.equal(testMoment.month(), 0,
16301 'lenient ordinal parsing of number ' + i + ' month check');
16302 assert.equal(testMoment.date(), i,
16303 'lenient ordinal parsing of number ' + i + ' date check');
16304 }
16305 });
16306
16307 test('meridiem invariant', function (assert) {
16308 var h, m, t1, t2;
16309 for (h = 0; h < 24; ++h) {
16310 for (m = 0; m < 60; m += 15) {
16311 t1 = moment.utc([2000, 0, 1, h, m]);
16312 t2 = moment(t1.format('A h:mm'), 'A h:mm');
16313 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
16314 'meridiem at ' + t1.format('HH:mm'));
16315 }
16316 }
16317 });
16318
16319 test('strict ordinal parsing', function (assert) {
16320 var i, ordinalStr, testMoment;
16321 for (i = 1; i <= 31; ++i) {
16322 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
16323 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
16324 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
16325 }
16326 });
16327
16328 }));
16329
16330 (function (global, factory) {
16331 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
16332 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
16333 factory(global.moment)
16334 }(this, function (moment) { 'use strict';
16335
16336 /*global QUnit:false*/
16337
16338 var test = QUnit.test;
16339
16340 function module (name, lifecycle) {
16341 QUnit.module(name, {
16342 setup : function () {
16343 moment.locale('en');
16344 moment.createFromInputFallback = function () {
16345 throw new Error('input not handled by moment');
16346 };
16347 if (lifecycle && lifecycle.setup) {
16348 lifecycle.setup();
16349 }
16350 },
16351 teardown : function () {
16352 if (lifecycle && lifecycle.teardown) {
16353 lifecycle.teardown();
16354 }
16355 }
16356 });
16357 }
16358
16359 function localeModule (name, lifecycle) {
16360 QUnit.module('locale:' + name, {
16361 setup : function () {
16362 moment.locale(name);
16363 moment.createFromInputFallback = function () {
16364 throw new Error('input not handled by moment');
16365 };
16366 if (lifecycle && lifecycle.setup) {
16367 lifecycle.setup();
16368 }
16369 },
16370 teardown : function () {
16371 moment.locale('en');
16372 if (lifecycle && lifecycle.teardown) {
16373 lifecycle.teardown();
16374 }
16375 }
16376 });
16377 }
16378
16379 localeModule('ka');
16380
16381 test('parse', function (assert) {
16382 var i,
16383 tests = 'იანვარი იან_თებერვალი თებ_მარტი მარ_აპრილი აპრ_მაისი მაი_ივნისი ივნ_ივლისი ივლ_აგვისტო აგვ_სექტემბერი სექ_ოქტომბერი ოქტ_ნოემბერი ნოე_დეკემბერი დეკ'.split('_');
16384
16385 function equalTest(input, mmm, i) {
16386 assert.equal(moment(input, mmm).month(), i, input + ' უნდა იყოს თვე ' + (i + 1));
16387 }
16388
16389 for (i = 0; i < 12; i++) {
16390 tests[i] = tests[i].split(' ');
16391 equalTest(tests[i][0], 'MMM', i);
16392 equalTest(tests[i][1], 'MMM', i);
16393 equalTest(tests[i][0], 'MMMM', i);
16394 equalTest(tests[i][1], 'MMMM', i);
16395 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16396 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
16397 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
16398 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
16399 }
16400 });
16401
16402 test('format', function (assert) {
16403 var a = [
16404 ['dddd, MMMM Do YYYY, h:mm:ss a', 'კვირა, თებერვალი მე-14 2010, 3:25:50 pm'],
16405 ['ddd, hA', 'კვი, 3PM'],
16406 ['M Mo MM MMMM MMM', '2 მე-2 02 თებერვალი თებ'],
16407 ['YYYY YY', '2010 10'],
16408 ['D Do DD', '14 მე-14 14'],
16409 ['d do dddd ddd dd', '0 0 კვირა კვი კვ'],
16410 ['DDD DDDo DDDD', '45 45-ე 045'],
16411 ['w wo ww', '7 მე-7 07'],
16412 ['h hh', '3 03'],
16413 ['H HH', '15 15'],
16414 ['m mm', '25 25'],
16415 ['s ss', '50 50'],
16416 ['a A', 'pm PM'],
16417 ['წლის DDDo დღე', 'წლის 45-ე დღე'],
16418 ['LTS', '3:25:50 PM'],
16419 ['L', '14/02/2010'],
16420 ['LL', '14 თებერვალი 2010'],
16421 ['LLL', '14 თებერვალი 2010 3:25 PM'],
16422 ['LLLL', 'კვირა, 14 თებერვალი 2010 3:25 PM'],
16423 ['l', '14/2/2010'],
16424 ['ll', '14 თებ 2010'],
16425 ['lll', '14 თებ 2010 3:25 PM'],
16426 ['llll', 'კვი, 14 თებ 2010 3:25 PM']
16427 ],
16428 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
16429 i;
16430
16431 for (i = 0; i < a.length; i++) {
16432 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
16433 }
16434 });
16435
16436 test('format ordinal', function (assert) {
16437 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ლი', '1-ლი');
16438 assert.equal(moment([2011, 0, 2]).format('DDDo'), 'მე-2', 'მე-2');
16439 assert.equal(moment([2011, 0, 3]).format('DDDo'), 'მე-3', 'მე-3');
16440 assert.equal(moment([2011, 0, 4]).format('DDDo'), 'მე-4', 'მე-4');
16441 assert.equal(moment([2011, 0, 5]).format('DDDo'), 'მე-5', 'მე-5');
16442 assert.equal(moment([2011, 0, 6]).format('DDDo'), 'მე-6', 'მე-6');
16443 assert.equal(moment([2011, 0, 7]).format('DDDo'), 'მე-7', 'მე-7');
16444 assert.equal(moment([2011, 0, 8]).format('DDDo'), 'მე-8', 'მე-8');
16445 assert.equal(moment([2011, 0, 9]).format('DDDo'), 'მე-9', 'მე-9');
16446 assert.equal(moment([2011, 0, 10]).format('DDDo'), 'მე-10', 'მე-10');
16447
16448 assert.equal(moment([2011, 0, 11]).format('DDDo'), 'მე-11', 'მე-11');
16449 assert.equal(moment([2011, 0, 12]).format('DDDo'), 'მე-12', 'მე-12');
16450 assert.equal(moment([2011, 0, 13]).format('DDDo'), 'მე-13', 'მე-13');
16451 assert.equal(moment([2011, 0, 14]).format('DDDo'), 'მე-14', 'მე-14');
16452 assert.equal(moment([2011, 0, 15]).format('DDDo'), 'მე-15', 'მე-15');
16453 assert.equal(moment([2011, 0, 16]).format('DDDo'), 'მე-16', 'მე-16');
16454 assert.equal(moment([2011, 0, 17]).format('DDDo'), 'მე-17', 'მე-17');
16455 assert.equal(moment([2011, 0, 18]).format('DDDo'), 'მე-18', 'მე-18');
16456 assert.equal(moment([2011, 0, 19]).format('DDDo'), 'მე-19', 'მე-19');
16457 assert.equal(moment([2011, 0, 20]).format('DDDo'), 'მე-20', 'მე-20');
16458
16459 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ე', '21-ე');
16460 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-ე', '22-ე');
16461 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-ე', '23-ე');
16462 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ე', '24-ე');
16463 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ე', '25-ე');
16464 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ე', '26-ე');
16465 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ე', '27-ე');
16466 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ე', '28-ე');
16467 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ე', '29-ე');
16468 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ე', '30-ე');
16469
16470 assert.equal(moment('2011 40', 'YYYY DDD').format('DDDo'), 'მე-40', 'მე-40');
16471 assert.equal(moment('2011 50', 'YYYY DDD').format('DDDo'), '50-ე', '50-ე');
16472 assert.equal(moment('2011 60', 'YYYY DDD').format('DDDo'), 'მე-60', 'მე-60');
16473 assert.equal(moment('2011 100', 'YYYY DDD').format('DDDo'), 'მე-100', 'მე-100');
16474 assert.equal(moment('2011 101', 'YYYY DDD').format('DDDo'), '101-ე', '101-ე');
16475 });
16476
16477 test('format month', function (assert) {
16478 var i,
16479 expected = 'იანვარი იან_თებერვალი თებ_მარტი მარ_აპრილი აპრ_მაისი მაი_ივნისი ივნ_ივლისი ივლ_აგვისტო აგვ_სექტემბერი სექ_ოქტომბერი ოქტ_ნოემბერი ნოე_დეკემბერი დეკ'.split('_');
16480
16481 for (i = 0; i < expected.length; i++) {
16482 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
16483 }
16484 });
16485
16486 test('format week', function (assert) {
16487 var i,
16488 expected = 'კვირა კვი კვ_ორშაბათი ორშ ორ_სამშაბათი სამ სა_ოთხშაბათი ოთხ ოთ_ხუთშაბათი ხუთ ხუ_პარასკევი პარ პა_შაბათი შაბ შა'.split('_');
16489
16490 for (i = 0; i < expected.length; i++) {
16491 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
16492 }
16493 });
16494
16495 test('from', function (assert) {
16496 var start = moment([2007, 1, 28]);
16497
16498 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'რამდენიმე წამი', '44 წამი = რამდენიმე წამი');
16499 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'წუთი', '45 წამი = წუთი');
16500 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'წუთი', '89 წამი = წუთი');
16501 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 წუთი', '90 წამი = 2 წუთი');
16502 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 წუთი', '44 წამი = 44 წუთი');
16503 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'საათი', '45 წამი = საათი');
16504 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'საათი', '89 წამი = საათი');
16505 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 საათი', '90 წამი = 2 საათი');
16506 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 საათი', '5 საათი = 5 საათი');
16507 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 საათი', '21 საათი = 21 საათი');
16508 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'დღე', '22 საათი = დღე');
16509 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'დღე', '35 საათი = დღე');
16510 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 დღე', '36 საათი = 2 დღე');
16511 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'დღე', '1 დღე = დღე');
16512 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 დღე', '5 დღე = 5 დღე');
16513 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 დღე', '25 დღე = 25 დღე');
16514 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'თვე', '26 დღე = თვე');
16515 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'თვე', '30 დღე = თვე');
16516 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'თვე', '45 დღე = თვე');
16517 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 თვე', '46 დღე = 2 თვე');
16518 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 თვე', '75 დღე = 2 თვე');
16519 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 თვე', '76 დღე = 3 თვე');
16520 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'თვე', '1 თვე = თვე');
16521 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 თვე', '5 თვე = 5 თვე');
16522 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'წელი', '345 დღე = წელი');
16523 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 წელი', '548 დღე = 2 წელი');
16524 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'წელი', '1 წელი = წელი');
16525 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 წელი', '5 წელი = 5 წელი');
16526 });
16527
16528 test('suffix', function (assert) {
16529 assert.equal(moment(30000).from(0), 'რამდენიმე წამში', 'ში სუფიქსი');
16530 assert.equal(moment(0).from(30000), 'რამდენიმე წამის წინ', 'წინ სუფიქსი');
16531 });
16532
16533 test('now from now', function (assert) {
16534 assert.equal(moment().fromNow(), 'რამდენიმე წამის წინ', 'უნდა აჩვენოს როგორც წარსული');
16535 });
16536
16537 test('fromNow', function (assert) {
16538 assert.equal(moment().add({s: 30}).fromNow(), 'რამდენიმე წამში', 'რამდენიმე წამში');
16539 assert.equal(moment().add({d: 5}).fromNow(), '5 დღეში', '5 დღეში');
16540 });
16541
16542 test('calendar day', function (assert) {
16543 var a = moment().hours(2).minutes(0).seconds(0);
16544
16545 assert.equal(moment(a).calendar(), 'დღეს 2:00 AM-ზე', 'დღეს ამავე დროს');
16546 assert.equal(moment(a).add({m: 25}).calendar(), 'დღეს 2:25 AM-ზე', 'ახლანდელ დროს დამატებული 25 წუთი');
16547 assert.equal(moment(a).add({h: 1}).calendar(), 'დღეს 3:00 AM-ზე', 'ახლანდელ დროს დამატებული 1 საათი');
16548 assert.equal(moment(a).add({d: 1}).calendar(), 'ხვალ 2:00 AM-ზე', 'ხვალ ამავე დროს');
16549 assert.equal(moment(a).subtract({h: 1}).calendar(), 'დღეს 1:00 AM-ზე', 'ახლანდელ დროს გამოკლებული 1 საათი');
16550 assert.equal(moment(a).subtract({d: 1}).calendar(), 'გუშინ 2:00 AM-ზე', 'გუშინ ამავე დროს');
16551 });
16552
16553 test('calendar next week', function (assert) {
16554 var i, m;
16555 for (i = 2; i < 7; i++) {
16556 m = moment().add({d: i});
16557 assert.equal(m.calendar(), m.format('[შემდეგ] dddd LT[-ზე]'), 'დღეს + ' + i + ' დღე ახლანდელ დროს');
16558 m.hours(0).minutes(0).seconds(0).milliseconds(0);
16559 assert.equal(m.calendar(), m.format('[შემდეგ] dddd LT[-ზე]'), 'დღეს + ' + i + ' დღე დღის დასაწყისში');
16560 m.hours(23).minutes(59).seconds(59).milliseconds(999);
16561 assert.equal(m.calendar(), m.format('[შემდეგ] dddd LT[-ზე]'), 'დღეს + ' + i + ' დღე დღის დასასრულს');
16562 }
16563 });
16564
16565 test('calendar last week', function (assert) {
16566 var i, m;
16567 for (i = 2; i < 7; i++) {
16568 m = moment().subtract({d: i});
16569 assert.equal(m.calendar(), m.format('[წინა] dddd LT[-ზე]'), 'დღეს - ' + i + ' დღე ახლანდელ დროს');
16570 m.hours(0).minutes(0).seconds(0).milliseconds(0);
16571 assert.equal(m.calendar(), m.format('[წინა] dddd LT[-ზე]'), 'დღეს - ' + i + ' დღე დღის დასაწყისში');
16572 m.hours(23).minutes(59).seconds(59).milliseconds(999);
16573 assert.equal(m.calendar(), m.format('[წინა] dddd LT[-ზე]'), 'დღეს - ' + i + ' დღე დღის დასასრულს');
16574 }
16575 });
16576
16577 test('calendar all else', function (assert) {
16578 var weeksAgo = moment().subtract({w: 1}),
16579 weeksFromNow = moment().add({w: 1});
16580
16581 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 კვირის წინ');
16582 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '1 კვირაში');
16583
16584 weeksAgo = moment().subtract({w: 2});
16585 weeksFromNow = moment().add({w: 2});
16586
16587 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 კვირის წინ');
16588 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 კვირაში');
16589 });
16590
16591 test('weeks year starting sunday', function (assert) {
16592 assert.equal(moment([2011, 11, 26]).week(), 1, 'დეკ 26 2011 უნდა იყოს კვირა 1');
16593 assert.equal(moment([2012, 0, 1]).week(), 1, 'იან 1 2012 უნდა იყოს კვირა 1');
16594 assert.equal(moment([2012, 0, 2]).week(), 2, 'იან 2 2012 უნდა იყოს კვირა 2');
16595 assert.equal(moment([2012, 0, 8]).week(), 2, 'იან 8 2012 უნდა იყოს კვირა 2');
16596 assert.equal(moment([2012, 0, 9]).week(), 3, 'იან 9 2012 უნდა იყოს კვირა 3');
16597 });
16598
16599 test('weeks year starting monday', function (assert) {
16600 assert.equal(moment([2007, 0, 1]).week(), 1, 'იან 1 2007 უნდა იყოს კვირა 1');
16601 assert.equal(moment([2007, 0, 7]).week(), 1, 'იან 7 2007 უნდა იყოს კვირა 1');
16602 assert.equal(moment([2007, 0, 8]).week(), 2, 'იან 8 2007 უნდა იყოს კვირა 2');
16603 assert.equal(moment([2007, 0, 14]).week(), 2, 'იან 14 2007 უნდა იყოს კვირა 2');
16604 assert.equal(moment([2007, 0, 15]).week(), 3, 'იან 15 2007 უნდა იყოს კვირა 3');
16605 });
16606
16607 test('weeks year starting tuesday', function (assert) {
16608 assert.equal(moment([2007, 11, 31]).week(), 1, 'დეკ 31 2007 უნდა იყოს კვირა 1');
16609 assert.equal(moment([2008, 0, 1]).week(), 1, 'იან 1 2008 უნდა იყოს კვირა 1');
16610 assert.equal(moment([2008, 0, 6]).week(), 1, 'იან 6 2008 უნდა იყოს კვირა 1');
16611 assert.equal(moment([2008, 0, 7]).week(), 2, 'იან 7 2008 უნდა იყოს კვირა 2');
16612 assert.equal(moment([2008, 0, 13]).week(), 2, 'იან 13 2008 უნდა იყოს კვირა 2');
16613 assert.equal(moment([2008, 0, 14]).week(), 3, 'იან 14 2008 უნდა იყოს კვირა 3');
16614 });
16615
16616 test('weeks year starting wednesday', function (assert) {
16617 assert.equal(moment([2002, 11, 30]).week(), 1, 'დეკ 30 2002 უნდა იყოს კვირა 1');
16618 assert.equal(moment([2003, 0, 1]).week(), 1, 'იან 1 2003 უნდა იყოს კვირა 1');
16619 assert.equal(moment([2003, 0, 5]).week(), 1, 'იან 5 2003 უნდა იყოს კვირა 1');
16620 assert.equal(moment([2003, 0, 6]).week(), 2, 'იან 6 2003 უნდა იყოს კვირა 2');
16621 assert.equal(moment([2003, 0, 12]).week(), 2, 'იან 12 2003 უნდა იყოს კვირა 2');
16622 assert.equal(moment([2003, 0, 13]).week(), 3, 'იან 13 2003 უნდა იყოს კვირა 3');
16623 });
16624
16625 test('weeks year starting thursday', function (assert) {
16626 assert.equal(moment([2008, 11, 29]).week(), 1, 'დეკ 29 2008 უნდა იყოს კვირა 1');
16627 assert.equal(moment([2009, 0, 1]).week(), 1, 'იან 1 2009 უნდა იყოს კვირა 1');
16628 assert.equal(moment([2009, 0, 4]).week(), 1, 'იან 4 2009 უნდა იყოს კვირა 1');
16629 assert.equal(moment([2009, 0, 5]).week(), 2, 'იან 5 2009 უნდა იყოს კვირა 2');
16630 assert.equal(moment([2009, 0, 11]).week(), 2, 'იან 11 2009 უნდა იყოს კვირა 2');
16631 assert.equal(moment([2009, 0, 12]).week(), 3, 'იან 12 2009 უნდა იყოს კვირა 3');
16632 });
16633
16634 test('weeks year starting friday', function (assert) {
16635 assert.equal(moment([2009, 11, 28]).week(), 1, 'დეკ 28 2009 უნდა იყოს კვირა 1');
16636 assert.equal(moment([2010, 0, 1]).week(), 1, 'იან 1 2010 უნდა იყოს კვირა 1');
16637 assert.equal(moment([2010, 0, 3]).week(), 1, 'იან 3 2010 უნდა იყოს კვირა 1');
16638 assert.equal(moment([2010, 0, 4]).week(), 2, 'იან 4 2010 უნდა იყოს კვირა 2');
16639 assert.equal(moment([2010, 0, 10]).week(), 2, 'იან 10 2010 უნდა იყოს კვირა 2');
16640 assert.equal(moment([2010, 0, 11]).week(), 3, 'იან 11 2010 უნდა იყოს კვირა 3');
16641 });
16642
16643 test('weeks year starting saturday', function (assert) {
16644 assert.equal(moment([2010, 11, 27]).week(), 1, 'დეკ 27 2010 უნდა იყოს კვირა 1');
16645 assert.equal(moment([2011, 0, 1]).week(), 1, 'იან 1 2011 უნდა იყოს კვირა 1');
16646 assert.equal(moment([2011, 0, 2]).week(), 1, 'იან 2 2011 უნდა იყოს კვირა 1');
16647 assert.equal(moment([2011, 0, 3]).week(), 2, 'იან 3 2011 უნდა იყოს კვირა 2');
16648 assert.equal(moment([2011, 0, 9]).week(), 2, 'იან 9 2011 უნდა იყოს კვირა 2');
16649 assert.equal(moment([2011, 0, 10]).week(), 3, 'იან 10 2011 უნდა იყოს კვირა 3');
16650 });
16651
16652 test('weeks year starting sunday formatted', function (assert) {
16653 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ლი', 'დეკ 26 2011 უნდა იყოს კვირა 1');
16654 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ლი', 'იან 1 2012 უნდა იყოს კვირა 1');
16655 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 მე-2', 'იან 2 2012 უნდა იყოს კვირა 2');
16656 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 მე-2', 'იან 8 2012 უნდა იყოს კვირა 2');
16657 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 მე-3', 'იან 9 2012 უნდა იყოს კვირა 3');
16658 });
16659
16660 test('lenient ordinal parsing', function (assert) {
16661 var i, ordinalStr, testMoment;
16662 for (i = 1; i <= 31; ++i) {
16663 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
16664 testMoment = moment(ordinalStr, 'YYYY MM Do');
16665 assert.equal(testMoment.year(), 2014,
16666 'lenient ordinal parsing ' + i + ' year check');
16667 assert.equal(testMoment.month(), 0,
16668 'lenient ordinal parsing ' + i + ' month check');
16669 assert.equal(testMoment.date(), i,
16670 'lenient ordinal parsing ' + i + ' date check');
16671 }
16672 });
16673
16674 test('lenient ordinal parsing of number', function (assert) {
16675 var i, testMoment;
16676 for (i = 1; i <= 31; ++i) {
16677 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
16678 assert.equal(testMoment.year(), 2014,
16679 'lenient ordinal parsing of number ' + i + ' year check');
16680 assert.equal(testMoment.month(), 0,
16681 'lenient ordinal parsing of number ' + i + ' month check');
16682 assert.equal(testMoment.date(), i,
16683 'lenient ordinal parsing of number ' + i + ' date check');
16684 }
16685 });
16686
16687 test('strict ordinal parsing', function (assert) {
16688 var i, ordinalStr, testMoment;
16689 for (i = 1; i <= 31; ++i) {
16690 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
16691 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
16692 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
16693 }
16694 });
16695
16696 }));
16697
16698 (function (global, factory) {
16699 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
16700 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
16701 factory(global.moment)
16702 }(this, function (moment) { 'use strict';
16703
16704 /*global QUnit:false*/
16705
16706 var test = QUnit.test;
16707
16708 function module (name, lifecycle) {
16709 QUnit.module(name, {
16710 setup : function () {
16711 moment.locale('en');
16712 moment.createFromInputFallback = function () {
16713 throw new Error('input not handled by moment');
16714 };
16715 if (lifecycle && lifecycle.setup) {
16716 lifecycle.setup();
16717 }
16718 },
16719 teardown : function () {
16720 if (lifecycle && lifecycle.teardown) {
16721 lifecycle.teardown();
16722 }
16723 }
16724 });
16725 }
16726
16727 function localeModule (name, lifecycle) {
16728 QUnit.module('locale:' + name, {
16729 setup : function () {
16730 moment.locale(name);
16731 moment.createFromInputFallback = function () {
16732 throw new Error('input not handled by moment');
16733 };
16734 if (lifecycle && lifecycle.setup) {
16735 lifecycle.setup();
16736 }
16737 },
16738 teardown : function () {
16739 moment.locale('en');
16740 if (lifecycle && lifecycle.teardown) {
16741 lifecycle.teardown();
16742 }
16743 }
16744 });
16745 }
16746
16747 localeModule('km');
16748
16749 test('parse', function (assert) {
16750 var tests = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
16751 i;
16752
16753 function equalTest(input, mmm, i) {
16754 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
16755 }
16756 for (i = 0; i < 12; i++) {
16757 tests[i] = tests[i].split(' ');
16758 equalTest(tests[i][0], 'MMM', i);
16759 equalTest(tests[i][1], 'MMM', i);
16760 equalTest(tests[i][0], 'MMMM', i);
16761 equalTest(tests[i][1], 'MMMM', i);
16762 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16763 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
16764 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
16765 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
16766 }
16767 });
16768
16769 test('format', function (assert) {
16770 var a = [
16771 ['dddd, MMMM Do YYYY, h:mm:ss a', 'អាទិត្យ, កុម្ភៈ 14 2010, 3:25:50 pm'],
16772 ['ddd, hA', 'អាទិត្យ, 3PM'],
16773 ['M Mo MM MMMM MMM', '2 2 02 កុម្ភៈ កុម្ភៈ'],
16774 ['YYYY YY', '2010 10'],
16775 ['D Do DD', '14 14 14'],
16776 ['d do dddd ddd dd', '0 0 អាទិត្យ អាទិត្យ អាទិត្យ'],
16777 ['DDD DDDo DDDD', '45 45 045'],
16778 ['w wo ww', '6 6 06'],
16779 ['h hh', '3 03'],
16780 ['H HH', '15 15'],
16781 ['m mm', '25 25'],
16782 ['s ss', '50 50'],
16783 ['a A', 'pm PM'],
16784 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
16785 ['LTS', '15:25:50'],
16786 ['L', '14/02/2010'],
16787 ['LL', '14 កុម្ភៈ 2010'],
16788 ['LLL', '14 កុម្ភៈ 2010 15:25'],
16789 ['LLLL', 'អាទិត្យ, 14 កុម្ភៈ 2010 15:25'],
16790 ['l', '14/2/2010'],
16791 ['ll', '14 កុម្ភៈ 2010'],
16792 ['lll', '14 កុម្ភៈ 2010 15:25'],
16793 ['llll', 'អាទិត្យ, 14 កុម្ភៈ 2010 15:25']
16794 ],
16795 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
16796 i;
16797 for (i = 0; i < a.length; i++) {
16798 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
16799 }
16800 });
16801
16802 test('format ordinal', function (assert) {
16803 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1st');
16804 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2nd');
16805 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3rd');
16806 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4th');
16807 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5th');
16808 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6th');
16809 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7th');
16810 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8th');
16811 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9th');
16812 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10th');
16813
16814 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11th');
16815 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12th');
16816 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13th');
16817 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14th');
16818 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15th');
16819 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16th');
16820 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17th');
16821 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18th');
16822 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19th');
16823 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20th');
16824
16825 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21st');
16826 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22nd');
16827 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23rd');
16828 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24th');
16829 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25th');
16830 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26th');
16831 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27th');
16832 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28th');
16833 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29th');
16834 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30th');
16835
16836 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31st');
16837 });
16838
16839 test('format month', function (assert) {
16840 var expected = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
16841 i;
16842 for (i = 0; i < expected.length; i++) {
16843 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
16844 }
16845 });
16846
16847 test('format week', function (assert) {
16848 var expected = 'អាទិត្យ អាទិត្យ អាទិត្យ_ច័ន្ទ ច័ន្ទ ច័ន្ទ_អង្គារ អង្គារ អង្គារ_ពុធ ពុធ ពុធ_ព្រហស្បតិ៍ ព្រហស្បតិ៍ ព្រហស្បតិ៍_សុក្រ សុក្រ សុក្រ_សៅរ៍ សៅរ៍ សៅរ៍'.split('_'),
16849 i;
16850 for (i = 0; i < expected.length; i++) {
16851 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
16852 }
16853 });
16854
16855 test('from', function (assert) {
16856 var start = moment([2007, 1, 28]);
16857 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ប៉ុន្មានវិនាទី', '44 seconds = ប៉ុន្មានវិនាទី');
16858 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'មួយនាទី', '45 seconds = មួយនាទី');
16859 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'មួយនាទី', '89 seconds = មួយនាទី');
16860 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 នាទី', '90 seconds = 2 នាទី');
16861 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 នាទី', '44 minutes = 44 នាទី');
16862 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'មួយម៉ោង', '45 minutes = មួយម៉ោង');
16863 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'មួយម៉ោង', '89 minutes = មួយម៉ោង');
16864 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ម៉ោង', '90 minutes = 2 ម៉ោង');
16865 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ម៉ោង', '5 hours = 5 ម៉ោង');
16866 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ម៉ោង', '21 hours = 21 ម៉ោង');
16867 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'មួយថ្ងៃ', '22 hours = មួយថ្ងៃ');
16868 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'មួយថ្ងៃ', '35 hours = មួយថ្ងៃ');
16869 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ថ្ងៃ', '36 hours = 2 ថ្ងៃ');
16870 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'មួយថ្ងៃ', '1 day = មួយថ្ងៃ');
16871 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ថ្ងៃ', '5 days = 5 ថ្ងៃ');
16872 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ថ្ងៃ', '25 days = 25 ថ្ងៃ');
16873 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'មួយខែ', '26 days = មួយខែ');
16874 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'មួយខែ', '30 days = មួយខែ');
16875 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'មួយខែ', '43 days = មួយខែ');
16876 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ខែ', '46 days = 2 ខែ');
16877 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ខែ', '75 days = 2 ខែ');
16878 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ខែ', '76 days = 3 ខែ');
16879 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'មួយខែ', '1 month = មួយខែ');
16880 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ខែ', '5 months = 5 ខែ');
16881 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'មួយឆ្នាំ', '345 days = មួយឆ្នាំ');
16882 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ឆ្នាំ', '548 days = 2 ឆ្នាំ');
16883 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'មួយឆ្នាំ', '1 year = មួយឆ្នាំ');
16884 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ឆ្នាំ', '5 years = 5 ឆ្នាំ');
16885 });
16886
16887 test('suffix', function (assert) {
16888 assert.equal(moment(30000).from(0), 'ប៉ុន្មានវិនាទីទៀត', 'prefix');
16889 assert.equal(moment(0).from(30000), 'ប៉ុន្មានវិនាទីមុន', 'suffix');
16890 });
16891
16892 test('now from now', function (assert) {
16893 assert.equal(moment().fromNow(), 'ប៉ុន្មានវិនាទីមុន', 'now from now should display as in the past');
16894 });
16895
16896 test('fromNow', function (assert) {
16897 assert.equal(moment().add({
16898 s: 30
16899 }).fromNow(), 'ប៉ុន្មានវិនាទីទៀត', 'in a few seconds');
16900 assert.equal(moment().add({
16901 d: 5
16902 }).fromNow(), '5 ថ្ងៃទៀត', 'in 5 days');
16903 });
16904
16905 test('calendar day', function (assert) {
16906 var a = moment().hours(2).minutes(0).seconds(0);
16907
16908 assert.equal(moment(a).calendar(), 'ថ្ងៃនៈ ម៉ោង 02:00', 'today at the same time');
16909 assert.equal(moment(a).add({
16910 m: 25
16911 }).calendar(), 'ថ្ងៃនៈ ម៉ោង 02:25', 'Now plus 25 min');
16912 assert.equal(moment(a).add({
16913 h: 1
16914 }).calendar(), 'ថ្ងៃនៈ ម៉ោង 03:00', 'Now plus 1 hour');
16915 assert.equal(moment(a).add({
16916 d: 1
16917 }).calendar(), 'ស្អែក ម៉ោង 02:00', 'tomorrow at the same time');
16918 assert.equal(moment(a).subtract({
16919 h: 1
16920 }).calendar(), 'ថ្ងៃនៈ ម៉ោង 01:00', 'Now minus 1 hour');
16921 assert.equal(moment(a).subtract({
16922 d: 1
16923 }).calendar(), 'ម្សិលមិញ ម៉ោង 02:00', 'yesterday at the same time');
16924 });
16925
16926 test('calendar next week', function (assert) {
16927 var i, m;
16928 for (i = 2; i < 7; i++) {
16929 m = moment().add({
16930 d: i
16931 });
16932 assert.equal(m.calendar(), m.format('dddd [ម៉ោង] LT'), 'Today + ' + i + ' days current time');
16933 m.hours(0).minutes(0).seconds(0).milliseconds(0);
16934 assert.equal(m.calendar(), m.format('dddd [ម៉ោង] LT'), 'Today + ' + i + ' days beginning of day');
16935 m.hours(23).minutes(59).seconds(59).milliseconds(999);
16936 assert.equal(m.calendar(), m.format('dddd [ម៉ោង] LT'), 'Today + ' + i + ' days end of day');
16937 }
16938 });
16939
16940 test('calendar last week', function (assert) {
16941 var i, m;
16942
16943 for (i = 2; i < 7; i++) {
16944 m = moment().subtract({
16945 d: i
16946 });
16947 assert.equal(m.calendar(), m.format('dddd [សប្តាហ៍មុន] [ម៉ោង] LT'), 'Today - ' + i + ' days current time');
16948 m.hours(0).minutes(0).seconds(0).milliseconds(0);
16949 assert.equal(m.calendar(), m.format('dddd [សប្តាហ៍មុន] [ម៉ោង] LT'), 'Today - ' + i + ' days beginning of day');
16950 m.hours(23).minutes(59).seconds(59).milliseconds(999);
16951 assert.equal(m.calendar(), m.format('dddd [សប្តាហ៍មុន] [ម៉ោង] LT'), 'Today - ' + i + ' days end of day');
16952 }
16953 });
16954
16955 test('calendar all else', function (assert) {
16956 var weeksAgo = moment().subtract({
16957 w: 1
16958 }),
16959 weeksFromNow = moment().add({
16960 w: 1
16961 });
16962
16963 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
16964 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
16965
16966 weeksAgo = moment().subtract({
16967 w: 2
16968 });
16969 weeksFromNow = moment().add({
16970 w: 2
16971 });
16972
16973 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
16974 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
16975 });
16976
16977 test('weeks year starting sunday', function (assert) {
16978 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
16979 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
16980 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
16981 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
16982 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
16983 });
16984
16985 test('weeks year starting monday', function (assert) {
16986 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
16987 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
16988 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
16989 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
16990 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
16991 });
16992
16993 test('weeks year starting tuesday', function (assert) {
16994 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
16995 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
16996 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
16997 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
16998 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
16999 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
17000 });
17001
17002 test('weeks year starting wednesday', function (assert) {
17003 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
17004 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
17005 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
17006 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
17007 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
17008 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
17009 });
17010
17011 test('weeks year starting thursday', function (assert) {
17012 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
17013 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
17014 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
17015 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
17016 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
17017 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
17018 });
17019
17020 test('weeks year starting friday', function (assert) {
17021 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
17022 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
17023 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
17024 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
17025 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
17026 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
17027 });
17028
17029 test('weeks year starting saturday', function (assert) {
17030 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
17031 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
17032 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
17033 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
17034 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
17035 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
17036 });
17037
17038 test('weeks year starting sunday formatted', function (assert) {
17039 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
17040 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
17041 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
17042 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
17043 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
17044 });
17045
17046 test('lenient ordinal parsing', function (assert) {
17047 var i, ordinalStr, testMoment;
17048 for (i = 1; i <= 31; ++i) {
17049 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
17050 testMoment = moment(ordinalStr, 'YYYY MM Do');
17051 assert.equal(testMoment.year(), 2014,
17052 'lenient ordinal parsing ' + i + ' year check');
17053 assert.equal(testMoment.month(), 0,
17054 'lenient ordinal parsing ' + i + ' month check');
17055 assert.equal(testMoment.date(), i,
17056 'lenient ordinal parsing ' + i + ' date check');
17057 }
17058 });
17059
17060 test('lenient ordinal parsing of number', function (assert) {
17061 var i, testMoment;
17062 for (i = 1; i <= 31; ++i) {
17063 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
17064 assert.equal(testMoment.year(), 2014,
17065 'lenient ordinal parsing of number ' + i + ' year check');
17066 assert.equal(testMoment.month(), 0,
17067 'lenient ordinal parsing of number ' + i + ' month check');
17068 assert.equal(testMoment.date(), i,
17069 'lenient ordinal parsing of number ' + i + ' date check');
17070 }
17071 });
17072
17073 test('strict ordinal parsing', function (assert) {
17074 var i, ordinalStr, testMoment;
17075 for (i = 1; i <= 31; ++i) {
17076 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
17077 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
17078 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
17079 }
17080 });
17081
17082 }));
17083
17084 (function (global, factory) {
17085 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
17086 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
17087 factory(global.moment)
17088 }(this, function (moment) { 'use strict';
17089
17090 /*global QUnit:false*/
17091
17092 var test = QUnit.test;
17093
17094 function module (name, lifecycle) {
17095 QUnit.module(name, {
17096 setup : function () {
17097 moment.locale('en');
17098 moment.createFromInputFallback = function () {
17099 throw new Error('input not handled by moment');
17100 };
17101 if (lifecycle && lifecycle.setup) {
17102 lifecycle.setup();
17103 }
17104 },
17105 teardown : function () {
17106 if (lifecycle && lifecycle.teardown) {
17107 lifecycle.teardown();
17108 }
17109 }
17110 });
17111 }
17112
17113 function localeModule (name, lifecycle) {
17114 QUnit.module('locale:' + name, {
17115 setup : function () {
17116 moment.locale(name);
17117 moment.createFromInputFallback = function () {
17118 throw new Error('input not handled by moment');
17119 };
17120 if (lifecycle && lifecycle.setup) {
17121 lifecycle.setup();
17122 }
17123 },
17124 teardown : function () {
17125 moment.locale('en');
17126 if (lifecycle && lifecycle.teardown) {
17127 lifecycle.teardown();
17128 }
17129 }
17130 });
17131 }
17132
17133 localeModule('ko');
17134
17135 test('parse', function (assert) {
17136 var tests = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split('_'), i;
17137 function equalTest(input, mmm, i) {
17138 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
17139 }
17140 for (i = 0; i < 12; i++) {
17141 tests[i] = tests[i].split(' ');
17142 equalTest(tests[i][0], 'MMM', i);
17143 equalTest(tests[i][1], 'MMM', i);
17144 equalTest(tests[i][0], 'MMMM', i);
17145 equalTest(tests[i][1], 'MMMM', i);
17146 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17147 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17148 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
17149 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
17150 }
17151 });
17152
17153 test('parse meridiem', function (assert) {
17154 var elements = [{
17155 expression : '1981년 9월 8일 오후 2시 30분',
17156 inputFormat : 'YYYY[년] M[월] D[일] A h[시] m[분]',
17157 outputFormat : 'A',
17158 expected : '오후'
17159 }, {
17160 expression : '1981년 9월 8일 오전 2시 30분',
17161 inputFormat : 'YYYY[년] M[월] D[일] A h[시] m[분]',
17162 outputFormat : 'A h시',
17163 expected : '오전 2시'
17164 }, {
17165 expression : '14시 30분',
17166 inputFormat : 'H[시] m[분]',
17167 outputFormat : 'A',
17168 expected : '오후'
17169 }, {
17170 expression : '오후 4시',
17171 inputFormat : 'A h[시]',
17172 outputFormat : 'H',
17173 expected : '16'
17174 }], i, l, it, actual;
17175
17176
17177 for (i = 0, l = elements.length; i < l; ++i) {
17178 it = elements[i];
17179 actual = moment(it.expression, it.inputFormat).format(it.outputFormat);
17180
17181 assert.equal(
17182 actual,
17183 it.expected,
17184 '\'' + it.outputFormat + '\' of \'' + it.expression + '\' must be \'' + it.expected + '\' but was \'' + actual + '\'.'
17185 );
17186 }
17187 });
17188
17189 test('format', function (assert) {
17190 var a = [
17191 ['YYYY년 MMMM Do dddd a h:mm:ss', '2010년 2월 14일 일요일 오후 3:25:50'],
17192 ['ddd A h', '일 오후 3'],
17193 ['M Mo MM MMMM MMM', '2 2일 02 2월 2월'],
17194 ['YYYY YY', '2010 10'],
17195 ['D Do DD', '14 14일 14'],
17196 ['d do dddd ddd dd', '0 0일 일요일 일 일'],
17197 ['DDD DDDo DDDD', '45 45일 045'],
17198 ['w wo ww', '8 8일 08'],
17199 ['h hh', '3 03'],
17200 ['H HH', '15 15'],
17201 ['m mm', '25 25'],
17202 ['s ss', '50 50'],
17203 ['a A', '오후 오후'],
17204 ['일년 중 DDDo째 되는 날', '일년 중 45일째 되는 날'],
17205 ['LTS', '오후 3시 25분 50초'],
17206 ['L', '2010.02.14'],
17207 ['LL', '2010년 2월 14일'],
17208 ['LLL', '2010년 2월 14일 오후 3시 25분'],
17209 ['LLLL', '2010년 2월 14일 일요일 오후 3시 25분'],
17210 ['l', '2010.2.14'],
17211 ['ll', '2010년 2월 14일'],
17212 ['lll', '2010년 2월 14일 오후 3시 25분'],
17213 ['llll', '2010년 2월 14일 일 오후 3시 25분']
17214 ],
17215 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
17216 i;
17217 for (i = 0; i < a.length; i++) {
17218 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
17219 }
17220 });
17221
17222 test('format ordinal', function (assert) {
17223 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1일', '1일');
17224 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2일', '2일');
17225 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3일', '3일');
17226 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4일', '4일');
17227 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5일', '5일');
17228 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6일', '6일');
17229 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7일', '7일');
17230 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8일', '8일');
17231 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9일', '9일');
17232 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10일', '10일');
17233
17234 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11일', '11일');
17235 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12일', '12일');
17236 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13일', '13일');
17237 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14일', '14일');
17238 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15일', '15일');
17239 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16일', '16일');
17240 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17일', '17일');
17241 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18일', '18일');
17242 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19일', '19일');
17243 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20일', '20일');
17244
17245 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21일', '21일');
17246 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22일', '22일');
17247 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23일', '23일');
17248 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24일', '24일');
17249 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25일', '25일');
17250 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26일', '26일');
17251 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27일', '27일');
17252 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28일', '28일');
17253 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29일', '29일');
17254 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30일', '30일');
17255
17256 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31일', '31일');
17257 });
17258
17259 test('format month', function (assert) {
17260 var expected = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split('_'), i;
17261 for (i = 0; i < expected.length; i++) {
17262 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
17263 }
17264 });
17265
17266 test('format week', function (assert) {
17267 var expected = '일요일 일 일_월요일 월 월_화요일 화 화_수요일 수 수_목요일 목 목_금요일 금 금_토요일 토 토'.split('_'), i;
17268 for (i = 0; i < expected.length; i++) {
17269 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
17270 }
17271 });
17272
17273 test('from', function (assert) {
17274 var start = moment([2007, 1, 28]);
17275 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '몇초', '44초 = 몇초');
17276 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '일분', '45초 = 일분');
17277 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '일분', '89초 = 일분');
17278 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2분', '90초 = 2분');
17279 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44분', '44분 = 44분');
17280 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '한시간', '45분 = 한시간');
17281 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '한시간', '89분 = 한시간');
17282 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2시간', '90분 = 2시간');
17283 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5시간', '5시간 = 5시간');
17284 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21시간', '21시간 = 21시간');
17285 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '하루', '22시간 = 하루');
17286 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '하루', '35시간 = 하루');
17287 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2일', '36시간 = 2일');
17288 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '하루', '하루 = 하루');
17289 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5일', '5일 = 5일');
17290 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25일', '25일 = 25일');
17291 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '한달', '26일 = 한달');
17292 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '한달', '30일 = 한달');
17293 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '한달', '45일 = 한달');
17294 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2달', '46일 = 2달');
17295 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2달', '75일 = 2달');
17296 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3달', '76일 = 3달');
17297 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '한달', '1달 = 한달');
17298 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5달', '5달 = 5달');
17299 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '일년', '345일 = 일년');
17300 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2년', '548일 = 2년');
17301 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '일년', '일년 = 일년');
17302 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5년', '5년 = 5년');
17303 });
17304
17305 test('suffix', function (assert) {
17306 assert.equal(moment(30000).from(0), '몇초 후', 'prefix');
17307 assert.equal(moment(0).from(30000), '몇초 전', 'suffix');
17308 });
17309
17310 test('now from now', function (assert) {
17311 assert.equal(moment().fromNow(), '몇초 전', 'now from now should display as in the past');
17312 });
17313
17314 test('fromNow', function (assert) {
17315 assert.equal(moment().add({s: 30}).fromNow(), '몇초 후', 'in a few seconds');
17316 assert.equal(moment().add({d: 5}).fromNow(), '5일 후', 'in 5 days');
17317 });
17318
17319 test('calendar day', function (assert) {
17320 var a = moment().hours(2).minutes(0).seconds(0);
17321
17322 assert.equal(moment(a).calendar(), '오늘 오전 2시 0분', 'today at the same time');
17323 assert.equal(moment(a).add({m: 25}).calendar(), '오늘 오전 2시 25분', 'Now plus 25 min');
17324 assert.equal(moment(a).add({h: 1}).calendar(), '오늘 오전 3시 0분', 'Now plus 1 hour');
17325 assert.equal(moment(a).add({d: 1}).calendar(), '내일 오전 2시 0분', 'tomorrow at the same time');
17326 assert.equal(moment(a).subtract({h: 1}).calendar(), '오늘 오전 1시 0분', 'Now minus 1 hour');
17327 assert.equal(moment(a).subtract({d: 1}).calendar(), '어제 오전 2시 0분', 'yesterday at the same time');
17328 });
17329
17330 test('calendar next week', function (assert) {
17331 var i, m;
17332 for (i = 2; i < 7; i++) {
17333 m = moment().add({d: i});
17334 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days current time');
17335 m.hours(0).minutes(0).seconds(0).milliseconds(0);
17336 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days beginning of day');
17337 m.hours(23).minutes(59).seconds(59).milliseconds(999);
17338 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days end of day');
17339 }
17340 });
17341
17342 test('calendar last week', function (assert) {
17343 var i, m;
17344 for (i = 2; i < 7; i++) {
17345 m = moment().subtract({d: i});
17346 assert.equal(m.calendar(), m.format('지난주 dddd LT'), 'Today - ' + i + ' days current time');
17347 m.hours(0).minutes(0).seconds(0).milliseconds(0);
17348 assert.equal(m.calendar(), m.format('지난주 dddd LT'), 'Today - ' + i + ' days beginning of day');
17349 m.hours(23).minutes(59).seconds(59).milliseconds(999);
17350 assert.equal(m.calendar(), m.format('지난주 dddd LT'), 'Today - ' + i + ' days end of day');
17351 }
17352 });
17353
17354 test('calendar all else', function (assert) {
17355 var weeksAgo = moment().subtract({w: 1}),
17356 weeksFromNow = moment().add({w: 1});
17357
17358 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
17359 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
17360
17361 weeksAgo = moment().subtract({w: 2});
17362 weeksFromNow = moment().add({w: 2});
17363
17364 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
17365 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
17366 });
17367
17368 test('weeks year starting sunday', function (assert) {
17369 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
17370 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
17371 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
17372 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
17373 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
17374 });
17375
17376 test('weeks year starting monday', function (assert) {
17377 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
17378 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
17379 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
17380 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
17381 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
17382 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
17383 });
17384
17385 test('weeks year starting tuesday', function (assert) {
17386 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
17387 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
17388 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
17389 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
17390 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
17391 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
17392 });
17393
17394 test('weeks year starting wednesday', function (assert) {
17395 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
17396 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
17397 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
17398 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
17399 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
17400 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
17401 });
17402
17403 test('weeks year starting thursday', function (assert) {
17404 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
17405 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
17406 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
17407 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
17408 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
17409 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
17410 });
17411
17412 test('weeks year starting friday', function (assert) {
17413 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
17414 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
17415 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
17416 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
17417 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
17418 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
17419 });
17420
17421 test('weeks year starting saturday', function (assert) {
17422 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
17423 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
17424 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
17425 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
17426 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
17427 });
17428
17429 test('weeks year starting sunday format', function (assert) {
17430 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1일', 'Jan 1 2012 should be week 1');
17431 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1일', 'Jan 7 2012 should be week 1');
17432 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2일', 'Jan 8 2012 should be week 2');
17433 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2일', 'Jan 14 2012 should be week 2');
17434 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3일', 'Jan 15 2012 should be week 3');
17435 });
17436
17437 test('lenient ordinal parsing', function (assert) {
17438 var i, ordinalStr, testMoment;
17439 for (i = 1; i <= 31; ++i) {
17440 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
17441 testMoment = moment(ordinalStr, 'YYYY MM Do');
17442 assert.equal(testMoment.year(), 2014,
17443 'lenient ordinal parsing ' + i + ' year check');
17444 assert.equal(testMoment.month(), 0,
17445 'lenient ordinal parsing ' + i + ' month check');
17446 assert.equal(testMoment.date(), i,
17447 'lenient ordinal parsing ' + i + ' date check');
17448 }
17449 });
17450
17451 test('lenient ordinal parsing of number', function (assert) {
17452 var i, testMoment;
17453 for (i = 1; i <= 31; ++i) {
17454 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
17455 assert.equal(testMoment.year(), 2014,
17456 'lenient ordinal parsing of number ' + i + ' year check');
17457 assert.equal(testMoment.month(), 0,
17458 'lenient ordinal parsing of number ' + i + ' month check');
17459 assert.equal(testMoment.date(), i,
17460 'lenient ordinal parsing of number ' + i + ' date check');
17461 }
17462 });
17463
17464 test('strict ordinal parsing', function (assert) {
17465 var i, ordinalStr, testMoment;
17466 for (i = 1; i <= 31; ++i) {
17467 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
17468 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
17469 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
17470 }
17471 });
17472
17473 }));
17474
17475 (function (global, factory) {
17476 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
17477 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
17478 factory(global.moment)
17479 }(this, function (moment) { 'use strict';
17480
17481 /*global QUnit:false*/
17482
17483 var test = QUnit.test;
17484
17485 function module (name, lifecycle) {
17486 QUnit.module(name, {
17487 setup : function () {
17488 moment.locale('en');
17489 moment.createFromInputFallback = function () {
17490 throw new Error('input not handled by moment');
17491 };
17492 if (lifecycle && lifecycle.setup) {
17493 lifecycle.setup();
17494 }
17495 },
17496 teardown : function () {
17497 if (lifecycle && lifecycle.teardown) {
17498 lifecycle.teardown();
17499 }
17500 }
17501 });
17502 }
17503
17504 function localeModule (name, lifecycle) {
17505 QUnit.module('locale:' + name, {
17506 setup : function () {
17507 moment.locale(name);
17508 moment.createFromInputFallback = function () {
17509 throw new Error('input not handled by moment');
17510 };
17511 if (lifecycle && lifecycle.setup) {
17512 lifecycle.setup();
17513 }
17514 },
17515 teardown : function () {
17516 moment.locale('en');
17517 if (lifecycle && lifecycle.teardown) {
17518 lifecycle.teardown();
17519 }
17520 }
17521 });
17522 }
17523
17524 localeModule('lb');
17525
17526 test('parse', function (assert) {
17527 var tests = 'Januar Jan._Februar Febr._Mäerz Mrz._Abrëll Abr._Mee Mee_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
17528
17529 function equalTest(input, mmm, i) {
17530 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
17531 }
17532
17533 for (i = 0; i < 12; i++) {
17534 tests[i] = tests[i].split(' ');
17535 equalTest(tests[i][0], 'MMM', i);
17536 equalTest(tests[i][1], 'MMM', i);
17537 equalTest(tests[i][0], 'MMMM', i);
17538 equalTest(tests[i][1], 'MMMM', i);
17539 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17540 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17541 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
17542 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
17543 }
17544 });
17545
17546 test('format', function (assert) {
17547 var a = [
17548 ['dddd, Do MMMM YYYY, HH:mm:ss', 'Sonndeg, 14. Februar 2010, 15:25:50'],
17549 ['ddd, HH:mm', 'So., 15:25'],
17550 ['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
17551 ['YYYY YY', '2010 10'],
17552 ['D Do DD', '14 14. 14'],
17553 ['d do dddd ddd dd', '0 0. Sonndeg So. So'],
17554 ['DDD DDDo DDDD', '45 45. 045'],
17555 ['w wo ww', '6 6. 06'],
17556 ['h hh', '3 03'],
17557 ['H HH', '15 15'],
17558 ['m mm', '25 25'],
17559 ['s ss', '50 50'],
17560 ['a A', 'pm PM'],
17561 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
17562 ['LTS', '15:25:50 Auer'],
17563 ['L', '14.02.2010'],
17564 ['LL', '14. Februar 2010'],
17565 ['LLL', '14. Februar 2010 15:25 Auer'],
17566 ['LLLL', 'Sonndeg, 14. Februar 2010 15:25 Auer'],
17567 ['l', '14.2.2010'],
17568 ['ll', '14. Febr. 2010'],
17569 ['lll', '14. Febr. 2010 15:25 Auer'],
17570 ['llll', 'So., 14. Febr. 2010 15:25 Auer']
17571 ],
17572 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
17573 i;
17574 for (i = 0; i < a.length; i++) {
17575 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
17576 }
17577 });
17578
17579 test('format month', function (assert) {
17580 var expected = 'Januar Jan._Februar Febr._Mäerz Mrz._Abrëll Abr._Mee Mee_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
17581 for (i = 0; i < expected.length; i++) {
17582 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
17583 }
17584 });
17585
17586 test('format week', function (assert) {
17587 var expected = 'Sonndeg So. So_Méindeg Mé. Mé_Dënschdeg Dë. Dë_Mëttwoch Më. Më_Donneschdeg Do. Do_Freideg Fr. Fr_Samschdeg Sa. Sa'.split('_'), i;
17588 for (i = 0; i < expected.length; i++) {
17589 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
17590 }
17591 });
17592
17593 test('from', function (assert) {
17594 var start = moment([2007, 1, 28]);
17595 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'e puer Sekonnen', '44 seconds = a few seconds');
17596 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eng Minutt', '45 seconds = a minute');
17597 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eng Minutt', '89 seconds = a minute');
17598 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 Minutten', '90 seconds = 2 minutes');
17599 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 Minutten', '44 minutes = 44 minutes');
17600 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'eng Stonn', '45 minutes = an hour');
17601 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'eng Stonn', '89 minutes = an hour');
17602 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 Stonnen', '90 minutes = 2 hours');
17603 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 Stonnen', '5 hours = 5 hours');
17604 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 Stonnen', '21 hours = 21 hours');
17605 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'een Dag', '22 hours = a day');
17606 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'een Dag', '35 hours = a day');
17607 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 Deeg', '36 hours = 2 days');
17608 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'een Dag', '1 day = a day');
17609 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 Deeg', '5 days = 5 days');
17610 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 Deeg', '25 days = 25 days');
17611 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ee Mount', '26 days = a month');
17612 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ee Mount', '30 days = a month');
17613 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ee Mount', '43 days = a month');
17614 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 Méint', '46 days = 2 months');
17615 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 Méint', '75 days = 2 months');
17616 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 Méint', '76 days = 3 months');
17617 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ee Mount', '1 month = a month');
17618 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 Méint', '5 months = 5 months');
17619 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ee Joer', '345 days = a year');
17620 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 Joer', '548 days = 2 years');
17621 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ee Joer', '1 year = a year');
17622 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 Joer', '5 years = 5 years');
17623 });
17624
17625 test('suffix', function (assert) {
17626 assert.equal(moment(30000).from(0), 'an e puer Sekonnen', 'prefix');
17627 assert.equal(moment(0).from(30000), 'virun e puer Sekonnen', 'suffix');
17628 });
17629
17630 test('fromNow', function (assert) {
17631 assert.equal(moment().add({s: 30}).fromNow(), 'an e puer Sekonnen', 'in a few seconds');
17632 assert.equal(moment().add({d: 1}).fromNow(), 'an engem Dag', 'in one day');
17633 assert.equal(moment().add({d: 2}).fromNow(), 'an 2 Deeg', 'in 2 days');
17634 assert.equal(moment().add({d: 3}).fromNow(), 'an 3 Deeg', 'in 3 days');
17635 assert.equal(moment().add({d: 4}).fromNow(), 'a 4 Deeg', 'in 4 days');
17636 assert.equal(moment().add({d: 5}).fromNow(), 'a 5 Deeg', 'in 5 days');
17637 assert.equal(moment().add({d: 6}).fromNow(), 'a 6 Deeg', 'in 6 days');
17638 assert.equal(moment().add({d: 7}).fromNow(), 'a 7 Deeg', 'in 7 days');
17639 assert.equal(moment().add({d: 8}).fromNow(), 'an 8 Deeg', 'in 8 days');
17640 assert.equal(moment().add({d: 9}).fromNow(), 'an 9 Deeg', 'in 9 days');
17641 assert.equal(moment().add({d: 10}).fromNow(), 'an 10 Deeg', 'in 10 days');
17642 assert.equal(moment().add({y: 100}).fromNow(), 'an 100 Joer', 'in 100 years');
17643 assert.equal(moment().add({y: 400}).fromNow(), 'a 400 Joer', 'in 400 years');
17644 });
17645
17646 test('calendar last week', function (assert) {
17647 var i, m, weekday, datestring;
17648 for (i = 2; i < 7; i++) {
17649 m = moment().subtract({d: i});
17650
17651 // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday)
17652 weekday = parseInt(m.format('d'), 10);
17653 datestring = (weekday === 2 || weekday === 4 ? '[Leschten] dddd [um] LT' : '[Leschte] dddd [um] LT');
17654
17655 assert.equal(m.calendar(), m.format(datestring), 'Today + ' + i + ' days current time');
17656 m.hours(0).minutes(0).seconds(0).milliseconds(0);
17657 assert.equal(m.calendar(), m.format(datestring), 'Today + ' + i + ' days beginning of day');
17658 m.hours(23).minutes(59).seconds(59).milliseconds(999);
17659 assert.equal(m.calendar(), m.format(datestring), 'Today + ' + i + ' days end of day');
17660 }
17661 });
17662
17663 test('lenient ordinal parsing', function (assert) {
17664 var i, ordinalStr, testMoment;
17665 for (i = 1; i <= 31; ++i) {
17666 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
17667 testMoment = moment(ordinalStr, 'YYYY MM Do');
17668 assert.equal(testMoment.year(), 2014,
17669 'lenient ordinal parsing ' + i + ' year check');
17670 assert.equal(testMoment.month(), 0,
17671 'lenient ordinal parsing ' + i + ' month check');
17672 assert.equal(testMoment.date(), i,
17673 'lenient ordinal parsing ' + i + ' date check');
17674 }
17675 });
17676
17677 test('lenient ordinal parsing of number', function (assert) {
17678 var i, testMoment;
17679 for (i = 1; i <= 31; ++i) {
17680 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
17681 assert.equal(testMoment.year(), 2014,
17682 'lenient ordinal parsing of number ' + i + ' year check');
17683 assert.equal(testMoment.month(), 0,
17684 'lenient ordinal parsing of number ' + i + ' month check');
17685 assert.equal(testMoment.date(), i,
17686 'lenient ordinal parsing of number ' + i + ' date check');
17687 }
17688 });
17689
17690 test('strict ordinal parsing', function (assert) {
17691 var i, ordinalStr, testMoment;
17692 for (i = 1; i <= 31; ++i) {
17693 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
17694 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
17695 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
17696 }
17697 });
17698
17699 }));
17700
17701 (function (global, factory) {
17702 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
17703 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
17704 factory(global.moment)
17705 }(this, function (moment) { 'use strict';
17706
17707 /*global QUnit:false*/
17708
17709 var test = QUnit.test;
17710
17711 function module (name, lifecycle) {
17712 QUnit.module(name, {
17713 setup : function () {
17714 moment.locale('en');
17715 moment.createFromInputFallback = function () {
17716 throw new Error('input not handled by moment');
17717 };
17718 if (lifecycle && lifecycle.setup) {
17719 lifecycle.setup();
17720 }
17721 },
17722 teardown : function () {
17723 if (lifecycle && lifecycle.teardown) {
17724 lifecycle.teardown();
17725 }
17726 }
17727 });
17728 }
17729
17730 function localeModule (name, lifecycle) {
17731 QUnit.module('locale:' + name, {
17732 setup : function () {
17733 moment.locale(name);
17734 moment.createFromInputFallback = function () {
17735 throw new Error('input not handled by moment');
17736 };
17737 if (lifecycle && lifecycle.setup) {
17738 lifecycle.setup();
17739 }
17740 },
17741 teardown : function () {
17742 moment.locale('en');
17743 if (lifecycle && lifecycle.teardown) {
17744 lifecycle.teardown();
17745 }
17746 }
17747 });
17748 }
17749
17750 localeModule('lt');
17751
17752 test('parse', function (assert) {
17753 var tests = 'sausis sau_vasaris vas_kovas kov_balandis bal_gegužė geg_birželis bir_liepa lie_rugpjūtis rgp_rugsėjis rgs_spalis spa_lapkritis lap_gruodis grd'.split('_'), i;
17754 function equalTest(input, mmm, i) {
17755 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
17756 }
17757 for (i = 0; i < 12; i++) {
17758 tests[i] = tests[i].split(' ');
17759 equalTest(tests[i][0], 'MMM', i);
17760 equalTest(tests[i][1], 'MMM', i);
17761 equalTest(tests[i][0], 'MMMM', i);
17762 equalTest(tests[i][1], 'MMMM', i);
17763 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17764 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17765 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
17766 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
17767 }
17768 });
17769
17770 test('format', function (assert) {
17771 var a = [
17772 ['dddd, Do MMMM YYYY, h:mm:ss a', 'sekmadienis, 14-oji vasario 2010, 3:25:50 pm'],
17773 ['ddd, hA', 'Sek, 3PM'],
17774 ['M Mo MM MMMM MMM', '2 2-oji 02 vasaris vas'],
17775 ['YYYY YY', '2010 10'],
17776 ['D Do DD', '14 14-oji 14'],
17777 ['d do dddd ddd dd', '0 0-oji sekmadienis Sek S'],
17778 ['DDD DDDo DDDD', '45 45-oji 045'],
17779 ['w wo ww', '6 6-oji 06'],
17780 ['h hh', '3 03'],
17781 ['H HH', '15 15'],
17782 ['m mm', '25 25'],
17783 ['s ss', '50 50'],
17784 ['a A', 'pm PM'],
17785 ['DDDo [metų diena]', '45-oji metų diena'],
17786 ['LTS', '15:25:50'],
17787 ['L', '2010-02-14'],
17788 ['LL', '2010 m. vasaris 14 d.'],
17789 ['LLL', '2010 m. vasaris 14 d., 15:25 val.'],
17790 ['LLLL', '2010 m. vasaris 14 d., sekmadienis, 15:25 val.'],
17791 ['l', '2010-02-14'],
17792 ['ll', '2010 m. vasaris 14 d.'],
17793 ['lll', '2010 m. vasaris 14 d., 15:25 val.'],
17794 ['llll', '2010 m. vasaris 14 d., Sek, 15:25 val.']
17795 ],
17796 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
17797 i;
17798 for (i = 0; i < a.length; i++) {
17799 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
17800 }
17801 });
17802
17803 test('format ordinal', function (assert) {
17804 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-oji', '1-oji');
17805 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-oji', '2-oji');
17806 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-oji', '3-oji');
17807 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-oji', '4-oji');
17808 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-oji', '5-oji');
17809 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-oji', '6-oji');
17810 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-oji', '7-oji');
17811 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-oji', '8-oji');
17812 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-oji', '9-oji');
17813 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-oji', '10-oji');
17814
17815 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-oji', '11-oji');
17816 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-oji', '12-oji');
17817 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-oji', '13-oji');
17818 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-oji', '14-oji');
17819 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-oji', '15-oji');
17820 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-oji', '16-oji');
17821 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-oji', '17-oji');
17822 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-oji', '18-oji');
17823 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-oji', '19-oji');
17824 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-oji', '20-oji');
17825
17826 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-oji', '21-oji');
17827 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-oji', '22-oji');
17828 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-oji', '23-oji');
17829 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-oji', '24-oji');
17830 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-oji', '25-oji');
17831 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-oji', '26-oji');
17832 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-oji', '27-oji');
17833 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-oji', '28-oji');
17834 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-oji', '29-oji');
17835 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-oji', '30-oji');
17836
17837 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-oji', '31-oji');
17838 });
17839
17840 test('format month', function (assert) {
17841 var expected = 'sausis sau_vasaris vas_kovas kov_balandis bal_gegužė geg_birželis bir_liepa lie_rugpjūtis rgp_rugsėjis rgs_spalis spa_lapkritis lap_gruodis grd'.split('_'), i;
17842 for (i = 0; i < expected.length; i++) {
17843 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
17844 }
17845 });
17846
17847 test('format week', function (assert) {
17848 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;
17849 for (i = 0; i < expected.length; i++) {
17850 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
17851 }
17852 });
17853
17854 test('format week on US calendar', function (assert) {
17855 // Tests, whether the weekday names are correct, even if the week does not start on Monday
17856 moment.locale('lt', {week: {dow: 0, doy: 6}});
17857 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;
17858 for (i = 0; i < expected.length; i++) {
17859 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
17860 }
17861 moment.locale('lt', {week: {dow: 1, doy: 4}});
17862 });
17863
17864 test('from', function (assert) {
17865 var start = moment([2007, 1, 28]);
17866 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'kelios sekundės', '44 seconds = seconds');
17867 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minutė', '45 seconds = a minute');
17868 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minutė', '89 seconds = a minute');
17869 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutės', '90 seconds = 2 minutes');
17870 assert.equal(start.from(moment([2007, 1, 28]).add({m: 10}), true), '10 minučių', '10 minutes = 10 minutes');
17871 assert.equal(start.from(moment([2007, 1, 28]).add({m: 11}), true), '11 minučių', '11 minutes = 11 minutes');
17872 assert.equal(start.from(moment([2007, 1, 28]).add({m: 19}), true), '19 minučių', '19 minutes = 19 minutes');
17873 assert.equal(start.from(moment([2007, 1, 28]).add({m: 20}), true), '20 minučių', '20 minutes = 20 minutes');
17874 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutės', '44 minutes = 44 minutes');
17875 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'valanda', '45 minutes = an hour');
17876 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'valanda', '89 minutes = an hour');
17877 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 valandos', '90 minutes = 2 hours');
17878 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 valandos', '5 hours = 5 hours');
17879 assert.equal(start.from(moment([2007, 1, 28]).add({h: 10}), true), '10 valandų', '10 hours = 10 hours');
17880 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 valandos', '21 hours = 21 hours');
17881 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'diena', '22 hours = a day');
17882 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'diena', '35 hours = a day');
17883 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dienos', '36 hours = 2 days');
17884 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'diena', '1 day = a day');
17885 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dienos', '5 days = 5 days');
17886 assert.equal(start.from(moment([2007, 1, 28]).add({d: 10}), true), '10 dienų', '10 days = 10 days');
17887 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dienos', '25 days = 25 days');
17888 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mėnuo', '26 days = a month');
17889 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mėnuo', '30 days = a month');
17890 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mėnuo', '43 days = a month');
17891 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mėnesiai', '46 days = 2 months');
17892 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mėnesiai', '75 days = 2 months');
17893 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mėnesiai', '76 days = 3 months');
17894 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mėnuo', '1 month = a month');
17895 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mėnesiai', '5 months = 5 months');
17896 assert.equal(start.from(moment([2007, 1, 28]).add({M: 10}), true), '10 mėnesių', '10 months = 10 months');
17897 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'metai', '345 days = a year');
17898 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 metai', '548 days = 2 years');
17899 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'metai', '1 year = a year');
17900 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 metai', '5 years = 5 years');
17901 });
17902
17903 test('suffix', function (assert) {
17904 assert.equal(moment(30000).from(0), 'po kelių sekundžių', 'prefix');
17905 assert.equal(moment(0).from(30000), 'prieš kelias sekundes', 'suffix');
17906 });
17907
17908 test('now from now', function (assert) {
17909 assert.equal(moment().fromNow(), 'prieš kelias sekundes', 'now from now should display as in the past');
17910 });
17911
17912 test('fromNow', function (assert) {
17913 assert.equal(moment().add({s: 30}).fromNow(), 'po kelių sekundžių', 'in seconds');
17914 assert.equal(moment().add({d: 5}).fromNow(), 'po 5 dienų', 'in 5 days');
17915 });
17916
17917 test('calendar day', function (assert) {
17918 var a = moment().hours(2).minutes(0).seconds(0);
17919
17920 assert.equal(moment(a).calendar(), 'Šiandien 02:00', 'today at the same time');
17921 assert.equal(moment(a).add({m: 25}).calendar(), 'Šiandien 02:25', 'Now plus 25 min');
17922 assert.equal(moment(a).add({h: 1}).calendar(), 'Šiandien 03:00', 'Now plus 1 hour');
17923 assert.equal(moment(a).add({d: 1}).calendar(), 'Rytoj 02:00', 'tomorrow at the same time');
17924 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šiandien 01:00', 'Now minus 1 hour');
17925 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar 02:00', 'yesterday at the same time');
17926 });
17927
17928 test('calendar next week', function (assert) {
17929 var i, m;
17930 for (i = 2; i < 7; i++) {
17931 m = moment().add({d: i});
17932 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days current time');
17933 m.hours(0).minutes(0).seconds(0).milliseconds(0);
17934 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days beginning of day');
17935 m.hours(23).minutes(59).seconds(59).milliseconds(999);
17936 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days end of day');
17937 }
17938 });
17939
17940 test('calendar last week', function (assert) {
17941 var i, m;
17942 for (i = 2; i < 7; i++) {
17943 m = moment().subtract({d: i});
17944 assert.equal(m.calendar(), m.format('[Praėjusį] dddd LT'), 'Today - ' + i + ' days current time');
17945 m.hours(0).minutes(0).seconds(0).milliseconds(0);
17946 assert.equal(m.calendar(), m.format('[Praėjusį] dddd LT'), 'Today - ' + i + ' days beginning of day');
17947 m.hours(23).minutes(59).seconds(59).milliseconds(999);
17948 assert.equal(m.calendar(), m.format('[Praėjusį] dddd LT'), 'Today - ' + i + ' days end of day');
17949 }
17950 });
17951
17952 test('calendar all else', function (assert) {
17953 var weeksAgo = moment().subtract({w: 1}),
17954 weeksFromNow = moment().add({w: 1});
17955
17956 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
17957 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
17958
17959 weeksAgo = moment().subtract({w: 2});
17960 weeksFromNow = moment().add({w: 2});
17961
17962 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
17963 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
17964 });
17965
17966 test('weeks year starting sunday', function (assert) {
17967 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
17968 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
17969 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
17970 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
17971 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
17972 });
17973
17974 test('weeks year starting monday', function (assert) {
17975 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
17976 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
17977 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
17978 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
17979 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
17980 });
17981
17982 test('weeks year starting tuesday', function (assert) {
17983 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
17984 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
17985 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
17986 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
17987 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
17988 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
17989 });
17990
17991 test('weeks year starting wednesday', function (assert) {
17992 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
17993 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
17994 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
17995 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
17996 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
17997 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
17998 });
17999
18000 test('weeks year starting thursday', function (assert) {
18001 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
18002 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
18003 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
18004 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
18005 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
18006 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
18007 });
18008
18009 test('weeks year starting friday', function (assert) {
18010 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
18011 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
18012 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
18013 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
18014 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
18015 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
18016 });
18017
18018 test('weeks year starting saturday', function (assert) {
18019 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
18020 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
18021 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
18022 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
18023 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
18024 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
18025 });
18026
18027 test('weeks year starting sunday formatted', function (assert) {
18028 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52-oji', 'Jan 1 2012 should be week 52');
18029 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1-oji', 'Jan 2 2012 should be week 1');
18030 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1-oji', 'Jan 8 2012 should be week 1');
18031 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2-oji', 'Jan 9 2012 should be week 2');
18032 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2-oji', 'Jan 15 2012 should be week 2');
18033 });
18034
18035 test('lenient ordinal parsing', function (assert) {
18036 var i, ordinalStr, testMoment;
18037 for (i = 1; i <= 31; ++i) {
18038 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
18039 testMoment = moment(ordinalStr, 'YYYY MM Do');
18040 assert.equal(testMoment.year(), 2014,
18041 'lenient ordinal parsing ' + i + ' year check');
18042 assert.equal(testMoment.month(), 0,
18043 'lenient ordinal parsing ' + i + ' month check');
18044 assert.equal(testMoment.date(), i,
18045 'lenient ordinal parsing ' + i + ' date check');
18046 }
18047 });
18048
18049 test('lenient ordinal parsing of number', function (assert) {
18050 var i, testMoment;
18051 for (i = 1; i <= 31; ++i) {
18052 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
18053 assert.equal(testMoment.year(), 2014,
18054 'lenient ordinal parsing of number ' + i + ' year check');
18055 assert.equal(testMoment.month(), 0,
18056 'lenient ordinal parsing of number ' + i + ' month check');
18057 assert.equal(testMoment.date(), i,
18058 'lenient ordinal parsing of number ' + i + ' date check');
18059 }
18060 });
18061
18062 test('strict ordinal parsing', function (assert) {
18063 var i, ordinalStr, testMoment;
18064 for (i = 1; i <= 31; ++i) {
18065 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
18066 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
18067 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
18068 }
18069 });
18070
18071 }));
18072
18073 (function (global, factory) {
18074 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
18075 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
18076 factory(global.moment)
18077 }(this, function (moment) { 'use strict';
18078
18079 /*global QUnit:false*/
18080
18081 var test = QUnit.test;
18082
18083 function module (name, lifecycle) {
18084 QUnit.module(name, {
18085 setup : function () {
18086 moment.locale('en');
18087 moment.createFromInputFallback = function () {
18088 throw new Error('input not handled by moment');
18089 };
18090 if (lifecycle && lifecycle.setup) {
18091 lifecycle.setup();
18092 }
18093 },
18094 teardown : function () {
18095 if (lifecycle && lifecycle.teardown) {
18096 lifecycle.teardown();
18097 }
18098 }
18099 });
18100 }
18101
18102 function localeModule (name, lifecycle) {
18103 QUnit.module('locale:' + name, {
18104 setup : function () {
18105 moment.locale(name);
18106 moment.createFromInputFallback = function () {
18107 throw new Error('input not handled by moment');
18108 };
18109 if (lifecycle && lifecycle.setup) {
18110 lifecycle.setup();
18111 }
18112 },
18113 teardown : function () {
18114 moment.locale('en');
18115 if (lifecycle && lifecycle.teardown) {
18116 lifecycle.teardown();
18117 }
18118 }
18119 });
18120 }
18121
18122 localeModule('lv');
18123
18124 test('parse', function (assert) {
18125 var tests = 'janvāris jan_februāris feb_marts mar_aprīlis apr_maijs mai_jūnijs jūn_jūlijs jūl_augusts aug_septembris sep_oktobris okt_novembris nov_decembris dec'.split('_'), i;
18126 function equalTest(input, mmm, i) {
18127 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
18128 }
18129 for (i = 0; i < 12; i++) {
18130 tests[i] = tests[i].split(' ');
18131 equalTest(tests[i][0], 'MMM', i);
18132 equalTest(tests[i][1], 'MMM', i);
18133 equalTest(tests[i][0], 'MMMM', i);
18134 equalTest(tests[i][1], 'MMMM', i);
18135 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18136 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18137 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18138 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
18139 }
18140 });
18141
18142 test('format', function (assert) {
18143 var a = [
18144 ['dddd, Do MMMM YYYY, h:mm:ss a', 'svētdiena, 14. februāris 2010, 3:25:50 pm'],
18145 ['ddd, hA', 'Sv, 3PM'],
18146 ['M Mo MM MMMM MMM', '2 2. 02 februāris feb'],
18147 ['YYYY YY', '2010 10'],
18148 ['D Do DD', '14 14. 14'],
18149 ['d do dddd ddd dd', '0 0. svētdiena Sv Sv'],
18150 ['DDD DDDo DDDD', '45 45. 045'],
18151 ['w wo ww', '6 6. 06'],
18152 ['h hh', '3 03'],
18153 ['H HH', '15 15'],
18154 ['m mm', '25 25'],
18155 ['s ss', '50 50'],
18156 ['a A', 'pm PM'],
18157 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
18158 ['LTS', '15:25:50'],
18159 ['L', '14.02.2010.'],
18160 ['LL', '2010. gada 14. februāris'],
18161 ['LLL', '2010. gada 14. februāris, 15:25'],
18162 ['LLLL', '2010. gada 14. februāris, svētdiena, 15:25'],
18163 ['l', '14.2.2010.'],
18164 ['ll', '2010. gada 14. feb'],
18165 ['lll', '2010. gada 14. feb, 15:25'],
18166 ['llll', '2010. gada 14. feb, Sv, 15:25']
18167 ],
18168 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
18169 i;
18170 for (i = 0; i < a.length; i++) {
18171 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
18172 }
18173 });
18174
18175 test('format ordinal', function (assert) {
18176 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
18177 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
18178 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
18179 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
18180 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
18181 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
18182 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
18183 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
18184 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
18185 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
18186
18187 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
18188 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
18189 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
18190 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
18191 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
18192 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
18193 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
18194 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
18195 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
18196 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
18197
18198 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
18199 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
18200 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
18201 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
18202 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
18203 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
18204 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
18205 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
18206 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
18207 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
18208
18209 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
18210 });
18211
18212 test('format month', function (assert) {
18213 var expected = 'janvāris jan_februāris feb_marts mar_aprīlis apr_maijs mai_jūnijs jūn_jūlijs jūl_augusts aug_septembris sep_oktobris okt_novembris nov_decembris dec'.split('_'), i;
18214 for (i = 0; i < expected.length; i++) {
18215 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
18216 }
18217 });
18218
18219 test('format week', function (assert) {
18220 var expected = 'svētdiena Sv Sv_pirmdiena P P_otrdiena O O_trešdiena T T_ceturtdiena C C_piektdiena Pk Pk_sestdiena S S'.split('_'), i;
18221 for (i = 0; i < expected.length; i++) {
18222 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
18223 }
18224 });
18225
18226 // Includes testing the cases of withoutSuffix = true and false.
18227 test('from', function (assert) {
18228 var start = moment([2007, 1, 28]);
18229 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'dažas sekundes', '44 seconds = seconds');
18230 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), false), 'pirms dažām sekundēm', '44 seconds with suffix = seconds ago');
18231 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minūte', '45 seconds = a minute');
18232 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), false), 'pirms minūtes', '45 seconds with suffix = a minute ago');
18233 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minūte', '89 seconds = a minute');
18234 assert.equal(start.from(moment([2007, 1, 28]).add({s: -89}), false), 'pēc minūtes', '89 seconds with suffix/prefix = in a minute');
18235 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minūtes', '90 seconds = 2 minutes');
18236 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), false), 'pirms 2 minūtēm', '90 seconds with suffix = 2 minutes ago');
18237 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minūtes', '44 minutes = 44 minutes');
18238 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), false), 'pirms 44 minūtēm', '44 minutes with suffix = 44 minutes ago');
18239 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'stunda', '45 minutes = an hour');
18240 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), false), 'pirms stundas', '45 minutes with suffix = an hour ago');
18241 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'stunda', '89 minutes = an hour');
18242 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 stundas', '90 minutes = 2 hours');
18243 assert.equal(start.from(moment([2007, 1, 28]).add({m: -90}), false), 'pēc 2 stundām', '90 minutes with suffix = in 2 hours');
18244 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 stundas', '5 hours = 5 hours');
18245 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), false), 'pirms 5 stundām', '5 hours with suffix = 5 hours ago');
18246 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 stunda', '21 hours = 21 hours');
18247 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), false), 'pirms 21 stundas', '21 hours with suffix = 21 hours ago');
18248 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'diena', '22 hours = a day');
18249 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), false), 'pirms dienas', '22 hours with suffix = a day ago');
18250 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'diena', '35 hours = a day');
18251 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dienas', '36 hours = 2 days');
18252 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), false), 'pirms 2 dienām', '36 hours with suffix = 2 days ago');
18253 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'diena', '1 day = a day');
18254 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dienas', '5 days = 5 days');
18255 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), false), 'pirms 5 dienām', '5 days with suffix = 5 days ago');
18256 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dienas', '25 days = 25 days');
18257 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), false), 'pirms 25 dienām', '25 days with suffix = 25 days ago');
18258 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mēnesis', '26 days = a month');
18259 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), false), 'pirms mēneša', '26 days with suffix = a month ago');
18260 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mēnesis', '30 days = a month');
18261 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mēnesis', '43 days = a month');
18262 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mēneši', '46 days = 2 months');
18263 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), false), 'pirms 2 mēnešiem', '46 days with suffix = 2 months ago');
18264 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mēneši', '75 days = 2 months');
18265 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mēneši', '76 days = 3 months');
18266 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), false), 'pirms 3 mēnešiem', '76 days with suffix = 3 months ago');
18267 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mēnesis', '1 month = a month');
18268 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mēneši', '5 months = 5 months');
18269 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), false), 'pirms 5 mēnešiem', '5 months with suffix = 5 months ago');
18270 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'gads', '345 days = a year');
18271 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), false), 'pirms gada', '345 days with suffix = a year ago');
18272 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 gadi', '548 days = 2 years');
18273 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), false), 'pirms 2 gadiem', '548 days with suffix = 2 years ago');
18274 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'gads', '1 year = a year');
18275 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 gadi', '5 years = 5 years');
18276 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), false), 'pirms 5 gadiem', '5 years with suffix = 5 years ago');
18277 });
18278
18279 test('suffix', function (assert) {
18280 assert.equal(moment(30000).from(0), 'pēc dažām sekundēm', 'prefix');
18281 assert.equal(moment(0).from(30000), 'pirms dažām sekundēm', 'suffix');
18282 });
18283
18284 test('now from now', function (assert) {
18285 assert.equal(moment().fromNow(), 'pirms dažām sekundēm', 'now from now should display as in the past');
18286 });
18287
18288 test('fromNow', function (assert) {
18289 assert.equal(moment().add({s: 30}).fromNow(), 'pēc dažām sekundēm', 'in seconds');
18290 assert.equal(moment().add({d: 5}).fromNow(), 'pēc 5 dienām', 'in 5 days');
18291 });
18292
18293 test('calendar day', function (assert) {
18294 var a = moment().hours(2).minutes(0).seconds(0);
18295
18296 assert.equal(moment(a).calendar(), 'Šodien pulksten 02:00', 'today at the same time');
18297 assert.equal(moment(a).add({m: 25}).calendar(), 'Šodien pulksten 02:25', 'Now plus 25 min');
18298 assert.equal(moment(a).add({h: 1}).calendar(), 'Šodien pulksten 03:00', 'Now plus 1 hour');
18299 assert.equal(moment(a).add({d: 1}).calendar(), 'Rīt pulksten 02:00', 'tomorrow at the same time');
18300 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šodien pulksten 01:00', 'Now minus 1 hour');
18301 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar pulksten 02:00', 'yesterday at the same time');
18302 });
18303
18304 test('calendar next week', function (assert) {
18305 var i, m;
18306 for (i = 2; i < 7; i++) {
18307 m = moment().add({d: i});
18308 assert.equal(m.calendar(), m.format('dddd [pulksten] LT'), 'Today + ' + i + ' days current time');
18309 m.hours(0).minutes(0).seconds(0).milliseconds(0);
18310 assert.equal(m.calendar(), m.format('dddd [pulksten] LT'), 'Today + ' + i + ' days beginning of day');
18311 m.hours(23).minutes(59).seconds(59).milliseconds(999);
18312 assert.equal(m.calendar(), m.format('dddd [pulksten] LT'), 'Today + ' + i + ' days end of day');
18313 }
18314 });
18315
18316 test('calendar last week', function (assert) {
18317 var i, m;
18318 for (i = 2; i < 7; i++) {
18319 m = moment().subtract({d: i});
18320 assert.equal(m.calendar(), m.format('[Pagājušā] dddd [pulksten] LT'), 'Today - ' + i + ' days current time');
18321 m.hours(0).minutes(0).seconds(0).milliseconds(0);
18322 assert.equal(m.calendar(), m.format('[Pagājušā] dddd [pulksten] LT'), 'Today - ' + i + ' days beginning of day');
18323 m.hours(23).minutes(59).seconds(59).milliseconds(999);
18324 assert.equal(m.calendar(), m.format('[Pagājušā] dddd [pulksten] LT'), 'Today - ' + i + ' days end of day');
18325 }
18326 });
18327
18328 test('calendar all else', function (assert) {
18329 var weeksAgo = moment().subtract({w: 1}),
18330 weeksFromNow = moment().add({w: 1});
18331
18332 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
18333 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
18334
18335 weeksAgo = moment().subtract({w: 2});
18336 weeksFromNow = moment().add({w: 2});
18337
18338 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
18339 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
18340 });
18341
18342 test('weeks year starting sunday', function (assert) {
18343 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
18344 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
18345 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
18346 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
18347 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
18348 });
18349
18350 test('weeks year starting monday', function (assert) {
18351 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
18352 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
18353 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
18354 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
18355 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
18356 });
18357
18358 test('weeks year starting tuesday', function (assert) {
18359 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
18360 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
18361 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
18362 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
18363 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
18364 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
18365 });
18366
18367 test('weeks year starting wednesday', function (assert) {
18368 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
18369 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
18370 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
18371 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
18372 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
18373 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
18374 });
18375
18376 test('weeks year starting thursday', function (assert) {
18377 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
18378 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
18379 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
18380 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
18381 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
18382 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
18383 });
18384
18385 test('weeks year starting friday', function (assert) {
18386 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
18387 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
18388 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
18389 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
18390 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
18391 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
18392 });
18393
18394 test('weeks year starting saturday', function (assert) {
18395 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
18396 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
18397 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
18398 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
18399 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
18400 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
18401 });
18402
18403 test('weeks year starting sunday formatted', function (assert) {
18404 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
18405 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
18406 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
18407 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
18408 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
18409 });
18410
18411 test('lenient ordinal parsing', function (assert) {
18412 var i, ordinalStr, testMoment;
18413 for (i = 1; i <= 31; ++i) {
18414 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
18415 testMoment = moment(ordinalStr, 'YYYY MM Do');
18416 assert.equal(testMoment.year(), 2014,
18417 'lenient ordinal parsing ' + i + ' year check');
18418 assert.equal(testMoment.month(), 0,
18419 'lenient ordinal parsing ' + i + ' month check');
18420 assert.equal(testMoment.date(), i,
18421 'lenient ordinal parsing ' + i + ' date check');
18422 }
18423 });
18424
18425 test('lenient ordinal parsing of number', function (assert) {
18426 var i, testMoment;
18427 for (i = 1; i <= 31; ++i) {
18428 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
18429 assert.equal(testMoment.year(), 2014,
18430 'lenient ordinal parsing of number ' + i + ' year check');
18431 assert.equal(testMoment.month(), 0,
18432 'lenient ordinal parsing of number ' + i + ' month check');
18433 assert.equal(testMoment.date(), i,
18434 'lenient ordinal parsing of number ' + i + ' date check');
18435 }
18436 });
18437
18438 test('strict ordinal parsing', function (assert) {
18439 var i, ordinalStr, testMoment;
18440 for (i = 1; i <= 31; ++i) {
18441 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
18442 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
18443 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
18444 }
18445 });
18446
18447 }));
18448
18449 (function (global, factory) {
18450 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
18451 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
18452 factory(global.moment)
18453 }(this, function (moment) { 'use strict';
18454
18455 /*global QUnit:false*/
18456
18457 var test = QUnit.test;
18458
18459 function module (name, lifecycle) {
18460 QUnit.module(name, {
18461 setup : function () {
18462 moment.locale('en');
18463 moment.createFromInputFallback = function () {
18464 throw new Error('input not handled by moment');
18465 };
18466 if (lifecycle && lifecycle.setup) {
18467 lifecycle.setup();
18468 }
18469 },
18470 teardown : function () {
18471 if (lifecycle && lifecycle.teardown) {
18472 lifecycle.teardown();
18473 }
18474 }
18475 });
18476 }
18477
18478 function localeModule (name, lifecycle) {
18479 QUnit.module('locale:' + name, {
18480 setup : function () {
18481 moment.locale(name);
18482 moment.createFromInputFallback = function () {
18483 throw new Error('input not handled by moment');
18484 };
18485 if (lifecycle && lifecycle.setup) {
18486 lifecycle.setup();
18487 }
18488 },
18489 teardown : function () {
18490 moment.locale('en');
18491 if (lifecycle && lifecycle.teardown) {
18492 lifecycle.teardown();
18493 }
18494 }
18495 });
18496 }
18497
18498 localeModule('me');
18499
18500 test('parse', function (assert) {
18501 var tests = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
18502 i;
18503 function equalTest(input, mmm, i) {
18504 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
18505 }
18506 for (i = 0; i < 12; i++) {
18507 tests[i] = tests[i].split(' ');
18508 equalTest(tests[i][0], 'MMM', i);
18509 equalTest(tests[i][1], 'MMM', i);
18510 equalTest(tests[i][0], 'MMMM', i);
18511 equalTest(tests[i][1], 'MMMM', i);
18512 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18513 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18514 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18515 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
18516 }
18517 });
18518
18519 test('format', function (assert) {
18520 var a = [
18521 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedjelja, 14. februar 2010, 3:25:50 pm'],
18522 ['ddd, hA', 'ned., 3PM'],
18523 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
18524 ['YYYY YY', '2010 10'],
18525 ['D Do DD', '14 14. 14'],
18526 ['d do dddd ddd dd', '0 0. nedjelja ned. ne'],
18527 ['DDD DDDo DDDD', '45 45. 045'],
18528 ['w wo ww', '7 7. 07'],
18529 ['h hh', '3 03'],
18530 ['H HH', '15 15'],
18531 ['m mm', '25 25'],
18532 ['s ss', '50 50'],
18533 ['a A', 'pm PM'],
18534 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
18535 ['LTS', '15:25:50'],
18536 ['L', '14. 02. 2010'],
18537 ['LL', '14. februar 2010'],
18538 ['LLL', '14. februar 2010 15:25'],
18539 ['LLLL', 'nedjelja, 14. februar 2010 15:25'],
18540 ['l', '14. 2. 2010'],
18541 ['ll', '14. feb. 2010'],
18542 ['lll', '14. feb. 2010 15:25'],
18543 ['llll', 'ned., 14. feb. 2010 15:25']
18544 ],
18545 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
18546 i;
18547 for (i = 0; i < a.length; i++) {
18548 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
18549 }
18550 });
18551
18552 test('format ordinal', function (assert) {
18553 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
18554 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
18555 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
18556 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
18557 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
18558 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
18559 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
18560 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
18561 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
18562 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
18563
18564 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
18565 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
18566 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
18567 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
18568 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
18569 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
18570 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
18571 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
18572 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
18573 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
18574
18575 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
18576 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
18577 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
18578 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
18579 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
18580 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
18581 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
18582 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
18583 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
18584 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
18585
18586 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
18587 });
18588
18589 test('format month', function (assert) {
18590 var expected = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
18591 i;
18592 for (i = 0; i < expected.length; i++) {
18593 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
18594 }
18595 });
18596
18597 test('format week', function (assert) {
18598 var expected = 'nedjelja ned. ne_ponedjeljak pon. po_utorak uto. ut_srijeda sri. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'),
18599 i;
18600 for (i = 0; i < expected.length; i++) {
18601 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
18602 }
18603 });
18604
18605 test('from', function (assert) {
18606 var start = moment([2007, 1, 28]);
18607 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nekoliko sekundi', '44 seconds = a few seconds');
18608 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedan minut', '45 seconds = a minute');
18609 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedan minut', '89 seconds = a minute');
18610 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuta', '90 seconds = 2 minutes');
18611 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
18612 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
18613 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
18614 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
18615 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
18616 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
18617 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
18618 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
18619 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
18620 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
18621 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
18622 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
18623 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mjesec', '26 days = a month');
18624 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mjesec', '30 days = a month');
18625 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mjesec', '43 days = a month');
18626 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mjeseca', '46 days = 2 months');
18627 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mjeseca', '75 days = 2 months');
18628 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mjeseca', '76 days = 3 months');
18629 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mjesec', '1 month = a month');
18630 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mjeseci', '5 months = 5 months');
18631 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
18632 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
18633 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
18634 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
18635 });
18636
18637 test('suffix', function (assert) {
18638 assert.equal(moment(30000).from(0), 'za nekoliko sekundi', 'prefix');
18639 assert.equal(moment(0).from(30000), 'prije nekoliko sekundi', 'prefix');
18640 });
18641
18642 test('now from now', function (assert) {
18643 assert.equal(moment().fromNow(), 'prije nekoliko sekundi', 'now from now should display as in the past');
18644 });
18645
18646 test('fromNow', function (assert) {
18647 assert.equal(moment().add({s: 30}).fromNow(), 'za nekoliko sekundi', 'in a few seconds');
18648 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
18649 });
18650
18651 test('calendar day', function (assert) {
18652 var a = moment().hours(2).minutes(0).seconds(0);
18653
18654 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
18655 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
18656 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
18657 assert.equal(moment(a).add({d: 1}).calendar(), 'sjutra u 2:00', 'tomorrow at the same time');
18658 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
18659 assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
18660 });
18661
18662 test('calendar next week', function (assert) {
18663 var i, m;
18664
18665 function makeFormat(d) {
18666 switch (d.day()) {
18667 case 0:
18668 return '[u] [nedjelju] [u] LT';
18669 case 3:
18670 return '[u] [srijedu] [u] LT';
18671 case 6:
18672 return '[u] [subotu] [u] LT';
18673 case 1:
18674 case 2:
18675 case 4:
18676 case 5:
18677 return '[u] dddd [u] LT';
18678 }
18679 }
18680
18681 for (i = 2; i < 7; i++) {
18682 m = moment().add({d: i});
18683 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
18684 m.hours(0).minutes(0).seconds(0).milliseconds(0);
18685 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
18686 m.hours(23).minutes(59).seconds(59).milliseconds(999);
18687 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
18688 }
18689 });
18690
18691 test('calendar last week', function (assert) {
18692 var i, m;
18693
18694 function makeFormat(d) {
18695 var lastWeekDay = [
18696 '[prošle] [nedjelje] [u] LT',
18697 '[prošlog] [ponedjeljka] [u] LT',
18698 '[prošlog] [utorka] [u] LT',
18699 '[prošle] [srijede] [u] LT',
18700 '[prošlog] [četvrtka] [u] LT',
18701 '[prošlog] [petka] [u] LT',
18702 '[prošle] [subote] [u] LT'
18703 ];
18704
18705 return lastWeekDay[d.day()];
18706 }
18707
18708 for (i = 2; i < 7; i++) {
18709 m = moment().subtract({d: i});
18710 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
18711 m.hours(0).minutes(0).seconds(0).milliseconds(0);
18712 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
18713 m.hours(23).minutes(59).seconds(59).milliseconds(999);
18714 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
18715 }
18716 });
18717
18718 test('calendar all else', function (assert) {
18719 var weeksAgo = moment().subtract({w: 1}),
18720 weeksFromNow = moment().add({w: 1});
18721
18722 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
18723 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
18724
18725 weeksAgo = moment().subtract({w: 2});
18726 weeksFromNow = moment().add({w: 2});
18727
18728 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
18729 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
18730 });
18731
18732 // Monday is the first day of the week.
18733 // The week that contains Jan 1st is the first week of the year.
18734
18735 test('weeks year starting sunday', function (assert) {
18736 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
18737 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
18738 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
18739 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
18740 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
18741 });
18742
18743 test('weeks year starting monday', function (assert) {
18744 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
18745 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
18746 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
18747 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
18748 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
18749 });
18750
18751 test('weeks year starting tuesday', function (assert) {
18752 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
18753 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
18754 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
18755 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
18756 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
18757 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
18758 });
18759
18760 test('weeks year starting wednesday', function (assert) {
18761 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
18762 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
18763 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
18764 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
18765 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
18766 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
18767 });
18768
18769 test('weeks year starting thursday', function (assert) {
18770 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
18771 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
18772 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
18773 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
18774 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
18775 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
18776 });
18777
18778 test('weeks year starting friday', function (assert) {
18779 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
18780 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
18781 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
18782 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
18783 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
18784 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
18785 });
18786
18787 test('weeks year starting saturday', function (assert) {
18788 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
18789 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
18790 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
18791 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
18792 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
18793 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
18794 });
18795
18796 test('weeks year starting sunday formatted', function (assert) {
18797 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
18798 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
18799 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
18800 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
18801 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
18802 });
18803
18804 test('lenient ordinal parsing', function (assert) {
18805 var i, ordinalStr, testMoment;
18806 for (i = 1; i <= 31; ++i) {
18807 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
18808 testMoment = moment(ordinalStr, 'YYYY MM Do');
18809 assert.equal(testMoment.year(), 2014,
18810 'lenient ordinal parsing ' + i + ' year check');
18811 assert.equal(testMoment.month(), 0,
18812 'lenient ordinal parsing ' + i + ' month check');
18813 assert.equal(testMoment.date(), i,
18814 'lenient ordinal parsing ' + i + ' date check');
18815 }
18816 });
18817
18818 test('lenient ordinal parsing of number', function (assert) {
18819 var i, testMoment;
18820 for (i = 1; i <= 31; ++i) {
18821 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
18822 assert.equal(testMoment.year(), 2014,
18823 'lenient ordinal parsing of number ' + i + ' year check');
18824 assert.equal(testMoment.month(), 0,
18825 'lenient ordinal parsing of number ' + i + ' month check');
18826 assert.equal(testMoment.date(), i,
18827 'lenient ordinal parsing of number ' + i + ' date check');
18828 }
18829 });
18830
18831 test('strict ordinal parsing', function (assert) {
18832 var i, ordinalStr, testMoment;
18833 for (i = 1; i <= 31; ++i) {
18834 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
18835 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
18836 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
18837 }
18838 });
18839
18840 }));
18841
18842 (function (global, factory) {
18843 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
18844 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
18845 factory(global.moment)
18846 }(this, function (moment) { 'use strict';
18847
18848 /*global QUnit:false*/
18849
18850 var test = QUnit.test;
18851
18852 function module (name, lifecycle) {
18853 QUnit.module(name, {
18854 setup : function () {
18855 moment.locale('en');
18856 moment.createFromInputFallback = function () {
18857 throw new Error('input not handled by moment');
18858 };
18859 if (lifecycle && lifecycle.setup) {
18860 lifecycle.setup();
18861 }
18862 },
18863 teardown : function () {
18864 if (lifecycle && lifecycle.teardown) {
18865 lifecycle.teardown();
18866 }
18867 }
18868 });
18869 }
18870
18871 function localeModule (name, lifecycle) {
18872 QUnit.module('locale:' + name, {
18873 setup : function () {
18874 moment.locale(name);
18875 moment.createFromInputFallback = function () {
18876 throw new Error('input not handled by moment');
18877 };
18878 if (lifecycle && lifecycle.setup) {
18879 lifecycle.setup();
18880 }
18881 },
18882 teardown : function () {
18883 moment.locale('en');
18884 if (lifecycle && lifecycle.teardown) {
18885 lifecycle.teardown();
18886 }
18887 }
18888 });
18889 }
18890
18891 localeModule('mk');
18892
18893 test('parse', function (assert) {
18894 var tests = 'јануари јан_февруари фев_март мар_април апр_мај мај_јуни јун_јули јул_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
18895 function equalTest(input, mmm, i) {
18896 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
18897 }
18898 for (i = 0; i < 12; i++) {
18899 tests[i] = tests[i].split(' ');
18900 equalTest(tests[i][0], 'MMM', i);
18901 equalTest(tests[i][1], 'MMM', i);
18902 equalTest(tests[i][0], 'MMMM', i);
18903 equalTest(tests[i][1], 'MMMM', i);
18904 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18905 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18906 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18907 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
18908 }
18909 });
18910
18911 test('format', function (assert) {
18912 var a = [
18913 ['dddd, MMMM Do YYYY, H:mm:ss', 'недела, февруари 14-ти 2010, 15:25:50'],
18914 ['ddd, hA', 'нед, 3PM'],
18915 ['M Mo MM MMMM MMM', '2 2-ри 02 февруари фев'],
18916 ['YYYY YY', '2010 10'],
18917 ['D Do DD', '14 14-ти 14'],
18918 ['d do dddd ddd dd', '0 0-ев недела нед нe'],
18919 ['DDD DDDo DDDD', '45 45-ти 045'],
18920 ['w wo ww', '7 7-ми 07'],
18921 ['h hh', '3 03'],
18922 ['H HH', '15 15'],
18923 ['m mm', '25 25'],
18924 ['s ss', '50 50'],
18925 ['a A', 'pm PM'],
18926 ['[the] DDDo [day of the year]', 'the 45-ти day of the year'],
18927 ['LTS', '15:25:50'],
18928 ['L', '14.02.2010'],
18929 ['LL', '14 февруари 2010'],
18930 ['LLL', '14 февруари 2010 15:25'],
18931 ['LLLL', 'недела, 14 февруари 2010 15:25'],
18932 ['l', '14.2.2010'],
18933 ['ll', '14 фев 2010'],
18934 ['lll', '14 фев 2010 15:25'],
18935 ['llll', 'нед, 14 фев 2010 15:25']
18936 ],
18937 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
18938 i;
18939 for (i = 0; i < a.length; i++) {
18940 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
18941 }
18942 });
18943
18944 test('format ordinal', function (assert) {
18945 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ви', '1-ви');
18946 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-ри', '2-ри');
18947 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-ти', '3-ти');
18948 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-ти', '4-ти');
18949 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-ти', '5-ти');
18950 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ти', '6-ти');
18951 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-ми', '7-ми');
18952 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-ми', '8-ми');
18953 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-ти', '9-ти');
18954 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-ти', '10-ти');
18955
18956 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-ти', '11-ти');
18957 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-ти', '12-ти');
18958 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-ти', '13-ти');
18959 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-ти', '14-ти');
18960 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-ти', '15-ти');
18961 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ти', '16-ти');
18962 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-ти', '17-ти');
18963 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-ти', '18-ти');
18964 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-ти', '19-ти');
18965 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-ти', '20-ти');
18966
18967 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ви', '21-ви');
18968 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-ри', '22-ри');
18969 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-ти', '23-ти');
18970 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ти', '24-ти');
18971 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ти', '25-ти');
18972 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ти', '26-ти');
18973 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ми', '27-ми');
18974 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ми', '28-ми');
18975 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ти', '29-ти');
18976 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ти', '30-ти');
18977
18978 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-ви', '31-ви');
18979 });
18980
18981 test('format month', function (assert) {
18982 var expected = 'јануари јан_февруари фев_март мар_април апр_мај мај_јуни јун_јули јул_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
18983 for (i = 0; i < expected.length; i++) {
18984 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
18985 }
18986 });
18987
18988 test('format week', function (assert) {
18989 var expected = 'недела нед нe_понеделник пон пo_вторник вто вт_среда сре ср_четврток чет че_петок пет пе_сабота саб сa'.split('_'), i;
18990 for (i = 0; i < expected.length; i++) {
18991 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
18992 }
18993 });
18994
18995 test('from', function (assert) {
18996 var start = moment([2007, 1, 28]);
18997 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'неколку секунди', '44 seconds = a few seconds');
18998 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'минута', '45 seconds = a minute');
18999 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'минута', '89 seconds = a minute');
19000 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минути', '90 seconds = 2 minutes');
19001 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минути', '44 minutes = 44 minutes');
19002 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'час', '45 minutes = an hour');
19003 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'час', '89 minutes = an hour');
19004 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 часа', '90 minutes = 2 hours');
19005 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 часа', '5 hours = 5 hours');
19006 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 часа', '21 hours = 21 hours');
19007 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ден', '22 hours = a day');
19008 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ден', '35 hours = a day');
19009 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дена', '36 hours = 2 days');
19010 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ден', '1 day = a day');
19011 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дена', '5 days = 5 days');
19012 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дена', '25 days = 25 days');
19013 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месец', '26 days = a month');
19014 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месец', '30 days = a month');
19015 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месец', '43 days = a month');
19016 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месеци', '46 days = 2 months');
19017 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месеци', '75 days = 2 months');
19018 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месеци', '76 days = 3 months');
19019 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месец', '1 month = a month');
19020 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месеци', '5 months = 5 months');
19021 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'година', '345 days = a year');
19022 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 години', '548 days = 2 years');
19023 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'година', '1 year = a year');
19024 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 години', '5 years = 5 years');
19025 });
19026
19027 test('suffix', function (assert) {
19028 assert.equal(moment(30000).from(0), 'после неколку секунди', 'prefix');
19029 assert.equal(moment(0).from(30000), 'пред неколку секунди', 'suffix');
19030 });
19031
19032 test('now from now', function (assert) {
19033 assert.equal(moment().fromNow(), 'пред неколку секунди', 'now from now should display as in the past');
19034 });
19035
19036 test('fromNow', function (assert) {
19037 assert.equal(moment().add({s: 30}).fromNow(), 'после неколку секунди', 'in a few seconds');
19038 assert.equal(moment().add({d: 5}).fromNow(), 'после 5 дена', 'in 5 days');
19039 });
19040
19041 test('calendar day', function (assert) {
19042 var a = moment().hours(2).minutes(0).seconds(0);
19043
19044 assert.equal(moment(a).calendar(), 'Денес во 2:00', 'today at the same time');
19045 assert.equal(moment(a).add({m: 25}).calendar(), 'Денес во 2:25', 'Now plus 25 min');
19046 assert.equal(moment(a).add({h: 1}).calendar(), 'Денес во 3:00', 'Now plus 1 hour');
19047 assert.equal(moment(a).add({d: 1}).calendar(), 'Утре во 2:00', 'tomorrow at the same time');
19048 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Денес во 1:00', 'Now minus 1 hour');
19049 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера во 2:00', 'yesterday at the same time');
19050 });
19051
19052 test('calendar next week', function (assert) {
19053 var i, m;
19054 for (i = 2; i < 7; i++) {
19055 m = moment().add({d: i});
19056 assert.equal(m.calendar(), m.format('dddd [во] LT'), 'Today + ' + i + ' days current time');
19057 m.hours(0).minutes(0).seconds(0).milliseconds(0);
19058 assert.equal(m.calendar(), m.format('dddd [во] LT'), 'Today + ' + i + ' days beginning of day');
19059 m.hours(23).minutes(59).seconds(59).milliseconds(999);
19060 assert.equal(m.calendar(), m.format('dddd [во] LT'), 'Today + ' + i + ' days end of day');
19061 }
19062 });
19063
19064 test('calendar last week', function (assert) {
19065 var i, m;
19066
19067 function makeFormat(d) {
19068 switch (d.day()) {
19069 case 0:
19070 case 3:
19071 case 6:
19072 return '[Во изминатата] dddd [во] LT';
19073 case 1:
19074 case 2:
19075 case 4:
19076 case 5:
19077 return '[Во изминатиот] dddd [во] LT';
19078 }
19079 }
19080
19081 for (i = 2; i < 7; i++) {
19082 m = moment().subtract({d: i});
19083 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
19084 m.hours(0).minutes(0).seconds(0).milliseconds(0);
19085 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
19086 m.hours(23).minutes(59).seconds(59).milliseconds(999);
19087 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
19088 }
19089 });
19090
19091 test('calendar all else', function (assert) {
19092 var weeksAgo = moment().subtract({w: 1}),
19093 weeksFromNow = moment().add({w: 1});
19094
19095 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
19096 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
19097
19098 weeksAgo = moment().subtract({w: 2});
19099 weeksFromNow = moment().add({w: 2});
19100
19101 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
19102 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
19103 });
19104
19105 test('weeks year starting sunday', function (assert) {
19106 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
19107 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
19108 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
19109 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
19110 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
19111 });
19112
19113 test('weeks year starting monday', function (assert) {
19114 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
19115 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
19116 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
19117 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
19118 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
19119 });
19120
19121 test('weeks year starting tuesday', function (assert) {
19122 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
19123 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
19124 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
19125 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
19126 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
19127 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
19128 });
19129
19130 test('weeks year starting wednesday', function (assert) {
19131 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
19132 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
19133 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
19134 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
19135 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
19136 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
19137 });
19138
19139 test('weeks year starting thursday', function (assert) {
19140 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
19141 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
19142 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
19143 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
19144 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
19145 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
19146 });
19147
19148 test('weeks year starting friday', function (assert) {
19149 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
19150 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
19151 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
19152 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
19153 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
19154 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
19155 });
19156
19157 test('weeks year starting saturday', function (assert) {
19158 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
19159 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
19160 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
19161 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
19162 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
19163 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
19164 });
19165
19166 test('weeks year starting sunday formatted', function (assert) {
19167 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
19168 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
19169 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-ри', 'Jan 2 2012 should be week 2');
19170 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-ри', 'Jan 8 2012 should be week 2');
19171 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
19172 });
19173
19174 test('lenient ordinal parsing', function (assert) {
19175 var i, ordinalStr, testMoment;
19176 for (i = 1; i <= 31; ++i) {
19177 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
19178 testMoment = moment(ordinalStr, 'YYYY MM Do');
19179 assert.equal(testMoment.year(), 2014,
19180 'lenient ordinal parsing ' + i + ' year check');
19181 assert.equal(testMoment.month(), 0,
19182 'lenient ordinal parsing ' + i + ' month check');
19183 assert.equal(testMoment.date(), i,
19184 'lenient ordinal parsing ' + i + ' date check');
19185 }
19186 });
19187
19188 test('lenient ordinal parsing of number', function (assert) {
19189 var i, testMoment;
19190 for (i = 1; i <= 31; ++i) {
19191 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
19192 assert.equal(testMoment.year(), 2014,
19193 'lenient ordinal parsing of number ' + i + ' year check');
19194 assert.equal(testMoment.month(), 0,
19195 'lenient ordinal parsing of number ' + i + ' month check');
19196 assert.equal(testMoment.date(), i,
19197 'lenient ordinal parsing of number ' + i + ' date check');
19198 }
19199 });
19200
19201 test('strict ordinal parsing', function (assert) {
19202 var i, ordinalStr, testMoment;
19203 for (i = 1; i <= 31; ++i) {
19204 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
19205 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
19206 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
19207 }
19208 });
19209
19210 }));
19211
19212 (function (global, factory) {
19213 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
19214 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
19215 factory(global.moment)
19216 }(this, function (moment) { 'use strict';
19217
19218 /*global QUnit:false*/
19219
19220 var test = QUnit.test;
19221
19222 function module (name, lifecycle) {
19223 QUnit.module(name, {
19224 setup : function () {
19225 moment.locale('en');
19226 moment.createFromInputFallback = function () {
19227 throw new Error('input not handled by moment');
19228 };
19229 if (lifecycle && lifecycle.setup) {
19230 lifecycle.setup();
19231 }
19232 },
19233 teardown : function () {
19234 if (lifecycle && lifecycle.teardown) {
19235 lifecycle.teardown();
19236 }
19237 }
19238 });
19239 }
19240
19241 function localeModule (name, lifecycle) {
19242 QUnit.module('locale:' + name, {
19243 setup : function () {
19244 moment.locale(name);
19245 moment.createFromInputFallback = function () {
19246 throw new Error('input not handled by moment');
19247 };
19248 if (lifecycle && lifecycle.setup) {
19249 lifecycle.setup();
19250 }
19251 },
19252 teardown : function () {
19253 moment.locale('en');
19254 if (lifecycle && lifecycle.teardown) {
19255 lifecycle.teardown();
19256 }
19257 }
19258 });
19259 }
19260
19261 localeModule('ml');
19262
19263 test('parse', function (assert) {
19264 var tests = 'ജനുവരി ജനു._ഫെബ്രുവരി ഫെബ്രു._മാർച്ച് മാർ._ഏപ്രിൽ ഏപ്രി._മേയ് മേയ്_ജൂൺ ജൂൺ_ജൂലൈ ജൂലൈ._ഓഗസ്റ്റ് ഓഗ._സെപ്റ്റംബർ സെപ്റ്റ._ഒക്ടോബർ ഒക്ടോ._നവംബർ നവം._ഡിസംബർ ഡിസം.'.split('_'), i;
19265 function equalTest(input, mmm, i) {
19266 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
19267 }
19268 for (i = 0; i < 12; i++) {
19269 tests[i] = tests[i].split(' ');
19270 equalTest(tests[i][0], 'MMM', i);
19271 equalTest(tests[i][1], 'MMM', i);
19272 equalTest(tests[i][0], 'MMMM', i);
19273 equalTest(tests[i][1], 'MMMM', i);
19274 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19275 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19276 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19277 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19278 }
19279 });
19280
19281 test('format', function (assert) {
19282 var a = [
19283 ['dddd, Do MMMM YYYY, a h:mm:ss -നു', 'ഞായറാഴ്ച, 14 ഫെബ്രുവരി 2010, ഉച്ച കഴിഞ്ഞ് 3:25:50 -നു'],
19284 ['ddd, a h -നു', 'ഞായർ, ഉച്ച കഴിഞ്ഞ് 3 -നു'],
19285 ['M Mo MM MMMM MMM', '2 2 02 ഫെബ്രുവരി ഫെബ്രു.'],
19286 ['YYYY YY', '2010 10'],
19287 ['D Do DD', '14 14 14'],
19288 ['d do dddd ddd dd', '0 0 ഞായറാഴ്ച ഞായർ ഞാ'],
19289 ['DDD DDDo DDDD', '45 45 045'],
19290 ['w wo ww', '8 8 08'],
19291 ['h hh', '3 03'],
19292 ['H HH', '15 15'],
19293 ['m mm', '25 25'],
19294 ['s ss', '50 50'],
19295 ['a A', 'ഉച്ച കഴിഞ്ഞ് ഉച്ച കഴിഞ്ഞ്'],
19296 ['LTS', 'ഉച്ച കഴിഞ്ഞ് 3:25:50 -നു'],
19297 ['L', '14/02/2010'],
19298 ['LL', '14 ഫെബ്രുവരി 2010'],
19299 ['LLL', '14 ഫെബ്രുവരി 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു'],
19300 ['LLLL', 'ഞായറാഴ്ച, 14 ഫെബ്രുവരി 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു'],
19301 ['l', '14/2/2010'],
19302 ['ll', '14 ഫെബ്രു. 2010'],
19303 ['lll', '14 ഫെബ്രു. 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു'],
19304 ['llll', 'ഞായർ, 14 ഫെബ്രു. 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു']
19305 ],
19306 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
19307 i;
19308 for (i = 0; i < a.length; i++) {
19309 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
19310 }
19311 });
19312
19313 test('format ordinal', function (assert) {
19314 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
19315 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
19316 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
19317 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
19318 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
19319 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
19320 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
19321 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
19322 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
19323 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
19324
19325 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
19326 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
19327 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
19328 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
19329 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
19330 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
19331 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
19332 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
19333 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
19334 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
19335
19336 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
19337 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
19338 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
19339 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
19340 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
19341 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
19342 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
19343 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
19344 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
19345 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
19346
19347 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
19348 });
19349
19350 test('format month', function (assert) {
19351 var expected = 'ജനുവരി ജനു._ഫെബ്രുവരി ഫെബ്രു._മാർച്ച് മാർ._ഏപ്രിൽ ഏപ്രി._മേയ് മേയ്_ജൂൺ ജൂൺ_ജൂലൈ ജൂലൈ._ഓഗസ്റ്റ് ഓഗ._സെപ്റ്റംബർ സെപ്റ്റ._ഒക്ടോബർ ഒക്ടോ._നവംബർ നവം._ഡിസംബർ ഡിസം.'.split('_'), i;
19352 for (i = 0; i < expected.length; i++) {
19353 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
19354 }
19355 });
19356
19357 test('format week', function (assert) {
19358 var expected = 'ഞായറാഴ്ച ഞായർ ഞാ_തിങ്കളാഴ്ച തിങ്കൾ തി_ചൊവ്വാഴ്ച ചൊവ്വ ചൊ_ബുധനാഴ്ച ബുധൻ ബു_വ്യാഴാഴ്ച വ്യാഴം വ്യാ_വെള്ളിയാഴ്ച വെള്ളി വെ_ശനിയാഴ്ച ശനി ശ'.split('_'), i;
19359 for (i = 0; i < expected.length; i++) {
19360 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
19361 }
19362 });
19363
19364 test('from', function (assert) {
19365 var start = moment([2007, 1, 28]);
19366 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'അൽപ നിമിഷങ്ങൾ', '44 seconds = a few seconds');
19367 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ഒരു മിനിറ്റ്', '45 seconds = a minute');
19368 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ഒരു മിനിറ്റ്', '89 seconds = a minute');
19369 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 മിനിറ്റ്', '90 seconds = 2 minutes');
19370 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 മിനിറ്റ്', '44 minutes = 44 minutes');
19371 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ഒരു മണിക്കൂർ', '45 minutes = an hour');
19372 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ഒരു മണിക്കൂർ', '89 minutes = an hour');
19373 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 മണിക്കൂർ', '90 minutes = 2 hours');
19374 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 മണിക്കൂർ', '5 hours = 5 hours');
19375 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 മണിക്കൂർ', '21 hours = 21 hours');
19376 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ഒരു ദിവസം', '22 hours = a day');
19377 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ഒരു ദിവസം', '35 hours = a day');
19378 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ദിവസം', '36 hours = 2 days');
19379 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ഒരു ദിവസം', '1 day = a day');
19380 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ദിവസം', '5 days = 5 days');
19381 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ദിവസം', '25 days = 25 days');
19382 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ഒരു മാസം', '26 days = a month');
19383 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ഒരു മാസം', '30 days = a month');
19384 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ഒരു മാസം', '43 days = a month');
19385 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 മാസം', '46 days = 2 months');
19386 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 മാസം', '75 days = 2 months');
19387 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 മാസം', '76 days = 3 months');
19388 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ഒരു മാസം', '1 month = a month');
19389 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 മാസം', '5 months = 5 months');
19390 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ഒരു വർഷം', '345 days = a year');
19391 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 വർഷം', '548 days = 2 years');
19392 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ഒരു വർഷം', '1 year = a year');
19393 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 വർഷം', '5 years = 5 years');
19394 });
19395
19396 test('suffix', function (assert) {
19397 assert.equal(moment(30000).from(0), 'അൽപ നിമിഷങ്ങൾ കഴിഞ്ഞ്', 'prefix');
19398 assert.equal(moment(0).from(30000), 'അൽപ നിമിഷങ്ങൾ മുൻപ്', 'suffix');
19399 });
19400
19401 test('now from now', function (assert) {
19402 assert.equal(moment().fromNow(), 'അൽപ നിമിഷങ്ങൾ മുൻപ്', 'now from now should display as in the past');
19403 });
19404
19405 test('fromNow', function (assert) {
19406 assert.equal(moment().add({s: 30}).fromNow(), 'അൽപ നിമിഷങ്ങൾ കഴിഞ്ഞ്', 'അൽപ നിമിഷങ്ങൾ കഴിഞ്ഞ്');
19407 assert.equal(moment().add({d: 5}).fromNow(), '5 ദിവസം കഴിഞ്ഞ്', '5 ദിവസം കഴിഞ്ഞ്');
19408 });
19409
19410 test('calendar day', function (assert) {
19411 var a = moment().hours(2).minutes(0).seconds(0);
19412
19413 assert.equal(moment(a).calendar(), 'ഇന്ന് രാത്രി 2:00 -നു', 'today at the same time');
19414 assert.equal(moment(a).add({m: 25}).calendar(), 'ഇന്ന് രാത്രി 2:25 -നു', 'Now plus 25 min');
19415 assert.equal(moment(a).add({h: 3}).calendar(), 'ഇന്ന് രാവിലെ 5:00 -നു', 'Now plus 3 hour');
19416 assert.equal(moment(a).add({d: 1}).calendar(), 'നാളെ രാത്രി 2:00 -നു', 'tomorrow at the same time');
19417 assert.equal(moment(a).subtract({h: 1}).calendar(), 'ഇന്ന് രാത്രി 1:00 -നു', 'Now minus 1 hour');
19418 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ഇന്നലെ രാത്രി 2:00 -നു', 'yesterday at the same time');
19419 });
19420
19421 test('calendar next week', function (assert) {
19422 var i, m;
19423 for (i = 2; i < 7; i++) {
19424 m = moment().add({d: i});
19425 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
19426 m.hours(0).minutes(0).seconds(0).milliseconds(0);
19427 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
19428 m.hours(23).minutes(59).seconds(59).milliseconds(999);
19429 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
19430 }
19431 });
19432
19433 test('calendar last week', function (assert) {
19434 var i, m;
19435
19436 for (i = 2; i < 7; i++) {
19437 m = moment().subtract({d: i});
19438 assert.equal(m.calendar(), m.format('[കഴിഞ്ഞ] dddd[,] LT'), 'Today - ' + i + ' days current time');
19439 m.hours(0).minutes(0).seconds(0).milliseconds(0);
19440 assert.equal(m.calendar(), m.format('[കഴിഞ്ഞ] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
19441 m.hours(23).minutes(59).seconds(59).milliseconds(999);
19442 assert.equal(m.calendar(), m.format('[കഴിഞ്ഞ] dddd[,] LT'), 'Today - ' + i + ' days end of day');
19443 }
19444 });
19445
19446 test('calendar all else', function (assert) {
19447 var weeksAgo = moment().subtract({w: 1}),
19448 weeksFromNow = moment().add({w: 1});
19449
19450 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
19451 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
19452
19453 weeksAgo = moment().subtract({w: 2});
19454 weeksFromNow = moment().add({w: 2});
19455
19456 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
19457 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
19458 });
19459
19460 test('meridiem', function (assert) {
19461 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'രാത്രി', 'before dawn');
19462 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'രാവിലെ', 'morning');
19463 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'ഉച്ച കഴിഞ്ഞ്', 'during day');
19464 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'വൈകുന്നേരം', 'evening');
19465 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'വൈകുന്നേരം', 'late evening');
19466 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'രാത്രി', 'night');
19467
19468 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'രാത്രി', 'before dawn');
19469 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'രാവിലെ', 'morning');
19470 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'ഉച്ച കഴിഞ്ഞ്', ' during day');
19471 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'വൈകുന്നേരം', 'evening');
19472 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'വൈകുന്നേരം', 'late evening');
19473 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'രാത്രി', 'night');
19474 });
19475
19476 test('weeks year starting sunday', function (assert) {
19477 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
19478 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
19479 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
19480 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
19481 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
19482 });
19483
19484 test('weeks year starting monday', function (assert) {
19485 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
19486 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
19487 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
19488 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
19489 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
19490 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
19491 });
19492
19493 test('weeks year starting tuesday', function (assert) {
19494 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
19495 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
19496 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
19497 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
19498 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
19499 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
19500 });
19501
19502 test('weeks year starting wednesday', function (assert) {
19503 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
19504 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
19505 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
19506 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
19507 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
19508 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
19509 });
19510
19511 test('weeks year starting thursday', function (assert) {
19512 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
19513 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
19514 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
19515 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
19516 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
19517 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
19518 });
19519
19520 test('weeks year starting friday', function (assert) {
19521 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
19522 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
19523 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
19524 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
19525 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
19526 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
19527 });
19528
19529 test('weeks year starting saturday', function (assert) {
19530 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
19531 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
19532 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
19533 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
19534 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
19535 });
19536
19537 test('weeks year starting sunday formatted', function (assert) {
19538 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
19539 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
19540 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
19541 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
19542 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
19543 });
19544
19545 test('lenient ordinal parsing', function (assert) {
19546 var i, ordinalStr, testMoment;
19547 for (i = 1; i <= 31; ++i) {
19548 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
19549 testMoment = moment(ordinalStr, 'YYYY MM Do');
19550 assert.equal(testMoment.year(), 2014,
19551 'lenient ordinal parsing ' + i + ' year check');
19552 assert.equal(testMoment.month(), 0,
19553 'lenient ordinal parsing ' + i + ' month check');
19554 assert.equal(testMoment.date(), i,
19555 'lenient ordinal parsing ' + i + ' date check');
19556 }
19557 });
19558
19559 test('lenient ordinal parsing of number', function (assert) {
19560 var i, testMoment;
19561 for (i = 1; i <= 31; ++i) {
19562 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
19563 assert.equal(testMoment.year(), 2014,
19564 'lenient ordinal parsing of number ' + i + ' year check');
19565 assert.equal(testMoment.month(), 0,
19566 'lenient ordinal parsing of number ' + i + ' month check');
19567 assert.equal(testMoment.date(), i,
19568 'lenient ordinal parsing of number ' + i + ' date check');
19569 }
19570 });
19571
19572 test('strict ordinal parsing', function (assert) {
19573 var i, ordinalStr, testMoment;
19574 for (i = 1; i <= 31; ++i) {
19575 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
19576 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
19577 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
19578 }
19579 });
19580
19581 }));
19582
19583 (function (global, factory) {
19584 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
19585 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
19586 factory(global.moment)
19587 }(this, function (moment) { 'use strict';
19588
19589 /*global QUnit:false*/
19590
19591 var test = QUnit.test;
19592
19593 function module (name, lifecycle) {
19594 QUnit.module(name, {
19595 setup : function () {
19596 moment.locale('en');
19597 moment.createFromInputFallback = function () {
19598 throw new Error('input not handled by moment');
19599 };
19600 if (lifecycle && lifecycle.setup) {
19601 lifecycle.setup();
19602 }
19603 },
19604 teardown : function () {
19605 if (lifecycle && lifecycle.teardown) {
19606 lifecycle.teardown();
19607 }
19608 }
19609 });
19610 }
19611
19612 function localeModule (name, lifecycle) {
19613 QUnit.module('locale:' + name, {
19614 setup : function () {
19615 moment.locale(name);
19616 moment.createFromInputFallback = function () {
19617 throw new Error('input not handled by moment');
19618 };
19619 if (lifecycle && lifecycle.setup) {
19620 lifecycle.setup();
19621 }
19622 },
19623 teardown : function () {
19624 moment.locale('en');
19625 if (lifecycle && lifecycle.teardown) {
19626 lifecycle.teardown();
19627 }
19628 }
19629 });
19630 }
19631
19632 localeModule('mr');
19633
19634 test('parse', function (assert) {
19635 var tests = 'जानेवारी जाने._फेब्रुवारी फेब्रु._मार्च मार्च._एप्रिल एप्रि._मे मे._जून जून._जुलै जुलै._ऑगस्ट ऑग._सप्टेंबर सप्टें._ऑक्टोबर ऑक्टो._नोव्हेंबर नोव्हें._डिसेंबर डिसें.'.split('_'), i;
19636 function equalTest(input, mmm, i) {
19637 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
19638 }
19639 for (i = 0; i < 12; i++) {
19640 tests[i] = tests[i].split(' ');
19641 equalTest(tests[i][0], 'MMM', i);
19642 equalTest(tests[i][1], 'MMM', i);
19643 equalTest(tests[i][0], 'MMMM', i);
19644 equalTest(tests[i][1], 'MMMM', i);
19645 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19646 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19647 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19648 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19649 }
19650 });
19651
19652 test('format', function (assert) {
19653 var a = [
19654 ['dddd, Do MMMM YYYY, a h:mm:ss वाजता', 'रविवार, १४ फेब्रुवारी २०१०, दुपारी ३:२५:५० वाजता'],
19655 ['ddd, a h वाजता', 'रवि, दुपारी ३ वाजता'],
19656 ['M Mo MM MMMM MMM', '२ २ ०२ फेब्रुवारी फेब्रु.'],
19657 ['YYYY YY', '२०१० १०'],
19658 ['D Do DD', '१४ १४ १४'],
19659 ['d do dddd ddd dd', '० ० रविवार रवि र'],
19660 ['DDD DDDo DDDD', '४५ ४५ ०४५'],
19661 ['w wo ww', '८ ८ ०८'],
19662 ['h hh', '३ ०३'],
19663 ['H HH', '१५ १५'],
19664 ['m mm', '२५ २५'],
19665 ['s ss', '५० ५०'],
19666 ['a A', 'दुपारी दुपारी'],
19667 ['LTS', 'दुपारी ३:२५:५० वाजता'],
19668 ['L', '१४/०२/२०१०'],
19669 ['LL', '१४ फेब्रुवारी २०१०'],
19670 ['LLL', '१४ फेब्रुवारी २०१०, दुपारी ३:२५ वाजता'],
19671 ['LLLL', 'रविवार, १४ फेब्रुवारी २०१०, दुपारी ३:२५ वाजता'],
19672 ['l', '१४/२/२०१०'],
19673 ['ll', '१४ फेब्रु. २०१०'],
19674 ['lll', '१४ फेब्रु. २०१०, दुपारी ३:२५ वाजता'],
19675 ['llll', 'रवि, १४ फेब्रु. २०१०, दुपारी ३:२५ वाजता']
19676 ],
19677 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
19678 i;
19679 for (i = 0; i < a.length; i++) {
19680 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
19681 }
19682 });
19683
19684 test('format ordinal', function (assert) {
19685 assert.equal(moment([2011, 0, 1]).format('DDDo'), '१', '१');
19686 assert.equal(moment([2011, 0, 2]).format('DDDo'), '२', '२');
19687 assert.equal(moment([2011, 0, 3]).format('DDDo'), '३', '३');
19688 assert.equal(moment([2011, 0, 4]).format('DDDo'), '४', '४');
19689 assert.equal(moment([2011, 0, 5]).format('DDDo'), '५', '५');
19690 assert.equal(moment([2011, 0, 6]).format('DDDo'), '६', '६');
19691 assert.equal(moment([2011, 0, 7]).format('DDDo'), '७', '७');
19692 assert.equal(moment([2011, 0, 8]).format('DDDo'), '८', '८');
19693 assert.equal(moment([2011, 0, 9]).format('DDDo'), '९', '९');
19694 assert.equal(moment([2011, 0, 10]).format('DDDo'), '१०', '१०');
19695
19696 assert.equal(moment([2011, 0, 11]).format('DDDo'), '११', '११');
19697 assert.equal(moment([2011, 0, 12]).format('DDDo'), '१२', '१२');
19698 assert.equal(moment([2011, 0, 13]).format('DDDo'), '१३', '१३');
19699 assert.equal(moment([2011, 0, 14]).format('DDDo'), '१४', '१४');
19700 assert.equal(moment([2011, 0, 15]).format('DDDo'), '१५', '१५');
19701 assert.equal(moment([2011, 0, 16]).format('DDDo'), '१६', '१६');
19702 assert.equal(moment([2011, 0, 17]).format('DDDo'), '१७', '१७');
19703 assert.equal(moment([2011, 0, 18]).format('DDDo'), '१८', '१८');
19704 assert.equal(moment([2011, 0, 19]).format('DDDo'), '१९', '१९');
19705 assert.equal(moment([2011, 0, 20]).format('DDDo'), '२०', '२०');
19706
19707 assert.equal(moment([2011, 0, 21]).format('DDDo'), '२१', '२१');
19708 assert.equal(moment([2011, 0, 22]).format('DDDo'), '२२', '२२');
19709 assert.equal(moment([2011, 0, 23]).format('DDDo'), '२३', '२३');
19710 assert.equal(moment([2011, 0, 24]).format('DDDo'), '२४', '२४');
19711 assert.equal(moment([2011, 0, 25]).format('DDDo'), '२५', '२५');
19712 assert.equal(moment([2011, 0, 26]).format('DDDo'), '२६', '२६');
19713 assert.equal(moment([2011, 0, 27]).format('DDDo'), '२७', '२७');
19714 assert.equal(moment([2011, 0, 28]).format('DDDo'), '२८', '२८');
19715 assert.equal(moment([2011, 0, 29]).format('DDDo'), '२९', '२९');
19716 assert.equal(moment([2011, 0, 30]).format('DDDo'), '३०', '३०');
19717
19718 assert.equal(moment([2011, 0, 31]).format('DDDo'), '३१', '३१');
19719 });
19720
19721 test('format month', function (assert) {
19722 var expected = 'जानेवारी जाने._फेब्रुवारी फेब्रु._मार्च मार्च._एप्रिल एप्रि._मे मे._जून जून._जुलै जुलै._ऑगस्ट ऑग._सप्टेंबर सप्टें._ऑक्टोबर ऑक्टो._नोव्हेंबर नोव्हें._डिसेंबर डिसें.'.split('_'), i;
19723 for (i = 0; i < expected.length; i++) {
19724 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
19725 }
19726 });
19727
19728 test('format week', function (assert) {
19729 var expected = 'रविवार रवि र_सोमवार सोम सो_मंगळवार मंगळ मं_बुधवार बुध बु_गुरूवार गुरू गु_शुक्रवार शुक्र शु_शनिवार शनि श'.split('_'), i;
19730 for (i = 0; i < expected.length; i++) {
19731 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
19732 }
19733 });
19734
19735 test('from', function (assert) {
19736 var start = moment([2007, 1, 28]);
19737 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'सेकंद', '44 seconds = a few seconds');
19738 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'एक मिनिट', '45 seconds = a minute');
19739 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'एक मिनिट', '89 seconds = a minute');
19740 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '२ मिनिटे', '90 seconds = 2 minutes');
19741 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '४४ मिनिटे', '44 minutes = 44 minutes');
19742 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'एक तास', '45 minutes = an hour');
19743 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'एक तास', '89 minutes = an hour');
19744 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '२ तास', '90 minutes = 2 hours');
19745 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '५ तास', '5 hours = 5 hours');
19746 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '२१ तास', '21 hours = 21 hours');
19747 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'एक दिवस', '22 hours = a day');
19748 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'एक दिवस', '35 hours = a day');
19749 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '२ दिवस', '36 hours = 2 days');
19750 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'एक दिवस', '1 day = a day');
19751 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '५ दिवस', '5 days = 5 days');
19752 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '२५ दिवस', '25 days = 25 days');
19753 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'एक महिना', '26 days = a month');
19754 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'एक महिना', '30 days = a month');
19755 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'एक महिना', '43 days = a month');
19756 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '२ महिने', '46 days = 2 months');
19757 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '२ महिने', '75 days = 2 months');
19758 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '३ महिने', '76 days = 3 months');
19759 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'एक महिना', '1 month = a month');
19760 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '५ महिने', '5 months = 5 months');
19761 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'एक वर्ष', '345 days = a year');
19762 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '२ वर्षे', '548 days = 2 years');
19763 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'एक वर्ष', '1 year = a year');
19764 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '५ वर्षे', '5 years = 5 years');
19765 });
19766
19767 test('suffix', function (assert) {
19768 assert.equal(moment(30000).from(0), 'सेकंद नंतर', 'prefix');
19769 assert.equal(moment(0).from(30000), 'सेकंद पूर्वी', 'suffix');
19770 });
19771
19772 test('now from now', function (assert) {
19773 assert.equal(moment().fromNow(), 'सेकंद पूर्वी', 'now from now should display as in the past');
19774 });
19775
19776 test('fromNow', function (assert) {
19777 assert.equal(moment().add({s: 30}).fromNow(), 'सेकंद नंतर', 'सेकंद नंतर');
19778 assert.equal(moment().add({d: 5}).fromNow(), '५ दिवस नंतर', '५ दिवस नंतर');
19779 });
19780
19781 test('calendar day', function (assert) {
19782 var a = moment().hours(2).minutes(0).seconds(0);
19783
19784 assert.equal(moment(a).calendar(), 'आज रात्री २:०० वाजता', 'today at the same time');
19785 assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात्री २:२५ वाजता', 'Now plus 25 min');
19786 assert.equal(moment(a).add({h: 3}).calendar(), 'आज सकाळी ५:०० वाजता', 'Now plus 3 hour');
19787 assert.equal(moment(a).add({d: 1}).calendar(), 'उद्या रात्री २:०० वाजता', 'tomorrow at the same time');
19788 assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात्री १:०० वाजता', 'Now minus 1 hour');
19789 assert.equal(moment(a).subtract({d: 1}).calendar(), 'काल रात्री २:०० वाजता', 'yesterday at the same time');
19790 });
19791
19792 test('calendar next week', function (assert) {
19793 var i, m;
19794 for (i = 2; i < 7; i++) {
19795 m = moment().add({d: i});
19796 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
19797 m.hours(0).minutes(0).seconds(0).milliseconds(0);
19798 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
19799 m.hours(23).minutes(59).seconds(59).milliseconds(999);
19800 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
19801 }
19802 });
19803
19804 test('calendar last week', function (assert) {
19805 var i, m;
19806
19807 for (i = 2; i < 7; i++) {
19808 m = moment().subtract({d: i});
19809 assert.equal(m.calendar(), m.format('[मागील] dddd[,] LT'), 'Today - ' + i + ' days current time');
19810 m.hours(0).minutes(0).seconds(0).milliseconds(0);
19811 assert.equal(m.calendar(), m.format('[मागील] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
19812 m.hours(23).minutes(59).seconds(59).milliseconds(999);
19813 assert.equal(m.calendar(), m.format('[मागील] dddd[,] LT'), 'Today - ' + i + ' days end of day');
19814 }
19815 });
19816
19817 test('calendar all else', function (assert) {
19818 var weeksAgo = moment().subtract({w: 1}),
19819 weeksFromNow = moment().add({w: 1});
19820
19821 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
19822 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
19823
19824 weeksAgo = moment().subtract({w: 2});
19825 weeksFromNow = moment().add({w: 2});
19826
19827 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
19828 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
19829 });
19830
19831 test('meridiem', function (assert) {
19832 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'रात्री', 'before dawn');
19833 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'सकाळी', 'morning');
19834 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दुपारी', 'during day');
19835 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'सायंकाळी', 'evening');
19836 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'सायंकाळी', 'late evening');
19837 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'रात्री', 'night');
19838
19839 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'रात्री', 'before dawn');
19840 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'सकाळी', 'morning');
19841 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'दुपारी', ' during day');
19842 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'सायंकाळी', 'evening');
19843 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'सायंकाळी', 'late evening');
19844 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात्री', 'night');
19845 });
19846
19847 test('weeks year starting sunday', function (assert) {
19848 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
19849 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
19850 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
19851 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
19852 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
19853 });
19854
19855 test('weeks year starting monday', function (assert) {
19856 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
19857 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
19858 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
19859 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
19860 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
19861 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
19862 });
19863
19864 test('weeks year starting tuesday', function (assert) {
19865 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
19866 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
19867 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
19868 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
19869 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
19870 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
19871 });
19872
19873 test('weeks year starting wednesday', function (assert) {
19874 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
19875 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
19876 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
19877 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
19878 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
19879 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
19880 });
19881
19882 test('weeks year starting thursday', function (assert) {
19883 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
19884 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
19885 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
19886 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
19887 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
19888 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
19889 });
19890
19891 test('weeks year starting friday', function (assert) {
19892 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
19893 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
19894 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
19895 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
19896 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
19897 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
19898 });
19899
19900 test('weeks year starting saturday', function (assert) {
19901 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
19902 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
19903 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
19904 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
19905 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
19906 });
19907
19908 test('weeks year starting sunday formatted', function (assert) {
19909 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
19910 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
19911 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '२ ०२ २', 'Jan 8 2012 should be week 2');
19912 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '२ ०२ २', 'Jan 14 2012 should be week 2');
19913 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
19914 });
19915
19916 test('lenient ordinal parsing', function (assert) {
19917 var i, ordinalStr, testMoment;
19918 for (i = 1; i <= 31; ++i) {
19919 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
19920 testMoment = moment(ordinalStr, 'YYYY MM Do');
19921 assert.equal(testMoment.year(), 2014,
19922 'lenient ordinal parsing ' + i + ' year check');
19923 assert.equal(testMoment.month(), 0,
19924 'lenient ordinal parsing ' + i + ' month check');
19925 assert.equal(testMoment.date(), i,
19926 'lenient ordinal parsing ' + i + ' date check');
19927 }
19928 });
19929
19930 test('lenient ordinal parsing of number', function (assert) {
19931 var i, testMoment;
19932 for (i = 1; i <= 31; ++i) {
19933 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
19934 assert.equal(testMoment.year(), 2014,
19935 'lenient ordinal parsing of number ' + i + ' year check');
19936 assert.equal(testMoment.month(), 0,
19937 'lenient ordinal parsing of number ' + i + ' month check');
19938 assert.equal(testMoment.date(), i,
19939 'lenient ordinal parsing of number ' + i + ' date check');
19940 }
19941 });
19942
19943 test('meridiem invariant', function (assert) {
19944 var h, m, t1, t2;
19945 for (h = 0; h < 24; ++h) {
19946 for (m = 0; m < 60; m += 15) {
19947 t1 = moment.utc([2000, 0, 1, h, m]);
19948 t2 = moment(t1.format('A h:mm'), 'A h:mm');
19949 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
19950 'meridiem at ' + t1.format('HH:mm'));
19951 }
19952 }
19953 });
19954
19955 test('strict ordinal parsing', function (assert) {
19956 var i, ordinalStr, testMoment;
19957 for (i = 1; i <= 31; ++i) {
19958 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
19959 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
19960 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
19961 }
19962 });
19963
19964 }));
19965
19966 (function (global, factory) {
19967 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
19968 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
19969 factory(global.moment)
19970 }(this, function (moment) { 'use strict';
19971
19972 /*global QUnit:false*/
19973
19974 var test = QUnit.test;
19975
19976 function module (name, lifecycle) {
19977 QUnit.module(name, {
19978 setup : function () {
19979 moment.locale('en');
19980 moment.createFromInputFallback = function () {
19981 throw new Error('input not handled by moment');
19982 };
19983 if (lifecycle && lifecycle.setup) {
19984 lifecycle.setup();
19985 }
19986 },
19987 teardown : function () {
19988 if (lifecycle && lifecycle.teardown) {
19989 lifecycle.teardown();
19990 }
19991 }
19992 });
19993 }
19994
19995 function localeModule (name, lifecycle) {
19996 QUnit.module('locale:' + name, {
19997 setup : function () {
19998 moment.locale(name);
19999 moment.createFromInputFallback = function () {
20000 throw new Error('input not handled by moment');
20001 };
20002 if (lifecycle && lifecycle.setup) {
20003 lifecycle.setup();
20004 }
20005 },
20006 teardown : function () {
20007 moment.locale('en');
20008 if (lifecycle && lifecycle.teardown) {
20009 lifecycle.teardown();
20010 }
20011 }
20012 });
20013 }
20014
20015 localeModule('ms-my');
20016
20017 test('parse', function (assert) {
20018 var i,
20019 tests = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
20020
20021 function equalTest(input, mmm, i) {
20022 assert.equal(moment(input, mmm).month(), i, input + ' sepatutnya bulan ' + (i + 1));
20023 }
20024
20025 for (i = 0; i < 12; i++) {
20026 tests[i] = tests[i].split(' ');
20027 equalTest(tests[i][0], 'MMM', i);
20028 equalTest(tests[i][1], 'MMM', i);
20029 equalTest(tests[i][0], 'MMMM', i);
20030 equalTest(tests[i][1], 'MMMM', i);
20031 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
20032 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20033 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20034 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20035 }
20036 });
20037
20038 test('format', function (assert) {
20039 var a = [
20040 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Ahad, Februari 14 2010, 3:25:50 petang'],
20041 ['ddd, hA', 'Ahd, 3petang'],
20042 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
20043 ['YYYY YY', '2010 10'],
20044 ['D Do DD', '14 14 14'],
20045 ['d do dddd ddd dd', '0 0 Ahad Ahd Ah'],
20046 ['DDD DDDo DDDD', '45 45 045'],
20047 ['w wo ww', '7 7 07'],
20048 ['h hh', '3 03'],
20049 ['H HH', '15 15'],
20050 ['m mm', '25 25'],
20051 ['s ss', '50 50'],
20052 ['a A', 'petang petang'],
20053 ['[hari] [ke] DDDo [tahun] ini', 'hari ke 45 tahun ini'],
20054 ['LTS', '15.25.50'],
20055 ['L', '14/02/2010'],
20056 ['LL', '14 Februari 2010'],
20057 ['LLL', '14 Februari 2010 pukul 15.25'],
20058 ['LLLL', 'Ahad, 14 Februari 2010 pukul 15.25'],
20059 ['l', '14/2/2010'],
20060 ['ll', '14 Feb 2010'],
20061 ['lll', '14 Feb 2010 pukul 15.25'],
20062 ['llll', 'Ahd, 14 Feb 2010 pukul 15.25']
20063 ],
20064 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
20065 i;
20066
20067 for (i = 0; i < a.length; i++) {
20068 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
20069 }
20070 });
20071
20072 test('format ordinal', function (assert) {
20073 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
20074 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
20075 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
20076 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
20077 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
20078 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
20079 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
20080 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
20081 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
20082 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
20083
20084 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
20085 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
20086 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
20087 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
20088 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
20089 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
20090 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
20091 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
20092 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
20093 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
20094
20095 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
20096 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
20097 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
20098 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
20099 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
20100 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
20101 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
20102 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
20103 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
20104 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
20105
20106 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
20107 });
20108
20109 test('format month', function (assert) {
20110 var i,
20111 expected = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
20112
20113 for (i = 0; i < expected.length; i++) {
20114 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
20115 }
20116 });
20117
20118 test('format week', function (assert) {
20119 var i,
20120 expected = 'Ahad Ahd Ah_Isnin Isn Is_Selasa Sel Sl_Rabu Rab Rb_Khamis Kha Km_Jumaat Jum Jm_Sabtu Sab Sb'.split('_');
20121
20122 for (i = 0; i < expected.length; i++) {
20123 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
20124 }
20125 });
20126
20127 test('from', function (assert) {
20128 var start = moment([2007, 1, 28]);
20129
20130 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'beberapa saat', '44 saat = beberapa saat');
20131 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'seminit', '45 saat = seminit');
20132 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'seminit', '89 saat = seminit');
20133 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minit', '90 saat = 2 minit');
20134 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minit', '44 minit = 44 minit');
20135 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'sejam', '45 minit = sejam');
20136 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'sejam', '89 minit = sejam');
20137 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minit = 2 jam');
20138 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 jam = 5 jam');
20139 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 jam = 21 jam');
20140 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sehari', '22 jam = sehari');
20141 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sehari', '35 jam = sehari');
20142 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 hari', '36 jam = 2 hari');
20143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sehari', '1 hari = sehari');
20144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 hari', '5 hari = 5 hari');
20145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 hari', '25 hari = 25 hari');
20146 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sebulan', '26 hari = sebulan');
20147 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sebulan', '30 hari = sebulan');
20148 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sebulan', '45 hari = sebulan');
20149 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 bulan', '46 hari = 2 bulan');
20150 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 bulan', '75 hari = 2 bulan');
20151 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 bulan', '76 hari = 3 bulan');
20152 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sebulan', '1 bulan = sebulan');
20153 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 bulan', '5 bulan = 5 bulan');
20154 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setahun', '345 hari = setahun');
20155 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 tahun', '548 hari = 2 tahun');
20156 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setahun', '1 tahun = setahun');
20157 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 tahun', '5 tahun = 5 tahun');
20158 });
20159
20160 test('suffix', function (assert) {
20161 assert.equal(moment(30000).from(0), 'dalam beberapa saat', 'prefix');
20162 assert.equal(moment(0).from(30000), 'beberapa saat yang lepas', 'suffix');
20163 });
20164
20165 test('now from now', function (assert) {
20166 assert.equal(moment().fromNow(), 'beberapa saat yang lepas', 'waktu sekarang dari sekarang sepatutnya menunjukkan sebagai telah lepas');
20167 });
20168
20169 test('fromNow', function (assert) {
20170 assert.equal(moment().add({s: 30}).fromNow(), 'dalam beberapa saat', 'dalam beberapa saat');
20171 assert.equal(moment().add({d: 5}).fromNow(), 'dalam 5 hari', 'dalam 5 hari');
20172 });
20173
20174 test('calendar day', function (assert) {
20175 var a = moment().hours(2).minutes(0).seconds(0);
20176
20177 assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
20178 assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
20179 assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
20180 assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
20181 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
20182 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
20183 });
20184
20185 test('calendar next week', function (assert) {
20186 var i, m;
20187 for (i = 2; i < 7; i++) {
20188 m = moment().add({d: i});
20189 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari waktu sekarang');
20190 m.hours(0).minutes(0).seconds(0).milliseconds(0);
20191 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari permulaan hari');
20192 m.hours(23).minutes(59).seconds(59).milliseconds(999);
20193 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari tamat hari');
20194 }
20195 });
20196
20197 test('calendar last week', function (assert) {
20198 var i, m;
20199 for (i = 2; i < 7; i++) {
20200 m = moment().subtract({d: i});
20201 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari waktu sekarang');
20202 m.hours(0).minutes(0).seconds(0).milliseconds(0);
20203 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari permulaan hari');
20204 m.hours(23).minutes(59).seconds(59).milliseconds(999);
20205 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari tamat hari');
20206 }
20207 });
20208
20209 test('calendar all else', function (assert) {
20210 var weeksAgo = moment().subtract({w: 1}),
20211 weeksFromNow = moment().add({w: 1});
20212
20213 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 minggu lepas');
20214 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 1 minggu');
20215
20216 weeksAgo = moment().subtract({w: 2});
20217 weeksFromNow = moment().add({w: 2});
20218
20219 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 minggu lepas');
20220 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
20221 });
20222
20223 test('weeks year starting sunday', function (assert) {
20224 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
20225 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
20226 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
20227 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
20228 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
20229 });
20230
20231 test('weeks year starting monday', function (assert) {
20232 assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
20233 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
20234 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
20235 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
20236 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
20237 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
20238 });
20239
20240 test('weeks year starting tuesday', function (assert) {
20241 assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
20242 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
20243 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
20244 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
20245 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
20246 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
20247 });
20248
20249 test('weeks year starting wednesday', function (assert) {
20250 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
20251 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
20252 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
20253 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
20254 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
20255 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
20256 });
20257
20258 test('weeks year starting thursday', function (assert) {
20259 assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
20260 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
20261 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
20262 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
20263 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
20264 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
20265 });
20266
20267 test('weeks year starting friday', function (assert) {
20268 assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
20269 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
20270 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
20271 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
20272 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
20273 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
20274 });
20275
20276 test('weeks year starting saturday', function (assert) {
20277 assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
20278 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
20279 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
20280 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
20281 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
20282 });
20283
20284 test('weeks year starting sunday format', function (assert) {
20285 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
20286 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
20287 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 sepatutnya minggu 2');
20288 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 sepatutnya minggu 3');
20289 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
20290 });
20291
20292 test('lenient ordinal parsing', function (assert) {
20293 var i, ordinalStr, testMoment;
20294 for (i = 1; i <= 31; ++i) {
20295 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
20296 testMoment = moment(ordinalStr, 'YYYY MM Do');
20297 assert.equal(testMoment.year(), 2014,
20298 'lenient ordinal parsing ' + i + ' year check');
20299 assert.equal(testMoment.month(), 0,
20300 'lenient ordinal parsing ' + i + ' month check');
20301 assert.equal(testMoment.date(), i,
20302 'lenient ordinal parsing ' + i + ' date check');
20303 }
20304 });
20305
20306 test('meridiem invariant', function (assert) {
20307 var h, m, t1, t2;
20308 for (h = 0; h < 24; ++h) {
20309 for (m = 0; m < 60; m += 15) {
20310 t1 = moment.utc([2000, 0, 1, h, m]);
20311 t2 = moment(t1.format('A h:mm'), 'A h:mm');
20312 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
20313 'meridiem at ' + t1.format('HH:mm'));
20314 }
20315 }
20316 });
20317
20318 test('lenient ordinal parsing of number', function (assert) {
20319 var i, testMoment;
20320 for (i = 1; i <= 31; ++i) {
20321 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
20322 assert.equal(testMoment.year(), 2014,
20323 'lenient ordinal parsing of number ' + i + ' year check');
20324 assert.equal(testMoment.month(), 0,
20325 'lenient ordinal parsing of number ' + i + ' month check');
20326 assert.equal(testMoment.date(), i,
20327 'lenient ordinal parsing of number ' + i + ' date check');
20328 }
20329 });
20330
20331 test('strict ordinal parsing', function (assert) {
20332 var i, ordinalStr, testMoment;
20333 for (i = 1; i <= 31; ++i) {
20334 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
20335 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
20336 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
20337 }
20338 });
20339
20340 }));
20341
20342 (function (global, factory) {
20343 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
20344 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
20345 factory(global.moment)
20346 }(this, function (moment) { 'use strict';
20347
20348 /*global QUnit:false*/
20349
20350 var test = QUnit.test;
20351
20352 function module (name, lifecycle) {
20353 QUnit.module(name, {
20354 setup : function () {
20355 moment.locale('en');
20356 moment.createFromInputFallback = function () {
20357 throw new Error('input not handled by moment');
20358 };
20359 if (lifecycle && lifecycle.setup) {
20360 lifecycle.setup();
20361 }
20362 },
20363 teardown : function () {
20364 if (lifecycle && lifecycle.teardown) {
20365 lifecycle.teardown();
20366 }
20367 }
20368 });
20369 }
20370
20371 function localeModule (name, lifecycle) {
20372 QUnit.module('locale:' + name, {
20373 setup : function () {
20374 moment.locale(name);
20375 moment.createFromInputFallback = function () {
20376 throw new Error('input not handled by moment');
20377 };
20378 if (lifecycle && lifecycle.setup) {
20379 lifecycle.setup();
20380 }
20381 },
20382 teardown : function () {
20383 moment.locale('en');
20384 if (lifecycle && lifecycle.teardown) {
20385 lifecycle.teardown();
20386 }
20387 }
20388 });
20389 }
20390
20391 localeModule('ms');
20392
20393 test('parse', function (assert) {
20394 var i,
20395 tests = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
20396
20397 function equalTest(input, mmm, i) {
20398 assert.equal(moment(input, mmm).month(), i, input + ' sepatutnya bulan ' + (i + 1));
20399 }
20400
20401 for (i = 0; i < 12; i++) {
20402 tests[i] = tests[i].split(' ');
20403 equalTest(tests[i][0], 'MMM', i);
20404 equalTest(tests[i][1], 'MMM', i);
20405 equalTest(tests[i][0], 'MMMM', i);
20406 equalTest(tests[i][1], 'MMMM', i);
20407 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
20408 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20409 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20410 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20411 }
20412 });
20413
20414 test('format', function (assert) {
20415 var a = [
20416 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Ahad, Februari 14 2010, 3:25:50 petang'],
20417 ['ddd, hA', 'Ahd, 3petang'],
20418 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
20419 ['YYYY YY', '2010 10'],
20420 ['D Do DD', '14 14 14'],
20421 ['d do dddd ddd dd', '0 0 Ahad Ahd Ah'],
20422 ['DDD DDDo DDDD', '45 45 045'],
20423 ['w wo ww', '7 7 07'],
20424 ['h hh', '3 03'],
20425 ['H HH', '15 15'],
20426 ['m mm', '25 25'],
20427 ['s ss', '50 50'],
20428 ['a A', 'petang petang'],
20429 ['[hari] [ke] DDDo [tahun] ini', 'hari ke 45 tahun ini'],
20430 ['LTS', '15.25.50'],
20431 ['L', '14/02/2010'],
20432 ['LL', '14 Februari 2010'],
20433 ['LLL', '14 Februari 2010 pukul 15.25'],
20434 ['LLLL', 'Ahad, 14 Februari 2010 pukul 15.25'],
20435 ['l', '14/2/2010'],
20436 ['ll', '14 Feb 2010'],
20437 ['lll', '14 Feb 2010 pukul 15.25'],
20438 ['llll', 'Ahd, 14 Feb 2010 pukul 15.25']
20439 ],
20440 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
20441 i;
20442
20443 for (i = 0; i < a.length; i++) {
20444 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
20445 }
20446 });
20447
20448 test('format ordinal', function (assert) {
20449 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
20450 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
20451 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
20452 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
20453 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
20454 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
20455 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
20456 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
20457 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
20458 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
20459
20460 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
20461 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
20462 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
20463 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
20464 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
20465 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
20466 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
20467 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
20468 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
20469 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
20470
20471 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
20472 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
20473 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
20474 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
20475 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
20476 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
20477 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
20478 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
20479 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
20480 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
20481
20482 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
20483 });
20484
20485 test('format month', function (assert) {
20486 var i,
20487 expected = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
20488
20489 for (i = 0; i < expected.length; i++) {
20490 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
20491 }
20492 });
20493
20494 test('format week', function (assert) {
20495 var i,
20496 expected = 'Ahad Ahd Ah_Isnin Isn Is_Selasa Sel Sl_Rabu Rab Rb_Khamis Kha Km_Jumaat Jum Jm_Sabtu Sab Sb'.split('_');
20497
20498 for (i = 0; i < expected.length; i++) {
20499 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
20500 }
20501 });
20502
20503 test('from', function (assert) {
20504 var start = moment([2007, 1, 28]);
20505
20506 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'beberapa saat', '44 saat = beberapa saat');
20507 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'seminit', '45 saat = seminit');
20508 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'seminit', '89 saat = seminit');
20509 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minit', '90 saat = 2 minit');
20510 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minit', '44 minit = 44 minit');
20511 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'sejam', '45 minit = sejam');
20512 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'sejam', '89 minit = sejam');
20513 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minit = 2 jam');
20514 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 jam = 5 jam');
20515 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 jam = 21 jam');
20516 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sehari', '22 jam = sehari');
20517 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sehari', '35 jam = sehari');
20518 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 hari', '36 jam = 2 hari');
20519 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sehari', '1 hari = sehari');
20520 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 hari', '5 hari = 5 hari');
20521 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 hari', '25 hari = 25 hari');
20522 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sebulan', '26 hari = sebulan');
20523 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sebulan', '30 hari = sebulan');
20524 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sebulan', '45 hari = sebulan');
20525 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 bulan', '46 hari = 2 bulan');
20526 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 bulan', '75 hari = 2 bulan');
20527 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 bulan', '76 hari = 3 bulan');
20528 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sebulan', '1 bulan = sebulan');
20529 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 bulan', '5 bulan = 5 bulan');
20530 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setahun', '345 hari = setahun');
20531 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 tahun', '548 hari = 2 tahun');
20532 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setahun', '1 tahun = setahun');
20533 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 tahun', '5 tahun = 5 tahun');
20534 });
20535
20536 test('suffix', function (assert) {
20537 assert.equal(moment(30000).from(0), 'dalam beberapa saat', 'prefix');
20538 assert.equal(moment(0).from(30000), 'beberapa saat yang lepas', 'suffix');
20539 });
20540
20541 test('now from now', function (assert) {
20542 assert.equal(moment().fromNow(), 'beberapa saat yang lepas', 'waktu sekarang dari sekarang sepatutnya menunjukkan sebagai telah lepas');
20543 });
20544
20545 test('fromNow', function (assert) {
20546 assert.equal(moment().add({s: 30}).fromNow(), 'dalam beberapa saat', 'dalam beberapa saat');
20547 assert.equal(moment().add({d: 5}).fromNow(), 'dalam 5 hari', 'dalam 5 hari');
20548 });
20549
20550 test('calendar day', function (assert) {
20551 var a = moment().hours(2).minutes(0).seconds(0);
20552
20553 assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
20554 assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
20555 assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
20556 assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
20557 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
20558 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
20559 });
20560
20561 test('calendar next week', function (assert) {
20562 var i, m;
20563 for (i = 2; i < 7; i++) {
20564 m = moment().add({d: i});
20565 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari waktu sekarang');
20566 m.hours(0).minutes(0).seconds(0).milliseconds(0);
20567 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari permulaan hari');
20568 m.hours(23).minutes(59).seconds(59).milliseconds(999);
20569 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari tamat hari');
20570 }
20571 });
20572
20573 test('calendar last week', function (assert) {
20574 var i, m;
20575 for (i = 2; i < 7; i++) {
20576 m = moment().subtract({d: i});
20577 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari waktu sekarang');
20578 m.hours(0).minutes(0).seconds(0).milliseconds(0);
20579 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari permulaan hari');
20580 m.hours(23).minutes(59).seconds(59).milliseconds(999);
20581 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari tamat hari');
20582 }
20583 });
20584
20585 test('calendar all else', function (assert) {
20586 var weeksAgo = moment().subtract({w: 1}),
20587 weeksFromNow = moment().add({w: 1});
20588
20589 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 minggu lepas');
20590 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 1 minggu');
20591
20592 weeksAgo = moment().subtract({w: 2});
20593 weeksFromNow = moment().add({w: 2});
20594
20595 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 minggu lepas');
20596 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
20597 });
20598
20599 test('weeks year starting sunday', function (assert) {
20600 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
20601 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
20602 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
20603 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
20604 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
20605 });
20606
20607 test('weeks year starting monday', function (assert) {
20608 assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
20609 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
20610 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
20611 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
20612 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
20613 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
20614 });
20615
20616 test('weeks year starting tuesday', function (assert) {
20617 assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
20618 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
20619 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
20620 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
20621 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
20622 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
20623 });
20624
20625 test('weeks year starting wednesday', function (assert) {
20626 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
20627 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
20628 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
20629 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
20630 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
20631 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
20632 });
20633
20634 test('weeks year starting thursday', function (assert) {
20635 assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
20636 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
20637 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
20638 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
20639 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
20640 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
20641 });
20642
20643 test('weeks year starting friday', function (assert) {
20644 assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
20645 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
20646 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
20647 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
20648 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
20649 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
20650 });
20651
20652 test('weeks year starting saturday', function (assert) {
20653 assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
20654 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
20655 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
20656 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
20657 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
20658 });
20659
20660 test('weeks year starting sunday format', function (assert) {
20661 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
20662 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
20663 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 sepatutnya minggu 2');
20664 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 sepatutnya minggu 3');
20665 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
20666 });
20667
20668 test('lenient ordinal parsing', function (assert) {
20669 var i, ordinalStr, testMoment;
20670 for (i = 1; i <= 31; ++i) {
20671 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
20672 testMoment = moment(ordinalStr, 'YYYY MM Do');
20673 assert.equal(testMoment.year(), 2014,
20674 'lenient ordinal parsing ' + i + ' year check');
20675 assert.equal(testMoment.month(), 0,
20676 'lenient ordinal parsing ' + i + ' month check');
20677 assert.equal(testMoment.date(), i,
20678 'lenient ordinal parsing ' + i + ' date check');
20679 }
20680 });
20681
20682 test('meridiem invariant', function (assert) {
20683 var h, m, t1, t2;
20684 for (h = 0; h < 24; ++h) {
20685 for (m = 0; m < 60; m += 15) {
20686 t1 = moment.utc([2000, 0, 1, h, m]);
20687 t2 = moment(t1.format('A h:mm'), 'A h:mm');
20688 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
20689 'meridiem at ' + t1.format('HH:mm'));
20690 }
20691 }
20692 });
20693
20694 test('lenient ordinal parsing of number', function (assert) {
20695 var i, testMoment;
20696 for (i = 1; i <= 31; ++i) {
20697 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
20698 assert.equal(testMoment.year(), 2014,
20699 'lenient ordinal parsing of number ' + i + ' year check');
20700 assert.equal(testMoment.month(), 0,
20701 'lenient ordinal parsing of number ' + i + ' month check');
20702 assert.equal(testMoment.date(), i,
20703 'lenient ordinal parsing of number ' + i + ' date check');
20704 }
20705 });
20706
20707 test('strict ordinal parsing', function (assert) {
20708 var i, ordinalStr, testMoment;
20709 for (i = 1; i <= 31; ++i) {
20710 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
20711 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
20712 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
20713 }
20714 });
20715
20716 }));
20717
20718 (function (global, factory) {
20719 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
20720 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
20721 factory(global.moment)
20722 }(this, function (moment) { 'use strict';
20723
20724 /*global QUnit:false*/
20725
20726 var test = QUnit.test;
20727
20728 function module (name, lifecycle) {
20729 QUnit.module(name, {
20730 setup : function () {
20731 moment.locale('en');
20732 moment.createFromInputFallback = function () {
20733 throw new Error('input not handled by moment');
20734 };
20735 if (lifecycle && lifecycle.setup) {
20736 lifecycle.setup();
20737 }
20738 },
20739 teardown : function () {
20740 if (lifecycle && lifecycle.teardown) {
20741 lifecycle.teardown();
20742 }
20743 }
20744 });
20745 }
20746
20747 function localeModule (name, lifecycle) {
20748 QUnit.module('locale:' + name, {
20749 setup : function () {
20750 moment.locale(name);
20751 moment.createFromInputFallback = function () {
20752 throw new Error('input not handled by moment');
20753 };
20754 if (lifecycle && lifecycle.setup) {
20755 lifecycle.setup();
20756 }
20757 },
20758 teardown : function () {
20759 moment.locale('en');
20760 if (lifecycle && lifecycle.teardown) {
20761 lifecycle.teardown();
20762 }
20763 }
20764 });
20765 }
20766
20767 localeModule('my');
20768
20769 test('parse', function (assert) {
20770 var tests = 'ဇန်နဝါရီ ဇန်_ဖေဖော်ဝါရီ ဖေ_မတ် မတ်_ဧပြီ ပြီ_မေ မေ_ဇွန် ဇွန်_ဇူလိုင် လိုင်_သြဂုတ် သြ_စက်တင်ဘာ စက်_အောက်တိုဘာ အောက်_နိုဝင်ဘာ နို_ဒီဇင်ဘာ ဒီ'.split('_'),
20771 i;
20772
20773 function equalTest (input, mmm, i) {
20774 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
20775 }
20776 for (i = 0; i < 12; i++) {
20777 tests[i] = tests[i].split(' ');
20778 equalTest(tests[i][0], 'MMM', i);
20779 equalTest(tests[i][1], 'MMM', i);
20780 equalTest(tests[i][0], 'MMMM', i);
20781 equalTest(tests[i][1], 'MMMM', i);
20782 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
20783 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20784 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20785 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20786 }
20787 });
20788
20789 test('format', function (assert) {
20790 var a = [
20791 ['dddd, MMMM Do YYYY, h:mm:ss a', 'တနင်္ဂနွေ, ဖေဖော်ဝါရီ ၁၄ ၂၀၁၀, ၃:၂၅:၅၀ pm'],
20792 ['ddd, hA', 'နွေ, ၃PM'],
20793 ['M Mo MM MMMM MMM', '၂ ၂ ၀၂ ဖေဖော်ဝါရီ ဖေ'],
20794 ['YYYY YY', '၂၀၁၀ ၁၀'],
20795 ['D Do DD', '၁၄ ၁၄ ၁၄'],
20796 ['d do dddd ddd dd', '၀ ၀ တနင်္ဂနွေ နွေ နွေ'],
20797 ['DDD DDDo DDDD', '၄၅ ၄၅ ၀၄၅'],
20798 ['w wo ww', '၆ ၆ ၀၆'],
20799 ['h hh', '၃ ၀၃'],
20800 ['H HH', '၁၅ ၁၅'],
20801 ['m mm', '၂၅ ၂၅'],
20802 ['s ss', '၅၀ ၅၀'],
20803 ['a A', 'pm PM'],
20804 ['[နှစ်၏] DDDo [ရက်မြောက်]', 'နှစ်၏ ၄၅ ရက်မြောက်'],
20805 ['LTS', '၁၅:၂၅:၅၀'],
20806 ['L', '၁၄/၀၂/၂၀၁၀'],
20807 ['LL', '၁၄ ဖေဖော်ဝါရီ ၂၀၁၀'],
20808 ['LLL', '၁၄ ဖေဖော်ဝါရီ ၂၀၁၀ ၁၅:၂၅'],
20809 ['LLLL', 'တနင်္ဂနွေ ၁၄ ဖေဖော်ဝါရီ ၂၀၁၀ ၁၅:၂၅'],
20810 ['l', '၁၄/၂/၂၀၁၀'],
20811 ['ll', '၁၄ ဖေ ၂၀၁၀'],
20812 ['lll', '၁၄ ဖေ ၂၀၁၀ ၁၅:၂၅'],
20813 ['llll', 'နွေ ၁၄ ဖေ ၂၀၁၀ ၁၅:၂၅']
20814 ],
20815 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
20816 i;
20817 for (i = 0; i < a.length; i++) {
20818 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
20819 }
20820 });
20821
20822 test('format ordinal', function (assert) {
20823 assert.equal(moment([2011, 0, 1]).format('DDDo'), '၁', '၁');
20824 assert.equal(moment([2011, 0, 2]).format('DDDo'), '၂', '၂');
20825 assert.equal(moment([2011, 0, 3]).format('DDDo'), '၃', '၃');
20826 assert.equal(moment([2011, 0, 4]).format('DDDo'), '၄', '၄');
20827 assert.equal(moment([2011, 0, 5]).format('DDDo'), '၅', '၅');
20828 assert.equal(moment([2011, 0, 6]).format('DDDo'), '၆', '၆');
20829 assert.equal(moment([2011, 0, 7]).format('DDDo'), '၇', '၇');
20830 assert.equal(moment([2011, 0, 8]).format('DDDo'), '၈', '၈');
20831 assert.equal(moment([2011, 0, 9]).format('DDDo'), '၉', '၉');
20832 assert.equal(moment([2011, 0, 10]).format('DDDo'), '၁၀', '၁၀');
20833
20834 assert.equal(moment([2011, 0, 11]).format('DDDo'), '၁၁', '၁၁');
20835 assert.equal(moment([2011, 0, 12]).format('DDDo'), '၁၂', '၁၂');
20836 assert.equal(moment([2011, 0, 13]).format('DDDo'), '၁၃', '၁၃');
20837 assert.equal(moment([2011, 0, 14]).format('DDDo'), '၁၄', '၁၄');
20838 assert.equal(moment([2011, 0, 15]).format('DDDo'), '၁၅', '၁၅');
20839 assert.equal(moment([2011, 0, 16]).format('DDDo'), '၁၆', '၁၆');
20840 assert.equal(moment([2011, 0, 17]).format('DDDo'), '၁၇', '၁၇');
20841 assert.equal(moment([2011, 0, 18]).format('DDDo'), '၁၈', '၁၈');
20842 assert.equal(moment([2011, 0, 19]).format('DDDo'), '၁၉', '၁၉');
20843 assert.equal(moment([2011, 0, 20]).format('DDDo'), '၂၀', '၂၀');
20844
20845 assert.equal(moment([2011, 0, 21]).format('DDDo'), '၂၁', '၂၁');
20846 assert.equal(moment([2011, 0, 22]).format('DDDo'), '၂၂', '၂၂');
20847 assert.equal(moment([2011, 0, 23]).format('DDDo'), '၂၃', '၂၃');
20848 assert.equal(moment([2011, 0, 24]).format('DDDo'), '၂၄', '၂၄');
20849 assert.equal(moment([2011, 0, 25]).format('DDDo'), '၂၅', '၂၅');
20850 assert.equal(moment([2011, 0, 26]).format('DDDo'), '၂၆', '၂၆');
20851 assert.equal(moment([2011, 0, 27]).format('DDDo'), '၂၇', '၂၇');
20852 assert.equal(moment([2011, 0, 28]).format('DDDo'), '၂၈', '၂၈');
20853 assert.equal(moment([2011, 0, 29]).format('DDDo'), '၂၉', '၂၉');
20854 assert.equal(moment([2011, 0, 30]).format('DDDo'), '၃၀', '၃၀');
20855
20856 assert.equal(moment([2011, 0, 31]).format('DDDo'), '၃၁', '၃၁');
20857 });
20858
20859 test('format month', function (assert) {
20860 var expected = 'ဇန်နဝါရီ ဇန်_ဖေဖော်ဝါရီ ဖေ_မတ် မတ်_ဧပြီ ပြီ_မေ မေ_ဇွန် ဇွန်_ဇူလိုင် လိုင်_သြဂုတ် သြ_စက်တင်ဘာ စက်_အောက်တိုဘာ အောက်_နိုဝင်ဘာ နို_ဒီဇင်ဘာ ဒီ'.split('_'),
20861 i;
20862 for (i = 0; i < expected.length; i++) {
20863 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
20864 }
20865 });
20866
20867 test('format week', function (assert) {
20868 var expected = 'တနင်္ဂနွေ နွေ နွေ_တနင်္လာ လာ လာ_အင်္ဂါ ဂါ ဂါ_ဗုဒ္ဓဟူး ဟူး ဟူး_ကြာသပတေး ကြာ ကြာ_သောကြာ သော သော_စနေ နေ နေ'.split('_'),
20869 i;
20870
20871 for (i = 0; i < expected.length; i++) {
20872 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
20873 }
20874 });
20875
20876 test('from', function (assert) {
20877 var start = moment([2007, 1, 28]);
20878 assert.equal(start.from(moment([2007, 1, 28]).add({
20879 s: 44
20880 }), true), 'စက္ကန်.အနည်းငယ်', '၄၄ စက္ကန်. = စက္ကန်.အနည်းငယ်');
20881 assert.equal(start.from(moment([2007, 1, 28]).add({
20882 s: 45
20883 }), true), 'တစ်မိနစ်', '၄၅ စက္ကန်. = တစ်မိနစ်');
20884 assert.equal(start.from(moment([2007, 1, 28]).add({
20885 s: 89
20886 }), true), 'တစ်မိနစ်', '၈၉ စက္ကန်. = တစ်မိနစ်');
20887 assert.equal(start.from(moment([2007, 1, 28]).add({
20888 s: 90
20889 }), true), '၂ မိနစ်', '၉၀ စက္ကန်. = ၂ မိနစ်');
20890 assert.equal(start.from(moment([2007, 1, 28]).add({
20891 m: 44
20892 }), true), '၄၄ မိနစ်', '၄၄ မိနစ် = ၄၄ မိနစ်');
20893 assert.equal(start.from(moment([2007, 1, 28]).add({
20894 m: 45
20895 }), true), 'တစ်နာရီ', '၄၅ မိနစ် = ၁ နာရီ');
20896 assert.equal(start.from(moment([2007, 1, 28]).add({
20897 m: 89
20898 }), true), 'တစ်နာရီ', '၈၉ မိနစ် = တစ်နာရီ');
20899 assert.equal(start.from(moment([2007, 1, 28]).add({
20900 m: 90
20901 }), true), '၂ နာရီ', 'မိနစ် ၉၀= ၂ နာရီ');
20902 assert.equal(start.from(moment([2007, 1, 28]).add({
20903 h: 5
20904 }), true), '၅ နာရီ', '၅ နာရီ= ၅ နာရီ');
20905 assert.equal(start.from(moment([2007, 1, 28]).add({
20906 h: 21
20907 }), true), '၂၁ နာရီ', '၂၁ နာရီ =၂၁ နာရီ');
20908 assert.equal(start.from(moment([2007, 1, 28]).add({
20909 h: 22
20910 }), true), 'တစ်ရက်', '၂၂ နာရီ =တစ်ရက်');
20911 assert.equal(start.from(moment([2007, 1, 28]).add({
20912 h: 35
20913 }), true), 'တစ်ရက်', '၃၅ နာရီ =တစ်ရက်');
20914 assert.equal(start.from(moment([2007, 1, 28]).add({
20915 h: 36
20916 }), true), '၂ ရက်', '၃၆ နာရီ = ၂ ရက်');
20917 assert.equal(start.from(moment([2007, 1, 28]).add({
20918 d: 1
20919 }), true), 'တစ်ရက်', '၁ ရက်= တစ်ရက်');
20920 assert.equal(start.from(moment([2007, 1, 28]).add({
20921 d: 5
20922 }), true), '၅ ရက်', '၅ ရက် = ၅ ရက်');
20923 assert.equal(start.from(moment([2007, 1, 28]).add({
20924 d: 25
20925 }), true), '၂၅ ရက်', '၂၅ ရက်= ၂၅ ရက်');
20926 assert.equal(start.from(moment([2007, 1, 28]).add({
20927 d: 26
20928 }), true), 'တစ်လ', '၂၆ ရက် = တစ်လ');
20929 assert.equal(start.from(moment([2007, 1, 28]).add({
20930 d: 30
20931 }), true), 'တစ်လ', 'ရက် ၃၀ = တစ်လ');
20932 assert.equal(start.from(moment([2007, 1, 28]).add({
20933 d: 43
20934 }), true), 'တစ်လ', '၄၃ ရက် = တစ်လ');
20935 assert.equal(start.from(moment([2007, 1, 28]).add({
20936 d: 46
20937 }), true), '၂ လ', '၄၆ ရက် = ၂ လ');
20938 assert.equal(start.from(moment([2007, 1, 28]).add({
20939 d: 74
20940 }), true), '၂ လ', '၇၅ ရက်= ၂ လ');
20941 assert.equal(start.from(moment([2007, 1, 28]).add({
20942 d: 76
20943 }), true), '၃ လ', '၇၆ ရက် = ၃ လ');
20944 assert.equal(start.from(moment([2007, 1, 28]).add({
20945 M: 1
20946 }), true), 'တစ်လ', '၁ လ = တစ်လ');
20947 assert.equal(start.from(moment([2007, 1, 28]).add({
20948 M: 5
20949 }), true), '၅ လ', '၅ လ = ၅ လ');
20950 assert.equal(start.from(moment([2007, 1, 28]).add({
20951 d: 345
20952 }), true), 'တစ်နှစ်', '၃၄၅ ရက် = တစ်နှစ်');
20953 assert.equal(start.from(moment([2007, 1, 28]).add({
20954 d: 548
20955 }), true), '၂ နှစ်', '၅၄၈ ရက် = ၂ နှစ်');
20956 assert.equal(start.from(moment([2007, 1, 28]).add({
20957 y: 1
20958 }), true), 'တစ်နှစ်', '၁ နှစ် = တစ်နှစ်');
20959 assert.equal(start.from(moment([2007, 1, 28]).add({
20960 y: 5
20961 }), true), '၅ နှစ်', '၅ နှစ် = ၅ နှစ်');
20962 });
20963
20964 test('suffix', function (assert) {
20965 assert.equal(moment(30000).from(0), 'လာမည့် စက္ကန်.အနည်းငယ် မှာ', 'prefix');
20966 assert.equal(moment(0).from(30000), 'လွန်ခဲ့သော စက္ကန်.အနည်းငယ် က', 'suffix');
20967 });
20968
20969 test('now from now', function (assert) {
20970 assert.equal(moment().fromNow(), 'လွန်ခဲ့သော စက္ကန်.အနည်းငယ် က', 'ယခုမှစပြီး အတိတ်တွင်ဖော်ပြသလိုဖော်ပြမည်');
20971 });
20972
20973 test('fromNow', function (assert) {
20974 assert.equal(moment().add({
20975 s: 30
20976 }).fromNow(), 'လာမည့် စက္ကန်.အနည်းငယ် မှာ', 'လာမည့် စက္ကန်.အနည်းငယ် မှာ');
20977 assert.equal(moment().add({
20978 d: 5
20979 }).fromNow(), 'လာမည့် ၅ ရက် မှာ', 'လာမည့် ၅ ရက် မှာ');
20980 });
20981
20982 test('calendar day', function (assert) {
20983 var a = moment().hours(2).minutes(0).seconds(0);
20984
20985 assert.equal(moment(a).calendar(), 'ယနေ. ၀၂:၀၀ မှာ', 'ယနေ. ဒီအချိန်');
20986 assert.equal(moment(a).add({
20987 m: 25
20988 }).calendar(), 'ယနေ. ၀၂:၂၅ မှာ', 'ယခုမှ ၂၅ မိနစ်ပေါင်းထည့်');
20989 assert.equal(moment(a).add({
20990 h: 1
20991 }).calendar(), 'ယနေ. ၀၃:၀၀ မှာ', 'ယခုမှ ၁ နာရီပေါင်းထည့်');
20992 assert.equal(moment(a).add({
20993 d: 1
20994 }).calendar(), 'မနက်ဖြန် ၀၂:၀၀ မှာ', 'မနက်ဖြန် ဒီအချိန်');
20995 assert.equal(moment(a).subtract({
20996 h: 1
20997 }).calendar(), 'ယနေ. ၀၁:၀၀ မှာ', 'ယခုမှ ၁ နာရီနှုတ်');
20998 assert.equal(moment(a).subtract({
20999 d: 1
21000 }).calendar(), 'မနေ.က ၀၂:၀၀ မှာ', 'မနေ.က ဒီအချိန်');
21001 });
21002
21003 test('calendar next week', function (assert) {
21004 var i, m;
21005 for (i = 2; i < 7; i++) {
21006 m = moment().add({
21007 d: i
21008 });
21009 assert.equal(m.calendar(), m.format('dddd LT [မှာ]'), 'Today + ' + i + ' days current time');
21010 m.hours(0).minutes(0).seconds(0).milliseconds(0);
21011 assert.equal(m.calendar(), m.format('dddd LT [မှာ]'), 'Today + ' + i + ' days beginning of day');
21012 m.hours(23).minutes(59).seconds(59).milliseconds(999);
21013 assert.equal(m.calendar(), m.format('dddd LT [မှာ]'), 'Today + ' + i + ' days end of day');
21014 }
21015 });
21016
21017 test('calendar last week', function (assert) {
21018 var i, m;
21019
21020 for (i = 2; i < 7; i++) {
21021 m = moment().subtract({
21022 d: i
21023 });
21024 assert.equal(m.calendar(), m.format('[ပြီးခဲ့သော] dddd LT [မှာ]'), 'Today - ' + i + ' days current time');
21025 m.hours(0).minutes(0).seconds(0).milliseconds(0);
21026 assert.equal(m.calendar(), m.format('[ပြီးခဲ့သော] dddd LT [မှာ]'), 'Today - ' + i + ' days beginning of day');
21027 m.hours(23).minutes(59).seconds(59).milliseconds(999);
21028 assert.equal(m.calendar(), m.format('[ပြီးခဲ့သော] dddd LT [မှာ]'), 'Today - ' + i + ' days end of day');
21029 }
21030 });
21031
21032 test('calendar all else', function (assert) {
21033 var weeksAgo = moment().subtract({
21034 w: 1
21035 }),
21036 weeksFromNow = moment().add({
21037 w: 1
21038 });
21039
21040 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'လွန်ခဲ့သော ၁ ပတ်က');
21041 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '၁ ပတ်အတွင်း');
21042
21043 weeksAgo = moment().subtract({
21044 w: 2
21045 });
21046 weeksFromNow = moment().add({
21047 w: 2
21048 });
21049
21050 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '၂ ပတ် အရင်က');
21051 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '၂ ပတ် အတွင်း');
21052 });
21053
21054 test('weeks year starting sunday', function (assert) {
21055 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
21056 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
21057 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
21058 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
21059 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
21060 });
21061
21062 test('weeks year starting monday', function (assert) {
21063 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
21064 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
21065 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
21066 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
21067 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
21068 });
21069
21070 test('weeks year starting tuesday', function (assert) {
21071 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
21072 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
21073 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
21074 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
21075 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
21076 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
21077 });
21078
21079 test('weeks year starting wednesday', function (assert) {
21080 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
21081 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
21082 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
21083 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
21084 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
21085 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
21086 });
21087
21088 test('weeks year starting thursday', function (assert) {
21089 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
21090 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
21091 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
21092 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
21093 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
21094 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
21095 });
21096
21097 test('weeks year starting friday', function (assert) {
21098 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
21099 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
21100 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
21101 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
21102 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
21103 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
21104 });
21105
21106 test('weeks year starting saturday', function (assert) {
21107 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
21108 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
21109 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
21110 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
21111 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
21112 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
21113 });
21114
21115 test('weeks year starting sunday formatted', function (assert) {
21116 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '၅၂ ၅၂ ၅၂', 'Jan 1 2012 should be week 52');
21117 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '၁ ၀၁ ၁', 'Jan 2 2012 should be week 1');
21118 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '၁ ၀၁ ၁', 'Jan 8 2012 should be week 1');
21119 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 9 2012 should be week 2');
21120 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 15 2012 should be week 2');
21121 });
21122
21123 test('lenient ordinal parsing', function (assert) {
21124 var i, ordinalStr, testMoment;
21125 for (i = 1; i <= 31; ++i) {
21126 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
21127 testMoment = moment(ordinalStr, 'YYYY MM Do');
21128 assert.equal(testMoment.year(), 2014,
21129 'lenient ordinal parsing ' + i + ' year check');
21130 assert.equal(testMoment.month(), 0,
21131 'lenient ordinal parsing ' + i + ' month check');
21132 assert.equal(testMoment.date(), i,
21133 'lenient ordinal parsing ' + i + ' date check');
21134 }
21135 });
21136
21137 test('lenient ordinal parsing of number', function (assert) {
21138 var i, testMoment;
21139 for (i = 1; i <= 31; ++i) {
21140 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
21141 assert.equal(testMoment.year(), 2014,
21142 'lenient ordinal parsing of number ' + i + ' year check');
21143 assert.equal(testMoment.month(), 0,
21144 'lenient ordinal parsing of number ' + i + ' month check');
21145 assert.equal(testMoment.date(), i,
21146 'lenient ordinal parsing of number ' + i + ' date check');
21147 }
21148 });
21149
21150 test('strict ordinal parsing', function (assert) {
21151 var i, ordinalStr, testMoment;
21152 for (i = 1; i <= 31; ++i) {
21153 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
21154 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
21155 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
21156 }
21157 });
21158
21159 }));
21160
21161 (function (global, factory) {
21162 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
21163 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
21164 factory(global.moment)
21165 }(this, function (moment) { 'use strict';
21166
21167 /*global QUnit:false*/
21168
21169 var test = QUnit.test;
21170
21171 function module (name, lifecycle) {
21172 QUnit.module(name, {
21173 setup : function () {
21174 moment.locale('en');
21175 moment.createFromInputFallback = function () {
21176 throw new Error('input not handled by moment');
21177 };
21178 if (lifecycle && lifecycle.setup) {
21179 lifecycle.setup();
21180 }
21181 },
21182 teardown : function () {
21183 if (lifecycle && lifecycle.teardown) {
21184 lifecycle.teardown();
21185 }
21186 }
21187 });
21188 }
21189
21190 function localeModule (name, lifecycle) {
21191 QUnit.module('locale:' + name, {
21192 setup : function () {
21193 moment.locale(name);
21194 moment.createFromInputFallback = function () {
21195 throw new Error('input not handled by moment');
21196 };
21197 if (lifecycle && lifecycle.setup) {
21198 lifecycle.setup();
21199 }
21200 },
21201 teardown : function () {
21202 moment.locale('en');
21203 if (lifecycle && lifecycle.teardown) {
21204 lifecycle.teardown();
21205 }
21206 }
21207 });
21208 }
21209
21210 localeModule('nb');
21211
21212 test('parse', function (assert) {
21213 var tests = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'),
21214 i;
21215 function equalTest(input, mmm, i) {
21216 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
21217 }
21218 for (i = 0; i < 12; i++) {
21219 tests[i] = tests[i].split(' ');
21220 equalTest(tests[i][0], 'MMM', i);
21221 equalTest(tests[i][1], 'MMM', i);
21222 equalTest(tests[i][0], 'MMMM', i);
21223 equalTest(tests[i][1], 'MMMM', i);
21224 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
21225 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
21226 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21227 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21228 }
21229 });
21230
21231 test('format', function (assert) {
21232 var a = [
21233 ['dddd, MMMM Do YYYY, h:mm:ss a', 'søndag, februar 14. 2010, 3:25:50 pm'],
21234 ['ddd, hA', 'søn, 3PM'],
21235 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
21236 ['YYYY YY', '2010 10'],
21237 ['D Do DD', '14 14. 14'],
21238 ['d do dddd ddd dd', '0 0. søndag søn sø'],
21239 ['DDD DDDo DDDD', '45 45. 045'],
21240 ['w wo ww', '6 6. 06'],
21241 ['h hh', '3 03'],
21242 ['H HH', '15 15'],
21243 ['m mm', '25 25'],
21244 ['s ss', '50 50'],
21245 ['a A', 'pm PM'],
21246 ['[den] DDDo [dagen i året]', 'den 45. dagen i året'],
21247 ['LTS', '15.25.50'],
21248 ['L', '14.02.2010'],
21249 ['LL', '14. februar 2010'],
21250 ['LLL', '14. februar 2010 kl. 15.25'],
21251 ['LLLL', 'søndag 14. februar 2010 kl. 15.25'],
21252 ['l', '14.2.2010'],
21253 ['ll', '14. feb 2010'],
21254 ['lll', '14. feb 2010 kl. 15.25'],
21255 ['llll', 'søn 14. feb 2010 kl. 15.25']
21256 ],
21257 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
21258 i;
21259 for (i = 0; i < a.length; i++) {
21260 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
21261 }
21262 });
21263
21264 test('format ordinal', function (assert) {
21265 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
21266 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
21267 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
21268 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
21269 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
21270 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
21271 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
21272 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
21273 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
21274 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
21275
21276 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
21277 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
21278 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
21279 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
21280 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
21281 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
21282 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
21283 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
21284 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
21285 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
21286
21287 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
21288 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
21289 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
21290 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
21291 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
21292 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
21293 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
21294 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
21295 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
21296 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
21297
21298 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
21299 });
21300
21301 test('format month', function (assert) {
21302 var expected = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
21303 for (i = 0; i < expected.length; i++) {
21304 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
21305 }
21306 });
21307
21308 test('format week', function (assert) {
21309 var expected = 'søndag søn sø_mandag man ma_tirsdag tirs ti_onsdag ons on_torsdag tors to_fredag fre fr_lørdag lør lø'.split('_'), i;
21310 for (i = 0; i < expected.length; i++) {
21311 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
21312 }
21313 });
21314
21315 test('from', function (assert) {
21316 var start = moment([2007, 1, 28]);
21317 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'noen sekunder', '44 sekunder = a few seconds');
21318 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ett minutt', '45 seconds = a minute');
21319 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ett minutt', '89 seconds = a minute');
21320 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutter', '90 seconds = 2 minutes');
21321 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutter', '44 minutes = 44 minutes');
21322 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'en time', '45 minutes = an hour');
21323 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'en time', '89 minutes = an hour');
21324 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timer', '90 minutes = 2 hours');
21325 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timer', '5 hours = 5 hours');
21326 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timer', '21 hours = 21 hours');
21327 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dag', '22 hours = a day');
21328 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dag', '35 hours = a day');
21329 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dager', '36 hours = 2 days');
21330 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dag', '1 day = a day');
21331 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dager', '5 days = 5 days');
21332 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dager', '25 days = 25 days');
21333 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en måned', '26 days = a month');
21334 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en måned', '30 days = a month');
21335 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en måned', '43 days = a month');
21336 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 måneder', '46 days = 2 months');
21337 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 måneder', '75 days = 2 months');
21338 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 måneder', '76 days = 3 months');
21339 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en måned', '1 month = a month');
21340 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 måneder', '5 months = 5 months');
21341 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ett år', '345 days = a year');
21342 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
21343 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ett år', '1 year = a year');
21344 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
21345 });
21346
21347 test('suffix', function (assert) {
21348 assert.equal(moment(30000).from(0), 'om noen sekunder', 'prefix');
21349 assert.equal(moment(0).from(30000), 'for noen sekunder siden', 'suffix');
21350 });
21351
21352 test('now from now', function (assert) {
21353 assert.equal(moment().fromNow(), 'for noen sekunder siden', 'now from now should display as in the past');
21354 });
21355
21356 test('fromNow', function (assert) {
21357 assert.equal(moment().add({s: 30}).fromNow(), 'om noen sekunder', 'in a few seconds');
21358 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dager', 'in 5 days');
21359 });
21360
21361 test('calendar day', function (assert) {
21362 var a = moment().hours(2).minutes(0).seconds(0);
21363
21364 assert.equal(moment(a).calendar(), 'i dag kl. 2.00', 'today at the same time');
21365 assert.equal(moment(a).add({m: 25}).calendar(), 'i dag kl. 2.25', 'Now plus 25 min');
21366 assert.equal(moment(a).add({h: 1}).calendar(), 'i dag kl. 3.00', 'Now plus 1 hour');
21367 assert.equal(moment(a).add({d: 1}).calendar(), 'i morgen kl. 2.00', 'tomorrow at the same time');
21368 assert.equal(moment(a).subtract({h: 1}).calendar(), 'i dag kl. 1.00', 'Now minus 1 hour');
21369 assert.equal(moment(a).subtract({d: 1}).calendar(), 'i går kl. 2.00', 'yesterday at the same time');
21370 });
21371
21372 test('calendar next week', function (assert) {
21373 var i, m;
21374 for (i = 2; i < 7; i++) {
21375 m = moment().add({d: i});
21376 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days current time');
21377 m.hours(0).minutes(0).seconds(0).milliseconds(0);
21378 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days beginning of day');
21379 m.hours(23).minutes(59).seconds(59).milliseconds(999);
21380 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days end of day');
21381 }
21382 });
21383
21384 test('calendar last week', function (assert) {
21385 var i, m;
21386 for (i = 2; i < 7; i++) {
21387 m = moment().subtract({d: i});
21388 assert.equal(m.calendar(), m.format('[forrige] dddd [kl.] LT'), 'Today - ' + i + ' days current time');
21389 m.hours(0).minutes(0).seconds(0).milliseconds(0);
21390 assert.equal(m.calendar(), m.format('[forrige] dddd [kl.] LT'), 'Today - ' + i + ' days beginning of day');
21391 m.hours(23).minutes(59).seconds(59).milliseconds(999);
21392 assert.equal(m.calendar(), m.format('[forrige] dddd [kl.] LT'), 'Today - ' + i + ' days end of day');
21393 }
21394 });
21395
21396 test('calendar all else', function (assert) {
21397 var weeksAgo = moment().subtract({w: 1}),
21398 weeksFromNow = moment().add({w: 1});
21399
21400 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
21401 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
21402
21403 weeksAgo = moment().subtract({w: 2});
21404 weeksFromNow = moment().add({w: 2});
21405
21406 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
21407 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
21408 });
21409
21410 test('weeks year starting sunday', function (assert) {
21411 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
21412 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
21413 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
21414 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
21415 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
21416 });
21417
21418 test('weeks year starting monday', function (assert) {
21419 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
21420 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
21421 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
21422 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
21423 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
21424 });
21425
21426 test('weeks year starting tuesday', function (assert) {
21427 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
21428 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
21429 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
21430 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
21431 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
21432 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
21433 });
21434
21435 test('weeks year starting wednesday', function (assert) {
21436 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
21437 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
21438 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
21439 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
21440 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
21441 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
21442 });
21443
21444 test('weeks year starting thursday', function (assert) {
21445 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
21446 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
21447 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
21448 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
21449 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
21450 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
21451 });
21452
21453 test('weeks year starting friday', function (assert) {
21454 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
21455 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
21456 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
21457 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
21458 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
21459 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
21460 });
21461
21462 test('weeks year starting saturday', function (assert) {
21463 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
21464 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
21465 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
21466 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
21467 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
21468 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
21469 });
21470
21471 test('weeks year starting sunday formatted', function (assert) {
21472 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
21473 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
21474 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
21475 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
21476 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
21477 });
21478
21479 test('lenient ordinal parsing', function (assert) {
21480 var i, ordinalStr, testMoment;
21481 for (i = 1; i <= 31; ++i) {
21482 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
21483 testMoment = moment(ordinalStr, 'YYYY MM Do');
21484 assert.equal(testMoment.year(), 2014,
21485 'lenient ordinal parsing ' + i + ' year check');
21486 assert.equal(testMoment.month(), 0,
21487 'lenient ordinal parsing ' + i + ' month check');
21488 assert.equal(testMoment.date(), i,
21489 'lenient ordinal parsing ' + i + ' date check');
21490 }
21491 });
21492
21493 test('lenient ordinal parsing of number', function (assert) {
21494 var i, testMoment;
21495 for (i = 1; i <= 31; ++i) {
21496 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
21497 assert.equal(testMoment.year(), 2014,
21498 'lenient ordinal parsing of number ' + i + ' year check');
21499 assert.equal(testMoment.month(), 0,
21500 'lenient ordinal parsing of number ' + i + ' month check');
21501 assert.equal(testMoment.date(), i,
21502 'lenient ordinal parsing of number ' + i + ' date check');
21503 }
21504 });
21505
21506 test('strict ordinal parsing', function (assert) {
21507 var i, ordinalStr, testMoment;
21508 for (i = 1; i <= 31; ++i) {
21509 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
21510 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
21511 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
21512 }
21513 });
21514
21515 }));
21516
21517 (function (global, factory) {
21518 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
21519 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
21520 factory(global.moment)
21521 }(this, function (moment) { 'use strict';
21522
21523 /*global QUnit:false*/
21524
21525 var test = QUnit.test;
21526
21527 function module (name, lifecycle) {
21528 QUnit.module(name, {
21529 setup : function () {
21530 moment.locale('en');
21531 moment.createFromInputFallback = function () {
21532 throw new Error('input not handled by moment');
21533 };
21534 if (lifecycle && lifecycle.setup) {
21535 lifecycle.setup();
21536 }
21537 },
21538 teardown : function () {
21539 if (lifecycle && lifecycle.teardown) {
21540 lifecycle.teardown();
21541 }
21542 }
21543 });
21544 }
21545
21546 function localeModule (name, lifecycle) {
21547 QUnit.module('locale:' + name, {
21548 setup : function () {
21549 moment.locale(name);
21550 moment.createFromInputFallback = function () {
21551 throw new Error('input not handled by moment');
21552 };
21553 if (lifecycle && lifecycle.setup) {
21554 lifecycle.setup();
21555 }
21556 },
21557 teardown : function () {
21558 moment.locale('en');
21559 if (lifecycle && lifecycle.teardown) {
21560 lifecycle.teardown();
21561 }
21562 }
21563 });
21564 }
21565
21566 localeModule('ne');
21567
21568 test('parse', function (assert) {
21569 var tests = 'जनवरी जन._फेब्रुवरी फेब्रु._मार्च मार्च_अप्रिल अप्रि._मई मई_जुन जुन_जुलाई जुलाई._अगष्ट अग._सेप्टेम्बर सेप्ट._अक्टोबर अक्टो._नोभेम्बर नोभे._डिसेम्बर डिसे.'.split('_'), i;
21570 function equalTest(input, mmm, i) {
21571 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
21572 }
21573 for (i = 0; i < 12; i++) {
21574 tests[i] = tests[i].split(' ');
21575 equalTest(tests[i][0], 'MMM', i);
21576 equalTest(tests[i][1], 'MMM', i);
21577 equalTest(tests[i][0], 'MMMM', i);
21578 equalTest(tests[i][1], 'MMMM', i);
21579 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
21580 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
21581 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21582 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21583 }
21584 });
21585
21586 test('format', function (assert) {
21587 var a = [
21588 ['dddd, Do MMMM YYYY, aको h:mm:ss बजे', 'आइतबार, १४ फेब्रुवरी २०१०, बेलुकाको ३:२५:५० बजे'],
21589 ['ddd, aको h बजे', 'आइत., बेलुकाको ३ बजे'],
21590 ['M Mo MM MMMM MMM', '२ २ ०२ फेब्रुवरी फेब्रु.'],
21591 ['YYYY YY', '२०१० १०'],
21592 ['D Do DD', '१४ १४ १४'],
21593 ['d do dddd ddd dd', '० ० आइतबार आइत. आइ.'],
21594 ['DDD DDDo DDDD', '४५ ४५ ०४५'],
21595 ['w wo ww', '७ ७ ०७'],
21596 ['h hh', '३ ०३'],
21597 ['H HH', '१५ १५'],
21598 ['m mm', '२५ २५'],
21599 ['s ss', '५० ५०'],
21600 ['a A', 'बेलुका बेलुका'],
21601 ['LTS', 'बेलुकाको ३:२५:५० बजे'],
21602 ['L', '१४/०२/२०१०'],
21603 ['LL', '१४ फेब्रुवरी २०१०'],
21604 ['LLL', '१४ फेब्रुवरी २०१०, बेलुकाको ३:२५ बजे'],
21605 ['LLLL', 'आइतबार, १४ फेब्रुवरी २०१०, बेलुकाको ३:२५ बजे'],
21606 ['l', '१४/२/२०१०'],
21607 ['ll', '१४ फेब्रु. २०१०'],
21608 ['lll', '१४ फेब्रु. २०१०, बेलुकाको ३:२५ बजे'],
21609 ['llll', 'आइत., १४ फेब्रु. २०१०, बेलुकाको ३:२५ बजे']
21610 ],
21611 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
21612 i;
21613 for (i = 0; i < a.length; i++) {
21614 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
21615 }
21616 });
21617
21618 test('format ordinal', function (assert) {
21619 assert.equal(moment([2011, 0, 1]).format('DDDo'), '१', '१');
21620 assert.equal(moment([2011, 0, 2]).format('DDDo'), '२', '२');
21621 assert.equal(moment([2011, 0, 3]).format('DDDo'), '३', '३');
21622 assert.equal(moment([2011, 0, 4]).format('DDDo'), '४', '४');
21623 assert.equal(moment([2011, 0, 5]).format('DDDo'), '५', '५');
21624 assert.equal(moment([2011, 0, 6]).format('DDDo'), '६', '६');
21625 assert.equal(moment([2011, 0, 7]).format('DDDo'), '७', '७');
21626 assert.equal(moment([2011, 0, 8]).format('DDDo'), '८', '८');
21627 assert.equal(moment([2011, 0, 9]).format('DDDo'), '९', '९');
21628 assert.equal(moment([2011, 0, 10]).format('DDDo'), '१०', '१०');
21629
21630 assert.equal(moment([2011, 0, 11]).format('DDDo'), '११', '११');
21631 assert.equal(moment([2011, 0, 12]).format('DDDo'), '१२', '१२');
21632 assert.equal(moment([2011, 0, 13]).format('DDDo'), '१३', '१३');
21633 assert.equal(moment([2011, 0, 14]).format('DDDo'), '१४', '१४');
21634 assert.equal(moment([2011, 0, 15]).format('DDDo'), '१५', '१५');
21635 assert.equal(moment([2011, 0, 16]).format('DDDo'), '१६', '१६');
21636 assert.equal(moment([2011, 0, 17]).format('DDDo'), '१७', '१७');
21637 assert.equal(moment([2011, 0, 18]).format('DDDo'), '१८', '१८');
21638 assert.equal(moment([2011, 0, 19]).format('DDDo'), '१९', '१९');
21639 assert.equal(moment([2011, 0, 20]).format('DDDo'), '२०', '२०');
21640
21641 assert.equal(moment([2011, 0, 21]).format('DDDo'), '२१', '२१');
21642 assert.equal(moment([2011, 0, 22]).format('DDDo'), '२२', '२२');
21643 assert.equal(moment([2011, 0, 23]).format('DDDo'), '२३', '२३');
21644 assert.equal(moment([2011, 0, 24]).format('DDDo'), '२४', '२४');
21645 assert.equal(moment([2011, 0, 25]).format('DDDo'), '२५', '२५');
21646 assert.equal(moment([2011, 0, 26]).format('DDDo'), '२६', '२६');
21647 assert.equal(moment([2011, 0, 27]).format('DDDo'), '२७', '२७');
21648 assert.equal(moment([2011, 0, 28]).format('DDDo'), '२८', '२८');
21649 assert.equal(moment([2011, 0, 29]).format('DDDo'), '२९', '२९');
21650 assert.equal(moment([2011, 0, 30]).format('DDDo'), '३०', '३०');
21651
21652 assert.equal(moment([2011, 0, 31]).format('DDDo'), '३१', '३१');
21653 });
21654
21655 test('format month', function (assert) {
21656 var expected = 'जनवरी जन._फेब्रुवरी फेब्रु._मार्च मार्च_अप्रिल अप्रि._मई मई_जुन जुन_जुलाई जुलाई._अगष्ट अग._सेप्टेम्बर सेप्ट._अक्टोबर अक्टो._नोभेम्बर नोभे._डिसेम्बर डिसे.'.split('_'), i;
21657 for (i = 0; i < expected.length; i++) {
21658 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
21659 }
21660 });
21661
21662 test('format week', function (assert) {
21663 var expected = 'आइतबार आइत. आइ._सोमबार सोम. सो._मङ्गलबार मङ्गल. मङ्_बुधबार बुध. बु._बिहिबार बिहि. बि._शुक्रबार शुक्र. शु._शनिबार शनि. श.'.split('_'), i;
21664 for (i = 0; i < expected.length; i++) {
21665 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
21666 }
21667 });
21668
21669 test('from', function (assert) {
21670 var start = moment([2007, 1, 28]);
21671 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'केही समय', '44 seconds = a few seconds');
21672 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'एक मिनेट', '45 seconds = a minute');
21673 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'एक मिनेट', '89 seconds = a minute');
21674 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '२ मिनेट', '90 seconds = 2 minutes');
21675 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '४४ मिनेट', '44 minutes = 44 minutes');
21676 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'एक घण्टा', '45 minutes = an hour');
21677 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'एक घण्टा', '89 minutes = an hour');
21678 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '२ घण्टा', '90 minutes = 2 hours');
21679 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '५ घण्टा', '5 hours = 5 hours');
21680 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '२१ घण्टा', '21 hours = 21 hours');
21681 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'एक दिन', '22 hours = a day');
21682 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'एक दिन', '35 hours = a day');
21683 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '२ दिन', '36 hours = 2 days');
21684 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'एक दिन', '1 day = a day');
21685 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '५ दिन', '5 days = 5 days');
21686 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '२५ दिन', '25 days = 25 days');
21687 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'एक महिना', '26 days = a month');
21688 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'एक महिना', '30 days = a month');
21689 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'एक महिना', '43 days = a month');
21690 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '२ महिना', '46 days = 2 months');
21691 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '२ महिना', '75 days = 2 months');
21692 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '३ महिना', '76 days = 3 months');
21693 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'एक महिना', '1 month = a month');
21694 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '५ महिना', '5 months = 5 months');
21695 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'एक बर्ष', '345 days = a year');
21696 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '२ बर्ष', '548 days = 2 years');
21697 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'एक बर्ष', '1 year = a year');
21698 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '५ बर्ष', '5 years = 5 years');
21699 });
21700
21701 test('suffix', function (assert) {
21702 assert.equal(moment(30000).from(0), 'केही समयमा', 'prefix');
21703 assert.equal(moment(0).from(30000), 'केही समय अगाडी', 'suffix');
21704 });
21705
21706 test('now from now', function (assert) {
21707 assert.equal(moment().fromNow(), 'केही समय अगाडी', 'now from now should display as in the past');
21708 });
21709
21710 test('fromNow', function (assert) {
21711 assert.equal(moment().add({s: 30}).fromNow(), 'केही समयमा', 'केही समयमा');
21712 assert.equal(moment().add({d: 5}).fromNow(), '५ दिनमा', '५ दिनमा');
21713 });
21714
21715 test('calendar day', function (assert) {
21716 var a = moment().hours(2).minutes(0).seconds(0);
21717
21718 assert.equal(moment(a).calendar(), 'आज रातीको २:०० बजे', 'today at the same time');
21719 assert.equal(moment(a).add({m: 25}).calendar(), 'आज रातीको २:२५ बजे', 'Now plus 25 min');
21720 assert.equal(moment(a).add({h: 1}).calendar(), 'आज बिहानको ३:०० बजे', 'Now plus 1 hour');
21721 assert.equal(moment(a).add({d: 1}).calendar(), 'भोली रातीको २:०० बजे', 'tomorrow at the same time');
21722 assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रातीको १:०० बजे', 'Now minus 1 hour');
21723 assert.equal(moment(a).subtract({d: 1}).calendar(), 'हिजो रातीको २:०० बजे', 'yesterday at the same time');
21724 });
21725
21726 test('calendar next week', function (assert) {
21727 var i, m;
21728 for (i = 2; i < 7; i++) {
21729 m = moment().add({d: i});
21730 assert.equal(m.calendar(), m.format('[आउँदो] dddd[,] LT'), 'Today + ' + i + ' days current time');
21731 m.hours(0).minutes(0).seconds(0).milliseconds(0);
21732 assert.equal(m.calendar(), m.format('[आउँदो] dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
21733 m.hours(23).minutes(59).seconds(59).milliseconds(999);
21734 assert.equal(m.calendar(), m.format('[आउँदो] dddd[,] LT'), 'Today + ' + i + ' days end of day');
21735 }
21736 });
21737
21738 test('calendar last week', function (assert) {
21739 var i, m;
21740 for (i = 2; i < 7; i++) {
21741 m = moment().subtract({d: i});
21742 assert.equal(m.calendar(), m.format('[गएको] dddd[,] LT'), 'Today - ' + i + ' days current time');
21743 m.hours(0).minutes(0).seconds(0).milliseconds(0);
21744 assert.equal(m.calendar(), m.format('[गएको] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
21745 m.hours(23).minutes(59).seconds(59).milliseconds(999);
21746 assert.equal(m.calendar(), m.format('[गएको] dddd[,] LT'), 'Today - ' + i + ' days end of day');
21747 }
21748 });
21749
21750 test('calendar all else', function (assert) {
21751 var weeksAgo = moment().subtract({w: 1}),
21752 weeksFromNow = moment().add({w: 1});
21753
21754 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
21755 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
21756
21757 weeksAgo = moment().subtract({w: 2});
21758 weeksFromNow = moment().add({w: 2});
21759
21760 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
21761 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
21762 });
21763
21764 test('meridiem', function (assert) {
21765 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'राती', 'before dawn');
21766 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'बिहान', 'morning');
21767 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दिउँसो', 'during day');
21768 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'बेलुका', 'evening');
21769 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'साँझ', 'late evening');
21770 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'राती', 'night');
21771
21772 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'राती', 'before dawn');
21773 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'बिहान', 'morning');
21774 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'दिउँसो', 'during day');
21775 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'बेलुका', 'evening');
21776 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'साँझ', 'late evening');
21777 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'राती', 'night');
21778 });
21779
21780 test('weeks year starting sunday', function (assert) {
21781 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
21782 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
21783 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
21784 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
21785 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
21786 });
21787
21788 test('weeks year starting monday', function (assert) {
21789 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
21790 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
21791 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
21792 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
21793 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
21794 });
21795
21796 test('weeks year starting tuesday', function (assert) {
21797 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
21798 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
21799 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
21800 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
21801 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
21802 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
21803 });
21804
21805 test('weeks year starting wednesday', function (assert) {
21806 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
21807 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
21808 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
21809 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
21810 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
21811 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
21812 });
21813
21814 test('weeks year starting thursday', function (assert) {
21815 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
21816 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
21817 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
21818 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
21819 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
21820 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
21821 });
21822
21823 test('weeks year starting friday', function (assert) {
21824 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
21825 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
21826 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
21827 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
21828 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
21829 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
21830 });
21831
21832 test('weeks year starting saturday', function (assert) {
21833 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
21834 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
21835 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
21836 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
21837 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
21838 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
21839 });
21840
21841 test('weeks year starting sunday formatted', function (assert) {
21842 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '१ ०१ १', 'Dec 26 2011 should be week 1');
21843 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
21844 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '२ ०२ २', 'Jan 2 2012 should be week 2');
21845 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '२ ०२ २', 'Jan 8 2012 should be week 2');
21846 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '३ ०३ ३', 'Jan 9 2012 should be week 3');
21847 });
21848
21849 test('lenient ordinal parsing', function (assert) {
21850 var i, ordinalStr, testMoment;
21851 for (i = 1; i <= 31; ++i) {
21852 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
21853 testMoment = moment(ordinalStr, 'YYYY MM Do');
21854 assert.equal(testMoment.year(), 2014,
21855 'lenient ordinal parsing ' + i + ' year check');
21856 assert.equal(testMoment.month(), 0,
21857 'lenient ordinal parsing ' + i + ' month check');
21858 assert.equal(testMoment.date(), i,
21859 'lenient ordinal parsing ' + i + ' date check');
21860 }
21861 });
21862
21863 test('lenient ordinal parsing of number', function (assert) {
21864 var i, testMoment;
21865 for (i = 1; i <= 31; ++i) {
21866 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
21867 assert.equal(testMoment.year(), 2014,
21868 'lenient ordinal parsing of number ' + i + ' year check');
21869 assert.equal(testMoment.month(), 0,
21870 'lenient ordinal parsing of number ' + i + ' month check');
21871 assert.equal(testMoment.date(), i,
21872 'lenient ordinal parsing of number ' + i + ' date check');
21873 }
21874 });
21875
21876 test('meridiem invariant', function (assert) {
21877 var h, m, t1, t2;
21878 for (h = 0; h < 24; ++h) {
21879 for (m = 0; m < 60; m += 15) {
21880 t1 = moment.utc([2000, 0, 1, h, m]);
21881 t2 = moment(t1.format('A h:mm'), 'A h:mm');
21882 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
21883 'meridiem at ' + t1.format('HH:mm'));
21884 }
21885 }
21886 });
21887
21888 test('strict ordinal parsing', function (assert) {
21889 var i, ordinalStr, testMoment;
21890 for (i = 1; i <= 31; ++i) {
21891 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
21892 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
21893 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
21894 }
21895 });
21896
21897 }));
21898
21899 (function (global, factory) {
21900 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
21901 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
21902 factory(global.moment)
21903 }(this, function (moment) { 'use strict';
21904
21905 /*global QUnit:false*/
21906
21907 var test = QUnit.test;
21908
21909 function module (name, lifecycle) {
21910 QUnit.module(name, {
21911 setup : function () {
21912 moment.locale('en');
21913 moment.createFromInputFallback = function () {
21914 throw new Error('input not handled by moment');
21915 };
21916 if (lifecycle && lifecycle.setup) {
21917 lifecycle.setup();
21918 }
21919 },
21920 teardown : function () {
21921 if (lifecycle && lifecycle.teardown) {
21922 lifecycle.teardown();
21923 }
21924 }
21925 });
21926 }
21927
21928 function localeModule (name, lifecycle) {
21929 QUnit.module('locale:' + name, {
21930 setup : function () {
21931 moment.locale(name);
21932 moment.createFromInputFallback = function () {
21933 throw new Error('input not handled by moment');
21934 };
21935 if (lifecycle && lifecycle.setup) {
21936 lifecycle.setup();
21937 }
21938 },
21939 teardown : function () {
21940 moment.locale('en');
21941 if (lifecycle && lifecycle.teardown) {
21942 lifecycle.teardown();
21943 }
21944 }
21945 });
21946 }
21947
21948 localeModule('nl');
21949
21950 test('parse', function (assert) {
21951 var tests = 'januari jan._februari feb._maart mrt._april apr._mei mei._juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.'.split('_'), i;
21952 function equalTest(input, mmm, i) {
21953 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
21954 }
21955 for (i = 0; i < 12; i++) {
21956 tests[i] = tests[i].split(' ');
21957 equalTest(tests[i][0], 'MMM', i);
21958 equalTest(tests[i][1], 'MMM', i);
21959 equalTest(tests[i][0], 'MMMM', i);
21960 equalTest(tests[i][1], 'MMMM', i);
21961 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
21962 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
21963 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21964 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21965 }
21966 });
21967
21968 test('format', function (assert) {
21969 var a = [
21970 ['dddd, MMMM Do YYYY, HH:mm:ss', 'zondag, februari 14de 2010, 15:25:50'],
21971 ['ddd, HH', 'zo., 15'],
21972 ['M Mo MM MMMM MMM', '2 2de 02 februari feb.'],
21973 ['YYYY YY', '2010 10'],
21974 ['D Do DD', '14 14de 14'],
21975 ['d do dddd ddd dd', '0 0de zondag zo. Zo'],
21976 ['DDD DDDo DDDD', '45 45ste 045'],
21977 ['w wo ww', '6 6de 06'],
21978 ['h hh', '3 03'],
21979 ['H HH', '15 15'],
21980 ['m mm', '25 25'],
21981 ['s ss', '50 50'],
21982 ['a A', 'pm PM'],
21983 ['[the] DDDo [day of the year]', 'the 45ste day of the year'],
21984 ['LTS', '15:25:50'],
21985 ['L', '14-02-2010'],
21986 ['LL', '14 februari 2010'],
21987 ['LLL', '14 februari 2010 15:25'],
21988 ['LLLL', 'zondag 14 februari 2010 15:25'],
21989 ['l', '14-2-2010'],
21990 ['ll', '14 feb. 2010'],
21991 ['lll', '14 feb. 2010 15:25'],
21992 ['llll', 'zo. 14 feb. 2010 15:25']
21993 ],
21994 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
21995 i;
21996 for (i = 0; i < a.length; i++) {
21997 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
21998 }
21999 });
22000
22001 test('format ordinal', function (assert) {
22002 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
22003 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
22004 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
22005 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4de', '4de');
22006 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5de', '5de');
22007 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6de', '6de');
22008 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7de', '7de');
22009 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
22010 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
22011 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
22012
22013 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
22014 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
22015 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
22016 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14de', '14de');
22017 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15de', '15de');
22018 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16de', '16de');
22019 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17de', '17de');
22020 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
22021 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
22022 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
22023
22024 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
22025 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
22026 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
22027 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ste', '24ste');
22028 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ste', '25ste');
22029 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ste', '26ste');
22030 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ste', '27ste');
22031 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
22032 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
22033 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
22034
22035 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
22036 });
22037
22038 test('format month', function (assert) {
22039 var expected = 'januari jan._februari feb._maart mrt._april apr._mei mei_juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.'.split('_'), i;
22040 for (i = 0; i < expected.length; i++) {
22041 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
22042 }
22043 });
22044
22045 test('format week', function (assert) {
22046 var expected = 'zondag zo. Zo_maandag ma. Ma_dinsdag di. Di_woensdag wo. Wo_donderdag do. Do_vrijdag vr. Vr_zaterdag za. Za'.split('_'), i;
22047 for (i = 0; i < expected.length; i++) {
22048 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
22049 }
22050 });
22051
22052 test('from', function (assert) {
22053 var start = moment([2007, 1, 28]);
22054 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'een paar seconden', '44 seconds = a few seconds');
22055 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'één minuut', '45 seconds = a minute');
22056 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'één minuut', '89 seconds = a minute');
22057 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuten', '90 seconds = 2 minutes');
22058 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuten', '44 minutes = 44 minutes');
22059 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'één uur', '45 minutes = an hour');
22060 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'één uur', '89 minutes = an hour');
22061 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 uur', '90 minutes = 2 hours');
22062 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 uur', '5 hours = 5 hours');
22063 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 uur', '21 hours = 21 hours');
22064 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'één dag', '22 hours = a day');
22065 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'één dag', '35 hours = a day');
22066 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagen', '36 hours = 2 days');
22067 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'één dag', '1 day = a day');
22068 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagen', '5 days = 5 days');
22069 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagen', '25 days = 25 days');
22070 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'één maand', '26 days = a month');
22071 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'één maand', '30 days = a month');
22072 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'één maand', '43 days = a month');
22073 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 maanden', '46 days = 2 months');
22074 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 maanden', '75 days = 2 months');
22075 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 maanden', '76 days = 3 months');
22076 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'één maand', '1 month = a month');
22077 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 maanden', '5 months = 5 months');
22078 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'één jaar', '345 days = a year');
22079 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jaar', '548 days = 2 years');
22080 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'één jaar', '1 year = a year');
22081 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jaar', '5 years = 5 years');
22082 });
22083
22084 test('suffix', function (assert) {
22085 assert.equal(moment(30000).from(0), 'over een paar seconden', 'prefix');
22086 assert.equal(moment(0).from(30000), 'een paar seconden geleden', 'suffix');
22087 });
22088
22089 test('now from now', function (assert) {
22090 assert.equal(moment().fromNow(), 'een paar seconden geleden', 'now from now should display as in the past');
22091 });
22092
22093 test('fromNow', function (assert) {
22094 assert.equal(moment().add({s: 30}).fromNow(), 'over een paar seconden', 'in a few seconds');
22095 assert.equal(moment().add({d: 5}).fromNow(), 'over 5 dagen', 'in 5 days');
22096 });
22097
22098 test('calendar day', function (assert) {
22099 var a = moment().hours(2).minutes(0).seconds(0);
22100
22101 assert.equal(moment(a).calendar(), 'vandaag om 02:00', 'today at the same time');
22102 assert.equal(moment(a).add({m: 25}).calendar(), 'vandaag om 02:25', 'Now plus 25 min');
22103 assert.equal(moment(a).add({h: 1}).calendar(), 'vandaag om 03:00', 'Now plus 1 hour');
22104 assert.equal(moment(a).add({d: 1}).calendar(), 'morgen om 02:00', 'tomorrow at the same time');
22105 assert.equal(moment(a).subtract({h: 1}).calendar(), 'vandaag om 01:00', 'Now minus 1 hour');
22106 assert.equal(moment(a).subtract({d: 1}).calendar(), 'gisteren om 02:00', 'yesterday at the same time');
22107 });
22108
22109 test('calendar next week', function (assert) {
22110 var i, m;
22111 for (i = 2; i < 7; i++) {
22112 m = moment().add({d: i});
22113 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days current time');
22114 m.hours(0).minutes(0).seconds(0).milliseconds(0);
22115 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days beginning of day');
22116 m.hours(23).minutes(59).seconds(59).milliseconds(999);
22117 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days end of day');
22118 }
22119 });
22120
22121 test('calendar last week', function (assert) {
22122 var i, m;
22123 for (i = 2; i < 7; i++) {
22124 m = moment().subtract({d: i});
22125 assert.equal(m.calendar(), m.format('[afgelopen] dddd [om] LT'), 'Today - ' + i + ' days current time');
22126 m.hours(0).minutes(0).seconds(0).milliseconds(0);
22127 assert.equal(m.calendar(), m.format('[afgelopen] dddd [om] LT'), 'Today - ' + i + ' days beginning of day');
22128 m.hours(23).minutes(59).seconds(59).milliseconds(999);
22129 assert.equal(m.calendar(), m.format('[afgelopen] dddd [om] LT'), 'Today - ' + i + ' days end of day');
22130 }
22131 });
22132
22133 test('calendar all else', function (assert) {
22134 var weeksAgo = moment().subtract({w: 1}),
22135 weeksFromNow = moment().add({w: 1});
22136
22137 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
22138 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
22139
22140 weeksAgo = moment().subtract({w: 2});
22141 weeksFromNow = moment().add({w: 2});
22142
22143 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
22144 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
22145 });
22146
22147 test('month abbreviation', function (assert) {
22148 assert.equal(moment([2012, 5, 23]).format('D-MMM-YYYY'), '23-jun-2012', 'format month abbreviation surrounded by dashes should not include a dot');
22149 assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
22150 });
22151
22152 test('weeks year starting sunday', function (assert) {
22153 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
22154 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
22155 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
22156 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
22157 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
22158 });
22159
22160 test('weeks year starting monday', function (assert) {
22161 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
22162 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
22163 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
22164 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
22165 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
22166 });
22167
22168 test('weeks year starting tuesday', function (assert) {
22169 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
22170 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
22171 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
22172 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
22173 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
22174 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
22175 });
22176
22177 test('weeks year starting wednesday', function (assert) {
22178 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
22179 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
22180 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
22181 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
22182 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
22183 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
22184 });
22185
22186 test('weeks year starting thursday', function (assert) {
22187 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
22188 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
22189 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
22190 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
22191 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
22192 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
22193 });
22194
22195 test('weeks year starting friday', function (assert) {
22196 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
22197 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
22198 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
22199 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
22200 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
22201 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
22202 });
22203
22204 test('weeks year starting saturday', function (assert) {
22205 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
22206 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
22207 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
22208 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
22209 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
22210 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
22211 });
22212
22213 test('weeks year starting sunday formatted', function (assert) {
22214 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
22215 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
22216 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1ste', 'Jan 8 2012 should be week 1');
22217 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2');
22218 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
22219 });
22220
22221 test('lenient ordinal parsing', function (assert) {
22222 var i, ordinalStr, testMoment;
22223 for (i = 1; i <= 31; ++i) {
22224 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
22225 testMoment = moment(ordinalStr, 'YYYY MM Do');
22226 assert.equal(testMoment.year(), 2014,
22227 'lenient ordinal parsing ' + i + ' year check');
22228 assert.equal(testMoment.month(), 0,
22229 'lenient ordinal parsing ' + i + ' month check');
22230 assert.equal(testMoment.date(), i,
22231 'lenient ordinal parsing ' + i + ' date check');
22232 }
22233 });
22234
22235 test('lenient ordinal parsing of number', function (assert) {
22236 var i, testMoment;
22237 for (i = 1; i <= 31; ++i) {
22238 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
22239 assert.equal(testMoment.year(), 2014,
22240 'lenient ordinal parsing of number ' + i + ' year check');
22241 assert.equal(testMoment.month(), 0,
22242 'lenient ordinal parsing of number ' + i + ' month check');
22243 assert.equal(testMoment.date(), i,
22244 'lenient ordinal parsing of number ' + i + ' date check');
22245 }
22246 });
22247
22248 test('strict ordinal parsing', function (assert) {
22249 var i, ordinalStr, testMoment;
22250 for (i = 1; i <= 31; ++i) {
22251 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
22252 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
22253 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
22254 }
22255 });
22256
22257 }));
22258
22259 (function (global, factory) {
22260 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
22261 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
22262 factory(global.moment)
22263 }(this, function (moment) { 'use strict';
22264
22265 /*global QUnit:false*/
22266
22267 var test = QUnit.test;
22268
22269 function module (name, lifecycle) {
22270 QUnit.module(name, {
22271 setup : function () {
22272 moment.locale('en');
22273 moment.createFromInputFallback = function () {
22274 throw new Error('input not handled by moment');
22275 };
22276 if (lifecycle && lifecycle.setup) {
22277 lifecycle.setup();
22278 }
22279 },
22280 teardown : function () {
22281 if (lifecycle && lifecycle.teardown) {
22282 lifecycle.teardown();
22283 }
22284 }
22285 });
22286 }
22287
22288 function localeModule (name, lifecycle) {
22289 QUnit.module('locale:' + name, {
22290 setup : function () {
22291 moment.locale(name);
22292 moment.createFromInputFallback = function () {
22293 throw new Error('input not handled by moment');
22294 };
22295 if (lifecycle && lifecycle.setup) {
22296 lifecycle.setup();
22297 }
22298 },
22299 teardown : function () {
22300 moment.locale('en');
22301 if (lifecycle && lifecycle.teardown) {
22302 lifecycle.teardown();
22303 }
22304 }
22305 });
22306 }
22307
22308 localeModule('nn');
22309
22310 test('parse', function (assert) {
22311 var tests = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
22312 function equalTest(input, mmm, i) {
22313 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
22314 }
22315 for (i = 0; i < 12; i++) {
22316 tests[i] = tests[i].split(' ');
22317 equalTest(tests[i][0], 'MMM', i);
22318 equalTest(tests[i][1], 'MMM', i);
22319 equalTest(tests[i][0], 'MMMM', i);
22320 equalTest(tests[i][1], 'MMMM', i);
22321 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
22322 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
22323 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
22324 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22325 }
22326 });
22327
22328 test('format', function (assert) {
22329 var a = [
22330 ['dddd, MMMM Do YYYY, h:mm:ss a', 'sundag, februar 14. 2010, 3:25:50 pm'],
22331 ['ddd, hA', 'sun, 3PM'],
22332 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
22333 ['YYYY YY', '2010 10'],
22334 ['D Do DD', '14 14. 14'],
22335 ['d do dddd ddd dd', '0 0. sundag sun su'],
22336 ['DDD DDDo DDDD', '45 45. 045'],
22337 ['w wo ww', '6 6. 06'],
22338 ['h hh', '3 03'],
22339 ['H HH', '15 15'],
22340 ['m mm', '25 25'],
22341 ['s ss', '50 50'],
22342 ['a A', 'pm PM'],
22343 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
22344 ['LTS', '15:25:50'],
22345 ['L', '14.02.2010'],
22346 ['LL', '14 februar 2010'],
22347 ['LLL', '14 februar 2010 15:25'],
22348 ['LLLL', 'sundag 14 februar 2010 15:25'],
22349 ['l', '14.2.2010'],
22350 ['ll', '14 feb 2010'],
22351 ['lll', '14 feb 2010 15:25'],
22352 ['llll', 'sun 14 feb 2010 15:25']
22353 ],
22354 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
22355 i;
22356 for (i = 0; i < a.length; i++) {
22357 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
22358 }
22359 });
22360
22361 test('format ordinal', function (assert) {
22362 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
22363 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
22364 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
22365 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
22366 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
22367 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
22368 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
22369 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
22370 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
22371 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
22372
22373 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
22374 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
22375 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
22376 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
22377 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
22378 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
22379 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
22380 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
22381 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
22382 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
22383
22384 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
22385 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
22386 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
22387 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
22388 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
22389 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
22390 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
22391 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
22392 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
22393 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
22394
22395 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
22396 });
22397
22398 test('format month', function (assert) {
22399 var expected = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
22400 for (i = 0; i < expected.length; i++) {
22401 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
22402 }
22403 });
22404
22405 test('format week', function (assert) {
22406 var expected = 'sundag sun su_måndag mån må_tysdag tys ty_onsdag ons on_torsdag tor to_fredag fre fr_laurdag lau lø'.split('_'), i;
22407 for (i = 0; i < expected.length; i++) {
22408 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
22409 }
22410 });
22411
22412 test('from', function (assert) {
22413 var start = moment([2007, 1, 28]);
22414 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nokre sekund', '44 sekunder = a few seconds');
22415 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eit minutt', '45 seconds = a minute');
22416 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eit minutt', '89 seconds = a minute');
22417 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutt', '90 seconds = 2 minutes');
22418 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutt', '44 minutes = 44 minutes');
22419 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ein time', '45 minutes = an hour');
22420 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ein time', '89 minutes = an hour');
22421 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timar', '90 minutes = 2 hours');
22422 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timar', '5 hours = 5 hours');
22423 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timar', '21 hours = 21 hours');
22424 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein dag', '22 hours = a day');
22425 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein dag', '35 hours = a day');
22426 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
22427 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein dag', '1 day = a day');
22428 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
22429 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
22430 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein månad', '26 days = a month');
22431 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein månad', '30 days = a month');
22432 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ein månad', '43 days = a month');
22433 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 månader', '46 days = 2 months');
22434 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 månader', '75 days = 2 months');
22435 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 månader', '76 days = 3 months');
22436 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein månad', '1 month = a month');
22437 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 månader', '5 months = 5 months');
22438 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'eit år', '345 days = a year');
22439 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
22440 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eit år', '1 year = a year');
22441 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
22442 });
22443
22444 test('suffix', function (assert) {
22445 assert.equal(moment(30000).from(0), 'om nokre sekund', 'prefix');
22446 assert.equal(moment(0).from(30000), 'for nokre sekund sidan', 'suffix');
22447 });
22448
22449 test('now from now', function (assert) {
22450 assert.equal(moment().fromNow(), 'for nokre sekund sidan', 'now from now should display as in the past');
22451 });
22452
22453 test('fromNow', function (assert) {
22454 assert.equal(moment().add({s: 30}).fromNow(), 'om nokre sekund', 'in a few seconds');
22455 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dagar', 'in 5 days');
22456 });
22457
22458 test('calendar day', function (assert) {
22459 var a = moment().hours(2).minutes(0).seconds(0);
22460
22461 assert.equal(moment(a).calendar(), 'I dag klokka 02:00', 'today at the same time');
22462 assert.equal(moment(a).add({m: 25}).calendar(), 'I dag klokka 02:25', 'Now plus 25 min');
22463 assert.equal(moment(a).add({h: 1}).calendar(), 'I dag klokka 03:00', 'Now plus 1 hour');
22464 assert.equal(moment(a).add({d: 1}).calendar(), 'I morgon klokka 02:00', 'tomorrow at the same time');
22465 assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag klokka 01:00', 'Now minus 1 hour');
22466 assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går klokka 02:00', 'yesterday at the same time');
22467 });
22468
22469 test('calendar next week', function (assert) {
22470 var i, m;
22471 for (i = 2; i < 7; i++) {
22472 m = moment().add({d: i});
22473 assert.equal(m.calendar(), m.format('dddd [klokka] LT'), 'Today + ' + i + ' days current time');
22474 m.hours(0).minutes(0).seconds(0).milliseconds(0);
22475 assert.equal(m.calendar(), m.format('dddd [klokka] LT'), 'Today + ' + i + ' days beginning of day');
22476 m.hours(23).minutes(59).seconds(59).milliseconds(999);
22477 assert.equal(m.calendar(), m.format('dddd [klokka] LT'), 'Today + ' + i + ' days end of day');
22478 }
22479 });
22480
22481 test('calendar last week', function (assert) {
22482 var i, m;
22483 for (i = 2; i < 7; i++) {
22484 m = moment().subtract({d: i});
22485 assert.equal(m.calendar(), m.format('[Føregåande] dddd [klokka] LT'), 'Today - ' + i + ' days current time');
22486 m.hours(0).minutes(0).seconds(0).milliseconds(0);
22487 assert.equal(m.calendar(), m.format('[Føregåande] dddd [klokka] LT'), 'Today - ' + i + ' days beginning of day');
22488 m.hours(23).minutes(59).seconds(59).milliseconds(999);
22489 assert.equal(m.calendar(), m.format('[Føregåande] dddd [klokka] LT'), 'Today - ' + i + ' days end of day');
22490 }
22491 });
22492
22493 test('calendar all else', function (assert) {
22494 var weeksAgo = moment().subtract({w: 1}),
22495 weeksFromNow = moment().add({w: 1});
22496
22497 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
22498 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
22499
22500 weeksAgo = moment().subtract({w: 2});
22501 weeksFromNow = moment().add({w: 2});
22502
22503 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
22504 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
22505 });
22506
22507 test('weeks year starting sunday', function (assert) {
22508 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
22509 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
22510 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
22511 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
22512 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
22513 });
22514
22515 test('weeks year starting monday', function (assert) {
22516 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
22517 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
22518 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
22519 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
22520 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
22521 });
22522
22523 test('weeks year starting tuesday', function (assert) {
22524 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
22525 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
22526 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
22527 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
22528 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
22529 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
22530 });
22531
22532 test('weeks year starting wednesday', function (assert) {
22533 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
22534 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
22535 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
22536 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
22537 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
22538 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
22539 });
22540
22541 test('weeks year starting thursday', function (assert) {
22542 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
22543 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
22544 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
22545 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
22546 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
22547 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
22548 });
22549
22550 test('weeks year starting friday', function (assert) {
22551 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
22552 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
22553 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
22554 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
22555 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
22556 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
22557 });
22558
22559 test('weeks year starting saturday', function (assert) {
22560 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
22561 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
22562 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
22563 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
22564 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
22565 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
22566 });
22567
22568 test('weeks year starting sunday formatted', function (assert) {
22569 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
22570 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
22571 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
22572 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
22573 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
22574 });
22575
22576 test('lenient ordinal parsing', function (assert) {
22577 var i, ordinalStr, testMoment;
22578 for (i = 1; i <= 31; ++i) {
22579 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
22580 testMoment = moment(ordinalStr, 'YYYY MM Do');
22581 assert.equal(testMoment.year(), 2014,
22582 'lenient ordinal parsing ' + i + ' year check');
22583 assert.equal(testMoment.month(), 0,
22584 'lenient ordinal parsing ' + i + ' month check');
22585 assert.equal(testMoment.date(), i,
22586 'lenient ordinal parsing ' + i + ' date check');
22587 }
22588 });
22589
22590 test('lenient ordinal parsing of number', function (assert) {
22591 var i, testMoment;
22592 for (i = 1; i <= 31; ++i) {
22593 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
22594 assert.equal(testMoment.year(), 2014,
22595 'lenient ordinal parsing of number ' + i + ' year check');
22596 assert.equal(testMoment.month(), 0,
22597 'lenient ordinal parsing of number ' + i + ' month check');
22598 assert.equal(testMoment.date(), i,
22599 'lenient ordinal parsing of number ' + i + ' date check');
22600 }
22601 });
22602
22603 test('strict ordinal parsing', function (assert) {
22604 var i, ordinalStr, testMoment;
22605 for (i = 1; i <= 31; ++i) {
22606 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
22607 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
22608 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
22609 }
22610 });
22611
22612 }));
22613
22614 (function (global, factory) {
22615 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
22616 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
22617 factory(global.moment)
22618 }(this, function (moment) { 'use strict';
22619
22620 /*global QUnit:false*/
22621
22622 var test = QUnit.test;
22623
22624 function module (name, lifecycle) {
22625 QUnit.module(name, {
22626 setup : function () {
22627 moment.locale('en');
22628 moment.createFromInputFallback = function () {
22629 throw new Error('input not handled by moment');
22630 };
22631 if (lifecycle && lifecycle.setup) {
22632 lifecycle.setup();
22633 }
22634 },
22635 teardown : function () {
22636 if (lifecycle && lifecycle.teardown) {
22637 lifecycle.teardown();
22638 }
22639 }
22640 });
22641 }
22642
22643 function localeModule (name, lifecycle) {
22644 QUnit.module('locale:' + name, {
22645 setup : function () {
22646 moment.locale(name);
22647 moment.createFromInputFallback = function () {
22648 throw new Error('input not handled by moment');
22649 };
22650 if (lifecycle && lifecycle.setup) {
22651 lifecycle.setup();
22652 }
22653 },
22654 teardown : function () {
22655 moment.locale('en');
22656 if (lifecycle && lifecycle.teardown) {
22657 lifecycle.teardown();
22658 }
22659 }
22660 });
22661 }
22662
22663 localeModule('pl');
22664
22665 test('parse', function (assert) {
22666 var tests = 'styczeń stycznia sty_luty lutego lut_marzec marca mar_kwiecień kwietnia kwi_maj maja maj_czerwiec czerwca cze_lipiec lipca lip_sierpień sierpnia sie_wrzesień września wrz_październik października paź_listopad listopada lis_grudzień grudnia gru'.split('_'), i;
22667 function equalTest(input, mmm, i) {
22668 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
22669 }
22670 for (i = 0; i < 12; i++) {
22671 tests[i] = tests[i].split(' ');
22672 equalTest(tests[i][0], 'MMM', i);
22673 equalTest(tests[i][1], 'MMM', i);
22674 equalTest(tests[i][2], 'MMM', i);
22675 equalTest(tests[i][0], 'MMMM', i);
22676 equalTest(tests[i][1], 'MMMM', i);
22677 equalTest(tests[i][2], 'MMMM', i);
22678 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
22679 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
22680 equalTest(tests[i][2].toLocaleLowerCase(), 'MMMM', i);
22681 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
22682 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22683 equalTest(tests[i][2].toLocaleUpperCase(), 'MMMM', i);
22684 }
22685 });
22686
22687 test('parse strict', function (assert) {
22688 var tests = 'styczeń stycznia sty_luty lutego lut_marzec marca mar_kwiecień kwietnia kwi_maj maja maj_czerwiec czerwca cze_lipiec lipca lip_sierpień sierpnia sie_wrzesień września wrz_październik października paź_listopad listopada lis_grudzień grudnia gru'.split('_'), i;
22689 function equalTest(input, mmm, i) {
22690 assert.equal(moment(input, mmm, true).month(), i, input + ' should be month ' + (i + 1));
22691 }
22692 for (i = 0; i < 12; i++) {
22693 tests[i] = tests[i].split(' ');
22694 equalTest(tests[i][0], 'MMMM', i);
22695 equalTest(tests[i][1], 'MMMM', i);
22696 equalTest(tests[i][2], 'MMM', i);
22697 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
22698 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
22699 equalTest(tests[i][2].toLocaleLowerCase(), 'MMM', i);
22700 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
22701 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22702 equalTest(tests[i][2].toLocaleUpperCase(), 'MMM', i);
22703 }
22704 });
22705
22706 test('format', function (assert) {
22707 var a = [
22708 ['dddd, MMMM Do YYYY, h:mm:ss a', 'niedziela, luty 14. 2010, 3:25:50 pm'],
22709 ['ddd, hA', 'nie, 3PM'],
22710 ['M Mo MM MMMM MMM', '2 2. 02 luty lut'],
22711 ['YYYY YY', '2010 10'],
22712 ['D Do DD', '14 14. 14'],
22713 ['d do dddd ddd dd', '0 0. niedziela nie N'],
22714 ['DDD DDDo DDDD', '45 45. 045'],
22715 ['w wo ww', '6 6. 06'],
22716 ['h hh', '3 03'],
22717 ['H HH', '15 15'],
22718 ['m mm', '25 25'],
22719 ['s ss', '50 50'],
22720 ['a A', 'pm PM'],
22721 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
22722 ['LTS', '15:25:50'],
22723 ['L', '14.02.2010'],
22724 ['LL', '14 lutego 2010'],
22725 ['LLL', '14 lutego 2010 15:25'],
22726 ['LLLL', 'niedziela, 14 lutego 2010 15:25'],
22727 ['l', '14.2.2010'],
22728 ['ll', '14 lut 2010'],
22729 ['lll', '14 lut 2010 15:25'],
22730 ['llll', 'nie, 14 lut 2010 15:25']
22731 ],
22732 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
22733 i;
22734 for (i = 0; i < a.length; i++) {
22735 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
22736 }
22737 });
22738
22739 test('format ordinal', function (assert) {
22740 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
22741 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
22742 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
22743 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
22744 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
22745 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
22746 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
22747 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
22748 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
22749 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
22750
22751 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
22752 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
22753 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
22754 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
22755 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
22756 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
22757 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
22758 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
22759 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
22760 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
22761
22762 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
22763 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
22764 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
22765 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
22766 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
22767 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
22768 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
22769 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
22770 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
22771 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
22772
22773 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
22774 });
22775
22776 test('format month', function (assert) {
22777 var expected = 'styczeń sty_luty lut_marzec mar_kwiecień kwi_maj maj_czerwiec cze_lipiec lip_sierpień sie_wrzesień wrz_październik paź_listopad lis_grudzień gru'.split('_'), i;
22778 for (i = 0; i < expected.length; i++) {
22779 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
22780 }
22781 });
22782
22783 test('format week', function (assert) {
22784 var expected = 'niedziela nie N_poniedziałek pon Pn_wtorek wt Wt_środa śr Śr_czwartek czw Cz_piątek pt Pt_sobota sb So'.split('_'), i;
22785 for (i = 0; i < expected.length; i++) {
22786 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
22787 }
22788 });
22789
22790 test('from', function (assert) {
22791 var start = moment([2007, 1, 28]);
22792 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'kilka sekund', '44 seconds = a few seconds');
22793 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuta', '45 seconds = a minute');
22794 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuta', '89 seconds = a minute');
22795 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuty', '90 seconds = 2 minutes');
22796 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuty', '44 minutes = 44 minutes');
22797 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'godzina', '45 minutes = an hour');
22798 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'godzina', '89 minutes = an hour');
22799 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 godziny', '90 minutes = 2 hours');
22800 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 godzin', '5 hours = 5 hours');
22801 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 godzin', '21 hours = 21 hours');
22802 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1 dzień', '22 hours = a day');
22803 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1 dzień', '35 hours = a day');
22804 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dni', '36 hours = 2 days');
22805 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1 dzień', '1 day = a day');
22806 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dni', '5 days = 5 days');
22807 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dni', '25 days = 25 days');
22808 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'miesiąc', '26 days = a month');
22809 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'miesiąc', '30 days = a month');
22810 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'miesiąc', '43 days = a month');
22811 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 miesiące', '46 days = 2 months');
22812 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 miesiące', '75 days = 2 months');
22813 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 miesiące', '76 days = 3 months');
22814 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'miesiąc', '1 month = a month');
22815 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 miesięcy', '5 months = 5 months');
22816 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'rok', '345 days = a year');
22817 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 lata', '548 days = 2 years');
22818 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'rok', '1 year = a year');
22819 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 lat', '5 years = 5 years');
22820 assert.equal(start.from(moment([2007, 1, 28]).add({y: 112}), true), '112 lat', '112 years = 112 years');
22821 assert.equal(start.from(moment([2007, 1, 28]).add({y: 122}), true), '122 lata', '122 years = 122 years');
22822 assert.equal(start.from(moment([2007, 1, 28]).add({y: 213}), true), '213 lat', '213 years = 213 years');
22823 assert.equal(start.from(moment([2007, 1, 28]).add({y: 223}), true), '223 lata', '223 years = 223 years');
22824 });
22825
22826 test('suffix', function (assert) {
22827 assert.equal(moment(30000).from(0), 'za kilka sekund', 'prefix');
22828 assert.equal(moment(0).from(30000), 'kilka sekund temu', 'suffix');
22829 });
22830
22831 test('now from now', function (assert) {
22832 assert.equal(moment().fromNow(), 'kilka sekund temu', 'now from now should display as in the past');
22833 });
22834
22835 test('fromNow', function (assert) {
22836 assert.equal(moment().add({s: 30}).fromNow(), 'za kilka sekund', 'in a few seconds');
22837 assert.equal(moment().add({h: 1}).fromNow(), 'za godzinę', 'in an hour');
22838 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dni', 'in 5 days');
22839 });
22840
22841 test('calendar day', function (assert) {
22842 var a = moment().hours(2).minutes(0).seconds(0);
22843
22844 assert.equal(moment(a).calendar(), 'Dziś o 02:00', 'today at the same time');
22845 assert.equal(moment(a).add({m: 25}).calendar(), 'Dziś o 02:25', 'Now plus 25 min');
22846 assert.equal(moment(a).add({h: 1}).calendar(), 'Dziś o 03:00', 'Now plus 1 hour');
22847 assert.equal(moment(a).add({d: 1}).calendar(), 'Jutro o 02:00', 'tomorrow at the same time');
22848 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dziś o 01:00', 'Now minus 1 hour');
22849 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Wczoraj o 02:00', 'yesterday at the same time');
22850 });
22851
22852 test('calendar next week', function (assert) {
22853 var i, m;
22854 for (i = 2; i < 7; i++) {
22855 m = moment().add({d: i});
22856 assert.equal(m.calendar(), m.format('[W] dddd [o] LT'), 'Today + ' + i + ' days current time');
22857 m.hours(0).minutes(0).seconds(0).milliseconds(0);
22858 assert.equal(m.calendar(), m.format('[W] dddd [o] LT'), 'Today + ' + i + ' days beginning of day');
22859 m.hours(23).minutes(59).seconds(59).milliseconds(999);
22860 assert.equal(m.calendar(), m.format('[W] dddd [o] LT'), 'Today + ' + i + ' days end of day');
22861 }
22862 });
22863
22864 test('calendar last week', function (assert) {
22865 var i, m;
22866
22867 function makeFormat(d) {
22868 switch (d.day()) {
22869 case 0:
22870 return '[W zeszłą niedzielę o] LT';
22871 case 3:
22872 return '[W zeszłą środę o] LT';
22873 case 6:
22874 return '[W zeszłą sobotę o] LT';
22875 default:
22876 return '[W zeszły] dddd [o] LT';
22877 }
22878 }
22879
22880 for (i = 2; i < 7; i++) {
22881 m = moment().subtract({d: i});
22882 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
22883
22884 m.hours(0).minutes(0).seconds(0).milliseconds(0);
22885 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
22886
22887 m.hours(23).minutes(59).seconds(59).milliseconds(999);
22888 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
22889 }
22890 });
22891
22892 test('calendar all else', function (assert) {
22893 var weeksAgo = moment().subtract({w: 1}),
22894 weeksFromNow = moment().add({w: 1});
22895
22896 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
22897 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
22898
22899 weeksAgo = moment().subtract({w: 2});
22900 weeksFromNow = moment().add({w: 2});
22901
22902 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
22903 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
22904 });
22905
22906 test('weeks year starting sunday', function (assert) {
22907 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
22908 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
22909 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
22910 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
22911 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
22912 });
22913
22914 test('weeks year starting monday', function (assert) {
22915 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
22916 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
22917 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
22918 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
22919 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
22920 });
22921
22922 test('weeks year starting tuesday', function (assert) {
22923 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
22924 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
22925 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
22926 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
22927 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
22928 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
22929 });
22930
22931 test('weeks year starting wednesday', function (assert) {
22932 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
22933 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
22934 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
22935 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
22936 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
22937 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
22938 });
22939
22940 test('weeks year starting thursday', function (assert) {
22941 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
22942 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
22943 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
22944 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
22945 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
22946 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
22947 });
22948
22949 test('weeks year starting friday', function (assert) {
22950 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
22951 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
22952 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
22953 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
22954 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
22955 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
22956 });
22957
22958 test('weeks year starting saturday', function (assert) {
22959 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
22960 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
22961 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
22962 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
22963 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
22964 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
22965 });
22966
22967 test('weeks year starting sunday formatted', function (assert) {
22968 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
22969 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
22970 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
22971 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
22972 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
22973 });
22974
22975 test('lenient ordinal parsing', function (assert) {
22976 var i, ordinalStr, testMoment;
22977 for (i = 1; i <= 31; ++i) {
22978 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
22979 testMoment = moment(ordinalStr, 'YYYY MM Do');
22980 assert.equal(testMoment.year(), 2014,
22981 'lenient ordinal parsing ' + i + ' year check');
22982 assert.equal(testMoment.month(), 0,
22983 'lenient ordinal parsing ' + i + ' month check');
22984 assert.equal(testMoment.date(), i,
22985 'lenient ordinal parsing ' + i + ' date check');
22986 }
22987 });
22988
22989 test('lenient ordinal parsing of number', function (assert) {
22990 var i, testMoment;
22991 for (i = 1; i <= 31; ++i) {
22992 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
22993 assert.equal(testMoment.year(), 2014,
22994 'lenient ordinal parsing of number ' + i + ' year check');
22995 assert.equal(testMoment.month(), 0,
22996 'lenient ordinal parsing of number ' + i + ' month check');
22997 assert.equal(testMoment.date(), i,
22998 'lenient ordinal parsing of number ' + i + ' date check');
22999 }
23000 });
23001
23002 test('strict ordinal parsing', function (assert) {
23003 var i, ordinalStr, testMoment;
23004 for (i = 1; i <= 31; ++i) {
23005 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
23006 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
23007 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
23008 }
23009 });
23010
23011 }));
23012
23013 (function (global, factory) {
23014 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
23015 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
23016 factory(global.moment)
23017 }(this, function (moment) { 'use strict';
23018
23019 /*global QUnit:false*/
23020
23021 var test = QUnit.test;
23022
23023 function module (name, lifecycle) {
23024 QUnit.module(name, {
23025 setup : function () {
23026 moment.locale('en');
23027 moment.createFromInputFallback = function () {
23028 throw new Error('input not handled by moment');
23029 };
23030 if (lifecycle && lifecycle.setup) {
23031 lifecycle.setup();
23032 }
23033 },
23034 teardown : function () {
23035 if (lifecycle && lifecycle.teardown) {
23036 lifecycle.teardown();
23037 }
23038 }
23039 });
23040 }
23041
23042 function localeModule (name, lifecycle) {
23043 QUnit.module('locale:' + name, {
23044 setup : function () {
23045 moment.locale(name);
23046 moment.createFromInputFallback = function () {
23047 throw new Error('input not handled by moment');
23048 };
23049 if (lifecycle && lifecycle.setup) {
23050 lifecycle.setup();
23051 }
23052 },
23053 teardown : function () {
23054 moment.locale('en');
23055 if (lifecycle && lifecycle.teardown) {
23056 lifecycle.teardown();
23057 }
23058 }
23059 });
23060 }
23061
23062 localeModule('pt-br');
23063
23064 test('parse', function (assert) {
23065 var tests = 'janeiro jan_fevereiro fev_março mar_abril abr_maio mai_junho jun_julho jul_agosto ago_setembro set_outubro out_novembro nov_dezembro dez'.split('_'), i;
23066
23067 function equalTest(input, mmm, i) {
23068 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
23069 }
23070
23071 for (i = 0; i < 12; i++) {
23072 tests[i] = tests[i].split(' ');
23073 equalTest(tests[i][0], 'MMM', i);
23074 equalTest(tests[i][1], 'MMM', i);
23075 equalTest(tests[i][0], 'MMMM', i);
23076 equalTest(tests[i][1], 'MMMM', i);
23077 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
23078 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
23079 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
23080 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
23081 }
23082 });
23083
23084 test('format', function (assert) {
23085 var a = [
23086 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
23087 ['ddd, hA', 'Dom, 3PM'],
23088 ['M Mo MM MMMM MMM', '2 2º 02 Fevereiro Fev'],
23089 ['YYYY YY', '2010 10'],
23090 ['D Do DD', '14 14º 14'],
23091 ['d do dddd ddd', '0 0º Domingo Dom'],
23092 ['DDD DDDo DDDD', '45 45º 045'],
23093 ['w wo ww', '8 8º 08'],
23094 ['h hh', '3 03'],
23095 ['H HH', '15 15'],
23096 ['m mm', '25 25'],
23097 ['s ss', '50 50'],
23098 ['a A', 'pm PM'],
23099 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
23100 ['LTS', '15:25:50'],
23101 ['L', '14/02/2010'],
23102 ['LL', '14 de Fevereiro de 2010'],
23103 ['LLL', '14 de Fevereiro de 2010 às 15:25'],
23104 ['LLLL', 'Domingo, 14 de Fevereiro de 2010 às 15:25'],
23105 ['l', '14/2/2010'],
23106 ['ll', '14 de Fev de 2010'],
23107 ['lll', '14 de Fev de 2010 às 15:25'],
23108 ['llll', 'Dom, 14 de Fev de 2010 às 15:25']
23109 ],
23110 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
23111 i;
23112 for (i = 0; i < a.length; i++) {
23113 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
23114 }
23115 });
23116
23117 test('format ordinal', function (assert) {
23118 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
23119 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
23120 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
23121 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
23122 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
23123 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
23124 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
23125 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
23126 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
23127 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
23128
23129 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
23130 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
23131 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
23132 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
23133 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
23134 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
23135 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
23136 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
23137 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
23138 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
23139
23140 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
23141 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
23142 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
23143 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
23144 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
23145 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
23146 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
23147 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
23148 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
23149 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
23150
23151 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
23152 });
23153
23154 test('format month', function (assert) {
23155 var expected = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split('_'), i;
23156 for (i = 0; i < expected.length; i++) {
23157 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
23158 }
23159 });
23160
23161 test('format week', function (assert) {
23162 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;
23163 for (i = 0; i < expected.length; i++) {
23164 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
23165 }
23166 });
23167
23168 test('from', function (assert) {
23169 var start = moment([2007, 1, 28]);
23170 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'poucos segundos', '44 seconds = seconds');
23171 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'um minuto', '45 seconds = a minute');
23172 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'um minuto', '89 seconds = a minute');
23173 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
23174 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
23175 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'uma hora', '45 minutes = an hour');
23176 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'uma hora', '89 minutes = an hour');
23177 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
23178 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
23179 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
23180 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'um dia', '22 hours = a day');
23181 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'um dia', '35 hours = a day');
23182 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dias', '36 hours = 2 days');
23183 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'um dia', '1 day = a day');
23184 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dias', '5 days = 5 days');
23185 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dias', '25 days = 25 days');
23186 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'um mês', '26 days = a month');
23187 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'um mês', '30 days = a month');
23188 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'um mês', '43 days = a month');
23189 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
23190 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
23191 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
23192 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'um mês', '1 month = a month');
23193 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
23194 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'um ano', '345 days = a year');
23195 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anos', '548 days = 2 years');
23196 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'um ano', '1 year = a year');
23197 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anos', '5 years = 5 years');
23198 });
23199
23200 test('suffix', function (assert) {
23201 assert.equal(moment(30000).from(0), 'em poucos segundos', 'prefix');
23202 assert.equal(moment(0).from(30000), 'poucos segundos atrás', 'suffix');
23203 });
23204
23205 test('fromNow', function (assert) {
23206 assert.equal(moment().add({s: 30}).fromNow(), 'em poucos segundos', 'in seconds');
23207 assert.equal(moment().add({d: 5}).fromNow(), 'em 5 dias', 'in 5 days');
23208 });
23209
23210 test('calendar day', function (assert) {
23211 var a = moment().hours(2).minutes(0).seconds(0);
23212
23213 assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
23214 assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
23215 assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
23216 assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
23217 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
23218 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
23219 });
23220
23221 test('calendar next week', function (assert) {
23222 var i, m;
23223 for (i = 2; i < 7; i++) {
23224 m = moment().add({d: i});
23225 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days current time');
23226 m.hours(0).minutes(0).seconds(0).milliseconds(0);
23227 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days beginning of day');
23228 m.hours(23).minutes(59).seconds(59).milliseconds(999);
23229 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days end of day');
23230 }
23231 });
23232
23233 test('calendar last week', function (assert) {
23234 var i, m;
23235 for (i = 2; i < 7; i++) {
23236 m = moment().subtract({d: i});
23237 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days current time');
23238 m.hours(0).minutes(0).seconds(0).milliseconds(0);
23239 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days beginning of day');
23240 m.hours(23).minutes(59).seconds(59).milliseconds(999);
23241 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days end of day');
23242 }
23243 });
23244
23245 test('calendar all else', function (assert) {
23246 var weeksAgo = moment().subtract({w: 1}),
23247 weeksFromNow = moment().add({w: 1});
23248
23249 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
23250 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
23251
23252 weeksAgo = moment().subtract({w: 2});
23253 weeksFromNow = moment().add({w: 2});
23254
23255 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
23256 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
23257 });
23258
23259 test('weeks year starting sunday', function (assert) {
23260 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
23261 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
23262 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
23263 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
23264 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
23265 });
23266
23267 test('weeks year starting monday', function (assert) {
23268 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
23269 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
23270 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
23271 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
23272 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
23273 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
23274 });
23275
23276 test('weeks year starting tuesday', function (assert) {
23277 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
23278 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
23279 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
23280 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
23281 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
23282 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
23283 });
23284
23285 test('weeks year starting wednesday', function (assert) {
23286 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
23287 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
23288 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
23289 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
23290 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
23291 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
23292 });
23293
23294 test('weeks year starting thursday', function (assert) {
23295 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
23296 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
23297 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
23298 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
23299 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
23300 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
23301 });
23302
23303 test('weeks year starting friday', function (assert) {
23304 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
23305 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
23306 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
23307 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
23308 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
23309 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
23310 });
23311
23312 test('weeks year starting saturday', function (assert) {
23313 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
23314 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
23315 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
23316 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
23317 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
23318 });
23319
23320 test('weeks year starting sunday format', function (assert) {
23321 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
23322 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1º', 'Jan 7 2012 should be week 1');
23323 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2º', 'Jan 8 2012 should be week 2');
23324 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2º', 'Jan 14 2012 should be week 2');
23325 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3º', 'Jan 15 2012 should be week 3');
23326 });
23327
23328 test('lenient ordinal parsing', function (assert) {
23329 var i, ordinalStr, testMoment;
23330 for (i = 1; i <= 31; ++i) {
23331 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
23332 testMoment = moment(ordinalStr, 'YYYY MM Do');
23333 assert.equal(testMoment.year(), 2014,
23334 'lenient ordinal parsing ' + i + ' year check');
23335 assert.equal(testMoment.month(), 0,
23336 'lenient ordinal parsing ' + i + ' month check');
23337 assert.equal(testMoment.date(), i,
23338 'lenient ordinal parsing ' + i + ' date check');
23339 }
23340 });
23341
23342 test('lenient ordinal parsing of number', function (assert) {
23343 var i, testMoment;
23344 for (i = 1; i <= 31; ++i) {
23345 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
23346 assert.equal(testMoment.year(), 2014,
23347 'lenient ordinal parsing of number ' + i + ' year check');
23348 assert.equal(testMoment.month(), 0,
23349 'lenient ordinal parsing of number ' + i + ' month check');
23350 assert.equal(testMoment.date(), i,
23351 'lenient ordinal parsing of number ' + i + ' date check');
23352 }
23353 });
23354
23355 test('strict ordinal parsing', function (assert) {
23356 var i, ordinalStr, testMoment;
23357 for (i = 1; i <= 31; ++i) {
23358 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
23359 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
23360 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
23361 }
23362 });
23363
23364 }));
23365
23366 (function (global, factory) {
23367 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
23368 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
23369 factory(global.moment)
23370 }(this, function (moment) { 'use strict';
23371
23372 /*global QUnit:false*/
23373
23374 var test = QUnit.test;
23375
23376 function module (name, lifecycle) {
23377 QUnit.module(name, {
23378 setup : function () {
23379 moment.locale('en');
23380 moment.createFromInputFallback = function () {
23381 throw new Error('input not handled by moment');
23382 };
23383 if (lifecycle && lifecycle.setup) {
23384 lifecycle.setup();
23385 }
23386 },
23387 teardown : function () {
23388 if (lifecycle && lifecycle.teardown) {
23389 lifecycle.teardown();
23390 }
23391 }
23392 });
23393 }
23394
23395 function localeModule (name, lifecycle) {
23396 QUnit.module('locale:' + name, {
23397 setup : function () {
23398 moment.locale(name);
23399 moment.createFromInputFallback = function () {
23400 throw new Error('input not handled by moment');
23401 };
23402 if (lifecycle && lifecycle.setup) {
23403 lifecycle.setup();
23404 }
23405 },
23406 teardown : function () {
23407 moment.locale('en');
23408 if (lifecycle && lifecycle.teardown) {
23409 lifecycle.teardown();
23410 }
23411 }
23412 });
23413 }
23414
23415 localeModule('pt');
23416
23417 test('parse', function (assert) {
23418 var tests = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split('_'), i;
23419 function equalTest(input, mmm, i) {
23420 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
23421 }
23422 for (i = 0; i < 12; i++) {
23423 tests[i] = tests[i].split(' ');
23424 equalTest(tests[i][0], 'MMM', i);
23425 equalTest(tests[i][1], 'MMM', i);
23426 equalTest(tests[i][0], 'MMMM', i);
23427 equalTest(tests[i][1], 'MMMM', i);
23428 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
23429 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
23430 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
23431 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
23432 }
23433 });
23434
23435 test('format', function (assert) {
23436 var a = [
23437 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
23438 ['ddd, hA', 'Dom, 3PM'],
23439 ['M Mo MM MMMM MMM', '2 2º 02 Fevereiro Fev'],
23440 ['YYYY YY', '2010 10'],
23441 ['D Do DD', '14 14º 14'],
23442 ['d do dddd ddd', '0 0º Domingo Dom'],
23443 ['DDD DDDo DDDD', '45 45º 045'],
23444 ['w wo ww', '6 6º 06'],
23445 ['h hh', '3 03'],
23446 ['H HH', '15 15'],
23447 ['m mm', '25 25'],
23448 ['s ss', '50 50'],
23449 ['a A', 'pm PM'],
23450 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
23451 ['LTS', '15:25:50'],
23452 ['L', '14/02/2010'],
23453 ['LL', '14 de Fevereiro de 2010'],
23454 ['LLL', '14 de Fevereiro de 2010 15:25'],
23455 ['LLLL', 'Domingo, 14 de Fevereiro de 2010 15:25'],
23456 ['l', '14/2/2010'],
23457 ['ll', '14 de Fev de 2010'],
23458 ['lll', '14 de Fev de 2010 15:25'],
23459 ['llll', 'Dom, 14 de Fev de 2010 15:25']
23460 ],
23461 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
23462 i;
23463 for (i = 0; i < a.length; i++) {
23464 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
23465 }
23466 });
23467
23468 test('format ordinal', function (assert) {
23469 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
23470 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
23471 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
23472 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
23473 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
23474 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
23475 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
23476 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
23477 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
23478 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
23479
23480 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
23481 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
23482 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
23483 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
23484 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
23485 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
23486 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
23487 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
23488 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
23489 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
23490
23491 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
23492 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
23493 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
23494 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
23495 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
23496 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
23497 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
23498 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
23499 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
23500 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
23501
23502 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
23503 });
23504
23505 test('format month', function (assert) {
23506 var expected = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split('_'), i;
23507 for (i = 0; i < expected.length; i++) {
23508 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
23509 }
23510 });
23511
23512 test('format week', function (assert) {
23513 var expected = 'Domingo Dom Dom_Segunda-Feira Seg 2ª_Terça-Feira Ter 3ª_Quarta-Feira Qua 4ª_Quinta-Feira Qui 5ª_Sexta-Feira Sex 6ª_Sábado Sáb Sáb'.split('_'), i;
23514 for (i = 0; i < expected.length; i++) {
23515 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
23516 }
23517 });
23518
23519 test('from', function (assert) {
23520 var start = moment([2007, 1, 28]);
23521 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'segundos', '44 seconds = seconds');
23522 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'um minuto', '45 seconds = a minute');
23523 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'um minuto', '89 seconds = a minute');
23524 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
23525 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
23526 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'uma hora', '45 minutes = an hour');
23527 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'uma hora', '89 minutes = an hour');
23528 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
23529 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
23530 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
23531 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'um dia', '22 hours = a day');
23532 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'um dia', '35 hours = a day');
23533 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dias', '36 hours = 2 days');
23534 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'um dia', '1 day = a day');
23535 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dias', '5 days = 5 days');
23536 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dias', '25 days = 25 days');
23537 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'um mês', '26 days = a month');
23538 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'um mês', '30 days = a month');
23539 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'um mês', '43 days = a month');
23540 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
23541 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
23542 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
23543 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'um mês', '1 month = a month');
23544 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
23545 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'um ano', '345 days = a year');
23546 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anos', '548 days = 2 years');
23547 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'um ano', '1 year = a year');
23548 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anos', '5 years = 5 years');
23549 });
23550
23551 test('suffix', function (assert) {
23552 assert.equal(moment(30000).from(0), 'em segundos', 'prefix');
23553 assert.equal(moment(0).from(30000), 'há segundos', 'suffix');
23554 });
23555
23556 test('fromNow', function (assert) {
23557 assert.equal(moment().add({s: 30}).fromNow(), 'em segundos', 'in seconds');
23558 assert.equal(moment().add({d: 5}).fromNow(), 'em 5 dias', 'in 5 days');
23559 });
23560
23561 test('calendar day', function (assert) {
23562 var a = moment().hours(2).minutes(0).seconds(0);
23563
23564 assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
23565 assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
23566 assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
23567 assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
23568 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
23569 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
23570 });
23571
23572 test('calendar next week', function (assert) {
23573 var i, m;
23574 for (i = 2; i < 7; i++) {
23575 m = moment().add({d: i});
23576 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days current time');
23577 m.hours(0).minutes(0).seconds(0).milliseconds(0);
23578 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days beginning of day');
23579 m.hours(23).minutes(59).seconds(59).milliseconds(999);
23580 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days end of day');
23581 }
23582 });
23583
23584 test('calendar last week', function (assert) {
23585 var i, m;
23586 for (i = 2; i < 7; i++) {
23587 m = moment().subtract({d: i});
23588 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days current time');
23589 m.hours(0).minutes(0).seconds(0).milliseconds(0);
23590 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days beginning of day');
23591 m.hours(23).minutes(59).seconds(59).milliseconds(999);
23592 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days end of day');
23593 }
23594 });
23595
23596 test('calendar all else', function (assert) {
23597 var weeksAgo = moment().subtract({w: 1}),
23598 weeksFromNow = moment().add({w: 1});
23599
23600 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
23601 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
23602
23603 weeksAgo = moment().subtract({w: 2});
23604 weeksFromNow = moment().add({w: 2});
23605
23606 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
23607 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
23608 });
23609
23610 test('weeks year starting sunday', function (assert) {
23611 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
23612 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
23613 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
23614 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
23615 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
23616 });
23617
23618 test('weeks year starting monday', function (assert) {
23619 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
23620 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
23621 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
23622 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
23623 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
23624 });
23625
23626 test('weeks year starting tuesday', function (assert) {
23627 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
23628 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
23629 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
23630 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
23631 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
23632 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
23633 });
23634
23635 test('weeks year starting wednesday', function (assert) {
23636 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
23637 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
23638 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
23639 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
23640 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
23641 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
23642 });
23643
23644 test('weeks year starting thursday', function (assert) {
23645 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
23646 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
23647 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
23648 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
23649 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
23650 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
23651 });
23652
23653 test('weeks year starting friday', function (assert) {
23654 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
23655 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
23656 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
23657 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
23658 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
23659 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
23660 });
23661
23662 test('weeks year starting saturday', function (assert) {
23663 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
23664 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
23665 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
23666 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
23667 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
23668 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
23669 });
23670
23671 test('weeks year starting sunday formatted', function (assert) {
23672 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
23673 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
23674 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', 'Jan 8 2012 should be week 1');
23675 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2');
23676 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
23677 });
23678
23679 test('lenient ordinal parsing', function (assert) {
23680 var i, ordinalStr, testMoment;
23681 for (i = 1; i <= 31; ++i) {
23682 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
23683 testMoment = moment(ordinalStr, 'YYYY MM Do');
23684 assert.equal(testMoment.year(), 2014,
23685 'lenient ordinal parsing ' + i + ' year check');
23686 assert.equal(testMoment.month(), 0,
23687 'lenient ordinal parsing ' + i + ' month check');
23688 assert.equal(testMoment.date(), i,
23689 'lenient ordinal parsing ' + i + ' date check');
23690 }
23691 });
23692
23693 test('lenient ordinal parsing of number', function (assert) {
23694 var i, testMoment;
23695 for (i = 1; i <= 31; ++i) {
23696 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
23697 assert.equal(testMoment.year(), 2014,
23698 'lenient ordinal parsing of number ' + i + ' year check');
23699 assert.equal(testMoment.month(), 0,
23700 'lenient ordinal parsing of number ' + i + ' month check');
23701 assert.equal(testMoment.date(), i,
23702 'lenient ordinal parsing of number ' + i + ' date check');
23703 }
23704 });
23705
23706 test('strict ordinal parsing', function (assert) {
23707 var i, ordinalStr, testMoment;
23708 for (i = 1; i <= 31; ++i) {
23709 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
23710 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
23711 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
23712 }
23713 });
23714
23715 }));
23716
23717 (function (global, factory) {
23718 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
23719 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
23720 factory(global.moment)
23721 }(this, function (moment) { 'use strict';
23722
23723 /*global QUnit:false*/
23724
23725 var test = QUnit.test;
23726
23727 function module (name, lifecycle) {
23728 QUnit.module(name, {
23729 setup : function () {
23730 moment.locale('en');
23731 moment.createFromInputFallback = function () {
23732 throw new Error('input not handled by moment');
23733 };
23734 if (lifecycle && lifecycle.setup) {
23735 lifecycle.setup();
23736 }
23737 },
23738 teardown : function () {
23739 if (lifecycle && lifecycle.teardown) {
23740 lifecycle.teardown();
23741 }
23742 }
23743 });
23744 }
23745
23746 function localeModule (name, lifecycle) {
23747 QUnit.module('locale:' + name, {
23748 setup : function () {
23749 moment.locale(name);
23750 moment.createFromInputFallback = function () {
23751 throw new Error('input not handled by moment');
23752 };
23753 if (lifecycle && lifecycle.setup) {
23754 lifecycle.setup();
23755 }
23756 },
23757 teardown : function () {
23758 moment.locale('en');
23759 if (lifecycle && lifecycle.teardown) {
23760 lifecycle.teardown();
23761 }
23762 }
23763 });
23764 }
23765
23766 localeModule('ro');
23767
23768 test('parse', function (assert) {
23769 var tests = 'ianuarie ian._februarie febr._martie mart._aprilie apr._mai mai_iunie iun._iulie iul._august aug._septembrie sept._octombrie oct._noiembrie nov._decembrie dec.'.split('_'), i;
23770 function equalTest(input, mmm, i) {
23771 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
23772 }
23773 for (i = 0; i < 12; i++) {
23774 tests[i] = tests[i].split(' ');
23775 equalTest(tests[i][0], 'MMM', i);
23776 equalTest(tests[i][1], 'MMM', i);
23777 equalTest(tests[i][0], 'MMMM', i);
23778 equalTest(tests[i][1], 'MMMM', i);
23779 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
23780 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
23781 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
23782 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
23783 }
23784 });
23785
23786 test('format', function (assert) {
23787 var a = [
23788 ['dddd, MMMM Do YYYY, h:mm:ss A', 'duminică, februarie 14 2010, 3:25:50 PM'],
23789 ['ddd, hA', 'Dum, 3PM'],
23790 ['M Mo MM MMMM MMM', '2 2 02 februarie febr.'],
23791 ['YYYY YY', '2010 10'],
23792 ['D Do DD', '14 14 14'],
23793 ['d do dddd ddd dd', '0 0 duminică Dum Du'],
23794 ['DDD DDDo DDDD', '45 45 045'],
23795 ['w wo ww', '7 7 07'],
23796 ['h hh', '3 03'],
23797 ['H HH', '15 15'],
23798 ['m mm', '25 25'],
23799 ['s ss', '50 50'],
23800 ['a A', 'pm PM'],
23801 ['[a] DDDo[a zi a anului]', 'a 45a zi a anului'],
23802 ['LTS', '15:25:50'],
23803 ['L', '14.02.2010'],
23804 ['LL', '14 februarie 2010'],
23805 ['LLL', '14 februarie 2010 15:25'],
23806 ['LLLL', 'duminică, 14 februarie 2010 15:25'],
23807 ['l', '14.2.2010'],
23808 ['ll', '14 febr. 2010'],
23809 ['lll', '14 febr. 2010 15:25'],
23810 ['llll', 'Dum, 14 febr. 2010 15:25']
23811 ],
23812 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
23813 i;
23814 for (i = 0; i < a.length; i++) {
23815 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
23816 }
23817 });
23818
23819 test('format ordinal', function (assert) {
23820 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
23821 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
23822 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
23823 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
23824 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
23825 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
23826 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
23827 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
23828 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
23829 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
23830
23831 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
23832 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
23833 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
23834 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
23835 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
23836 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
23837 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
23838 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
23839 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
23840 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
23841
23842 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
23843 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
23844 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
23845 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
23846 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
23847 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
23848 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
23849 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
23850 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
23851 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
23852
23853 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
23854 });
23855
23856 test('format month', function (assert) {
23857 var expected = 'ianuarie ian._februarie febr._martie mart._aprilie apr._mai mai_iunie iun._iulie iul._august aug._septembrie sept._octombrie oct._noiembrie nov._decembrie dec.'.split('_'), i;
23858 for (i = 0; i < expected.length; i++) {
23859 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
23860 }
23861 });
23862
23863 test('format week', function (assert) {
23864 var expected = 'duminică Dum Du_luni Lun Lu_marți Mar Ma_miercuri Mie Mi_joi Joi Jo_vineri Vin Vi_sâmbătă Sâm Sâ'.split('_'), i;
23865 for (i = 0; i < expected.length; i++) {
23866 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
23867 }
23868 });
23869
23870 test('from', function (assert) {
23871 var start = moment([2007, 1, 28]);
23872 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'câteva secunde', '44 seconds = a few seconds');
23873 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minut', '45 seconds = a minute');
23874 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minut', '89 seconds = a minute');
23875 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
23876 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 de minute', '44 minutes = 44 minutes');
23877 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'o oră', '45 minutes = an hour');
23878 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'o oră', '89 minutes = an hour');
23879 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ore', '90 minutes = 2 hours');
23880 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ore', '5 hours = 5 hours');
23881 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 de ore', '21 hours = 21 hours');
23882 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'o zi', '22 hours = a day');
23883 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'o zi', '35 hours = a day');
23884 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 zile', '36 hours = 2 days');
23885 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'o zi', '1 day = a day');
23886 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 zile', '5 days = 5 days');
23887 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 de zile', '25 days = 25 days');
23888 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'o lună', '26 days = a month');
23889 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'o lună', '30 days = a month');
23890 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'o lună', '43 days = a month');
23891 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 luni', '46 days = 2 months');
23892 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 luni', '75 days = 2 months');
23893 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 luni', '76 days = 3 months');
23894 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'o lună', '1 month = a month');
23895 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 luni', '5 months = 5 months');
23896 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un an', '345 days = a year');
23897 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ani', '548 days = 2 years');
23898 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un an', '1 year = a year');
23899 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ani', '5 years = 5 years');
23900 assert.equal(start.from(moment([2007, 1, 28]).add({y: 19}), true), '19 ani', '19 years = 19 years');
23901 assert.equal(start.from(moment([2007, 1, 28]).add({y: 20}), true), '20 de ani', '20 years = 20 years');
23902 assert.equal(start.from(moment([2007, 1, 28]).add({y: 100}), true), '100 de ani', '100 years = 100 years');
23903 assert.equal(start.from(moment([2007, 1, 28]).add({y: 101}), true), '101 ani', '101 years = 101 years');
23904 assert.equal(start.from(moment([2007, 1, 28]).add({y: 119}), true), '119 ani', '119 years = 119 years');
23905 assert.equal(start.from(moment([2007, 1, 28]).add({y: 120}), true), '120 de ani', '120 years = 120 years');
23906 assert.equal(start.from(moment([2007, 1, 28]).add({y: 219}), true), '219 ani', '219 years = 219 years');
23907 assert.equal(start.from(moment([2007, 1, 28]).add({y: 220}), true), '220 de ani', '220 years = 220 years');
23908 });
23909
23910 test('suffix', function (assert) {
23911 assert.equal(moment(30000).from(0), 'peste câteva secunde', 'prefix');
23912 assert.equal(moment(0).from(30000), 'câteva secunde în urmă', 'suffix');
23913 });
23914
23915 test('now from now', function (assert) {
23916 assert.equal(moment().fromNow(), 'câteva secunde în urmă', 'now from now should display as in the past');
23917 });
23918
23919 test('fromNow', function (assert) {
23920 assert.equal(moment().add({s: 30}).fromNow(), 'peste câteva secunde', 'in a few seconds');
23921 assert.equal(moment().add({d: 5}).fromNow(), 'peste 5 zile', 'in 5 days');
23922 });
23923
23924 test('calendar day', function (assert) {
23925 var a = moment().hours(2).minutes(0).seconds(0);
23926
23927 assert.equal(moment(a).calendar(), 'azi la 2:00', 'today at the same time');
23928 assert.equal(moment(a).add({m: 25}).calendar(), 'azi la 2:25', 'Now plus 25 min');
23929 assert.equal(moment(a).add({h: 1}).calendar(), 'azi la 3:00', 'Now plus 1 hour');
23930 assert.equal(moment(a).add({d: 1}).calendar(), 'mâine la 2:00', 'tomorrow at the same time');
23931 assert.equal(moment(a).subtract({h: 1}).calendar(), 'azi la 1:00', 'Now minus 1 hour');
23932 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieri la 2:00', 'yesterday at the same time');
23933 });
23934
23935 test('calendar next week', function (assert) {
23936 var i, m;
23937 for (i = 2; i < 7; i++) {
23938 m = moment().add({d: i});
23939 assert.equal(m.calendar(), m.format('dddd [la] LT'), 'Today + ' + i + ' days current time');
23940 m.hours(0).minutes(0).seconds(0).milliseconds(0);
23941 assert.equal(m.calendar(), m.format('dddd [la] LT'), 'Today + ' + i + ' days beginning of day');
23942 m.hours(23).minutes(59).seconds(59).milliseconds(999);
23943 assert.equal(m.calendar(), m.format('dddd [la] LT'), 'Today + ' + i + ' days end of day');
23944 }
23945 });
23946
23947 test('calendar last week', function (assert) {
23948 var i, m;
23949 for (i = 2; i < 7; i++) {
23950 m = moment().subtract({d: i});
23951 assert.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), 'Today - ' + i + ' days current time');
23952 m.hours(0).minutes(0).seconds(0).milliseconds(0);
23953 assert.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), 'Today - ' + i + ' days beginning of day');
23954 m.hours(23).minutes(59).seconds(59).milliseconds(999);
23955 assert.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), 'Today - ' + i + ' days end of day');
23956 }
23957 });
23958
23959 test('calendar all else', function (assert) {
23960 var weeksAgo = moment().subtract({w: 1}),
23961 weeksFromNow = moment().add({w: 1});
23962
23963 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
23964 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
23965
23966 weeksAgo = moment().subtract({w: 2});
23967 weeksFromNow = moment().add({w: 2});
23968
23969 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
23970 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
23971 });
23972
23973 test('weeks year starting sunday', function (assert) {
23974 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
23975 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
23976 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
23977 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
23978 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
23979 });
23980
23981 test('weeks year starting monday', function (assert) {
23982 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
23983 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
23984 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
23985 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
23986 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
23987 });
23988
23989 test('weeks year starting tuesday', function (assert) {
23990 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
23991 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
23992 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
23993 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
23994 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
23995 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
23996 });
23997
23998 test('weeks year starting wednesday', function (assert) {
23999 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
24000 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
24001 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
24002 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
24003 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
24004 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
24005 });
24006
24007 test('weeks year starting thursday', function (assert) {
24008 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
24009 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
24010 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
24011 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
24012 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
24013 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
24014 });
24015
24016 test('weeks year starting friday', function (assert) {
24017 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
24018 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
24019 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
24020 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
24021 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
24022 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
24023 });
24024
24025 test('weeks year starting saturday', function (assert) {
24026 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
24027 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
24028 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
24029 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
24030 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
24031 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
24032 });
24033
24034 test('weeks year starting sunday formatted', function (assert) {
24035 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
24036 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
24037 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 2');
24038 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
24039 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
24040 });
24041
24042 test('lenient ordinal parsing', function (assert) {
24043 var i, ordinalStr, testMoment;
24044 for (i = 1; i <= 31; ++i) {
24045 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
24046 testMoment = moment(ordinalStr, 'YYYY MM Do');
24047 assert.equal(testMoment.year(), 2014,
24048 'lenient ordinal parsing ' + i + ' year check');
24049 assert.equal(testMoment.month(), 0,
24050 'lenient ordinal parsing ' + i + ' month check');
24051 assert.equal(testMoment.date(), i,
24052 'lenient ordinal parsing ' + i + ' date check');
24053 }
24054 });
24055
24056 test('lenient ordinal parsing of number', function (assert) {
24057 var i, testMoment;
24058 for (i = 1; i <= 31; ++i) {
24059 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
24060 assert.equal(testMoment.year(), 2014,
24061 'lenient ordinal parsing of number ' + i + ' year check');
24062 assert.equal(testMoment.month(), 0,
24063 'lenient ordinal parsing of number ' + i + ' month check');
24064 assert.equal(testMoment.date(), i,
24065 'lenient ordinal parsing of number ' + i + ' date check');
24066 }
24067 });
24068
24069 test('strict ordinal parsing', function (assert) {
24070 var i, ordinalStr, testMoment;
24071 for (i = 1; i <= 31; ++i) {
24072 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
24073 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
24074 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
24075 }
24076 });
24077
24078 }));
24079
24080 (function (global, factory) {
24081 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
24082 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
24083 factory(global.moment)
24084 }(this, function (moment) { 'use strict';
24085
24086 /*global QUnit:false*/
24087
24088 var test = QUnit.test;
24089
24090 function module (name, lifecycle) {
24091 QUnit.module(name, {
24092 setup : function () {
24093 moment.locale('en');
24094 moment.createFromInputFallback = function () {
24095 throw new Error('input not handled by moment');
24096 };
24097 if (lifecycle && lifecycle.setup) {
24098 lifecycle.setup();
24099 }
24100 },
24101 teardown : function () {
24102 if (lifecycle && lifecycle.teardown) {
24103 lifecycle.teardown();
24104 }
24105 }
24106 });
24107 }
24108
24109 function localeModule (name, lifecycle) {
24110 QUnit.module('locale:' + name, {
24111 setup : function () {
24112 moment.locale(name);
24113 moment.createFromInputFallback = function () {
24114 throw new Error('input not handled by moment');
24115 };
24116 if (lifecycle && lifecycle.setup) {
24117 lifecycle.setup();
24118 }
24119 },
24120 teardown : function () {
24121 moment.locale('en');
24122 if (lifecycle && lifecycle.teardown) {
24123 lifecycle.teardown();
24124 }
24125 }
24126 });
24127 }
24128
24129 localeModule('ru');
24130
24131 test('parse', function (assert) {
24132 var tests = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
24133 function equalTest(input, mmm, i) {
24134 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
24135 }
24136 for (i = 0; i < 12; i++) {
24137 tests[i] = tests[i].split(' ');
24138 equalTest(tests[i][0], 'MMM', i);
24139 equalTest(tests[i][1], 'MMM', i);
24140 equalTest(tests[i][0], 'MMMM', i);
24141 equalTest(tests[i][1], 'MMMM', i);
24142 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
24143 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
24144 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
24145 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
24146 }
24147 });
24148
24149 test('parse exceptional case', function (assert) {
24150 assert.equal(moment('11 мая 1989', ['DD MMMM YYYY']).format('DD-MM-YYYY'), '11-05-1989');
24151 });
24152
24153 test('format', function (assert) {
24154 var a = [
24155 ['dddd, Do MMMM YYYY, HH:mm:ss', 'воскресенье, 14-го февраля 2010, 15:25:50'],
24156 ['ddd, h A', 'вс, 3 дня'],
24157 ['M Mo MM MMMM MMM', '2 2-й 02 февраль фев'],
24158 ['YYYY YY', '2010 10'],
24159 ['D Do DD', '14 14-го 14'],
24160 ['d do dddd ddd dd', '0 0-й воскресенье вс вс'],
24161 ['DDD DDDo DDDD', '45 45-й 045'],
24162 ['w wo ww', '7 7-я 07'],
24163 ['h hh', '3 03'],
24164 ['H HH', '15 15'],
24165 ['m mm', '25 25'],
24166 ['s ss', '50 50'],
24167 ['a A', 'дня дня'],
24168 ['DDDo [день года]', '45-й день года'],
24169 ['LTS', '15:25:50'],
24170 ['L', '14.02.2010'],
24171 ['LL', '14 февраля 2010 г.'],
24172 ['LLL', '14 февраля 2010 г., 15:25'],
24173 ['LLLL', 'воскресенье, 14 февраля 2010 г., 15:25'],
24174 ['l', '14.2.2010'],
24175 ['ll', '14 фев 2010 г.'],
24176 ['lll', '14 фев 2010 г., 15:25'],
24177 ['llll', 'вс, 14 фев 2010 г., 15:25']
24178 ],
24179 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
24180 i;
24181 for (i = 0; i < a.length; i++) {
24182 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
24183 }
24184 });
24185
24186 test('format meridiem', function (assert) {
24187 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'ночи', 'night');
24188 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'ночи', 'night');
24189 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'утра', 'morning');
24190 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'утра', 'morning');
24191 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'дня', 'afternoon');
24192 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'дня', 'afternoon');
24193 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'вечера', 'evening');
24194 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'вечера', 'evening');
24195 });
24196
24197 test('format ordinal', function (assert) {
24198 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-й', '1-й');
24199 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-й', '2-й');
24200 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-й', '3-й');
24201 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-й', '4-й');
24202 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-й', '5-й');
24203 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-й', '6-й');
24204 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-й', '7-й');
24205 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-й', '8-й');
24206 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-й', '9-й');
24207 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-й', '10-й');
24208
24209 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-й', '11-й');
24210 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-й', '12-й');
24211 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-й', '13-й');
24212 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-й', '14-й');
24213 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-й', '15-й');
24214 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-й', '16-й');
24215 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-й', '17-й');
24216 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-й', '18-й');
24217 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-й', '19-й');
24218 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-й', '20-й');
24219
24220 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-й', '21-й');
24221 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-й', '22-й');
24222 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-й', '23-й');
24223 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-й', '24-й');
24224 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-й', '25-й');
24225 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-й', '26-й');
24226 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-й', '27-й');
24227 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-й', '28-й');
24228 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-й', '29-й');
24229 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-й', '30-й');
24230
24231 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-й', '31-й');
24232 });
24233
24234 test('format month', function (assert) {
24235 var expected = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
24236 for (i = 0; i < expected.length; i++) {
24237 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
24238 }
24239 });
24240
24241 test('format month case', function (assert) {
24242 var months = {
24243 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
24244 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
24245 }, i;
24246 for (i = 0; i < 12; i++) {
24247 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
24248 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
24249 }
24250 });
24251
24252 test('format month short case', function (assert) {
24253 var monthsShort = {
24254 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
24255 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
24256 }, i;
24257 for (i = 0; i < 12; i++) {
24258 assert.equal(moment([2011, i, 1]).format('D MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
24259 assert.equal(moment([2011, i, 1]).format('MMM'), monthsShort.nominative[i], '1 ' + monthsShort.nominative[i]);
24260 }
24261 });
24262
24263 test('format month case with escaped symbols', function (assert) {
24264 var months = {
24265 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
24266 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
24267 }, i;
24268 for (i = 0; i < 12; i++) {
24269 assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
24270 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMMM[</b>]'), '<i>1</i> <b>' + months.accusative[i] + '</b>', '1 <b>' + months.accusative[i] + '</b>');
24271 assert.equal(moment([2013, i, 1]).format('D[-й день] MMMM'), '1-й день ' + months.accusative[i], '1-й день ' + months.accusative[i]);
24272 assert.equal(moment([2013, i, 1]).format('D, MMMM'), '1, ' + months.nominative[i], '1, ' + months.nominative[i]);
24273 }
24274 });
24275
24276 test('format month short case with escaped symbols', function (assert) {
24277 var monthsShort = {
24278 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
24279 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
24280 }, i;
24281 for (i = 0; i < 12; i++) {
24282 assert.equal(moment([2013, i, 1]).format('D[] MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
24283 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMM[</b>]'), '<i>1</i> <b>' + monthsShort.accusative[i] + '</b>', '1 <b>' + monthsShort.accusative[i] + '</b>');
24284 assert.equal(moment([2013, i, 1]).format('D[-й день] MMM'), '1-й день ' + monthsShort.accusative[i], '1-й день ' + monthsShort.accusative[i]);
24285 assert.equal(moment([2013, i, 1]).format('D, MMM'), '1, ' + monthsShort.nominative[i], '1, ' + monthsShort.nominative[i]);
24286 }
24287 });
24288
24289 test('format week', function (assert) {
24290 var expected = 'воскресенье вс вс_понедельник пн пн_вторник вт вт_среда ср ср_четверг чт чт_пятница пт пт_суббота сб сб'.split('_'), i;
24291 for (i = 0; i < expected.length; i++) {
24292 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
24293 }
24294 });
24295
24296 test('from', function (assert) {
24297 var start = moment([2007, 1, 28]);
24298 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'несколько секунд', '44 seconds = seconds');
24299 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'минута', '45 seconds = a minute');
24300 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'минута', '89 seconds = a minute');
24301 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минуты', '90 seconds = 2 minutes');
24302 assert.equal(start.from(moment([2007, 1, 28]).add({m: 31}), true), '31 минута', '31 minutes = 31 minutes');
24303 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минуты', '44 minutes = 44 minutes');
24304 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'час', '45 minutes = an hour');
24305 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'час', '89 minutes = an hour');
24306 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 часа', '90 minutes = 2 hours');
24307 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 часов', '5 hours = 5 hours');
24308 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 час', '21 hours = 21 hours');
24309 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'день', '22 hours = a day');
24310 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'день', '35 hours = a day');
24311 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дня', '36 hours = 2 days');
24312 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'день', '1 day = a day');
24313 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дней', '5 days = 5 days');
24314 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 дней', '11 days = 11 days');
24315 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 день', '21 days = 21 days');
24316 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дней', '25 days = 25 days');
24317 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месяц', '26 days = a month');
24318 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месяц', '30 days = a month');
24319 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месяц', '43 days = a month');
24320 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месяца', '46 days = 2 months');
24321 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месяца', '75 days = 2 months');
24322 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месяца', '76 days = 3 months');
24323 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месяц', '1 month = a month');
24324 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месяцев', '5 months = 5 months');
24325 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'год', '345 days = a year');
24326 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 года', '548 days = 2 years');
24327 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'год', '1 year = a year');
24328 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 лет', '5 years = 5 years');
24329 });
24330
24331 test('suffix', function (assert) {
24332 assert.equal(moment(30000).from(0), 'через несколько секунд', 'prefix');
24333 assert.equal(moment(0).from(30000), 'несколько секунд назад', 'suffix');
24334 });
24335
24336 test('fromNow', function (assert) {
24337 assert.equal(moment().add({s: 30}).fromNow(), 'через несколько секунд', 'in seconds');
24338 assert.equal(moment().add({d: 5}).fromNow(), 'через 5 дней', 'in 5 days');
24339 assert.equal(moment().add({m: 31}).fromNow(), 'через 31 минуту', 'in 31 minutes = in 31 minutes');
24340 assert.equal(moment().subtract({m: 31}).fromNow(), '31 минуту назад', '31 minutes ago = 31 minutes ago');
24341 });
24342
24343 test('calendar day', function (assert) {
24344 var a = moment().hours(2).minutes(0).seconds(0);
24345
24346 assert.equal(moment(a).calendar(), 'Сегодня в 02:00', 'today at the same time');
24347 assert.equal(moment(a).add({m: 25}).calendar(), 'Сегодня в 02:25', 'Now plus 25 min');
24348 assert.equal(moment(a).add({h: 1}).calendar(), 'Сегодня в 03:00', 'Now plus 1 hour');
24349 assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра в 02:00', 'tomorrow at the same time');
24350 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сегодня в 01:00', 'Now minus 1 hour');
24351 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 02:00', 'yesterday at the same time');
24352 });
24353
24354 test('calendar next week', function (assert) {
24355 var i, m;
24356 function makeFormat(d) {
24357 return d.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
24358 }
24359
24360 for (i = 2; i < 7; i++) {
24361 m = moment().add({d: i});
24362 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
24363 m.hours(0).minutes(0).seconds(0).milliseconds(0);
24364 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
24365 m.hours(23).minutes(59).seconds(59).milliseconds(999);
24366 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
24367 }
24368 });
24369
24370 test('calendar last week', function (assert) {
24371 var i, m, now;
24372
24373 function makeFormatLast(d) {
24374 switch (d.day()) {
24375 case 0:
24376 return '[В прошлое] dddd [в] LT';
24377 case 1:
24378 case 2:
24379 case 4:
24380 return '[В прошлый] dddd [в] LT';
24381 case 3:
24382 case 5:
24383 case 6:
24384 return '[В прошлую] dddd [в] LT';
24385 }
24386 }
24387
24388 function makeFormatThis(d) {
24389 switch (d.day()) {
24390 case 2:
24391 return '[Во] dddd [в] LT';
24392 case 0:
24393 case 1:
24394 case 3:
24395 case 4:
24396 case 5:
24397 case 6:
24398 return '[В] dddd [в] LT';
24399 }
24400 }
24401
24402 now = moment().startOf('week');
24403 for (i = 2; i < 7; i++) {
24404 m = moment(now).subtract({d: i});
24405 assert.equal(m.calendar(now), m.format(makeFormatLast(m)), 'Today - ' + i + ' days current time');
24406 m.hours(0).minutes(0).seconds(0).milliseconds(0);
24407 assert.equal(m.calendar(now), m.format(makeFormatLast(m)), 'Today - ' + i + ' days beginning of day');
24408 m.hours(23).minutes(59).seconds(59).milliseconds(999);
24409 assert.equal(m.calendar(now), m.format(makeFormatLast(m)), 'Today - ' + i + ' days end of day');
24410 }
24411
24412 now = moment().endOf('week');
24413 for (i = 2; i < 7; i++) {
24414 m = moment(now).subtract({d: i});
24415 assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today - ' + i + ' days current time');
24416 m.hours(0).minutes(0).seconds(0).milliseconds(0);
24417 assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today - ' + i + ' days beginning of day');
24418 m.hours(23).minutes(59).seconds(59).milliseconds(999);
24419 assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today - ' + i + ' days end of day');
24420 }
24421 });
24422
24423 test('calendar all else', function (assert) {
24424 var weeksAgo = moment().subtract({w: 1}),
24425 weeksFromNow = moment().add({w: 1});
24426
24427 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
24428 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
24429
24430 weeksAgo = moment().subtract({w: 2});
24431 weeksFromNow = moment().add({w: 2});
24432
24433 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
24434 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
24435 });
24436
24437 test('weeks year starting sunday', function (assert) {
24438 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
24439 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
24440 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
24441 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
24442 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
24443 });
24444
24445 test('weeks year starting monday', function (assert) {
24446 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
24447 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
24448 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
24449 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
24450 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
24451 });
24452
24453 test('weeks year starting tuesday', function (assert) {
24454 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
24455 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
24456 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
24457 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
24458 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
24459 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
24460 });
24461
24462 test('weeks year starting wednesday', function (assert) {
24463 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
24464 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
24465 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
24466 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
24467 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
24468 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
24469 });
24470
24471 test('weeks year starting thursday', function (assert) {
24472 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
24473 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
24474 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
24475 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
24476 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
24477 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
24478 });
24479
24480 test('weeks year starting friday', function (assert) {
24481 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
24482 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
24483 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
24484 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
24485 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
24486 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
24487 });
24488
24489 test('weeks year starting saturday', function (assert) {
24490 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
24491 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
24492 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
24493 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
24494 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
24495 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
24496 });
24497
24498 test('weeks year starting sunday formatted', function (assert) {
24499 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-я', 'Dec 26 2011 should be week 1');
24500 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-я', 'Jan 1 2012 should be week 1');
24501 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-я', 'Jan 2 2012 should be week 2');
24502 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-я', 'Jan 8 2012 should be week 2');
24503 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-я', 'Jan 9 2012 should be week 3');
24504 });
24505
24506 test('lenient ordinal parsing', function (assert) {
24507 var i, ordinalStr, testMoment;
24508 for (i = 1; i <= 31; ++i) {
24509 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
24510 testMoment = moment(ordinalStr, 'YYYY MM Do');
24511 assert.equal(testMoment.year(), 2014,
24512 'lenient ordinal parsing ' + i + ' year check');
24513 assert.equal(testMoment.month(), 0,
24514 'lenient ordinal parsing ' + i + ' month check');
24515 assert.equal(testMoment.date(), i,
24516 'lenient ordinal parsing ' + i + ' date check');
24517 }
24518 });
24519
24520 test('lenient ordinal parsing of number', function (assert) {
24521 var i, testMoment;
24522 for (i = 1; i <= 31; ++i) {
24523 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
24524 assert.equal(testMoment.year(), 2014,
24525 'lenient ordinal parsing of number ' + i + ' year check');
24526 assert.equal(testMoment.month(), 0,
24527 'lenient ordinal parsing of number ' + i + ' month check');
24528 assert.equal(testMoment.date(), i,
24529 'lenient ordinal parsing of number ' + i + ' date check');
24530 }
24531 });
24532
24533 test('strict ordinal parsing', function (assert) {
24534 var i, ordinalStr, testMoment;
24535 for (i = 1; i <= 31; ++i) {
24536 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
24537 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
24538 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
24539 }
24540 });
24541
24542 }));
24543
24544 (function (global, factory) {
24545 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
24546 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
24547 factory(global.moment)
24548 }(this, function (moment) { 'use strict';
24549
24550 /*global QUnit:false*/
24551
24552 var test = QUnit.test;
24553
24554 function module (name, lifecycle) {
24555 QUnit.module(name, {
24556 setup : function () {
24557 moment.locale('en');
24558 moment.createFromInputFallback = function () {
24559 throw new Error('input not handled by moment');
24560 };
24561 if (lifecycle && lifecycle.setup) {
24562 lifecycle.setup();
24563 }
24564 },
24565 teardown : function () {
24566 if (lifecycle && lifecycle.teardown) {
24567 lifecycle.teardown();
24568 }
24569 }
24570 });
24571 }
24572
24573 function localeModule (name, lifecycle) {
24574 QUnit.module('locale:' + name, {
24575 setup : function () {
24576 moment.locale(name);
24577 moment.createFromInputFallback = function () {
24578 throw new Error('input not handled by moment');
24579 };
24580 if (lifecycle && lifecycle.setup) {
24581 lifecycle.setup();
24582 }
24583 },
24584 teardown : function () {
24585 moment.locale('en');
24586 if (lifecycle && lifecycle.teardown) {
24587 lifecycle.teardown();
24588 }
24589 }
24590 });
24591 }
24592
24593 localeModule('si');
24594
24595 /*jshint -W100*/
24596 test('parse', function (assert) {
24597 var tests = 'ජනවාරි ජන_පෙබරවාරි පෙබ_මාර්තු මාර්_අප්‍රේල් අප්_මැයි මැයි_ජූනි ජූනි_ජූලි ජූලි_අගෝස්තු අගෝ_සැප්තැම්බර් සැප්_ඔක්තෝබර් ඔක්_නොවැම්බර් නොවැ_දෙසැම්බර් දෙසැ'.split('_'), i;
24598 function equalTest(input, mmm, i) {
24599 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
24600 }
24601 for (i = 0; i < 12; i++) {
24602 tests[i] = tests[i].split(' ');
24603 equalTest(tests[i][0], 'MMM', i);
24604 equalTest(tests[i][1], 'MMM', i);
24605 equalTest(tests[i][0], 'MMMM', i);
24606 equalTest(tests[i][1], 'MMMM', i);
24607 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
24608 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
24609 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
24610 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
24611 }
24612 });
24613
24614 test('format', function (assert) {
24615 var a = [
24616 ['YYYY MMMM Do dddd, a h:mm:ss', '2010 පෙබරවාරි 14 වැනි ඉරිදා, ප.ව. 3:25:50'],
24617 ['YYYY MMMM Do dddd, a h:mm:ss', '2010 පෙබරවාරි 14 වැනි ඉරිදා, ප.ව. 3:25:50'],
24618 ['ddd, A h', 'ඉරි, පස් වරු 3'],
24619 ['M Mo MM MMMM MMM', '2 2 වැනි 02 පෙබරවාරි පෙබ'],
24620 ['YYYY YY', '2010 10'],
24621 ['D Do DD', '14 14 වැනි 14'],
24622 ['d do dddd ddd dd', '0 0 වැනි ඉරිදා ඉරි ඉ'],
24623 ['DDD DDDo DDDD', '45 45 වැනි 045'],
24624 ['h hh', '3 03'],
24625 ['H HH', '15 15'],
24626 ['m mm', '25 25'],
24627 ['s ss', '50 50'],
24628 ['a A', 'ප.ව. පස් වරු'],
24629 ['[වසරේ] DDDo [දිනය]', 'වසරේ 45 වැනි දිනය'],
24630 ['LTS', 'ප.ව. 3:25:50'],
24631 ['LT', 'ප.ව. 3:25'],
24632 ['L', '2010/02/14'],
24633 ['LL', '2010 පෙබරවාරි 14'],
24634 ['LLL', '2010 පෙබරවාරි 14, ප.ව. 3:25'],
24635 ['LLLL', '2010 පෙබරවාරි 14 වැනි ඉරිදා, ප.ව. 3:25:50'],
24636 ['l', '2010/2/14'],
24637 ['ll', '2010 පෙබ 14'],
24638 ['lll', '2010 පෙබ 14, ප.ව. 3:25'],
24639 ['llll', '2010 පෙබ 14 වැනි ඉරි, ප.ව. 3:25:50']
24640 ],
24641 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
24642 i;
24643 for (i = 0; i < a.length; i++) {
24644 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
24645 }
24646 });
24647
24648 test('format ordinal', function (assert) {
24649 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1 වැනි', '1 වැනි');
24650 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2 වැනි', '2 වැනි');
24651 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3 වැනි', '3 වැනි');
24652 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4 වැනි', '4 වැනි');
24653 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5 වැනි', '5 වැනි');
24654 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6 වැනි', '6 වැනි');
24655 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7 වැනි', '7 වැනි');
24656 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8 වැනි', '8 වැනි');
24657 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9 වැනි', '9 වැනි');
24658 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10 වැනි', '10 වැනි');
24659
24660 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11 වැනි', '11 වැනි');
24661 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12 වැනි', '12 වැනි');
24662 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13 වැනි', '13 වැනි');
24663 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14 වැනි', '14 වැනි');
24664 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15 වැනි', '15 වැනි');
24665 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16 වැනි', '16 වැනි');
24666 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17 වැනි', '17 වැනි');
24667 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18 වැනි', '18 වැනි');
24668 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19 වැනි', '19 වැනි');
24669 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20 වැනි', '20 වැනි');
24670
24671 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21 වැනි', '21 වැනි');
24672 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22 වැනි', '22 වැනි');
24673 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23 වැනි', '23 වැනි');
24674 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24 වැනි', '24 වැනි');
24675 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25 වැනි', '25 වැනි');
24676 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26 වැනි', '26 වැනි');
24677 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27 වැනි', '27 වැනි');
24678 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28 වැනි', '28 වැනි');
24679 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29 වැනි', '29 වැනි');
24680 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30 වැනි', '30 වැනි');
24681
24682 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31 වැනි', '31 වැනි');
24683 });
24684
24685 test('format month', function (assert) {
24686 var expected = 'ජනවාරි ජන_පෙබරවාරි පෙබ_මාර්තු මාර්_අප්‍රේල් අප්_මැයි මැයි_ජූනි ජූනි_ජූලි ජූලි_අගෝස්තු අගෝ_සැප්තැම්බර් සැප්_ඔක්තෝබර් ඔක්_නොවැම්බර් නොවැ_දෙසැම්බර් දෙසැ'.split('_'), i;
24687 for (i = 0; i < expected.length; i++) {
24688 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
24689 }
24690 });
24691
24692 test('format week', function (assert) {
24693 var expected = 'ඉරිදා ඉරි ඉ_සඳුදා සඳු ස_අඟහරුවාදා අඟ අ_බදාදා බදා බ_බ්‍රහස්පතින්දා බ්‍රහ බ්‍ර_සිකුරාදා සිකු සි_සෙනසුරාදා සෙන සෙ'.split('_'), i;
24694 for (i = 0; i < expected.length; i++) {
24695 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
24696 }
24697 });
24698
24699 test('from', function (assert) {
24700 var start = moment([2007, 1, 28]);
24701 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'තත්පර කිහිපය', '44 seconds = a few seconds');
24702 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'මිනිත්තුව', '45 seconds = a minute');
24703 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'මිනිත්තුව', '89 seconds = a minute');
24704 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'මිනිත්තු 2', '90 seconds = 2 minutes');
24705 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), 'මිනිත්තු 44', '44 minutes = 44 minutes');
24706 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'පැය', '45 minutes = an hour');
24707 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'පැය', '89 minutes = an hour');
24708 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'පැය 2', '90 minutes = 2 hours');
24709 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'පැය 5', '5 hours = 5 hours');
24710 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), 'පැය 21', '21 hours = 21 hours');
24711 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'දිනය', '22 hours = a day');
24712 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'දිනය', '35 hours = a day');
24713 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'දින 2', '36 hours = 2 days');
24714 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'දිනය', '1 day = a day');
24715 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'දින 5', '5 days = 5 days');
24716 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), 'දින 25', '25 days = 25 days');
24717 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'මාසය', '26 days = a month');
24718 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'මාසය', '30 days = a month');
24719 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'මාසය', '43 days = a month');
24720 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'මාස 2', '46 days = 2 months');
24721 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'මාස 2', '75 days = 2 months');
24722 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'මාස 3', '76 days = 3 months');
24723 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'මාසය', '1 month = a month');
24724 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'මාස 5', '5 months = 5 months');
24725 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'වසර', '345 days = a year');
24726 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'වසර 2', '548 days = 2 years');
24727 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'වසර', '1 year = a year');
24728 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'වසර 5', '5 years = 5 years');
24729 });
24730
24731 test('suffix', function (assert) {
24732 assert.equal(moment(30000).from(0), 'තත්පර කිහිපයකින්', 'prefix');
24733 assert.equal(moment(0).from(30000), 'තත්පර කිහිපයකට පෙර', 'suffix');
24734 });
24735
24736 test('now from now', function (assert) {
24737 assert.equal(moment().fromNow(), 'තත්පර කිහිපයකට පෙර', 'now from now should display as in the past');
24738 });
24739
24740 test('fromNow', function (assert) {
24741 assert.equal(moment().add({s: 30}).fromNow(), 'තත්පර කිහිපයකින්', 'in a few seconds');
24742 assert.equal(moment().add({d: 5}).fromNow(), 'දින 5කින්', 'in 5 days');
24743 });
24744
24745 test('calendar day', function (assert) {
24746 var a = moment().hours(2).minutes(0).seconds(0);
24747
24748 assert.equal(moment(a).calendar(), 'අද පෙ.ව. 2:00ට', 'today at the same time');
24749 assert.equal(moment(a).add({m: 25}).calendar(), 'අද පෙ.ව. 2:25ට', 'Now plus 25 min');
24750 assert.equal(moment(a).add({h: 1}).calendar(), 'අද පෙ.ව. 3:00ට', 'Now plus 1 hour');
24751 assert.equal(moment(a).add({d: 1}).calendar(), 'හෙට පෙ.ව. 2:00ට', 'tomorrow at the same time');
24752 assert.equal(moment(a).subtract({h: 1}).calendar(), 'අද පෙ.ව. 1:00ට', 'Now minus 1 hour');
24753 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ඊයේ පෙ.ව. 2:00ට', 'yesterday at the same time');
24754 });
24755
24756 test('calendar next week', function (assert) {
24757 var i, m;
24758 for (i = 2; i < 7; i++) {
24759 m = moment().add({d: i});
24760 assert.equal(m.calendar(), m.format('dddd LT[ට]'), 'Today + ' + i + ' days current time');
24761 m.hours(0).minutes(0).seconds(0).milliseconds(0);
24762 assert.equal(m.calendar(), m.format('dddd LT[ට]'), 'Today + ' + i + ' days beginning of day');
24763 m.hours(23).minutes(59).seconds(59).milliseconds(999);
24764 assert.equal(m.calendar(), m.format('dddd LT[ට]'), 'Today + ' + i + ' days end of day');
24765 }
24766 });
24767
24768 test('calendar last week', function (assert) {
24769 var i, m;
24770
24771 for (i = 2; i < 7; i++) {
24772 m = moment().subtract({d: i});
24773 assert.equal(m.calendar(), m.format('[පසුගිය] dddd LT[ට]'), 'Today - ' + i + ' days current time');
24774 m.hours(0).minutes(0).seconds(0).milliseconds(0);
24775 assert.equal(m.calendar(), m.format('[පසුගිය] dddd LT[ට]'), 'Today - ' + i + ' days beginning of day');
24776 m.hours(23).minutes(59).seconds(59).milliseconds(999);
24777 assert.equal(m.calendar(), m.format('[පසුගිය] dddd LT[ට]'), 'Today - ' + i + ' days end of day');
24778 }
24779 });
24780
24781 test('calendar all else', function (assert) {
24782 var weeksAgo = moment().subtract({w: 1}),
24783 weeksFromNow = moment().add({w: 1});
24784
24785 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
24786 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
24787
24788 weeksAgo = moment().subtract({w: 2});
24789 weeksFromNow = moment().add({w: 2});
24790
24791 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
24792 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
24793 });
24794
24795 test('lenient ordinal parsing', function (assert) {
24796 var i, ordinalStr, testMoment;
24797 for (i = 1; i <= 31; ++i) {
24798 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
24799 testMoment = moment(ordinalStr, 'YYYY MM Do');
24800 assert.equal(testMoment.year(), 2014,
24801 'lenient ordinal parsing ' + i + ' year check');
24802 assert.equal(testMoment.month(), 0,
24803 'lenient ordinal parsing ' + i + ' month check');
24804 assert.equal(testMoment.date(), i,
24805 'lenient ordinal parsing ' + i + ' date check');
24806 }
24807 });
24808
24809 test('lenient ordinal parsing of number', function (assert) {
24810 var i, testMoment;
24811 for (i = 1; i <= 31; ++i) {
24812 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
24813 assert.equal(testMoment.year(), 2014,
24814 'lenient ordinal parsing of number ' + i + ' year check');
24815 assert.equal(testMoment.month(), 0,
24816 'lenient ordinal parsing of number ' + i + ' month check');
24817 assert.equal(testMoment.date(), i,
24818 'lenient ordinal parsing of number ' + i + ' date check');
24819 }
24820 });
24821
24822 test('strict ordinal parsing', function (assert) {
24823 var i, ordinalStr, testMoment;
24824 for (i = 1; i <= 31; ++i) {
24825 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
24826 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
24827 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
24828 }
24829 });
24830
24831 }));
24832
24833 (function (global, factory) {
24834 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
24835 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
24836 factory(global.moment)
24837 }(this, function (moment) { 'use strict';
24838
24839 /*global QUnit:false*/
24840
24841 var test = QUnit.test;
24842
24843 function module (name, lifecycle) {
24844 QUnit.module(name, {
24845 setup : function () {
24846 moment.locale('en');
24847 moment.createFromInputFallback = function () {
24848 throw new Error('input not handled by moment');
24849 };
24850 if (lifecycle && lifecycle.setup) {
24851 lifecycle.setup();
24852 }
24853 },
24854 teardown : function () {
24855 if (lifecycle && lifecycle.teardown) {
24856 lifecycle.teardown();
24857 }
24858 }
24859 });
24860 }
24861
24862 function localeModule (name, lifecycle) {
24863 QUnit.module('locale:' + name, {
24864 setup : function () {
24865 moment.locale(name);
24866 moment.createFromInputFallback = function () {
24867 throw new Error('input not handled by moment');
24868 };
24869 if (lifecycle && lifecycle.setup) {
24870 lifecycle.setup();
24871 }
24872 },
24873 teardown : function () {
24874 moment.locale('en');
24875 if (lifecycle && lifecycle.teardown) {
24876 lifecycle.teardown();
24877 }
24878 }
24879 });
24880 }
24881
24882 localeModule('sk');
24883
24884 test('parse', function (assert) {
24885 var tests = 'január jan._február feb._marec mar._apríl apr._máj máj_jún jún._júl júl._august aug._september sep._október okt._november nov._december dec.'.split('_'), i;
24886 function equalTest(input, mmm, monthIndex) {
24887 assert.equal(moment(input, mmm).month(), monthIndex, input + ' should be month ' + (monthIndex + 1));
24888 }
24889 for (i = 0; i < 12; i++) {
24890 tests[i] = tests[i].split(' ');
24891 equalTest(tests[i][0], 'MMM', i);
24892 equalTest(tests[i][1], 'MMM', i);
24893 equalTest(tests[i][0], 'MMMM', i);
24894 equalTest(tests[i][1], 'MMMM', i);
24895 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
24896 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
24897 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
24898 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
24899 }
24900 });
24901
24902 test('format', function (assert) {
24903 var a = [
24904 ['dddd, MMMM Do YYYY, h:mm:ss', 'nedeľa, február 14. 2010, 3:25:50'],
24905 ['ddd, h', 'ne, 3'],
24906 ['M Mo MM MMMM MMM', '2 2. 02 február feb'],
24907 ['YYYY YY', '2010 10'],
24908 ['D Do DD', '14 14. 14'],
24909 ['d do dddd ddd dd', '0 0. nedeľa ne ne'],
24910 ['DDD DDDo DDDD', '45 45. 045'],
24911 ['w wo ww', '6 6. 06'],
24912 ['h hh', '3 03'],
24913 ['H HH', '15 15'],
24914 ['m mm', '25 25'],
24915 ['s ss', '50 50'],
24916 ['a A', 'pm PM'],
24917 ['DDDo [deň v roku]', '45. deň v roku'],
24918 ['LTS', '15:25:50'],
24919 ['L', '14.02.2010'],
24920 ['LL', '14. február 2010'],
24921 ['LLL', '14. február 2010 15:25'],
24922 ['LLLL', 'nedeľa 14. február 2010 15:25'],
24923 ['l', '14.2.2010'],
24924 ['ll', '14. feb 2010'],
24925 ['lll', '14. feb 2010 15:25'],
24926 ['llll', 'ne 14. feb 2010 15:25']
24927 ],
24928 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
24929 i;
24930 for (i = 0; i < a.length; i++) {
24931 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
24932 }
24933 });
24934
24935 test('format ordinal', function (assert) {
24936 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
24937 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
24938 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
24939 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
24940 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
24941 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
24942 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
24943 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
24944 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
24945 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
24946
24947 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
24948 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
24949 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
24950 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
24951 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
24952 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
24953 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
24954 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
24955 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
24956 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
24957
24958 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
24959 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
24960 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
24961 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
24962 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
24963 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
24964 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
24965 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
24966 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
24967 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
24968
24969 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
24970 });
24971
24972 test('format month', function (assert) {
24973 var expected = 'január jan_február feb_marec mar_apríl apr_máj máj_jún jún_júl júl_august aug_september sep_október okt_november nov_december dec'.split('_'), i;
24974 for (i = 0; i < expected.length; i++) {
24975 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
24976 }
24977 });
24978
24979 test('format week', function (assert) {
24980 var expected = 'nedeľa ne ne_pondelok po po_utorok ut ut_streda st st_štvrtok št št_piatok pi pi_sobota so so'.split('_'), i;
24981 for (i = 0; i < expected.length; i++) {
24982 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
24983 }
24984 });
24985
24986 test('from', function (assert) {
24987 var start = moment([2007, 1, 28]);
24988 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'pár sekúnd', '44 seconds = a few seconds');
24989 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minúta', '45 seconds = a minute');
24990 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minúta', '89 seconds = a minute');
24991 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minúty', '90 seconds = 2 minutes');
24992 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minút', '44 minutes = 44 minutes');
24993 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'hodina', '45 minutes = an hour');
24994 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'hodina', '89 minutes = an hour');
24995 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hodiny', '90 minutes = 2 hours');
24996 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hodín', '5 hours = 5 hours');
24997 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hodín', '21 hours = 21 hours');
24998 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'deň', '22 hours = a day');
24999 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'deň', '35 hours = a day');
25000 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dni', '36 hours = 2 days');
25001 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'deň', '1 day = a day');
25002 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dní', '5 days = 5 days');
25003 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dní', '25 days = 25 days');
25004 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mesiac', '26 days = a month');
25005 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mesiac', '30 days = a month');
25006 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mesiac', '43 days = a month');
25007 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesiace', '46 days = 2 months');
25008 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesiace', '75 days = 2 months');
25009 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesiace', '76 days = 3 months');
25010 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mesiac', '1 month = a month');
25011 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesiacov', '5 months = 5 months');
25012 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'rok', '345 days = a year');
25013 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 roky', '548 days = 2 years');
25014 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'rok', '1 year = a year');
25015 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 rokov', '5 years = 5 years');
25016 });
25017
25018 test('suffix', function (assert) {
25019 assert.equal(moment(30000).from(0), 'za pár sekúnd', 'prefix');
25020 assert.equal(moment(0).from(30000), 'pred pár sekundami', 'suffix');
25021 });
25022
25023 test('now from now', function (assert) {
25024 assert.equal(moment().fromNow(), 'pred pár sekundami', 'now from now should display as in the past');
25025 });
25026
25027 test('fromNow (future)', function (assert) {
25028 assert.equal(moment().add({s: 30}).fromNow(), 'za pár sekúnd', 'in a few seconds');
25029 assert.equal(moment().add({m: 1}).fromNow(), 'za minútu', 'in a minute');
25030 assert.equal(moment().add({m: 3}).fromNow(), 'za 3 minúty', 'in 3 minutes');
25031 assert.equal(moment().add({m: 10}).fromNow(), 'za 10 minút', 'in 10 minutes');
25032 assert.equal(moment().add({h: 1}).fromNow(), 'za hodinu', 'in an hour');
25033 assert.equal(moment().add({h: 3}).fromNow(), 'za 3 hodiny', 'in 3 hours');
25034 assert.equal(moment().add({h: 10}).fromNow(), 'za 10 hodín', 'in 10 hours');
25035 assert.equal(moment().add({d: 1}).fromNow(), 'za deň', 'in a day');
25036 assert.equal(moment().add({d: 3}).fromNow(), 'za 3 dni', 'in 3 days');
25037 assert.equal(moment().add({d: 10}).fromNow(), 'za 10 dní', 'in 10 days');
25038 assert.equal(moment().add({M: 1}).fromNow(), 'za mesiac', 'in a month');
25039 assert.equal(moment().add({M: 3}).fromNow(), 'za 3 mesiace', 'in 3 months');
25040 assert.equal(moment().add({M: 10}).fromNow(), 'za 10 mesiacov', 'in 10 months');
25041 assert.equal(moment().add({y: 1}).fromNow(), 'za rok', 'in a year');
25042 assert.equal(moment().add({y: 3}).fromNow(), 'za 3 roky', 'in 3 years');
25043 assert.equal(moment().add({y: 10}).fromNow(), 'za 10 rokov', 'in 10 years');
25044 });
25045
25046 test('fromNow (past)', function (assert) {
25047 assert.equal(moment().subtract({s: 30}).fromNow(), 'pred pár sekundami', 'a few seconds ago');
25048 assert.equal(moment().subtract({m: 1}).fromNow(), 'pred minútou', 'a minute ago');
25049 assert.equal(moment().subtract({m: 3}).fromNow(), 'pred 3 minútami', '3 minutes ago');
25050 assert.equal(moment().subtract({m: 10}).fromNow(), 'pred 10 minútami', '10 minutes ago');
25051 assert.equal(moment().subtract({h: 1}).fromNow(), 'pred hodinou', 'an hour ago');
25052 assert.equal(moment().subtract({h: 3}).fromNow(), 'pred 3 hodinami', '3 hours ago');
25053 assert.equal(moment().subtract({h: 10}).fromNow(), 'pred 10 hodinami', '10 hours ago');
25054 assert.equal(moment().subtract({d: 1}).fromNow(), 'pred dňom', 'a day ago');
25055 assert.equal(moment().subtract({d: 3}).fromNow(), 'pred 3 dňami', '3 days ago');
25056 assert.equal(moment().subtract({d: 10}).fromNow(), 'pred 10 dňami', '10 days ago');
25057 assert.equal(moment().subtract({M: 1}).fromNow(), 'pred mesiacom', 'a month ago');
25058 assert.equal(moment().subtract({M: 3}).fromNow(), 'pred 3 mesiacmi', '3 months ago');
25059 assert.equal(moment().subtract({M: 10}).fromNow(), 'pred 10 mesiacmi', '10 months ago');
25060 assert.equal(moment().subtract({y: 1}).fromNow(), 'pred rokom', 'a year ago');
25061 assert.equal(moment().subtract({y: 3}).fromNow(), 'pred 3 rokmi', '3 years ago');
25062 assert.equal(moment().subtract({y: 10}).fromNow(), 'pred 10 rokmi', '10 years ago');
25063 });
25064
25065 test('calendar day', function (assert) {
25066 var a = moment().hours(2).minutes(0).seconds(0);
25067
25068 assert.equal(moment(a).calendar(), 'dnes o 2:00', 'today at the same time');
25069 assert.equal(moment(a).add({m: 25}).calendar(), 'dnes o 2:25', 'Now plus 25 min');
25070 assert.equal(moment(a).add({h: 1}).calendar(), 'dnes o 3:00', 'Now plus 1 hour');
25071 assert.equal(moment(a).add({d: 1}).calendar(), 'zajtra o 2:00', 'tomorrow at the same time');
25072 assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes o 1:00', 'Now minus 1 hour');
25073 assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera o 2:00', 'yesterday at the same time');
25074 });
25075
25076 test('calendar next week', function (assert) {
25077 var i, m, nextDay;
25078 for (i = 2; i < 7; i++) {
25079 m = moment().add({d: i});
25080 nextDay = '';
25081 switch (m.day()) {
25082 case 0:
25083 nextDay = 'v nedeľu';
25084 break;
25085 case 1:
25086 nextDay = 'v pondelok';
25087 break;
25088 case 2:
25089 nextDay = 'v utorok';
25090 break;
25091 case 3:
25092 nextDay = 'v stredu';
25093 break;
25094 case 4:
25095 nextDay = 'vo štvrtok';
25096 break;
25097 case 5:
25098 nextDay = 'v piatok';
25099 break;
25100 case 6:
25101 nextDay = 'v sobotu';
25102 break;
25103 }
25104 assert.equal(m.calendar(), m.format('[' + nextDay + '] [o] LT'), 'Today + ' + i + ' days current time');
25105 m.hours(0).minutes(0).seconds(0).milliseconds(0);
25106 assert.equal(m.calendar(), m.format('[' + nextDay + '] [o] LT'), 'Today + ' + i + ' days beginning of day');
25107 m.hours(23).minutes(59).seconds(59).milliseconds(999);
25108 assert.equal(m.calendar(), m.format('[' + nextDay + '] [o] LT'), 'Today + ' + i + ' days end of day');
25109 }
25110 });
25111
25112 test('calendar last week', function (assert) {
25113 var i, m, lastDay;
25114 for (i = 2; i < 7; i++) {
25115 m = moment().subtract({d: i});
25116 lastDay = '';
25117 switch (m.day()) {
25118 case 0:
25119 lastDay = 'minulú nedeľu';
25120 break;
25121 case 1:
25122 lastDay = 'minulý pondelok';
25123 break;
25124 case 2:
25125 lastDay = 'minulý utorok';
25126 break;
25127 case 3:
25128 lastDay = 'minulú stredu';
25129 break;
25130 case 4:
25131 lastDay = 'minulý štvrtok';
25132 break;
25133 case 5:
25134 lastDay = 'minulý piatok';
25135 break;
25136 case 6:
25137 lastDay = 'minulú sobotu';
25138 break;
25139 }
25140 assert.equal(m.calendar(), m.format('[' + lastDay + '] [o] LT'), 'Today - ' + i + ' days current time');
25141 m.hours(0).minutes(0).seconds(0).milliseconds(0);
25142 assert.equal(m.calendar(), m.format('[' + lastDay + '] [o] LT'), 'Today - ' + i + ' days beginning of day');
25143 m.hours(23).minutes(59).seconds(59).milliseconds(999);
25144 assert.equal(m.calendar(), m.format('[' + lastDay + '] [o] LT'), 'Today - ' + i + ' days end of day');
25145 }
25146 });
25147
25148 test('calendar all else', function (assert) {
25149 var weeksAgo = moment().subtract({w: 1}),
25150 weeksFromNow = moment().add({w: 1});
25151
25152 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
25153 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
25154
25155 weeksAgo = moment().subtract({w: 2});
25156 weeksFromNow = moment().add({w: 2});
25157
25158 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
25159 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
25160 });
25161
25162 test('humanize duration', function (assert) {
25163 assert.equal(moment.duration(1, 'minutes').humanize(), 'minúta', 'a minute (future)');
25164 assert.equal(moment.duration(1, 'minutes').humanize(true), 'za minútu', 'in a minute');
25165 assert.equal(moment.duration(-1, 'minutes').humanize(), 'minúta', 'a minute (past)');
25166 assert.equal(moment.duration(-1, 'minutes').humanize(true), 'pred minútou', 'a minute ago');
25167 });
25168
25169 test('weeks year starting sunday', function (assert) {
25170 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
25171 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
25172 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
25173 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
25174 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
25175 });
25176
25177 test('weeks year starting monday', function (assert) {
25178 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
25179 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
25180 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
25181 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
25182 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
25183 });
25184
25185 test('weeks year starting tuesday', function (assert) {
25186 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
25187 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
25188 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
25189 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
25190 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
25191 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
25192 });
25193
25194 test('weeks year starting wednesday', function (assert) {
25195 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
25196 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
25197 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
25198 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
25199 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
25200 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
25201 });
25202
25203 test('weeks year starting thursday', function (assert) {
25204 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
25205 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
25206 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
25207 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
25208 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
25209 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
25210 });
25211
25212 test('weeks year starting friday', function (assert) {
25213 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
25214 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
25215 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
25216 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
25217 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
25218 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
25219 });
25220
25221 test('weeks year starting saturday', function (assert) {
25222 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
25223 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
25224 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
25225 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
25226 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
25227 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
25228 });
25229
25230 test('weeks year starting sunday formatted', function (assert) {
25231 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
25232 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
25233 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
25234 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
25235 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
25236 });
25237
25238 test('lenient ordinal parsing', function (assert) {
25239 var i, ordinalStr, testMoment;
25240 for (i = 1; i <= 31; ++i) {
25241 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
25242 testMoment = moment(ordinalStr, 'YYYY MM Do');
25243 assert.equal(testMoment.year(), 2014,
25244 'lenient ordinal parsing ' + i + ' year check');
25245 assert.equal(testMoment.month(), 0,
25246 'lenient ordinal parsing ' + i + ' month check');
25247 assert.equal(testMoment.date(), i,
25248 'lenient ordinal parsing ' + i + ' date check');
25249 }
25250 });
25251
25252 test('lenient ordinal parsing of number', function (assert) {
25253 var i, testMoment;
25254 for (i = 1; i <= 31; ++i) {
25255 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
25256 assert.equal(testMoment.year(), 2014,
25257 'lenient ordinal parsing of number ' + i + ' year check');
25258 assert.equal(testMoment.month(), 0,
25259 'lenient ordinal parsing of number ' + i + ' month check');
25260 assert.equal(testMoment.date(), i,
25261 'lenient ordinal parsing of number ' + i + ' date check');
25262 }
25263 });
25264
25265 test('strict ordinal parsing', function (assert) {
25266 var i, ordinalStr, testMoment;
25267 for (i = 1; i <= 31; ++i) {
25268 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
25269 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
25270 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
25271 }
25272 });
25273
25274 }));
25275
25276 (function (global, factory) {
25277 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
25278 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
25279 factory(global.moment)
25280 }(this, function (moment) { 'use strict';
25281
25282 /*global QUnit:false*/
25283
25284 var test = QUnit.test;
25285
25286 function module (name, lifecycle) {
25287 QUnit.module(name, {
25288 setup : function () {
25289 moment.locale('en');
25290 moment.createFromInputFallback = function () {
25291 throw new Error('input not handled by moment');
25292 };
25293 if (lifecycle && lifecycle.setup) {
25294 lifecycle.setup();
25295 }
25296 },
25297 teardown : function () {
25298 if (lifecycle && lifecycle.teardown) {
25299 lifecycle.teardown();
25300 }
25301 }
25302 });
25303 }
25304
25305 function localeModule (name, lifecycle) {
25306 QUnit.module('locale:' + name, {
25307 setup : function () {
25308 moment.locale(name);
25309 moment.createFromInputFallback = function () {
25310 throw new Error('input not handled by moment');
25311 };
25312 if (lifecycle && lifecycle.setup) {
25313 lifecycle.setup();
25314 }
25315 },
25316 teardown : function () {
25317 moment.locale('en');
25318 if (lifecycle && lifecycle.teardown) {
25319 lifecycle.teardown();
25320 }
25321 }
25322 });
25323 }
25324
25325 localeModule('sl');
25326
25327 test('parse', function (assert) {
25328 var tests = 'januar jan._februar feb._marec mar._april apr._maj maj_junij jun._julij jul._avgust avg._september sep._oktober okt._november nov._december dec.'.split('_'), i;
25329 function equalTest(input, mmm, i) {
25330 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
25331 }
25332 for (i = 0; i < 12; i++) {
25333 tests[i] = tests[i].split(' ');
25334 equalTest(tests[i][0], 'MMM', i);
25335 equalTest(tests[i][1], 'MMM', i);
25336 equalTest(tests[i][0], 'MMMM', i);
25337 equalTest(tests[i][1], 'MMMM', i);
25338 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
25339 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
25340 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
25341 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
25342 }
25343 });
25344
25345 test('format', function (assert) {
25346 var a = [
25347 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedelja, 14. februar 2010, 3:25:50 pm'],
25348 ['ddd, hA', 'ned., 3PM'],
25349 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
25350 ['YYYY YY', '2010 10'],
25351 ['D Do DD', '14 14. 14'],
25352 ['d do dddd ddd dd', '0 0. nedelja ned. ne'],
25353 ['DDD DDDo DDDD', '45 45. 045'],
25354 ['w wo ww', '7 7. 07'],
25355 ['h hh', '3 03'],
25356 ['H HH', '15 15'],
25357 ['m mm', '25 25'],
25358 ['s ss', '50 50'],
25359 ['a A', 'pm PM'],
25360 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
25361 ['LTS', '15:25:50'],
25362 ['L', '14. 02. 2010'],
25363 ['LL', '14. februar 2010'],
25364 ['LLL', '14. februar 2010 15:25'],
25365 ['LLLL', 'nedelja, 14. februar 2010 15:25'],
25366 ['l', '14. 2. 2010'],
25367 ['ll', '14. feb. 2010'],
25368 ['lll', '14. feb. 2010 15:25'],
25369 ['llll', 'ned., 14. feb. 2010 15:25']
25370 ],
25371 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
25372 i;
25373 for (i = 0; i < a.length; i++) {
25374 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
25375 }
25376 });
25377
25378 test('format ordinal', function (assert) {
25379 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
25380 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
25381 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
25382 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
25383 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
25384 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
25385 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
25386 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
25387 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
25388 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
25389
25390 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
25391 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
25392 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
25393 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
25394 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
25395 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
25396 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
25397 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
25398 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
25399 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
25400
25401 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
25402 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
25403 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
25404 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
25405 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
25406 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
25407 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
25408 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
25409 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
25410 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
25411
25412 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
25413 });
25414
25415 test('format month', function (assert) {
25416 var expected = 'januar jan._februar feb._marec mar._april apr._maj maj._junij jun._julij jul._avgust avg._september sep._oktober okt._november nov._december dec.'.split('_'), i;
25417 for (i = 0; i < expected.length; i++) {
25418 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
25419 }
25420 });
25421
25422 test('format week', function (assert) {
25423 var expected = 'nedelja ned. ne_ponedeljek pon. po_torek tor. to_sreda sre. sr_četrtek čet. če_petek pet. pe_sobota sob. so'.split('_'), i;
25424 for (i = 0; i < expected.length; i++) {
25425 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
25426 }
25427 });
25428
25429 test('from', function (assert) {
25430 var start = moment([2007, 1, 28]);
25431 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nekaj sekund', '44 seconds = a few seconds');
25432 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ena minuta', '45 seconds = a minute');
25433 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ena minuta', '89 seconds = a minute');
25434 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuti', '90 seconds = 2 minutes');
25435 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minut', '44 minutes = 44 minutes');
25436 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ena ura', '45 minutes = an hour');
25437 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ena ura', '89 minutes = an hour');
25438 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 uri', '90 minutes = 2 hours');
25439 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ur', '5 hours = 5 hours');
25440 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ur', '21 hours = 21 hours');
25441 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dan', '22 hours = a day');
25442 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dan', '35 hours = a day');
25443 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dni', '36 hours = 2 days');
25444 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dan', '1 day = a day');
25445 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dni', '5 days = 5 days');
25446 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dni', '25 days = 25 days');
25447 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en mesec', '26 days = a month');
25448 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en mesec', '30 days = a month');
25449 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en mesec', '43 days = a month');
25450 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meseca', '46 days = 2 months');
25451 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meseca', '75 days = 2 months');
25452 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesece', '76 days = 3 months');
25453 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en mesec', '1 month = a month');
25454 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesecev', '5 months = 5 months');
25455 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'eno leto', '345 days = a year');
25456 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 leti', '548 days = 2 years');
25457 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eno leto', '1 year = a year');
25458 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 let', '5 years = 5 years');
25459
25460 assert.equal(start.from(moment([2007, 1, 28]).add({m: 1}), true), 'ena minuta', 'a minute');
25461 assert.equal(start.from(moment([2007, 1, 28]).add({m: 2}), true), '2 minuti', '2 minutes');
25462 assert.equal(start.from(moment([2007, 1, 28]).add({m: 3}), true), '3 minute', '3 minutes');
25463 assert.equal(start.from(moment([2007, 1, 28]).add({m: 4}), true), '4 minute', '4 minutes');
25464 assert.equal(start.from(moment([2007, 1, 28]).add({m: 5}), true), '5 minut', '5 minutes');
25465
25466 assert.equal(start.from(moment([2007, 1, 28]).add({h: 1}), true), 'ena ura', 'an hour');
25467 assert.equal(start.from(moment([2007, 1, 28]).add({h: 2}), true), '2 uri', '2 hours');
25468 assert.equal(start.from(moment([2007, 1, 28]).add({h: 3}), true), '3 ure', '3 hours');
25469 assert.equal(start.from(moment([2007, 1, 28]).add({h: 4}), true), '4 ure', '4 hours');
25470 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ur', '5 hours');
25471
25472 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dan', 'a day');
25473 assert.equal(start.from(moment([2007, 1, 28]).add({d: 2}), true), '2 dni', '2 days');
25474 assert.equal(start.from(moment([2007, 1, 28]).add({d: 3}), true), '3 dni', '3 days');
25475 assert.equal(start.from(moment([2007, 1, 28]).add({d: 4}), true), '4 dni', '4 days');
25476 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dni', '5 days');
25477
25478 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en mesec', 'a month');
25479 assert.equal(start.from(moment([2007, 1, 28]).add({M: 2}), true), '2 meseca', '2 months');
25480 assert.equal(start.from(moment([2007, 1, 28]).add({M: 3}), true), '3 mesece', '3 months');
25481 assert.equal(start.from(moment([2007, 1, 28]).add({M: 4}), true), '4 mesece', '4 months');
25482 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesecev', '5 months');
25483
25484 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eno leto', 'a year');
25485 assert.equal(start.from(moment([2007, 1, 28]).add({y: 2}), true), '2 leti', '2 years');
25486 assert.equal(start.from(moment([2007, 1, 28]).add({y: 3}), true), '3 leta', '3 years');
25487 assert.equal(start.from(moment([2007, 1, 28]).add({y: 4}), true), '4 leta', '4 years');
25488 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 let', '5 years');
25489 });
25490
25491 test('suffix', function (assert) {
25492 assert.equal(moment(30000).from(0), 'čez nekaj sekund', 'prefix');
25493 assert.equal(moment(0).from(30000), 'pred nekaj sekundami', 'suffix');
25494 });
25495
25496 test('now from now', function (assert) {
25497 assert.equal(moment().fromNow(), 'pred nekaj sekundami', 'now from now should display as in the past');
25498 });
25499
25500 test('fromNow (future)', function (assert) {
25501 assert.equal(moment().add({s: 30}).fromNow(), 'čez nekaj sekund', 'in a few seconds');
25502 assert.equal(moment().add({m: 1}).fromNow(), 'čez eno minuto', 'in a minute');
25503 assert.equal(moment().add({m: 2}).fromNow(), 'čez 2 minuti', 'in 2 minutes');
25504 assert.equal(moment().add({m: 3}).fromNow(), 'čez 3 minute', 'in 3 minutes');
25505 assert.equal(moment().add({m: 4}).fromNow(), 'čez 4 minute', 'in 4 minutes');
25506 assert.equal(moment().add({m: 5}).fromNow(), 'čez 5 minut', 'in 5 minutes');
25507
25508 assert.equal(moment().add({h: 1}).fromNow(), 'čez eno uro', 'in an hour');
25509 assert.equal(moment().add({h: 2}).fromNow(), 'čez 2 uri', 'in 2 hours');
25510 assert.equal(moment().add({h: 3}).fromNow(), 'čez 3 ure', 'in 3 hours');
25511 assert.equal(moment().add({h: 4}).fromNow(), 'čez 4 ure', 'in 4 hours');
25512 assert.equal(moment().add({h: 5}).fromNow(), 'čez 5 ur', 'in 5 hours');
25513
25514 assert.equal(moment().add({d: 1}).fromNow(), 'čez en dan', 'in a day');
25515 assert.equal(moment().add({d: 2}).fromNow(), 'čez 2 dni', 'in 2 days');
25516 assert.equal(moment().add({d: 3}).fromNow(), 'čez 3 dni', 'in 3 days');
25517 assert.equal(moment().add({d: 4}).fromNow(), 'čez 4 dni', 'in 4 days');
25518 assert.equal(moment().add({d: 5}).fromNow(), 'čez 5 dni', 'in 5 days');
25519
25520 assert.equal(moment().add({M: 1}).fromNow(), 'čez en mesec', 'in a month');
25521 assert.equal(moment().add({M: 2}).fromNow(), 'čez 2 meseca', 'in 2 months');
25522 assert.equal(moment().add({M: 3}).fromNow(), 'čez 3 mesece', 'in 3 months');
25523 assert.equal(moment().add({M: 4}).fromNow(), 'čez 4 mesece', 'in 4 months');
25524 assert.equal(moment().add({M: 5}).fromNow(), 'čez 5 mesecev', 'in 5 months');
25525
25526 assert.equal(moment().add({y: 1}).fromNow(), 'čez eno leto', 'in a year');
25527 assert.equal(moment().add({y: 2}).fromNow(), 'čez 2 leti', 'in 2 years');
25528 assert.equal(moment().add({y: 3}).fromNow(), 'čez 3 leta', 'in 3 years');
25529 assert.equal(moment().add({y: 4}).fromNow(), 'čez 4 leta', 'in 4 years');
25530 assert.equal(moment().add({y: 5}).fromNow(), 'čez 5 let', 'in 5 years');
25531
25532 assert.equal(moment().subtract({s: 30}).fromNow(), 'pred nekaj sekundami', 'a few seconds ago');
25533
25534 assert.equal(moment().subtract({m: 1}).fromNow(), 'pred eno minuto', 'a minute ago');
25535 assert.equal(moment().subtract({m: 2}).fromNow(), 'pred 2 minutama', '2 minutes ago');
25536 assert.equal(moment().subtract({m: 3}).fromNow(), 'pred 3 minutami', '3 minutes ago');
25537 assert.equal(moment().subtract({m: 4}).fromNow(), 'pred 4 minutami', '4 minutes ago');
25538 assert.equal(moment().subtract({m: 5}).fromNow(), 'pred 5 minutami', '5 minutes ago');
25539
25540 assert.equal(moment().subtract({h: 1}).fromNow(), 'pred eno uro', 'an hour ago');
25541 assert.equal(moment().subtract({h: 2}).fromNow(), 'pred 2 urama', '2 hours ago');
25542 assert.equal(moment().subtract({h: 3}).fromNow(), 'pred 3 urami', '3 hours ago');
25543 assert.equal(moment().subtract({h: 4}).fromNow(), 'pred 4 urami', '4 hours ago');
25544 assert.equal(moment().subtract({h: 5}).fromNow(), 'pred 5 urami', '5 hours ago');
25545
25546 assert.equal(moment().subtract({d: 1}).fromNow(), 'pred enim dnem', 'a day ago');
25547 assert.equal(moment().subtract({d: 2}).fromNow(), 'pred 2 dnevoma', '2 days ago');
25548 assert.equal(moment().subtract({d: 3}).fromNow(), 'pred 3 dnevi', '3 days ago');
25549 assert.equal(moment().subtract({d: 4}).fromNow(), 'pred 4 dnevi', '4 days ago');
25550 assert.equal(moment().subtract({d: 5}).fromNow(), 'pred 5 dnevi', '5 days ago');
25551
25552 assert.equal(moment().subtract({M: 1}).fromNow(), 'pred enim mesecem', 'a month ago');
25553 assert.equal(moment().subtract({M: 2}).fromNow(), 'pred 2 mesecema', '2 months ago');
25554 assert.equal(moment().subtract({M: 3}).fromNow(), 'pred 3 meseci', '3 months ago');
25555 assert.equal(moment().subtract({M: 4}).fromNow(), 'pred 4 meseci', '4 months ago');
25556 assert.equal(moment().subtract({M: 5}).fromNow(), 'pred 5 meseci', '5 months ago');
25557
25558 assert.equal(moment().subtract({y: 1}).fromNow(), 'pred enim letom', 'a year ago');
25559 assert.equal(moment().subtract({y: 2}).fromNow(), 'pred 2 letoma', '2 years ago');
25560 assert.equal(moment().subtract({y: 3}).fromNow(), 'pred 3 leti', '3 years ago');
25561 assert.equal(moment().subtract({y: 4}).fromNow(), 'pred 4 leti', '4 years ago');
25562 assert.equal(moment().subtract({y: 5}).fromNow(), 'pred 5 leti', '5 years ago');
25563 });
25564
25565 test('calendar day', function (assert) {
25566 var a = moment().hours(2).minutes(0).seconds(0);
25567
25568 assert.equal(moment(a).calendar(), 'danes ob 2:00', 'today at the same time');
25569 assert.equal(moment(a).add({m: 25}).calendar(), 'danes ob 2:25', 'Now plus 25 min');
25570 assert.equal(moment(a).add({h: 1}).calendar(), 'danes ob 3:00', 'Now plus 1 hour');
25571 assert.equal(moment(a).add({d: 1}).calendar(), 'jutri ob 2:00', 'tomorrow at the same time');
25572 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danes ob 1:00', 'Now minus 1 hour');
25573 assert.equal(moment(a).subtract({d: 1}).calendar(), 'včeraj ob 2:00', 'yesterday at the same time');
25574 });
25575
25576 test('calendar next week', function (assert) {
25577 var i, m;
25578
25579 function makeFormat(d) {
25580 switch (d.day()) {
25581 case 0:
25582 return '[v] [nedeljo] [ob] LT';
25583 case 3:
25584 return '[v] [sredo] [ob] LT';
25585 case 6:
25586 return '[v] [soboto] [ob] LT';
25587 case 1:
25588 case 2:
25589 case 4:
25590 case 5:
25591 return '[v] dddd [ob] LT';
25592 }
25593 }
25594
25595 for (i = 2; i < 7; i++) {
25596 m = moment().add({d: i});
25597 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
25598 m.hours(0).minutes(0).seconds(0).milliseconds(0);
25599 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
25600 m.hours(23).minutes(59).seconds(59).milliseconds(999);
25601 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
25602 }
25603 });
25604
25605 test('calendar last week', function (assert) {
25606 var i, m;
25607
25608 function makeFormat(d) {
25609 switch (d.day()) {
25610 case 0:
25611 return '[prejšnjo] [nedeljo] [ob] LT';
25612 case 3:
25613 return '[prejšnjo] [sredo] [ob] LT';
25614 case 6:
25615 return '[prejšnjo] [soboto] [ob] LT';
25616 case 1:
25617 case 2:
25618 case 4:
25619 case 5:
25620 return '[prejšnji] dddd [ob] LT';
25621 }
25622 }
25623
25624 for (i = 2; i < 7; i++) {
25625 m = moment().subtract({d: i});
25626 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
25627 m.hours(0).minutes(0).seconds(0).milliseconds(0);
25628 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
25629 m.hours(23).minutes(59).seconds(59).milliseconds(999);
25630 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
25631 }
25632 });
25633
25634 test('calendar all else', function (assert) {
25635 var weeksAgo = moment().subtract({w: 1}),
25636 weeksFromNow = moment().add({w: 1});
25637
25638 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
25639 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
25640
25641 weeksAgo = moment().subtract({w: 2});
25642 weeksFromNow = moment().add({w: 2});
25643
25644 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
25645 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
25646 });
25647
25648 test('weeks year starting sunday', function (assert) {
25649 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
25650 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
25651 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
25652 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
25653 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
25654 });
25655
25656 test('weeks year starting monday', function (assert) {
25657 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
25658 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
25659 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
25660 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
25661 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
25662 });
25663
25664 test('weeks year starting tuesday', function (assert) {
25665 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
25666 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
25667 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
25668 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
25669 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
25670 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
25671 });
25672
25673 test('weeks year starting wednesday', function (assert) {
25674 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
25675 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
25676 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
25677 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
25678 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
25679 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
25680 });
25681
25682 test('weeks year starting thursday', function (assert) {
25683 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
25684 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
25685 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
25686 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
25687 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
25688 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
25689 });
25690
25691 test('weeks year starting friday', function (assert) {
25692 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
25693 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
25694 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
25695 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
25696 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
25697 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
25698 });
25699
25700 test('weeks year starting saturday', function (assert) {
25701 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
25702 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
25703 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
25704 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
25705 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
25706 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
25707 });
25708
25709 test('weeks year starting sunday formatted', function (assert) {
25710 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
25711 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
25712 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
25713 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
25714 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
25715 });
25716
25717 test('lenient ordinal parsing', function (assert) {
25718 var i, ordinalStr, testMoment;
25719 for (i = 1; i <= 31; ++i) {
25720 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
25721 testMoment = moment(ordinalStr, 'YYYY MM Do');
25722 assert.equal(testMoment.year(), 2014,
25723 'lenient ordinal parsing ' + i + ' year check');
25724 assert.equal(testMoment.month(), 0,
25725 'lenient ordinal parsing ' + i + ' month check');
25726 assert.equal(testMoment.date(), i,
25727 'lenient ordinal parsing ' + i + ' date check');
25728 }
25729 });
25730
25731 test('lenient ordinal parsing of number', function (assert) {
25732 var i, testMoment;
25733 for (i = 1; i <= 31; ++i) {
25734 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
25735 assert.equal(testMoment.year(), 2014,
25736 'lenient ordinal parsing of number ' + i + ' year check');
25737 assert.equal(testMoment.month(), 0,
25738 'lenient ordinal parsing of number ' + i + ' month check');
25739 assert.equal(testMoment.date(), i,
25740 'lenient ordinal parsing of number ' + i + ' date check');
25741 }
25742 });
25743
25744 test('strict ordinal parsing', function (assert) {
25745 var i, ordinalStr, testMoment;
25746 for (i = 1; i <= 31; ++i) {
25747 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
25748 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
25749 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
25750 }
25751 });
25752
25753 }));
25754
25755 (function (global, factory) {
25756 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
25757 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
25758 factory(global.moment)
25759 }(this, function (moment) { 'use strict';
25760
25761 /*global QUnit:false*/
25762
25763 var test = QUnit.test;
25764
25765 function module (name, lifecycle) {
25766 QUnit.module(name, {
25767 setup : function () {
25768 moment.locale('en');
25769 moment.createFromInputFallback = function () {
25770 throw new Error('input not handled by moment');
25771 };
25772 if (lifecycle && lifecycle.setup) {
25773 lifecycle.setup();
25774 }
25775 },
25776 teardown : function () {
25777 if (lifecycle && lifecycle.teardown) {
25778 lifecycle.teardown();
25779 }
25780 }
25781 });
25782 }
25783
25784 function localeModule (name, lifecycle) {
25785 QUnit.module('locale:' + name, {
25786 setup : function () {
25787 moment.locale(name);
25788 moment.createFromInputFallback = function () {
25789 throw new Error('input not handled by moment');
25790 };
25791 if (lifecycle && lifecycle.setup) {
25792 lifecycle.setup();
25793 }
25794 },
25795 teardown : function () {
25796 moment.locale('en');
25797 if (lifecycle && lifecycle.teardown) {
25798 lifecycle.teardown();
25799 }
25800 }
25801 });
25802 }
25803
25804 localeModule('sq');
25805
25806 test('parse', function (assert) {
25807 var i,
25808 tests = 'Janar Jan_Shkurt Shk_Mars Mar_Prill Pri_Maj Maj_Qershor Qer_Korrik Kor_Gusht Gus_Shtator Sht_Tetor Tet_Nëntor Nën_Dhjetor Dhj'.split('_');
25809
25810 function equalTest(input, mmm, i) {
25811 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
25812 }
25813
25814 for (i = 0; i < 12; i++) {
25815 tests[i] = tests[i].split(' ');
25816 equalTest(tests[i][0], 'MMM', i);
25817 equalTest(tests[i][1], 'MMM', i);
25818 equalTest(tests[i][0], 'MMMM', i);
25819 equalTest(tests[i][1], 'MMMM', i);
25820 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
25821 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
25822 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
25823 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
25824 }
25825 });
25826
25827 test('format', function (assert) {
25828 var a = [
25829 ['dddd, MMMM Do YYYY, HH:mm:ss', 'E Diel, Shkurt 14. 2010, 15:25:50'],
25830 ['ddd, HH', 'Die, 15'],
25831 ['M Mo MM MMMM MMM', '2 2. 02 Shkurt Shk'],
25832 ['YYYY YY', '2010 10'],
25833 ['D Do DD', '14 14. 14'],
25834 ['d do dddd ddd dd', '0 0. E Diel Die D'],
25835 ['DDD DDDo DDDD', '45 45. 045'],
25836 ['w wo ww', '6 6. 06'],
25837 ['h hh', '3 03'],
25838 ['H HH', '15 15'],
25839 ['m mm', '25 25'],
25840 ['s ss', '50 50'],
25841 ['a A', 'MD MD'],
25842 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
25843 ['LTS', '15:25:50'],
25844 ['L', '14/02/2010'],
25845 ['LL', '14 Shkurt 2010'],
25846 ['LLL', '14 Shkurt 2010 15:25'],
25847 ['LLLL', 'E Diel, 14 Shkurt 2010 15:25'],
25848 ['l', '14/2/2010'],
25849 ['ll', '14 Shk 2010'],
25850 ['lll', '14 Shk 2010 15:25'],
25851 ['llll', 'Die, 14 Shk 2010 15:25']
25852 ],
25853 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
25854 i;
25855
25856 for (i = 0; i < a.length; i++) {
25857 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
25858 }
25859 });
25860
25861 test('meridiem', function (assert) {
25862 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), 'PD', 'before dawn');
25863 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), 'MD', 'noon');
25864 });
25865
25866 test('format ordinal', function (assert) {
25867 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
25868 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
25869 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
25870 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
25871 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
25872 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
25873 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
25874 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
25875 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
25876 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
25877
25878 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
25879 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
25880 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
25881 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
25882 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
25883 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
25884 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
25885 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
25886 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
25887 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
25888
25889 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
25890 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
25891 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
25892 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
25893 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
25894 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
25895 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
25896 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
25897 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
25898 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
25899
25900 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
25901 });
25902
25903 test('format month', function (assert) {
25904 var i,
25905 expected = 'Janar Jan_Shkurt Shk_Mars Mar_Prill Pri_Maj Maj_Qershor Qer_Korrik Kor_Gusht Gus_Shtator Sht_Tetor Tet_Nëntor Nën_Dhjetor Dhj'.split('_');
25906
25907 for (i = 0; i < expected.length; i++) {
25908 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
25909 }
25910 });
25911
25912 test('format week', function (assert) {
25913 var i,
25914 expected = 'E Diel Die D_E Hënë Hën H_E Martë Mar Ma_E Mërkurë Mër Më_E Enjte Enj E_E Premte Pre P_E Shtunë Sht Sh'.split('_');
25915
25916 for (i = 0; i < expected.length; i++) {
25917 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
25918 }
25919 });
25920
25921 test('from', function (assert) {
25922 var start = moment([2007, 1, 28]);
25923
25924 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'disa sekonda', '44 seconds = a few seconds');
25925 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'një minutë', '45 seconds = a minute');
25926 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'një minutë', '89 seconds = a minute');
25927 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuta', '90 seconds = 2 minutes');
25928 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
25929 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'një orë', '45 minutes = an hour');
25930 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'një orë', '89 minutes = an hour');
25931 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 orë', '90 minutes = 2 hours');
25932 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 orë', '5 hours = 5 hours');
25933 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 orë', '21 hours = 21 hours');
25934 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'një ditë', '22 hours = a day');
25935 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'një ditë', '35 hours = a day');
25936 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ditë', '36 hours = 2 days');
25937 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'një ditë', '1 day = a day');
25938 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ditë', '5 days = 5 days');
25939 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ditë', '25 days = 25 days');
25940 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'një muaj', '26 days = a month');
25941 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'një muaj', '30 days = a month');
25942 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'një muaj', '43 days = a month');
25943 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 muaj', '46 days = 2 months');
25944 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 muaj', '75 days = 2 months');
25945 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 muaj', '76 days = 3 months');
25946 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'një muaj', '1 month = a month');
25947 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 muaj', '5 months = 5 months');
25948 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'një vit', '345 days = a year');
25949 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 vite', '548 days = 2 years');
25950 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'një vit', '1 year = a year');
25951 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 vite', '5 years = 5 years');
25952 });
25953
25954 test('suffix', function (assert) {
25955 assert.equal(moment(30000).from(0), 'në disa sekonda', 'prefix');
25956 assert.equal(moment(0).from(30000), 'disa sekonda më parë', 'suffix');
25957 });
25958
25959 test('now from now', function (assert) {
25960 assert.equal(moment().fromNow(), 'disa sekonda më parë', 'now from now should display as in the past');
25961 });
25962
25963 test('fromNow', function (assert) {
25964 assert.equal(moment().add({s: 30}).fromNow(), 'në disa sekonda', 'in a few seconds');
25965 assert.equal(moment().add({d: 5}).fromNow(), 'në 5 ditë', 'in 5 days');
25966 });
25967
25968 test('calendar day', function (assert) {
25969 var a = moment().hours(2).minutes(0).seconds(0);
25970
25971 assert.equal(moment(a).calendar(), 'Sot në 02:00', 'today at the same time');
25972 assert.equal(moment(a).add({m: 25}).calendar(), 'Sot në 02:25', 'Now plus 25 min');
25973 assert.equal(moment(a).add({h: 1}).calendar(), 'Sot në 03:00', 'Now plus 1 hour');
25974 assert.equal(moment(a).add({d: 1}).calendar(), 'Nesër në 02:00', 'tomorrow at the same time');
25975 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Sot në 01:00', 'Now minus 1 hour');
25976 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dje në 02:00', 'yesterday at the same time');
25977 });
25978
25979 test('calendar next week', function (assert) {
25980 var i, m;
25981
25982 for (i = 2; i < 7; i++) {
25983 m = moment().add({d: i});
25984 assert.equal(m.calendar(), m.format('dddd [në] LT'), 'Today + ' + i + ' days current time');
25985 m.hours(0).minutes(0).seconds(0).milliseconds(0);
25986 assert.equal(m.calendar(), m.format('dddd [në] LT'), 'Today + ' + i + ' days beginning of day');
25987 m.hours(23).minutes(59).seconds(59).milliseconds(999);
25988 assert.equal(m.calendar(), m.format('dddd [në] LT'), 'Today + ' + i + ' days end of day');
25989 }
25990 });
25991
25992 test('calendar last week', function (assert) {
25993 var i, m;
25994
25995 for (i = 2; i < 7; i++) {
25996 m = moment().subtract({d: i});
25997 assert.equal(m.calendar(), m.format('dddd [e kaluar në] LT'), 'Today - ' + i + ' days current time');
25998 m.hours(0).minutes(0).seconds(0).milliseconds(0);
25999 assert.equal(m.calendar(), m.format('dddd [e kaluar në] LT'), 'Today - ' + i + ' days beginning of day');
26000 m.hours(23).minutes(59).seconds(59).milliseconds(999);
26001 assert.equal(m.calendar(), m.format('dddd [e kaluar në] LT'), 'Today - ' + i + ' days end of day');
26002 }
26003 });
26004
26005 test('calendar all else', function (assert) {
26006 var weeksAgo = moment().subtract({w: 1}),
26007 weeksFromNow = moment().add({w: 1});
26008
26009 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
26010 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
26011
26012 weeksAgo = moment().subtract({w: 2});
26013 weeksFromNow = moment().add({w: 2});
26014
26015 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
26016 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
26017 });
26018
26019 test('weeks year starting sunday', function (assert) {
26020 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
26021 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
26022 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
26023 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
26024 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
26025 });
26026
26027 test('weeks year starting monday', function (assert) {
26028 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
26029 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
26030 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
26031 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
26032 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
26033 });
26034
26035 test('weeks year starting tuesday', function (assert) {
26036 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
26037 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
26038 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
26039 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
26040 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
26041 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
26042 });
26043
26044 test('weeks year starting wednesday', function (assert) {
26045 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
26046 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
26047 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
26048 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
26049 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
26050 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
26051 });
26052
26053 test('weeks year starting thursday', function (assert) {
26054 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
26055 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
26056 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
26057 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
26058 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
26059 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
26060 });
26061
26062 test('weeks year starting friday', function (assert) {
26063 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
26064 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
26065 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
26066 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
26067 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
26068 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
26069 });
26070
26071 test('weeks year starting saturday', function (assert) {
26072 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
26073 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
26074 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
26075 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
26076 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
26077 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
26078 });
26079
26080 test('weeks year starting sunday formatted', function (assert) {
26081 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
26082 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
26083 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
26084 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
26085 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
26086 });
26087
26088 test('lenient ordinal parsing', function (assert) {
26089 var i, ordinalStr, testMoment;
26090 for (i = 1; i <= 31; ++i) {
26091 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
26092 testMoment = moment(ordinalStr, 'YYYY MM Do');
26093 assert.equal(testMoment.year(), 2014,
26094 'lenient ordinal parsing ' + i + ' year check');
26095 assert.equal(testMoment.month(), 0,
26096 'lenient ordinal parsing ' + i + ' month check');
26097 assert.equal(testMoment.date(), i,
26098 'lenient ordinal parsing ' + i + ' date check');
26099 }
26100 });
26101
26102 test('lenient ordinal parsing of number', function (assert) {
26103 var i, testMoment;
26104 for (i = 1; i <= 31; ++i) {
26105 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
26106 assert.equal(testMoment.year(), 2014,
26107 'lenient ordinal parsing of number ' + i + ' year check');
26108 assert.equal(testMoment.month(), 0,
26109 'lenient ordinal parsing of number ' + i + ' month check');
26110 assert.equal(testMoment.date(), i,
26111 'lenient ordinal parsing of number ' + i + ' date check');
26112 }
26113 });
26114
26115 test('strict ordinal parsing', function (assert) {
26116 var i, ordinalStr, testMoment;
26117 for (i = 1; i <= 31; ++i) {
26118 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
26119 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
26120 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
26121 }
26122 });
26123
26124 }));
26125
26126 (function (global, factory) {
26127 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
26128 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
26129 factory(global.moment)
26130 }(this, function (moment) { 'use strict';
26131
26132 /*global QUnit:false*/
26133
26134 var test = QUnit.test;
26135
26136 function module (name, lifecycle) {
26137 QUnit.module(name, {
26138 setup : function () {
26139 moment.locale('en');
26140 moment.createFromInputFallback = function () {
26141 throw new Error('input not handled by moment');
26142 };
26143 if (lifecycle && lifecycle.setup) {
26144 lifecycle.setup();
26145 }
26146 },
26147 teardown : function () {
26148 if (lifecycle && lifecycle.teardown) {
26149 lifecycle.teardown();
26150 }
26151 }
26152 });
26153 }
26154
26155 function localeModule (name, lifecycle) {
26156 QUnit.module('locale:' + name, {
26157 setup : function () {
26158 moment.locale(name);
26159 moment.createFromInputFallback = function () {
26160 throw new Error('input not handled by moment');
26161 };
26162 if (lifecycle && lifecycle.setup) {
26163 lifecycle.setup();
26164 }
26165 },
26166 teardown : function () {
26167 moment.locale('en');
26168 if (lifecycle && lifecycle.teardown) {
26169 lifecycle.teardown();
26170 }
26171 }
26172 });
26173 }
26174
26175 localeModule('sr-cyrl');
26176
26177 test('parse', function (assert) {
26178 var tests = 'јануар јан._фебруар феб._март мар._април апр._мај мај_јун јун_јул јул_август авг._септембар сеп._октобар окт._новембар нов._децембар дец.'.split('_'),
26179 i;
26180 function equalTest(input, mmm, i) {
26181 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
26182 }
26183 for (i = 0; i < 12; i++) {
26184 tests[i] = tests[i].split(' ');
26185 equalTest(tests[i][0], 'MMM', i);
26186 equalTest(tests[i][1], 'MMM', i);
26187 equalTest(tests[i][0], 'MMMM', i);
26188 equalTest(tests[i][1], 'MMMM', i);
26189 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
26190 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
26191 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
26192 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
26193 }
26194 });
26195
26196 test('format', function (assert) {
26197 var a = [
26198 ['dddd, Do MMMM YYYY, h:mm:ss a', 'недеља, 14. фебруар 2010, 3:25:50 pm'],
26199 ['ddd, hA', 'нед., 3PM'],
26200 ['M Mo MM MMMM MMM', '2 2. 02 фебруар феб.'],
26201 ['YYYY YY', '2010 10'],
26202 ['D Do DD', '14 14. 14'],
26203 ['d do dddd ddd dd', '0 0. недеља нед. не'],
26204 ['DDD DDDo DDDD', '45 45. 045'],
26205 ['w wo ww', '7 7. 07'],
26206 ['h hh', '3 03'],
26207 ['H HH', '15 15'],
26208 ['m mm', '25 25'],
26209 ['s ss', '50 50'],
26210 ['a A', 'pm PM'],
26211 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
26212 ['LTS', '15:25:50'],
26213 ['L', '14. 02. 2010'],
26214 ['LL', '14. фебруар 2010'],
26215 ['LLL', '14. фебруар 2010 15:25'],
26216 ['LLLL', 'недеља, 14. фебруар 2010 15:25'],
26217 ['l', '14. 2. 2010'],
26218 ['ll', '14. феб. 2010'],
26219 ['lll', '14. феб. 2010 15:25'],
26220 ['llll', 'нед., 14. феб. 2010 15:25']
26221 ],
26222 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
26223 i;
26224 for (i = 0; i < a.length; i++) {
26225 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
26226 }
26227 });
26228
26229 test('format ordinal', function (assert) {
26230 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
26231 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
26232 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
26233 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
26234 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
26235 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
26236 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
26237 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
26238 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
26239 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
26240
26241 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
26242 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
26243 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
26244 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
26245 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
26246 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
26247 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
26248 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
26249 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
26250 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
26251
26252 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
26253 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
26254 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
26255 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
26256 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
26257 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
26258 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
26259 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
26260 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
26261 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
26262
26263 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
26264 });
26265
26266 test('format month', function (assert) {
26267 var expected = 'јануар јан._фебруар феб._март мар._април апр._мај мај_јун јун_јул јул_август авг._септембар сеп._октобар окт._новембар нов._децембар дец.'.split('_'),
26268 i;
26269 for (i = 0; i < expected.length; i++) {
26270 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
26271 }
26272 });
26273
26274 test('format week', function (assert) {
26275 var expected = 'недеља нед. не_понедељак пон. по_уторак уто. ут_среда сре. ср_четвртак чет. че_петак пет. пе_субота суб. су'.split('_'),
26276 i;
26277 for (i = 0; i < expected.length; i++) {
26278 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
26279 }
26280 });
26281
26282 test('from', function (assert) {
26283 var start = moment([2007, 1, 28]);
26284 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'неколико секунди', '44 seconds = a few seconds');
26285 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'један минут', '45 seconds = a minute');
26286 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'један минут', '89 seconds = a minute');
26287 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минуте', '90 seconds = 2 minutes');
26288 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минута', '44 minutes = 44 minutes');
26289 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'један сат', '45 minutes = an hour');
26290 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'један сат', '89 minutes = an hour');
26291 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 сата', '90 minutes = 2 hours');
26292 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 сати', '5 hours = 5 hours');
26293 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 сати', '21 hours = 21 hours');
26294 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'дан', '22 hours = a day');
26295 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'дан', '35 hours = a day');
26296 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дана', '36 hours = 2 days');
26297 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'дан', '1 day = a day');
26298 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дана', '5 days = 5 days');
26299 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дана', '25 days = 25 days');
26300 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месец', '26 days = a month');
26301 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месец', '30 days = a month');
26302 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месец', '43 days = a month');
26303 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месеца', '46 days = 2 months');
26304 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месеца', '75 days = 2 months');
26305 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месеца', '76 days = 3 months');
26306 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месец', '1 month = a month');
26307 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месеци', '5 months = 5 months');
26308 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'годину', '345 days = a year');
26309 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 године', '548 days = 2 years');
26310 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'годину', '1 year = a year');
26311 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 година', '5 years = 5 years');
26312 });
26313
26314 test('suffix', function (assert) {
26315 assert.equal(moment(30000).from(0), 'за неколико секунди', 'prefix');
26316 assert.equal(moment(0).from(30000), 'пре неколико секунди', 'prefix');
26317 });
26318
26319 test('now from now', function (assert) {
26320 assert.equal(moment().fromNow(), 'пре неколико секунди', 'now from now should display as in the past');
26321 });
26322
26323 test('fromNow', function (assert) {
26324 assert.equal(moment().add({s: 30}).fromNow(), 'за неколико секунди', 'in a few seconds');
26325 assert.equal(moment().add({d: 5}).fromNow(), 'за 5 дана', 'in 5 days');
26326 });
26327
26328 test('calendar day', function (assert) {
26329 var a = moment().hours(2).minutes(0).seconds(0);
26330
26331 assert.equal(moment(a).calendar(), 'данас у 2:00', 'today at the same time');
26332 assert.equal(moment(a).add({m: 25}).calendar(), 'данас у 2:25', 'Now plus 25 min');
26333 assert.equal(moment(a).add({h: 1}).calendar(), 'данас у 3:00', 'Now plus 1 hour');
26334 assert.equal(moment(a).add({d: 1}).calendar(), 'сутра у 2:00', 'tomorrow at the same time');
26335 assert.equal(moment(a).subtract({h: 1}).calendar(), 'данас у 1:00', 'Now minus 1 hour');
26336 assert.equal(moment(a).subtract({d: 1}).calendar(), 'јуче у 2:00', 'yesterday at the same time');
26337 });
26338
26339 test('calendar next week', function (assert) {
26340 var i, m;
26341
26342 function makeFormat(d) {
26343 switch (d.day()) {
26344 case 0:
26345 return '[у] [недељу] [у] LT';
26346 case 3:
26347 return '[у] [среду] [у] LT';
26348 case 6:
26349 return '[у] [суботу] [у] LT';
26350 case 1:
26351 case 2:
26352 case 4:
26353 case 5:
26354 return '[у] dddd [у] LT';
26355 }
26356 }
26357
26358 for (i = 2; i < 7; i++) {
26359 m = moment().add({d: i});
26360 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
26361 m.hours(0).minutes(0).seconds(0).milliseconds(0);
26362 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
26363 m.hours(23).minutes(59).seconds(59).milliseconds(999);
26364 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
26365 }
26366 });
26367
26368 test('calendar last week', function (assert) {
26369 var i, m;
26370
26371 function makeFormat(d) {
26372 var lastWeekDay = [
26373 '[прошле] [недеље] [у] LT',
26374 '[прошлог] [понедељка] [у] LT',
26375 '[прошлог] [уторка] [у] LT',
26376 '[прошле] [среде] [у] LT',
26377 '[прошлог] [четвртка] [у] LT',
26378 '[прошлог] [петка] [у] LT',
26379 '[прошле] [суботе] [у] LT'
26380 ];
26381
26382 return lastWeekDay[d.day()];
26383 }
26384
26385 for (i = 2; i < 7; i++) {
26386 m = moment().subtract({d: i});
26387 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
26388 m.hours(0).minutes(0).seconds(0).milliseconds(0);
26389 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
26390 m.hours(23).minutes(59).seconds(59).milliseconds(999);
26391 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
26392 }
26393 });
26394
26395 test('calendar all else', function (assert) {
26396 var weeksAgo = moment().subtract({w: 1}),
26397 weeksFromNow = moment().add({w: 1});
26398
26399 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
26400 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
26401
26402 weeksAgo = moment().subtract({w: 2});
26403 weeksFromNow = moment().add({w: 2});
26404
26405 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
26406 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
26407 });
26408
26409 test('weeks year starting sunday', function (assert) {
26410 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
26411 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
26412 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
26413 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
26414 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
26415 });
26416
26417 test('weeks year starting monday', function (assert) {
26418 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
26419 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
26420 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
26421 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
26422 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
26423 });
26424
26425 test('weeks year starting tuesday', function (assert) {
26426 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
26427 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
26428 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
26429 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
26430 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
26431 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
26432 });
26433
26434 test('weeks year starting wednesday', function (assert) {
26435 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
26436 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
26437 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
26438 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
26439 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
26440 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
26441 });
26442
26443 test('weeks year starting thursday', function (assert) {
26444 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
26445 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
26446 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
26447 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
26448 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
26449 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
26450 });
26451
26452 test('weeks year starting friday', function (assert) {
26453 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
26454 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
26455 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
26456 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
26457 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
26458 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
26459 });
26460
26461 test('weeks year starting saturday', function (assert) {
26462 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
26463 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
26464 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
26465 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
26466 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
26467 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
26468 });
26469
26470 test('weeks year starting sunday formatted', function (assert) {
26471 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
26472 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
26473 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
26474 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
26475 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
26476 });
26477
26478 test('lenient ordinal parsing', function (assert) {
26479 var i, ordinalStr, testMoment;
26480 for (i = 1; i <= 31; ++i) {
26481 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
26482 testMoment = moment(ordinalStr, 'YYYY MM Do');
26483 assert.equal(testMoment.year(), 2014,
26484 'lenient ordinal parsing ' + i + ' year check');
26485 assert.equal(testMoment.month(), 0,
26486 'lenient ordinal parsing ' + i + ' month check');
26487 assert.equal(testMoment.date(), i,
26488 'lenient ordinal parsing ' + i + ' date check');
26489 }
26490 });
26491
26492 test('lenient ordinal parsing of number', function (assert) {
26493 var i, testMoment;
26494 for (i = 1; i <= 31; ++i) {
26495 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
26496 assert.equal(testMoment.year(), 2014,
26497 'lenient ordinal parsing of number ' + i + ' year check');
26498 assert.equal(testMoment.month(), 0,
26499 'lenient ordinal parsing of number ' + i + ' month check');
26500 assert.equal(testMoment.date(), i,
26501 'lenient ordinal parsing of number ' + i + ' date check');
26502 }
26503 });
26504
26505 test('strict ordinal parsing', function (assert) {
26506 var i, ordinalStr, testMoment;
26507 for (i = 1; i <= 31; ++i) {
26508 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
26509 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
26510 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
26511 }
26512 });
26513
26514 }));
26515
26516 (function (global, factory) {
26517 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
26518 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
26519 factory(global.moment)
26520 }(this, function (moment) { 'use strict';
26521
26522 /*global QUnit:false*/
26523
26524 var test = QUnit.test;
26525
26526 function module (name, lifecycle) {
26527 QUnit.module(name, {
26528 setup : function () {
26529 moment.locale('en');
26530 moment.createFromInputFallback = function () {
26531 throw new Error('input not handled by moment');
26532 };
26533 if (lifecycle && lifecycle.setup) {
26534 lifecycle.setup();
26535 }
26536 },
26537 teardown : function () {
26538 if (lifecycle && lifecycle.teardown) {
26539 lifecycle.teardown();
26540 }
26541 }
26542 });
26543 }
26544
26545 function localeModule (name, lifecycle) {
26546 QUnit.module('locale:' + name, {
26547 setup : function () {
26548 moment.locale(name);
26549 moment.createFromInputFallback = function () {
26550 throw new Error('input not handled by moment');
26551 };
26552 if (lifecycle && lifecycle.setup) {
26553 lifecycle.setup();
26554 }
26555 },
26556 teardown : function () {
26557 moment.locale('en');
26558 if (lifecycle && lifecycle.teardown) {
26559 lifecycle.teardown();
26560 }
26561 }
26562 });
26563 }
26564
26565 localeModule('sr');
26566
26567 test('parse', function (assert) {
26568 var tests = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
26569 i;
26570 function equalTest(input, mmm, i) {
26571 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
26572 }
26573 for (i = 0; i < 12; i++) {
26574 tests[i] = tests[i].split(' ');
26575 equalTest(tests[i][0], 'MMM', i);
26576 equalTest(tests[i][1], 'MMM', i);
26577 equalTest(tests[i][0], 'MMMM', i);
26578 equalTest(tests[i][1], 'MMMM', i);
26579 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
26580 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
26581 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
26582 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
26583 }
26584 });
26585
26586 test('format', function (assert) {
26587 var a = [
26588 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedelja, 14. februar 2010, 3:25:50 pm'],
26589 ['ddd, hA', 'ned., 3PM'],
26590 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
26591 ['YYYY YY', '2010 10'],
26592 ['D Do DD', '14 14. 14'],
26593 ['d do dddd ddd dd', '0 0. nedelja ned. ne'],
26594 ['DDD DDDo DDDD', '45 45. 045'],
26595 ['w wo ww', '7 7. 07'],
26596 ['h hh', '3 03'],
26597 ['H HH', '15 15'],
26598 ['m mm', '25 25'],
26599 ['s ss', '50 50'],
26600 ['a A', 'pm PM'],
26601 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
26602 ['LTS', '15:25:50'],
26603 ['L', '14. 02. 2010'],
26604 ['LL', '14. februar 2010'],
26605 ['LLL', '14. februar 2010 15:25'],
26606 ['LLLL', 'nedelja, 14. februar 2010 15:25'],
26607 ['l', '14. 2. 2010'],
26608 ['ll', '14. feb. 2010'],
26609 ['lll', '14. feb. 2010 15:25'],
26610 ['llll', 'ned., 14. feb. 2010 15:25']
26611 ],
26612 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
26613 i;
26614 for (i = 0; i < a.length; i++) {
26615 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
26616 }
26617 });
26618
26619 test('format ordinal', function (assert) {
26620 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
26621 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
26622 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
26623 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
26624 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
26625 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
26626 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
26627 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
26628 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
26629 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
26630
26631 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
26632 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
26633 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
26634 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
26635 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
26636 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
26637 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
26638 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
26639 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
26640 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
26641
26642 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
26643 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
26644 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
26645 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
26646 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
26647 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
26648 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
26649 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
26650 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
26651 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
26652
26653 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
26654 });
26655
26656 test('format month', function (assert) {
26657 var expected = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
26658 i;
26659 for (i = 0; i < expected.length; i++) {
26660 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
26661 }
26662 });
26663
26664 test('format week', function (assert) {
26665 var expected = 'nedelja ned. ne_ponedeljak pon. po_utorak uto. ut_sreda sre. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'),
26666 i;
26667 for (i = 0; i < expected.length; i++) {
26668 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
26669 }
26670 });
26671
26672 test('from', function (assert) {
26673 var start = moment([2007, 1, 28]);
26674 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nekoliko sekundi', '44 seconds = a few seconds');
26675 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedan minut', '45 seconds = a minute');
26676 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedan minut', '89 seconds = a minute');
26677 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
26678 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
26679 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
26680 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
26681 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
26682 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
26683 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
26684 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
26685 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
26686 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
26687 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
26688 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
26689 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
26690 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mesec', '26 days = a month');
26691 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mesec', '30 days = a month');
26692 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mesec', '43 days = a month');
26693 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meseca', '46 days = 2 months');
26694 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meseca', '75 days = 2 months');
26695 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meseca', '76 days = 3 months');
26696 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mesec', '1 month = a month');
26697 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meseci', '5 months = 5 months');
26698 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
26699 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
26700 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
26701 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
26702 });
26703
26704 test('suffix', function (assert) {
26705 assert.equal(moment(30000).from(0), 'za nekoliko sekundi', 'prefix');
26706 assert.equal(moment(0).from(30000), 'pre nekoliko sekundi', 'prefix');
26707 });
26708
26709 test('now from now', function (assert) {
26710 assert.equal(moment().fromNow(), 'pre nekoliko sekundi', 'now from now should display as in the past');
26711 });
26712
26713 test('fromNow', function (assert) {
26714 assert.equal(moment().add({s: 30}).fromNow(), 'za nekoliko sekundi', 'in a few seconds');
26715 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
26716 });
26717
26718 test('calendar day', function (assert) {
26719 var a = moment().hours(2).minutes(0).seconds(0);
26720
26721 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
26722 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
26723 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
26724 assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
26725 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
26726 assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
26727 });
26728
26729 test('calendar next week', function (assert) {
26730 var i, m;
26731
26732 function makeFormat(d) {
26733 switch (d.day()) {
26734 case 0:
26735 return '[u] [nedelju] [u] LT';
26736 case 3:
26737 return '[u] [sredu] [u] LT';
26738 case 6:
26739 return '[u] [subotu] [u] LT';
26740 case 1:
26741 case 2:
26742 case 4:
26743 case 5:
26744 return '[u] dddd [u] LT';
26745 }
26746 }
26747
26748 for (i = 2; i < 7; i++) {
26749 m = moment().add({d: i});
26750 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
26751 m.hours(0).minutes(0).seconds(0).milliseconds(0);
26752 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
26753 m.hours(23).minutes(59).seconds(59).milliseconds(999);
26754 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
26755 }
26756 });
26757
26758 test('calendar last week', function (assert) {
26759 var i, m;
26760
26761 function makeFormat(d) {
26762 var lastWeekDay = [
26763 '[prošle] [nedelje] [u] LT',
26764 '[prošlog] [ponedeljka] [u] LT',
26765 '[prošlog] [utorka] [u] LT',
26766 '[prošle] [srede] [u] LT',
26767 '[prošlog] [četvrtka] [u] LT',
26768 '[prošlog] [petka] [u] LT',
26769 '[prošle] [subote] [u] LT'
26770 ];
26771
26772 return lastWeekDay[d.day()];
26773 }
26774
26775 for (i = 2; i < 7; i++) {
26776 m = moment().subtract({d: i});
26777 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
26778 m.hours(0).minutes(0).seconds(0).milliseconds(0);
26779 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
26780 m.hours(23).minutes(59).seconds(59).milliseconds(999);
26781 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
26782 }
26783 });
26784
26785 test('calendar all else', function (assert) {
26786 var weeksAgo = moment().subtract({w: 1}),
26787 weeksFromNow = moment().add({w: 1});
26788
26789 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
26790 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
26791
26792 weeksAgo = moment().subtract({w: 2});
26793 weeksFromNow = moment().add({w: 2});
26794
26795 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
26796 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
26797 });
26798
26799 test('weeks year starting sunday', function (assert) {
26800 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
26801 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
26802 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
26803 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
26804 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
26805 });
26806
26807 test('weeks year starting monday', function (assert) {
26808 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
26809 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
26810 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
26811 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
26812 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
26813 });
26814
26815 test('weeks year starting tuesday', function (assert) {
26816 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
26817 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
26818 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
26819 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
26820 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
26821 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
26822 });
26823
26824 test('weeks year starting wednesday', function (assert) {
26825 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
26826 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
26827 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
26828 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
26829 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
26830 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
26831 });
26832
26833 test('weeks year starting thursday', function (assert) {
26834 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
26835 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
26836 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
26837 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
26838 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
26839 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
26840 });
26841
26842 test('weeks year starting friday', function (assert) {
26843 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
26844 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
26845 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
26846 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
26847 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
26848 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
26849 });
26850
26851 test('weeks year starting saturday', function (assert) {
26852 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
26853 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
26854 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
26855 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
26856 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
26857 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
26858 });
26859
26860 test('weeks year starting sunday formatted', function (assert) {
26861 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
26862 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
26863 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
26864 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
26865 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
26866 });
26867
26868 test('lenient ordinal parsing', function (assert) {
26869 var i, ordinalStr, testMoment;
26870 for (i = 1; i <= 31; ++i) {
26871 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
26872 testMoment = moment(ordinalStr, 'YYYY MM Do');
26873 assert.equal(testMoment.year(), 2014,
26874 'lenient ordinal parsing ' + i + ' year check');
26875 assert.equal(testMoment.month(), 0,
26876 'lenient ordinal parsing ' + i + ' month check');
26877 assert.equal(testMoment.date(), i,
26878 'lenient ordinal parsing ' + i + ' date check');
26879 }
26880 });
26881
26882 test('lenient ordinal parsing of number', function (assert) {
26883 var i, testMoment;
26884 for (i = 1; i <= 31; ++i) {
26885 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
26886 assert.equal(testMoment.year(), 2014,
26887 'lenient ordinal parsing of number ' + i + ' year check');
26888 assert.equal(testMoment.month(), 0,
26889 'lenient ordinal parsing of number ' + i + ' month check');
26890 assert.equal(testMoment.date(), i,
26891 'lenient ordinal parsing of number ' + i + ' date check');
26892 }
26893 });
26894
26895 test('strict ordinal parsing', function (assert) {
26896 var i, ordinalStr, testMoment;
26897 for (i = 1; i <= 31; ++i) {
26898 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
26899 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
26900 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
26901 }
26902 });
26903
26904 }));
26905
26906 (function (global, factory) {
26907 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
26908 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
26909 factory(global.moment)
26910 }(this, function (moment) { 'use strict';
26911
26912 /*global QUnit:false*/
26913
26914 var test = QUnit.test;
26915
26916 function module (name, lifecycle) {
26917 QUnit.module(name, {
26918 setup : function () {
26919 moment.locale('en');
26920 moment.createFromInputFallback = function () {
26921 throw new Error('input not handled by moment');
26922 };
26923 if (lifecycle && lifecycle.setup) {
26924 lifecycle.setup();
26925 }
26926 },
26927 teardown : function () {
26928 if (lifecycle && lifecycle.teardown) {
26929 lifecycle.teardown();
26930 }
26931 }
26932 });
26933 }
26934
26935 function localeModule (name, lifecycle) {
26936 QUnit.module('locale:' + name, {
26937 setup : function () {
26938 moment.locale(name);
26939 moment.createFromInputFallback = function () {
26940 throw new Error('input not handled by moment');
26941 };
26942 if (lifecycle && lifecycle.setup) {
26943 lifecycle.setup();
26944 }
26945 },
26946 teardown : function () {
26947 moment.locale('en');
26948 if (lifecycle && lifecycle.teardown) {
26949 lifecycle.teardown();
26950 }
26951 }
26952 });
26953 }
26954
26955 localeModule('sv');
26956
26957 test('parse', function (assert) {
26958 var tests = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
26959 function equalTest(input, mmm, i) {
26960 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
26961 }
26962 for (i = 0; i < 12; i++) {
26963 tests[i] = tests[i].split(' ');
26964 equalTest(tests[i][0], 'MMM', i);
26965 equalTest(tests[i][1], 'MMM', i);
26966 equalTest(tests[i][0], 'MMMM', i);
26967 equalTest(tests[i][1], 'MMMM', i);
26968 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
26969 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
26970 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
26971 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
26972 }
26973 });
26974
26975 test('format', function (assert) {
26976 var a = [
26977 ['dddd, MMMM Do YYYY, h:mm:ss a', 'söndag, februari 14e 2010, 3:25:50 pm'],
26978 ['ddd, hA', 'sön, 3PM'],
26979 ['M Mo MM MMMM MMM', '2 2a 02 februari feb'],
26980 ['YYYY YY', '2010 10'],
26981 ['D Do DD', '14 14e 14'],
26982 ['d do dddd ddd dd', '0 0e söndag sön sö'],
26983 ['DDD DDDo DDDD', '45 45e 045'],
26984 ['w wo ww', '6 6e 06'],
26985 ['h hh', '3 03'],
26986 ['H HH', '15 15'],
26987 ['m mm', '25 25'],
26988 ['s ss', '50 50'],
26989 ['a A', 'pm PM'],
26990 ['[the] DDDo [day of the year]', 'the 45e day of the year'],
26991 ['LTS', '15:25:50'],
26992 ['L', '2010-02-14'],
26993 ['LL', '14 februari 2010'],
26994 ['LLL', '14 februari 2010 15:25'],
26995 ['LLLL', 'söndag 14 februari 2010 15:25'],
26996 ['l', '2010-2-14'],
26997 ['ll', '14 feb 2010'],
26998 ['lll', '14 feb 2010 15:25'],
26999 ['llll', 'sön 14 feb 2010 15:25']
27000 ],
27001 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
27002 i;
27003 for (i = 0; i < a.length; i++) {
27004 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
27005 }
27006 });
27007
27008 test('format ordinal', function (assert) {
27009 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
27010 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
27011 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3e', '3e');
27012 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4e', '4e');
27013 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5e', '5e');
27014 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6e', '6e');
27015 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7e', '7e');
27016 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8e', '8e');
27017 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9e', '9e');
27018 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10e', '10e');
27019
27020 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11e', '11e');
27021 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12e', '12e');
27022 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13e', '13e');
27023 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14e', '14e');
27024 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15e', '15e');
27025 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16e', '16e');
27026 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17e', '17e');
27027 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18e', '18e');
27028 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19e', '19e');
27029 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20e', '20e');
27030
27031 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
27032 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
27033 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23e', '23e');
27034 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24e', '24e');
27035 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25e', '25e');
27036 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26e', '26e');
27037 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27e', '27e');
27038 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28e', '28e');
27039 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29e', '29e');
27040 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30e', '30e');
27041
27042 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
27043 });
27044
27045 test('format month', function (assert) {
27046 var expected = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
27047 for (i = 0; i < expected.length; i++) {
27048 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
27049 }
27050 });
27051
27052 test('format week', function (assert) {
27053 var expected = 'söndag sön sö_måndag mån må_tisdag tis ti_onsdag ons on_torsdag tor to_fredag fre fr_lördag lör lö'.split('_'), i;
27054 for (i = 0; i < expected.length; i++) {
27055 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
27056 }
27057 });
27058
27059 test('from', function (assert) {
27060 var start = moment([2007, 1, 28]);
27061 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'några sekunder', '44 seconds = a few seconds');
27062 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'en minut', '45 seconds = a minute');
27063 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'en minut', '89 seconds = a minute');
27064 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuter', '90 seconds = 2 minutes');
27065 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuter', '44 minutes = 44 minutes');
27066 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'en timme', '45 minutes = an hour');
27067 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'en timme', '89 minutes = an hour');
27068 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timmar', '90 minutes = 2 hours');
27069 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timmar', '5 hours = 5 hours');
27070 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timmar', '21 hours = 21 hours');
27071 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dag', '22 hours = a day');
27072 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dag', '35 hours = a day');
27073 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
27074 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dag', '1 day = a day');
27075 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
27076 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
27077 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en månad', '26 days = a month');
27078 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en månad', '30 days = a month');
27079 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en månad', '43 days = a month');
27080 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 månader', '46 days = 2 months');
27081 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 månader', '75 days = 2 months');
27082 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 månader', '76 days = 3 months');
27083 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en månad', '1 month = a month');
27084 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 månader', '5 months = 5 months');
27085 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ett år', '345 days = a year');
27086 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
27087 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ett år', '1 year = a year');
27088 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
27089 });
27090
27091 test('suffix', function (assert) {
27092 assert.equal(moment(30000).from(0), 'om några sekunder', 'prefix');
27093 assert.equal(moment(0).from(30000), 'för några sekunder sedan', 'suffix');
27094 });
27095
27096 test('now from now', function (assert) {
27097 assert.equal(moment().fromNow(), 'för några sekunder sedan', 'now from now should display as in the past');
27098 });
27099
27100 test('fromNow', function (assert) {
27101 assert.equal(moment().add({s: 30}).fromNow(), 'om några sekunder', 'in a few seconds');
27102 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dagar', 'in 5 days');
27103 });
27104
27105 test('calendar day', function (assert) {
27106 var a = moment().hours(2).minutes(0).seconds(0);
27107
27108 assert.equal(moment(a).calendar(), 'Idag 02:00', 'today at the same time');
27109 assert.equal(moment(a).add({m: 25}).calendar(), 'Idag 02:25', 'Now plus 25 min');
27110 assert.equal(moment(a).add({h: 1}).calendar(), 'Idag 03:00', 'Now plus 1 hour');
27111 assert.equal(moment(a).add({d: 1}).calendar(), 'Imorgon 02:00', 'tomorrow at the same time');
27112 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Idag 01:00', 'Now minus 1 hour');
27113 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Igår 02:00', 'yesterday at the same time');
27114 });
27115
27116 test('calendar next week', function (assert) {
27117 var i, m;
27118 for (i = 2; i < 7; i++) {
27119 m = moment().add({d: i});
27120 assert.equal(m.calendar(), m.format('[På] dddd LT'), 'Today + ' + i + ' days current time');
27121 m.hours(0).minutes(0).seconds(0).milliseconds(0);
27122 assert.equal(m.calendar(), m.format('[På] dddd LT'), 'Today + ' + i + ' days beginning of day');
27123 m.hours(23).minutes(59).seconds(59).milliseconds(999);
27124 assert.equal(m.calendar(), m.format('[På] dddd LT'), 'Today + ' + i + ' days end of day');
27125 }
27126 });
27127
27128 test('calendar last week', function (assert) {
27129 var i, m;
27130 for (i = 2; i < 7; i++) {
27131 m = moment().subtract({d: i});
27132 assert.equal(m.calendar(), m.format('[I] dddd[s] LT'), 'Today - ' + i + ' days current time');
27133 m.hours(0).minutes(0).seconds(0).milliseconds(0);
27134 assert.equal(m.calendar(), m.format('[I] dddd[s] LT'), 'Today - ' + i + ' days beginning of day');
27135 m.hours(23).minutes(59).seconds(59).milliseconds(999);
27136 assert.equal(m.calendar(), m.format('[I] dddd[s] LT'), 'Today - ' + i + ' days end of day');
27137 }
27138 });
27139
27140 test('calendar all else', function (assert) {
27141 var weeksAgo = moment().subtract({w: 1}),
27142 weeksFromNow = moment().add({w: 1});
27143
27144 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
27145 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
27146
27147 weeksAgo = moment().subtract({w: 2});
27148 weeksFromNow = moment().add({w: 2});
27149
27150 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
27151 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
27152 });
27153
27154 test('weeks year starting sunday', function (assert) {
27155 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
27156 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
27157 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
27158 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
27159 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
27160 });
27161
27162 test('weeks year starting monday', function (assert) {
27163 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
27164 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
27165 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
27166 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
27167 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
27168 });
27169
27170 test('weeks year starting tuesday', function (assert) {
27171 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
27172 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
27173 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
27174 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
27175 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
27176 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
27177 });
27178
27179 test('weeks year starting wednesday', function (assert) {
27180 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
27181 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
27182 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
27183 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
27184 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
27185 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
27186 });
27187
27188 test('weeks year starting thursday', function (assert) {
27189 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
27190 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
27191 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
27192 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
27193 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
27194 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
27195 });
27196
27197 test('weeks year starting friday', function (assert) {
27198 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
27199 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
27200 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
27201 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
27202 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
27203 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
27204 });
27205
27206 test('weeks year starting saturday', function (assert) {
27207 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
27208 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
27209 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
27210 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
27211 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
27212 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
27213 });
27214
27215 test('weeks year starting sunday formatted', function (assert) {
27216 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
27217 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
27218 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1a', 'Jan 8 2012 should be week 1');
27219 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2a', 'Jan 9 2012 should be week 2');
27220 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
27221 });
27222
27223 test('lenient ordinal parsing', function (assert) {
27224 var i, ordinalStr, testMoment;
27225 for (i = 1; i <= 31; ++i) {
27226 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
27227 testMoment = moment(ordinalStr, 'YYYY MM Do');
27228 assert.equal(testMoment.year(), 2014,
27229 'lenient ordinal parsing ' + i + ' year check');
27230 assert.equal(testMoment.month(), 0,
27231 'lenient ordinal parsing ' + i + ' month check');
27232 assert.equal(testMoment.date(), i,
27233 'lenient ordinal parsing ' + i + ' date check');
27234 }
27235 });
27236
27237 test('lenient ordinal parsing of number', function (assert) {
27238 var i, testMoment;
27239 for (i = 1; i <= 31; ++i) {
27240 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
27241 assert.equal(testMoment.year(), 2014,
27242 'lenient ordinal parsing of number ' + i + ' year check');
27243 assert.equal(testMoment.month(), 0,
27244 'lenient ordinal parsing of number ' + i + ' month check');
27245 assert.equal(testMoment.date(), i,
27246 'lenient ordinal parsing of number ' + i + ' date check');
27247 }
27248 });
27249
27250 test('strict ordinal parsing', function (assert) {
27251 var i, ordinalStr, testMoment;
27252 for (i = 1; i <= 31; ++i) {
27253 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
27254 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
27255 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
27256 }
27257 });
27258
27259 }));
27260
27261 (function (global, factory) {
27262 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
27263 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
27264 factory(global.moment)
27265 }(this, function (moment) { 'use strict';
27266
27267 /*global QUnit:false*/
27268
27269 var test = QUnit.test;
27270
27271 function module (name, lifecycle) {
27272 QUnit.module(name, {
27273 setup : function () {
27274 moment.locale('en');
27275 moment.createFromInputFallback = function () {
27276 throw new Error('input not handled by moment');
27277 };
27278 if (lifecycle && lifecycle.setup) {
27279 lifecycle.setup();
27280 }
27281 },
27282 teardown : function () {
27283 if (lifecycle && lifecycle.teardown) {
27284 lifecycle.teardown();
27285 }
27286 }
27287 });
27288 }
27289
27290 function localeModule (name, lifecycle) {
27291 QUnit.module('locale:' + name, {
27292 setup : function () {
27293 moment.locale(name);
27294 moment.createFromInputFallback = function () {
27295 throw new Error('input not handled by moment');
27296 };
27297 if (lifecycle && lifecycle.setup) {
27298 lifecycle.setup();
27299 }
27300 },
27301 teardown : function () {
27302 moment.locale('en');
27303 if (lifecycle && lifecycle.teardown) {
27304 lifecycle.teardown();
27305 }
27306 }
27307 });
27308 }
27309
27310 localeModule('ta');
27311
27312 test('parse', function (assert) {
27313 var tests = 'ஜனவரி ஜனவரி_பிப்ரவரி பிப்ரவரி_மார்ச் மார்ச்_ஏப்ரல் ஏப்ரல்_மே மே_ஜூன் ஜூன்_ஜூலை ஜூலை_ஆகஸ்ட் ஆகஸ்ட்_செப்டெம்பர் செப்டெம்பர்_அக்டோபர் அக்டோபர்_நவம்பர் நவம்பர்_டிசம்பர் டிசம்பர்'.split('_'), i;
27314 function equalTest(input, mmm, i) {
27315 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
27316 }
27317 for (i = 0; i < 12; i++) {
27318 tests[i] = tests[i].split(' ');
27319 equalTest(tests[i][0], 'MMM', i);
27320 equalTest(tests[i][1], 'MMM', i);
27321 equalTest(tests[i][0], 'MMMM', i);
27322 equalTest(tests[i][1], 'MMMM', i);
27323 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
27324 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
27325 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
27326 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
27327 }
27328 });
27329
27330 test('format', function (assert) {
27331 var a = [
27332 ['dddd, MMMM Do YYYY, h:mm:ss a', 'ஞாயிற்றுக்கிழமை, பிப்ரவரி 14வது 2010, 3:25:50 எற்பாடு'],
27333 ['ddd, hA', 'ஞாயிறு, 3 எற்பாடு'],
27334 ['M Mo MM MMMM MMM', '2 2வது 02 பிப்ரவரி பிப்ரவரி'],
27335 ['YYYY YY', '2010 10'],
27336 ['D Do DD', '14 14வது 14'],
27337 ['d do dddd ddd dd', '0 0வது ஞாயிற்றுக்கிழமை ஞாயிறு ஞா'],
27338 ['DDD DDDo DDDD', '45 45வது 045'],
27339 ['w wo ww', '8 8வது 08'],
27340 ['h hh', '3 03'],
27341 ['H HH', '15 15'],
27342 ['m mm', '25 25'],
27343 ['s ss', '50 50'],
27344 ['a A', ' எற்பாடு எற்பாடு'],
27345 ['[ஆண்டின்] DDDo [நாள்]', 'ஆண்டின் 45வது நாள்'],
27346 ['LTS', '15:25:50'],
27347 ['L', '14/02/2010'],
27348 ['LL', '14 பிப்ரவரி 2010'],
27349 ['LLL', '14 பிப்ரவரி 2010, 15:25'],
27350 ['LLLL', 'ஞாயிற்றுக்கிழமை, 14 பிப்ரவரி 2010, 15:25'],
27351 ['l', '14/2/2010'],
27352 ['ll', '14 பிப்ரவரி 2010'],
27353 ['lll', '14 பிப்ரவரி 2010, 15:25'],
27354 ['llll', 'ஞாயிறு, 14 பிப்ரவரி 2010, 15:25']
27355 ],
27356 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
27357 i;
27358 for (i = 0; i < a.length; i++) {
27359 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
27360 }
27361 });
27362
27363 test('format ordinal', function (assert) {
27364 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1வது', '1வது');
27365 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2வது', '2வது');
27366 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3வது', '3வது');
27367 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4வது', '4வது');
27368 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5வது', '5வது');
27369 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6வது', '6வது');
27370 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7வது', '7வது');
27371 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8வது', '8வது');
27372 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9வது', '9வது');
27373 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10வது', '10வது');
27374
27375 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11வது', '11வது');
27376 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12வது', '12வது');
27377 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13வது', '13வது');
27378 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14வது', '14வது');
27379 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15வது', '15வது');
27380 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16வது', '16வது');
27381 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17வது', '17வது');
27382 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18வது', '18வது');
27383 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19வது', '19வது');
27384 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20வது', '20வது');
27385
27386 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21வது', '21வது');
27387 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22வது', '22வது');
27388 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23வது', '23வது');
27389 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24வது', '24வது');
27390 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25வது', '25வது');
27391 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26வது', '26வது');
27392 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27வது', '27வது');
27393 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28வது', '28வது');
27394 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29வது', '29வது');
27395 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30வது', '30வது');
27396
27397 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31வது', '31வது');
27398 });
27399
27400 test('format month', function (assert) {
27401 var expected = 'ஜனவரி ஜனவரி_பிப்ரவரி பிப்ரவரி_மார்ச் மார்ச்_ஏப்ரல் ஏப்ரல்_மே மே_ஜூன் ஜூன்_ஜூலை ஜூலை_ஆகஸ்ட் ஆகஸ்ட்_செப்டெம்பர் செப்டெம்பர்_அக்டோபர் அக்டோபர்_நவம்பர் நவம்பர்_டிசம்பர் டிசம்பர்'.split('_'), i;
27402 for (i = 0; i < expected.length; i++) {
27403 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
27404 }
27405 });
27406
27407 test('format week', function (assert) {
27408 var expected = 'ஞாயிற்றுக்கிழமை ஞாயிறு ஞா_திங்கட்கிழமை திங்கள் தி_செவ்வாய்கிழமை செவ்வாய் செ_புதன்கிழமை புதன் பு_வியாழக்கிழமை வியாழன் வி_வெள்ளிக்கிழமை வெள்ளி வெ_சனிக்கிழமை சனி ச'.split('_'), i;
27409 for (i = 0; i < expected.length; i++) {
27410 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
27411 }
27412 });
27413
27414 test('from', function (assert) {
27415 var start = moment([2007, 1, 28]);
27416 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ஒரு சில விநாடிகள்', '44 விநாடிகள் = ஒரு சில விநாடிகள்');
27417 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ஒரு நிமிடம்', '45 விநாடிகள் = ஒரு நிமிடம்');
27418 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ஒரு நிமிடம்', '89 விநாடிகள் = ஒரு நிமிடம்');
27419 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 நிமிடங்கள்', '90 விநாடிகள் = 2 நிமிடங்கள்');
27420 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 நிமிடங்கள்', '44 நிமிடங்கள் = 44 நிமிடங்கள்');
27421 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ஒரு மணி நேரம்', '45 நிமிடங்கள் = ஒரு மணி நேரம்');
27422 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ஒரு மணி நேரம்', '89 நிமிடங்கள் = ஒரு மணி நேரம்');
27423 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 மணி நேரம்', '90 நிமிடங்கள் = 2 மணி நேரம்');
27424 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 மணி நேரம்', '5 மணி நேரம் = 5 மணி நேரம்');
27425 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 மணி நேரம்', '21 மணி நேரம் = 21 மணி நேரம்');
27426 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ஒரு நாள்', '22 மணி நேரம் = ஒரு நாள்');
27427 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ஒரு நாள்', '35 மணி நேரம் = ஒரு நாள்');
27428 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 நாட்கள்', '36 மணி நேரம் = 2 days');
27429 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ஒரு நாள்', '1 நாள் = ஒரு நாள்');
27430 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 நாட்கள்', '5 நாட்கள் = 5 நாட்கள்');
27431 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 நாட்கள்', '25 நாட்கள் = 25 நாட்கள்');
27432 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ஒரு மாதம்', '26 நாட்கள் = ஒரு மாதம்');
27433 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ஒரு மாதம்', '30 நாட்கள் = ஒரு மாதம்');
27434 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ஒரு மாதம்', '45 நாட்கள் = ஒரு மாதம்');
27435 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 மாதங்கள்', '46 நாட்கள் = 2 மாதங்கள்');
27436 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 மாதங்கள்', '75 நாட்கள் = 2 மாதங்கள்');
27437 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 மாதங்கள்', '76 நாட்கள் = 3 மாதங்கள்');
27438 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ஒரு மாதம்', '1 மாதம் = ஒரு மாதம்');
27439 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 மாதங்கள்', '5 மாதங்கள் = 5 மாதங்கள்');
27440 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ஒரு வருடம்', '345 நாட்கள் = ஒரு வருடம்');
27441 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ஆண்டுகள்', '548 நாட்கள் = 2 ஆண்டுகள்');
27442 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ஒரு வருடம்', '1 வருடம் = ஒரு வருடம்');
27443 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ஆண்டுகள்', '5 ஆண்டுகள் = 5 ஆண்டுகள்');
27444 });
27445
27446 test('suffix', function (assert) {
27447 assert.equal(moment(30000).from(0), 'ஒரு சில விநாடிகள் இல்', 'prefix');
27448 assert.equal(moment(0).from(30000), 'ஒரு சில விநாடிகள் முன்', 'suffix');
27449 });
27450
27451 test('now from now', function (assert) {
27452 assert.equal(moment().fromNow(), 'ஒரு சில விநாடிகள் முன்', 'இப்போது இருந்து கடந்த காலத்தில் காட்ட வேண்டும்');
27453 });
27454
27455 test('fromNow', function (assert) {
27456 assert.equal(moment().add({s: 30}).fromNow(), 'ஒரு சில விநாடிகள் இல்', 'ஒரு சில விநாடிகள் இல்');
27457 assert.equal(moment().add({d: 5}).fromNow(), '5 நாட்கள் இல்', '5 நாட்கள் இல்');
27458 });
27459
27460 test('calendar day', function (assert) {
27461 var a = moment().hours(2).minutes(0).seconds(0);
27462
27463 assert.equal(moment(a).calendar(), 'இன்று 02:00', 'இன்று 02:00');
27464 assert.equal(moment(a).add({m: 25}).calendar(), 'இன்று 02:25', 'இன்று 02:25');
27465 assert.equal(moment(a).add({h: 1}).calendar(), 'இன்று 03:00', 'இன்று 03:00');
27466 assert.equal(moment(a).add({d: 1}).calendar(), 'நாளை 02:00', 'நாளை 02:00');
27467 assert.equal(moment(a).subtract({h: 1}).calendar(), 'இன்று 01:00', 'இன்று 01:00');
27468 assert.equal(moment(a).subtract({d: 1}).calendar(), 'நேற்று 02:00', 'நேற்று 02:00');
27469 });
27470
27471 test('calendar next week', function (assert) {
27472 var i, m;
27473 for (i = 2; i < 7; i++) {
27474 m = moment().add({d: i});
27475 assert.equal(m.calendar(), m.format('dddd, LT'), 'Today + ' + i + ' days current time');
27476 m.hours(0).minutes(0).seconds(0).milliseconds(0);
27477 assert.equal(m.calendar(), m.format('dddd, LT'), 'Today + ' + i + ' days beginning of day');
27478 m.hours(23).minutes(59).seconds(59).milliseconds(999);
27479 assert.equal(m.calendar(), m.format('dddd, LT'), 'Today + ' + i + ' days end of day');
27480 }
27481 });
27482
27483 test('calendar last week', function (assert) {
27484 var i, m;
27485
27486 for (i = 2; i < 7; i++) {
27487 m = moment().subtract({d: i});
27488 assert.equal(m.calendar(), m.format('[கடந்த வாரம்] dddd, LT'), 'Today - ' + i + ' days current time');
27489 m.hours(0).minutes(0).seconds(0).milliseconds(0);
27490 assert.equal(m.calendar(), m.format('[கடந்த வாரம்] dddd, LT'), 'Today - ' + i + ' days beginning of day');
27491 m.hours(23).minutes(59).seconds(59).milliseconds(999);
27492 assert.equal(m.calendar(), m.format('[கடந்த வாரம்] dddd, LT'), 'Today - ' + i + ' days end of day');
27493 }
27494 });
27495
27496 test('calendar all else', function (assert) {
27497 var weeksAgo = moment().subtract({w: 1}),
27498 weeksFromNow = moment().add({w: 1});
27499
27500 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
27501 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
27502
27503 weeksAgo = moment().subtract({w: 2});
27504 weeksFromNow = moment().add({w: 2});
27505
27506 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
27507 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
27508 });
27509
27510 test('weeks year starting sunday', function (assert) {
27511 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
27512 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
27513 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
27514 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
27515 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
27516 });
27517
27518 test('weeks year starting monday', function (assert) {
27519 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
27520 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
27521 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
27522 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
27523 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
27524 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
27525 });
27526
27527 test('weeks year starting tuesday', function (assert) {
27528 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
27529 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
27530 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
27531 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
27532 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
27533 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
27534 });
27535
27536 test('weeks year starting wednesday', function (assert) {
27537 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
27538 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
27539 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
27540 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
27541 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
27542 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
27543 });
27544
27545 test('weeks year starting thursday', function (assert) {
27546 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
27547 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
27548 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
27549 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
27550 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
27551 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
27552 });
27553
27554 test('weeks year starting friday', function (assert) {
27555 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
27556 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
27557 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
27558 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
27559 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
27560 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
27561 });
27562
27563 test('weeks year starting saturday', function (assert) {
27564 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
27565 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
27566 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
27567 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
27568 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
27569 });
27570
27571 test('meridiem', function (assert) {
27572 assert.equal(moment([2011, 2, 23, 0, 30]).format('a'), ' யாமம்', '(after) midnight');
27573 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), ' வைகறை', 'before dawn');
27574 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), ' காலை', 'morning');
27575 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), ' எற்பாடு', 'during day');
27576 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), ' எற்பாடு', 'evening');
27577 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), ' மாலை', 'late evening');
27578 assert.equal(moment([2011, 2, 23, 23, 30]).format('a'), ' யாமம்', '(before) midnight');
27579 });
27580
27581 test('lenient ordinal parsing', function (assert) {
27582 var i, ordinalStr, testMoment;
27583 for (i = 1; i <= 31; ++i) {
27584 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
27585 testMoment = moment(ordinalStr, 'YYYY MM Do');
27586 assert.equal(testMoment.year(), 2014,
27587 'lenient ordinal parsing ' + i + ' year check');
27588 assert.equal(testMoment.month(), 0,
27589 'lenient ordinal parsing ' + i + ' month check');
27590 assert.equal(testMoment.date(), i,
27591 'lenient ordinal parsing ' + i + ' date check');
27592 }
27593 });
27594
27595 test('lenient ordinal parsing of number', function (assert) {
27596 var i, testMoment;
27597 for (i = 1; i <= 31; ++i) {
27598 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
27599 assert.equal(testMoment.year(), 2014,
27600 'lenient ordinal parsing of number ' + i + ' year check');
27601 assert.equal(testMoment.month(), 0,
27602 'lenient ordinal parsing of number ' + i + ' month check');
27603 assert.equal(testMoment.date(), i,
27604 'lenient ordinal parsing of number ' + i + ' date check');
27605 }
27606 });
27607
27608 test('meridiem invariant', function (assert) {
27609 var h, m, t1, t2;
27610 for (h = 0; h < 24; ++h) {
27611 for (m = 0; m < 60; m += 15) {
27612 t1 = moment.utc([2000, 0, 1, h, m]);
27613 t2 = moment(t1.format('A h:mm'), 'A h:mm');
27614 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
27615 'meridiem at ' + t1.format('HH:mm'));
27616 }
27617 }
27618 });
27619
27620 test('strict ordinal parsing', function (assert) {
27621 var i, ordinalStr, testMoment;
27622 for (i = 1; i <= 31; ++i) {
27623 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
27624 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
27625 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
27626 }
27627 });
27628
27629 }));
27630
27631 (function (global, factory) {
27632 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
27633 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
27634 factory(global.moment)
27635 }(this, function (moment) { 'use strict';
27636
27637 /*global QUnit:false*/
27638
27639 var test = QUnit.test;
27640
27641 function module (name, lifecycle) {
27642 QUnit.module(name, {
27643 setup : function () {
27644 moment.locale('en');
27645 moment.createFromInputFallback = function () {
27646 throw new Error('input not handled by moment');
27647 };
27648 if (lifecycle && lifecycle.setup) {
27649 lifecycle.setup();
27650 }
27651 },
27652 teardown : function () {
27653 if (lifecycle && lifecycle.teardown) {
27654 lifecycle.teardown();
27655 }
27656 }
27657 });
27658 }
27659
27660 function localeModule (name, lifecycle) {
27661 QUnit.module('locale:' + name, {
27662 setup : function () {
27663 moment.locale(name);
27664 moment.createFromInputFallback = function () {
27665 throw new Error('input not handled by moment');
27666 };
27667 if (lifecycle && lifecycle.setup) {
27668 lifecycle.setup();
27669 }
27670 },
27671 teardown : function () {
27672 moment.locale('en');
27673 if (lifecycle && lifecycle.teardown) {
27674 lifecycle.teardown();
27675 }
27676 }
27677 });
27678 }
27679
27680 localeModule('th');
27681
27682 test('parse', function (assert) {
27683 var tests = 'มกราคม มกรา_กุมภาพันธ์ กุมภา_มีนาคม มีนา_เมษายน เมษา_พฤษภาคม พฤษภา_มิถุนายน มิถุนา_กรกฎาคม กรกฎา_สิงหาคม สิงหา_กันยายน กันยา_ตุลาคม ตุลา_พฤศจิกายน พฤศจิกา_ธันวาคม ธันวา'.split('_'), i;
27684 function equalTest(input, mmm, i) {
27685 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
27686 }
27687 for (i = 0; i < 12; i++) {
27688 tests[i] = tests[i].split(' ');
27689 equalTest(tests[i][0], 'MMM', i);
27690 equalTest(tests[i][1], 'MMM', i);
27691 equalTest(tests[i][0], 'MMMM', i);
27692 equalTest(tests[i][1], 'MMMM', i);
27693 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
27694 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
27695 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
27696 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
27697 }
27698 });
27699
27700 test('format', function (assert) {
27701 var a = [
27702 ['dddd, Do MMMM YYYY, h:mm:ss a', 'อาทิตย์, 14 กุมภาพันธ์ 2010, 3:25:50 หลังเที่ยง'],
27703 ['ddd, h A', 'อาทิตย์, 3 หลังเที่ยง'],
27704 ['M Mo MM MMMM MMM', '2 2 02 กุมภาพันธ์ กุมภา'],
27705 ['YYYY YY', '2010 10'],
27706 ['D Do DD', '14 14 14'],
27707 ['d do dddd ddd dd', '0 0 อาทิตย์ อาทิตย์ อา.'],
27708 ['DDD DDDo DDDD', '45 45 045'],
27709 ['w wo ww', '8 8 08'],
27710 ['h hh', '3 03'],
27711 ['H HH', '15 15'],
27712 ['m mm', '25 25'],
27713 ['s ss', '50 50'],
27714 ['a A', 'หลังเที่ยง หลังเที่ยง'],
27715 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
27716 ['LTS', '15 นาฬิกา 25 นาที 50 วินาที'],
27717 ['L', '2010/02/14'],
27718 ['LL', '14 กุมภาพันธ์ 2010'],
27719 ['LLL', '14 กุมภาพันธ์ 2010 เวลา 15 นาฬิกา 25 นาที'],
27720 ['LLLL', 'วันอาทิตย์ที่ 14 กุมภาพันธ์ 2010 เวลา 15 นาฬิกา 25 นาที'],
27721 ['l', '2010/2/14'],
27722 ['ll', '14 กุมภา 2010'],
27723 ['lll', '14 กุมภา 2010 เวลา 15 นาฬิกา 25 นาที'],
27724 ['llll', 'วันอาทิตย์ที่ 14 กุมภา 2010 เวลา 15 นาฬิกา 25 นาที']
27725 ],
27726 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
27727 i;
27728 for (i = 0; i < a.length; i++) {
27729 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
27730 }
27731 });
27732
27733 test('format month', function (assert) {
27734 var expected = 'มกราคม มกรา_กุมภาพันธ์ กุมภา_มีนาคม มีนา_เมษายน เมษา_พฤษภาคม พฤษภา_มิถุนายน มิถุนา_กรกฎาคม กรกฎา_สิงหาคม สิงหา_กันยายน กันยา_ตุลาคม ตุลา_พฤศจิกายน พฤศจิกา_ธันวาคม ธันวา'.split('_'), i;
27735 for (i = 0; i < expected.length; i++) {
27736 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
27737 }
27738 });
27739
27740 test('format week', function (assert) {
27741 var expected = 'อาทิตย์ อาทิตย์ อา._จันทร์ จันทร์ จ._อังคาร อังคาร อ._พุธ พุธ พ._พฤหัสบดี พฤหัส พฤ._ศุกร์ ศุกร์ ศ._เสาร์ เสาร์ ส.'.split('_'), i;
27742 for (i = 0; i < expected.length; i++) {
27743 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
27744 }
27745 });
27746
27747 test('from', function (assert) {
27748 var start = moment([2007, 1, 28]);
27749 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ไม่กี่วินาที', '44 seconds = a few seconds');
27750 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1 นาที', '45 seconds = a minute');
27751 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1 นาที', '89 seconds = a minute');
27752 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 นาที', '90 seconds = 2 minutes');
27753 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 นาที', '44 minutes = 44 minutes');
27754 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1 ชั่วโมง', '45 minutes = an hour');
27755 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1 ชั่วโมง', '89 minutes = an hour');
27756 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ชั่วโมง', '90 minutes = 2 hours');
27757 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ชั่วโมง', '5 hours = 5 hours');
27758 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ชั่วโมง', '21 hours = 21 hours');
27759 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1 วัน', '22 hours = a day');
27760 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1 วัน', '35 hours = a day');
27761 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 วัน', '36 hours = 2 days');
27762 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1 วัน', '1 day = a day');
27763 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 วัน', '5 days = 5 days');
27764 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 วัน', '25 days = 25 days');
27765 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1 เดือน', '26 days = a month');
27766 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1 เดือน', '30 days = a month');
27767 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1 เดือน', '43 days = a month');
27768 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 เดือน', '46 days = 2 months');
27769 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 เดือน', '75 days = 2 months');
27770 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 เดือน', '76 days = 3 months');
27771 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1 เดือน', '1 month = a month');
27772 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 เดือน', '5 months = 5 months');
27773 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1 ปี', '345 days = a year');
27774 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ปี', '548 days = 2 years');
27775 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1 ปี', '1 year = a year');
27776 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ปี', '5 years = 5 years');
27777 });
27778
27779 test('suffix', function (assert) {
27780 assert.equal(moment(30000).from(0), 'อีก ไม่กี่วินาที', 'prefix');
27781 assert.equal(moment(0).from(30000), 'ไม่กี่วินาทีที่แล้ว', 'suffix');
27782 });
27783
27784 test('now from now', function (assert) {
27785 assert.equal(moment().fromNow(), 'ไม่กี่วินาทีที่แล้ว', 'now from now should display as in the past');
27786 });
27787
27788 test('fromNow', function (assert) {
27789 assert.equal(moment().add({s: 30}).fromNow(), 'อีก ไม่กี่วินาที', 'in a few seconds');
27790 assert.equal(moment().add({d: 5}).fromNow(), 'อีก 5 วัน', 'in 5 days');
27791 });
27792
27793 test('calendar day', function (assert) {
27794 var a = moment().hours(2).minutes(0).seconds(0);
27795
27796 assert.equal(moment(a).calendar(), 'วันนี้ เวลา 2 นาฬิกา 0 นาที', 'today at the same time');
27797 assert.equal(moment(a).add({m: 25}).calendar(), 'วันนี้ เวลา 2 นาฬิกา 25 นาที', 'Now plus 25 min');
27798 assert.equal(moment(a).add({h: 1}).calendar(), 'วันนี้ เวลา 3 นาฬิกา 0 นาที', 'Now plus 1 hour');
27799 assert.equal(moment(a).add({d: 1}).calendar(), 'พรุ่งนี้ เวลา 2 นาฬิกา 0 นาที', 'tomorrow at the same time');
27800 assert.equal(moment(a).subtract({h: 1}).calendar(), 'วันนี้ เวลา 1 นาฬิกา 0 นาที', 'Now minus 1 hour');
27801 assert.equal(moment(a).subtract({d: 1}).calendar(), 'เมื่อวานนี้ เวลา 2 นาฬิกา 0 นาที', 'yesterday at the same time');
27802 });
27803
27804 test('calendar next week', function (assert) {
27805 var i, m;
27806 for (i = 2; i < 7; i++) {
27807 m = moment().add({d: i});
27808 assert.equal(m.calendar(), m.format('dddd[หน้า เวลา] LT'), 'Today + ' + i + ' days current time');
27809 m.hours(0).minutes(0).seconds(0).milliseconds(0);
27810 assert.equal(m.calendar(), m.format('dddd[หน้า เวลา] LT'), 'Today + ' + i + ' days beginning of day');
27811 m.hours(23).minutes(59).seconds(59).milliseconds(999);
27812 assert.equal(m.calendar(), m.format('dddd[หน้า เวลา] LT'), 'Today + ' + i + ' days end of day');
27813 }
27814 });
27815
27816 test('calendar last week', function (assert) {
27817 var i, m;
27818 for (i = 2; i < 7; i++) {
27819 m = moment().subtract({d: i});
27820 assert.equal(m.calendar(), m.format('[วัน]dddd[ที่แล้ว เวลา] LT'), 'Today - ' + i + ' days current time');
27821 m.hours(0).minutes(0).seconds(0).milliseconds(0);
27822 assert.equal(m.calendar(), m.format('[วัน]dddd[ที่แล้ว เวลา] LT'), 'Today - ' + i + ' days beginning of day');
27823 m.hours(23).minutes(59).seconds(59).milliseconds(999);
27824 assert.equal(m.calendar(), m.format('[วัน]dddd[ที่แล้ว เวลา] LT'), 'Today - ' + i + ' days end of day');
27825 }
27826 });
27827
27828 test('calendar all else', function (assert) {
27829 var weeksAgo = moment().subtract({w: 1}),
27830 weeksFromNow = moment().add({w: 1});
27831
27832 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
27833 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
27834
27835 weeksAgo = moment().subtract({w: 2});
27836 weeksFromNow = moment().add({w: 2});
27837
27838 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
27839 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
27840 });
27841
27842 test('weeks year starting sunday', function (assert) {
27843 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
27844 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
27845 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
27846 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
27847 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
27848 });
27849
27850 test('weeks year starting monday', function (assert) {
27851 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
27852 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
27853 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
27854 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
27855 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
27856 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
27857 });
27858
27859 test('weeks year starting tuesday', function (assert) {
27860 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
27861 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
27862 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
27863 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
27864 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
27865 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
27866 });
27867
27868 test('weeks year starting wednesday', function (assert) {
27869 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
27870 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
27871 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
27872 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
27873 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
27874 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
27875 });
27876
27877 test('weeks year starting thursday', function (assert) {
27878 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
27879 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
27880 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
27881 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
27882 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
27883 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
27884 });
27885
27886 test('weeks year starting friday', function (assert) {
27887 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
27888 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
27889 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
27890 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
27891 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
27892 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
27893 });
27894
27895 test('weeks year starting saturday', function (assert) {
27896 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
27897 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
27898 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
27899 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
27900 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
27901 });
27902
27903 test('weeks year starting sunday format', function (assert) {
27904 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
27905 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
27906 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
27907 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
27908 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
27909 });
27910
27911 test('lenient ordinal parsing', function (assert) {
27912 var i, ordinalStr, testMoment;
27913 for (i = 1; i <= 31; ++i) {
27914 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
27915 testMoment = moment(ordinalStr, 'YYYY MM Do');
27916 assert.equal(testMoment.year(), 2014,
27917 'lenient ordinal parsing ' + i + ' year check');
27918 assert.equal(testMoment.month(), 0,
27919 'lenient ordinal parsing ' + i + ' month check');
27920 assert.equal(testMoment.date(), i,
27921 'lenient ordinal parsing ' + i + ' date check');
27922 }
27923 });
27924
27925 test('lenient ordinal parsing of number', function (assert) {
27926 var i, testMoment;
27927 for (i = 1; i <= 31; ++i) {
27928 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
27929 assert.equal(testMoment.year(), 2014,
27930 'lenient ordinal parsing of number ' + i + ' year check');
27931 assert.equal(testMoment.month(), 0,
27932 'lenient ordinal parsing of number ' + i + ' month check');
27933 assert.equal(testMoment.date(), i,
27934 'lenient ordinal parsing of number ' + i + ' date check');
27935 }
27936 });
27937
27938 test('strict ordinal parsing', function (assert) {
27939 var i, ordinalStr, testMoment;
27940 for (i = 1; i <= 31; ++i) {
27941 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
27942 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
27943 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
27944 }
27945 });
27946
27947 }));
27948
27949 (function (global, factory) {
27950 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
27951 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
27952 factory(global.moment)
27953 }(this, function (moment) { 'use strict';
27954
27955 /*global QUnit:false*/
27956
27957 var test = QUnit.test;
27958
27959 function module (name, lifecycle) {
27960 QUnit.module(name, {
27961 setup : function () {
27962 moment.locale('en');
27963 moment.createFromInputFallback = function () {
27964 throw new Error('input not handled by moment');
27965 };
27966 if (lifecycle && lifecycle.setup) {
27967 lifecycle.setup();
27968 }
27969 },
27970 teardown : function () {
27971 if (lifecycle && lifecycle.teardown) {
27972 lifecycle.teardown();
27973 }
27974 }
27975 });
27976 }
27977
27978 function localeModule (name, lifecycle) {
27979 QUnit.module('locale:' + name, {
27980 setup : function () {
27981 moment.locale(name);
27982 moment.createFromInputFallback = function () {
27983 throw new Error('input not handled by moment');
27984 };
27985 if (lifecycle && lifecycle.setup) {
27986 lifecycle.setup();
27987 }
27988 },
27989 teardown : function () {
27990 moment.locale('en');
27991 if (lifecycle && lifecycle.teardown) {
27992 lifecycle.teardown();
27993 }
27994 }
27995 });
27996 }
27997
27998 localeModule('tl-ph');
27999
28000 test('parse', function (assert) {
28001 var tests = 'Enero Ene_Pebrero Peb_Marso Mar_Abril Abr_Mayo May_Hunyo Hun_Hulyo Hul_Agosto Ago_Setyembre Set_Oktubre Okt_Nobyembre Nob_Disyembre Dis'.split('_'),
28002 i;
28003 function equalTest(input, mmm, i) {
28004 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
28005 }
28006 for (i = 0; i < 12; i++) {
28007 tests[i] = tests[i].split(' ');
28008 equalTest(tests[i][0], 'MMM', i);
28009 equalTest(tests[i][1], 'MMM', i);
28010 equalTest(tests[i][0], 'MMMM', i);
28011 equalTest(tests[i][1], 'MMMM', i);
28012 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
28013 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
28014 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
28015 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
28016 }
28017 });
28018
28019 test('format', function (assert) {
28020 var a = [
28021 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Linggo, Pebrero 14 2010, 3:25:50 pm'],
28022 ['ddd, hA', 'Lin, 3PM'],
28023 ['M Mo MM MMMM MMM', '2 2 02 Pebrero Peb'],
28024 ['YYYY YY', '2010 10'],
28025 ['D Do DD', '14 14 14'],
28026 ['d do dddd ddd dd', '0 0 Linggo Lin Li'],
28027 ['DDD DDDo DDDD', '45 45 045'],
28028 ['w wo ww', '6 6 06'],
28029 ['h hh', '3 03'],
28030 ['H HH', '15 15'],
28031 ['m mm', '25 25'],
28032 ['s ss', '50 50'],
28033 ['a A', 'pm PM'],
28034 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
28035 ['LTS', '15:25:50'],
28036 ['L', '02/14/2010'],
28037 ['LL', 'Pebrero 14, 2010'],
28038 ['LLL', 'Pebrero 14, 2010 15:25'],
28039 ['LLLL', 'Linggo, Pebrero 14, 2010 15:25'],
28040 ['l', '2/14/2010'],
28041 ['ll', 'Peb 14, 2010'],
28042 ['lll', 'Peb 14, 2010 15:25'],
28043 ['llll', 'Lin, Peb 14, 2010 15:25']
28044 ],
28045 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
28046 i;
28047 for (i = 0; i < a.length; i++) {
28048 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
28049 }
28050 });
28051
28052 test('format ordinal', function (assert) {
28053 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
28054 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
28055 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
28056 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
28057 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
28058 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
28059 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
28060 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
28061 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
28062 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
28063
28064 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
28065 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
28066 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
28067 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
28068 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
28069 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
28070 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
28071 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
28072 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
28073 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
28074
28075 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
28076 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
28077 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
28078 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
28079 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
28080 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
28081 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
28082 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
28083 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
28084 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
28085
28086 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
28087 });
28088
28089 test('format month', function (assert) {
28090 var expected = 'Enero Ene_Pebrero Peb_Marso Mar_Abril Abr_Mayo May_Hunyo Hun_Hulyo Hul_Agosto Ago_Setyembre Set_Oktubre Okt_Nobyembre Nob_Disyembre Dis'.split('_'), i;
28091 for (i = 0; i < expected.length; i++) {
28092 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
28093 }
28094 });
28095
28096 test('format week', function (assert) {
28097 var expected = 'Linggo Lin Li_Lunes Lun Lu_Martes Mar Ma_Miyerkules Miy Mi_Huwebes Huw Hu_Biyernes Biy Bi_Sabado Sab Sab'.split('_'), i;
28098 for (i = 0; i < expected.length; i++) {
28099 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
28100 }
28101 });
28102
28103 test('from', function (assert) {
28104 var start = moment([2007, 1, 28]);
28105 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ilang segundo', '44 seconds = a few seconds');
28106 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'isang minuto', '45 seconds = a minute');
28107 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'isang minuto', '89 seconds = a minute');
28108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuto', '90 seconds = 2 minutes');
28109 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuto', '44 minutes = 44 minutes');
28110 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'isang oras', '45 minutes = an hour');
28111 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'isang oras', '89 minutes = an hour');
28112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 oras', '90 minutes = 2 hours');
28113 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 oras', '5 hours = 5 hours');
28114 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 oras', '21 hours = 21 hours');
28115 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'isang araw', '22 hours = a day');
28116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'isang araw', '35 hours = a day');
28117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 araw', '36 hours = 2 days');
28118 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'isang araw', '1 day = a day');
28119 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 araw', '5 days = 5 days');
28120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 araw', '25 days = 25 days');
28121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'isang buwan', '26 days = a month');
28122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'isang buwan', '30 days = a month');
28123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'isang buwan', '43 days = a month');
28124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 buwan', '46 days = 2 months');
28125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 buwan', '75 days = 2 months');
28126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 buwan', '76 days = 3 months');
28127 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'isang buwan', '1 month = a month');
28128 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 buwan', '5 months = 5 months');
28129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'isang taon', '345 days = a year');
28130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 taon', '548 days = 2 years');
28131 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'isang taon', '1 year = a year');
28132 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 taon', '5 years = 5 years');
28133 });
28134
28135 test('suffix', function (assert) {
28136 assert.equal(moment(30000).from(0), 'sa loob ng ilang segundo', 'prefix');
28137 assert.equal(moment(0).from(30000), 'ilang segundo ang nakalipas', 'suffix');
28138 });
28139
28140 test('fromNow', function (assert) {
28141 assert.equal(moment().add({s: 30}).fromNow(), 'sa loob ng ilang segundo', 'in a few seconds');
28142 assert.equal(moment().add({d: 5}).fromNow(), 'sa loob ng 5 araw', 'in 5 days');
28143 });
28144
28145 test('same day', function (assert) {
28146 var a = moment().hours(2).minutes(0).seconds(0);
28147
28148 assert.equal(moment(a).calendar(), 'Ngayon sa 02:00', 'today at the same time');
28149 assert.equal(moment(a).add({m: 25}).calendar(), 'Ngayon sa 02:25', 'Now plus 25 min');
28150 assert.equal(moment(a).add({h: 1}).calendar(), 'Ngayon sa 03:00', 'Now plus 1 hour');
28151 assert.equal(moment(a).add({d: 1}).calendar(), 'Bukas sa 02:00', 'tomorrow at the same time');
28152 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ngayon sa 01:00', 'Now minus 1 hour');
28153 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kahapon sa 02:00', 'yesterday at the same time');
28154 });
28155
28156 test('same next week', function (assert) {
28157 var i, m;
28158
28159 for (i = 2; i < 7; i++) {
28160 m = moment().add({d: i});
28161 assert.equal(m.calendar(), m.format('dddd [sa] LT'), 'Today + ' + i + ' days current time');
28162 m.hours(0).minutes(0).seconds(0).milliseconds(0);
28163 assert.equal(m.calendar(), m.format('dddd [sa] LT'), 'Today + ' + i + ' days beginning of day');
28164 m.hours(23).minutes(59).seconds(59).milliseconds(999);
28165 assert.equal(m.calendar(), m.format('dddd [sa] LT'), 'Today + ' + i + ' days end of day');
28166 }
28167 });
28168
28169 test('same last week', function (assert) {
28170 var i, m;
28171
28172 for (i = 2; i < 7; i++) {
28173 m = moment().subtract({d: i});
28174 assert.equal(m.calendar(), m.format('dddd [huling linggo] LT'), 'Today - ' + i + ' days current time');
28175 m.hours(0).minutes(0).seconds(0).milliseconds(0);
28176 assert.equal(m.calendar(), m.format('dddd [huling linggo] LT'), 'Today - ' + i + ' days beginning of day');
28177 m.hours(23).minutes(59).seconds(59).milliseconds(999);
28178 assert.equal(m.calendar(), m.format('dddd [huling linggo] LT'), 'Today - ' + i + ' days end of day');
28179 }
28180 });
28181
28182 test('same all else', function (assert) {
28183 var weeksAgo = moment().subtract({w: 1}),
28184 weeksFromNow = moment().add({w: 1});
28185
28186 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
28187 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
28188
28189 weeksAgo = moment().subtract({w: 2});
28190 weeksFromNow = moment().add({w: 2});
28191
28192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
28193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
28194 });
28195
28196 test('weeks year starting sunday', function (assert) {
28197 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
28198 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
28199 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
28200 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
28201 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
28202 });
28203
28204 test('weeks year starting monday', function (assert) {
28205 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
28206 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
28207 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
28208 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
28209 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
28210 });
28211
28212 test('weeks year starting tuesday', function (assert) {
28213 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
28214 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
28215 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
28216 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
28217 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
28218 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
28219 });
28220
28221 test('weeks year starting wednesday', function (assert) {
28222 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
28223 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
28224 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
28225 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
28226 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
28227 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
28228 });
28229
28230 test('weeks year starting thursday', function (assert) {
28231 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
28232 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
28233 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
28234 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
28235 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
28236 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
28237 });
28238
28239 test('weeks year starting friday', function (assert) {
28240 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
28241 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
28242 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
28243 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
28244 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
28245 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
28246 });
28247
28248 test('weeks year starting saturday', function (assert) {
28249 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
28250 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
28251 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
28252 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
28253 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
28254 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
28255 });
28256
28257 test('weeks year starting sunday formatted', function (assert) {
28258 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
28259 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
28260 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
28261 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
28262 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
28263 });
28264
28265 test('lenient ordinal parsing', function (assert) {
28266 var i, ordinalStr, testMoment;
28267 for (i = 1; i <= 31; ++i) {
28268 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
28269 testMoment = moment(ordinalStr, 'YYYY MM Do');
28270 assert.equal(testMoment.year(), 2014,
28271 'lenient ordinal parsing ' + i + ' year check');
28272 assert.equal(testMoment.month(), 0,
28273 'lenient ordinal parsing ' + i + ' month check');
28274 assert.equal(testMoment.date(), i,
28275 'lenient ordinal parsing ' + i + ' date check');
28276 }
28277 });
28278
28279 test('lenient ordinal parsing of number', function (assert) {
28280 var i, testMoment;
28281 for (i = 1; i <= 31; ++i) {
28282 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
28283 assert.equal(testMoment.year(), 2014,
28284 'lenient ordinal parsing of number ' + i + ' year check');
28285 assert.equal(testMoment.month(), 0,
28286 'lenient ordinal parsing of number ' + i + ' month check');
28287 assert.equal(testMoment.date(), i,
28288 'lenient ordinal parsing of number ' + i + ' date check');
28289 }
28290 });
28291
28292 test('strict ordinal parsing', function (assert) {
28293 var i, ordinalStr, testMoment;
28294 for (i = 1; i <= 31; ++i) {
28295 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
28296 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
28297 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
28298 }
28299 });
28300
28301 }));
28302
28303 (function (global, factory) {
28304 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
28305 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
28306 factory(global.moment)
28307 }(this, function (moment) { 'use strict';
28308
28309 /*global QUnit:false*/
28310
28311 var test = QUnit.test;
28312
28313 function module (name, lifecycle) {
28314 QUnit.module(name, {
28315 setup : function () {
28316 moment.locale('en');
28317 moment.createFromInputFallback = function () {
28318 throw new Error('input not handled by moment');
28319 };
28320 if (lifecycle && lifecycle.setup) {
28321 lifecycle.setup();
28322 }
28323 },
28324 teardown : function () {
28325 if (lifecycle && lifecycle.teardown) {
28326 lifecycle.teardown();
28327 }
28328 }
28329 });
28330 }
28331
28332 function localeModule (name, lifecycle) {
28333 QUnit.module('locale:' + name, {
28334 setup : function () {
28335 moment.locale(name);
28336 moment.createFromInputFallback = function () {
28337 throw new Error('input not handled by moment');
28338 };
28339 if (lifecycle && lifecycle.setup) {
28340 lifecycle.setup();
28341 }
28342 },
28343 teardown : function () {
28344 moment.locale('en');
28345 if (lifecycle && lifecycle.teardown) {
28346 lifecycle.teardown();
28347 }
28348 }
28349 });
28350 }
28351
28352 localeModule('tr');
28353
28354 test('parse', function (assert) {
28355 var tests = 'Ocak Oca_Şubat Şub_Mart Mar_Nisan Nis_Mayıs May_Haziran Haz_Temmuz Tem_Ağustos Ağu_Eylül Eyl_Ekim Eki_Kasım Kas_Aralık Ara'.split('_'), i;
28356 function equalTest(input, mmm, i) {
28357 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
28358 }
28359 for (i = 0; i < 12; i++) {
28360 tests[i] = tests[i].split(' ');
28361 equalTest(tests[i][0], 'MMM', i);
28362 equalTest(tests[i][1], 'MMM', i);
28363 equalTest(tests[i][0], 'MMMM', i);
28364 equalTest(tests[i][1], 'MMMM', i);
28365 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
28366 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
28367 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
28368 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
28369 }
28370 });
28371
28372 test('format', function (assert) {
28373 var a = [
28374 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Pazar, Şubat 14\'üncü 2010, 3:25:50 pm'],
28375 ['ddd, hA', 'Paz, 3PM'],
28376 ['M Mo MM MMMM MMM', '2 2\'nci 02 Şubat Şub'],
28377 ['YYYY YY', '2010 10'],
28378 ['D Do DD', '14 14\'üncü 14'],
28379 ['d do dddd ddd dd', '0 0\'ıncı Pazar Paz Pz'],
28380 ['DDD DDDo DDDD', '45 45\'inci 045'],
28381 ['w wo ww', '7 7\'nci 07'],
28382 ['h hh', '3 03'],
28383 ['H HH', '15 15'],
28384 ['m mm', '25 25'],
28385 ['s ss', '50 50'],
28386 ['a A', 'pm PM'],
28387 ['[yılın] DDDo [günü]', 'yılın 45\'inci günü'],
28388 ['LTS', '15:25:50'],
28389 ['L', '14.02.2010'],
28390 ['LL', '14 Şubat 2010'],
28391 ['LLL', '14 Şubat 2010 15:25'],
28392 ['LLLL', 'Pazar, 14 Şubat 2010 15:25'],
28393 ['l', '14.2.2010'],
28394 ['ll', '14 Şub 2010'],
28395 ['lll', '14 Şub 2010 15:25'],
28396 ['llll', 'Paz, 14 Şub 2010 15:25']
28397 ],
28398 DDDo = [
28399 [359, '360\'ıncı'],
28400 [199, '200\'üncü'],
28401 [149, '150\'nci']
28402 ],
28403 dt = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
28404 DDDoDt,
28405 i;
28406
28407 for (i = 0; i < a.length; i++) {
28408 assert.equal(dt.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
28409 }
28410 for (i = 0; i < DDDo.length; i++) {
28411 DDDoDt = moment([2010]);
28412 assert.equal(DDDoDt.add(DDDo[i][0], 'days').format('DDDo'), DDDo[i][1], DDDo[i][0] + ' ---> ' + DDDo[i][1]);
28413 }
28414 });
28415
28416 test('format ordinal', function (assert) {
28417 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1\'inci', '1st');
28418 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2\'nci', '2nd');
28419 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3\'üncü', '3rd');
28420 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4\'üncü', '4th');
28421 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5\'inci', '5th');
28422 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6\'ncı', '6th');
28423 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7\'nci', '7th');
28424 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8\'inci', '8th');
28425 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9\'uncu', '9th');
28426 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10\'uncu', '10th');
28427
28428 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11\'inci', '11th');
28429 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12\'nci', '12th');
28430 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13\'üncü', '13th');
28431 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14\'üncü', '14th');
28432 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15\'inci', '15th');
28433 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16\'ncı', '16th');
28434 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17\'nci', '17th');
28435 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18\'inci', '18th');
28436 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19\'uncu', '19th');
28437 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20\'nci', '20th');
28438
28439 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21\'inci', '21th');
28440 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22\'nci', '22th');
28441 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23\'üncü', '23th');
28442 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24\'üncü', '24th');
28443 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25\'inci', '25th');
28444 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26\'ncı', '26th');
28445 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27\'nci', '27th');
28446 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28\'inci', '28th');
28447 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29\'uncu', '29th');
28448 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30\'uncu', '30th');
28449
28450 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31\'inci', '31st');
28451 });
28452
28453 test('format month', function (assert) {
28454 var expected = 'Ocak Oca_Şubat Şub_Mart Mar_Nisan Nis_Mayıs May_Haziran Haz_Temmuz Tem_Ağustos Ağu_Eylül Eyl_Ekim Eki_Kasım Kas_Aralık Ara'.split('_'), i;
28455 for (i = 0; i < expected.length; i++) {
28456 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
28457 }
28458 });
28459
28460 test('format week', function (assert) {
28461 var expected = 'Pazar Paz Pz_Pazartesi Pts Pt_Salı Sal Sa_Çarşamba Çar Ça_Perşembe Per Pe_Cuma Cum Cu_Cumartesi Cts Ct'.split('_'), i;
28462 for (i = 0; i < expected.length; i++) {
28463 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
28464 }
28465 });
28466
28467 test('from', function (assert) {
28468 var start = moment([2007, 1, 28]);
28469 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'birkaç saniye', '44 seconds = a few seconds');
28470 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'bir dakika', '45 seconds = a minute');
28471 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'bir dakika', '89 seconds = a minute');
28472 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 dakika', '90 seconds = 2 minutes');
28473 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 dakika', '44 minutes = 44 minutes');
28474 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'bir saat', '45 minutes = an hour');
28475 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'bir saat', '89 minutes = an hour');
28476 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 saat', '90 minutes = 2 hours');
28477 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 saat', '5 hours = 5 hours');
28478 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 saat', '21 hours = 21 hours');
28479 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'bir gün', '22 hours = a day');
28480 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'bir gün', '35 hours = a day');
28481 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 gün', '36 hours = 2 days');
28482 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'bir gün', '1 day = a day');
28483 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 gün', '5 days = 5 days');
28484 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 gün', '25 days = 25 days');
28485 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'bir ay', '26 days = a month');
28486 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'bir ay', '30 days = a month');
28487 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'bir ay', '43 days = a month');
28488 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ay', '46 days = 2 months');
28489 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ay', '75 days = 2 months');
28490 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ay', '76 days = 3 months');
28491 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'bir ay', '1 month = a month');
28492 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ay', '5 months = 5 months');
28493 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'bir yıl', '345 days = a year');
28494 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 yıl', '548 days = 2 years');
28495 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'bir yıl', '1 year = a year');
28496 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 yıl', '5 years = 5 years');
28497 });
28498
28499 test('suffix', function (assert) {
28500 assert.equal(moment(30000).from(0), 'birkaç saniye sonra', 'prefix');
28501 assert.equal(moment(0).from(30000), 'birkaç saniye önce', 'suffix');
28502 });
28503
28504 test('now from now', function (assert) {
28505 assert.equal(moment().fromNow(), 'birkaç saniye önce', 'now from now should display as in the past');
28506 });
28507
28508 test('fromNow', function (assert) {
28509 assert.equal(moment().add({s: 30}).fromNow(), 'birkaç saniye sonra', 'in a few seconds');
28510 assert.equal(moment().add({d: 5}).fromNow(), '5 gün sonra', 'in 5 days');
28511 });
28512
28513 test('calendar day', function (assert) {
28514 var a = moment().hours(2).minutes(0).seconds(0);
28515
28516 assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
28517 assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
28518 assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
28519 assert.equal(moment(a).add({d: 1}).calendar(), 'yarın saat 02:00', 'tomorrow at the same time');
28520 assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
28521 assert.equal(moment(a).subtract({d: 1}).calendar(), 'dün 02:00', 'yesterday at the same time');
28522 });
28523
28524 test('calendar next week', function (assert) {
28525 var i, m;
28526 for (i = 2; i < 7; i++) {
28527 m = moment().add({d: i});
28528 assert.equal(m.calendar(), m.format('[haftaya] dddd [saat] LT'), 'Today + ' + i + ' days current time');
28529 m.hours(0).minutes(0).seconds(0).milliseconds(0);
28530 assert.equal(m.calendar(), m.format('[haftaya] dddd [saat] LT'), 'Today + ' + i + ' days beginning of day');
28531 m.hours(23).minutes(59).seconds(59).milliseconds(999);
28532 assert.equal(m.calendar(), m.format('[haftaya] dddd [saat] LT'), 'Today + ' + i + ' days end of day');
28533 }
28534 });
28535
28536 test('calendar last week', function (assert) {
28537 var i, m;
28538 for (i = 2; i < 7; i++) {
28539 m = moment().subtract({d: i});
28540 assert.equal(m.calendar(), m.format('[geçen hafta] dddd [saat] LT'), 'Today - ' + i + ' days current time');
28541 m.hours(0).minutes(0).seconds(0).milliseconds(0);
28542 assert.equal(m.calendar(), m.format('[geçen hafta] dddd [saat] LT'), 'Today - ' + i + ' days beginning of day');
28543 m.hours(23).minutes(59).seconds(59).milliseconds(999);
28544 assert.equal(m.calendar(), m.format('[geçen hafta] dddd [saat] LT'), 'Today - ' + i + ' days end of day');
28545 }
28546 });
28547
28548 test('calendar all else', function (assert) {
28549 var weeksAgo = moment().subtract({w: 1}),
28550 weeksFromNow = moment().add({w: 1});
28551
28552 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
28553 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
28554
28555 weeksAgo = moment().subtract({w: 2});
28556 weeksFromNow = moment().add({w: 2});
28557
28558 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
28559 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
28560 });
28561
28562 test('weeks year starting sunday', function (assert) {
28563 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
28564 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
28565 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
28566 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
28567 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
28568 });
28569
28570 test('weeks year starting monday', function (assert) {
28571 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
28572 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
28573 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
28574 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
28575 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
28576 });
28577
28578 test('weeks year starting tuesday', function (assert) {
28579 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
28580 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
28581 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
28582 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
28583 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
28584 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
28585 });
28586
28587 test('weeks year starting wednesday', function (assert) {
28588 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
28589 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
28590 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
28591 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
28592 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
28593 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
28594 });
28595
28596 test('weeks year starting thursday', function (assert) {
28597 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
28598 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
28599 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
28600 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
28601 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
28602 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
28603 });
28604
28605 test('weeks year starting friday', function (assert) {
28606 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
28607 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
28608 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
28609 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
28610 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
28611 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
28612 });
28613
28614 test('weeks year starting saturday', function (assert) {
28615 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
28616 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
28617 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
28618 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
28619 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
28620 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
28621 });
28622
28623 test('weeks year starting sunday formatted', function (assert) {
28624 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1\'inci', 'Dec 26 2011 should be week 1');
28625 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1\'inci', 'Jan 1 2012 should be week 1');
28626 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2\'nci', 'Jan 2 2012 should be week 2');
28627 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2\'nci', 'Jan 8 2012 should be week 2');
28628 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3\'üncü', 'Jan 9 2012 should be week 3');
28629 });
28630
28631 test('lenient ordinal parsing', function (assert) {
28632 var i, ordinalStr, testMoment;
28633 for (i = 1; i <= 31; ++i) {
28634 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
28635 testMoment = moment(ordinalStr, 'YYYY MM Do');
28636 assert.equal(testMoment.year(), 2014,
28637 'lenient ordinal parsing ' + i + ' year check');
28638 assert.equal(testMoment.month(), 0,
28639 'lenient ordinal parsing ' + i + ' month check');
28640 assert.equal(testMoment.date(), i,
28641 'lenient ordinal parsing ' + i + ' date check');
28642 }
28643 });
28644
28645 test('lenient ordinal parsing of number', function (assert) {
28646 var i, testMoment;
28647 for (i = 1; i <= 31; ++i) {
28648 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
28649 assert.equal(testMoment.year(), 2014,
28650 'lenient ordinal parsing of number ' + i + ' year check');
28651 assert.equal(testMoment.month(), 0,
28652 'lenient ordinal parsing of number ' + i + ' month check');
28653 assert.equal(testMoment.date(), i,
28654 'lenient ordinal parsing of number ' + i + ' date check');
28655 }
28656 });
28657
28658 test('strict ordinal parsing', function (assert) {
28659 var i, ordinalStr, testMoment;
28660 for (i = 1; i <= 31; ++i) {
28661 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
28662 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
28663 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
28664 }
28665 });
28666
28667 }));
28668
28669 (function (global, factory) {
28670 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
28671 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
28672 factory(global.moment)
28673 }(this, function (moment) { 'use strict';
28674
28675 /*global QUnit:false*/
28676
28677 var test = QUnit.test;
28678
28679 function module (name, lifecycle) {
28680 QUnit.module(name, {
28681 setup : function () {
28682 moment.locale('en');
28683 moment.createFromInputFallback = function () {
28684 throw new Error('input not handled by moment');
28685 };
28686 if (lifecycle && lifecycle.setup) {
28687 lifecycle.setup();
28688 }
28689 },
28690 teardown : function () {
28691 if (lifecycle && lifecycle.teardown) {
28692 lifecycle.teardown();
28693 }
28694 }
28695 });
28696 }
28697
28698 function localeModule (name, lifecycle) {
28699 QUnit.module('locale:' + name, {
28700 setup : function () {
28701 moment.locale(name);
28702 moment.createFromInputFallback = function () {
28703 throw new Error('input not handled by moment');
28704 };
28705 if (lifecycle && lifecycle.setup) {
28706 lifecycle.setup();
28707 }
28708 },
28709 teardown : function () {
28710 moment.locale('en');
28711 if (lifecycle && lifecycle.teardown) {
28712 lifecycle.teardown();
28713 }
28714 }
28715 });
28716 }
28717
28718 localeModule('tzl');
28719
28720 test('parse', function (assert) {
28721 var tests = 'Januar Jan_Fevraglh Fev_Març Mar_Avrïu Avr_Mai Mai_Gün Gün_Julia Jul_Guscht Gus_Setemvar Set_Listopäts Lis_Noemvar Noe_Zecemvar Zec'.split('_'), i;
28722 function equalTest(input, mmm, i) {
28723 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
28724 }
28725 for (i = 0; i < 12; i++) {
28726 tests[i] = tests[i].split(' ');
28727 equalTest(tests[i][0], 'MMM', i);
28728 equalTest(tests[i][1], 'MMM', i);
28729 equalTest(tests[i][0], 'MMMM', i);
28730 equalTest(tests[i][1], 'MMMM', i);
28731 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
28732 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
28733 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
28734 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
28735 }
28736 });
28737
28738 test('format', function (assert) {
28739 var a = [
28740 ['dddd, MMMM Do YYYY, h.mm.ss a', 'Súladi, Fevraglh 14. 2010, 3.25.50 d\'o'],
28741 ['ddd, hA', 'Súl, 3D\'O'],
28742 ['M Mo MM MMMM MMM', '2 2. 02 Fevraglh Fev'],
28743 ['YYYY YY', '2010 10'],
28744 ['D Do DD', '14 14. 14'],
28745 ['d do dddd ddd dd', '0 0. Súladi Súl Sú'],
28746 ['DDD DDDo DDDD', '45 45. 045'],
28747 ['w wo ww', '6 6. 06'],
28748 ['h hh', '3 03'],
28749 ['H HH', '15 15'],
28750 ['m mm', '25 25'],
28751 ['s ss', '50 50'],
28752 ['a A', 'd\'o D\'O'],
28753 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
28754 ['LTS', '15.25.50'],
28755 ['L', '14.02.2010'],
28756 ['LL', '14. Fevraglh dallas 2010'],
28757 ['LLL', '14. Fevraglh dallas 2010 15.25'],
28758 ['LLLL', 'Súladi, li 14. Fevraglh dallas 2010 15.25'],
28759 ['l', '14.2.2010'],
28760 ['ll', '14. Fev dallas 2010'],
28761 ['lll', '14. Fev dallas 2010 15.25'],
28762 ['llll', 'Súl, li 14. Fev dallas 2010 15.25']
28763 ],
28764 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
28765 i;
28766 for (i = 0; i < a.length; i++) {
28767 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
28768 }
28769 });
28770
28771 test('format ordinal', function (assert) {
28772 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
28773 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
28774 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
28775 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
28776 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
28777 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
28778 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
28779 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
28780 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
28781 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
28782
28783 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
28784 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
28785 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
28786 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
28787 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
28788 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
28789 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
28790 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
28791 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
28792 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
28793
28794 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
28795 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
28796 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
28797 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
28798 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
28799 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
28800 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
28801 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
28802 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
28803 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
28804
28805 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
28806 });
28807
28808 test('format month', function (assert) {
28809 var expected = 'Januar Jan_Fevraglh Fev_Març Mar_Avrïu Avr_Mai Mai_Gün Gün_Julia Jul_Guscht Gus_Setemvar Set_Listopäts Lis_Noemvar Noe_Zecemvar Zec'.split('_'), i;
28810 for (i = 0; i < expected.length; i++) {
28811 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
28812 }
28813 });
28814
28815 test('format week', function (assert) {
28816 var expected = 'Súladi Súl Sú_Lúneçi Lún Lú_Maitzi Mai Ma_Márcuri Már Má_Xhúadi Xhú Xh_Viénerçi Vié Vi_Sáturi Sát Sá'.split('_'), i;
28817 for (i = 0; i < expected.length; i++) {
28818 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
28819 }
28820 });
28821
28822 test('from', function (assert) {
28823 var start = moment([2007, 1, 28]);
28824 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'viensas secunds', '44 seconds = a few seconds');
28825 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '\'n míut', '45 seconds = a minute');
28826 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '\'n míut', '89 seconds = a minute');
28827 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 míuts', '90 seconds = 2 minutes');
28828 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 míuts', '44 minutes = 44 minutes');
28829 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '\'n þora', '45 minutes = an hour');
28830 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '\'n þora', '89 minutes = an hour');
28831 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 þoras', '90 minutes = 2 hours');
28832 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 þoras', '5 hours = 5 hours');
28833 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 þoras', '21 hours = 21 hours');
28834 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '\'n ziua', '22 hours = a day');
28835 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '\'n ziua', '35 hours = a day');
28836 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ziuas', '36 hours = 2 days');
28837 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '\'n ziua', '1 day = a day');
28838 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ziuas', '5 days = 5 days');
28839 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ziuas', '25 days = 25 days');
28840 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '\'n mes', '26 days = a month');
28841 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '\'n mes', '30 days = a month');
28842 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '\'n mes', '43 days = a month');
28843 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesen', '46 days = 2 months');
28844 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesen', '75 days = 2 months');
28845 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesen', '76 days = 3 months');
28846 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '\'n mes', '1 month = a month');
28847 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesen', '5 months = 5 months');
28848 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '\'n ar', '345 days = a year');
28849 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ars', '548 days = 2 years');
28850 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '\'n ar', '1 year = a year');
28851 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ars', '5 years = 5 years');
28852 });
28853
28854 test('suffix', function (assert) {
28855 assert.equal(moment(30000).from(0), 'osprei viensas secunds', 'prefix');
28856 assert.equal(moment(0).from(30000), 'ja\'iensas secunds', 'suffix');
28857 });
28858
28859 test('now from now', function (assert) {
28860 assert.equal(moment().fromNow(), 'ja\'iensas secunds', 'now from now should display as in the past');
28861 });
28862
28863 test('fromNow', function (assert) {
28864 assert.equal(moment().add({s: 30}).fromNow(), 'osprei viensas secunds', 'in a few seconds');
28865 assert.equal(moment().add({d: 5}).fromNow(), 'osprei 5 ziuas', 'in 5 days');
28866 });
28867
28868 test('calendar day', function (assert) {
28869 var a = moment().hours(2).minutes(0).seconds(0);
28870
28871 assert.equal(moment(a).calendar(), 'oxhi à 02.00', 'today at the same time');
28872 assert.equal(moment(a).add({m: 25}).calendar(), 'oxhi à 02.25', 'Now plus 25 min');
28873 assert.equal(moment(a).add({h: 1}).calendar(), 'oxhi à 03.00', 'Now plus 1 hour');
28874 assert.equal(moment(a).add({d: 1}).calendar(), 'demà à 02.00', 'tomorrow at the same time');
28875 assert.equal(moment(a).subtract({h: 1}).calendar(), 'oxhi à 01.00', 'Now minus 1 hour');
28876 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieiri à 02.00', 'yesterday at the same time');
28877 });
28878
28879 test('calendar next week', function (assert) {
28880 var i, m;
28881 for (i = 2; i < 7; i++) {
28882 m = moment().add({d: i});
28883 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time');
28884 m.hours(0).minutes(0).seconds(0).milliseconds(0);
28885 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day');
28886 m.hours(23).minutes(59).seconds(59).milliseconds(999);
28887 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day');
28888 }
28889 });
28890
28891 test('calendar last week', function (assert) {
28892 var i, m;
28893
28894 for (i = 2; i < 7; i++) {
28895 m = moment().subtract({d: i});
28896 assert.equal(m.calendar(), m.format('[sür el] dddd [lasteu à] LT'), 'Today - ' + i + ' days current time');
28897 m.hours(0).minutes(0).seconds(0).milliseconds(0);
28898 assert.equal(m.calendar(), m.format('[sür el] dddd [lasteu à] LT'), 'Today - ' + i + ' days beginning of day');
28899 m.hours(23).minutes(59).seconds(59).milliseconds(999);
28900 assert.equal(m.calendar(), m.format('[sür el] dddd [lasteu à] LT'), 'Today - ' + i + ' days end of day');
28901 }
28902 });
28903
28904 test('calendar all else', function (assert) {
28905 var weeksAgo = moment().subtract({w: 1}),
28906 weeksFromNow = moment().add({w: 1});
28907
28908 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
28909 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
28910
28911 weeksAgo = moment().subtract({w: 2});
28912 weeksFromNow = moment().add({w: 2});
28913
28914 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
28915 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
28916 });
28917
28918 // Monday is the first day of the week.
28919 // The week that contains Jan 4th is the first week of the year.
28920
28921 test('weeks year starting sunday', function (assert) {
28922 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
28923 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
28924 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
28925 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
28926 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
28927 });
28928
28929 test('weeks year starting monday', function (assert) {
28930 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
28931 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
28932 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
28933 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
28934 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
28935 });
28936
28937 test('weeks year starting tuesday', function (assert) {
28938 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
28939 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
28940 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
28941 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
28942 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
28943 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
28944 });
28945
28946 test('weeks year starting wednesday', function (assert) {
28947 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
28948 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
28949 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
28950 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
28951 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
28952 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
28953 });
28954
28955 test('weeks year starting thursday', function (assert) {
28956 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
28957 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
28958 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
28959 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
28960 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
28961 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
28962 });
28963
28964 test('weeks year starting friday', function (assert) {
28965 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
28966 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
28967 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
28968 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
28969 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
28970 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
28971 });
28972
28973 test('weeks year starting saturday', function (assert) {
28974 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
28975 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
28976 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
28977 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
28978 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
28979 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
28980 });
28981
28982 test('weeks year starting sunday formatted', function (assert) {
28983 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
28984 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
28985 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
28986 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
28987 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
28988 });
28989
28990 test('lenient ordinal parsing', function (assert) {
28991 var i, ordinalStr, testMoment;
28992 for (i = 1; i <= 31; ++i) {
28993 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
28994 testMoment = moment(ordinalStr, 'YYYY MM Do');
28995 assert.equal(testMoment.year(), 2014,
28996 'lenient ordinal parsing ' + i + ' year check');
28997 assert.equal(testMoment.month(), 0,
28998 'lenient ordinal parsing ' + i + ' month check');
28999 assert.equal(testMoment.date(), i,
29000 'lenient ordinal parsing ' + i + ' date check');
29001 }
29002 });
29003
29004 test('lenient ordinal parsing of number', function (assert) {
29005 var i, testMoment;
29006 for (i = 1; i <= 31; ++i) {
29007 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
29008 assert.equal(testMoment.year(), 2014,
29009 'lenient ordinal parsing of number ' + i + ' year check');
29010 assert.equal(testMoment.month(), 0,
29011 'lenient ordinal parsing of number ' + i + ' month check');
29012 assert.equal(testMoment.date(), i,
29013 'lenient ordinal parsing of number ' + i + ' date check');
29014 }
29015 });
29016
29017 test('strict ordinal parsing', function (assert) {
29018 var i, ordinalStr, testMoment;
29019 for (i = 1; i <= 31; ++i) {
29020 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
29021 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
29022 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
29023 }
29024 });
29025
29026 }));
29027
29028 (function (global, factory) {
29029 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
29030 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
29031 factory(global.moment)
29032 }(this, function (moment) { 'use strict';
29033
29034 /*global QUnit:false*/
29035
29036 var test = QUnit.test;
29037
29038 function module (name, lifecycle) {
29039 QUnit.module(name, {
29040 setup : function () {
29041 moment.locale('en');
29042 moment.createFromInputFallback = function () {
29043 throw new Error('input not handled by moment');
29044 };
29045 if (lifecycle && lifecycle.setup) {
29046 lifecycle.setup();
29047 }
29048 },
29049 teardown : function () {
29050 if (lifecycle && lifecycle.teardown) {
29051 lifecycle.teardown();
29052 }
29053 }
29054 });
29055 }
29056
29057 function localeModule (name, lifecycle) {
29058 QUnit.module('locale:' + name, {
29059 setup : function () {
29060 moment.locale(name);
29061 moment.createFromInputFallback = function () {
29062 throw new Error('input not handled by moment');
29063 };
29064 if (lifecycle && lifecycle.setup) {
29065 lifecycle.setup();
29066 }
29067 },
29068 teardown : function () {
29069 moment.locale('en');
29070 if (lifecycle && lifecycle.teardown) {
29071 lifecycle.teardown();
29072 }
29073 }
29074 });
29075 }
29076
29077 localeModule('tzm-latn');
29078
29079 test('parse', function (assert) {
29080 var tests = 'innayr innayr_brˤayrˤ brˤayrˤ_marˤsˤ marˤsˤ_ibrir ibrir_mayyw mayyw_ywnyw ywnyw_ywlywz ywlywz_ɣwšt ɣwšt_šwtanbir šwtanbir_ktˤwbrˤ ktˤwbrˤ_nwwanbir nwwanbir_dwjnbir dwjnbir'.split('_'), i;
29081 function equalTest(input, mmm, i) {
29082 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
29083 }
29084 for (i = 0; i < 12; i++) {
29085 tests[i] = tests[i].split(' ');
29086 equalTest(tests[i][0], 'MMM', i);
29087 equalTest(tests[i][1], 'MMM', i);
29088 equalTest(tests[i][0], 'MMMM', i);
29089 equalTest(tests[i][1], 'MMMM', i);
29090 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
29091 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
29092 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
29093 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
29094 }
29095 });
29096
29097 test('format', function (assert) {
29098 var a = [
29099 ['dddd, MMMM Do YYYY, h:mm:ss a', 'asamas, brˤayrˤ 14 2010, 3:25:50 pm'],
29100 ['ddd, hA', 'asamas, 3PM'],
29101 ['M Mo MM MMMM MMM', '2 2 02 brˤayrˤ brˤayrˤ'],
29102 ['YYYY YY', '2010 10'],
29103 ['D Do DD', '14 14 14'],
29104 ['d do dddd ddd dd', '0 0 asamas asamas asamas'],
29105 ['DDD DDDo DDDD', '45 45 045'],
29106 ['w wo ww', '8 8 08'],
29107 ['h hh', '3 03'],
29108 ['H HH', '15 15'],
29109 ['m mm', '25 25'],
29110 ['s ss', '50 50'],
29111 ['a A', 'pm PM'],
29112 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
29113 ['LTS', '15:25:50'],
29114 ['L', '14/02/2010'],
29115 ['LL', '14 brˤayrˤ 2010'],
29116 ['LLL', '14 brˤayrˤ 2010 15:25'],
29117 ['LLLL', 'asamas 14 brˤayrˤ 2010 15:25'],
29118 ['l', '14/2/2010'],
29119 ['ll', '14 brˤayrˤ 2010'],
29120 ['lll', '14 brˤayrˤ 2010 15:25'],
29121 ['llll', 'asamas 14 brˤayrˤ 2010 15:25']
29122 ],
29123 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
29124 i;
29125 for (i = 0; i < a.length; i++) {
29126 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
29127 }
29128 });
29129
29130 test('format ordinal', function (assert) {
29131 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
29132 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
29133 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
29134 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
29135 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
29136 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
29137 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
29138 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
29139 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
29140 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
29141
29142 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
29143 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
29144 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
29145 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
29146 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
29147 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
29148 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
29149 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
29150 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
29151 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
29152
29153 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
29154 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
29155 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
29156 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
29157 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
29158 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
29159 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
29160 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
29161 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
29162 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
29163
29164 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
29165 });
29166
29167 test('format month', function (assert) {
29168 var expected = 'innayr innayr_brˤayrˤ brˤayrˤ_marˤsˤ marˤsˤ_ibrir ibrir_mayyw mayyw_ywnyw ywnyw_ywlywz ywlywz_ɣwšt ɣwšt_šwtanbir šwtanbir_ktˤwbrˤ ktˤwbrˤ_nwwanbir nwwanbir_dwjnbir dwjnbir'.split('_'), i;
29169 for (i = 0; i < expected.length; i++) {
29170 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
29171 }
29172 });
29173
29174 test('format week', function (assert) {
29175 var expected = 'asamas asamas asamas_aynas aynas aynas_asinas asinas asinas_akras akras akras_akwas akwas akwas_asimwas asimwas asimwas_asiḍyas asiḍyas asiḍyas'.split('_'), i;
29176 for (i = 0; i < expected.length; i++) {
29177 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
29178 }
29179 });
29180
29181 test('from', function (assert) {
29182 var start = moment([2007, 1, 28]);
29183 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'imik', '44 seconds = a few seconds');
29184 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuḍ', '45 seconds = a minute');
29185 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuḍ', '89 seconds = a minute');
29186 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuḍ', '90 seconds = 2 minutes');
29187 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuḍ', '44 minutes = 44 minutes');
29188 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'saɛa', '45 minutes = an hour');
29189 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'saɛa', '89 minutes = an hour');
29190 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 tassaɛin', '90 minutes = 2 hours');
29191 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 tassaɛin', '5 hours = 5 hours');
29192 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tassaɛin', '21 hours = 21 hours');
29193 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ass', '22 hours = a day');
29194 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ass', '35 hours = a day');
29195 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ossan', '36 hours = 2 days');
29196 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ass', '1 day = a day');
29197 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ossan', '5 days = 5 days');
29198 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ossan', '25 days = 25 days');
29199 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ayowr', '26 days = a month');
29200 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ayowr', '30 days = a month');
29201 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ayowr', '43 days = a month');
29202 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 iyyirn', '46 days = 2 months');
29203 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 iyyirn', '75 days = 2 months');
29204 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 iyyirn', '76 days = 3 months');
29205 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ayowr', '1 month = a month');
29206 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 iyyirn', '5 months = 5 months');
29207 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'asgas', '345 days = a year');
29208 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 isgasn', '548 days = 2 years');
29209 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'asgas', '1 year = a year');
29210 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 isgasn', '5 years = 5 years');
29211 });
29212
29213 test('suffix', function (assert) {
29214 assert.equal(moment(30000).from(0), 'dadkh s yan imik', 'prefix');
29215 assert.equal(moment(0).from(30000), 'yan imik', 'suffix');
29216 });
29217
29218 test('now from now', function (assert) {
29219 assert.equal(moment().fromNow(), 'yan imik', 'now from now should display as in the past');
29220 });
29221
29222 test('fromNow', function (assert) {
29223 assert.equal(moment().add({s: 30}).fromNow(), 'dadkh s yan imik', 'in a few seconds');
29224 assert.equal(moment().add({d: 5}).fromNow(), 'dadkh s yan 5 ossan', 'in 5 days');
29225 });
29226
29227 test('calendar day', function (assert) {
29228 var a = moment().hours(2).minutes(0).seconds(0);
29229
29230 assert.equal(moment(a).calendar(), 'asdkh g 02:00', 'today at the same time');
29231 assert.equal(moment(a).add({m: 25}).calendar(), 'asdkh g 02:25', 'Now plus 25 min');
29232 assert.equal(moment(a).add({h: 1}).calendar(), 'asdkh g 03:00', 'Now plus 1 hour');
29233 assert.equal(moment(a).add({d: 1}).calendar(), 'aska g 02:00', 'tomorrow at the same time');
29234 assert.equal(moment(a).subtract({h: 1}).calendar(), 'asdkh g 01:00', 'Now minus 1 hour');
29235 assert.equal(moment(a).subtract({d: 1}).calendar(), 'assant g 02:00', 'yesterday at the same time');
29236 });
29237
29238 test('calendar next week', function (assert) {
29239 var i, m;
29240 for (i = 2; i < 7; i++) {
29241 m = moment().add({d: i});
29242 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today + ' + i + ' days current time');
29243 m.hours(0).minutes(0).seconds(0).milliseconds(0);
29244 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today + ' + i + ' days beginning of day');
29245 m.hours(23).minutes(59).seconds(59).milliseconds(999);
29246 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today + ' + i + ' days end of day');
29247 }
29248 });
29249
29250 test('calendar last week', function (assert) {
29251 var i, m;
29252 for (i = 2; i < 7; i++) {
29253 m = moment().subtract({d: i});
29254 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today - ' + i + ' days current time');
29255 m.hours(0).minutes(0).seconds(0).milliseconds(0);
29256 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today - ' + i + ' days beginning of day');
29257 m.hours(23).minutes(59).seconds(59).milliseconds(999);
29258 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today - ' + i + ' days end of day');
29259 }
29260 });
29261
29262 test('calendar all else', function (assert) {
29263 var weeksAgo = moment().subtract({w: 1}),
29264 weeksFromNow = moment().add({w: 1});
29265
29266 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
29267 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
29268
29269 weeksAgo = moment().subtract({w: 2});
29270 weeksFromNow = moment().add({w: 2});
29271
29272 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
29273 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
29274 });
29275
29276 test('weeks year starting sunday', function (assert) {
29277 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
29278 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
29279 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
29280 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
29281 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
29282 });
29283
29284 test('weeks year starting monday', function (assert) {
29285 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
29286 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
29287 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
29288 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
29289 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
29290 });
29291
29292 test('weeks year starting tuesday', function (assert) {
29293 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
29294 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
29295 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
29296 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
29297 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
29298 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
29299 });
29300
29301 test('weeks year starting wednesday', function (assert) {
29302 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
29303 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
29304 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
29305 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
29306 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
29307 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
29308 });
29309
29310 test('weeks year starting thursday', function (assert) {
29311 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
29312 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
29313 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
29314 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
29315 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
29316 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
29317 });
29318
29319 test('weeks year starting friday', function (assert) {
29320 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
29321 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
29322 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
29323 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
29324 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
29325 });
29326
29327 test('weeks year starting saturday', function (assert) {
29328 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
29329 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
29330 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
29331 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
29332 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
29333 });
29334
29335 test('weeks year starting sunday formatted', function (assert) {
29336 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
29337 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
29338 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 should be week 2');
29339 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2');
29340 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
29341 });
29342
29343 test('lenient ordinal parsing', function (assert) {
29344 var i, ordinalStr, testMoment;
29345 for (i = 1; i <= 31; ++i) {
29346 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
29347 testMoment = moment(ordinalStr, 'YYYY MM Do');
29348 assert.equal(testMoment.year(), 2014,
29349 'lenient ordinal parsing ' + i + ' year check');
29350 assert.equal(testMoment.month(), 0,
29351 'lenient ordinal parsing ' + i + ' month check');
29352 assert.equal(testMoment.date(), i,
29353 'lenient ordinal parsing ' + i + ' date check');
29354 }
29355 });
29356
29357 test('lenient ordinal parsing of number', function (assert) {
29358 var i, testMoment;
29359 for (i = 1; i <= 31; ++i) {
29360 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
29361 assert.equal(testMoment.year(), 2014,
29362 'lenient ordinal parsing of number ' + i + ' year check');
29363 assert.equal(testMoment.month(), 0,
29364 'lenient ordinal parsing of number ' + i + ' month check');
29365 assert.equal(testMoment.date(), i,
29366 'lenient ordinal parsing of number ' + i + ' date check');
29367 }
29368 });
29369
29370 test('strict ordinal parsing', function (assert) {
29371 var i, ordinalStr, testMoment;
29372 for (i = 1; i <= 31; ++i) {
29373 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
29374 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
29375 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
29376 }
29377 });
29378
29379 }));
29380
29381 (function (global, factory) {
29382 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
29383 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
29384 factory(global.moment)
29385 }(this, function (moment) { 'use strict';
29386
29387 /*global QUnit:false*/
29388
29389 var test = QUnit.test;
29390
29391 function module (name, lifecycle) {
29392 QUnit.module(name, {
29393 setup : function () {
29394 moment.locale('en');
29395 moment.createFromInputFallback = function () {
29396 throw new Error('input not handled by moment');
29397 };
29398 if (lifecycle && lifecycle.setup) {
29399 lifecycle.setup();
29400 }
29401 },
29402 teardown : function () {
29403 if (lifecycle && lifecycle.teardown) {
29404 lifecycle.teardown();
29405 }
29406 }
29407 });
29408 }
29409
29410 function localeModule (name, lifecycle) {
29411 QUnit.module('locale:' + name, {
29412 setup : function () {
29413 moment.locale(name);
29414 moment.createFromInputFallback = function () {
29415 throw new Error('input not handled by moment');
29416 };
29417 if (lifecycle && lifecycle.setup) {
29418 lifecycle.setup();
29419 }
29420 },
29421 teardown : function () {
29422 moment.locale('en');
29423 if (lifecycle && lifecycle.teardown) {
29424 lifecycle.teardown();
29425 }
29426 }
29427 });
29428 }
29429
29430 localeModule('tzm');
29431
29432 test('parse', function (assert) {
29433 var tests = 'ⵉⵏⵏⴰⵢⵔ ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), i;
29434 function equalTest(input, mmm, i) {
29435 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
29436 }
29437 for (i = 0; i < 12; i++) {
29438 tests[i] = tests[i].split(' ');
29439 equalTest(tests[i][0], 'MMM', i);
29440 equalTest(tests[i][1], 'MMM', i);
29441 equalTest(tests[i][0], 'MMMM', i);
29442 equalTest(tests[i][1], 'MMMM', i);
29443 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
29444 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
29445 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
29446 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
29447 }
29448 });
29449
29450 test('format', function (assert) {
29451 var a = [
29452 ['dddd, MMMM Do YYYY, h:mm:ss a', 'ⴰⵙⴰⵎⴰⵙ, ⴱⵕⴰⵢⵕ 14 2010, 3:25:50 pm'],
29453 ['ddd, hA', 'ⴰⵙⴰⵎⴰⵙ, 3PM'],
29454 ['M Mo MM MMMM MMM', '2 2 02 ⴱⵕⴰⵢⵕ ⴱⵕⴰⵢⵕ'],
29455 ['YYYY YY', '2010 10'],
29456 ['D Do DD', '14 14 14'],
29457 ['d do dddd ddd dd', '0 0 ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ'],
29458 ['DDD DDDo DDDD', '45 45 045'],
29459 ['w wo ww', '8 8 08'],
29460 ['h hh', '3 03'],
29461 ['H HH', '15 15'],
29462 ['m mm', '25 25'],
29463 ['s ss', '50 50'],
29464 ['a A', 'pm PM'],
29465 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
29466 ['LTS', '15:25:50'],
29467 ['L', '14/02/2010'],
29468 ['LL', '14 ⴱⵕⴰⵢⵕ 2010'],
29469 ['LLL', '14 ⴱⵕⴰⵢⵕ 2010 15:25'],
29470 ['LLLL', 'ⴰⵙⴰⵎⴰⵙ 14 ⴱⵕⴰⵢⵕ 2010 15:25'],
29471 ['l', '14/2/2010'],
29472 ['ll', '14 ⴱⵕⴰⵢⵕ 2010'],
29473 ['lll', '14 ⴱⵕⴰⵢⵕ 2010 15:25'],
29474 ['llll', 'ⴰⵙⴰⵎⴰⵙ 14 ⴱⵕⴰⵢⵕ 2010 15:25']
29475 ],
29476 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
29477 i;
29478 for (i = 0; i < a.length; i++) {
29479 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
29480 }
29481 });
29482
29483 test('format ordinal', function (assert) {
29484 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
29485 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
29486 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
29487 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
29488 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
29489 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
29490 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
29491 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
29492 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
29493 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
29494
29495 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
29496 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
29497 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
29498 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
29499 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
29500 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
29501 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
29502 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
29503 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
29504 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
29505
29506 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
29507 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
29508 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
29509 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
29510 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
29511 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
29512 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
29513 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
29514 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
29515 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
29516
29517 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
29518 });
29519
29520 test('format month', function (assert) {
29521 var expected = 'ⵉⵏⵏⴰⵢⵔ ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), i;
29522 for (i = 0; i < expected.length; i++) {
29523 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
29524 }
29525 });
29526
29527 test('format week', function (assert) {
29528 var expected = 'ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ ⴰⵢⵏⴰⵙ ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ ⴰⵙⵉⵏⴰⵙ ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ ⴰⴽⵔⴰⵙ ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ ⴰⴽⵡⴰⵙ ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ ⴰⵙⵉⵎⵡⴰⵙ ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ ⴰⵙⵉⴹⵢⴰⵙ ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), i;
29529 for (i = 0; i < expected.length; i++) {
29530 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
29531 }
29532 });
29533
29534 test('from', function (assert) {
29535 var start = moment([2007, 1, 28]);
29536 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ⵉⵎⵉⴽ', '44 seconds = a few seconds');
29537 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ⵎⵉⵏⵓⴺ', '45 seconds = a minute');
29538 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ⵎⵉⵏⵓⴺ', '89 seconds = a minute');
29539 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 ⵎⵉⵏⵓⴺ', '90 seconds = 2 minutes');
29540 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 ⵎⵉⵏⵓⴺ', '44 minutes = 44 minutes');
29541 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ⵙⴰⵄⴰ', '45 minutes = an hour');
29542 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ⵙⴰⵄⴰ', '89 minutes = an hour');
29543 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ⵜⴰⵙⵙⴰⵄⵉⵏ', '90 minutes = 2 hours');
29544 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ⵜⴰⵙⵙⴰⵄⵉⵏ', '5 hours = 5 hours');
29545 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ⵜⴰⵙⵙⴰⵄⵉⵏ', '21 hours = 21 hours');
29546 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ⴰⵙⵙ', '22 hours = a day');
29547 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ⴰⵙⵙ', '35 hours = a day');
29548 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 oⵙⵙⴰⵏ', '36 hours = 2 days');
29549 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ⴰⵙⵙ', '1 day = a day');
29550 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 oⵙⵙⴰⵏ', '5 days = 5 days');
29551 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 oⵙⵙⴰⵏ', '25 days = 25 days');
29552 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ⴰⵢoⵓⵔ', '26 days = a month');
29553 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ⴰⵢoⵓⵔ', '30 days = a month');
29554 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ⴰⵢoⵓⵔ', '43 days = a month');
29555 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ⵉⵢⵢⵉⵔⵏ', '46 days = 2 months');
29556 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ⵉⵢⵢⵉⵔⵏ', '75 days = 2 months');
29557 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ⵉⵢⵢⵉⵔⵏ', '76 days = 3 months');
29558 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ⴰⵢoⵓⵔ', '1 month = a month');
29559 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ⵉⵢⵢⵉⵔⵏ', '5 months = 5 months');
29560 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ⴰⵙⴳⴰⵙ', '345 days = a year');
29561 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ⵉⵙⴳⴰⵙⵏ', '548 days = 2 years');
29562 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ⴰⵙⴳⴰⵙ', '1 year = a year');
29563 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ⵉⵙⴳⴰⵙⵏ', '5 years = 5 years');
29564 });
29565
29566 test('suffix', function (assert) {
29567 assert.equal(moment(30000).from(0), 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ ⵉⵎⵉⴽ', 'prefix');
29568 assert.equal(moment(0).from(30000), 'ⵢⴰⵏ ⵉⵎⵉⴽ', 'suffix');
29569 });
29570
29571 test('now from now', function (assert) {
29572 assert.equal(moment().fromNow(), 'ⵢⴰⵏ ⵉⵎⵉⴽ', 'now from now should display as in the past');
29573 });
29574
29575 test('fromNow', function (assert) {
29576 assert.equal(moment().add({s: 30}).fromNow(), 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ ⵉⵎⵉⴽ', 'in a few seconds');
29577 assert.equal(moment().add({d: 5}).fromNow(), 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ 5 oⵙⵙⴰⵏ', 'in 5 days');
29578 });
29579
29580 test('calendar day', function (assert) {
29581 var a = moment().hours(2).minutes(0).seconds(0);
29582
29583 assert.equal(moment(a).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:00', 'today at the same time');
29584 assert.equal(moment(a).add({m: 25}).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:25', 'Now plus 25 min');
29585 assert.equal(moment(a).add({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 03:00', 'Now plus 1 hour');
29586 assert.equal(moment(a).add({d: 1}).calendar(), 'ⴰⵙⴽⴰ ⴴ 02:00', 'tomorrow at the same time');
29587 assert.equal(moment(a).subtract({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 01:00', 'Now minus 1 hour');
29588 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ⴰⵚⴰⵏⵜ ⴴ 02:00', 'yesterday at the same time');
29589 });
29590
29591 test('calendar next week', function (assert) {
29592 var i, m;
29593 for (i = 2; i < 7; i++) {
29594 m = moment().add({d: i});
29595 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today + ' + i + ' days current time');
29596 m.hours(0).minutes(0).seconds(0).milliseconds(0);
29597 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today + ' + i + ' days beginning of day');
29598 m.hours(23).minutes(59).seconds(59).milliseconds(999);
29599 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today + ' + i + ' days end of day');
29600 }
29601 });
29602
29603 test('calendar last week', function (assert) {
29604 var i, m;
29605 for (i = 2; i < 7; i++) {
29606 m = moment().subtract({d: i});
29607 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today - ' + i + ' days current time');
29608 m.hours(0).minutes(0).seconds(0).milliseconds(0);
29609 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today - ' + i + ' days beginning of day');
29610 m.hours(23).minutes(59).seconds(59).milliseconds(999);
29611 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today - ' + i + ' days end of day');
29612 }
29613 });
29614
29615 test('calendar all else', function (assert) {
29616 var weeksAgo = moment().subtract({w: 1}),
29617 weeksFromNow = moment().add({w: 1});
29618
29619 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
29620 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
29621
29622 weeksAgo = moment().subtract({w: 2});
29623 weeksFromNow = moment().add({w: 2});
29624
29625 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
29626 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
29627 });
29628
29629 test('weeks year starting sunday', function (assert) {
29630 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
29631 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
29632 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
29633 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
29634 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
29635 });
29636
29637 test('weeks year starting monday', function (assert) {
29638 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
29639 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
29640 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
29641 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
29642 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
29643 });
29644
29645 test('weeks year starting tuesday', function (assert) {
29646 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
29647 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
29648 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
29649 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
29650 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
29651 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
29652 });
29653
29654 test('weeks year starting wednesday', function (assert) {
29655 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
29656 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
29657 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
29658 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
29659 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
29660 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
29661 });
29662
29663 test('weeks year starting thursday', function (assert) {
29664 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
29665 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
29666 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
29667 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
29668 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
29669 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
29670 });
29671
29672 test('weeks year starting friday', function (assert) {
29673 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
29674 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
29675 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
29676 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
29677 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
29678 });
29679
29680 test('weeks year starting saturday', function (assert) {
29681 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
29682 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
29683 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
29684 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
29685 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
29686 });
29687
29688 test('weeks year starting sunday formatted', function (assert) {
29689 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
29690 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
29691 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 should be week 2');
29692 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2');
29693 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
29694 });
29695
29696 test('lenient ordinal parsing', function (assert) {
29697 var i, ordinalStr, testMoment;
29698 for (i = 1; i <= 31; ++i) {
29699 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
29700 testMoment = moment(ordinalStr, 'YYYY MM Do');
29701 assert.equal(testMoment.year(), 2014,
29702 'lenient ordinal parsing ' + i + ' year check');
29703 assert.equal(testMoment.month(), 0,
29704 'lenient ordinal parsing ' + i + ' month check');
29705 assert.equal(testMoment.date(), i,
29706 'lenient ordinal parsing ' + i + ' date check');
29707 }
29708 });
29709
29710 test('lenient ordinal parsing of number', function (assert) {
29711 var i, testMoment;
29712 for (i = 1; i <= 31; ++i) {
29713 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
29714 assert.equal(testMoment.year(), 2014,
29715 'lenient ordinal parsing of number ' + i + ' year check');
29716 assert.equal(testMoment.month(), 0,
29717 'lenient ordinal parsing of number ' + i + ' month check');
29718 assert.equal(testMoment.date(), i,
29719 'lenient ordinal parsing of number ' + i + ' date check');
29720 }
29721 });
29722
29723 test('strict ordinal parsing', function (assert) {
29724 var i, ordinalStr, testMoment;
29725 for (i = 1; i <= 31; ++i) {
29726 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
29727 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
29728 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
29729 }
29730 });
29731
29732 }));
29733
29734 (function (global, factory) {
29735 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
29736 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
29737 factory(global.moment)
29738 }(this, function (moment) { 'use strict';
29739
29740 /*global QUnit:false*/
29741
29742 var test = QUnit.test;
29743
29744 function module (name, lifecycle) {
29745 QUnit.module(name, {
29746 setup : function () {
29747 moment.locale('en');
29748 moment.createFromInputFallback = function () {
29749 throw new Error('input not handled by moment');
29750 };
29751 if (lifecycle && lifecycle.setup) {
29752 lifecycle.setup();
29753 }
29754 },
29755 teardown : function () {
29756 if (lifecycle && lifecycle.teardown) {
29757 lifecycle.teardown();
29758 }
29759 }
29760 });
29761 }
29762
29763 function localeModule (name, lifecycle) {
29764 QUnit.module('locale:' + name, {
29765 setup : function () {
29766 moment.locale(name);
29767 moment.createFromInputFallback = function () {
29768 throw new Error('input not handled by moment');
29769 };
29770 if (lifecycle && lifecycle.setup) {
29771 lifecycle.setup();
29772 }
29773 },
29774 teardown : function () {
29775 moment.locale('en');
29776 if (lifecycle && lifecycle.teardown) {
29777 lifecycle.teardown();
29778 }
29779 }
29780 });
29781 }
29782
29783 localeModule('uk');
29784
29785 test('parse', function (assert) {
29786 var tests = 'січень січ_лютий лют_березень бер_квітень квіт_травень трав_червень черв_липень лип_серпень серп_вересень вер_жовтень жовт_листопад лист_грудень груд'.split('_'), i;
29787 function equalTest(input, mmm, i) {
29788 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
29789 }
29790 for (i = 0; i < 12; i++) {
29791 tests[i] = tests[i].split(' ');
29792 equalTest(tests[i][0], 'MMM', i);
29793 equalTest(tests[i][1], 'MMM', i);
29794 equalTest(tests[i][0], 'MMMM', i);
29795 equalTest(tests[i][1], 'MMMM', i);
29796 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
29797 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
29798 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
29799 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
29800 }
29801 });
29802
29803 test('format', function (assert) {
29804 var a = [
29805 ['dddd, Do MMMM YYYY, HH:mm:ss', 'неділя, 14-го лютого 2010, 15:25:50'],
29806 ['ddd, h A', 'нд, 3 дня'],
29807 ['M Mo MM MMMM MMM', '2 2-й 02 лютий лют'],
29808 ['YYYY YY', '2010 10'],
29809 ['D Do DD', '14 14-го 14'],
29810 ['d do dddd ddd dd', '0 0-й неділя нд нд'],
29811 ['DDD DDDo DDDD', '45 45-й 045'],
29812 ['w wo ww', '7 7-й 07'],
29813 ['h hh', '3 03'],
29814 ['H HH', '15 15'],
29815 ['m mm', '25 25'],
29816 ['s ss', '50 50'],
29817 ['a A', 'дня дня'],
29818 ['DDDo [день року]', '45-й день року'],
29819 ['LTS', '15:25:50'],
29820 ['L', '14.02.2010'],
29821 ['LL', '14 лютого 2010 р.'],
29822 ['LLL', '14 лютого 2010 р., 15:25'],
29823 ['LLLL', 'неділя, 14 лютого 2010 р., 15:25']
29824 ],
29825 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
29826 i;
29827 for (i = 0; i < a.length; i++) {
29828 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
29829 }
29830 });
29831
29832 test('format meridiem', function (assert) {
29833 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'ночі', 'night');
29834 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'ночі', 'night');
29835 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'ранку', 'morning');
29836 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'ранку', 'morning');
29837 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'дня', 'afternoon');
29838 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'дня', 'afternoon');
29839 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'вечора', 'evening');
29840 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'вечора', 'evening');
29841 });
29842
29843 test('format ordinal', function (assert) {
29844 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-й', '1-й');
29845 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-й', '2-й');
29846 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-й', '3-й');
29847 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-й', '4-й');
29848 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-й', '5-й');
29849 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-й', '6-й');
29850 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-й', '7-й');
29851 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-й', '8-й');
29852 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-й', '9-й');
29853 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-й', '10-й');
29854
29855 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-й', '11-й');
29856 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-й', '12-й');
29857 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-й', '13-й');
29858 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-й', '14-й');
29859 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-й', '15-й');
29860 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-й', '16-й');
29861 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-й', '17-й');
29862 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-й', '18-й');
29863 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-й', '19-й');
29864 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-й', '20-й');
29865
29866 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-й', '21-й');
29867 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-й', '22-й');
29868 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-й', '23-й');
29869 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-й', '24-й');
29870 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-й', '25-й');
29871 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-й', '26-й');
29872 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-й', '27-й');
29873 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-й', '28-й');
29874 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-й', '29-й');
29875 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-й', '30-й');
29876
29877 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-й', '31-й');
29878 });
29879
29880 test('format month', function (assert) {
29881 var expected = 'січень січ_лютий лют_березень бер_квітень квіт_травень трав_червень черв_липень лип_серпень серп_вересень вер_жовтень жовт_листопад лист_грудень груд'.split('_'), i;
29882 for (i = 0; i < expected.length; i++) {
29883 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
29884 }
29885 });
29886
29887 test('format month case', function (assert) {
29888 var months = {
29889 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
29890 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
29891 }, i;
29892 for (i = 0; i < 12; i++) {
29893 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
29894 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
29895 }
29896 });
29897
29898 test('format week', function (assert) {
29899 var expected = 'неділя нд нд_понеділок пн пн_вівторок вт вт_середа ср ср_четвер чт чт_п’ятниця пт пт_субота сб сб'.split('_'), i;
29900 for (i = 0; i < expected.length; i++) {
29901 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
29902 }
29903 });
29904
29905 test('from', function (assert) {
29906 var start = moment([2007, 1, 28]);
29907 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'декілька секунд', '44 seconds = seconds');
29908 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'хвилина', '45 seconds = a minute');
29909 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'хвилина', '89 seconds = a minute');
29910 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 хвилини', '90 seconds = 2 minutes');
29911 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 хвилини', '44 minutes = 44 minutes');
29912 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'годину', '45 minutes = an hour');
29913 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'годину', '89 minutes = an hour');
29914 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 години', '90 minutes = 2 hours');
29915 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 годин', '5 hours = 5 hours');
29916 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 година', '21 hours = 21 hours');
29917 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'день', '22 hours = a day');
29918 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'день', '35 hours = a day');
29919 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дні', '36 hours = 2 days');
29920 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'день', '1 day = a day');
29921 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 днів', '5 days = 5 days');
29922 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 днів', '11 days = 11 days');
29923 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 день', '21 days = 21 days');
29924 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 днів', '25 days = 25 days');
29925 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'місяць', '26 days = a month');
29926 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'місяць', '30 days = a month');
29927 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'місяць', '43 days = a month');
29928 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 місяці', '46 days = 2 months');
29929 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 місяці', '75 days = 2 months');
29930 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 місяці', '76 days = 3 months');
29931 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'місяць', '1 month = a month');
29932 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 місяців', '5 months = 5 months');
29933 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'рік', '345 days = a year');
29934 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 роки', '548 days = 2 years');
29935 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'рік', '1 year = a year');
29936 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 років', '5 years = 5 years');
29937 });
29938
29939 test('suffix', function (assert) {
29940 assert.equal(moment(30000).from(0), 'за декілька секунд', 'prefix');
29941 assert.equal(moment(0).from(30000), 'декілька секунд тому', 'suffix');
29942 });
29943
29944 test('fromNow', function (assert) {
29945 assert.equal(moment().add({s: 30}).fromNow(), 'за декілька секунд', 'in seconds');
29946 assert.equal(moment().add({d: 5}).fromNow(), 'за 5 днів', 'in 5 days');
29947 });
29948
29949 test('calendar day', function (assert) {
29950 var a = moment().hours(2).minutes(0).seconds(0);
29951
29952 assert.equal(moment(a).calendar(), 'Сьогодні о 02:00', 'today at the same time');
29953 assert.equal(moment(a).add({m: 25}).calendar(), 'Сьогодні о 02:25', 'Now plus 25 min');
29954 assert.equal(moment(a).add({h: 1}).calendar(), 'Сьогодні о 03:00', 'Now plus 1 hour');
29955 assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра о 02:00', 'tomorrow at the same time');
29956 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сьогодні о 01:00', 'Now minus 1 hour');
29957 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчора о 02:00', 'yesterday at the same time');
29958 // A special case for Ukrainian since 11 hours have different preposition
29959 assert.equal(moment(a).add({h: 9}).calendar(), 'Сьогодні об 11:00', 'same day at 11 o\'clock');
29960 });
29961
29962 test('calendar next week', function (assert) {
29963 var i, m;
29964 for (i = 2; i < 7; i++) {
29965 m = moment().add({d: i});
29966 assert.equal(m.calendar(), m.format('[У] dddd [о' + (m.hours() === 11 ? 'б' : '') + '] LT'), 'Today + ' + i + ' days current time');
29967 m.hours(0).minutes(0).seconds(0).milliseconds(0);
29968 assert.equal(m.calendar(), m.format('[У] dddd [о] LT'), 'Today + ' + i + ' days beginning of day');
29969 m.hours(23).minutes(59).seconds(59).milliseconds(999);
29970 assert.equal(m.calendar(), m.format('[У] dddd [о] LT'), 'Today + ' + i + ' days end of day');
29971 }
29972 });
29973
29974 test('calendar last week', function (assert) {
29975 var i, m;
29976
29977 function makeFormat(d) {
29978 switch (d.day()) {
29979 case 0:
29980 case 3:
29981 case 5:
29982 case 6:
29983 return '[Минулої] dddd [о' + (d.hours() === 11 ? 'б' : '') + '] LT';
29984 case 1:
29985 case 2:
29986 case 4:
29987 return '[Минулого] dddd [о' + (d.hours() === 11 ? 'б' : '') + '] LT';
29988 }
29989 }
29990
29991 for (i = 2; i < 7; i++) {
29992 m = moment().subtract({d: i});
29993 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
29994 m.hours(0).minutes(0).seconds(0).milliseconds(0);
29995 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
29996 m.hours(23).minutes(59).seconds(59).milliseconds(999);
29997 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
29998 }
29999 });
30000
30001 test('calendar all else', function (assert) {
30002 var weeksAgo = moment().subtract({w: 1}),
30003 weeksFromNow = moment().add({w: 1});
30004
30005 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
30006 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
30007
30008 weeksAgo = moment().subtract({w: 2});
30009 weeksFromNow = moment().add({w: 2});
30010
30011 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
30012 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
30013 });
30014
30015 test('weeks year starting sunday', function (assert) {
30016 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
30017 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
30018 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
30019 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
30020 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
30021 });
30022
30023 test('weeks year starting monday', function (assert) {
30024 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
30025 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
30026 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
30027 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
30028 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
30029 });
30030
30031 test('weeks year starting tuesday', function (assert) {
30032 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
30033 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
30034 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
30035 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
30036 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
30037 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
30038 });
30039
30040 test('weeks year starting wednesday', function (assert) {
30041 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
30042 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
30043 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
30044 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
30045 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
30046 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
30047 });
30048
30049 test('weeks year starting thursday', function (assert) {
30050 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
30051 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
30052 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
30053 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
30054 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
30055 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
30056 });
30057
30058 test('weeks year starting friday', function (assert) {
30059 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
30060 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
30061 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
30062 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
30063 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
30064 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
30065 });
30066
30067 test('weeks year starting saturday', function (assert) {
30068 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
30069 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
30070 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
30071 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
30072 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
30073 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
30074 });
30075
30076 test('weeks year starting sunday formatted', function (assert) {
30077 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-й', 'Dec 26 2011 should be week 1');
30078 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-й', 'Jan 1 2012 should be week 1');
30079 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-й', 'Jan 2 2012 should be week 2');
30080 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-й', 'Jan 8 2012 should be week 2');
30081 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-й', 'Jan 9 2012 should be week 3');
30082 });
30083
30084 test('lenient ordinal parsing', function (assert) {
30085 var i, ordinalStr, testMoment;
30086 for (i = 1; i <= 31; ++i) {
30087 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
30088 testMoment = moment(ordinalStr, 'YYYY MM Do');
30089 assert.equal(testMoment.year(), 2014,
30090 'lenient ordinal parsing ' + i + ' year check');
30091 assert.equal(testMoment.month(), 0,
30092 'lenient ordinal parsing ' + i + ' month check');
30093 assert.equal(testMoment.date(), i,
30094 'lenient ordinal parsing ' + i + ' date check');
30095 }
30096 });
30097
30098 test('lenient ordinal parsing of number', function (assert) {
30099 var i, testMoment;
30100 for (i = 1; i <= 31; ++i) {
30101 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
30102 assert.equal(testMoment.year(), 2014,
30103 'lenient ordinal parsing of number ' + i + ' year check');
30104 assert.equal(testMoment.month(), 0,
30105 'lenient ordinal parsing of number ' + i + ' month check');
30106 assert.equal(testMoment.date(), i,
30107 'lenient ordinal parsing of number ' + i + ' date check');
30108 }
30109 });
30110
30111 test('strict ordinal parsing', function (assert) {
30112 var i, ordinalStr, testMoment;
30113 for (i = 1; i <= 31; ++i) {
30114 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
30115 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
30116 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
30117 }
30118 });
30119
30120 }));
30121
30122 (function (global, factory) {
30123 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
30124 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
30125 factory(global.moment)
30126 }(this, function (moment) { 'use strict';
30127
30128 /*global QUnit:false*/
30129
30130 var test = QUnit.test;
30131
30132 function module (name, lifecycle) {
30133 QUnit.module(name, {
30134 setup : function () {
30135 moment.locale('en');
30136 moment.createFromInputFallback = function () {
30137 throw new Error('input not handled by moment');
30138 };
30139 if (lifecycle && lifecycle.setup) {
30140 lifecycle.setup();
30141 }
30142 },
30143 teardown : function () {
30144 if (lifecycle && lifecycle.teardown) {
30145 lifecycle.teardown();
30146 }
30147 }
30148 });
30149 }
30150
30151 function localeModule (name, lifecycle) {
30152 QUnit.module('locale:' + name, {
30153 setup : function () {
30154 moment.locale(name);
30155 moment.createFromInputFallback = function () {
30156 throw new Error('input not handled by moment');
30157 };
30158 if (lifecycle && lifecycle.setup) {
30159 lifecycle.setup();
30160 }
30161 },
30162 teardown : function () {
30163 moment.locale('en');
30164 if (lifecycle && lifecycle.teardown) {
30165 lifecycle.teardown();
30166 }
30167 }
30168 });
30169 }
30170
30171 localeModule('uz');
30172
30173 test('parse', function (assert) {
30174 var tests = 'январь янв_февраль фев_март мар_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
30175 function equalTest(input, mmm, i) {
30176 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
30177 }
30178 for (i = 0; i < 12; i++) {
30179 tests[i] = tests[i].split(' ');
30180 equalTest(tests[i][0], 'MMM', i);
30181 equalTest(tests[i][1], 'MMM', i);
30182 equalTest(tests[i][0], 'MMMM', i);
30183 equalTest(tests[i][1], 'MMMM', i);
30184 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
30185 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
30186 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
30187 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
30188 }
30189 });
30190
30191 test('format', function (assert) {
30192 var a = [
30193 ['dddd, Do-MMMM YYYY, h:mm:ss', 'Якшанба, 14-февраль 2010, 3:25:50'],
30194 ['ddd, h:mm', 'Якш, 3:25'],
30195 ['M Mo MM MMMM MMM', '2 2 02 февраль фев'],
30196 ['YYYY YY', '2010 10'],
30197 ['D Do DD', '14 14 14'],
30198 ['d do dddd ddd dd', '0 0 Якшанба Якш Як'],
30199 ['DDD DDDo DDDD', '45 45 045'],
30200 ['w wo ww', '7 7 07'],
30201 ['h hh', '3 03'],
30202 ['H HH', '15 15'],
30203 ['m mm', '25 25'],
30204 ['s ss', '50 50'],
30205 ['a A', 'pm PM'],
30206 ['[йилнинг] DDDo-[куни]', 'йилнинг 45-куни'],
30207 ['LTS', '15:25:50'],
30208 ['L', '14/02/2010'],
30209 ['LL', '14 февраль 2010'],
30210 ['LLL', '14 февраль 2010 15:25'],
30211 ['LLLL', '14 февраль 2010, Якшанба 15:25'],
30212 ['l', '14/2/2010'],
30213 ['ll', '14 фев 2010'],
30214 ['lll', '14 фев 2010 15:25'],
30215 ['llll', '14 фев 2010, Якш 15:25']
30216 ],
30217 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
30218 i;
30219 for (i = 0; i < a.length; i++) {
30220 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
30221 }
30222 });
30223
30224 test('format ordinal', function (assert) {
30225 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
30226 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
30227 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
30228 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
30229 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
30230 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
30231 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
30232 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
30233 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
30234 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
30235
30236 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
30237 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
30238 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
30239 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
30240 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
30241 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
30242 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
30243 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
30244 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
30245 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
30246
30247 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
30248 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
30249 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
30250 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
30251 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
30252 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
30253 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
30254 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
30255 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
30256 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
30257
30258 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
30259 });
30260
30261 test('format month', function (assert) {
30262 var expected = 'январь янв_февраль фев_март мар_апрель апр_май май_июнь июн_июль июл_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
30263 for (i = 0; i < expected.length; i++) {
30264 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
30265 }
30266 });
30267
30268 test('format week', function (assert) {
30269 var expected = 'Якшанба Якш Як_Душанба Душ Ду_Сешанба Сеш Се_Чоршанба Чор Чо_Пайшанба Пай Па_Жума Жум Жу_Шанба Шан Ша'.split('_'), i;
30270 for (i = 0; i < expected.length; i++) {
30271 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
30272 }
30273 });
30274
30275 test('from', function (assert) {
30276 var start = moment([2007, 1, 28]);
30277 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'фурсат', '44 секунд = фурсат');
30278 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'бир дакика', '45 секунд = бир дакика');
30279 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'бир дакика', '89 секунд = бир дакика');
30280 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 дакика', '90 секунд = 2 дакика');
30281 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 дакика', '44 дакика = 44 дакика');
30282 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'бир соат', '45 минут = бир соат');
30283 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'бир соат', '89 minutes = an hour');
30284 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 соат', '90 минут = 2 соат');
30285 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 соат', '5 соат = 5 соат');
30286 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 соат', '21 соат = 21 соат');
30287 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'бир кун', '22 соат = бир кун');
30288 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'бир кун', '35 соат = бир кун');
30289 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 кун', '36 соат = 2 кун');
30290 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'бир кун', '1 кун = 1 кун');
30291 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 кун', '5 кун = 5 кун');
30292 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 кун', '25 кун = 25 кун');
30293 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'бир ой', '26 кун = бир ой');
30294 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'бир ой', '30 кун = бир ой');
30295 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'бир ой', '45 кун = бир ой');
30296 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ой', '46 кун = 2 ой');
30297 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ой', '75 кун = 2 ой');
30298 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ой', '76 кун = 3 ой');
30299 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'бир ой', 'бир ой = бир ой');
30300 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ой', '5 ой = 5 ой');
30301 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'бир йил', '345 кун = бир йил');
30302 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 йил', '548 кун = 2 йил');
30303 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'бир йил', '1 йил = бир йил');
30304 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 йил', '5 йил = 5 йил');
30305 });
30306
30307 test('suffix', function (assert) {
30308 assert.equal(moment(30000).from(0), 'Якин фурсат ичида', 'prefix');
30309 assert.equal(moment(0).from(30000), 'Бир неча фурсат олдин', 'suffix');
30310 });
30311
30312 test('now from now', function (assert) {
30313 assert.equal(moment().fromNow(), 'Бир неча фурсат олдин', 'now from now should display as in the past');
30314 });
30315
30316 test('fromNow', function (assert) {
30317 assert.equal(moment().add({s: 30}).fromNow(), 'Якин фурсат ичида', 'in a few seconds');
30318 assert.equal(moment().add({d: 5}).fromNow(), 'Якин 5 кун ичида', 'in 5 days');
30319 });
30320
30321 test('calendar day', function (assert) {
30322 var a = moment().hours(2).minutes(0).seconds(0);
30323
30324 assert.equal(moment(a).calendar(), 'Бугун соат 02:00 да', 'today at the same time');
30325 assert.equal(moment(a).add({m: 25}).calendar(), 'Бугун соат 02:25 да', 'Now plus 25 min');
30326 assert.equal(moment(a).add({h: 1}).calendar(), 'Бугун соат 03:00 да', 'Now plus 1 hour');
30327 assert.equal(moment(a).add({d: 1}).calendar(), 'Эртага 02:00 да', 'tomorrow at the same time');
30328 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бугун соат 01:00 да', 'Now minus 1 hour');
30329 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеча соат 02:00 да', 'yesterday at the same time');
30330 });
30331
30332 test('calendar next week', function (assert) {
30333 var i, m;
30334 for (i = 2; i < 7; i++) {
30335 m = moment().add({d: i});
30336 assert.equal(m.calendar(), m.format('dddd [куни соат] LT [да]'), 'Today + ' + i + ' days current time');
30337 m.hours(0).minutes(0).seconds(0).milliseconds(0);
30338 assert.equal(m.calendar(), m.format('dddd [куни соат] LT [да]'), 'Today + ' + i + ' days beginning of day');
30339 m.hours(23).minutes(59).seconds(59).milliseconds(999);
30340 assert.equal(m.calendar(), m.format('dddd [куни соат] LT [да]'), 'Today + ' + i + ' days end of day');
30341 }
30342 });
30343
30344 test('calendar last week', function (assert) {
30345 var i, m;
30346
30347 for (i = 2; i < 7; i++) {
30348 m = moment().subtract({d: i});
30349 assert.equal(m.calendar(), m.format('[Утган] dddd [куни соат] LT [да]'), 'Today - ' + i + ' days current time');
30350 m.hours(0).minutes(0).seconds(0).milliseconds(0);
30351 assert.equal(m.calendar(), m.format('[Утган] dddd [куни соат] LT [да]'), 'Today - ' + i + ' days beginning of day');
30352 m.hours(23).minutes(59).seconds(59).milliseconds(999);
30353 assert.equal(m.calendar(), m.format('[Утган] dddd [куни соат] LT [да]'), 'Today - ' + i + ' days end of day');
30354 }
30355 });
30356
30357 test('calendar all else', function (assert) {
30358 var weeksAgo = moment().subtract({w: 1}),
30359 weeksFromNow = moment().add({w: 1});
30360
30361 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
30362 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
30363
30364 weeksAgo = moment().subtract({w: 2});
30365 weeksFromNow = moment().add({w: 2});
30366
30367 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
30368 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
30369 });
30370
30371 test('weeks year starting sunday', function (assert) {
30372 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 52');
30373 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 1');
30374 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 1');
30375 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 2');
30376 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 2');
30377 });
30378
30379 test('weeks year starting monday', function (assert) {
30380 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
30381 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
30382 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
30383 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
30384 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
30385 });
30386
30387 test('weeks year starting tuesday', function (assert) {
30388 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
30389 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
30390 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
30391 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
30392 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
30393 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
30394 });
30395
30396 test('weeks year starting wednesday', function (assert) {
30397 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
30398 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
30399 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
30400 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
30401 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
30402 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
30403 });
30404
30405 test('weeks year starting thursday', function (assert) {
30406 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
30407 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
30408 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
30409 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
30410 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
30411 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
30412 });
30413
30414 test('weeks year starting friday', function (assert) {
30415 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 53');
30416 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 53');
30417 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 53');
30418 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 1');
30419 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 1');
30420 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 2');
30421 });
30422
30423 test('weeks year starting saturday', function (assert) {
30424 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 52');
30425 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 52');
30426 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 52');
30427 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 1');
30428 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 1');
30429 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 2');
30430 });
30431
30432 test('weeks year starting sunday formatted', function (assert) {
30433 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 52');
30434 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 1');
30435 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 1');
30436 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 2');
30437 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 2');
30438 });
30439
30440 test('lenient ordinal parsing', function (assert) {
30441 var i, ordinalStr, testMoment;
30442 for (i = 1; i <= 31; ++i) {
30443 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
30444 testMoment = moment(ordinalStr, 'YYYY MM Do');
30445 assert.equal(testMoment.year(), 2014,
30446 'lenient ordinal parsing ' + i + ' year check');
30447 assert.equal(testMoment.month(), 0,
30448 'lenient ordinal parsing ' + i + ' month check');
30449 assert.equal(testMoment.date(), i,
30450 'lenient ordinal parsing ' + i + ' date check');
30451 }
30452 });
30453
30454 test('lenient ordinal parsing of number', function (assert) {
30455 var i, testMoment;
30456 for (i = 1; i <= 31; ++i) {
30457 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
30458 assert.equal(testMoment.year(), 2014,
30459 'lenient ordinal parsing of number ' + i + ' year check');
30460 assert.equal(testMoment.month(), 0,
30461 'lenient ordinal parsing of number ' + i + ' month check');
30462 assert.equal(testMoment.date(), i,
30463 'lenient ordinal parsing of number ' + i + ' date check');
30464 }
30465 });
30466
30467 test('strict ordinal parsing', function (assert) {
30468 var i, ordinalStr, testMoment;
30469 for (i = 1; i <= 31; ++i) {
30470 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
30471 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
30472 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
30473 }
30474 });
30475
30476 }));
30477
30478 (function (global, factory) {
30479 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
30480 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
30481 factory(global.moment)
30482 }(this, function (moment) { 'use strict';
30483
30484 /*global QUnit:false*/
30485
30486 var test = QUnit.test;
30487
30488 function module (name, lifecycle) {
30489 QUnit.module(name, {
30490 setup : function () {
30491 moment.locale('en');
30492 moment.createFromInputFallback = function () {
30493 throw new Error('input not handled by moment');
30494 };
30495 if (lifecycle && lifecycle.setup) {
30496 lifecycle.setup();
30497 }
30498 },
30499 teardown : function () {
30500 if (lifecycle && lifecycle.teardown) {
30501 lifecycle.teardown();
30502 }
30503 }
30504 });
30505 }
30506
30507 function localeModule (name, lifecycle) {
30508 QUnit.module('locale:' + name, {
30509 setup : function () {
30510 moment.locale(name);
30511 moment.createFromInputFallback = function () {
30512 throw new Error('input not handled by moment');
30513 };
30514 if (lifecycle && lifecycle.setup) {
30515 lifecycle.setup();
30516 }
30517 },
30518 teardown : function () {
30519 moment.locale('en');
30520 if (lifecycle && lifecycle.teardown) {
30521 lifecycle.teardown();
30522 }
30523 }
30524 });
30525 }
30526
30527 localeModule('vi');
30528
30529 test('parse', function (assert) {
30530 var i,
30531 tests = 'tháng 1,Th01_tháng 2,Th02_tháng 3,Th03_tháng 4,Th04_tháng 5,Th05_tháng 6,Th06_tháng 7,Th07_tháng 8,Th08_tháng 9,Th09_tháng 10,Th10_tháng 11,Th11_tháng 12,Th12'.split('_');
30532
30533 function equalTest(input, mmm, i) {
30534 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + i);
30535 }
30536
30537 for (i = 0; i < 12; i++) {
30538 tests[i] = tests[i].split(',');
30539 equalTest(tests[i][0], '[tháng] M', i);
30540 equalTest(tests[i][1], '[Th]M', i);
30541 equalTest(tests[i][0], '[tháng] MM', i);
30542 equalTest(tests[i][1], '[Th]MM', i);
30543 equalTest(tests[i][0].toLocaleLowerCase(), '[THÁNG] M', i);
30544 equalTest(tests[i][1].toLocaleLowerCase(), '[TH]M', i);
30545 equalTest(tests[i][0].toLocaleUpperCase(), '[THÁNG] MM', i);
30546 equalTest(tests[i][1].toLocaleUpperCase(), '[TH]MM', i);
30547 }
30548 });
30549
30550 test('format', function (assert) {
30551 var a = [
30552 ['dddd, MMMM Do YYYY, h:mm:ss a', 'chủ nhật, tháng 2 14 2010, 3:25:50 pm'],
30553 ['ddd, hA', 'CN, 3PM'],
30554 ['M Mo MM MMMM MMM', '2 2 02 tháng 2 Th02'],
30555 ['YYYY YY', '2010 10'],
30556 ['D Do DD', '14 14 14'],
30557 ['d do dddd ddd dd', '0 0 chủ nhật CN CN'],
30558 ['DDD DDDo DDDD', '45 45 045'],
30559 ['w wo ww', '6 6 06'],
30560 ['h hh', '3 03'],
30561 ['H HH', '15 15'],
30562 ['m mm', '25 25'],
30563 ['s ss', '50 50'],
30564 ['a A', 'pm PM'],
30565 ['[ngày thứ] DDDo [của năm]', 'ngày thứ 45 của năm'],
30566 ['LTS', '15:25:50'],
30567 ['L', '14/02/2010'],
30568 ['LL', '14 tháng 2 năm 2010'],
30569 ['LLL', '14 tháng 2 năm 2010 15:25'],
30570 ['LLLL', 'chủ nhật, 14 tháng 2 năm 2010 15:25'],
30571 ['l', '14/2/2010'],
30572 ['ll', '14 Th02 2010'],
30573 ['lll', '14 Th02 2010 15:25'],
30574 ['llll', 'CN, 14 Th02 2010 15:25']
30575 ],
30576 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
30577 i;
30578
30579 for (i = 0; i < a.length; i++) {
30580 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
30581 }
30582 });
30583
30584 test('format ordinal', function (assert) {
30585 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
30586 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
30587 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
30588 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
30589 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
30590 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
30591 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
30592 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
30593 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
30594 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
30595
30596 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
30597 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
30598 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
30599 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
30600 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
30601 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
30602 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
30603 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
30604 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
30605 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
30606
30607 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
30608 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
30609 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
30610 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
30611 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
30612 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
30613 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
30614 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
30615 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
30616 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
30617
30618 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
30619 });
30620
30621 test('format month', function (assert) {
30622 var i,
30623 expected = 'tháng 1,Th01_tháng 2,Th02_tháng 3,Th03_tháng 4,Th04_tháng 5,Th05_tháng 6,Th06_tháng 7,Th07_tháng 8,Th08_tháng 9,Th09_tháng 10,Th10_tháng 11,Th11_tháng 12,Th12'.split('_');
30624
30625 for (i = 0; i < expected.length; i++) {
30626 assert.equal(moment([2011, i, 1]).format('MMMM,MMM'), expected[i], expected[i]);
30627 }
30628 });
30629
30630 test('format week', function (assert) {
30631 var i,
30632 expected = 'chủ nhật CN CN_thứ hai T2 T2_thứ ba T3 T3_thứ tư T4 T4_thứ năm T5 T5_thứ sáu T6 T6_thứ bảy T7 T7'.split('_');
30633
30634 for (i = 0; i < expected.length; i++) {
30635 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
30636 }
30637 });
30638
30639 test('from', function (assert) {
30640 var start = moment([2007, 1, 28]);
30641
30642 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'vài giây', '44 seconds = a few seconds');
30643 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'một phút', '45 seconds = a minute');
30644 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'một phút', '89 seconds = a minute');
30645 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 phút', '90 seconds = 2 minutes');
30646 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 phút', '44 minutes = 44 minutes');
30647 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'một giờ', '45 minutes = an hour');
30648 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'một giờ', '89 minutes = an hour');
30649 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 giờ', '90 minutes = 2 hours');
30650 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 giờ', '5 hours = 5 hours');
30651 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 giờ', '21 hours = 21 hours');
30652 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'một ngày', '22 hours = a day');
30653 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'một ngày', '35 hours = a day');
30654 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ngày', '36 hours = 2 days');
30655 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'một ngày', '1 day = a day');
30656 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ngày', '5 days = 5 days');
30657 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ngày', '25 days = 25 days');
30658 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'một tháng', '26 days = a month');
30659 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'một tháng', '30 days = a month');
30660 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'một tháng', '43 days = a month');
30661 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 tháng', '46 days = 2 months');
30662 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 tháng', '75 days = 2 months');
30663 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 tháng', '76 days = 3 months');
30664 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'một tháng', '1 month = a month');
30665 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 tháng', '5 months = 5 months');
30666 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'một năm', '345 days = a year');
30667 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 năm', '548 days = 2 years');
30668 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'một năm', '1 year = a year');
30669 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 năm', '5 years = 5 years');
30670 });
30671
30672 test('suffix', function (assert) {
30673 assert.equal(moment(30000).from(0), 'vài giây tới', 'prefix');
30674 assert.equal(moment(0).from(30000), 'vài giây trước', 'suffix');
30675 });
30676
30677 test('now from now', function (assert) {
30678 assert.equal(moment().fromNow(), 'vài giây trước', 'now from now should display as in the past');
30679 });
30680
30681 test('fromNow', function (assert) {
30682 assert.equal(moment().add({s: 30}).fromNow(), 'vài giây tới', 'in a few seconds');
30683 assert.equal(moment().add({d: 5}).fromNow(), '5 ngày tới', 'in 5 days');
30684 });
30685
30686 test('calendar day', function (assert) {
30687 var a = moment().hours(2).minutes(0).seconds(0);
30688
30689 assert.equal(moment(a).calendar(), 'Hôm nay lúc 02:00', 'today at the same time');
30690 assert.equal(moment(a).add({m: 25}).calendar(), 'Hôm nay lúc 02:25', 'Now plus 25 min');
30691 assert.equal(moment(a).add({h: 1}).calendar(), 'Hôm nay lúc 03:00', 'Now plus 1 hour');
30692 assert.equal(moment(a).add({d: 1}).calendar(), 'Ngày mai lúc 02:00', 'tomorrow at the same time');
30693 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hôm nay lúc 01:00', 'Now minus 1 hour');
30694 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hôm qua lúc 02:00', 'yesterday at the same time');
30695 });
30696
30697 test('calendar next week', function (assert) {
30698 var i, m;
30699
30700 for (i = 2; i < 7; i++) {
30701 m = moment().add({d: i});
30702 assert.equal(m.calendar(), m.format('dddd [tuần tới lúc] LT'), 'Today + ' + i + ' days current time');
30703 m.hours(0).minutes(0).seconds(0).milliseconds(0);
30704 assert.equal(m.calendar(), m.format('dddd [tuần tới lúc] LT'), 'Today + ' + i + ' days beginning of day');
30705 m.hours(23).minutes(59).seconds(59).milliseconds(999);
30706 assert.equal(m.calendar(), m.format('dddd [tuần tới lúc] LT'), 'Today + ' + i + ' days end of day');
30707 }
30708 });
30709
30710 test('calendar last week', function (assert) {
30711 var i, m;
30712
30713 for (i = 2; i < 7; i++) {
30714 m = moment().subtract({d: i});
30715 assert.equal(m.calendar(), m.format('dddd [tuần rồi lúc] LT'), 'Today - ' + i + ' days current time');
30716 m.hours(0).minutes(0).seconds(0).milliseconds(0);
30717 assert.equal(m.calendar(), m.format('dddd [tuần rồi lúc] LT'), 'Today - ' + i + ' days beginning of day');
30718 m.hours(23).minutes(59).seconds(59).milliseconds(999);
30719 assert.equal(m.calendar(), m.format('dddd [tuần rồi lúc] LT'), 'Today - ' + i + ' days end of day');
30720 }
30721 });
30722
30723 test('calendar all else', function (assert) {
30724 var weeksAgo = moment().subtract({w: 1}),
30725 weeksFromNow = moment().add({w: 1});
30726
30727 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
30728 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
30729
30730 weeksAgo = moment().subtract({w: 2});
30731 weeksFromNow = moment().add({w: 2});
30732
30733 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
30734 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
30735 });
30736
30737 test('weeks year starting sunday', function (assert) {
30738 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
30739 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
30740 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
30741 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
30742 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
30743 });
30744
30745 test('weeks year starting monday', function (assert) {
30746 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
30747 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
30748 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
30749 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
30750 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
30751 });
30752
30753 test('weeks year starting tuesday', function (assert) {
30754 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
30755 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
30756 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
30757 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
30758 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
30759 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
30760 });
30761
30762 test('weeks year starting wednesday', function (assert) {
30763 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
30764 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
30765 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
30766 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
30767 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
30768 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
30769 });
30770
30771 test('weeks year starting thursday', function (assert) {
30772 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
30773 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
30774 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
30775 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
30776 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
30777 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
30778 });
30779
30780 test('weeks year starting friday', function (assert) {
30781 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
30782 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
30783 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
30784 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
30785 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
30786 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
30787 });
30788
30789 test('weeks year starting saturday', function (assert) {
30790 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
30791 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
30792 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
30793 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
30794 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
30795 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
30796 });
30797
30798 test('weeks year starting sunday formatted', function (assert) {
30799 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
30800 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
30801 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
30802 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
30803 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
30804 });
30805
30806 test('lenient ordinal parsing', function (assert) {
30807 var i, ordinalStr, testMoment;
30808 for (i = 1; i <= 31; ++i) {
30809 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
30810 testMoment = moment(ordinalStr, 'YYYY MM Do');
30811 assert.equal(testMoment.year(), 2014,
30812 'lenient ordinal parsing ' + i + ' year check');
30813 assert.equal(testMoment.month(), 0,
30814 'lenient ordinal parsing ' + i + ' month check');
30815 assert.equal(testMoment.date(), i,
30816 'lenient ordinal parsing ' + i + ' date check');
30817 }
30818 });
30819
30820 test('lenient ordinal parsing of number', function (assert) {
30821 var i, testMoment;
30822 for (i = 1; i <= 31; ++i) {
30823 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
30824 assert.equal(testMoment.year(), 2014,
30825 'lenient ordinal parsing of number ' + i + ' year check');
30826 assert.equal(testMoment.month(), 0,
30827 'lenient ordinal parsing of number ' + i + ' month check');
30828 assert.equal(testMoment.date(), i,
30829 'lenient ordinal parsing of number ' + i + ' date check');
30830 }
30831 });
30832
30833 test('strict ordinal parsing', function (assert) {
30834 var i, ordinalStr, testMoment;
30835 for (i = 1; i <= 31; ++i) {
30836 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
30837 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
30838 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
30839 }
30840 });
30841
30842 }));
30843
30844 (function (global, factory) {
30845 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
30846 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
30847 factory(global.moment)
30848 }(this, function (moment) { 'use strict';
30849
30850 /*global QUnit:false*/
30851
30852 var test = QUnit.test;
30853
30854 function module (name, lifecycle) {
30855 QUnit.module(name, {
30856 setup : function () {
30857 moment.locale('en');
30858 moment.createFromInputFallback = function () {
30859 throw new Error('input not handled by moment');
30860 };
30861 if (lifecycle && lifecycle.setup) {
30862 lifecycle.setup();
30863 }
30864 },
30865 teardown : function () {
30866 if (lifecycle && lifecycle.teardown) {
30867 lifecycle.teardown();
30868 }
30869 }
30870 });
30871 }
30872
30873 function localeModule (name, lifecycle) {
30874 QUnit.module('locale:' + name, {
30875 setup : function () {
30876 moment.locale(name);
30877 moment.createFromInputFallback = function () {
30878 throw new Error('input not handled by moment');
30879 };
30880 if (lifecycle && lifecycle.setup) {
30881 lifecycle.setup();
30882 }
30883 },
30884 teardown : function () {
30885 moment.locale('en');
30886 if (lifecycle && lifecycle.teardown) {
30887 lifecycle.teardown();
30888 }
30889 }
30890 });
30891 }
30892
30893 localeModule('zh-cn');
30894
30895 test('parse', function (assert) {
30896 var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
30897
30898 function equalTest(input, mmm, i) {
30899 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
30900 }
30901
30902 for (i = 0; i < 12; i++) {
30903 tests[i] = tests[i].split(' ');
30904 equalTest(tests[i][0], 'MMM', i);
30905 equalTest(tests[i][1], 'MMM', i);
30906 equalTest(tests[i][0], 'MMMM', i);
30907 equalTest(tests[i][1], 'MMMM', i);
30908 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
30909 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
30910 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
30911 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
30912 }
30913 });
30914
30915 test('format', function (assert) {
30916 var a = [
30917 ['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14日 2010, 下午 3:25:50'],
30918 ['ddd, Ah', '周日, 下午3'],
30919 ['M Mo MM MMMM MMM', '2 2月 02 二月 2月'],
30920 ['YYYY YY', '2010 10'],
30921 ['D Do DD', '14 14日 14'],
30922 ['d do dddd ddd dd', '0 0日 星期日 周日 日'],
30923 ['DDD DDDo DDDD', '45 45日 045'],
30924 ['w wo ww', '6 6周 06'],
30925 ['h hh', '3 03'],
30926 ['H HH', '15 15'],
30927 ['m mm', '25 25'],
30928 ['s ss', '50 50'],
30929 ['a A', '下午 下午'],
30930 ['[这年的第] DDDo', '这年的第 45日'],
30931 ['LTS', '下午3点25分50秒'],
30932 ['L', '2010-02-14'],
30933 ['LL', '2010年2月14日'],
30934 ['LLL', '2010年2月14日下午3点25分'],
30935 ['LLLL', '2010年2月14日星期日下午3点25分'],
30936 ['l', '2010-02-14'],
30937 ['ll', '2010年2月14日'],
30938 ['lll', '2010年2月14日下午3点25分'],
30939 ['llll', '2010年2月14日星期日下午3点25分']
30940 ],
30941 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
30942 i;
30943
30944 for (i = 0; i < a.length; i++) {
30945 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
30946 }
30947 });
30948
30949 test('format month', function (assert) {
30950 var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
30951
30952 for (i = 0; i < expected.length; i++) {
30953 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
30954 }
30955 });
30956
30957 test('format week', function (assert) {
30958 var expected = '星期日 周日 日_星期一 周一 一_星期二 周二 二_星期三 周三 三_星期四 周四 四_星期五 周五 五_星期六 周六 六'.split('_'), i;
30959
30960 for (i = 0; i < expected.length; i++) {
30961 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
30962 }
30963 });
30964
30965 test('from', function (assert) {
30966 var start = moment([2007, 1, 28]);
30967 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '几秒', '44 seconds = a few seconds');
30968 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1 分钟', '45 seconds = a minute');
30969 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1 分钟', '89 seconds = a minute');
30970 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 分钟', '90 seconds = 2 minutes');
30971 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 分钟', '44 minutes = 44 minutes');
30972 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1 小时', '45 minutes = an hour');
30973 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1 小时', '89 minutes = an hour');
30974 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 小时', '90 minutes = 2 hours');
30975 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 小时', '5 hours = 5 hours');
30976 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 小时', '21 hours = 21 hours');
30977 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1 天', '22 hours = a day');
30978 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1 天', '35 hours = a day');
30979 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 天', '36 hours = 2 days');
30980 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1 天', '1 day = a day');
30981 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 天', '5 days = 5 days');
30982 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 天', '25 days = 25 days');
30983 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1 个月', '26 days = a month');
30984 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1 个月', '30 days = a month');
30985 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1 个月', '43 days = a month');
30986 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 个月', '46 days = 2 months');
30987 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 个月', '75 days = 2 months');
30988 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 个月', '76 days = 3 months');
30989 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1 个月', '1 month = a month');
30990 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 个月', '5 months = 5 months');
30991 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1 年', '345 days = a year');
30992 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 年', '548 days = 2 years');
30993 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1 年', '1 year = a year');
30994 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 年', '5 years = 5 years');
30995 });
30996
30997 test('suffix', function (assert) {
30998 assert.equal(moment(30000).from(0), '几秒内', 'prefix');
30999 assert.equal(moment(0).from(30000), '几秒前', 'suffix');
31000 });
31001
31002 test('now from now', function (assert) {
31003 assert.equal(moment().fromNow(), '几秒前', 'now from now should display as in the past');
31004 });
31005
31006 test('fromNow', function (assert) {
31007 assert.equal(moment().add({s: 30}).fromNow(), '几秒内', 'in a few seconds');
31008 assert.equal(moment().add({d: 5}).fromNow(), '5 天内', 'in 5 days');
31009 });
31010
31011 test('calendar day', function (assert) {
31012 var a = moment().hours(2).minutes(0).seconds(0);
31013
31014 assert.equal(moment(a).calendar(), '今天凌晨2点整', 'today at the same time');
31015 assert.equal(moment(a).add({m: 25}).calendar(), '今天凌晨2点25分', 'Now plus 25 min');
31016 assert.equal(moment(a).add({h: 1}).calendar(), '今天凌晨3点整', 'Now plus 1 hour');
31017 assert.equal(moment(a).add({d: 1}).calendar(), '明天凌晨2点整', 'tomorrow at the same time');
31018 assert.equal(moment(a).subtract({h: 1}).calendar(), '今天凌晨1点整', 'Now minus 1 hour');
31019 assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天凌晨2点整', 'yesterday at the same time');
31020 });
31021
31022 test('calendar current week', function (assert) {
31023 var i, m,
31024 today = moment().startOf('day');
31025
31026 for (i = 0; i < 7; i++) {
31027 m = moment().startOf('week').add({d: i});
31028 if (Math.abs(m.diff(today, 'days')) <= 1) {
31029 continue; // skip today, yesterday, tomorrow
31030 }
31031 assert.equal(m.calendar(), m.format('[本]ddd凌晨12点整'), 'Monday + ' + i + ' days current time');
31032 }
31033 });
31034
31035 test('calendar next week', function (assert) {
31036 var i, m,
31037 today = moment().startOf('day');
31038
31039 for (i = 7; i < 14; i++) {
31040 m = moment().startOf('week').add({d: i});
31041 if (Math.abs(m.diff(today, 'days')) >= 7) {
31042 continue;
31043 }
31044 if (Math.abs(m.diff(today, 'days')) <= 1) {
31045 continue; // skip today, yesterday, tomorrow
31046 }
31047 assert.equal(m.calendar(), m.format('[下]ddd凌晨12点整'), 'Today + ' + i + ' days beginning of day');
31048 }
31049 assert.equal(42, 42, 'at least one assert');
31050 });
31051
31052 test('calendar last week', function (assert) {
31053 var i, m,
31054 today = moment().startOf('day');
31055
31056 for (i = 1; i < 8; i++) {
31057 m = moment().startOf('week').subtract({d: i});
31058 if ((Math.abs(m.diff(today, 'days')) >= 7) || (Math.abs(m.diff(today, 'days')) <= 1)) {
31059 continue;
31060 }
31061 assert.equal(m.calendar(), m.format('[上]ddd凌晨12点整'), 'Monday - ' + i + ' days next week');
31062 }
31063 assert.equal(42, 42, 'at least one assert');
31064 });
31065
31066 test('calendar all else', function (assert) {
31067 var weeksAgo = moment().subtract({w: 1}),
31068 weeksFromNow = moment().add({w: 1});
31069
31070 assert.equal(weeksAgo.calendar(), weeksAgo.format('LL'), '1 week ago');
31071 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('LL'), 'in 1 week');
31072
31073 weeksAgo = moment().subtract({w: 2});
31074 weeksFromNow = moment().add({w: 2});
31075
31076 assert.equal(weeksAgo.calendar(), weeksAgo.format('LL'), '2 weeks ago');
31077 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('LL'), 'in 2 weeks');
31078 });
31079
31080 test('meridiem', function (assert) {
31081 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), '凌晨', 'before dawn');
31082 assert.equal(moment([2011, 2, 23, 6, 0]).format('A'), '早上', 'morning');
31083 assert.equal(moment([2011, 2, 23, 9, 0]).format('A'), '上午', 'before noon');
31084 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), '中午', 'noon');
31085 assert.equal(moment([2011, 2, 23, 13, 0]).format('A'), '下午', 'afternoon');
31086 assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
31087 });
31088
31089 test('weeks year starting sunday', function (assert) {
31090 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
31091 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 52');
31092 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
31093 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
31094 });
31095
31096 test('weeks year starting monday', function (assert) {
31097 assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
31098 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
31099 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
31100 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
31101 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
31102 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
31103 });
31104
31105 test('weeks year starting tuesday', function (assert) {
31106 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
31107 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
31108 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
31109 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
31110 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
31111 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
31112 });
31113
31114 test('weeks year starting wednesday', function (assert) {
31115 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
31116 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
31117 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
31118 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
31119 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
31120 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
31121 });
31122
31123 test('weeks year starting thursday', function (assert) {
31124 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
31125 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
31126 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
31127 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
31128 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
31129 });
31130
31131 test('weeks year starting friday', function (assert) {
31132 assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
31133 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
31134 });
31135
31136 test('weeks year starting saturday', function (assert) {
31137 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
31138 assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
31139 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
31140 });
31141
31142 test('weeks year starting sunday format', function (assert) {
31143 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52周', 'Jan 1 2012 应该是第52周');
31144 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1周', 'Jan 7 2012 应该是第 1周');
31145 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2周', 'Jan 14 2012 应该是第 2周');
31146 });
31147
31148 test('lenient ordinal parsing', function (assert) {
31149 var i, ordinalStr, testMoment;
31150 for (i = 1; i <= 31; ++i) {
31151 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
31152 testMoment = moment(ordinalStr, 'YYYY MM Do');
31153 assert.equal(testMoment.year(), 2014,
31154 'lenient ordinal parsing ' + i + ' year check');
31155 assert.equal(testMoment.month(), 0,
31156 'lenient ordinal parsing ' + i + ' month check');
31157 assert.equal(testMoment.date(), i,
31158 'lenient ordinal parsing ' + i + ' date check');
31159 }
31160 });
31161
31162 test('lenient ordinal parsing of number', function (assert) {
31163 var i, testMoment;
31164 for (i = 1; i <= 31; ++i) {
31165 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
31166 assert.equal(testMoment.year(), 2014,
31167 'lenient ordinal parsing of number ' + i + ' year check');
31168 assert.equal(testMoment.month(), 0,
31169 'lenient ordinal parsing of number ' + i + ' month check');
31170 assert.equal(testMoment.date(), i,
31171 'lenient ordinal parsing of number ' + i + ' date check');
31172 }
31173 });
31174
31175 test('meridiem invariant', function (assert) {
31176 var h, m, t1, t2;
31177 for (h = 0; h < 24; ++h) {
31178 for (m = 0; m < 60; m += 15) {
31179 t1 = moment.utc([2000, 0, 1, h, m]);
31180 t2 = moment(t1.format('A h:mm'), 'A h:mm');
31181 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
31182 'meridiem at ' + t1.format('HH:mm'));
31183 }
31184 }
31185 });
31186
31187 test('strict ordinal parsing', function (assert) {
31188 var i, ordinalStr, testMoment;
31189 for (i = 1; i <= 31; ++i) {
31190 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
31191 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
31192 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
31193 }
31194 });
31195
31196 }));
31197
31198 (function (global, factory) {
31199 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
31200 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
31201 factory(global.moment)
31202 }(this, function (moment) { 'use strict';
31203
31204 /*global QUnit:false*/
31205
31206 var test = QUnit.test;
31207
31208 function module (name, lifecycle) {
31209 QUnit.module(name, {
31210 setup : function () {
31211 moment.locale('en');
31212 moment.createFromInputFallback = function () {
31213 throw new Error('input not handled by moment');
31214 };
31215 if (lifecycle && lifecycle.setup) {
31216 lifecycle.setup();
31217 }
31218 },
31219 teardown : function () {
31220 if (lifecycle && lifecycle.teardown) {
31221 lifecycle.teardown();
31222 }
31223 }
31224 });
31225 }
31226
31227 function localeModule (name, lifecycle) {
31228 QUnit.module('locale:' + name, {
31229 setup : function () {
31230 moment.locale(name);
31231 moment.createFromInputFallback = function () {
31232 throw new Error('input not handled by moment');
31233 };
31234 if (lifecycle && lifecycle.setup) {
31235 lifecycle.setup();
31236 }
31237 },
31238 teardown : function () {
31239 moment.locale('en');
31240 if (lifecycle && lifecycle.teardown) {
31241 lifecycle.teardown();
31242 }
31243 }
31244 });
31245 }
31246
31247 localeModule('zh-tw');
31248
31249 test('parse', function (assert) {
31250 var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
31251 function equalTest(input, mmm, i) {
31252 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
31253 }
31254 for (i = 0; i < 12; i++) {
31255 tests[i] = tests[i].split(' ');
31256 equalTest(tests[i][0], 'MMM', i);
31257 equalTest(tests[i][1], 'MMM', i);
31258 equalTest(tests[i][0], 'MMMM', i);
31259 equalTest(tests[i][1], 'MMMM', i);
31260 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
31261 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
31262 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
31263 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
31264 }
31265 });
31266
31267 test('format', function (assert) {
31268 var a = [
31269 ['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14日 2010, 下午 3:25:50'],
31270 ['ddd, Ah', '週日, 下午3'],
31271 ['M Mo MM MMMM MMM', '2 2月 02 二月 2月'],
31272 ['YYYY YY', '2010 10'],
31273 ['D Do DD', '14 14日 14'],
31274 ['d do dddd ddd dd', '0 0日 星期日 週日 日'],
31275 ['DDD DDDo DDDD', '45 45日 045'],
31276 ['w wo ww', '8 8週 08'],
31277 ['h hh', '3 03'],
31278 ['H HH', '15 15'],
31279 ['m mm', '25 25'],
31280 ['s ss', '50 50'],
31281 ['a A', '下午 下午'],
31282 ['[這年的第] DDDo', '這年的第 45日'],
31283 ['LTS', '下午3點25分50秒'],
31284 ['L', '2010年2月14日'],
31285 ['LL', '2010年2月14日'],
31286 ['LLL', '2010年2月14日下午3點25分'],
31287 ['LLLL', '2010年2月14日星期日下午3點25分'],
31288 ['l', '2010年2月14日'],
31289 ['ll', '2010年2月14日'],
31290 ['lll', '2010年2月14日下午3點25分'],
31291 ['llll', '2010年2月14日星期日下午3點25分']
31292 ],
31293 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
31294 i;
31295
31296 for (i = 0; i < a.length; i++) {
31297 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
31298 }
31299 });
31300
31301 test('format month', function (assert) {
31302 var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
31303
31304 for (i = 0; i < expected.length; i++) {
31305 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
31306 }
31307 });
31308
31309 test('format week', function (assert) {
31310 var expected = '星期日 週日 日_星期一 週一 一_星期二 週二 二_星期三 週三 三_星期四 週四 四_星期五 週五 五_星期六 週六 六'.split('_'), i;
31311
31312 for (i = 0; i < expected.length; i++) {
31313 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
31314 }
31315 });
31316
31317 test('from', function (assert) {
31318 var start = moment([2007, 1, 28]);
31319 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '幾秒', '44 seconds = a few seconds');
31320 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '一分鐘', '45 seconds = a minute');
31321 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '一分鐘', '89 seconds = a minute');
31322 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2分鐘', '90 seconds = 2 minutes');
31323 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44分鐘', '44 minutes = 44 minutes');
31324 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '一小時', '45 minutes = an hour');
31325 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '一小時', '89 minutes = an hour');
31326 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2小時', '90 minutes = 2 hours');
31327 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5小時', '5 hours = 5 hours');
31328 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21小時', '21 hours = 21 hours');
31329 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '一天', '22 hours = a day');
31330 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '一天', '35 hours = a day');
31331 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2天', '36 hours = 2 days');
31332 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '一天', '1 day = a day');
31333 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5天', '5 days = 5 days');
31334 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25天', '25 days = 25 days');
31335 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '一個月', '26 days = a month');
31336 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '一個月', '30 days = a month');
31337 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '一個月', '43 days = a month');
31338 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2個月', '46 days = 2 months');
31339 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2個月', '75 days = 2 months');
31340 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3個月', '76 days = 3 months');
31341 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '一個月', '1 month = a month');
31342 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5個月', '5 months = 5 months');
31343 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '一年', '345 days = a year');
31344 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2年', '548 days = 2 years');
31345 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '一年', '1 year = a year');
31346 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5年', '5 years = 5 years');
31347 });
31348
31349 test('suffix', function (assert) {
31350 assert.equal(moment(30000).from(0), '幾秒內', 'prefix');
31351 assert.equal(moment(0).from(30000), '幾秒前', 'suffix');
31352 });
31353
31354 test('now from now', function (assert) {
31355 assert.equal(moment().fromNow(), '幾秒前', 'now from now should display as in the past');
31356 });
31357
31358 test('fromNow', function (assert) {
31359 assert.equal(moment().add({s: 30}).fromNow(), '幾秒內', 'in a few seconds');
31360 assert.equal(moment().add({d: 5}).fromNow(), '5天內', 'in 5 days');
31361 });
31362
31363 test('calendar day', function (assert) {
31364 var a = moment().hours(2).minutes(0).seconds(0);
31365
31366 assert.equal(moment(a).calendar(), '今天早上2點00分', 'today at the same time');
31367 assert.equal(moment(a).add({m: 25}).calendar(), '今天早上2點25分', 'Now plus 25 min');
31368 assert.equal(moment(a).add({h: 1}).calendar(), '今天早上3點00分', 'Now plus 1 hour');
31369 assert.equal(moment(a).add({d: 1}).calendar(), '明天早上2點00分', 'tomorrow at the same time');
31370 assert.equal(moment(a).subtract({h: 1}).calendar(), '今天早上1點00分', 'Now minus 1 hour');
31371 assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天早上2點00分', 'yesterday at the same time');
31372 });
31373
31374 test('calendar next week', function (assert) {
31375 var i, m;
31376 for (i = 2; i < 7; i++) {
31377 m = moment().add({d: i});
31378 assert.equal(m.calendar(), m.format('[下]ddddLT'), 'Today + ' + i + ' days current time');
31379 m.hours(0).minutes(0).seconds(0).milliseconds(0);
31380 assert.equal(m.calendar(), m.format('[下]ddddLT'), 'Today + ' + i + ' days beginning of day');
31381 m.hours(23).minutes(59).seconds(59).milliseconds(999);
31382 assert.equal(m.calendar(), m.format('[下]ddddLT'), 'Today + ' + i + ' days end of day');
31383 }
31384 });
31385
31386 test('calendar last week', function (assert) {
31387 var i, m;
31388 for (i = 2; i < 7; i++) {
31389 m = moment().subtract({d: i});
31390 assert.equal(m.calendar(), m.format('[上]ddddLT'), 'Today - ' + i + ' days current time');
31391 m.hours(0).minutes(0).seconds(0).milliseconds(0);
31392 assert.equal(m.calendar(), m.format('[上]ddddLT'), 'Today - ' + i + ' days beginning of day');
31393 m.hours(23).minutes(59).seconds(59).milliseconds(999);
31394 assert.equal(m.calendar(), m.format('[上]ddddLT'), 'Today - ' + i + ' days end of day');
31395 }
31396 });
31397
31398 test('calendar all else', function (assert) {
31399 var weeksAgo = moment().subtract({w: 1}),
31400 weeksFromNow = moment().add({w: 1});
31401
31402 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
31403 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
31404
31405 weeksAgo = moment().subtract({w: 2});
31406 weeksFromNow = moment().add({w: 2});
31407
31408 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
31409 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
31410 });
31411
31412 test('meridiem', function (assert) {
31413 assert.equal(moment([2011, 2, 23, 0, 0]).format('a'), '早上', 'morning');
31414 assert.equal(moment([2011, 2, 23, 9, 0]).format('a'), '上午', 'before noon');
31415 assert.equal(moment([2011, 2, 23, 12, 0]).format('a'), '中午', 'noon');
31416 assert.equal(moment([2011, 2, 23, 13, 0]).format('a'), '下午', 'after noon');
31417 assert.equal(moment([2011, 2, 23, 18, 0]).format('a'), '晚上', 'night');
31418
31419 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), '早上', 'morning');
31420 assert.equal(moment([2011, 2, 23, 9, 0]).format('A'), '上午', 'before noon');
31421 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), '中午', 'noon');
31422 assert.equal(moment([2011, 2, 23, 13, 0]).format('A'), '下午', 'afternoon');
31423 assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
31424 });
31425
31426 test('weeks year starting sunday', function (assert) {
31427 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
31428 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
31429 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
31430 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
31431 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
31432 });
31433
31434 test('weeks year starting monday', function (assert) {
31435 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
31436 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
31437 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
31438 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
31439 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
31440 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
31441 });
31442
31443 test('weeks year starting tuesday', function (assert) {
31444 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
31445 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
31446 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
31447 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
31448 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
31449 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
31450 });
31451
31452 test('weeks year starting wednesday', function (assert) {
31453 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
31454 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
31455 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
31456 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
31457 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
31458 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
31459 });
31460
31461 test('weeks year starting thursday', function (assert) {
31462 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
31463 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
31464 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
31465 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
31466 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
31467 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
31468 });
31469
31470 test('weeks year starting friday', function (assert) {
31471 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
31472 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
31473 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
31474 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
31475 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
31476 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
31477 });
31478
31479 test('weeks year starting saturday', function (assert) {
31480 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
31481 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
31482 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
31483 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
31484 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
31485 });
31486
31487 test('weeks year starting sunday format', function (assert) {
31488 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1週', 'Jan 1 2012 應該是第 1週');
31489 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1週', 'Jan 7 2012 應該是第 1週');
31490 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2週', 'Jan 8 2012 應該是第 2週');
31491 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2週', 'Jan 14 2012 應該是第 2週');
31492 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3週', 'Jan 15 2012 應該是第 3週');
31493 });
31494
31495 test('lenient ordinal parsing', function (assert) {
31496 var i, ordinalStr, testMoment;
31497 for (i = 1; i <= 31; ++i) {
31498 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
31499 testMoment = moment(ordinalStr, 'YYYY MM Do');
31500 assert.equal(testMoment.year(), 2014,
31501 'lenient ordinal parsing ' + i + ' year check');
31502 assert.equal(testMoment.month(), 0,
31503 'lenient ordinal parsing ' + i + ' month check');
31504 assert.equal(testMoment.date(), i,
31505 'lenient ordinal parsing ' + i + ' date check');
31506 }
31507 });
31508
31509 test('lenient ordinal parsing of number', function (assert) {
31510 var i, testMoment;
31511 for (i = 1; i <= 31; ++i) {
31512 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
31513 assert.equal(testMoment.year(), 2014,
31514 'lenient ordinal parsing of number ' + i + ' year check');
31515 assert.equal(testMoment.month(), 0,
31516 'lenient ordinal parsing of number ' + i + ' month check');
31517 assert.equal(testMoment.date(), i,
31518 'lenient ordinal parsing of number ' + i + ' date check');
31519 }
31520 });
31521
31522 test('meridiem invariant', function (assert) {
31523 var h, m, t1, t2;
31524 for (h = 0; h < 24; ++h) {
31525 for (m = 0; m < 60; m += 15) {
31526 t1 = moment.utc([2000, 0, 1, h, m]);
31527 t2 = moment(t1.format('A h:mm'), 'A h:mm');
31528 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
31529 'meridiem at ' + t1.format('HH:mm'));
31530 }
31531 }
31532 });
31533
31534 test('strict ordinal parsing', function (assert) {
31535 var i, ordinalStr, testMoment;
31536 for (i = 1; i <= 31; ++i) {
31537 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
31538 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
31539 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
31540 }
31541 });
31542
31543 }));
31544
31545 (function (global, factory) {
31546 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
31547 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
31548 factory(global.moment)
31549 }(this, function (moment) { 'use strict';
31550
31551 /*global QUnit:false*/
31552
31553 var test = QUnit.test;
31554
31555 function module (name, lifecycle) {
31556 QUnit.module(name, {
31557 setup : function () {
31558 moment.locale('en');
31559 moment.createFromInputFallback = function () {
31560 throw new Error('input not handled by moment');
31561 };
31562 if (lifecycle && lifecycle.setup) {
31563 lifecycle.setup();
31564 }
31565 },
31566 teardown : function () {
31567 if (lifecycle && lifecycle.teardown) {
31568 lifecycle.teardown();
31569 }
31570 }
31571 });
31572 }
31573
31574 function localeModule (name, lifecycle) {
31575 QUnit.module('locale:' + name, {
31576 setup : function () {
31577 moment.locale(name);
31578 moment.createFromInputFallback = function () {
31579 throw new Error('input not handled by moment');
31580 };
31581 if (lifecycle && lifecycle.setup) {
31582 lifecycle.setup();
31583 }
31584 },
31585 teardown : function () {
31586 moment.locale('en');
31587 if (lifecycle && lifecycle.teardown) {
31588 lifecycle.teardown();
31589 }
31590 }
31591 });
31592 }
31593
31594 module('add and subtract');
31595
31596 test('add short reverse args', function (assert) {
31597 var a = moment(), b, c, d;
31598 a.year(2011);
31599 a.month(9);
31600 a.date(12);
31601 a.hours(6);
31602 a.minutes(7);
31603 a.seconds(8);
31604 a.milliseconds(500);
31605
31606 assert.equal(a.add({ms: 50}).milliseconds(), 550, 'Add milliseconds');
31607 assert.equal(a.add({s: 1}).seconds(), 9, 'Add seconds');
31608 assert.equal(a.add({m: 1}).minutes(), 8, 'Add minutes');
31609 assert.equal(a.add({h: 1}).hours(), 7, 'Add hours');
31610 assert.equal(a.add({d: 1}).date(), 13, 'Add date');
31611 assert.equal(a.add({w: 1}).date(), 20, 'Add week');
31612 assert.equal(a.add({M: 1}).month(), 10, 'Add month');
31613 assert.equal(a.add({y: 1}).year(), 2012, 'Add year');
31614 assert.equal(a.add({Q: 1}).month(), 1, 'Add quarter');
31615
31616 b = moment([2010, 0, 31]).add({M: 1});
31617 c = moment([2010, 1, 28]).subtract({M: 1});
31618 d = moment([2010, 1, 28]).subtract({Q: 1});
31619
31620 assert.equal(b.month(), 1, 'add month, jan 31st to feb 28th');
31621 assert.equal(b.date(), 28, 'add month, jan 31st to feb 28th');
31622 assert.equal(c.month(), 0, 'subtract month, feb 28th to jan 28th');
31623 assert.equal(c.date(), 28, 'subtract month, feb 28th to jan 28th');
31624 assert.equal(d.month(), 10, 'subtract quarter, feb 28th 2010 to nov 28th 2009');
31625 assert.equal(d.date(), 28, 'subtract quarter, feb 28th 2010 to nov 28th 2009');
31626 assert.equal(d.year(), 2009, 'subtract quarter, feb 28th 2010 to nov 28th 2009');
31627 });
31628
31629 test('add long reverse args', function (assert) {
31630 var a = moment();
31631 a.year(2011);
31632 a.month(9);
31633 a.date(12);
31634 a.hours(6);
31635 a.minutes(7);
31636 a.seconds(8);
31637 a.milliseconds(500);
31638
31639 assert.equal(a.add({milliseconds: 50}).milliseconds(), 550, 'Add milliseconds');
31640 assert.equal(a.add({seconds: 1}).seconds(), 9, 'Add seconds');
31641 assert.equal(a.add({minutes: 1}).minutes(), 8, 'Add minutes');
31642 assert.equal(a.add({hours: 1}).hours(), 7, 'Add hours');
31643 assert.equal(a.add({days: 1}).date(), 13, 'Add date');
31644 assert.equal(a.add({weeks: 1}).date(), 20, 'Add week');
31645 assert.equal(a.add({months: 1}).month(), 10, 'Add month');
31646 assert.equal(a.add({years: 1}).year(), 2012, 'Add year');
31647 assert.equal(a.add({quarters: 1}).month(), 1, 'Add quarter');
31648 });
31649
31650 test('add long singular reverse args', function (assert) {
31651 var a = moment();
31652 a.year(2011);
31653 a.month(9);
31654 a.date(12);
31655 a.hours(6);
31656 a.minutes(7);
31657 a.seconds(8);
31658 a.milliseconds(500);
31659
31660 assert.equal(a.add({millisecond: 50}).milliseconds(), 550, 'Add milliseconds');
31661 assert.equal(a.add({second: 1}).seconds(), 9, 'Add seconds');
31662 assert.equal(a.add({minute: 1}).minutes(), 8, 'Add minutes');
31663 assert.equal(a.add({hour: 1}).hours(), 7, 'Add hours');
31664 assert.equal(a.add({day: 1}).date(), 13, 'Add date');
31665 assert.equal(a.add({week: 1}).date(), 20, 'Add week');
31666 assert.equal(a.add({month: 1}).month(), 10, 'Add month');
31667 assert.equal(a.add({year: 1}).year(), 2012, 'Add year');
31668 assert.equal(a.add({quarter: 1}).month(), 1, 'Add quarter');
31669 });
31670
31671 test('add string long reverse args', function (assert) {
31672 var a = moment(), b;
31673 a.year(2011);
31674 a.month(9);
31675 a.date(12);
31676 a.hours(6);
31677 a.minutes(7);
31678 a.seconds(8);
31679 a.milliseconds(500);
31680
31681 b = a.clone();
31682
31683 assert.equal(a.add('millisecond', 50).milliseconds(), 550, 'Add milliseconds');
31684 assert.equal(a.add('second', 1).seconds(), 9, 'Add seconds');
31685 assert.equal(a.add('minute', 1).minutes(), 8, 'Add minutes');
31686 assert.equal(a.add('hour', 1).hours(), 7, 'Add hours');
31687 assert.equal(a.add('day', 1).date(), 13, 'Add date');
31688 assert.equal(a.add('week', 1).date(), 20, 'Add week');
31689 assert.equal(a.add('month', 1).month(), 10, 'Add month');
31690 assert.equal(a.add('year', 1).year(), 2012, 'Add year');
31691 assert.equal(b.add('day', '01').date(), 13, 'Add date');
31692 assert.equal(a.add('quarter', 1).month(), 1, 'Add quarter');
31693 });
31694
31695 test('add string long singular reverse args', function (assert) {
31696 var a = moment(), b;
31697 a.year(2011);
31698 a.month(9);
31699 a.date(12);
31700 a.hours(6);
31701 a.minutes(7);
31702 a.seconds(8);
31703 a.milliseconds(500);
31704
31705 b = a.clone();
31706
31707 assert.equal(a.add('milliseconds', 50).milliseconds(), 550, 'Add milliseconds');
31708 assert.equal(a.add('seconds', 1).seconds(), 9, 'Add seconds');
31709 assert.equal(a.add('minutes', 1).minutes(), 8, 'Add minutes');
31710 assert.equal(a.add('hours', 1).hours(), 7, 'Add hours');
31711 assert.equal(a.add('days', 1).date(), 13, 'Add date');
31712 assert.equal(a.add('weeks', 1).date(), 20, 'Add week');
31713 assert.equal(a.add('months', 1).month(), 10, 'Add month');
31714 assert.equal(a.add('years', 1).year(), 2012, 'Add year');
31715 assert.equal(b.add('days', '01').date(), 13, 'Add date');
31716 assert.equal(a.add('quarters', 1).month(), 1, 'Add quarter');
31717 });
31718
31719 test('add string short reverse args', function (assert) {
31720 var a = moment();
31721 a.year(2011);
31722 a.month(9);
31723 a.date(12);
31724 a.hours(6);
31725 a.minutes(7);
31726 a.seconds(8);
31727 a.milliseconds(500);
31728
31729 assert.equal(a.add('ms', 50).milliseconds(), 550, 'Add milliseconds');
31730 assert.equal(a.add('s', 1).seconds(), 9, 'Add seconds');
31731 assert.equal(a.add('m', 1).minutes(), 8, 'Add minutes');
31732 assert.equal(a.add('h', 1).hours(), 7, 'Add hours');
31733 assert.equal(a.add('d', 1).date(), 13, 'Add date');
31734 assert.equal(a.add('w', 1).date(), 20, 'Add week');
31735 assert.equal(a.add('M', 1).month(), 10, 'Add month');
31736 assert.equal(a.add('y', 1).year(), 2012, 'Add year');
31737 assert.equal(a.add('Q', 1).month(), 1, 'Add quarter');
31738 });
31739
31740 test('add string long', function (assert) {
31741 var a = moment();
31742 a.year(2011);
31743 a.month(9);
31744 a.date(12);
31745 a.hours(6);
31746 a.minutes(7);
31747 a.seconds(8);
31748 a.milliseconds(500);
31749
31750 assert.equal(a.add(50, 'millisecond').milliseconds(), 550, 'Add milliseconds');
31751 assert.equal(a.add(1, 'second').seconds(), 9, 'Add seconds');
31752 assert.equal(a.add(1, 'minute').minutes(), 8, 'Add minutes');
31753 assert.equal(a.add(1, 'hour').hours(), 7, 'Add hours');
31754 assert.equal(a.add(1, 'day').date(), 13, 'Add date');
31755 assert.equal(a.add(1, 'week').date(), 20, 'Add week');
31756 assert.equal(a.add(1, 'month').month(), 10, 'Add month');
31757 assert.equal(a.add(1, 'year').year(), 2012, 'Add year');
31758 assert.equal(a.add(1, 'quarter').month(), 1, 'Add quarter');
31759 });
31760
31761 test('add string long singular', function (assert) {
31762 var a = moment();
31763 a.year(2011);
31764 a.month(9);
31765 a.date(12);
31766 a.hours(6);
31767 a.minutes(7);
31768 a.seconds(8);
31769 a.milliseconds(500);
31770
31771 assert.equal(a.add(50, 'milliseconds').milliseconds(), 550, 'Add milliseconds');
31772 assert.equal(a.add(1, 'seconds').seconds(), 9, 'Add seconds');
31773 assert.equal(a.add(1, 'minutes').minutes(), 8, 'Add minutes');
31774 assert.equal(a.add(1, 'hours').hours(), 7, 'Add hours');
31775 assert.equal(a.add(1, 'days').date(), 13, 'Add date');
31776 assert.equal(a.add(1, 'weeks').date(), 20, 'Add week');
31777 assert.equal(a.add(1, 'months').month(), 10, 'Add month');
31778 assert.equal(a.add(1, 'years').year(), 2012, 'Add year');
31779 assert.equal(a.add(1, 'quarters').month(), 1, 'Add quarter');
31780 });
31781
31782 test('add string short', function (assert) {
31783 var a = moment();
31784 a.year(2011);
31785 a.month(9);
31786 a.date(12);
31787 a.hours(6);
31788 a.minutes(7);
31789 a.seconds(8);
31790 a.milliseconds(500);
31791
31792 assert.equal(a.add(50, 'ms').milliseconds(), 550, 'Add milliseconds');
31793 assert.equal(a.add(1, 's').seconds(), 9, 'Add seconds');
31794 assert.equal(a.add(1, 'm').minutes(), 8, 'Add minutes');
31795 assert.equal(a.add(1, 'h').hours(), 7, 'Add hours');
31796 assert.equal(a.add(1, 'd').date(), 13, 'Add date');
31797 assert.equal(a.add(1, 'w').date(), 20, 'Add week');
31798 assert.equal(a.add(1, 'M').month(), 10, 'Add month');
31799 assert.equal(a.add(1, 'y').year(), 2012, 'Add year');
31800 assert.equal(a.add(1, 'Q').month(), 1, 'Add quarter');
31801 });
31802
31803 test('add strings string short args', function (assert) {
31804 var a = moment();
31805 a.year(2011);
31806 a.month(9);
31807 a.date(12);
31808 a.hours(6);
31809 a.minutes(7);
31810 a.seconds(8);
31811 a.milliseconds(500);
31812
31813 assert.equal(a.add('ms', '50').milliseconds(), 550, 'Add milliseconds');
31814 assert.equal(a.add('s', '1').seconds(), 9, 'Add seconds');
31815 assert.equal(a.add('m', '1').minutes(), 8, 'Add minutes');
31816 assert.equal(a.add('h', '1').hours(), 7, 'Add hours');
31817 assert.equal(a.add('d', '1').date(), 13, 'Add date');
31818 assert.equal(a.add('w', '1').date(), 20, 'Add week');
31819 assert.equal(a.add('M', '1').month(), 10, 'Add month');
31820 assert.equal(a.add('y', '1').year(), 2012, 'Add year');
31821 assert.equal(a.add('Q', '1').month(), 1, 'Add quarter');
31822 });
31823
31824 test('subtract strings string short args', function (assert) {
31825 var a = moment();
31826 a.year(2011);
31827 a.month(9);
31828 a.date(12);
31829 a.hours(6);
31830 a.minutes(7);
31831 a.seconds(8);
31832 a.milliseconds(500);
31833
31834 assert.equal(a.subtract('ms', '50').milliseconds(), 450, 'Subtract milliseconds');
31835 assert.equal(a.subtract('s', '1').seconds(), 7, 'Subtract seconds');
31836 assert.equal(a.subtract('m', '1').minutes(), 6, 'Subtract minutes');
31837 assert.equal(a.subtract('h', '1').hours(), 5, 'Subtract hours');
31838 assert.equal(a.subtract('d', '1').date(), 11, 'Subtract date');
31839 assert.equal(a.subtract('w', '1').date(), 4, 'Subtract week');
31840 assert.equal(a.subtract('M', '1').month(), 8, 'Subtract month');
31841 assert.equal(a.subtract('y', '1').year(), 2010, 'Subtract year');
31842 assert.equal(a.subtract('Q', '1').month(), 5, 'Subtract quarter');
31843 });
31844
31845 test('add strings string short', function (assert) {
31846 var a = moment();
31847 a.year(2011);
31848 a.month(9);
31849 a.date(12);
31850 a.hours(6);
31851 a.minutes(7);
31852 a.seconds(8);
31853 a.milliseconds(500);
31854
31855 assert.equal(a.add('50', 'ms').milliseconds(), 550, 'Add milliseconds');
31856 assert.equal(a.add('1', 's').seconds(), 9, 'Add seconds');
31857 assert.equal(a.add('1', 'm').minutes(), 8, 'Add minutes');
31858 assert.equal(a.add('1', 'h').hours(), 7, 'Add hours');
31859 assert.equal(a.add('1', 'd').date(), 13, 'Add date');
31860 assert.equal(a.add('1', 'w').date(), 20, 'Add week');
31861 assert.equal(a.add('1', 'M').month(), 10, 'Add month');
31862 assert.equal(a.add('1', 'y').year(), 2012, 'Add year');
31863 assert.equal(a.add('1', 'Q').month(), 1, 'Add quarter');
31864 });
31865
31866 test('subtract strings string short', function (assert) {
31867 var a = moment();
31868 a.year(2011);
31869 a.month(9);
31870 a.date(12);
31871 a.hours(6);
31872 a.minutes(7);
31873 a.seconds(8);
31874 a.milliseconds(500);
31875
31876 assert.equal(a.subtract('50', 'ms').milliseconds(), 450, 'Subtract milliseconds');
31877 assert.equal(a.subtract('1', 's').seconds(), 7, 'Subtract seconds');
31878 assert.equal(a.subtract('1', 'm').minutes(), 6, 'Subtract minutes');
31879 assert.equal(a.subtract('1', 'h').hours(), 5, 'Subtract hours');
31880 assert.equal(a.subtract('1', 'd').date(), 11, 'Subtract date');
31881 assert.equal(a.subtract('1', 'w').date(), 4, 'Subtract week');
31882 assert.equal(a.subtract('1', 'M').month(), 8, 'Subtract month');
31883 assert.equal(a.subtract('1', 'y').year(), 2010, 'Subtract year');
31884 assert.equal(a.subtract('1', 'Q').month(), 5, 'Subtract quarter');
31885 });
31886
31887 test('add across DST', function (assert) {
31888 // Detect Safari bug and bail. Hours on 13th March 2011 are shifted
31889 // with 1 ahead.
31890 if (new Date(2011, 2, 13, 5, 0, 0).getHours() !== 5) {
31891 assert.expect(0);
31892 return;
31893 }
31894
31895 var a = moment(new Date(2011, 2, 12, 5, 0, 0)),
31896 b = moment(new Date(2011, 2, 12, 5, 0, 0)),
31897 c = moment(new Date(2011, 2, 12, 5, 0, 0)),
31898 d = moment(new Date(2011, 2, 12, 5, 0, 0)),
31899 e = moment(new Date(2011, 2, 12, 5, 0, 0));
31900 a.add(1, 'days');
31901 b.add(24, 'hours');
31902 c.add(1, 'months');
31903 e.add(1, 'quarter');
31904
31905 assert.equal(a.hours(), 5, 'adding days over DST difference should result in the same hour');
31906 if (b.isDST() && !d.isDST()) {
31907 assert.equal(b.hours(), 6, 'adding hours over DST difference should result in a different hour');
31908 } else if (!b.isDST() && d.isDST()) {
31909 assert.equal(b.hours(), 4, 'adding hours over DST difference should result in a different hour');
31910 } else {
31911 assert.equal(b.hours(), 5, 'adding hours over DST difference should result in a same hour if the timezone does not have daylight savings time');
31912 }
31913 assert.equal(c.hours(), 5, 'adding months over DST difference should result in the same hour');
31914 assert.equal(e.hours(), 5, 'adding quarters over DST difference should result in the same hour');
31915 });
31916
31917 }));
31918
31919 (function (global, factory) {
31920 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
31921 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
31922 factory(global.moment)
31923 }(this, function (moment) { 'use strict';
31924
31925 /*global QUnit:false*/
31926
31927 var test = QUnit.test;
31928
31929 function module (name, lifecycle) {
31930 QUnit.module(name, {
31931 setup : function () {
31932 moment.locale('en');
31933 moment.createFromInputFallback = function () {
31934 throw new Error('input not handled by moment');
31935 };
31936 if (lifecycle && lifecycle.setup) {
31937 lifecycle.setup();
31938 }
31939 },
31940 teardown : function () {
31941 if (lifecycle && lifecycle.teardown) {
31942 lifecycle.teardown();
31943 }
31944 }
31945 });
31946 }
31947
31948 function localeModule (name, lifecycle) {
31949 QUnit.module('locale:' + name, {
31950 setup : function () {
31951 moment.locale(name);
31952 moment.createFromInputFallback = function () {
31953 throw new Error('input not handled by moment');
31954 };
31955 if (lifecycle && lifecycle.setup) {
31956 lifecycle.setup();
31957 }
31958 },
31959 teardown : function () {
31960 moment.locale('en');
31961 if (lifecycle && lifecycle.teardown) {
31962 lifecycle.teardown();
31963 }
31964 }
31965 });
31966 }
31967
31968 module('create');
31969
31970 test('array', function (assert) {
31971 assert.ok(moment([2010]).toDate() instanceof Date, '[2010]');
31972 assert.ok(moment([2010, 1]).toDate() instanceof Date, '[2010, 1]');
31973 assert.ok(moment([2010, 1, 12]).toDate() instanceof Date, '[2010, 1, 12]');
31974 assert.ok(moment([2010, 1, 12, 1]).toDate() instanceof Date, '[2010, 1, 12, 1]');
31975 assert.ok(moment([2010, 1, 12, 1, 1]).toDate() instanceof Date, '[2010, 1, 12, 1, 1]');
31976 assert.ok(moment([2010, 1, 12, 1, 1, 1]).toDate() instanceof Date, '[2010, 1, 12, 1, 1, 1]');
31977 assert.ok(moment([2010, 1, 12, 1, 1, 1, 1]).toDate() instanceof Date, '[2010, 1, 12, 1, 1, 1, 1]');
31978 assert.equal(+moment(new Date(2010, 1, 14, 15, 25, 50, 125)), +moment([2010, 1, 14, 15, 25, 50, 125]), 'constructing with array === constructing with new Date()');
31979 });
31980
31981 test('array copying', function (assert) {
31982 var importantArray = [2009, 11];
31983 moment(importantArray);
31984 assert.deepEqual(importantArray, [2009, 11], 'initializer should not mutate the original array');
31985 });
31986
31987 test('object', function (assert) {
31988 var fmt = 'YYYY-MM-DD HH:mm:ss.SSS',
31989 tests = [
31990 [{year: 2010}, '2010-01-01 00:00:00.000'],
31991 [{year: 2010, month: 1}, '2010-02-01 00:00:00.000'],
31992 [{year: 2010, month: 1, day: 12}, '2010-02-12 00:00:00.000'],
31993 [{year: 2010, month: 1, date: 12}, '2010-02-12 00:00:00.000'],
31994 [{year: 2010, month: 1, day: 12, hours: 1}, '2010-02-12 01:00:00.000'],
31995 [{year: 2010, month: 1, date: 12, hours: 1}, '2010-02-12 01:00:00.000'],
31996 [{year: 2010, month: 1, day: 12, hours: 1, minutes: 1}, '2010-02-12 01:01:00.000'],
31997 [{year: 2010, month: 1, date: 12, hours: 1, minutes: 1}, '2010-02-12 01:01:00.000'],
31998 [{year: 2010, month: 1, day: 12, hours: 1, minutes: 1, seconds: 1}, '2010-02-12 01:01:01.000'],
31999 [{year: 2010, month: 1, day: 12, hours: 1, minutes: 1, seconds: 1, milliseconds: 1}, '2010-02-12 01:01:01.001'],
32000 [{years: 2010, months: 1, days: 14, hours: 15, minutes: 25, seconds: 50, milliseconds: 125}, '2010-02-14 15:25:50.125'],
32001 [{year: 2010, month: 1, day: 14, hour: 15, minute: 25, second: 50, millisecond: 125}, '2010-02-14 15:25:50.125'],
32002 [{y: 2010, M: 1, d: 14, h: 15, m: 25, s: 50, ms: 125}, '2010-02-14 15:25:50.125']
32003 ], i;
32004 for (i = 0; i < tests.length; ++i) {
32005 assert.equal(moment(tests[i][0]).format(fmt), tests[i][1]);
32006 }
32007 });
32008
32009 test('multi format array copying', function (assert) {
32010 var importantArray = ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY'];
32011 moment('1999-02-13', importantArray);
32012 assert.deepEqual(importantArray, ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY'], 'initializer should not mutate the original array');
32013 });
32014
32015 test('number', function (assert) {
32016 assert.ok(moment(1000).toDate() instanceof Date, '1000');
32017 assert.equal(moment(1000).valueOf(), 1000, 'asserting valueOf');
32018 assert.equal(moment.utc(1000).valueOf(), 1000, 'asserting valueOf');
32019 });
32020
32021 test('unix', function (assert) {
32022 assert.equal(moment.unix(1).valueOf(), 1000, '1 unix timestamp == 1000 Date.valueOf');
32023 assert.equal(moment(1000).unix(), 1, '1000 Date.valueOf == 1 unix timestamp');
32024 assert.equal(moment.unix(1000).valueOf(), 1000000, '1000 unix timestamp == 1000000 Date.valueOf');
32025 assert.equal(moment(1500).unix(), 1, '1500 Date.valueOf == 1 unix timestamp');
32026 assert.equal(moment(1900).unix(), 1, '1900 Date.valueOf == 1 unix timestamp');
32027 assert.equal(moment(2100).unix(), 2, '2100 Date.valueOf == 2 unix timestamp');
32028 assert.equal(moment(1333129333524).unix(), 1333129333, '1333129333524 Date.valueOf == 1333129333 unix timestamp');
32029 assert.equal(moment(1333129333524000).unix(), 1333129333524, '1333129333524000 Date.valueOf == 1333129333524 unix timestamp');
32030 });
32031
32032 test('date', function (assert) {
32033 assert.ok(moment(new Date()).toDate() instanceof Date, 'new Date()');
32034 });
32035
32036 test('date mutation', function (assert) {
32037 var a = new Date();
32038 assert.ok(moment(a).toDate() !== a, 'the date moment uses should not be the date passed in');
32039 });
32040
32041 test('moment', function (assert) {
32042 assert.ok(moment(moment()).toDate() instanceof Date, 'moment(moment())');
32043 assert.ok(moment(moment(moment())).toDate() instanceof Date, 'moment(moment(moment()))');
32044 });
32045
32046 test('cloning moment should only copy own properties', function (assert) {
32047 assert.ok(!moment().clone().hasOwnProperty('month'), 'Should not clone prototype methods');
32048 });
32049
32050 test('cloning moment works with weird clones', function (assert) {
32051 var extend = function (a, b) {
32052 var i;
32053 for (i in b) {
32054 a[i] = b[i];
32055 }
32056 return a;
32057 },
32058 now = moment(),
32059 nowu = moment.utc();
32060
32061 assert.equal(+extend({}, now).clone(), +now, 'cloning extend-ed now is now');
32062 assert.equal(+extend({}, nowu).clone(), +nowu, 'cloning extend-ed utc now is utc now');
32063 });
32064
32065 test('cloning respects moment.momentProperties', function (assert) {
32066 var m = moment();
32067
32068 assert.equal(m.clone()._special, undefined, 'cloning ignores extra properties');
32069 m._special = 'bacon';
32070 moment.momentProperties.push('_special');
32071 assert.equal(m.clone()._special, 'bacon', 'cloning respects momentProperties');
32072 moment.momentProperties.pop();
32073 });
32074
32075 test('undefined', function (assert) {
32076 assert.ok(moment().toDate() instanceof Date, 'undefined');
32077 });
32078
32079 test('iso with bad input', function (assert) {
32080 assert.ok(!moment('a', moment.ISO_8601).isValid(), 'iso parsing with invalid string');
32081 assert.ok(!moment('a', moment.ISO_8601, true).isValid(), 'iso parsing with invalid string, strict');
32082 });
32083
32084 test('iso format 24hrs', function (assert) {
32085 assert.equal(moment('2014-01-01T24:00:00.000').format('YYYY-MM-DD[T]HH:mm:ss.SSS'),
32086 '2014-01-02T00:00:00.000', 'iso format with 24:00 localtime');
32087 assert.equal(moment.utc('2014-01-01T24:00:00.000').format('YYYY-MM-DD[T]HH:mm:ss.SSS'),
32088 '2014-01-02T00:00:00.000', 'iso format with 24:00 utc');
32089 });
32090
32091 test('string without format - json', function (assert) {
32092 assert.equal(moment('Date(1325132654000)').valueOf(), 1325132654000, 'Date(1325132654000)');
32093 assert.equal(moment('Date(-1325132654000)').valueOf(), -1325132654000, 'Date(-1325132654000)');
32094 assert.equal(moment('/Date(1325132654000)/').valueOf(), 1325132654000, '/Date(1325132654000)/');
32095 assert.equal(moment('/Date(1325132654000+0700)/').valueOf(), 1325132654000, '/Date(1325132654000+0700)/');
32096 assert.equal(moment('/Date(1325132654000-0700)/').valueOf(), 1325132654000, '/Date(1325132654000-0700)/');
32097 });
32098
32099 test('string with format dropped am/pm bug', function (assert) {
32100 moment.locale('en');
32101
32102 assert.equal(moment('05/1/2012 12:25:00', 'MM/DD/YYYY h:m:s a').format('MM/DD/YYYY'), '05/01/2012', 'should not break if am/pm is left off from the parsing tokens');
32103 assert.equal(moment('05/1/2012 12:25:00 am', 'MM/DD/YYYY h:m:s a').format('MM/DD/YYYY'), '05/01/2012', 'should not break if am/pm is left off from the parsing tokens');
32104 assert.equal(moment('05/1/2012 12:25:00 pm', 'MM/DD/YYYY h:m:s a').format('MM/DD/YYYY'), '05/01/2012', 'should not break if am/pm is left off from the parsing tokens');
32105
32106 assert.ok(moment('05/1/2012 12:25:00', 'MM/DD/YYYY h:m:s a').isValid());
32107 assert.ok(moment('05/1/2012 12:25:00 am', 'MM/DD/YYYY h:m:s a').isValid());
32108 assert.ok(moment('05/1/2012 12:25:00 pm', 'MM/DD/YYYY h:m:s a').isValid());
32109 });
32110
32111 test('empty string with formats', function (assert) {
32112 assert.equal(moment('', 'MM').format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
32113 assert.equal(moment(' ', 'MM').format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
32114 assert.equal(moment(' ', 'DD').format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
32115 assert.equal(moment(' ', ['MM', 'DD']).format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
32116
32117 assert.ok(!moment('', 'MM').isValid());
32118 assert.ok(!moment(' ', 'MM').isValid());
32119 assert.ok(!moment(' ', 'DD').isValid());
32120 assert.ok(!moment(' ', ['MM', 'DD']).isValid());
32121 });
32122
32123 test('defaulting to current date', function (assert) {
32124 var now = moment();
32125 assert.equal(moment('12:13:14', 'hh:mm:ss').format('YYYY-MM-DD hh:mm:ss'),
32126 now.clone().hour(12).minute(13).second(14).format('YYYY-MM-DD hh:mm:ss'),
32127 'given only time default to current date');
32128 assert.equal(moment('05', 'DD').format('YYYY-MM-DD'),
32129 now.clone().date(5).format('YYYY-MM-DD'),
32130 'given day of month default to current month, year');
32131 assert.equal(moment('05', 'MM').format('YYYY-MM-DD'),
32132 now.clone().month(4).date(1).format('YYYY-MM-DD'),
32133 'given month default to current year');
32134 assert.equal(moment('1996', 'YYYY').format('YYYY-MM-DD'),
32135 now.clone().year(1996).month(0).date(1).format('YYYY-MM-DD'),
32136 'given year do not default');
32137 });
32138
32139 test('matching am/pm', function (assert) {
32140 assert.equal(moment('2012-09-03T03:00PM', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for PM');
32141 assert.equal(moment('2012-09-03T03:00P.M.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for P.M.');
32142 assert.equal(moment('2012-09-03T03:00P', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for P');
32143 assert.equal(moment('2012-09-03T03:00pm', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for pm');
32144 assert.equal(moment('2012-09-03T03:00p.m.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for p.m.');
32145 assert.equal(moment('2012-09-03T03:00p', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for p');
32146
32147 assert.equal(moment('2012-09-03T03:00AM', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for AM');
32148 assert.equal(moment('2012-09-03T03:00A.M.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for A.M.');
32149 assert.equal(moment('2012-09-03T03:00A', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for A');
32150 assert.equal(moment('2012-09-03T03:00am', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for am');
32151 assert.equal(moment('2012-09-03T03:00a.m.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for a.m.');
32152 assert.equal(moment('2012-09-03T03:00a', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for a');
32153
32154 assert.equal(moment('5:00p.m.March 4 2012', 'h:mmAMMMM D YYYY').format('YYYY-MM-DDThh:mmA'), '2012-03-04T05:00PM', 'am/pm should parse correctly before month names');
32155 });
32156
32157 test('string with format', function (assert) {
32158 moment.locale('en');
32159 var a = [
32160 ['YYYY-Q', '2014-4'],
32161 ['MM-DD-YYYY', '12-02-1999'],
32162 ['DD-MM-YYYY', '12-02-1999'],
32163 ['DD/MM/YYYY', '12/02/1999'],
32164 ['DD_MM_YYYY', '12_02_1999'],
32165 ['DD:MM:YYYY', '12:02:1999'],
32166 ['D-M-YY', '2-2-99'],
32167 ['YY', '99'],
32168 ['DDD-YYYY', '300-1999'],
32169 ['DD-MM-YYYY h:m:s', '12-02-1999 2:45:10'],
32170 ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 am'],
32171 ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 pm'],
32172 ['h:mm a', '12:00 pm'],
32173 ['h:mm a', '12:30 pm'],
32174 ['h:mm a', '12:00 am'],
32175 ['h:mm a', '12:30 am'],
32176 ['HH:mm', '12:00'],
32177 ['YYYY-MM-DDTHH:mm:ss', '2011-11-11T11:11:11'],
32178 ['MM-DD-YYYY [M]', '12-02-1999 M'],
32179 ['ddd MMM DD HH:mm:ss YYYY', 'Tue Apr 07 22:52:51 2009'],
32180 ['HH:mm:ss', '12:00:00'],
32181 ['HH:mm:ss', '12:30:00'],
32182 ['HH:mm:ss', '00:00:00'],
32183 ['HH:mm:ss S', '00:30:00 1'],
32184 ['HH:mm:ss SS', '00:30:00 12'],
32185 ['HH:mm:ss SSS', '00:30:00 123'],
32186 ['HH:mm:ss S', '00:30:00 7'],
32187 ['HH:mm:ss SS', '00:30:00 78'],
32188 ['HH:mm:ss SSS', '00:30:00 789'],
32189 ['X', '1234567890'],
32190 ['x', '1234567890123'],
32191 ['LT', '12:30 AM'],
32192 ['LTS', '12:30:29 AM'],
32193 ['L', '09/02/1999'],
32194 ['l', '9/2/1999'],
32195 ['LL', 'September 2, 1999'],
32196 ['ll', 'Sep 2, 1999'],
32197 ['LLL', 'September 2, 1999 12:30 AM'],
32198 ['lll', 'Sep 2, 1999 12:30 AM'],
32199 ['LLLL', 'Thursday, September 2, 1999 12:30 AM'],
32200 ['llll', 'Thu, Sep 2, 1999 12:30 AM']
32201 ],
32202 m,
32203 i;
32204
32205 for (i = 0; i < a.length; i++) {
32206 m = moment(a[i][1], a[i][0]);
32207 assert.ok(m.isValid());
32208 assert.equal(m.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
32209 }
32210 });
32211
32212 test('2 digit year with YYYY format', function (assert) {
32213 assert.equal(moment('9/2/99', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/1999', 'D/M/YYYY ---> 9/2/99');
32214 assert.equal(moment('9/2/1999', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/1999', 'D/M/YYYY ---> 9/2/1999');
32215 assert.equal(moment('9/2/68', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/2068', 'D/M/YYYY ---> 9/2/68');
32216 assert.equal(moment('9/2/69', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/1969', 'D/M/YYYY ---> 9/2/69');
32217 });
32218
32219 test('unix timestamp format', function (assert) {
32220 var formats = ['X', 'X.S', 'X.SS', 'X.SSS'], i, format;
32221
32222 for (i = 0; i < formats.length; i++) {
32223 format = formats[i];
32224 assert.equal(moment('1234567890', format).valueOf(), 1234567890 * 1000, format + ' matches timestamp without milliseconds');
32225 assert.equal(moment('1234567890.1', format).valueOf(), 1234567890 * 1000 + 100, format + ' matches timestamp with deciseconds');
32226 assert.equal(moment('1234567890.12', format).valueOf(), 1234567890 * 1000 + 120, format + ' matches timestamp with centiseconds');
32227 assert.equal(moment('1234567890.123', format).valueOf(), 1234567890 * 1000 + 123, format + ' matches timestamp with milliseconds');
32228 }
32229 });
32230
32231 test('unix offset milliseconds', function (assert) {
32232 assert.equal(moment('1234567890123', 'x').valueOf(), 1234567890123, 'x matches unix offset in milliseconds');
32233 });
32234
32235 test('milliseconds format', function (assert) {
32236 assert.equal(moment('1', 'S').get('ms'), 100, 'deciseconds');
32237 // assert.equal(moment('10', 'S', true).isValid(), false, 'deciseconds with two digits');
32238 // assert.equal(moment('1', 'SS', true).isValid(), false, 'centiseconds with one digits');
32239 assert.equal(moment('12', 'SS').get('ms'), 120, 'centiseconds');
32240 // assert.equal(moment('123', 'SS', true).isValid(), false, 'centiseconds with three digits');
32241 assert.equal(moment('123', 'SSS').get('ms'), 123, 'milliseconds');
32242 assert.equal(moment('1234', 'SSSS').get('ms'), 123, 'milliseconds with SSSS');
32243 assert.equal(moment('123456789101112', 'SSSS').get('ms'), 123, 'milliseconds with SSSS');
32244 });
32245
32246 test('string with format no separators', function (assert) {
32247 moment.locale('en');
32248 var a = [
32249 ['MMDDYYYY', '12021999'],
32250 ['DDMMYYYY', '12021999'],
32251 ['YYYYMMDD', '19991202'],
32252 ['DDMMMYYYY', '10Sep2001']
32253 ], i;
32254
32255 for (i = 0; i < a.length; i++) {
32256 assert.equal(moment(a[i][1], a[i][0]).format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
32257 }
32258 });
32259
32260 test('string with format (timezone)', function (assert) {
32261 assert.equal(moment('5 -0700', 'H ZZ').toDate().getUTCHours(), 12, 'parse hours \'5 -0700\' ---> \'H ZZ\'');
32262 assert.equal(moment('5 -07:00', 'H Z').toDate().getUTCHours(), 12, 'parse hours \'5 -07:00\' ---> \'H Z\'');
32263 assert.equal(moment('5 -0730', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours \'5 -0730\' ---> \'H ZZ\'');
32264 assert.equal(moment('5 -07:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours \'5 -07:0\' ---> \'H Z\'');
32265 assert.equal(moment('5 +0100', 'H ZZ').toDate().getUTCHours(), 4, 'parse hours \'5 +0100\' ---> \'H ZZ\'');
32266 assert.equal(moment('5 +01:00', 'H Z').toDate().getUTCHours(), 4, 'parse hours \'5 +01:00\' ---> \'H Z\'');
32267 assert.equal(moment('5 +0130', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours \'5 +0130\' ---> \'H ZZ\'');
32268 assert.equal(moment('5 +01:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours \'5 +01:30\' ---> \'H Z\'');
32269 });
32270
32271 test('string with format (timezone offset)', function (assert) {
32272 var a, b, c, d, e, f;
32273 a = new Date(Date.UTC(2011, 0, 1, 1));
32274 b = moment('2011 1 1 0 -01:00', 'YYYY MM DD HH Z');
32275 assert.equal(a.getHours(), b.hours(), 'date created with utc == parsed string with timezone offset');
32276 assert.equal(+a, +b, 'date created with utc == parsed string with timezone offset');
32277 c = moment('2011 2 1 10 -05:00', 'YYYY MM DD HH Z');
32278 d = moment('2011 2 1 8 -07:00', 'YYYY MM DD HH Z');
32279 assert.equal(c.hours(), d.hours(), '10 am central time == 8 am pacific time');
32280 e = moment.utc('Fri, 20 Jul 2012 17:15:00', 'ddd, DD MMM YYYY HH:mm:ss');
32281 f = moment.utc('Fri, 20 Jul 2012 10:15:00 -0700', 'ddd, DD MMM YYYY HH:mm:ss ZZ');
32282 assert.equal(e.hours(), f.hours(), 'parse timezone offset in utc');
32283 });
32284
32285 test('string with timezone around start of year', function (assert) {
32286 assert.equal(moment('2000-01-01T00:00:00.000+01:00').toISOString(), '1999-12-31T23:00:00.000Z', '+1:00 around 2000');
32287 assert.equal(moment('2000-01-01T00:00:00.000-01:00').toISOString(), '2000-01-01T01:00:00.000Z', '-1:00 around 2000');
32288 assert.equal(moment('1970-01-01T00:00:00.000+01:00').toISOString(), '1969-12-31T23:00:00.000Z', '+1:00 around 1970');
32289 assert.equal(moment('1970-01-01T00:00:00.000-01:00').toISOString(), '1970-01-01T01:00:00.000Z', '-1:00 around 1970');
32290 assert.equal(moment('1200-01-01T00:00:00.000+01:00').toISOString(), '1199-12-31T23:00:00.000Z', '+1:00 around 1200');
32291 assert.equal(moment('1200-01-01T00:00:00.000-01:00').toISOString(), '1200-01-01T01:00:00.000Z', '-1:00 around 1200');
32292 });
32293
32294 test('string with array of formats', function (assert) {
32295 assert.equal(moment('11-02-1999', ['MM-DD-YYYY', 'DD-MM-YYYY']).format('MM DD YYYY'), '11 02 1999', 'switching month and day');
32296 assert.equal(moment('02-11-1999', ['MM/DD/YYYY', 'YYYY MM DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 11 1999', 'year last');
32297 assert.equal(moment('1999-02-11', ['MM/DD/YYYY', 'YYYY MM DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 11 1999', 'year first');
32298
32299 assert.equal(moment('02-11-1999', ['MM/DD/YYYY', 'YYYY MM DD']).format('MM DD YYYY'), '02 11 1999', 'year last');
32300 assert.equal(moment('1999-02-11', ['MM/DD/YYYY', 'YYYY MM DD']).format('MM DD YYYY'), '02 11 1999', 'year first');
32301 assert.equal(moment('02-11-1999', ['YYYY MM DD', 'MM/DD/YYYY']).format('MM DD YYYY'), '02 11 1999', 'year last');
32302 assert.equal(moment('1999-02-11', ['YYYY MM DD', 'MM/DD/YYYY']).format('MM DD YYYY'), '02 11 1999', 'year first');
32303
32304 assert.equal(moment('13-11-1999', ['MM/DD/YYYY', 'DD/MM/YYYY']).format('MM DD YYYY'), '11 13 1999', 'second must be month');
32305 assert.equal(moment('11-13-1999', ['MM/DD/YYYY', 'DD/MM/YYYY']).format('MM DD YYYY'), '11 13 1999', 'first must be month');
32306 assert.equal(moment('01-02-2000', ['MM/DD/YYYY', 'DD/MM/YYYY']).format('MM DD YYYY'), '01 02 2000', 'either can be a month, month first format');
32307 assert.equal(moment('02-01-2000', ['DD/MM/YYYY', 'MM/DD/YYYY']).format('MM DD YYYY'), '01 02 2000', 'either can be a month, day first format');
32308
32309 assert.equal(moment('11-02-10', ['MM/DD/YY', 'YY MM DD', 'DD-MM-YY']).format('MM DD YYYY'), '02 11 2010', 'all unparsed substrings have influence on format penalty');
32310 assert.equal(moment('11-02-10', ['MM-DD-YY HH:mm', 'YY MM DD']).format('MM DD YYYY'), '02 10 2011', 'prefer formats without extra tokens');
32311 assert.equal(moment('11-02-10 junk', ['MM-DD-YY', 'YY.MM.DD junk']).format('MM DD YYYY'), '02 10 2011', 'prefer formats that dont result in extra characters');
32312 assert.equal(moment('11-22-10', ['YY-MM-DD', 'YY-DD-MM']).format('MM DD YYYY'), '10 22 2011', 'prefer valid results');
32313
32314 assert.equal(moment('gibberish', ['YY-MM-DD', 'YY-DD-MM']).format('MM DD YYYY'), 'Invalid date', 'doest throw for invalid strings');
32315 assert.equal(moment('gibberish', []).format('MM DD YYYY'), 'Invalid date', 'doest throw for an empty array');
32316
32317 //https://github.com/moment/moment/issues/1143
32318 assert.equal(moment(
32319 'System Administrator and Database Assistant (7/1/2011), System Administrator and Database Assistant (7/1/2011), Database Coordinator (7/1/2011), Vice President (7/1/2011), System Administrator and Database Assistant (5/31/2012), Database Coordinator (7/1/2012), System Administrator and Database Assistant (7/1/2013)',
32320 ['MM/DD/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD', 'YYYY-MM-DDTHH:mm:ssZ'])
32321 .format('YYYY-MM-DD'), '2011-07-01', 'Works for long strings');
32322
32323 assert.equal(moment('11-02-10', ['MM.DD.YY', 'DD-MM-YY']).format('MM DD YYYY'), '02 11 2010', 'escape RegExp special characters on comparing');
32324
32325 assert.equal(moment('13-10-98', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YY', 'use two digit year');
32326 assert.equal(moment('13-10-1998', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YYYY', 'use four digit year');
32327
32328 assert.equal(moment('01', ['MM', 'DD'])._f, 'MM', 'Should use first valid format');
32329 });
32330
32331 test('string with array of formats + ISO', function (assert) {
32332 assert.equal(moment('1994', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).year(), 1994, 'iso: assert parse YYYY');
32333 assert.equal(moment('17:15', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).hour(), 17, 'iso: assert parse HH:mm (1)');
32334 assert.equal(moment('17:15', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).minutes(), 15, 'iso: assert parse HH:mm (2)');
32335 assert.equal(moment('06', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).month(), 6 - 1, 'iso: assert parse MM');
32336 assert.equal(moment('2012-06-01', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).parsingFlags().iso, true, 'iso: assert parse iso');
32337 assert.equal(moment('2014-05-05', [moment.ISO_8601, 'YYYY-MM-DD']).parsingFlags().iso, true, 'iso: edge case array precedence iso');
32338 assert.equal(moment('2014-05-05', ['YYYY-MM-DD', moment.ISO_8601]).parsingFlags().iso, false, 'iso: edge case array precedence not iso');
32339 });
32340
32341 test('string with format - years', function (assert) {
32342 assert.equal(moment('67', 'YY').format('YYYY'), '2067', '67 > 2067');
32343 assert.equal(moment('68', 'YY').format('YYYY'), '2068', '68 > 2068');
32344 assert.equal(moment('69', 'YY').format('YYYY'), '1969', '69 > 1969');
32345 assert.equal(moment('70', 'YY').format('YYYY'), '1970', '70 > 1970');
32346 });
32347
32348 test('implicit cloning', function (assert) {
32349 var momentA = moment([2011, 10, 10]),
32350 momentB = moment(momentA);
32351 momentA.month(5);
32352 assert.equal(momentB.month(), 10, 'Calling moment() on a moment will create a clone');
32353 assert.equal(momentA.month(), 5, 'Calling moment() on a moment will create a clone');
32354 });
32355
32356 test('explicit cloning', function (assert) {
32357 var momentA = moment([2011, 10, 10]),
32358 momentB = momentA.clone();
32359 momentA.month(5);
32360 assert.equal(momentB.month(), 10, 'Calling moment() on a moment will create a clone');
32361 assert.equal(momentA.month(), 5, 'Calling moment() on a moment will create a clone');
32362 });
32363
32364 test('cloning carrying over utc mode', function (assert) {
32365 assert.equal(moment().local().clone()._isUTC, false, 'An explicit cloned local moment should have _isUTC == false');
32366 assert.equal(moment().utc().clone()._isUTC, true, 'An cloned utc moment should have _isUTC == true');
32367 assert.equal(moment().clone()._isUTC, false, 'An explicit cloned local moment should have _isUTC == false');
32368 assert.equal(moment.utc().clone()._isUTC, true, 'An explicit cloned utc moment should have _isUTC == true');
32369 assert.equal(moment(moment().local())._isUTC, false, 'An implicit cloned local moment should have _isUTC == false');
32370 assert.equal(moment(moment().utc())._isUTC, true, 'An implicit cloned utc moment should have _isUTC == true');
32371 assert.equal(moment(moment())._isUTC, false, 'An implicit cloned local moment should have _isUTC == false');
32372 assert.equal(moment(moment.utc())._isUTC, true, 'An implicit cloned utc moment should have _isUTC == true');
32373 });
32374
32375 test('parsing iso', function (assert) {
32376 var offset = moment([2011, 9, 8]).utcOffset(),
32377 pad = function (input) {
32378 if (input < 10) {
32379 return '0' + input;
32380 }
32381 return '' + input;
32382 },
32383 hourOffset = (offset > 0 ? Math.floor(offset / 60) : Math.ceil(offset / 60)),
32384 minOffset = offset - (hourOffset * 60),
32385 tz = (offset >= 0) ?
32386 '+' + pad(hourOffset) + ':' + pad(minOffset) :
32387 '-' + pad(-hourOffset) + ':' + pad(-minOffset),
32388 tz2 = tz.replace(':', ''),
32389 tz3 = tz2.slice(0, 3),
32390 formats = [
32391 ['2011-10-08', '2011-10-08T00:00:00.000' + tz],
32392 ['2011-10-08T18', '2011-10-08T18:00:00.000' + tz],
32393 ['2011-10-08T18:04', '2011-10-08T18:04:00.000' + tz],
32394 ['2011-10-08T18:04:20', '2011-10-08T18:04:20.000' + tz],
32395 ['2011-10-08T18:04' + tz, '2011-10-08T18:04:00.000' + tz],
32396 ['2011-10-08T18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
32397 ['2011-10-08T18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
32398 ['2011-10-08T18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
32399 ['2011-10-08T18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
32400 ['2011-10-08T18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
32401 ['2011-10-08T18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
32402 ['2011-10-08T18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
32403 ['2011-10-08T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
32404 ['2011-10-08 18', '2011-10-08T18:00:00.000' + tz],
32405 ['2011-10-08 18:04', '2011-10-08T18:04:00.000' + tz],
32406 ['2011-10-08 18:04:20', '2011-10-08T18:04:20.000' + tz],
32407 ['2011-10-08 18:04' + tz, '2011-10-08T18:04:00.000' + tz],
32408 ['2011-10-08 18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
32409 ['2011-10-08 18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
32410 ['2011-10-08 18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
32411 ['2011-10-08 18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
32412 ['2011-10-08 18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
32413 ['2011-10-08 18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
32414 ['2011-10-08 18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
32415 ['2011-10-08 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
32416 ['2011-W40', '2011-10-03T00:00:00.000' + tz],
32417 ['2011-W40-6', '2011-10-08T00:00:00.000' + tz],
32418 ['2011-W40-6T18', '2011-10-08T18:00:00.000' + tz],
32419 ['2011-W40-6T18:04', '2011-10-08T18:04:00.000' + tz],
32420 ['2011-W40-6T18:04:20', '2011-10-08T18:04:20.000' + tz],
32421 ['2011-W40-6T18:04' + tz, '2011-10-08T18:04:00.000' + tz],
32422 ['2011-W40-6T18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
32423 ['2011-W40-6T18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
32424 ['2011-W40-6T18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
32425 ['2011-W40-6T18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
32426 ['2011-W40-6T18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
32427 ['2011-W40-6T18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
32428 ['2011-W40-6T18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
32429 ['2011-W40-6T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
32430 ['2011-W40-6 18', '2011-10-08T18:00:00.000' + tz],
32431 ['2011-W40-6 18:04', '2011-10-08T18:04:00.000' + tz],
32432 ['2011-W40-6 18:04:20', '2011-10-08T18:04:20.000' + tz],
32433 ['2011-W40-6 18:04' + tz, '2011-10-08T18:04:00.000' + tz],
32434 ['2011-W40-6 18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
32435 ['2011-W40-6 18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
32436 ['2011-W40-6 18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
32437 ['2011-W40-6 18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
32438 ['2011-W40-6 18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
32439 ['2011-W40-6 18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
32440 ['2011-W40-6 18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
32441 ['2011-W40-6 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
32442 ['2011-281', '2011-10-08T00:00:00.000' + tz],
32443 ['2011-281T18', '2011-10-08T18:00:00.000' + tz],
32444 ['2011-281T18:04', '2011-10-08T18:04:00.000' + tz],
32445 ['2011-281T18:04:20', '2011-10-08T18:04:20.000' + tz],
32446 ['2011-281T18:04' + tz, '2011-10-08T18:04:00.000' + tz],
32447 ['2011-281T18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
32448 ['2011-281T18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
32449 ['2011-281T18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
32450 ['2011-281T18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
32451 ['2011-281T18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
32452 ['2011-281T18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
32453 ['2011-281T18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
32454 ['2011-281T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
32455 ['2011-281 18', '2011-10-08T18:00:00.000' + tz],
32456 ['2011-281 18:04', '2011-10-08T18:04:00.000' + tz],
32457 ['2011-281 18:04:20', '2011-10-08T18:04:20.000' + tz],
32458 ['2011-281 18:04' + tz, '2011-10-08T18:04:00.000' + tz],
32459 ['2011-281 18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
32460 ['2011-281 18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
32461 ['2011-281 18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
32462 ['2011-281 18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
32463 ['2011-281 18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
32464 ['2011-281 18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
32465 ['2011-281 18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
32466 ['2011-281 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz]
32467 ], i;
32468 for (i = 0; i < formats.length; i++) {
32469 assert.equal(moment(formats[i][0]).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), formats[i][1], 'moment should be able to parse ISO ' + formats[i][0]);
32470 }
32471 });
32472
32473 test('parsing iso week year/week/weekday', function (assert) {
32474 assert.equal(moment.utc('2007-W01').format(), '2007-01-01T00:00:00+00:00', '2008 week 1 (1st Jan Mon)');
32475 assert.equal(moment.utc('2008-W01').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
32476 assert.equal(moment.utc('2003-W01').format(), '2002-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Wed)');
32477 assert.equal(moment.utc('2009-W01').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
32478 assert.equal(moment.utc('2010-W01').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
32479 assert.equal(moment.utc('2011-W01').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
32480 assert.equal(moment.utc('2012-W01').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
32481 });
32482
32483 test('parsing week year/week/weekday (dow 1, doy 4)', function (assert) {
32484 moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
32485
32486 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
32487 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
32488 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
32489 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
32490 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
32491 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
32492 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
32493
32494 moment.defineLocale('dow:1,doy:4', null);
32495 });
32496
32497 test('parsing week year/week/weekday (dow 1, doy 7)', function (assert) {
32498 moment.locale('dow:1,doy:7', {week: {dow: 1, doy: 7}});
32499
32500 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
32501 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
32502 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
32503 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
32504 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-28T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
32505 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-27T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
32506 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-26T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
32507 moment.defineLocale('dow:1,doy:7', null);
32508 });
32509
32510 test('parsing week year/week/weekday (dow 0, doy 6)', function (assert) {
32511 moment.locale('dow:0,doy:6', {week: {dow: 0, doy: 6}});
32512
32513 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-31T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
32514 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
32515 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-29T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
32516 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-28T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
32517 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-27T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
32518 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-26T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
32519 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-01T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
32520 moment.defineLocale('dow:0,doy:6', null);
32521 });
32522
32523 test('parsing week year/week/weekday (dow 6, doy 12)', function (assert) {
32524 moment.locale('dow:6,doy:12', {week: {dow: 6, doy: 12}});
32525
32526 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-30T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
32527 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-29T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
32528 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-28T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
32529 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-27T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
32530 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-26T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
32531 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-01T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
32532 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-31T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
32533 });
32534
32535 test('parsing ISO with Z', function (assert) {
32536 var i, mom, formats = [
32537 ['2011-10-08T18:04', '2011-10-08T18:04:00.000'],
32538 ['2011-10-08T18:04:20', '2011-10-08T18:04:20.000'],
32539 ['2011-10-08T18:04:20.1', '2011-10-08T18:04:20.100'],
32540 ['2011-10-08T18:04:20.11', '2011-10-08T18:04:20.110'],
32541 ['2011-10-08T18:04:20.111', '2011-10-08T18:04:20.111'],
32542 ['2011-W40-6T18', '2011-10-08T18:00:00.000'],
32543 ['2011-W40-6T18:04', '2011-10-08T18:04:00.000'],
32544 ['2011-W40-6T18:04:20', '2011-10-08T18:04:20.000'],
32545 ['2011-W40-6T18:04:20.1', '2011-10-08T18:04:20.100'],
32546 ['2011-W40-6T18:04:20.11', '2011-10-08T18:04:20.110'],
32547 ['2011-W40-6T18:04:20.111', '2011-10-08T18:04:20.111'],
32548 ['2011-281T18', '2011-10-08T18:00:00.000'],
32549 ['2011-281T18:04', '2011-10-08T18:04:00.000'],
32550 ['2011-281T18:04:20', '2011-10-08T18:04:20.000'],
32551 ['2011-281T18:04:20', '2011-10-08T18:04:20.000'],
32552 ['2011-281T18:04:20.1', '2011-10-08T18:04:20.100'],
32553 ['2011-281T18:04:20.11', '2011-10-08T18:04:20.110'],
32554 ['2011-281T18:04:20.111', '2011-10-08T18:04:20.111']
32555 ];
32556
32557 for (i = 0; i < formats.length; i++) {
32558 mom = moment(formats[i][0] + 'Z').utc();
32559 assert.equal(mom.format('YYYY-MM-DDTHH:mm:ss.SSS'), formats[i][1], 'moment should be able to parse ISO in UTC ' + formats[i][0] + 'Z');
32560
32561 mom = moment(formats[i][0] + ' Z').utc();
32562 assert.equal(mom.format('YYYY-MM-DDTHH:mm:ss.SSS'), formats[i][1], 'moment should be able to parse ISO in UTC ' + formats[i][0] + ' Z');
32563 }
32564 });
32565
32566 test('parsing iso with T', function (assert) {
32567 assert.equal(moment('2011-10-08T18')._f, 'YYYY-MM-DDTHH', 'should include \'T\' in the format');
32568 assert.equal(moment('2011-10-08T18:20')._f, 'YYYY-MM-DDTHH:mm', 'should include \'T\' in the format');
32569 assert.equal(moment('2011-10-08T18:20:13')._f, 'YYYY-MM-DDTHH:mm:ss', 'should include \'T\' in the format');
32570 assert.equal(moment('2011-10-08T18:20:13.321')._f, 'YYYY-MM-DDTHH:mm:ss.SSSS', 'should include \'T\' in the format');
32571
32572 assert.equal(moment('2011-10-08 18')._f, 'YYYY-MM-DD HH', 'should not include \'T\' in the format');
32573 assert.equal(moment('2011-10-08 18:20')._f, 'YYYY-MM-DD HH:mm', 'should not include \'T\' in the format');
32574 assert.equal(moment('2011-10-08 18:20:13')._f, 'YYYY-MM-DD HH:mm:ss', 'should not include \'T\' in the format');
32575 assert.equal(moment('2011-10-08 18:20:13.321')._f, 'YYYY-MM-DD HH:mm:ss.SSSS', 'should not include \'T\' in the format');
32576 });
32577
32578 test('parsing iso Z timezone', function (assert) {
32579 var i,
32580 formats = [
32581 ['2011-10-08T18:04Z', '2011-10-08T18:04:00.000+00:00'],
32582 ['2011-10-08T18:04:20Z', '2011-10-08T18:04:20.000+00:00'],
32583 ['2011-10-08T18:04:20.111Z', '2011-10-08T18:04:20.111+00:00']
32584 ];
32585 for (i = 0; i < formats.length; i++) {
32586 assert.equal(moment.utc(formats[i][0]).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), formats[i][1], 'moment should be able to parse ISO ' + formats[i][0]);
32587 }
32588 });
32589
32590 test('parsing iso Z timezone into local', function (assert) {
32591 var m = moment('2011-10-08T18:04:20.111Z');
32592
32593 assert.equal(m.utc().format('YYYY-MM-DDTHH:mm:ss.SSS'), '2011-10-08T18:04:20.111', 'moment should be able to parse ISO 2011-10-08T18:04:20.111Z');
32594 });
32595
32596 test('parsing iso with more subsecond precision digits', function (assert) {
32597 assert.equal(moment.utc('2013-07-31T22:00:00.0000000Z').format(), '2013-07-31T22:00:00+00:00', 'more than 3 subsecond digits');
32598 });
32599
32600 test('null or empty', function (assert) {
32601 assert.equal(moment('').isValid(), false, 'moment(\'\') is not valid');
32602 assert.equal(moment(null).isValid(), false, 'moment(null) is not valid');
32603 assert.equal(moment(null, 'YYYY-MM-DD').isValid(), false, 'moment(\'\', \'format\') is not valid');
32604 assert.equal(moment('', 'YYYY-MM-DD').isValid(), false, 'moment(\'\', \'format\') is not valid');
32605 assert.equal(moment.utc('').isValid(), false, 'moment.utc(\'\') is not valid');
32606 assert.equal(moment.utc(null).isValid(), false, 'moment.utc(null) is not valid');
32607 assert.equal(moment.utc(null, 'YYYY-MM-DD').isValid(), false, 'moment.utc(null) is not valid');
32608 assert.equal(moment.utc('', 'YYYY-MM-DD').isValid(), false, 'moment.utc(\'\', \'YYYY-MM-DD\') is not valid');
32609 });
32610
32611 test('first century', function (assert) {
32612 assert.equal(moment([0, 0, 1]).format('YYYY-MM-DD'), '0000-01-01', 'Year AD 0');
32613 assert.equal(moment([99, 0, 1]).format('YYYY-MM-DD'), '0099-01-01', 'Year AD 99');
32614 assert.equal(moment([999, 0, 1]).format('YYYY-MM-DD'), '0999-01-01', 'Year AD 999');
32615 assert.equal(moment('0 1 1', 'YYYY MM DD').format('YYYY-MM-DD'), '0000-01-01', 'Year AD 0');
32616 assert.equal(moment('999 1 1', 'YYYY MM DD').format('YYYY-MM-DD'), '0999-01-01', 'Year AD 999');
32617 assert.equal(moment('0 1 1', 'YYYYY MM DD').format('YYYYY-MM-DD'), '00000-01-01', 'Year AD 0');
32618 assert.equal(moment('99 1 1', 'YYYYY MM DD').format('YYYYY-MM-DD'), '00099-01-01', 'Year AD 99');
32619 assert.equal(moment('999 1 1', 'YYYYY MM DD').format('YYYYY-MM-DD'), '00999-01-01', 'Year AD 999');
32620 });
32621
32622 test('six digit years', function (assert) {
32623 assert.equal(moment([-270000, 0, 1]).format('YYYYY-MM-DD'), '-270000-01-01', 'format BC 270,001');
32624 assert.equal(moment([270000, 0, 1]).format('YYYYY-MM-DD'), '270000-01-01', 'format AD 270,000');
32625 assert.equal(moment('-270000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), -270000, 'parse BC 270,001');
32626 assert.equal(moment('270000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), 270000, 'parse AD 270,000');
32627 assert.equal(moment('+270000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), 270000, 'parse AD +270,000');
32628 assert.equal(moment.utc('-270000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), -270000, 'parse utc BC 270,001');
32629 assert.equal(moment.utc('270000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), 270000, 'parse utc AD 270,000');
32630 assert.equal(moment.utc('+270000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), 270000, 'parse utc AD +270,000');
32631 });
32632
32633 test('negative four digit years', function (assert) {
32634 assert.equal(moment('-1000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), -1000, 'parse BC 1,001');
32635 assert.equal(moment.utc('-1000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), -1000, 'parse utc BC 1,001');
32636 });
32637
32638 test('strict parsing', function (assert) {
32639 assert.equal(moment('2014-', 'YYYY-Q', true).isValid(), false, 'fail missing quarter');
32640
32641 assert.equal(moment('2012-05', 'YYYY-MM', true).format('YYYY-MM'), '2012-05', 'parse correct string');
32642 assert.equal(moment(' 2012-05', 'YYYY-MM', true).isValid(), false, 'fail on extra whitespace');
32643 assert.equal(moment('foo 2012-05', '[foo] YYYY-MM', true).format('YYYY-MM'), '2012-05', 'handle fixed text');
32644 assert.equal(moment('2012 05', 'YYYY-MM', true).isValid(), false, 'fail on different separator');
32645 assert.equal(moment('2012 05', 'YYYY MM DD', true).isValid(), false, 'fail on too many tokens');
32646
32647 assert.equal(moment('05 30 2010', ['DD MM YYYY', 'MM DD YYYY'], true).format('MM DD YYYY'), '05 30 2010', 'array with bad date');
32648 assert.equal(moment('05 30 2010', ['', 'MM DD YYYY'], true).format('MM DD YYYY'), '05 30 2010', 'array with invalid format');
32649 assert.equal(moment('05 30 2010', [' DD MM YYYY', 'MM DD YYYY'], true).format('MM DD YYYY'), '05 30 2010', 'array with non-matching format');
32650
32651 assert.equal(moment('2010.*...', 'YYYY.*', true).isValid(), false, 'invalid format with regex chars');
32652 assert.equal(moment('2010.*', 'YYYY.*', true).year(), 2010, 'valid format with regex chars');
32653 assert.equal(moment('.*2010.*', '.*YYYY.*', true).year(), 2010, 'valid format with regex chars on both sides');
32654
32655 //strict tokens
32656 assert.equal(moment('-5-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid negative year');
32657 assert.equal(moment('2-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid one-digit year');
32658 assert.equal(moment('20-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid two-digit year');
32659 assert.equal(moment('201-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid three-digit year');
32660 assert.equal(moment('2010-05-25', 'YYYY-MM-DD', true).isValid(), true, 'valid four-digit year');
32661 assert.equal(moment('22010-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid five-digit year');
32662
32663 assert.equal(moment('12-05-25', 'YY-MM-DD', true).isValid(), true, 'valid two-digit year');
32664 assert.equal(moment('2012-05-25', 'YY-MM-DD', true).isValid(), false, 'invalid four-digit year');
32665
32666 assert.equal(moment('-5-05-25', 'Y-MM-DD', true).isValid(), true, 'valid negative year');
32667 assert.equal(moment('2-05-25', 'Y-MM-DD', true).isValid(), true, 'valid one-digit year');
32668 assert.equal(moment('20-05-25', 'Y-MM-DD', true).isValid(), true, 'valid two-digit year');
32669 assert.equal(moment('201-05-25', 'Y-MM-DD', true).isValid(), true, 'valid three-digit year');
32670
32671 assert.equal(moment('2012-5-25', 'YYYY-M-DD', true).isValid(), true, 'valid one-digit month');
32672 assert.equal(moment('2012-5-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid one-digit month');
32673 assert.equal(moment('2012-05-25', 'YYYY-M-DD', true).isValid(), true, 'valid one-digit month');
32674 assert.equal(moment('2012-05-25', 'YYYY-MM-DD', true).isValid(), true, 'valid one-digit month');
32675
32676 assert.equal(moment('2012-05-2', 'YYYY-MM-D', true).isValid(), true, 'valid one-digit day');
32677 assert.equal(moment('2012-05-2', 'YYYY-MM-DD', true).isValid(), false, 'invalid one-digit day');
32678 assert.equal(moment('2012-05-02', 'YYYY-MM-D', true).isValid(), true, 'valid two-digit day');
32679 assert.equal(moment('2012-05-02', 'YYYY-MM-DD', true).isValid(), true, 'valid two-digit day');
32680
32681 assert.equal(moment('+002012-05-25', 'YYYYY-MM-DD', true).isValid(), true, 'valid six-digit year');
32682 assert.equal(moment('+2012-05-25', 'YYYYY-MM-DD', true).isValid(), false, 'invalid four-digit year');
32683
32684 //thse are kinda pointless, but they should work as expected
32685 assert.equal(moment('1', 'S', true).isValid(), true, 'valid one-digit milisecond');
32686 assert.equal(moment('12', 'S', true).isValid(), false, 'invalid two-digit milisecond');
32687 assert.equal(moment('123', 'S', true).isValid(), false, 'invalid three-digit milisecond');
32688
32689 assert.equal(moment('1', 'SS', true).isValid(), false, 'invalid one-digit milisecond');
32690 assert.equal(moment('12', 'SS', true).isValid(), true, 'valid two-digit milisecond');
32691 assert.equal(moment('123', 'SS', true).isValid(), false, 'invalid three-digit milisecond');
32692
32693 assert.equal(moment('1', 'SSS', true).isValid(), false, 'invalid one-digit milisecond');
32694 assert.equal(moment('12', 'SSS', true).isValid(), false, 'invalid two-digit milisecond');
32695 assert.equal(moment('123', 'SSS', true).isValid(), true, 'valid three-digit milisecond');
32696
32697 // strict parsing respects month length
32698 assert.ok(moment('1 January 2000', 'D MMMM YYYY', true).isValid(), 'capital long-month + MMMM');
32699 assert.ok(!moment('1 January 2000', 'D MMM YYYY', true).isValid(), 'capital long-month + MMM');
32700 assert.ok(!moment('1 Jan 2000', 'D MMMM YYYY', true).isValid(), 'capital short-month + MMMM');
32701 assert.ok(moment('1 Jan 2000', 'D MMM YYYY', true).isValid(), 'capital short-month + MMM');
32702 assert.ok(moment('1 january 2000', 'D MMMM YYYY', true).isValid(), 'lower long-month + MMMM');
32703 assert.ok(!moment('1 january 2000', 'D MMM YYYY', true).isValid(), 'lower long-month + MMM');
32704 assert.ok(!moment('1 jan 2000', 'D MMMM YYYY', true).isValid(), 'lower short-month + MMMM');
32705 assert.ok(moment('1 jan 2000', 'D MMM YYYY', true).isValid(), 'lower short-month + MMM');
32706 });
32707
32708 test('parsing into a locale', function (assert) {
32709 moment.defineLocale('parselocale', {
32710 months : 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_'),
32711 monthsShort : 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_')
32712 });
32713
32714 moment.locale('en');
32715
32716 assert.equal(moment('2012 seven', 'YYYY MMM', 'parselocale').month(), 6, 'should be able to parse in a specific locale');
32717
32718 moment.locale('parselocale');
32719
32720 assert.equal(moment('2012 july', 'YYYY MMM', 'en').month(), 6, 'should be able to parse in a specific locale');
32721
32722 moment.defineLocale('parselocale', null);
32723 });
32724
32725 function getVerifier(test) {
32726 return function (input, format, expected, description, asymetrical) {
32727 var m = moment(input, format);
32728 test.equal(m.format('YYYY MM DD'), expected, 'compare: ' + description);
32729
32730 //test round trip
32731 if (!asymetrical) {
32732 test.equal(m.format(format), input, 'round trip: ' + description);
32733 }
32734 };
32735 }
32736
32737 test('parsing week and weekday information', function (assert) {
32738 var ver = getVerifier(assert);
32739
32740 // year
32741 ver('12', 'gg', '2012 01 01', 'week-year two digits');
32742 ver('2012', 'gggg', '2012 01 01', 'week-year four digits');
32743
32744 ver('99', 'gg', '1998 12 27', 'week-year two digits previous year');
32745 ver('1999', 'gggg', '1998 12 27', 'week-year four digits previous year');
32746
32747 ver('99', 'GG', '1999 01 04', 'iso week-year two digits');
32748 ver('1999', 'GGGG', '1999 01 04', 'iso week-year four digits');
32749
32750 ver('13', 'GG', '2012 12 31', 'iso week-year two digits previous year');
32751 ver('2013', 'GGGG', '2012 12 31', 'iso week-year four digits previous year');
32752
32753 // year + week
32754 ver('1999 37', 'gggg w', '1999 09 05', 'week');
32755 ver('1999 37', 'gggg ww', '1999 09 05', 'week double');
32756 ver('1999 37', 'GGGG W', '1999 09 13', 'iso week');
32757 ver('1999 37', 'GGGG WW', '1999 09 13', 'iso week double');
32758
32759 ver('1999 37 4', 'GGGG WW E', '1999 09 16', 'iso day');
32760 ver('1999 37 04', 'GGGG WW E', '1999 09 16', 'iso day wide', true);
32761
32762 ver('1999 37 4', 'gggg ww e', '1999 09 09', 'day');
32763 ver('1999 37 04', 'gggg ww e', '1999 09 09', 'day wide', true);
32764
32765 // year + week + day
32766 ver('1999 37 4', 'gggg ww d', '1999 09 09', 'd');
32767 ver('1999 37 Th', 'gggg ww dd', '1999 09 09', 'dd');
32768 ver('1999 37 Thu', 'gggg ww ddd', '1999 09 09', 'ddd');
32769 ver('1999 37 Thursday', 'gggg ww dddd', '1999 09 09', 'dddd');
32770
32771 // lower-order only
32772 assert.equal(moment('22', 'ww').week(), 22, 'week sets the week by itself');
32773 assert.equal(moment('22', 'ww').weekYear(), moment().weekYear(), 'week keeps this year');
32774 assert.equal(moment('2012 22', 'YYYY ww').weekYear(), 2012, 'week keeps parsed year');
32775
32776 assert.equal(moment('22', 'WW').isoWeek(), 22, 'iso week sets the week by itself');
32777 assert.equal(moment('2012 22', 'YYYY WW').weekYear(), 2012, 'iso week keeps parsed year');
32778 assert.equal(moment('22', 'WW').isoWeekYear(), moment().isoWeekYear(), 'iso week keeps this year');
32779
32780 // order
32781 ver('6 2013 2', 'e gggg w', '2013 01 12', 'order doesn\'t matter');
32782 ver('6 2013 2', 'E GGGG W', '2013 01 12', 'iso order doesn\'t matter');
32783
32784 //can parse other stuff too
32785 assert.equal(moment('1999-W37-4 3:30', 'GGGG-[W]WW-E HH:mm').format('YYYY MM DD HH:mm'), '1999 09 16 03:30', 'parsing weeks and hours');
32786
32787 // In safari, all years before 1300 are shifted back with one day.
32788 // http://stackoverflow.com/questions/20768975/safari-subtracts-1-day-from-dates-before-1300
32789 if (new Date('1300-01-01').getUTCFullYear() === 1300) {
32790 // Years less than 100
32791 ver('0098-06', 'GGGG-WW', '0098 02 03', 'small years work', true);
32792 }
32793 });
32794
32795 test('parsing localized weekdays', function (assert) {
32796 var ver = getVerifier(assert);
32797 try {
32798 moment.locale('dow:1,doy:4', {
32799 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
32800 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
32801 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
32802 week: {dow: 1, doy: 4}
32803 });
32804 ver('1999 37 4', 'GGGG WW E', '1999 09 16', 'iso ignores locale');
32805 ver('1999 37 7', 'GGGG WW E', '1999 09 19', 'iso ignores locale');
32806
32807 ver('1999 37 0', 'gggg ww e', '1999 09 13', 'localized e uses local doy and dow: 0 = monday');
32808 ver('1999 37 4', 'gggg ww e', '1999 09 17', 'localized e uses local doy and dow: 4 = friday');
32809
32810 ver('1999 37 1', 'gggg ww d', '1999 09 13', 'localized d uses 0-indexed days: 1 = monday');
32811 ver('1999 37 Lu', 'gggg ww dd', '1999 09 13', 'localized d uses 0-indexed days: Mo');
32812 ver('1999 37 lun.', 'gggg ww ddd', '1999 09 13', 'localized d uses 0-indexed days: Mon');
32813 ver('1999 37 lundi', 'gggg ww dddd', '1999 09 13', 'localized d uses 0-indexed days: Monday');
32814 ver('1999 37 4', 'gggg ww d', '1999 09 16', 'localized d uses 0-indexed days: 4');
32815
32816 //sunday goes at the end of the week
32817 ver('1999 37 0', 'gggg ww d', '1999 09 19', 'localized d uses 0-indexed days: 0 = sund');
32818 ver('1999 37 Di', 'gggg ww dd', '1999 09 19', 'localized d uses 0-indexed days: 0 = sund');
32819 }
32820 finally {
32821 moment.locale('en');
32822 }
32823 });
32824
32825 test('parsing with customized two-digit year', function (assert) {
32826 var original = moment.parseTwoDigitYear;
32827 try {
32828 assert.equal(moment('68', 'YY').year(), 2068);
32829 assert.equal(moment('69', 'YY').year(), 1969);
32830 moment.parseTwoDigitYear = function (input) {
32831 return +input + (+input > 30 ? 1900 : 2000);
32832 };
32833 assert.equal(moment('68', 'YY').year(), 1968);
32834 assert.equal(moment('67', 'YY').year(), 1967);
32835 assert.equal(moment('31', 'YY').year(), 1931);
32836 assert.equal(moment('30', 'YY').year(), 2030);
32837 }
32838 finally {
32839 moment.parseTwoDigitYear = original;
32840 }
32841 });
32842
32843 test('array with strings', function (assert) {
32844 assert.equal(moment(['2014', '7', '31']).isValid(), true, 'string array + isValid');
32845 });
32846
32847 test('utc with array of formats', function (assert) {
32848 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');
32849 });
32850
32851 test('parsing invalid string weekdays', function (assert) {
32852 assert.equal(false, moment('a', 'dd').isValid(),
32853 'dd with invalid weekday, non-strict');
32854 assert.equal(false, moment('a', 'dd', true).isValid(),
32855 'dd with invalid weekday, strict');
32856 assert.equal(false, moment('a', 'ddd').isValid(),
32857 'ddd with invalid weekday, non-strict');
32858 assert.equal(false, moment('a', 'ddd', true).isValid(),
32859 'ddd with invalid weekday, strict');
32860 assert.equal(false, moment('a', 'dddd').isValid(),
32861 'dddd with invalid weekday, non-strict');
32862 assert.equal(false, moment('a', 'dddd', true).isValid(),
32863 'dddd with invalid weekday, strict');
32864 });
32865
32866 test('milliseconds', function (assert) {
32867 assert.equal(moment('1', 'S').millisecond(), 100);
32868 assert.equal(moment('12', 'SS').millisecond(), 120);
32869 assert.equal(moment('123', 'SSS').millisecond(), 123);
32870 assert.equal(moment('1234', 'SSSS').millisecond(), 123);
32871 assert.equal(moment('12345', 'SSSSS').millisecond(), 123);
32872 assert.equal(moment('123456', 'SSSSSS').millisecond(), 123);
32873 assert.equal(moment('1234567', 'SSSSSSS').millisecond(), 123);
32874 assert.equal(moment('12345678', 'SSSSSSSS').millisecond(), 123);
32875 assert.equal(moment('123456789', 'SSSSSSSSS').millisecond(), 123);
32876 });
32877
32878 }));
32879
32880 (function (global, factory) {
32881 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
32882 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
32883 factory(global.moment)
32884 }(this, function (moment) { 'use strict';
32885
32886 /*global QUnit:false*/
32887
32888 var test = QUnit.test;
32889
32890 function module (name, lifecycle) {
32891 QUnit.module(name, {
32892 setup : function () {
32893 moment.locale('en');
32894 moment.createFromInputFallback = function () {
32895 throw new Error('input not handled by moment');
32896 };
32897 if (lifecycle && lifecycle.setup) {
32898 lifecycle.setup();
32899 }
32900 },
32901 teardown : function () {
32902 if (lifecycle && lifecycle.teardown) {
32903 lifecycle.teardown();
32904 }
32905 }
32906 });
32907 }
32908
32909 function localeModule (name, lifecycle) {
32910 QUnit.module('locale:' + name, {
32911 setup : function () {
32912 moment.locale(name);
32913 moment.createFromInputFallback = function () {
32914 throw new Error('input not handled by moment');
32915 };
32916 if (lifecycle && lifecycle.setup) {
32917 lifecycle.setup();
32918 }
32919 },
32920 teardown : function () {
32921 moment.locale('en');
32922 if (lifecycle && lifecycle.teardown) {
32923 lifecycle.teardown();
32924 }
32925 }
32926 });
32927 }
32928
32929 function each(array, callback) {
32930 var i;
32931 for (i = 0; i < array.length; i++) {
32932 callback(array[i], i, array);
32933 }
32934 }
32935
32936 module('days in month');
32937
32938 test('days in month', function (assert) {
32939 each([31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], function (days, i) {
32940 var firstDay = moment([2012, i]),
32941 lastDay = moment([2012, i, days]);
32942 assert.equal(firstDay.daysInMonth(), days, firstDay.format('L') + ' should have ' + days + ' days.');
32943 assert.equal(lastDay.daysInMonth(), days, lastDay.format('L') + ' should have ' + days + ' days.');
32944 });
32945 });
32946
32947 test('days in month leap years', function (assert) {
32948 assert.equal(moment([2010, 1]).daysInMonth(), 28, 'Feb 2010 should have 28 days');
32949 assert.equal(moment([2100, 1]).daysInMonth(), 28, 'Feb 2100 should have 28 days');
32950 assert.equal(moment([2008, 1]).daysInMonth(), 29, 'Feb 2008 should have 29 days');
32951 assert.equal(moment([2000, 1]).daysInMonth(), 29, 'Feb 2000 should have 29 days');
32952 });
32953
32954 }));
32955
32956 (function (global, factory) {
32957 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
32958 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
32959 factory(global.moment)
32960 }(this, function (moment) { 'use strict';
32961
32962 /*global QUnit:false*/
32963
32964 var test = QUnit.test;
32965
32966 function module (name, lifecycle) {
32967 QUnit.module(name, {
32968 setup : function () {
32969 moment.locale('en');
32970 moment.createFromInputFallback = function () {
32971 throw new Error('input not handled by moment');
32972 };
32973 if (lifecycle && lifecycle.setup) {
32974 lifecycle.setup();
32975 }
32976 },
32977 teardown : function () {
32978 if (lifecycle && lifecycle.teardown) {
32979 lifecycle.teardown();
32980 }
32981 }
32982 });
32983 }
32984
32985 function localeModule (name, lifecycle) {
32986 QUnit.module('locale:' + name, {
32987 setup : function () {
32988 moment.locale(name);
32989 moment.createFromInputFallback = function () {
32990 throw new Error('input not handled by moment');
32991 };
32992 if (lifecycle && lifecycle.setup) {
32993 lifecycle.setup();
32994 }
32995 },
32996 teardown : function () {
32997 moment.locale('en');
32998 if (lifecycle && lifecycle.teardown) {
32999 lifecycle.teardown();
33000 }
33001 }
33002 });
33003 }
33004
33005 function equal(assert, a, b, message) {
33006 assert.ok(Math.abs(a - b) < 0.00000001, '(' + a + ' === ' + b + ') ' + message);
33007 }
33008
33009 function dstForYear(year) {
33010 var start = moment([year]),
33011 end = moment([year + 1]),
33012 current = start.clone(),
33013 last;
33014
33015 while (current < end) {
33016 last = current.clone();
33017 current.add(24, 'hour');
33018 if (last.utcOffset() !== current.utcOffset()) {
33019 end = current.clone();
33020 current = last.clone();
33021 break;
33022 }
33023 }
33024
33025 while (current < end) {
33026 last = current.clone();
33027 current.add(1, 'hour');
33028 if (last.utcOffset() !== current.utcOffset()) {
33029 return {
33030 moment : last,
33031 diff : -(current.utcOffset() - last.utcOffset()) / 60
33032 };
33033 }
33034 }
33035 }
33036
33037 module('diff');
33038
33039 test('diff', function (assert) {
33040 assert.equal(moment(1000).diff(0), 1000, '1 second - 0 = 1000');
33041 assert.equal(moment(1000).diff(500), 500, '1 second - 0.5 seconds = 500');
33042 assert.equal(moment(0).diff(1000), -1000, '0 - 1 second = -1000');
33043 assert.equal(moment(new Date(1000)).diff(1000), 0, '1 second - 1 second = 0');
33044 var oneHourDate = new Date(),
33045 nowDate = new Date(+oneHourDate);
33046 oneHourDate.setHours(oneHourDate.getHours() + 1);
33047 assert.equal(moment(oneHourDate).diff(nowDate), 60 * 60 * 1000, '1 hour from now = 3600000');
33048 });
33049
33050 test('diff key after', function (assert) {
33051 assert.equal(moment([2010]).diff([2011], 'years'), -1, 'year diff');
33052 assert.equal(moment([2010]).diff([2010, 2], 'months'), -2, 'month diff');
33053 assert.equal(moment([2010]).diff([2010, 0, 7], 'weeks'), 0, 'week diff');
33054 assert.equal(moment([2010]).diff([2010, 0, 8], 'weeks'), -1, 'week diff');
33055 assert.equal(moment([2010]).diff([2010, 0, 21], 'weeks'), -2, 'week diff');
33056 assert.equal(moment([2010]).diff([2010, 0, 22], 'weeks'), -3, 'week diff');
33057 assert.equal(moment([2010]).diff([2010, 0, 4], 'days'), -3, 'day diff');
33058 assert.equal(moment([2010]).diff([2010, 0, 1, 4], 'hours'), -4, 'hour diff');
33059 assert.equal(moment([2010]).diff([2010, 0, 1, 0, 5], 'minutes'), -5, 'minute diff');
33060 assert.equal(moment([2010]).diff([2010, 0, 1, 0, 0, 6], 'seconds'), -6, 'second diff');
33061 });
33062
33063 test('diff key before', function (assert) {
33064 assert.equal(moment([2011]).diff([2010], 'years'), 1, 'year diff');
33065 assert.equal(moment([2010, 2]).diff([2010], 'months'), 2, 'month diff');
33066 assert.equal(moment([2010, 0, 4]).diff([2010], 'days'), 3, 'day diff');
33067 assert.equal(moment([2010, 0, 7]).diff([2010], 'weeks'), 0, 'week diff');
33068 assert.equal(moment([2010, 0, 8]).diff([2010], 'weeks'), 1, 'week diff');
33069 assert.equal(moment([2010, 0, 21]).diff([2010], 'weeks'), 2, 'week diff');
33070 assert.equal(moment([2010, 0, 22]).diff([2010], 'weeks'), 3, 'week diff');
33071 assert.equal(moment([2010, 0, 1, 4]).diff([2010], 'hours'), 4, 'hour diff');
33072 assert.equal(moment([2010, 0, 1, 0, 5]).diff([2010], 'minutes'), 5, 'minute diff');
33073 assert.equal(moment([2010, 0, 1, 0, 0, 6]).diff([2010], 'seconds'), 6, 'second diff');
33074 });
33075
33076 test('diff key before singular', function (assert) {
33077 assert.equal(moment([2011]).diff([2010], 'year'), 1, 'year diff singular');
33078 assert.equal(moment([2010, 2]).diff([2010], 'month'), 2, 'month diff singular');
33079 assert.equal(moment([2010, 0, 4]).diff([2010], 'day'), 3, 'day diff singular');
33080 assert.equal(moment([2010, 0, 7]).diff([2010], 'week'), 0, 'week diff singular');
33081 assert.equal(moment([2010, 0, 8]).diff([2010], 'week'), 1, 'week diff singular');
33082 assert.equal(moment([2010, 0, 21]).diff([2010], 'week'), 2, 'week diff singular');
33083 assert.equal(moment([2010, 0, 22]).diff([2010], 'week'), 3, 'week diff singular');
33084 assert.equal(moment([2010, 0, 1, 4]).diff([2010], 'hour'), 4, 'hour diff singular');
33085 assert.equal(moment([2010, 0, 1, 0, 5]).diff([2010], 'minute'), 5, 'minute diff singular');
33086 assert.equal(moment([2010, 0, 1, 0, 0, 6]).diff([2010], 'second'), 6, 'second diff singular');
33087 });
33088
33089 test('diff key before abbreviated', function (assert) {
33090 assert.equal(moment([2011]).diff([2010], 'y'), 1, 'year diff abbreviated');
33091 assert.equal(moment([2010, 2]).diff([2010], 'M'), 2, 'month diff abbreviated');
33092 assert.equal(moment([2010, 0, 4]).diff([2010], 'd'), 3, 'day diff abbreviated');
33093 assert.equal(moment([2010, 0, 7]).diff([2010], 'w'), 0, 'week diff abbreviated');
33094 assert.equal(moment([2010, 0, 8]).diff([2010], 'w'), 1, 'week diff abbreviated');
33095 assert.equal(moment([2010, 0, 21]).diff([2010], 'w'), 2, 'week diff abbreviated');
33096 assert.equal(moment([2010, 0, 22]).diff([2010], 'w'), 3, 'week diff abbreviated');
33097 assert.equal(moment([2010, 0, 1, 4]).diff([2010], 'h'), 4, 'hour diff abbreviated');
33098 assert.equal(moment([2010, 0, 1, 0, 5]).diff([2010], 'm'), 5, 'minute diff abbreviated');
33099 assert.equal(moment([2010, 0, 1, 0, 0, 6]).diff([2010], 's'), 6, 'second diff abbreviated');
33100 });
33101
33102 test('diff month', function (assert) {
33103 assert.equal(moment([2011, 0, 31]).diff([2011, 2, 1], 'months'), -1, 'month diff');
33104 });
33105
33106 test('diff across DST', function (assert) {
33107 var dst = dstForYear(2012), a, b, daysInMonth;
33108 if (!dst) {
33109 assert.equal(42, 42, 'at least one assertion');
33110 return;
33111 }
33112
33113 a = dst.moment;
33114 b = a.clone().utc().add(12, 'hours').local();
33115 daysInMonth = (a.daysInMonth() + b.daysInMonth()) / 2;
33116 assert.equal(b.diff(a, 'milliseconds', true), 12 * 60 * 60 * 1000,
33117 'ms diff across DST');
33118 assert.equal(b.diff(a, 'seconds', true), 12 * 60 * 60,
33119 'second diff across DST');
33120 assert.equal(b.diff(a, 'minutes', true), 12 * 60,
33121 'minute diff across DST');
33122 assert.equal(b.diff(a, 'hours', true), 12,
33123 'hour diff across DST');
33124 assert.equal(b.diff(a, 'days', true), (12 - dst.diff) / 24,
33125 'day diff across DST');
33126 equal(assert, b.diff(a, 'weeks', true), (12 - dst.diff) / 24 / 7,
33127 'week diff across DST');
33128 assert.ok(0.95 / (2 * 31) < b.diff(a, 'months', true),
33129 'month diff across DST, lower bound');
33130 assert.ok(b.diff(a, 'month', true) < 1.05 / (2 * 28),
33131 'month diff across DST, upper bound');
33132 assert.ok(0.95 / (2 * 31 * 12) < b.diff(a, 'years', true),
33133 'year diff across DST, lower bound');
33134 assert.ok(b.diff(a, 'year', true) < 1.05 / (2 * 28 * 12),
33135 'year diff across DST, upper bound');
33136
33137 a = dst.moment;
33138 b = a.clone().utc().add(12 + dst.diff, 'hours').local();
33139 daysInMonth = (a.daysInMonth() + b.daysInMonth()) / 2;
33140
33141 assert.equal(b.diff(a, 'milliseconds', true),
33142 (12 + dst.diff) * 60 * 60 * 1000,
33143 'ms diff across DST');
33144 assert.equal(b.diff(a, 'seconds', true), (12 + dst.diff) * 60 * 60,
33145 'second diff across DST');
33146 assert.equal(b.diff(a, 'minutes', true), (12 + dst.diff) * 60,
33147 'minute diff across DST');
33148 assert.equal(b.diff(a, 'hours', true), (12 + dst.diff),
33149 'hour diff across DST');
33150 assert.equal(b.diff(a, 'days', true), 12 / 24, 'day diff across DST');
33151 equal(assert, b.diff(a, 'weeks', true), 12 / 24 / 7,
33152 'week diff across DST');
33153 assert.ok(0.95 / (2 * 31) < b.diff(a, 'months', true),
33154 'month diff across DST, lower bound');
33155 assert.ok(b.diff(a, 'month', true) < 1.05 / (2 * 28),
33156 'month diff across DST, upper bound');
33157 assert.ok(0.95 / (2 * 31 * 12) < b.diff(a, 'years', true),
33158 'year diff across DST, lower bound');
33159 assert.ok(b.diff(a, 'year', true) < 1.05 / (2 * 28 * 12),
33160 'year diff across DST, upper bound');
33161 });
33162
33163 test('diff overflow', function (assert) {
33164 assert.equal(moment([2011]).diff([2010], 'months'), 12, 'month diff');
33165 assert.equal(moment([2010, 0, 2]).diff([2010], 'hours'), 24, 'hour diff');
33166 assert.equal(moment([2010, 0, 1, 2]).diff([2010], 'minutes'), 120, 'minute diff');
33167 assert.equal(moment([2010, 0, 1, 0, 4]).diff([2010], 'seconds'), 240, 'second diff');
33168 });
33169
33170 test('diff between utc and local', function (assert) {
33171 if (moment([2012]).utcOffset() === moment([2011]).utcOffset()) {
33172 // Russia's utc offset on 1st of Jan 2012 vs 2011 is different
33173 assert.equal(moment([2012]).utc().diff([2011], 'years'), 1, 'year diff');
33174 }
33175 assert.equal(moment([2010, 2, 2]).utc().diff([2010, 0, 2], 'months'), 2, 'month diff');
33176 assert.equal(moment([2010, 0, 4]).utc().diff([2010], 'days'), 3, 'day diff');
33177 assert.equal(moment([2010, 0, 22]).utc().diff([2010], 'weeks'), 3, 'week diff');
33178 assert.equal(moment([2010, 0, 1, 4]).utc().diff([2010], 'hours'), 4, 'hour diff');
33179 assert.equal(moment([2010, 0, 1, 0, 5]).utc().diff([2010], 'minutes'), 5, 'minute diff');
33180 assert.equal(moment([2010, 0, 1, 0, 0, 6]).utc().diff([2010], 'seconds'), 6, 'second diff');
33181 });
33182
33183 test('diff floored', function (assert) {
33184 assert.equal(moment([2010, 0, 1, 23]).diff([2010], 'day'), 0, '23 hours = 0 days');
33185 assert.equal(moment([2010, 0, 1, 23, 59]).diff([2010], 'day'), 0, '23:59 hours = 0 days');
33186 assert.equal(moment([2010, 0, 1, 24]).diff([2010], 'day'), 1, '24 hours = 1 day');
33187 assert.equal(moment([2010, 0, 2]).diff([2011, 0, 1], 'year'), 0, 'year rounded down');
33188 assert.equal(moment([2011, 0, 1]).diff([2010, 0, 2], 'year'), 0, 'year rounded down');
33189 assert.equal(moment([2010, 0, 2]).diff([2011, 0, 2], 'year'), -1, 'year rounded down');
33190 assert.equal(moment([2011, 0, 2]).diff([2010, 0, 2], 'year'), 1, 'year rounded down');
33191 });
33192
33193 test('year diffs include dates', function (assert) {
33194 assert.ok(moment([2012, 1, 19]).diff(moment([2002, 1, 20]), 'years', true) < 10, 'year diff should include date of month');
33195 });
33196
33197 test('month diffs', function (assert) {
33198 // due to floating point math errors, these tests just need to be accurate within 0.00000001
33199 assert.equal(moment([2012, 0, 1]).diff([2012, 1, 1], 'months', true), -1, 'Jan 1 to Feb 1 should be 1 month');
33200 equal(assert, moment([2012, 0, 1]).diff([2012, 0, 1, 12], 'months', true), -0.5 / 31, 'Jan 1 to Jan 1 noon should be 0.5 / 31 months');
33201 assert.equal(moment([2012, 0, 15]).diff([2012, 1, 15], 'months', true), -1, 'Jan 15 to Feb 15 should be 1 month');
33202 assert.equal(moment([2012, 0, 28]).diff([2012, 1, 28], 'months', true), -1, 'Jan 28 to Feb 28 should be 1 month');
33203 assert.ok(moment([2012, 0, 31]).diff([2012, 1, 29], 'months', true), -1, 'Jan 31 to Feb 29 should be 1 month');
33204 assert.ok(-1 > moment([2012, 0, 31]).diff([2012, 2, 1], 'months', true), 'Jan 31 to Mar 1 should be more than 1 month');
33205 assert.ok(-30 / 28 < moment([2012, 0, 31]).diff([2012, 2, 1], 'months', true), 'Jan 31 to Mar 1 should be less than 1 month and 1 day');
33206 equal(assert, moment([2012, 0, 1]).diff([2012, 0, 31], 'months', true), -(30 / 31), 'Jan 1 to Jan 31 should be 30 / 31 months');
33207 assert.ok(0 < moment('2014-02-01').diff(moment('2014-01-31'), 'months', true), 'jan-31 to feb-1 diff is positive');
33208 });
33209
33210 test('exact month diffs', function (assert) {
33211 // generate all pairs of months and compute month diff, with fixed day
33212 // of month = 15.
33213
33214 var m1, m2;
33215 for (m1 = 0; m1 < 12; ++m1) {
33216 for (m2 = m1; m2 < 12; ++m2) {
33217 assert.equal(moment([2013, m2, 15]).diff(moment([2013, m1, 15]), 'months', true), m2 - m1,
33218 'month diff from 2013-' + m1 + '-15 to 2013-' + m2 + '-15');
33219 }
33220 }
33221 });
33222
33223 test('year diffs', function (assert) {
33224 // due to floating point math errors, these tests just need to be accurate within 0.00000001
33225 equal(assert, moment([2012, 0, 1]).diff([2013, 0, 1], 'years', true), -1, 'Jan 1 2012 to Jan 1 2013 should be 1 year');
33226 equal(assert, moment([2012, 1, 28]).diff([2013, 1, 28], 'years', true), -1, 'Feb 28 2012 to Feb 28 2013 should be 1 year');
33227 equal(assert, moment([2012, 2, 1]).diff([2013, 2, 1], 'years', true), -1, 'Mar 1 2012 to Mar 1 2013 should be 1 year');
33228 equal(assert, moment([2012, 11, 1]).diff([2013, 11, 1], 'years', true), -1, 'Dec 1 2012 to Dec 1 2013 should be 1 year');
33229 equal(assert, moment([2012, 11, 31]).diff([2013, 11, 31], 'years', true), -1, 'Dec 31 2012 to Dec 31 2013 should be 1 year');
33230 equal(assert, moment([2012, 0, 1]).diff([2013, 6, 1], 'years', true), -1.5, 'Jan 1 2012 to Jul 1 2013 should be 1.5 years');
33231 equal(assert, moment([2012, 0, 31]).diff([2013, 6, 31], 'years', true), -1.5, 'Jan 31 2012 to Jul 31 2013 should be 1.5 years');
33232 equal(assert, moment([2012, 0, 1]).diff([2013, 0, 1, 12], 'years', true), -1 - (0.5 / 31) / 12, 'Jan 1 2012 to Jan 1 2013 noon should be 1+(0.5 / 31) / 12 years');
33233 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');
33234 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');
33235 });
33236
33237 }));
33238
33239 (function (global, factory) {
33240 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
33241 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
33242 factory(global.moment)
33243 }(this, function (moment) { 'use strict';
33244
33245 /*global QUnit:false*/
33246
33247 var test = QUnit.test;
33248
33249 function module (name, lifecycle) {
33250 QUnit.module(name, {
33251 setup : function () {
33252 moment.locale('en');
33253 moment.createFromInputFallback = function () {
33254 throw new Error('input not handled by moment');
33255 };
33256 if (lifecycle && lifecycle.setup) {
33257 lifecycle.setup();
33258 }
33259 },
33260 teardown : function () {
33261 if (lifecycle && lifecycle.teardown) {
33262 lifecycle.teardown();
33263 }
33264 }
33265 });
33266 }
33267
33268 function localeModule (name, lifecycle) {
33269 QUnit.module('locale:' + name, {
33270 setup : function () {
33271 moment.locale(name);
33272 moment.createFromInputFallback = function () {
33273 throw new Error('input not handled by moment');
33274 };
33275 if (lifecycle && lifecycle.setup) {
33276 lifecycle.setup();
33277 }
33278 },
33279 teardown : function () {
33280 moment.locale('en');
33281 if (lifecycle && lifecycle.teardown) {
33282 lifecycle.teardown();
33283 }
33284 }
33285 });
33286 }
33287
33288 module('duration');
33289
33290 test('object instantiation', function (assert) {
33291 var d = moment.duration({
33292 years: 2,
33293 months: 3,
33294 weeks: 2,
33295 days: 1,
33296 hours: 8,
33297 minutes: 9,
33298 seconds: 20,
33299 milliseconds: 12
33300 });
33301
33302 assert.equal(d.years(), 2, 'years');
33303 assert.equal(d.months(), 3, 'months');
33304 assert.equal(d.weeks(), 2, 'weeks');
33305 assert.equal(d.days(), 15, 'days'); // two weeks + 1 day
33306 assert.equal(d.hours(), 8, 'hours');
33307 assert.equal(d.minutes(), 9, 'minutes');
33308 assert.equal(d.seconds(), 20, 'seconds');
33309 assert.equal(d.milliseconds(), 12, 'milliseconds');
33310 });
33311
33312 test('object instantiation with strings', function (assert) {
33313 var d = moment.duration({
33314 years: '2',
33315 months: '3',
33316 weeks: '2',
33317 days: '1',
33318 hours: '8',
33319 minutes: '9',
33320 seconds: '20',
33321 milliseconds: '12'
33322 });
33323
33324 assert.equal(d.years(), 2, 'years');
33325 assert.equal(d.months(), 3, 'months');
33326 assert.equal(d.weeks(), 2, 'weeks');
33327 assert.equal(d.days(), 15, 'days'); // two weeks + 1 day
33328 assert.equal(d.hours(), 8, 'hours');
33329 assert.equal(d.minutes(), 9, 'minutes');
33330 assert.equal(d.seconds(), 20, 'seconds');
33331 assert.equal(d.milliseconds(), 12, 'milliseconds');
33332 });
33333
33334 test('milliseconds instantiation', function (assert) {
33335 assert.equal(moment.duration(72).milliseconds(), 72, 'milliseconds');
33336 });
33337
33338 test('undefined instantiation', function (assert) {
33339 assert.equal(moment.duration(undefined).milliseconds(), 0, 'milliseconds');
33340 });
33341
33342 test('null instantiation', function (assert) {
33343 assert.equal(moment.duration(null).milliseconds(), 0, 'milliseconds');
33344 });
33345
33346 test('instantiation by type', function (assert) {
33347 assert.equal(moment.duration(1, 'years').years(), 1, 'years');
33348 assert.equal(moment.duration(1, 'y').years(), 1, 'y');
33349 assert.equal(moment.duration(2, 'months').months(), 2, 'months');
33350 assert.equal(moment.duration(2, 'M').months(), 2, 'M');
33351 assert.equal(moment.duration(3, 'weeks').weeks(), 3, 'weeks');
33352 assert.equal(moment.duration(3, 'w').weeks(), 3, 'weeks');
33353 assert.equal(moment.duration(4, 'days').days(), 4, 'days');
33354 assert.equal(moment.duration(4, 'd').days(), 4, 'd');
33355 assert.equal(moment.duration(5, 'hours').hours(), 5, 'hours');
33356 assert.equal(moment.duration(5, 'h').hours(), 5, 'h');
33357 assert.equal(moment.duration(6, 'minutes').minutes(), 6, 'minutes');
33358 assert.equal(moment.duration(6, 'm').minutes(), 6, 'm');
33359 assert.equal(moment.duration(7, 'seconds').seconds(), 7, 'seconds');
33360 assert.equal(moment.duration(7, 's').seconds(), 7, 's');
33361 assert.equal(moment.duration(8, 'milliseconds').milliseconds(), 8, 'milliseconds');
33362 assert.equal(moment.duration(8, 'ms').milliseconds(), 8, 'ms');
33363 });
33364
33365 test('shortcuts', function (assert) {
33366 assert.equal(moment.duration({y: 1}).years(), 1, 'years = y');
33367 assert.equal(moment.duration({M: 2}).months(), 2, 'months = M');
33368 assert.equal(moment.duration({w: 3}).weeks(), 3, 'weeks = w');
33369 assert.equal(moment.duration({d: 4}).days(), 4, 'days = d');
33370 assert.equal(moment.duration({h: 5}).hours(), 5, 'hours = h');
33371 assert.equal(moment.duration({m: 6}).minutes(), 6, 'minutes = m');
33372 assert.equal(moment.duration({s: 7}).seconds(), 7, 'seconds = s');
33373 assert.equal(moment.duration({ms: 8}).milliseconds(), 8, 'milliseconds = ms');
33374 });
33375
33376 test('generic getter', function (assert) {
33377 assert.equal(moment.duration(1, 'years').get('years'), 1, 'years');
33378 assert.equal(moment.duration(1, 'years').get('year'), 1, 'years = year');
33379 assert.equal(moment.duration(1, 'years').get('y'), 1, 'years = y');
33380 assert.equal(moment.duration(2, 'months').get('months'), 2, 'months');
33381 assert.equal(moment.duration(2, 'months').get('month'), 2, 'months = month');
33382 assert.equal(moment.duration(2, 'months').get('M'), 2, 'months = M');
33383 assert.equal(moment.duration(3, 'weeks').get('weeks'), 3, 'weeks');
33384 assert.equal(moment.duration(3, 'weeks').get('week'), 3, 'weeks = week');
33385 assert.equal(moment.duration(3, 'weeks').get('w'), 3, 'weeks = w');
33386 assert.equal(moment.duration(4, 'days').get('days'), 4, 'days');
33387 assert.equal(moment.duration(4, 'days').get('day'), 4, 'days = day');
33388 assert.equal(moment.duration(4, 'days').get('d'), 4, 'days = d');
33389 assert.equal(moment.duration(5, 'hours').get('hours'), 5, 'hours');
33390 assert.equal(moment.duration(5, 'hours').get('hour'), 5, 'hours = hour');
33391 assert.equal(moment.duration(5, 'hours').get('h'), 5, 'hours = h');
33392 assert.equal(moment.duration(6, 'minutes').get('minutes'), 6, 'minutes');
33393 assert.equal(moment.duration(6, 'minutes').get('minute'), 6, 'minutes = minute');
33394 assert.equal(moment.duration(6, 'minutes').get('m'), 6, 'minutes = m');
33395 assert.equal(moment.duration(7, 'seconds').get('seconds'), 7, 'seconds');
33396 assert.equal(moment.duration(7, 'seconds').get('second'), 7, 'seconds = second');
33397 assert.equal(moment.duration(7, 'seconds').get('s'), 7, 'seconds = s');
33398 assert.equal(moment.duration(8, 'milliseconds').get('milliseconds'), 8, 'milliseconds');
33399 assert.equal(moment.duration(8, 'milliseconds').get('millisecond'), 8, 'milliseconds = millisecond');
33400 assert.equal(moment.duration(8, 'milliseconds').get('ms'), 8, 'milliseconds = ms');
33401 });
33402
33403 test('instantiation from another duration', function (assert) {
33404 var simple = moment.duration(1234),
33405 lengthy = moment.duration(60 * 60 * 24 * 360 * 1e3),
33406 complicated = moment.duration({
33407 years: 2,
33408 months: 3,
33409 weeks: 4,
33410 days: 1,
33411 hours: 8,
33412 minutes: 9,
33413 seconds: 20,
33414 milliseconds: 12
33415 }),
33416 modified = moment.duration(1, 'day').add(moment.duration(1, 'day'));
33417
33418 assert.deepEqual(moment.duration(simple), simple, 'simple clones are equal');
33419 assert.deepEqual(moment.duration(lengthy), lengthy, 'lengthy clones are equal');
33420 assert.deepEqual(moment.duration(complicated), complicated, 'complicated clones are equal');
33421 assert.deepEqual(moment.duration(modified), modified, 'cloning modified duration works');
33422 });
33423
33424 test('instantiation from 24-hour time zero', function (assert) {
33425 assert.equal(moment.duration('00:00').years(), 0, '0 years');
33426 assert.equal(moment.duration('00:00').days(), 0, '0 days');
33427 assert.equal(moment.duration('00:00').hours(), 0, '0 hours');
33428 assert.equal(moment.duration('00:00').minutes(), 0, '0 minutes');
33429 assert.equal(moment.duration('00:00').seconds(), 0, '0 seconds');
33430 assert.equal(moment.duration('00:00').milliseconds(), 0, '0 milliseconds');
33431 });
33432
33433 test('instantiation from 24-hour time <24 hours', function (assert) {
33434 assert.equal(moment.duration('06:45').years(), 0, '0 years');
33435 assert.equal(moment.duration('06:45').days(), 0, '0 days');
33436 assert.equal(moment.duration('06:45').hours(), 6, '6 hours');
33437 assert.equal(moment.duration('06:45').minutes(), 45, '45 minutes');
33438 assert.equal(moment.duration('06:45').seconds(), 0, '0 seconds');
33439 assert.equal(moment.duration('06:45').milliseconds(), 0, '0 milliseconds');
33440 });
33441
33442 test('instantiation from 24-hour time >24 hours', function (assert) {
33443 assert.equal(moment.duration('26:45').years(), 0, '0 years');
33444 assert.equal(moment.duration('26:45').days(), 1, '0 days');
33445 assert.equal(moment.duration('26:45').hours(), 2, '2 hours');
33446 assert.equal(moment.duration('26:45').minutes(), 45, '45 minutes');
33447 assert.equal(moment.duration('26:45').seconds(), 0, '0 seconds');
33448 assert.equal(moment.duration('26:45').milliseconds(), 0, '0 milliseconds');
33449 });
33450
33451 test('instatiation from serialized C# TimeSpan zero', function (assert) {
33452 assert.equal(moment.duration('00:00:00').years(), 0, '0 years');
33453 assert.equal(moment.duration('00:00:00').days(), 0, '0 days');
33454 assert.equal(moment.duration('00:00:00').hours(), 0, '0 hours');
33455 assert.equal(moment.duration('00:00:00').minutes(), 0, '0 minutes');
33456 assert.equal(moment.duration('00:00:00').seconds(), 0, '0 seconds');
33457 assert.equal(moment.duration('00:00:00').milliseconds(), 0, '0 milliseconds');
33458 });
33459
33460 test('instatiation from serialized C# TimeSpan with days', function (assert) {
33461 assert.equal(moment.duration('1.02:03:04.9999999').years(), 0, '0 years');
33462 assert.equal(moment.duration('1.02:03:04.9999999').days(), 1, '1 day');
33463 assert.equal(moment.duration('1.02:03:04.9999999').hours(), 2, '2 hours');
33464 assert.equal(moment.duration('1.02:03:04.9999999').minutes(), 3, '3 minutes');
33465 assert.equal(moment.duration('1.02:03:04.9999999').seconds(), 4, '4 seconds');
33466 assert.equal(moment.duration('1.02:03:04.9999999').milliseconds(), 999, '999 milliseconds');
33467 });
33468
33469 test('instatiation from serialized C# TimeSpan without days', function (assert) {
33470 assert.equal(moment.duration('01:02:03.9999999').years(), 0, '0 years');
33471 assert.equal(moment.duration('01:02:03.9999999').days(), 0, '0 days');
33472 assert.equal(moment.duration('01:02:03.9999999').hours(), 1, '1 hour');
33473 assert.equal(moment.duration('01:02:03.9999999').minutes(), 2, '2 minutes');
33474 assert.equal(moment.duration('01:02:03.9999999').seconds(), 3, '3 seconds');
33475 assert.equal(moment.duration('01:02:03.9999999').milliseconds(), 999, '999 milliseconds');
33476
33477 assert.equal(moment.duration('23:59:59.9999999').days(), 0, '0 days');
33478 assert.equal(moment.duration('23:59:59.9999999').hours(), 23, '23 hours');
33479
33480 assert.equal(moment.duration('500:59:59.9999999').days(), 20, '500 hours overflows to 20 days');
33481 assert.equal(moment.duration('500:59:59.9999999').hours(), 20, '500 hours overflows to 20 hours');
33482 });
33483
33484 test('instatiation from serialized C# TimeSpan without days or milliseconds', function (assert) {
33485 assert.equal(moment.duration('01:02:03').years(), 0, '0 years');
33486 assert.equal(moment.duration('01:02:03').days(), 0, '0 days');
33487 assert.equal(moment.duration('01:02:03').hours(), 1, '1 hour');
33488 assert.equal(moment.duration('01:02:03').minutes(), 2, '2 minutes');
33489 assert.equal(moment.duration('01:02:03').seconds(), 3, '3 seconds');
33490 assert.equal(moment.duration('01:02:03').milliseconds(), 0, '0 milliseconds');
33491 });
33492
33493 test('instatiation from serialized C# TimeSpan without milliseconds', function (assert) {
33494 assert.equal(moment.duration('1.02:03:04').years(), 0, '0 years');
33495 assert.equal(moment.duration('1.02:03:04').days(), 1, '1 day');
33496 assert.equal(moment.duration('1.02:03:04').hours(), 2, '2 hours');
33497 assert.equal(moment.duration('1.02:03:04').minutes(), 3, '3 minutes');
33498 assert.equal(moment.duration('1.02:03:04').seconds(), 4, '4 seconds');
33499 assert.equal(moment.duration('1.02:03:04').milliseconds(), 0, '0 milliseconds');
33500 });
33501
33502 test('instatiation from serialized C# TimeSpan maxValue', function (assert) {
33503 var d = moment.duration('10675199.02:48:05.4775807');
33504
33505 assert.equal(d.years(), 29227, '29227 years');
33506 assert.equal(d.months(), 8, '8 months');
33507 assert.equal(d.days(), 12, '12 day'); // if you have to change this value -- just do it
33508
33509 assert.equal(d.hours(), 2, '2 hours');
33510 assert.equal(d.minutes(), 48, '48 minutes');
33511 assert.equal(d.seconds(), 5, '5 seconds');
33512 assert.equal(d.milliseconds(), 477, '477 milliseconds');
33513 });
33514
33515 test('instatiation from serialized C# TimeSpan minValue', function (assert) {
33516 var d = moment.duration('-10675199.02:48:05.4775808');
33517
33518 assert.equal(d.years(), -29227, '29653 years');
33519 assert.equal(d.months(), -8, '8 day');
33520 assert.equal(d.days(), -12, '12 day'); // if you have to change this value -- just do it
33521
33522 assert.equal(d.hours(), -2, '2 hours');
33523 assert.equal(d.minutes(), -48, '48 minutes');
33524 assert.equal(d.seconds(), -5, '5 seconds');
33525 assert.equal(d.milliseconds(), -477, '477 milliseconds');
33526 });
33527
33528 test('instantiation from ISO 8601 duration', function (assert) {
33529 assert.equal(moment.duration('P1Y2M3DT4H5M6S').asSeconds(), moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).asSeconds(), 'all fields');
33530 assert.equal(moment.duration('P1M').asSeconds(), moment.duration({M: 1}).asSeconds(), 'single month field');
33531 assert.equal(moment.duration('PT1M').asSeconds(), moment.duration({m: 1}).asSeconds(), 'single minute field');
33532 assert.equal(moment.duration('P1MT2H').asSeconds(), moment.duration({M: 1, h: 2}).asSeconds(), 'random fields missing');
33533 assert.equal(moment.duration('-P60D').asSeconds(), moment.duration({d: -60}).asSeconds(), 'negative days');
33534 assert.equal(moment.duration('PT0.5S').asSeconds(), moment.duration({s: 0.5}).asSeconds(), 'fractional seconds');
33535 assert.equal(moment.duration('PT0,5S').asSeconds(), moment.duration({s: 0.5}).asSeconds(), 'fractional seconds (comma)');
33536 });
33537
33538 test('serialization to ISO 8601 duration strings', function (assert) {
33539 assert.equal(moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).toISOString(), 'P1Y2M3DT4H5M6S', 'all fields');
33540 assert.equal(moment.duration({M: -1}).toISOString(), '-P1M', 'one month ago');
33541 assert.equal(moment.duration({m: -1}).toISOString(), '-PT1M', 'one minute ago');
33542 assert.equal(moment.duration({s: -0.5}).toISOString(), '-PT0.5S', 'one half second ago');
33543 assert.equal(moment.duration({y: -0.5, M: 1}).toISOString(), '-P5M', 'a month after half a year ago');
33544 assert.equal(moment.duration({}).toISOString(), 'P0D', 'zero duration');
33545 assert.equal(moment.duration({M: 16, d:40, s: 86465}).toISOString(), 'P1Y4M40DT24H1M5S', 'all fields');
33546 });
33547
33548 test('toString acts as toISOString', function (assert) {
33549 assert.equal(moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).toString(), 'P1Y2M3DT4H5M6S', 'all fields');
33550 assert.equal(moment.duration({M: -1}).toString(), '-P1M', 'one month ago');
33551 assert.equal(moment.duration({m: -1}).toString(), '-PT1M', 'one minute ago');
33552 assert.equal(moment.duration({s: -0.5}).toString(), '-PT0.5S', 'one half second ago');
33553 assert.equal(moment.duration({y: -0.5, M: 1}).toString(), '-P5M', 'a month after half a year ago');
33554 assert.equal(moment.duration({}).toString(), 'P0D', 'zero duration');
33555 assert.equal(moment.duration({M: 16, d:40, s: 86465}).toString(), 'P1Y4M40DT24H1M5S', 'all fields');
33556 });
33557
33558 test('toIsoString deprecation', function (assert) {
33559 assert.equal(moment.duration({}).toIsoString(), moment.duration({}).toISOString(), 'toIsoString delegates to toISOString');
33560 });
33561
33562 test('`isodate` (python) test cases', function (assert) {
33563 assert.equal(moment.duration('P18Y9M4DT11H9M8S').asSeconds(), moment.duration({y: 18, M: 9, d: 4, h: 11, m: 9, s: 8}).asSeconds(), 'python isodate 1');
33564 assert.equal(moment.duration('P2W').asSeconds(), moment.duration({w: 2}).asSeconds(), 'python isodate 2');
33565 assert.equal(moment.duration('P3Y6M4DT12H30M5S').asSeconds(), moment.duration({y: 3, M: 6, d: 4, h: 12, m: 30, s: 5}).asSeconds(), 'python isodate 3');
33566 assert.equal(moment.duration('P23DT23H').asSeconds(), moment.duration({d: 23, h: 23}).asSeconds(), 'python isodate 4');
33567 assert.equal(moment.duration('P4Y').asSeconds(), moment.duration({y: 4}).asSeconds(), 'python isodate 5');
33568 assert.equal(moment.duration('P1M').asSeconds(), moment.duration({M: 1}).asSeconds(), 'python isodate 6');
33569 assert.equal(moment.duration('PT1M').asSeconds(), moment.duration({m: 1}).asSeconds(), 'python isodate 7');
33570 assert.equal(moment.duration('P0.5Y').asSeconds(), moment.duration({y: 0.5}).asSeconds(), 'python isodate 8');
33571 assert.equal(moment.duration('PT36H').asSeconds(), moment.duration({h: 36}).asSeconds(), 'python isodate 9');
33572 assert.equal(moment.duration('P1DT12H').asSeconds(), moment.duration({d: 1, h: 12}).asSeconds(), 'python isodate 10');
33573 assert.equal(moment.duration('-P2W').asSeconds(), moment.duration({w: -2}).asSeconds(), 'python isodate 11');
33574 assert.equal(moment.duration('-P2.2W').asSeconds(), moment.duration({w: -2.2}).asSeconds(), 'python isodate 12');
33575 assert.equal(moment.duration('P1DT2H3M4S').asSeconds(), moment.duration({d: 1, h: 2, m: 3, s: 4}).asSeconds(), 'python isodate 13');
33576 assert.equal(moment.duration('P1DT2H3M').asSeconds(), moment.duration({d: 1, h: 2, m: 3}).asSeconds(), 'python isodate 14');
33577 assert.equal(moment.duration('P1DT2H').asSeconds(), moment.duration({d: 1, h: 2}).asSeconds(), 'python isodate 15');
33578 assert.equal(moment.duration('PT2H').asSeconds(), moment.duration({h: 2}).asSeconds(), 'python isodate 16');
33579 assert.equal(moment.duration('PT2.3H').asSeconds(), moment.duration({h: 2.3}).asSeconds(), 'python isodate 17');
33580 assert.equal(moment.duration('PT2H3M4S').asSeconds(), moment.duration({h: 2, m: 3, s: 4}).asSeconds(), 'python isodate 18');
33581 assert.equal(moment.duration('PT3M4S').asSeconds(), moment.duration({m: 3, s: 4}).asSeconds(), 'python isodate 19');
33582 assert.equal(moment.duration('PT22S').asSeconds(), moment.duration({s: 22}).asSeconds(), 'python isodate 20');
33583 assert.equal(moment.duration('PT22.22S').asSeconds(), moment.duration({s: 22.22}).asSeconds(), 'python isodate 21');
33584 assert.equal(moment.duration('-P2Y').asSeconds(), moment.duration({y: -2}).asSeconds(), 'python isodate 22');
33585 assert.equal(moment.duration('-P3Y6M4DT12H30M5S').asSeconds(), moment.duration({y: -3, M: -6, d: -4, h: -12, m: -30, s: -5}).asSeconds(), 'python isodate 23');
33586 assert.equal(moment.duration('-P1DT2H3M4S').asSeconds(), moment.duration({d: -1, h: -2, m: -3, s: -4}).asSeconds(), 'python isodate 24');
33587 });
33588
33589 test('ISO 8601 misuse cases', function (assert) {
33590 assert.equal(moment.duration('P').asSeconds(), 0, 'lonely P');
33591 assert.equal(moment.duration('PT').asSeconds(), 0, 'just P and T');
33592 assert.equal(moment.duration('P1H').asSeconds(), 0, 'missing T');
33593 assert.equal(moment.duration('P1D1Y').asSeconds(), 0, 'out of order');
33594 assert.equal(moment.duration('PT.5S').asSeconds(), 0.5, 'accept no leading zero for decimal');
33595 assert.equal(moment.duration('PT1,S').asSeconds(), 1, 'accept trailing decimal separator');
33596 assert.equal(moment.duration('PT1M0,,5S').asSeconds(), 60, 'extra decimal separators are ignored as 0');
33597 assert.equal(moment.duration('P-1DS').asSeconds(), 0, 'wrong position of negative');
33598 });
33599
33600 test('humanize', function (assert) {
33601 moment.locale('en');
33602 assert.equal(moment.duration({seconds: 44}).humanize(), 'a few seconds', '44 seconds = a few seconds');
33603 assert.equal(moment.duration({seconds: 45}).humanize(), 'a minute', '45 seconds = a minute');
33604 assert.equal(moment.duration({seconds: 89}).humanize(), 'a minute', '89 seconds = a minute');
33605 assert.equal(moment.duration({seconds: 90}).humanize(), '2 minutes', '90 seconds = 2 minutes');
33606 assert.equal(moment.duration({minutes: 44}).humanize(), '44 minutes', '44 minutes = 44 minutes');
33607 assert.equal(moment.duration({minutes: 45}).humanize(), 'an hour', '45 minutes = an hour');
33608 assert.equal(moment.duration({minutes: 89}).humanize(), 'an hour', '89 minutes = an hour');
33609 assert.equal(moment.duration({minutes: 90}).humanize(), '2 hours', '90 minutes = 2 hours');
33610 assert.equal(moment.duration({hours: 5}).humanize(), '5 hours', '5 hours = 5 hours');
33611 assert.equal(moment.duration({hours: 21}).humanize(), '21 hours', '21 hours = 21 hours');
33612 assert.equal(moment.duration({hours: 22}).humanize(), 'a day', '22 hours = a day');
33613 assert.equal(moment.duration({hours: 35}).humanize(), 'a day', '35 hours = a day');
33614 assert.equal(moment.duration({hours: 36}).humanize(), '2 days', '36 hours = 2 days');
33615 assert.equal(moment.duration({days: 1}).humanize(), 'a day', '1 day = a day');
33616 assert.equal(moment.duration({days: 5}).humanize(), '5 days', '5 days = 5 days');
33617 assert.equal(moment.duration({weeks: 1}).humanize(), '7 days', '1 week = 7 days');
33618 assert.equal(moment.duration({days: 25}).humanize(), '25 days', '25 days = 25 days');
33619 assert.equal(moment.duration({days: 26}).humanize(), 'a month', '26 days = a month');
33620 assert.equal(moment.duration({days: 30}).humanize(), 'a month', '30 days = a month');
33621 assert.equal(moment.duration({days: 45}).humanize(), 'a month', '45 days = a month');
33622 assert.equal(moment.duration({days: 46}).humanize(), '2 months', '46 days = 2 months');
33623 assert.equal(moment.duration({days: 74}).humanize(), '2 months', '74 days = 2 months');
33624 assert.equal(moment.duration({days: 77}).humanize(), '3 months', '77 days = 3 months');
33625 assert.equal(moment.duration({months: 1}).humanize(), 'a month', '1 month = a month');
33626 assert.equal(moment.duration({months: 5}).humanize(), '5 months', '5 months = 5 months');
33627 assert.equal(moment.duration({days: 344}).humanize(), 'a year', '344 days = a year');
33628 assert.equal(moment.duration({days: 345}).humanize(), 'a year', '345 days = a year');
33629 assert.equal(moment.duration({days: 547}).humanize(), 'a year', '547 days = a year');
33630 assert.equal(moment.duration({days: 548}).humanize(), '2 years', '548 days = 2 years');
33631 assert.equal(moment.duration({years: 1}).humanize(), 'a year', '1 year = a year');
33632 assert.equal(moment.duration({years: 5}).humanize(), '5 years', '5 years = 5 years');
33633 assert.equal(moment.duration(7200000).humanize(), '2 hours', '7200000 = 2 minutes');
33634 });
33635
33636 test('humanize duration with suffix', function (assert) {
33637 moment.locale('en');
33638 assert.equal(moment.duration({seconds: 44}).humanize(true), 'in a few seconds', '44 seconds = a few seconds');
33639 assert.equal(moment.duration({seconds: -44}).humanize(true), 'a few seconds ago', '44 seconds = a few seconds');
33640 });
33641
33642 test('bubble value up', function (assert) {
33643 assert.equal(moment.duration({milliseconds: 61001}).milliseconds(), 1, '61001 milliseconds has 1 millisecond left over');
33644 assert.equal(moment.duration({milliseconds: 61001}).seconds(), 1, '61001 milliseconds has 1 second left over');
33645 assert.equal(moment.duration({milliseconds: 61001}).minutes(), 1, '61001 milliseconds has 1 minute left over');
33646
33647 assert.equal(moment.duration({minutes: 350}).minutes(), 50, '350 minutes has 50 minutes left over');
33648 assert.equal(moment.duration({minutes: 350}).hours(), 5, '350 minutes has 5 hours left over');
33649 });
33650
33651 test('clipping', function (assert) {
33652 assert.equal(moment.duration({months: 11}).months(), 11, '11 months is 11 months');
33653 assert.equal(moment.duration({months: 11}).years(), 0, '11 months makes no year');
33654 assert.equal(moment.duration({months: 12}).months(), 0, '12 months is 0 months left over');
33655 assert.equal(moment.duration({months: 12}).years(), 1, '12 months makes 1 year');
33656 assert.equal(moment.duration({months: 13}).months(), 1, '13 months is 1 month left over');
33657 assert.equal(moment.duration({months: 13}).years(), 1, '13 months makes 1 year');
33658
33659 assert.equal(moment.duration({days: 30}).days(), 30, '30 days is 30 days');
33660 assert.equal(moment.duration({days: 30}).months(), 0, '30 days makes no month');
33661 assert.equal(moment.duration({days: 31}).days(), 0, '31 days is 0 days left over');
33662 assert.equal(moment.duration({days: 31}).months(), 1, '31 days is a month');
33663 assert.equal(moment.duration({days: 32}).days(), 1, '32 days is 1 day left over');
33664 assert.equal(moment.duration({days: 32}).months(), 1, '32 days is a month');
33665
33666 assert.equal(moment.duration({hours: 23}).hours(), 23, '23 hours is 23 hours');
33667 assert.equal(moment.duration({hours: 23}).days(), 0, '23 hours makes no day');
33668 assert.equal(moment.duration({hours: 24}).hours(), 0, '24 hours is 0 hours left over');
33669 assert.equal(moment.duration({hours: 24}).days(), 1, '24 hours makes 1 day');
33670 assert.equal(moment.duration({hours: 25}).hours(), 1, '25 hours is 1 hour left over');
33671 assert.equal(moment.duration({hours: 25}).days(), 1, '25 hours makes 1 day');
33672 });
33673
33674 test('bubbling consistency', function (assert) {
33675 var days = 0, months = 0, newDays, newMonths, totalDays, d;
33676 for (totalDays = 1; totalDays <= 500; ++totalDays) {
33677 d = moment.duration(totalDays, 'days');
33678 newDays = d.days();
33679 newMonths = d.months() + d.years() * 12;
33680 assert.ok(
33681 (months === newMonths && days + 1 === newDays) ||
33682 (months + 1 === newMonths && newDays === 0),
33683 'consistent total days ' + totalDays +
33684 ' was ' + months + ' ' + days +
33685 ' now ' + newMonths + ' ' + newDays);
33686 days = newDays;
33687 months = newMonths;
33688 }
33689 });
33690
33691 test('effective equivalency', function (assert) {
33692 assert.deepEqual(moment.duration({seconds: 1})._data, moment.duration({milliseconds: 1000})._data, '1 second is the same as 1000 milliseconds');
33693 assert.deepEqual(moment.duration({seconds: 60})._data, moment.duration({minutes: 1})._data, '1 minute is the same as 60 seconds');
33694 assert.deepEqual(moment.duration({minutes: 60})._data, moment.duration({hours: 1})._data, '1 hour is the same as 60 minutes');
33695 assert.deepEqual(moment.duration({hours: 24})._data, moment.duration({days: 1})._data, '1 day is the same as 24 hours');
33696 assert.deepEqual(moment.duration({days: 7})._data, moment.duration({weeks: 1})._data, '1 week is the same as 7 days');
33697 assert.deepEqual(moment.duration({days: 31})._data, moment.duration({months: 1})._data, '1 month is the same as 30 days');
33698 assert.deepEqual(moment.duration({months: 12})._data, moment.duration({years: 1})._data, '1 years is the same as 12 months');
33699 });
33700
33701 test('asGetters', function (assert) {
33702 // 400 years have exactly 146097 days
33703
33704 // years
33705 assert.equal(moment.duration(1, 'year').asYears(), 1, '1 year as years');
33706 assert.equal(moment.duration(1, 'year').asMonths(), 12, '1 year as months');
33707 assert.equal(moment.duration(400, 'year').asMonths(), 4800, '400 years as months');
33708 assert.equal(moment.duration(1, 'year').asWeeks().toFixed(3), 52.143, '1 year as weeks');
33709 assert.equal(moment.duration(1, 'year').asDays(), 365, '1 year as days');
33710 assert.equal(moment.duration(2, 'year').asDays(), 730, '2 years as days');
33711 assert.equal(moment.duration(3, 'year').asDays(), 1096, '3 years as days');
33712 assert.equal(moment.duration(4, 'year').asDays(), 1461, '4 years as days');
33713 assert.equal(moment.duration(400, 'year').asDays(), 146097, '400 years as days');
33714 assert.equal(moment.duration(1, 'year').asHours(), 8760, '1 year as hours');
33715 assert.equal(moment.duration(1, 'year').asMinutes(), 525600, '1 year as minutes');
33716 assert.equal(moment.duration(1, 'year').asSeconds(), 31536000, '1 year as seconds');
33717 assert.equal(moment.duration(1, 'year').asMilliseconds(), 31536000000, '1 year as milliseconds');
33718
33719 // months
33720 assert.equal(moment.duration(1, 'month').asYears().toFixed(4), 0.0833, '1 month as years');
33721 assert.equal(moment.duration(1, 'month').asMonths(), 1, '1 month as months');
33722 assert.equal(moment.duration(1, 'month').asWeeks().toFixed(3), 4.286, '1 month as weeks');
33723 assert.equal(moment.duration(1, 'month').asDays(), 30, '1 month as days');
33724 assert.equal(moment.duration(2, 'month').asDays(), 61, '2 months as days');
33725 assert.equal(moment.duration(3, 'month').asDays(), 91, '3 months as days');
33726 assert.equal(moment.duration(4, 'month').asDays(), 122, '4 months as days');
33727 assert.equal(moment.duration(5, 'month').asDays(), 152, '5 months as days');
33728 assert.equal(moment.duration(6, 'month').asDays(), 183, '6 months as days');
33729 assert.equal(moment.duration(7, 'month').asDays(), 213, '7 months as days');
33730 assert.equal(moment.duration(8, 'month').asDays(), 243, '8 months as days');
33731 assert.equal(moment.duration(9, 'month').asDays(), 274, '9 months as days');
33732 assert.equal(moment.duration(10, 'month').asDays(), 304, '10 months as days');
33733 assert.equal(moment.duration(11, 'month').asDays(), 335, '11 months as days');
33734 assert.equal(moment.duration(12, 'month').asDays(), 365, '12 months as days');
33735 assert.equal(moment.duration(24, 'month').asDays(), 730, '24 months as days');
33736 assert.equal(moment.duration(36, 'month').asDays(), 1096, '36 months as days');
33737 assert.equal(moment.duration(48, 'month').asDays(), 1461, '48 months as days');
33738 assert.equal(moment.duration(4800, 'month').asDays(), 146097, '4800 months as days');
33739 assert.equal(moment.duration(1, 'month').asHours(), 720, '1 month as hours');
33740 assert.equal(moment.duration(1, 'month').asMinutes(), 43200, '1 month as minutes');
33741 assert.equal(moment.duration(1, 'month').asSeconds(), 2592000, '1 month as seconds');
33742 assert.equal(moment.duration(1, 'month').asMilliseconds(), 2592000000, '1 month as milliseconds');
33743
33744 // weeks
33745 assert.equal(moment.duration(1, 'week').asYears().toFixed(4), 0.0192, '1 week as years');
33746 assert.equal(moment.duration(1, 'week').asMonths().toFixed(3), 0.230, '1 week as months');
33747 assert.equal(moment.duration(1, 'week').asWeeks(), 1, '1 week as weeks');
33748 assert.equal(moment.duration(1, 'week').asDays(), 7, '1 week as days');
33749 assert.equal(moment.duration(1, 'week').asHours(), 168, '1 week as hours');
33750 assert.equal(moment.duration(1, 'week').asMinutes(), 10080, '1 week as minutes');
33751 assert.equal(moment.duration(1, 'week').asSeconds(), 604800, '1 week as seconds');
33752 assert.equal(moment.duration(1, 'week').asMilliseconds(), 604800000, '1 week as milliseconds');
33753
33754 // days
33755 assert.equal(moment.duration(1, 'day').asYears().toFixed(4), 0.0027, '1 day as years');
33756 assert.equal(moment.duration(1, 'day').asMonths().toFixed(3), 0.033, '1 day as months');
33757 assert.equal(moment.duration(1, 'day').asWeeks().toFixed(3), 0.143, '1 day as weeks');
33758 assert.equal(moment.duration(1, 'day').asDays(), 1, '1 day as days');
33759 assert.equal(moment.duration(1, 'day').asHours(), 24, '1 day as hours');
33760 assert.equal(moment.duration(1, 'day').asMinutes(), 1440, '1 day as minutes');
33761 assert.equal(moment.duration(1, 'day').asSeconds(), 86400, '1 day as seconds');
33762 assert.equal(moment.duration(1, 'day').asMilliseconds(), 86400000, '1 day as milliseconds');
33763
33764 // hours
33765 assert.equal(moment.duration(1, 'hour').asYears().toFixed(6), 0.000114, '1 hour as years');
33766 assert.equal(moment.duration(1, 'hour').asMonths().toFixed(5), 0.00137, '1 hour as months');
33767 assert.equal(moment.duration(1, 'hour').asWeeks().toFixed(5), 0.00595, '1 hour as weeks');
33768 assert.equal(moment.duration(1, 'hour').asDays().toFixed(4), 0.0417, '1 hour as days');
33769 assert.equal(moment.duration(1, 'hour').asHours(), 1, '1 hour as hours');
33770 assert.equal(moment.duration(1, 'hour').asMinutes(), 60, '1 hour as minutes');
33771 assert.equal(moment.duration(1, 'hour').asSeconds(), 3600, '1 hour as seconds');
33772 assert.equal(moment.duration(1, 'hour').asMilliseconds(), 3600000, '1 hour as milliseconds');
33773
33774 // minutes
33775 assert.equal(moment.duration(1, 'minute').asYears().toFixed(8), 0.00000190, '1 minute as years');
33776 assert.equal(moment.duration(1, 'minute').asMonths().toFixed(7), 0.0000228, '1 minute as months');
33777 assert.equal(moment.duration(1, 'minute').asWeeks().toFixed(7), 0.0000992, '1 minute as weeks');
33778 assert.equal(moment.duration(1, 'minute').asDays().toFixed(6), 0.000694, '1 minute as days');
33779 assert.equal(moment.duration(1, 'minute').asHours().toFixed(4), 0.0167, '1 minute as hours');
33780 assert.equal(moment.duration(1, 'minute').asMinutes(), 1, '1 minute as minutes');
33781 assert.equal(moment.duration(1, 'minute').asSeconds(), 60, '1 minute as seconds');
33782 assert.equal(moment.duration(1, 'minute').asMilliseconds(), 60000, '1 minute as milliseconds');
33783
33784 // seconds
33785 assert.equal(moment.duration(1, 'second').asYears().toFixed(10), 0.0000000317, '1 second as years');
33786 assert.equal(moment.duration(1, 'second').asMonths().toFixed(9), 0.000000380, '1 second as months');
33787 assert.equal(moment.duration(1, 'second').asWeeks().toFixed(8), 0.00000165, '1 second as weeks');
33788 assert.equal(moment.duration(1, 'second').asDays().toFixed(7), 0.0000116, '1 second as days');
33789 assert.equal(moment.duration(1, 'second').asHours().toFixed(6), 0.000278, '1 second as hours');
33790 assert.equal(moment.duration(1, 'second').asMinutes().toFixed(4), 0.0167, '1 second as minutes');
33791 assert.equal(moment.duration(1, 'second').asSeconds(), 1, '1 second as seconds');
33792 assert.equal(moment.duration(1, 'second').asMilliseconds(), 1000, '1 second as milliseconds');
33793
33794 // milliseconds
33795 assert.equal(moment.duration(1, 'millisecond').asYears().toFixed(13), 0.0000000000317, '1 millisecond as years');
33796 assert.equal(moment.duration(1, 'millisecond').asMonths().toFixed(12), 0.000000000380, '1 millisecond as months');
33797 assert.equal(moment.duration(1, 'millisecond').asWeeks().toFixed(11), 0.00000000165, '1 millisecond as weeks');
33798 assert.equal(moment.duration(1, 'millisecond').asDays().toFixed(10), 0.0000000116, '1 millisecond as days');
33799 assert.equal(moment.duration(1, 'millisecond').asHours().toFixed(9), 0.000000278, '1 millisecond as hours');
33800 assert.equal(moment.duration(1, 'millisecond').asMinutes().toFixed(7), 0.0000167, '1 millisecond as minutes');
33801 assert.equal(moment.duration(1, 'millisecond').asSeconds(), 0.001, '1 millisecond as seconds');
33802 assert.equal(moment.duration(1, 'millisecond').asMilliseconds(), 1, '1 millisecond as milliseconds');
33803 });
33804
33805 test('as getters for small units', function (assert) {
33806 var dS = moment.duration(1, 'milliseconds'),
33807 ds = moment.duration(3, 'seconds'),
33808 dm = moment.duration(13, 'minutes');
33809
33810 // Tests for issue #1867.
33811 // Floating point errors for small duration units were introduced in version 2.8.0.
33812 assert.equal(dS.as('milliseconds'), 1, 'as("milliseconds")');
33813 assert.equal(dS.asMilliseconds(), 1, 'asMilliseconds()');
33814 assert.equal(ds.as('seconds'), 3, 'as("seconds")');
33815 assert.equal(ds.asSeconds(), 3, 'asSeconds()');
33816 assert.equal(dm.as('minutes'), 13, 'as("minutes")');
33817 assert.equal(dm.asMinutes(), 13, 'asMinutes()');
33818 });
33819
33820 test('isDuration', function (assert) {
33821 assert.ok(moment.isDuration(moment.duration(12345678)), 'correctly says true');
33822 assert.ok(!moment.isDuration(moment()), 'moment object is not a duration');
33823 assert.ok(!moment.isDuration({milliseconds: 1}), 'plain object is not a duration');
33824 });
33825
33826 test('add', function (assert) {
33827 var d = moment.duration({months: 4, weeks: 3, days: 2});
33828 // for some reason, d._data._months does not get updated; use d._months instead.
33829 assert.equal(d.add(1, 'month')._months, 5, 'Add months');
33830 assert.equal(d.add(5, 'days')._days, 28, 'Add days');
33831 assert.equal(d.add(10000)._milliseconds, 10000, 'Add milliseconds');
33832 assert.equal(d.add({h: 23, m: 59})._milliseconds, 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 10000, 'Add hour:minute');
33833 });
33834
33835 test('add and bubble', function (assert) {
33836 var d;
33837
33838 assert.equal(moment.duration(1, 'second').add(1000, 'milliseconds').seconds(), 2, 'Adding milliseconds should bubble up to seconds');
33839 assert.equal(moment.duration(1, 'minute').add(60, 'second').minutes(), 2, 'Adding seconds should bubble up to minutes');
33840 assert.equal(moment.duration(1, 'hour').add(60, 'minutes').hours(), 2, 'Adding minutes should bubble up to hours');
33841 assert.equal(moment.duration(1, 'day').add(24, 'hours').days(), 2, 'Adding hours should bubble up to days');
33842
33843 d = moment.duration(-1, 'day').add(1, 'hour');
33844 assert.equal(d.hours(), -23, '-1 day + 1 hour == -23 hour (component)');
33845 assert.equal(d.asHours(), -23, '-1 day + 1 hour == -23 hours');
33846
33847 d = moment.duration(-1, 'year').add(1, 'day');
33848 assert.equal(d.days(), -30, '- 1 year + 1 day == -30 days (component)');
33849 assert.equal(d.months(), -11, '- 1 year + 1 day == -11 months (component)');
33850 assert.equal(d.years(), 0, '- 1 year + 1 day == 0 years (component)');
33851 assert.equal(d.asDays(), -364, '- 1 year + 1 day == -364 days');
33852
33853 d = moment.duration(-1, 'year').add(1, 'hour');
33854 assert.equal(d.hours(), -23, '- 1 year + 1 hour == -23 hours (component)');
33855 assert.equal(d.days(), -30, '- 1 year + 1 hour == -30 days (component)');
33856 assert.equal(d.months(), -11, '- 1 year + 1 hour == -11 months (component)');
33857 assert.equal(d.years(), 0, '- 1 year + 1 hour == 0 years (component)');
33858 });
33859
33860 test('subtract and bubble', function (assert) {
33861 var d;
33862
33863 assert.equal(moment.duration(2, 'second').subtract(1000, 'milliseconds').seconds(), 1, 'Subtracting milliseconds should bubble up to seconds');
33864 assert.equal(moment.duration(2, 'minute').subtract(60, 'second').minutes(), 1, 'Subtracting seconds should bubble up to minutes');
33865 assert.equal(moment.duration(2, 'hour').subtract(60, 'minutes').hours(), 1, 'Subtracting minutes should bubble up to hours');
33866 assert.equal(moment.duration(2, 'day').subtract(24, 'hours').days(), 1, 'Subtracting hours should bubble up to days');
33867
33868 d = moment.duration(1, 'day').subtract(1, 'hour');
33869 assert.equal(d.hours(), 23, '1 day - 1 hour == 23 hour (component)');
33870 assert.equal(d.asHours(), 23, '1 day - 1 hour == 23 hours');
33871
33872 d = moment.duration(1, 'year').subtract(1, 'day');
33873 assert.equal(d.days(), 30, '1 year - 1 day == 30 days (component)');
33874 assert.equal(d.months(), 11, '1 year - 1 day == 11 months (component)');
33875 assert.equal(d.years(), 0, '1 year - 1 day == 0 years (component)');
33876 assert.equal(d.asDays(), 364, '1 year - 1 day == 364 days');
33877
33878 d = moment.duration(1, 'year').subtract(1, 'hour');
33879 assert.equal(d.hours(), 23, '1 year - 1 hour == 23 hours (component)');
33880 assert.equal(d.days(), 30, '1 year - 1 hour == 30 days (component)');
33881 assert.equal(d.months(), 11, '1 year - 1 hour == 11 months (component)');
33882 assert.equal(d.years(), 0, '1 year - 1 hour == 0 years (component)');
33883 });
33884
33885 test('subtract', function (assert) {
33886 var d = moment.duration({months: 2, weeks: 2, days: 0, hours: 5});
33887 // for some reason, d._data._months does not get updated; use d._months instead.
33888 assert.equal(d.subtract(1, 'months')._months, 1, 'Subtract months');
33889 assert.equal(d.subtract(14, 'days')._days, 0, 'Subtract days');
33890 assert.equal(d.subtract(10000)._milliseconds, 5 * 60 * 60 * 1000 - 10000, 'Subtract milliseconds');
33891 assert.equal(d.subtract({h: 1, m: 59})._milliseconds, 3 * 60 * 60 * 1000 + 1 * 60 * 1000 - 10000, 'Subtract hour:minute');
33892 });
33893
33894 test('JSON.stringify duration', function (assert) {
33895 var d = moment.duration(1024, 'h');
33896
33897 assert.equal(JSON.stringify(d), '"' + d.toISOString() + '"', 'JSON.stringify on duration should return ISO string');
33898 });
33899
33900 test('duration plugins', function (assert) {
33901 var durationObject = moment.duration();
33902 moment.duration.fn.foo = function (arg) {
33903 assert.equal(this, durationObject);
33904 assert.equal(arg, 5);
33905 };
33906 durationObject.foo(5);
33907 });
33908
33909 }));
33910
33911 (function (global, factory) {
33912 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
33913 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
33914 factory(global.moment)
33915 }(this, function (moment) { 'use strict';
33916
33917 /*global QUnit:false*/
33918
33919 var test = QUnit.test;
33920
33921 function module (name, lifecycle) {
33922 QUnit.module(name, {
33923 setup : function () {
33924 moment.locale('en');
33925 moment.createFromInputFallback = function () {
33926 throw new Error('input not handled by moment');
33927 };
33928 if (lifecycle && lifecycle.setup) {
33929 lifecycle.setup();
33930 }
33931 },
33932 teardown : function () {
33933 if (lifecycle && lifecycle.teardown) {
33934 lifecycle.teardown();
33935 }
33936 }
33937 });
33938 }
33939
33940 function localeModule (name, lifecycle) {
33941 QUnit.module('locale:' + name, {
33942 setup : function () {
33943 moment.locale(name);
33944 moment.createFromInputFallback = function () {
33945 throw new Error('input not handled by moment');
33946 };
33947 if (lifecycle && lifecycle.setup) {
33948 lifecycle.setup();
33949 }
33950 },
33951 teardown : function () {
33952 moment.locale('en');
33953 if (lifecycle && lifecycle.teardown) {
33954 lifecycle.teardown();
33955 }
33956 }
33957 });
33958 }
33959
33960 module('duration from moments');
33961
33962 test('pure year diff', function (assert) {
33963 var m1 = moment('2012-01-01T00:00:00.000Z'),
33964 m2 = moment('2013-01-01T00:00:00.000Z');
33965
33966 assert.equal(moment.duration({from: m1, to: m2}).as('years'), 1, 'year moment difference');
33967 assert.equal(moment.duration({from: m2, to: m1}).as('years'), -1, 'negative year moment difference');
33968 });
33969
33970 test('month and day diff', function (assert) {
33971 var m1 = moment('2012-01-15T00:00:00.000Z'),
33972 m2 = moment('2012-02-17T00:00:00.000Z'),
33973 d = moment.duration({from: m1, to: m2});
33974
33975 assert.equal(d.get('days'), 2);
33976 assert.equal(d.get('months'), 1);
33977 });
33978
33979 test('day diff, separate months', function (assert) {
33980 var m1 = moment('2012-01-15T00:00:00.000Z'),
33981 m2 = moment('2012-02-13T00:00:00.000Z'),
33982 d = moment.duration({from: m1, to: m2});
33983
33984 assert.equal(d.as('days'), 29);
33985 });
33986
33987 test('hour diff', function (assert) {
33988 var m1 = moment('2012-01-15T17:00:00.000Z'),
33989 m2 = moment('2012-01-16T03:00:00.000Z'),
33990 d = moment.duration({from: m1, to: m2});
33991
33992 assert.equal(d.as('hours'), 10);
33993 });
33994
33995 test('minute diff', function (assert) {
33996 var m1 = moment('2012-01-15T17:45:00.000Z'),
33997 m2 = moment('2012-01-16T03:15:00.000Z'),
33998 d = moment.duration({from: m1, to: m2});
33999
34000 assert.equal(d.as('hours'), 9.5);
34001 });
34002
34003 }));
34004
34005 (function (global, factory) {
34006 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
34007 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
34008 factory(global.moment)
34009 }(this, function (moment) { 'use strict';
34010
34011 /*global QUnit:false*/
34012
34013 var test = QUnit.test;
34014
34015 function module (name, lifecycle) {
34016 QUnit.module(name, {
34017 setup : function () {
34018 moment.locale('en');
34019 moment.createFromInputFallback = function () {
34020 throw new Error('input not handled by moment');
34021 };
34022 if (lifecycle && lifecycle.setup) {
34023 lifecycle.setup();
34024 }
34025 },
34026 teardown : function () {
34027 if (lifecycle && lifecycle.teardown) {
34028 lifecycle.teardown();
34029 }
34030 }
34031 });
34032 }
34033
34034 function localeModule (name, lifecycle) {
34035 QUnit.module('locale:' + name, {
34036 setup : function () {
34037 moment.locale(name);
34038 moment.createFromInputFallback = function () {
34039 throw new Error('input not handled by moment');
34040 };
34041 if (lifecycle && lifecycle.setup) {
34042 lifecycle.setup();
34043 }
34044 },
34045 teardown : function () {
34046 moment.locale('en');
34047 if (lifecycle && lifecycle.teardown) {
34048 lifecycle.teardown();
34049 }
34050 }
34051 });
34052 }
34053
34054 module('format');
34055
34056 test('format YY', function (assert) {
34057 var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
34058 assert.equal(b.format('YY'), '09', 'YY ---> 09');
34059 });
34060
34061 test('format escape brackets', function (assert) {
34062 moment.locale('en');
34063
34064 var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
34065 assert.equal(b.format('[day]'), 'day', 'Single bracket');
34066 assert.equal(b.format('[day] YY [YY]'), 'day 09 YY', 'Double bracket');
34067 assert.equal(b.format('[YY'), '[09', 'Un-ended bracket');
34068 assert.equal(b.format('[[YY]]'), '[YY]', 'Double nested brackets');
34069 assert.equal(b.format('[[]'), '[', 'Escape open bracket');
34070 assert.equal(b.format('[Last]'), 'Last', 'localized tokens');
34071 assert.equal(b.format('[L] L'), 'L 02/14/2009', 'localized tokens with escaped localized tokens');
34072 assert.equal(b.format('[L LL LLL LLLL aLa]'), 'L LL LLL LLLL aLa', 'localized tokens with escaped localized tokens');
34073 assert.equal(b.format('[LLL] LLL'), 'LLL February 14, 2009 3:25 PM', 'localized tokens with escaped localized tokens (recursion)');
34074 assert.equal(b.format('YYYY[\n]DD[\n]'), '2009\n14\n', 'Newlines');
34075 });
34076
34077 test('handle negative years', function (assert) {
34078 moment.locale('en');
34079 assert.equal(moment.utc().year(-1).format('YY'), '-01', 'YY with negative year');
34080 assert.equal(moment.utc().year(-1).format('YYYY'), '-0001', 'YYYY with negative year');
34081 assert.equal(moment.utc().year(-12).format('YY'), '-12', 'YY with negative year');
34082 assert.equal(moment.utc().year(-12).format('YYYY'), '-0012', 'YYYY with negative year');
34083 assert.equal(moment.utc().year(-123).format('YY'), '-23', 'YY with negative year');
34084 assert.equal(moment.utc().year(-123).format('YYYY'), '-0123', 'YYYY with negative year');
34085 assert.equal(moment.utc().year(-1234).format('YY'), '-34', 'YY with negative year');
34086 assert.equal(moment.utc().year(-1234).format('YYYY'), '-1234', 'YYYY with negative year');
34087 assert.equal(moment.utc().year(-12345).format('YY'), '-45', 'YY with negative year');
34088 assert.equal(moment.utc().year(-12345).format('YYYY'), '-12345', 'YYYY with negative year');
34089 });
34090
34091 test('format milliseconds', function (assert) {
34092 var b = moment(new Date(2009, 1, 14, 15, 25, 50, 123));
34093 assert.equal(b.format('S'), '1', 'Deciseconds');
34094 assert.equal(b.format('SS'), '12', 'Centiseconds');
34095 assert.equal(b.format('SSS'), '123', 'Milliseconds');
34096 b.milliseconds(789);
34097 assert.equal(b.format('S'), '7', 'Deciseconds');
34098 assert.equal(b.format('SS'), '78', 'Centiseconds');
34099 assert.equal(b.format('SSS'), '789', 'Milliseconds');
34100 });
34101
34102 test('format timezone', function (assert) {
34103 var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
34104 assert.ok(b.format('Z').match(/^[\+\-]\d\d:\d\d$/), b.format('Z') + ' should be something like \'+07:30\'');
34105 assert.ok(b.format('ZZ').match(/^[\+\-]\d{4}$/), b.format('ZZ') + ' should be something like \'+0700\'');
34106 });
34107
34108 test('format multiple with utc offset', function (assert) {
34109 var b = moment('2012-10-08 -1200', ['YYYY-MM-DD HH:mm ZZ', 'YYYY-MM-DD ZZ', 'YYYY-MM-DD']);
34110 assert.equal(b.format('YYYY-MM'), '2012-10', 'Parsing multiple formats should not crash with different sized formats');
34111 });
34112
34113 test('isDST', function (assert) {
34114 var janOffset = new Date(2011, 0, 1).getTimezoneOffset(),
34115 julOffset = new Date(2011, 6, 1).getTimezoneOffset(),
34116 janIsDst = janOffset < julOffset,
34117 julIsDst = julOffset < janOffset,
34118 jan1 = moment([2011]),
34119 jul1 = moment([2011, 6]);
34120
34121 if (janIsDst && julIsDst) {
34122 assert.ok(0, 'January and July cannot both be in DST');
34123 assert.ok(0, 'January and July cannot both be in DST');
34124 } else if (janIsDst) {
34125 assert.ok(jan1.isDST(), 'January 1 is DST');
34126 assert.ok(!jul1.isDST(), 'July 1 is not DST');
34127 } else if (julIsDst) {
34128 assert.ok(!jan1.isDST(), 'January 1 is not DST');
34129 assert.ok(jul1.isDST(), 'July 1 is DST');
34130 } else {
34131 assert.ok(!jan1.isDST(), 'January 1 is not DST');
34132 assert.ok(!jul1.isDST(), 'July 1 is not DST');
34133 }
34134 });
34135
34136 test('unix timestamp', function (assert) {
34137 var m = moment('1234567890.123', 'X');
34138 assert.equal(m.format('X'), '1234567890', 'unix timestamp without milliseconds');
34139 assert.equal(m.format('X.S'), '1234567890.1', 'unix timestamp with deciseconds');
34140 assert.equal(m.format('X.SS'), '1234567890.12', 'unix timestamp with centiseconds');
34141 assert.equal(m.format('X.SSS'), '1234567890.123', 'unix timestamp with milliseconds');
34142
34143 m = moment(1234567890.123, 'X');
34144 assert.equal(m.format('X'), '1234567890', 'unix timestamp as integer');
34145 });
34146
34147 test('unix offset milliseconds', function (assert) {
34148 var m = moment('1234567890123', 'x');
34149 assert.equal(m.format('x'), '1234567890123', 'unix offset in milliseconds');
34150
34151 m = moment(1234567890123, 'x');
34152 assert.equal(m.format('x'), '1234567890123', 'unix offset in milliseconds as integer');
34153 });
34154
34155 test('utcOffset sanity checks', function (assert) {
34156 assert.equal(moment().utcOffset() % 15, 0,
34157 'utc offset should be a multiple of 15 (was ' + moment().utcOffset() + ')');
34158
34159 assert.equal(moment().utcOffset(), -(new Date()).getTimezoneOffset(),
34160 'utcOffset should return the opposite of getTimezoneOffset');
34161 });
34162
34163 test('default format', function (assert) {
34164 var isoRegex = /\d{4}.\d\d.\d\dT\d\d.\d\d.\d\d[\+\-]\d\d:\d\d/;
34165 assert.ok(isoRegex.exec(moment().format()), 'default format (' + moment().format() + ') should match ISO');
34166 });
34167
34168 test('toJSON', function (assert) {
34169 var supportsJson = typeof JSON !== 'undefined' && JSON.stringify && JSON.stringify.call,
34170 date = moment('2012-10-09T21:30:40.678+0100');
34171
34172 assert.equal(date.toJSON(), '2012-10-09T20:30:40.678Z', 'should output ISO8601 on moment.fn.toJSON');
34173
34174 if (supportsJson) {
34175 assert.equal(JSON.stringify({
34176 date : date
34177 }), '{"date":"2012-10-09T20:30:40.678Z"}', 'should output ISO8601 on JSON.stringify');
34178 }
34179 });
34180
34181 test('toISOString', function (assert) {
34182 var date = moment.utc('2012-10-09T20:30:40.678');
34183
34184 assert.equal(date.toISOString(), '2012-10-09T20:30:40.678Z', 'should output ISO8601 on moment.fn.toISOString');
34185
34186 // big years
34187 date = moment.utc('+020123-10-09T20:30:40.678');
34188 assert.equal(date.toISOString(), '+020123-10-09T20:30:40.678Z', 'ISO8601 format on big positive year');
34189 // negative years
34190 date = moment.utc('-000001-10-09T20:30:40.678');
34191 assert.equal(date.toISOString(), '-000001-10-09T20:30:40.678Z', 'ISO8601 format on negative year');
34192 // big negative years
34193 date = moment.utc('-020123-10-09T20:30:40.678');
34194 assert.equal(date.toISOString(), '-020123-10-09T20:30:40.678Z', 'ISO8601 format on big negative year');
34195 });
34196
34197 test('long years', function (assert) {
34198 assert.equal(moment.utc().year(2).format('YYYYYY'), '+000002', 'small year with YYYYYY');
34199 assert.equal(moment.utc().year(2012).format('YYYYYY'), '+002012', 'regular year with YYYYYY');
34200 assert.equal(moment.utc().year(20123).format('YYYYYY'), '+020123', 'big year with YYYYYY');
34201
34202 assert.equal(moment.utc().year(-1).format('YYYYYY'), '-000001', 'small negative year with YYYYYY');
34203 assert.equal(moment.utc().year(-2012).format('YYYYYY'), '-002012', 'negative year with YYYYYY');
34204 assert.equal(moment.utc().year(-20123).format('YYYYYY'), '-020123', 'big negative year with YYYYYY');
34205 });
34206
34207 test('iso week formats', function (assert) {
34208 // http://en.wikipedia.org/wiki/ISO_week_date
34209 var cases = {
34210 '2005-01-02': '2004-53',
34211 '2005-12-31': '2005-52',
34212 '2007-01-01': '2007-01',
34213 '2007-12-30': '2007-52',
34214 '2007-12-31': '2008-01',
34215 '2008-01-01': '2008-01',
34216 '2008-12-28': '2008-52',
34217 '2008-12-29': '2009-01',
34218 '2008-12-30': '2009-01',
34219 '2008-12-31': '2009-01',
34220 '2009-01-01': '2009-01',
34221 '2009-12-31': '2009-53',
34222 '2010-01-01': '2009-53',
34223 '2010-01-02': '2009-53',
34224 '2010-01-03': '2009-53',
34225 '404-12-31': '0404-53',
34226 '405-12-31': '0405-52'
34227 }, i, isoWeek, formatted2, formatted1;
34228
34229 for (i in cases) {
34230 isoWeek = cases[i].split('-').pop();
34231 formatted2 = moment(i, 'YYYY-MM-DD').format('WW');
34232 assert.equal(isoWeek, formatted2, i + ': WW should be ' + isoWeek + ', but ' + formatted2);
34233 isoWeek = isoWeek.replace(/^0+/, '');
34234 formatted1 = moment(i, 'YYYY-MM-DD').format('W');
34235 assert.equal(isoWeek, formatted1, i + ': W should be ' + isoWeek + ', but ' + formatted1);
34236 }
34237 });
34238
34239 test('iso week year formats', function (assert) {
34240 // http://en.wikipedia.org/wiki/ISO_week_date
34241 var cases = {
34242 '2005-01-02': '2004-53',
34243 '2005-12-31': '2005-52',
34244 '2007-01-01': '2007-01',
34245 '2007-12-30': '2007-52',
34246 '2007-12-31': '2008-01',
34247 '2008-01-01': '2008-01',
34248 '2008-12-28': '2008-52',
34249 '2008-12-29': '2009-01',
34250 '2008-12-30': '2009-01',
34251 '2008-12-31': '2009-01',
34252 '2009-01-01': '2009-01',
34253 '2009-12-31': '2009-53',
34254 '2010-01-01': '2009-53',
34255 '2010-01-02': '2009-53',
34256 '2010-01-03': '2009-53',
34257 '404-12-31': '0404-53',
34258 '405-12-31': '0405-52'
34259 }, i, isoWeekYear, formatted5, formatted4, formatted2;
34260
34261 for (i in cases) {
34262 isoWeekYear = cases[i].split('-')[0];
34263 formatted5 = moment(i, 'YYYY-MM-DD').format('GGGGG');
34264 assert.equal('0' + isoWeekYear, formatted5, i + ': GGGGG should be ' + isoWeekYear + ', but ' + formatted5);
34265 formatted4 = moment(i, 'YYYY-MM-DD').format('GGGG');
34266 assert.equal(isoWeekYear, formatted4, i + ': GGGG should be ' + isoWeekYear + ', but ' + formatted4);
34267 formatted2 = moment(i, 'YYYY-MM-DD').format('GG');
34268 assert.equal(isoWeekYear.slice(2, 4), formatted2, i + ': GG should be ' + isoWeekYear + ', but ' + formatted2);
34269 }
34270 });
34271
34272 test('week year formats', function (assert) {
34273 // http://en.wikipedia.org/wiki/ISO_week_date
34274 var cases = {
34275 '2005-01-02': '2004-53',
34276 '2005-12-31': '2005-52',
34277 '2007-01-01': '2007-01',
34278 '2007-12-30': '2007-52',
34279 '2007-12-31': '2008-01',
34280 '2008-01-01': '2008-01',
34281 '2008-12-28': '2008-52',
34282 '2008-12-29': '2009-01',
34283 '2008-12-30': '2009-01',
34284 '2008-12-31': '2009-01',
34285 '2009-01-01': '2009-01',
34286 '2009-12-31': '2009-53',
34287 '2010-01-01': '2009-53',
34288 '2010-01-02': '2009-53',
34289 '2010-01-03': '2009-53',
34290 '404-12-31': '0404-53',
34291 '405-12-31': '0405-52'
34292 }, i, isoWeekYear, formatted5, formatted4, formatted2;
34293
34294 moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
34295
34296 for (i in cases) {
34297 isoWeekYear = cases[i].split('-')[0];
34298 formatted5 = moment(i, 'YYYY-MM-DD').format('ggggg');
34299 assert.equal('0' + isoWeekYear, formatted5, i + ': ggggg should be ' + isoWeekYear + ', but ' + formatted5);
34300 formatted4 = moment(i, 'YYYY-MM-DD').format('gggg');
34301 assert.equal(isoWeekYear, formatted4, i + ': gggg should be ' + isoWeekYear + ', but ' + formatted4);
34302 formatted2 = moment(i, 'YYYY-MM-DD').format('gg');
34303 assert.equal(isoWeekYear.slice(2, 4), formatted2, i + ': gg should be ' + isoWeekYear + ', but ' + formatted2);
34304 }
34305 });
34306
34307 test('iso weekday formats', function (assert) {
34308 assert.equal(moment([1985, 1, 4]).format('E'), '1', 'Feb 4 1985 is Monday -- 1st day');
34309 assert.equal(moment([2029, 8, 18]).format('E'), '2', 'Sep 18 2029 is Tuesday -- 2nd day');
34310 assert.equal(moment([2013, 3, 24]).format('E'), '3', 'Apr 24 2013 is Wednesday -- 3rd day');
34311 assert.equal(moment([2015, 2, 5]).format('E'), '4', 'Mar 5 2015 is Thursday -- 4th day');
34312 assert.equal(moment([1970, 0, 2]).format('E'), '5', 'Jan 2 1970 is Friday -- 5th day');
34313 assert.equal(moment([2001, 4, 12]).format('E'), '6', 'May 12 2001 is Saturday -- 6th day');
34314 assert.equal(moment([2000, 0, 2]).format('E'), '7', 'Jan 2 2000 is Sunday -- 7th day');
34315 });
34316
34317 test('weekday formats', function (assert) {
34318 moment.locale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
34319 assert.equal(moment([1985, 1, 6]).format('e'), '0', 'Feb 6 1985 is Wednesday -- 0th day');
34320 assert.equal(moment([2029, 8, 20]).format('e'), '1', 'Sep 20 2029 is Thursday -- 1st day');
34321 assert.equal(moment([2013, 3, 26]).format('e'), '2', 'Apr 26 2013 is Friday -- 2nd day');
34322 assert.equal(moment([2015, 2, 7]).format('e'), '3', 'Mar 7 2015 is Saturday -- 3nd day');
34323 assert.equal(moment([1970, 0, 4]).format('e'), '4', 'Jan 4 1970 is Sunday -- 4th day');
34324 assert.equal(moment([2001, 4, 14]).format('e'), '5', 'May 14 2001 is Monday -- 5th day');
34325 assert.equal(moment([2000, 0, 4]).format('e'), '6', 'Jan 4 2000 is Tuesday -- 6th day');
34326 });
34327
34328 test('toString is just human readable format', function (assert) {
34329 var b = moment(new Date(2009, 1, 5, 15, 25, 50, 125));
34330 assert.equal(b.toString(), b.format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'));
34331 });
34332
34333 test('toJSON skips postformat', function (assert) {
34334 moment.locale('postformat', {
34335 postformat: function (s) {
34336 s.replace(/./g, 'X');
34337 }
34338 });
34339 assert.equal(moment.utc([2000, 0, 1]).toJSON(), '2000-01-01T00:00:00.000Z', 'toJSON doesn\'t postformat');
34340 moment.locale('postformat', null);
34341 });
34342
34343 test('calendar day timezone', function (assert) {
34344 moment.locale('en');
34345 var zones = [60, -60, 90, -90, 360, -360, 720, -720],
34346 b = moment().utc().startOf('day').subtract({m : 1}),
34347 c = moment().local().startOf('day').subtract({m : 1}),
34348 d = moment().local().startOf('day').subtract({d : 2}),
34349 i, z, a;
34350
34351 for (i = 0; i < zones.length; ++i) {
34352 z = zones[i];
34353 a = moment().utcOffset(z).startOf('day').subtract({m: 1});
34354 assert.equal(moment(a).utcOffset(z).calendar(), 'Yesterday at 11:59 PM',
34355 'Yesterday at 11:59 PM, not Today, or the wrong time, tz = ' + z);
34356 }
34357
34358 assert.equal(moment(b).utc().calendar(), 'Yesterday at 11:59 PM', 'Yesterday at 11:59 PM, not Today, or the wrong time');
34359 assert.equal(moment(c).local().calendar(), 'Yesterday at 11:59 PM', 'Yesterday at 11:59 PM, not Today, or the wrong time');
34360 assert.equal(moment(c).local().calendar(d), 'Tomorrow at 11:59 PM', 'Tomorrow at 11:59 PM, not Yesterday, or the wrong time');
34361 });
34362
34363 test('calendar with custom formats', function (assert) {
34364 assert.equal(moment().calendar(null, {sameDay: '[Today]'}), 'Today', 'Today');
34365 assert.equal(moment().add(1, 'days').calendar(null, {nextDay: '[Tomorrow]'}), 'Tomorrow', 'Tomorrow');
34366 assert.equal(moment([1985, 1, 4]).calendar(null, {sameElse: 'YYYY-MM-DD'}), '1985-02-04', 'Else');
34367 });
34368
34369 test('invalid', function (assert) {
34370 assert.equal(moment.invalid().format(), 'Invalid date');
34371 assert.equal(moment.invalid().format('YYYY-MM-DD'), 'Invalid date');
34372 });
34373
34374 test('quarter formats', function (assert) {
34375 assert.equal(moment([1985, 1, 4]).format('Q'), '1', 'Feb 4 1985 is Q1');
34376 assert.equal(moment([2029, 8, 18]).format('Q'), '3', 'Sep 18 2029 is Q3');
34377 assert.equal(moment([2013, 3, 24]).format('Q'), '2', 'Apr 24 2013 is Q2');
34378 assert.equal(moment([2015, 2, 5]).format('Q'), '1', 'Mar 5 2015 is Q1');
34379 assert.equal(moment([1970, 0, 2]).format('Q'), '1', 'Jan 2 1970 is Q1');
34380 assert.equal(moment([2001, 11, 12]).format('Q'), '4', 'Dec 12 2001 is Q4');
34381 assert.equal(moment([2000, 0, 2]).format('[Q]Q-YYYY'), 'Q1-2000', 'Jan 2 2000 is Q1');
34382 });
34383
34384 test('full expanded format is returned from abbreviated formats', function (assert) {
34385 var locales = '';
34386
34387 locales += 'af ar-ma ar-sa ar-tn ar az be bg bn bo br bs';
34388 locales += 'ca cs cv cy da de-at de el en-au en-ca en-gb';
34389 locales += 'en eo es et eu fa fi fo fr-ca fr fy gl he hi';
34390 locales += 'hr hu hy-am id is it ja jv ka km ko lb lt lv';
34391 locales += 'me mk ml mr ms-my my nb ne nl nn pl pt-rb pt';
34392 locales += 'ro ru si sk sl sq sr-cyrl sr sv ta th tl-ph';
34393 locales += 'tr tzm-latn tzm uk uz vi zh-cn zh-tw';
34394
34395 locales.split(' ').forEach(function (locale) {
34396 var data, tokens;
34397 data = moment().locale(locale).localeData()._longDateFormat;
34398 tokens = Object.keys(data);
34399 tokens.forEach(function (token) {
34400 // Check each format string to make sure it does not contain any
34401 // tokens that need to be expanded.
34402 tokens.forEach(function (i) {
34403 // strip escaped sequences
34404 var format = data[i].replace(/(\[[^\]]*\])/g, '');
34405 assert.equal(false, !!~format.indexOf(token), 'locale ' + locale + ' contains ' + token + ' in ' + i);
34406 });
34407 });
34408 });
34409 });
34410
34411 test('milliseconds', function (assert) {
34412 var m = moment('123', 'SSS');
34413
34414 assert.equal(m.format('S'), '1');
34415 assert.equal(m.format('SS'), '12');
34416 assert.equal(m.format('SSS'), '123');
34417 assert.equal(m.format('SSSS'), '1230');
34418 assert.equal(m.format('SSSSS'), '12300');
34419 assert.equal(m.format('SSSSSS'), '123000');
34420 assert.equal(m.format('SSSSSSS'), '1230000');
34421 assert.equal(m.format('SSSSSSSS'), '12300000');
34422 assert.equal(m.format('SSSSSSSSS'), '123000000');
34423 });
34424
34425 }));
34426
34427 (function (global, factory) {
34428 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
34429 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
34430 factory(global.moment)
34431 }(this, function (moment) { 'use strict';
34432
34433 /*global QUnit:false*/
34434
34435 var test = QUnit.test;
34436
34437 function module (name, lifecycle) {
34438 QUnit.module(name, {
34439 setup : function () {
34440 moment.locale('en');
34441 moment.createFromInputFallback = function () {
34442 throw new Error('input not handled by moment');
34443 };
34444 if (lifecycle && lifecycle.setup) {
34445 lifecycle.setup();
34446 }
34447 },
34448 teardown : function () {
34449 if (lifecycle && lifecycle.teardown) {
34450 lifecycle.teardown();
34451 }
34452 }
34453 });
34454 }
34455
34456 function localeModule (name, lifecycle) {
34457 QUnit.module('locale:' + name, {
34458 setup : function () {
34459 moment.locale(name);
34460 moment.createFromInputFallback = function () {
34461 throw new Error('input not handled by moment');
34462 };
34463 if (lifecycle && lifecycle.setup) {
34464 lifecycle.setup();
34465 }
34466 },
34467 teardown : function () {
34468 moment.locale('en');
34469 if (lifecycle && lifecycle.teardown) {
34470 lifecycle.teardown();
34471 }
34472 }
34473 });
34474 }
34475
34476 module('from_to');
34477
34478 test('from', function (assert) {
34479 var start = moment();
34480 moment.locale('en');
34481 assert.equal(start.from(start.clone().add(5, 'seconds')), 'a few seconds ago', '5 seconds = a few seconds ago');
34482 assert.equal(start.from(start.clone().add(1, 'minute')), 'a minute ago', '1 minute = a minute ago');
34483 assert.equal(start.from(start.clone().add(5, 'minutes')), '5 minutes ago', '5 minutes = 5 minutes ago');
34484
34485 assert.equal(start.from(start.clone().subtract(5, 'seconds')), 'in a few seconds', '5 seconds = in a few seconds');
34486 assert.equal(start.from(start.clone().subtract(1, 'minute')), 'in a minute', '1 minute = in a minute');
34487 assert.equal(start.from(start.clone().subtract(5, 'minutes')), 'in 5 minutes', '5 minutes = in 5 minutes');
34488 });
34489
34490 test('from with absolute duration', function (assert) {
34491 var start = moment();
34492 moment.locale('en');
34493 assert.equal(start.from(start.clone().add(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
34494 assert.equal(start.from(start.clone().add(1, 'minute'), true), 'a minute', '1 minute = a minute');
34495 assert.equal(start.from(start.clone().add(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
34496
34497 assert.equal(start.from(start.clone().subtract(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
34498 assert.equal(start.from(start.clone().subtract(1, 'minute'), true), 'a minute', '1 minute = a minute');
34499 assert.equal(start.from(start.clone().subtract(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
34500 });
34501
34502 test('to', function (assert) {
34503 var start = moment();
34504 moment.locale('en');
34505 assert.equal(start.to(start.clone().subtract(5, 'seconds')), 'a few seconds ago', '5 seconds = a few seconds ago');
34506 assert.equal(start.to(start.clone().subtract(1, 'minute')), 'a minute ago', '1 minute = a minute ago');
34507 assert.equal(start.to(start.clone().subtract(5, 'minutes')), '5 minutes ago', '5 minutes = 5 minutes ago');
34508
34509 assert.equal(start.to(start.clone().add(5, 'seconds')), 'in a few seconds', '5 seconds = in a few seconds');
34510 assert.equal(start.to(start.clone().add(1, 'minute')), 'in a minute', '1 minute = in a minute');
34511 assert.equal(start.to(start.clone().add(5, 'minutes')), 'in 5 minutes', '5 minutes = in 5 minutes');
34512 });
34513
34514 test('to with absolute duration', function (assert) {
34515 var start = moment();
34516 moment.locale('en');
34517 assert.equal(start.to(start.clone().add(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
34518 assert.equal(start.to(start.clone().add(1, 'minute'), true), 'a minute', '1 minute = a minute');
34519 assert.equal(start.to(start.clone().add(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
34520
34521 assert.equal(start.to(start.clone().subtract(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
34522 assert.equal(start.to(start.clone().subtract(1, 'minute'), true), 'a minute', '1 minute = a minute');
34523 assert.equal(start.to(start.clone().subtract(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
34524 });
34525
34526 }));
34527
34528 (function (global, factory) {
34529 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
34530 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
34531 factory(global.moment)
34532 }(this, function (moment) { 'use strict';
34533
34534 /*global QUnit:false*/
34535
34536 var test = QUnit.test;
34537
34538 function module (name, lifecycle) {
34539 QUnit.module(name, {
34540 setup : function () {
34541 moment.locale('en');
34542 moment.createFromInputFallback = function () {
34543 throw new Error('input not handled by moment');
34544 };
34545 if (lifecycle && lifecycle.setup) {
34546 lifecycle.setup();
34547 }
34548 },
34549 teardown : function () {
34550 if (lifecycle && lifecycle.teardown) {
34551 lifecycle.teardown();
34552 }
34553 }
34554 });
34555 }
34556
34557 function localeModule (name, lifecycle) {
34558 QUnit.module('locale:' + name, {
34559 setup : function () {
34560 moment.locale(name);
34561 moment.createFromInputFallback = function () {
34562 throw new Error('input not handled by moment');
34563 };
34564 if (lifecycle && lifecycle.setup) {
34565 lifecycle.setup();
34566 }
34567 },
34568 teardown : function () {
34569 moment.locale('en');
34570 if (lifecycle && lifecycle.teardown) {
34571 lifecycle.teardown();
34572 }
34573 }
34574 });
34575 }
34576
34577 module('getters and setters');
34578
34579 test('getters', function (assert) {
34580 var a = moment([2011, 9, 12, 6, 7, 8, 9]);
34581 assert.equal(a.year(), 2011, 'year');
34582 assert.equal(a.month(), 9, 'month');
34583 assert.equal(a.date(), 12, 'date');
34584 assert.equal(a.day(), 3, 'day');
34585 assert.equal(a.hours(), 6, 'hour');
34586 assert.equal(a.minutes(), 7, 'minute');
34587 assert.equal(a.seconds(), 8, 'second');
34588 assert.equal(a.milliseconds(), 9, 'milliseconds');
34589 });
34590
34591 test('getters programmatic', function (assert) {
34592 var a = moment([2011, 9, 12, 6, 7, 8, 9]);
34593 assert.equal(a.get('year'), 2011, 'year');
34594 assert.equal(a.get('month'), 9, 'month');
34595 assert.equal(a.get('date'), 12, 'date');
34596 assert.equal(a.get('day'), 3, 'day');
34597 assert.equal(a.get('hour'), 6, 'hour');
34598 assert.equal(a.get('minute'), 7, 'minute');
34599 assert.equal(a.get('second'), 8, 'second');
34600 assert.equal(a.get('milliseconds'), 9, 'milliseconds');
34601
34602 //actual getters tested elsewhere
34603 assert.equal(a.get('weekday'), a.weekday(), 'weekday');
34604 assert.equal(a.get('isoWeekday'), a.isoWeekday(), 'isoWeekday');
34605 assert.equal(a.get('week'), a.week(), 'week');
34606 assert.equal(a.get('isoWeek'), a.isoWeek(), 'isoWeek');
34607 assert.equal(a.get('dayOfYear'), a.dayOfYear(), 'dayOfYear');
34608 });
34609
34610 test('setters plural', function (assert) {
34611 var a = moment();
34612 a.years(2011);
34613 a.months(9);
34614 a.dates(12);
34615 a.hours(6);
34616 a.minutes(7);
34617 a.seconds(8);
34618 a.milliseconds(9);
34619 assert.equal(a.years(), 2011, 'years');
34620 assert.equal(a.months(), 9, 'months');
34621 assert.equal(a.dates(), 12, 'dates');
34622 assert.equal(a.days(), 3, 'days');
34623 assert.equal(a.hours(), 6, 'hours');
34624 assert.equal(a.minutes(), 7, 'minutes');
34625 assert.equal(a.seconds(), 8, 'seconds');
34626 assert.equal(a.milliseconds(), 9, 'milliseconds');
34627 });
34628
34629 test('setters singular', function (assert) {
34630 var a = moment();
34631 a.year(2011);
34632 a.month(9);
34633 a.date(12);
34634 a.hour(6);
34635 a.minute(7);
34636 a.second(8);
34637 a.millisecond(9);
34638 assert.equal(a.year(), 2011, 'year');
34639 assert.equal(a.month(), 9, 'month');
34640 assert.equal(a.date(), 12, 'date');
34641 assert.equal(a.day(), 3, 'day');
34642 assert.equal(a.hour(), 6, 'hour');
34643 assert.equal(a.minute(), 7, 'minute');
34644 assert.equal(a.second(), 8, 'second');
34645 assert.equal(a.millisecond(), 9, 'milliseconds');
34646 });
34647
34648 test('setters', function (assert) {
34649 var a = moment();
34650 a.year(2011);
34651 a.month(9);
34652 a.date(12);
34653 a.hours(6);
34654 a.minutes(7);
34655 a.seconds(8);
34656 a.milliseconds(9);
34657 assert.equal(a.year(), 2011, 'year');
34658 assert.equal(a.month(), 9, 'month');
34659 assert.equal(a.date(), 12, 'date');
34660 assert.equal(a.day(), 3, 'day');
34661 assert.equal(a.hours(), 6, 'hour');
34662 assert.equal(a.minutes(), 7, 'minute');
34663 assert.equal(a.seconds(), 8, 'second');
34664 assert.equal(a.milliseconds(), 9, 'milliseconds');
34665
34666 // Test month() behavior. See https://github.com/timrwood/moment/pull/822
34667 a = moment('20130531', 'YYYYMMDD');
34668 a.month(3);
34669 assert.equal(a.month(), 3, 'month edge case');
34670 });
34671
34672 test('setter programmatic', function (assert) {
34673 var a = moment();
34674 a.set('year', 2011);
34675 a.set('month', 9);
34676 a.set('date', 12);
34677 a.set('hours', 6);
34678 a.set('minutes', 7);
34679 a.set('seconds', 8);
34680 a.set('milliseconds', 9);
34681 assert.equal(a.year(), 2011, 'year');
34682 assert.equal(a.month(), 9, 'month');
34683 assert.equal(a.date(), 12, 'date');
34684 assert.equal(a.day(), 3, 'day');
34685 assert.equal(a.hours(), 6, 'hour');
34686 assert.equal(a.minutes(), 7, 'minute');
34687 assert.equal(a.seconds(), 8, 'second');
34688 assert.equal(a.milliseconds(), 9, 'milliseconds');
34689
34690 // Test month() behavior. See https://github.com/timrwood/moment/pull/822
34691 a = moment('20130531', 'YYYYMMDD');
34692 a.month(3);
34693 assert.equal(a.month(), 3, 'month edge case');
34694 });
34695
34696 // Disable this, until we weekYear setter is fixed.
34697 // https://github.com/moment/moment/issues/1379
34698 // test('setters programatic with weeks', function (assert) {
34699 // var a = moment();
34700 // a.set('weekYear', 2001);
34701 // a.set('week', 49);
34702 // a.set('day', 4);
34703 // assert.equals(a.weekYear(), 2001);
34704 // assert.equals(a.week(), 49);
34705 // assert.equals(a.day(), 4);
34706
34707 // a.set('weekday', 1);
34708 // assert.equals(a.weekday(), 1);
34709
34710 // assert.done();
34711 //},
34712
34713 // I think this suffers from the same issue as the non-iso version.
34714 // test('setters programatic with weeks ISO', function (assert) {
34715 // var a = moment();
34716 // a.set('isoWeekYear', 2001);
34717 // a.set('isoWeek', 49);
34718 // a.set('isoWeekday', 4);
34719
34720 // assert.equals(a.weekYear(), 2001);
34721 // assert.equals(a.week(), 49);
34722 // assert.equals(a.day(), 4);
34723
34724 // assert.done();
34725 //},
34726
34727 test('setters strings', function (assert) {
34728 var a = moment([2012]).locale('en');
34729 assert.equal(a.clone().day(0).day('Wednesday').day(), 3, 'day full name');
34730 assert.equal(a.clone().day(0).day('Wed').day(), 3, 'day short name');
34731 assert.equal(a.clone().day(0).day('We').day(), 3, 'day minimal name');
34732 assert.equal(a.clone().day(0).day('invalid').day(), 0, 'invalid day name');
34733 assert.equal(a.clone().month(0).month('April').month(), 3, 'month full name');
34734 assert.equal(a.clone().month(0).month('Apr').month(), 3, 'month short name');
34735 assert.equal(a.clone().month(0).month('invalid').month(), 0, 'invalid month name');
34736 });
34737
34738 test('setters - falsey values', function (assert) {
34739 var a = moment();
34740 // ensure minutes wasn't coincidentally 0 already
34741 a.minutes(1);
34742 a.minutes(0);
34743 assert.equal(a.minutes(), 0, 'falsey value');
34744 });
34745
34746 test('chaining setters', function (assert) {
34747 var a = moment();
34748 a.year(2011)
34749 .month(9)
34750 .date(12)
34751 .hours(6)
34752 .minutes(7)
34753 .seconds(8);
34754 assert.equal(a.year(), 2011, 'year');
34755 assert.equal(a.month(), 9, 'month');
34756 assert.equal(a.date(), 12, 'date');
34757 assert.equal(a.day(), 3, 'day');
34758 assert.equal(a.hours(), 6, 'hour');
34759 assert.equal(a.minutes(), 7, 'minute');
34760 assert.equal(a.seconds(), 8, 'second');
34761 });
34762
34763 test('setter with multiple unit values', function (assert) {
34764 var a = moment();
34765 a.set({
34766 year: 2011,
34767 month: 9,
34768 date: 12,
34769 hours: 6,
34770 minutes: 7,
34771 seconds: 8,
34772 milliseconds: 9
34773 });
34774 assert.equal(a.year(), 2011, 'year');
34775 assert.equal(a.month(), 9, 'month');
34776 assert.equal(a.date(), 12, 'date');
34777 assert.equal(a.day(), 3, 'day');
34778 assert.equal(a.hours(), 6, 'hour');
34779 assert.equal(a.minutes(), 7, 'minute');
34780 assert.equal(a.seconds(), 8, 'second');
34781 assert.equal(a.milliseconds(), 9, 'milliseconds');
34782 });
34783
34784 test('day setter', function (assert) {
34785 var a = moment([2011, 0, 15]);
34786 assert.equal(moment(a).day(0).date(), 9, 'set from saturday to sunday');
34787 assert.equal(moment(a).day(6).date(), 15, 'set from saturday to saturday');
34788 assert.equal(moment(a).day(3).date(), 12, 'set from saturday to wednesday');
34789
34790 a = moment([2011, 0, 9]);
34791 assert.equal(moment(a).day(0).date(), 9, 'set from sunday to sunday');
34792 assert.equal(moment(a).day(6).date(), 15, 'set from sunday to saturday');
34793 assert.equal(moment(a).day(3).date(), 12, 'set from sunday to wednesday');
34794
34795 a = moment([2011, 0, 12]);
34796 assert.equal(moment(a).day(0).date(), 9, 'set from wednesday to sunday');
34797 assert.equal(moment(a).day(6).date(), 15, 'set from wednesday to saturday');
34798 assert.equal(moment(a).day(3).date(), 12, 'set from wednesday to wednesday');
34799
34800 assert.equal(moment(a).day(-7).date(), 2, 'set from wednesday to last sunday');
34801 assert.equal(moment(a).day(-1).date(), 8, 'set from wednesday to last saturday');
34802 assert.equal(moment(a).day(-4).date(), 5, 'set from wednesday to last wednesday');
34803
34804 assert.equal(moment(a).day(7).date(), 16, 'set from wednesday to next sunday');
34805 assert.equal(moment(a).day(13).date(), 22, 'set from wednesday to next saturday');
34806 assert.equal(moment(a).day(10).date(), 19, 'set from wednesday to next wednesday');
34807
34808 assert.equal(moment(a).day(14).date(), 23, 'set from wednesday to second next sunday');
34809 assert.equal(moment(a).day(20).date(), 29, 'set from wednesday to second next saturday');
34810 assert.equal(moment(a).day(17).date(), 26, 'set from wednesday to second next wednesday');
34811 });
34812
34813 }));
34814
34815 (function (global, factory) {
34816 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
34817 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
34818 factory(global.moment)
34819 }(this, function (moment) { 'use strict';
34820
34821 /*global QUnit:false*/
34822
34823 var test = QUnit.test;
34824
34825 function module (name, lifecycle) {
34826 QUnit.module(name, {
34827 setup : function () {
34828 moment.locale('en');
34829 moment.createFromInputFallback = function () {
34830 throw new Error('input not handled by moment');
34831 };
34832 if (lifecycle && lifecycle.setup) {
34833 lifecycle.setup();
34834 }
34835 },
34836 teardown : function () {
34837 if (lifecycle && lifecycle.teardown) {
34838 lifecycle.teardown();
34839 }
34840 }
34841 });
34842 }
34843
34844 function localeModule (name, lifecycle) {
34845 QUnit.module('locale:' + name, {
34846 setup : function () {
34847 moment.locale(name);
34848 moment.createFromInputFallback = function () {
34849 throw new Error('input not handled by moment');
34850 };
34851 if (lifecycle && lifecycle.setup) {
34852 lifecycle.setup();
34853 }
34854 },
34855 teardown : function () {
34856 moment.locale('en');
34857 if (lifecycle && lifecycle.teardown) {
34858 lifecycle.teardown();
34859 }
34860 }
34861 });
34862 }
34863
34864 module('invalid');
34865
34866 test('invalid', function (assert) {
34867 var m = moment.invalid();
34868 assert.equal(m.isValid(), false);
34869 assert.equal(m.parsingFlags().userInvalidated, true);
34870 assert.ok(isNaN(m.valueOf()));
34871 });
34872
34873 test('invalid with existing flag', function (assert) {
34874 var m = moment.invalid({invalidMonth : 'whatchamacallit'});
34875 assert.equal(m.isValid(), false);
34876 assert.equal(m.parsingFlags().userInvalidated, false);
34877 assert.equal(m.parsingFlags().invalidMonth, 'whatchamacallit');
34878 assert.ok(isNaN(m.valueOf()));
34879 });
34880
34881 test('invalid with custom flag', function (assert) {
34882 var m = moment.invalid({tooBusyWith : 'reiculating splines'});
34883 assert.equal(m.isValid(), false);
34884 assert.equal(m.parsingFlags().userInvalidated, false);
34885 assert.equal(m.parsingFlags().tooBusyWith, 'reiculating splines');
34886 assert.ok(isNaN(m.valueOf()));
34887 });
34888
34889 }));
34890
34891 (function (global, factory) {
34892 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
34893 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
34894 factory(global.moment)
34895 }(this, function (moment) { 'use strict';
34896
34897 /*global QUnit:false*/
34898
34899 var test = QUnit.test;
34900
34901 function module (name, lifecycle) {
34902 QUnit.module(name, {
34903 setup : function () {
34904 moment.locale('en');
34905 moment.createFromInputFallback = function () {
34906 throw new Error('input not handled by moment');
34907 };
34908 if (lifecycle && lifecycle.setup) {
34909 lifecycle.setup();
34910 }
34911 },
34912 teardown : function () {
34913 if (lifecycle && lifecycle.teardown) {
34914 lifecycle.teardown();
34915 }
34916 }
34917 });
34918 }
34919
34920 function localeModule (name, lifecycle) {
34921 QUnit.module('locale:' + name, {
34922 setup : function () {
34923 moment.locale(name);
34924 moment.createFromInputFallback = function () {
34925 throw new Error('input not handled by moment');
34926 };
34927 if (lifecycle && lifecycle.setup) {
34928 lifecycle.setup();
34929 }
34930 },
34931 teardown : function () {
34932 moment.locale('en');
34933 if (lifecycle && lifecycle.teardown) {
34934 lifecycle.teardown();
34935 }
34936 }
34937 });
34938 }
34939
34940 module('is after');
34941
34942 test('is after without units', function (assert) {
34943 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
34944 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, 'year is later');
34945 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), true, 'year is earlier');
34946 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, 'month is later');
34947 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), true, 'month is earlier');
34948 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, 'day is later');
34949 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), true, 'day is earlier');
34950 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, 'hour is later');
34951 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), true, 'hour is earlier');
34952 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, 'minute is later');
34953 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), true, 'minute is earlier');
34954 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, 'second is later');
34955 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), true, 'second is earlier');
34956 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond match');
34957 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, 'millisecond is later');
34958 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), true, 'millisecond is earlier');
34959 assert.equal(m.isAfter(m), false, 'moments are not after themselves');
34960 assert.equal(+m, +mCopy, 'isAfter second should not change moment');
34961 });
34962
34963 test('is after year', function (assert) {
34964 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
34965 assert.equal(m.isAfter(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');
34966 assert.equal(m.isAfter(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
34967 assert.equal(m.isAfter(moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is later');
34968 assert.equal(m.isAfter(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is earlier');
34969 assert.equal(m.isAfter(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), false, 'exact start of year');
34970 assert.equal(m.isAfter(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), false, 'exact end of year');
34971 assert.equal(m.isAfter(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), false, 'start of next year');
34972 assert.equal(m.isAfter(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), true, 'end of previous year');
34973 assert.equal(m.isAfter(moment(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year'), true, 'end of year far before');
34974 assert.equal(m.isAfter(m, 'year'), false, 'same moments are not after the same year');
34975 assert.equal(+m, +mCopy, 'isAfter year should not change moment');
34976 });
34977
34978 test('is after month', function (assert) {
34979 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
34980 assert.equal(m.isAfter(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month match');
34981 assert.equal(m.isAfter(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
34982 assert.equal(m.isAfter(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year is later');
34983 assert.equal(m.isAfter(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month'), true, 'year is earlier');
34984 assert.equal(m.isAfter(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), false, 'month is later');
34985 assert.equal(m.isAfter(moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), true, 'month is earlier');
34986 assert.equal(m.isAfter(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), false, 'exact start of month');
34987 assert.equal(m.isAfter(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), false, 'exact end of month');
34988 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), false, 'start of next month');
34989 assert.equal(m.isAfter(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), true, 'end of previous month');
34990 assert.equal(m.isAfter(moment(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month'), true, 'later month but earlier year');
34991 assert.equal(m.isAfter(m, 'month'), false, 'same moments are not after the same month');
34992 assert.equal(+m, +mCopy, 'isAfter month should not change moment');
34993 });
34994
34995 test('is after day', function (assert) {
34996 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
34997 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day'), false, 'day match');
34998 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');
34999 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day'), false, 'year is later');
35000 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day'), true, 'year is earlier');
35001 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day'), false, 'month is later');
35002 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), true, 'month is earlier');
35003 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day'), false, 'day is later');
35004 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day'), true, 'day is earlier');
35005 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day'), false, 'exact start of day');
35006 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day'), false, 'exact end of day');
35007 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day'), false, 'start of next day');
35008 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day'), true, 'end of previous day');
35009 assert.equal(m.isAfter(moment(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day'), true, 'later day but earlier year');
35010 assert.equal(m.isAfter(m, 'day'), false, 'same moments are not after the same day');
35011 assert.equal(+m, +mCopy, 'isAfter day should not change moment');
35012 });
35013
35014 test('is after hour', function (assert) {
35015 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
35016 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour match');
35017 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');
35018 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'year is later');
35019 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour'), true, 'year is earlier');
35020 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour'), false, 'month is later');
35021 assert.equal(m.isAfter(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), true, 'month is earlier');
35022 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour'), false, 'day is later');
35023 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour'), true, 'day is earlier');
35024 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour'), false, 'hour is later');
35025 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour is earlier');
35026 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour'), false, 'exact start of hour');
35027 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour'), false, 'exact end of hour');
35028 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour'), false, 'start of next hour');
35029 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour'), true, 'end of previous hour');
35030 assert.equal(m.isAfter(m, 'hour'), false, 'same moments are not after the same hour');
35031 assert.equal(+m, +mCopy, 'isAfter hour should not change moment');
35032 });
35033
35034 test('is after minute', function (assert) {
35035 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
35036 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');
35037 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');
35038 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'year is later');
35039 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute'), true, 'year is earlier');
35040 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute'), false, 'month is later');
35041 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), true, 'month is earlier');
35042 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute'), false, 'day is later');
35043 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute'), true, 'day is earlier');
35044 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute'), false, 'hour is later');
35045 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute'), true, 'hour is earler');
35046 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute'), false, 'minute is later');
35047 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute'), true, 'minute is earlier');
35048 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute'), false, 'exact start of minute');
35049 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute'), false, 'exact end of minute');
35050 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute'), false, 'start of next minute');
35051 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute'), true, 'end of previous minute');
35052 assert.equal(m.isAfter(m, 'minute'), false, 'same moments are not after the same minute');
35053 assert.equal(+m, +mCopy, 'isAfter minute should not change moment');
35054 });
35055
35056 test('is after second', function (assert) {
35057 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35058 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second'), false, 'second match');
35059 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');
35060 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second'), false, 'year is later');
35061 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second'), true, 'year is earlier');
35062 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second'), false, 'month is later');
35063 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), true, 'month is earlier');
35064 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second'), false, 'day is later');
35065 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second'), true, 'day is earlier');
35066 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second'), false, 'hour is later');
35067 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second'), true, 'hour is earlier');
35068 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second'), false, 'minute is later');
35069 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second'), true, 'minute is earlier');
35070 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second'), false, 'second is later');
35071 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second'), true, 'second is earlier');
35072 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second'), false, 'exact start of second');
35073 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second'), false, 'exact end of second');
35074 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second'), false, 'start of next second');
35075 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second'), true, 'end of previous second');
35076 assert.equal(m.isAfter(m, 'second'), false, 'same moments are not after the same second');
35077 assert.equal(+m, +mCopy, 'isAfter second should not change moment');
35078 });
35079
35080 test('is after millisecond', function (assert) {
35081 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35082 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond match');
35083 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'plural should work');
35084 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is later');
35085 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'year is earlier');
35086 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is later');
35087 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), true, 'month is earlier');
35088 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), false, 'day is later');
35089 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), true, 'day is earlier');
35090 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), false, 'hour is later');
35091 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), true, 'hour is earlier');
35092 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), false, 'minute is later');
35093 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), true, 'minute is earlier');
35094 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), false, 'second is later');
35095 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), true, 'second is earlier');
35096 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), false, 'millisecond is later');
35097 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), true, 'millisecond is earlier');
35098 assert.equal(m.isAfter(m, 'millisecond'), false, 'same moments are not after the same millisecond');
35099 assert.equal(+m, +mCopy, 'isAfter millisecond should not change moment');
35100 });
35101
35102 test('is after invalid', function (assert) {
35103 var m = moment(), invalid = moment.invalid();
35104 assert.equal(m.isAfter(invalid), false, 'valid moment is not after invalid moment');
35105 assert.equal(invalid.isAfter(m), false, 'invalid moment is not after valid moment');
35106 assert.equal(m.isAfter(invalid, 'year'), false, 'invalid moment year');
35107 assert.equal(m.isAfter(invalid, 'month'), false, 'invalid moment month');
35108 assert.equal(m.isAfter(invalid, 'day'), false, 'invalid moment day');
35109 assert.equal(m.isAfter(invalid, 'hour'), false, 'invalid moment hour');
35110 assert.equal(m.isAfter(invalid, 'minute'), false, 'invalid moment minute');
35111 assert.equal(m.isAfter(invalid, 'second'), false, 'invalid moment second');
35112 assert.equal(m.isAfter(invalid, 'milliseconds'), false, 'invalid moment milliseconds');
35113 });
35114
35115 }));
35116
35117 (function (global, factory) {
35118 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
35119 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
35120 factory(global.moment)
35121 }(this, function (moment) { 'use strict';
35122
35123 /*global QUnit:false*/
35124
35125 var test = QUnit.test;
35126
35127 function module (name, lifecycle) {
35128 QUnit.module(name, {
35129 setup : function () {
35130 moment.locale('en');
35131 moment.createFromInputFallback = function () {
35132 throw new Error('input not handled by moment');
35133 };
35134 if (lifecycle && lifecycle.setup) {
35135 lifecycle.setup();
35136 }
35137 },
35138 teardown : function () {
35139 if (lifecycle && lifecycle.teardown) {
35140 lifecycle.teardown();
35141 }
35142 }
35143 });
35144 }
35145
35146 function localeModule (name, lifecycle) {
35147 QUnit.module('locale:' + name, {
35148 setup : function () {
35149 moment.locale(name);
35150 moment.createFromInputFallback = function () {
35151 throw new Error('input not handled by moment');
35152 };
35153 if (lifecycle && lifecycle.setup) {
35154 lifecycle.setup();
35155 }
35156 },
35157 teardown : function () {
35158 moment.locale('en');
35159 if (lifecycle && lifecycle.teardown) {
35160 lifecycle.teardown();
35161 }
35162 }
35163 });
35164 }
35165
35166 module('is before');
35167
35168 test('is after without units', function (assert) {
35169 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35170 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), true, 'year is later');
35171 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, 'year is earlier');
35172 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), true, 'month is later');
35173 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, 'month is earlier');
35174 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), true, 'day is later');
35175 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, 'day is earlier');
35176 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), true, 'hour is later');
35177 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, 'hour is earlier');
35178 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), true, 'minute is later');
35179 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, 'minute is earlier');
35180 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), true, 'second is later');
35181 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, 'second is earlier');
35182 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond match');
35183 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), true, 'millisecond is later');
35184 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, 'millisecond is earlier');
35185 assert.equal(m.isBefore(m), false, 'moments are not before themselves');
35186 assert.equal(+m, +mCopy, 'isBefore second should not change moment');
35187 });
35188
35189 test('is before year', function (assert) {
35190 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35191 assert.equal(m.isBefore(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');
35192 assert.equal(m.isBefore(moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
35193 assert.equal(m.isBefore(moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is later');
35194 assert.equal(m.isBefore(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is earlier');
35195 assert.equal(m.isBefore(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), false, 'exact start of year');
35196 assert.equal(m.isBefore(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), false, 'exact end of year');
35197 assert.equal(m.isBefore(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), true, 'start of next year');
35198 assert.equal(m.isBefore(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of previous year');
35199 assert.equal(m.isBefore(moment(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of year far before');
35200 assert.equal(m.isBefore(m, 'year'), false, 'same moments are not before the same year');
35201 assert.equal(+m, +mCopy, 'isBefore year should not change moment');
35202 });
35203
35204 test('is before month', function (assert) {
35205 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
35206 assert.equal(m.isBefore(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month match');
35207 assert.equal(m.isBefore(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
35208 assert.equal(m.isBefore(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), true, 'year is later');
35209 assert.equal(m.isBefore(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year is earlier');
35210 assert.equal(m.isBefore(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), true, 'month is later');
35211 assert.equal(m.isBefore(moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), false, 'month is earlier');
35212 assert.equal(m.isBefore(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), false, 'exact start of month');
35213 assert.equal(m.isBefore(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), false, 'exact end of month');
35214 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), true, 'start of next month');
35215 assert.equal(m.isBefore(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), false, 'end of previous month');
35216 assert.equal(m.isBefore(moment(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month'), false, 'later month but earlier year');
35217 assert.equal(m.isBefore(m, 'month'), false, 'same moments are not before the same month');
35218 assert.equal(+m, +mCopy, 'isBefore month should not change moment');
35219 });
35220
35221 test('is before day', function (assert) {
35222 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
35223 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day'), false, 'day match');
35224 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');
35225 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day'), true, 'year is later');
35226 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day'), false, 'year is earlier');
35227 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day'), true, 'month is later');
35228 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), false, 'month is earlier');
35229 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day'), true, 'day is later');
35230 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day'), false, 'day is earlier');
35231 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day'), false, 'exact start of day');
35232 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day'), false, 'exact end of day');
35233 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day'), true, 'start of next day');
35234 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day'), false, 'end of previous day');
35235 assert.equal(m.isBefore(moment(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day'), false, 'later day but earlier year');
35236 assert.equal(m.isBefore(m, 'day'), false, 'same moments are not before the same day');
35237 assert.equal(+m, +mCopy, 'isBefore day should not change moment');
35238 });
35239
35240 test('is before hour', function (assert) {
35241 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
35242 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour match');
35243 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');
35244 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour'), true, 'year is later');
35245 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'year is earlier');
35246 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour'), true, 'month is later');
35247 assert.equal(m.isBefore(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), false, 'month is earlier');
35248 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour'), true, 'day is later');
35249 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour'), false, 'day is earlier');
35250 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour'), true, 'hour is later');
35251 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour is earlier');
35252 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour'), false, 'exact start of hour');
35253 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour'), false, 'exact end of hour');
35254 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour'), true, 'start of next hour');
35255 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour'), false, 'end of previous hour');
35256 assert.equal(m.isBefore(m, 'hour'), false, 'same moments are not before the same hour');
35257 assert.equal(+m, +mCopy, 'isBefore hour should not change moment');
35258 });
35259
35260 test('is before minute', function (assert) {
35261 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
35262 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');
35263 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');
35264 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute'), true, 'year is later');
35265 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'year is earlier');
35266 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute'), true, 'month is later');
35267 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), false, 'month is earlier');
35268 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute'), true, 'day is later');
35269 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute'), false, 'day is earlier');
35270 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute'), true, 'hour is later');
35271 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute'), false, 'hour is earler');
35272 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute'), true, 'minute is later');
35273 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute'), false, 'minute is earlier');
35274 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute'), false, 'exact start of minute');
35275 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute'), false, 'exact end of minute');
35276 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute'), true, 'start of next minute');
35277 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute'), false, 'end of previous minute');
35278 assert.equal(m.isBefore(m, 'minute'), false, 'same moments are not before the same minute');
35279 assert.equal(+m, +mCopy, 'isBefore minute should not change moment');
35280 });
35281
35282 test('is before second', function (assert) {
35283 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35284 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second'), false, 'second match');
35285 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');
35286 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second'), true, 'year is later');
35287 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second'), false, 'year is earlier');
35288 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second'), true, 'month is later');
35289 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), false, 'month is earlier');
35290 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second'), true, 'day is later');
35291 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second'), false, 'day is earlier');
35292 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second'), true, 'hour is later');
35293 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second'), false, 'hour is earlier');
35294 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second'), true, 'minute is later');
35295 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second'), false, 'minute is earlier');
35296 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second'), true, 'second is later');
35297 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second'), false, 'second is earlier');
35298 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second'), false, 'exact start of second');
35299 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second'), false, 'exact end of second');
35300 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second'), true, 'start of next second');
35301 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second'), false, 'end of previous second');
35302 assert.equal(m.isBefore(m, 'second'), false, 'same moments are not before the same second');
35303 assert.equal(+m, +mCopy, 'isBefore second should not change moment');
35304 });
35305
35306 test('is before millisecond', function (assert) {
35307 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35308 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond match');
35309 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds'), false, 'plural should work');
35310 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'year is later');
35311 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is earlier');
35312 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), true, 'month is later');
35313 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is earlier');
35314 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), true, 'day is later');
35315 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), false, 'day is earlier');
35316 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), true, 'hour is later');
35317 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), false, 'hour is earlier');
35318 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), true, 'minute is later');
35319 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), false, 'minute is earlier');
35320 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), true, 'second is later');
35321 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), false, 'second is earlier');
35322 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), true, 'millisecond is later');
35323 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), false, 'millisecond is earlier');
35324 assert.equal(m.isBefore(m, 'millisecond'), false, 'same moments are not before the same millisecond');
35325 assert.equal(+m, +mCopy, 'isBefore millisecond should not change moment');
35326 });
35327
35328 test('is before invalid', function (assert) {
35329 var m = moment(), invalid = moment.invalid();
35330 assert.equal(m.isBefore(invalid), false, 'valid moment is not before invalid moment');
35331 assert.equal(invalid.isBefore(m), false, 'invalid moment is not before valid moment');
35332 assert.equal(m.isBefore(invalid, 'year'), false, 'invalid moment year');
35333 assert.equal(m.isBefore(invalid, 'month'), false, 'invalid moment month');
35334 assert.equal(m.isBefore(invalid, 'day'), false, 'invalid moment day');
35335 assert.equal(m.isBefore(invalid, 'hour'), false, 'invalid moment hour');
35336 assert.equal(m.isBefore(invalid, 'minute'), false, 'invalid moment minute');
35337 assert.equal(m.isBefore(invalid, 'second'), false, 'invalid moment second');
35338 assert.equal(m.isBefore(invalid, 'milliseconds'), false, 'invalid moment milliseconds');
35339 });
35340
35341 }));
35342
35343 (function (global, factory) {
35344 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
35345 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
35346 factory(global.moment)
35347 }(this, function (moment) { 'use strict';
35348
35349 /*global QUnit:false*/
35350
35351 var test = QUnit.test;
35352
35353 function module (name, lifecycle) {
35354 QUnit.module(name, {
35355 setup : function () {
35356 moment.locale('en');
35357 moment.createFromInputFallback = function () {
35358 throw new Error('input not handled by moment');
35359 };
35360 if (lifecycle && lifecycle.setup) {
35361 lifecycle.setup();
35362 }
35363 },
35364 teardown : function () {
35365 if (lifecycle && lifecycle.teardown) {
35366 lifecycle.teardown();
35367 }
35368 }
35369 });
35370 }
35371
35372 function localeModule (name, lifecycle) {
35373 QUnit.module('locale:' + name, {
35374 setup : function () {
35375 moment.locale(name);
35376 moment.createFromInputFallback = function () {
35377 throw new Error('input not handled by moment');
35378 };
35379 if (lifecycle && lifecycle.setup) {
35380 lifecycle.setup();
35381 }
35382 },
35383 teardown : function () {
35384 moment.locale('en');
35385 if (lifecycle && lifecycle.teardown) {
35386 lifecycle.teardown();
35387 }
35388 }
35389 });
35390 }
35391
35392 module('is between');
35393
35394 test('is between without units', function (assert) {
35395 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35396 assert.equal(m.isBetween(
35397 moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
35398 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'year is later');
35399 assert.equal(m.isBetween(
35400 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
35401 moment(new Date(2013, 3, 2, 3, 4, 5, 10))), false, 'year is earlier');
35402 assert.equal(m.isBetween(
35403 moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
35404 moment(new Date(2012, 3, 2, 3, 4, 5, 10))), true, 'year is between');
35405 assert.equal(m.isBetween(
35406 moment(new Date(2011, 1, 2, 3, 4, 5, 10)),
35407 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'month is later');
35408 assert.equal(m.isBetween(
35409 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
35410 moment(new Date(2011, 5, 2, 3, 4, 5, 10))), false, 'month is earlier');
35411 assert.equal(m.isBetween(
35412 moment(new Date(2011, 2, 2, 3, 4, 5, 10)),
35413 moment(new Date(2011, 4, 2, 3, 4, 5, 10))), true, 'month is between');
35414 assert.equal(m.isBetween(
35415 moment(new Date(2011, 3, 1, 3, 4, 5, 10)),
35416 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'day is later');
35417 assert.equal(m.isBetween(
35418 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
35419 moment(new Date(2011, 3, 4, 3, 4, 5, 10))), false, 'day is earlier');
35420 assert.equal(m.isBetween(
35421 moment(new Date(2011, 3, 1, 3, 4, 5, 10)),
35422 moment(new Date(2011, 3, 3, 3, 4, 5, 10))), true, 'day is between');
35423 assert.equal(m.isBetween(
35424 moment(new Date(2011, 3, 2, 1, 4, 5, 10)),
35425 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'hour is later');
35426 assert.equal(m.isBetween(
35427 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
35428 moment(new Date(2011, 3, 2, 5, 4, 5, 10))), false, 'hour is earlier');
35429 assert.equal(m.isBetween(
35430 moment(new Date(2011, 3, 2, 2, 4, 5, 10)),
35431 moment(new Date(2011, 3, 2, 4, 4, 5, 10))), true, 'hour is between');
35432 assert.equal(m.isBetween(
35433 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
35434 moment(new Date(2011, 3, 2, 3, 6, 5, 10))), false, 'minute is later');
35435 assert.equal(m.isBetween(
35436 moment(new Date(2011, 3, 2, 3, 2, 5, 10)),
35437 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'minute is earlier');
35438 assert.equal(m.isBetween(
35439 moment(new Date(2011, 3, 2, 3, 3, 5, 10)),
35440 moment(new Date(2011, 3, 2, 3, 5, 5, 10))), true, 'minute is between');
35441 assert.equal(m.isBetween(
35442 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
35443 moment(new Date(2011, 3, 2, 3, 4, 7, 10))), false, 'second is later');
35444 assert.equal(m.isBetween(
35445 moment(new Date(2011, 3, 2, 3, 4, 3, 10)),
35446 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'second is earlier');
35447 assert.equal(m.isBetween(
35448 moment(new Date(2011, 3, 2, 3, 4, 4, 10)),
35449 moment(new Date(2011, 3, 2, 3, 4, 6, 10))), true, 'second is between');
35450 assert.equal(m.isBetween(
35451 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
35452 moment(new Date(2011, 3, 2, 3, 4, 5, 12))), false, 'millisecond is later');
35453 assert.equal(m.isBetween(
35454 moment(new Date(2011, 3, 2, 3, 4, 5, 8)),
35455 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond is earlier');
35456 assert.equal(m.isBetween(
35457 moment(new Date(2011, 3, 2, 3, 4, 5, 9)),
35458 moment(new Date(2011, 3, 2, 3, 4, 5, 11))), true, 'millisecond is between');
35459 assert.equal(m.isBetween(m, m), false, 'moments are not between themselves');
35460 assert.equal(+m, +mCopy, 'isBetween second should not change moment');
35461 });
35462
35463 test('is between year', function (assert) {
35464 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35465 assert.equal(m.isBetween(
35466 moment(new Date(2011, 5, 6, 7, 8, 9, 10)),
35467 moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');
35468 assert.equal(m.isBetween(
35469 moment(new Date(2010, 5, 6, 7, 8, 9, 10)),
35470 moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
35471 assert.equal(m.isBetween(
35472 moment(new Date(2010, 5, 6, 7, 8, 9, 10)),
35473 moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is between');
35474 assert.equal(m.isBetween(
35475 moment(new Date(2011, 5, 6, 7, 8, 9, 10)),
35476 moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is earlier');
35477 assert.equal(m.isBetween(
35478 moment(new Date(2010, 5, 6, 7, 8, 9, 10)),
35479 moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is later');
35480 assert.equal(m.isBetween(m, 'year'), false, 'same moments are not between the same year');
35481 assert.equal(+m, +mCopy, 'isBetween year should not change moment');
35482 });
35483
35484 test('is between month', function (assert) {
35485 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35486 assert.equal(m.isBetween(
35487 moment(new Date(2011, 1, 6, 7, 8, 9, 10)),
35488 moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), false, 'month match');
35489 assert.equal(m.isBetween(
35490 moment(new Date(2011, 0, 6, 7, 8, 9, 10)),
35491 moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
35492 assert.equal(m.isBetween(
35493 moment(new Date(2011, 0, 31, 23, 59, 59, 999)),
35494 moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), true, 'month is between');
35495 assert.equal(m.isBetween(
35496 moment(new Date(2011, 1, 6, 7, 8, 9, 10)),
35497 moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month is earlier');
35498 assert.equal(m.isBetween(
35499 moment(new Date(2011, 11, 6, 7, 8, 9, 10)),
35500 moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), false, 'month is later');
35501 assert.equal(m.isBetween(m, 'month'), false, 'same moments are not between the same month');
35502 assert.equal(+m, +mCopy, 'isBetween month should not change moment');
35503 });
35504
35505 test('is between day', function (assert) {
35506 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35507 assert.equal(m.isBetween(
35508 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
35509 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), false, 'day match');
35510 assert.equal(m.isBetween(
35511 moment(new Date(2011, 1, 1, 7, 8, 9, 10)),
35512 moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'days'), true, 'plural should work');
35513 assert.equal(m.isBetween(
35514 moment(new Date(2011, 1, 1, 7, 8, 9, 10)),
35515 moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day'), true, 'day is between');
35516 assert.equal(m.isBetween(
35517 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
35518 moment(new Date(2011, 1, 4, 7, 8, 9, 10)), 'day'), false, 'day is earlier');
35519 assert.equal(m.isBetween(
35520 moment(new Date(2011, 1, 1, 7, 8, 9, 10)),
35521 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), false, 'day is later');
35522 assert.equal(m.isBetween(m, 'day'), false, 'same moments are not between the same day');
35523 assert.equal(+m, +mCopy, 'isBetween day should not change moment');
35524 });
35525
35526 test('is between hour', function (assert) {
35527 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35528 assert.equal(m.isBetween(
35529 moment(new Date(2011, 1, 2, 3, 5, 9, 10)),
35530 moment(new Date(2011, 1, 2, 3, 9, 9, 10)), 'hour'), false, 'hour match');
35531 assert.equal(m.isBetween(
35532 moment(new Date(2011, 1, 2, 1, 59, 59, 999)),
35533 moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hours'), true, 'plural should work');
35534 assert.equal(m.isBetween(
35535 moment(new Date(2011, 1, 2, 2, 59, 59, 999)),
35536 moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour'), true, 'hour is between');
35537 assert.equal(m.isBetween(
35538 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
35539 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'hour'), false, 'hour is earlier');
35540 assert.equal(m.isBetween(
35541 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
35542 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'hour'), false, 'hour is later');
35543 assert.equal(m.isBetween(m, 'hour'), false, 'same moments are not between the same hour');
35544 assert.equal(+m, +mCopy, 'isBetween hour should not change moment');
35545 });
35546
35547 test('is between minute', function (assert) {
35548 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35549 assert.equal(m.isBetween(
35550 moment(new Date(2011, 1, 2, 3, 4, 9, 10)),
35551 moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');
35552 assert.equal(m.isBetween(
35553 moment(new Date(2011, 1, 2, 3, 3, 9, 10)),
35554 moment(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minutes'), true, 'plural should work');
35555 assert.equal(m.isBetween(
35556 moment(new Date(2011, 1, 2, 3, 3, 59, 999)),
35557 moment(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute'), true, 'minute is between');
35558 assert.equal(m.isBetween(
35559 moment(new Date(2011, 1, 2, 3, 5, 0, 0)),
35560 moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'minute'), false, 'minute is earlier');
35561 assert.equal(m.isBetween(
35562 moment(new Date(2011, 1, 2, 3, 2, 9, 10)),
35563 moment(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute'), false, 'minute is later');
35564 assert.equal(m.isBetween(m, 'minute'), false, 'same moments are not between the same minute');
35565 assert.equal(+m, +mCopy, 'isBetween minute should not change moment');
35566 });
35567
35568 test('is between second', function (assert) {
35569 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35570 assert.equal(m.isBetween(
35571 moment(new Date(2011, 1, 2, 3, 4, 5, 10)),
35572 moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second'), false, 'second match');
35573 assert.equal(m.isBetween(
35574 moment(new Date(2011, 1, 2, 3, 4, 4, 10)),
35575 moment(new Date(2011, 1, 2, 3, 4, 6, 10)), 'seconds'), true, 'plural should work');
35576 assert.equal(m.isBetween(
35577 moment(new Date(2011, 1, 2, 3, 4, 4, 999)),
35578 moment(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second'), true, 'second is between');
35579 assert.equal(m.isBetween(
35580 moment(new Date(2011, 1, 2, 3, 4, 6, 0)),
35581 moment(new Date(2011, 1, 2, 3, 4, 7, 10)), 'second'), false, 'second is earlier');
35582 assert.equal(m.isBetween(
35583 moment(new Date(2011, 1, 2, 3, 4, 3, 10)),
35584 moment(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second'), false, 'second is later');
35585 assert.equal(m.isBetween(m, 'second'), false, 'same moments are not between the same second');
35586 assert.equal(+m, +mCopy, 'isBetween second should not change moment');
35587 });
35588
35589 test('is between millisecond', function (assert) {
35590 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35591 assert.equal(m.isBetween(
35592 moment(new Date(2011, 1, 2, 3, 4, 5, 6)),
35593 moment(new Date(2011, 1, 2, 3, 4, 5, 6)), 'millisecond'), false, 'millisecond match');
35594 assert.equal(m.isBetween(
35595 moment(new Date(2011, 1, 2, 3, 4, 5, 5)),
35596 moment(new Date(2011, 1, 2, 3, 4, 5, 7)), 'milliseconds'), true, 'plural should work');
35597 assert.equal(m.isBetween(
35598 moment(new Date(2011, 1, 2, 3, 4, 5, 5)),
35599 moment(new Date(2011, 1, 2, 3, 4, 5, 7)), 'millisecond'), true, 'millisecond is between');
35600 assert.equal(m.isBetween(
35601 moment(new Date(2011, 1, 2, 3, 4, 5, 7)),
35602 moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond is earlier');
35603 assert.equal(m.isBetween(
35604 moment(new Date(2011, 1, 2, 3, 4, 5, 4)),
35605 moment(new Date(2011, 1, 2, 3, 4, 5, 6)), 'millisecond'), false, 'millisecond is later');
35606 assert.equal(m.isBetween(m, 'millisecond'), false, 'same moments are not between the same millisecond');
35607 assert.equal(+m, +mCopy, 'isBetween millisecond should not change moment');
35608 });
35609
35610 }));
35611
35612 (function (global, factory) {
35613 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
35614 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
35615 factory(global.moment)
35616 }(this, function (moment) { 'use strict';
35617
35618 /*global QUnit:false*/
35619
35620 var test = QUnit.test;
35621
35622 function module (name, lifecycle) {
35623 QUnit.module(name, {
35624 setup : function () {
35625 moment.locale('en');
35626 moment.createFromInputFallback = function () {
35627 throw new Error('input not handled by moment');
35628 };
35629 if (lifecycle && lifecycle.setup) {
35630 lifecycle.setup();
35631 }
35632 },
35633 teardown : function () {
35634 if (lifecycle && lifecycle.teardown) {
35635 lifecycle.teardown();
35636 }
35637 }
35638 });
35639 }
35640
35641 function localeModule (name, lifecycle) {
35642 QUnit.module('locale:' + name, {
35643 setup : function () {
35644 moment.locale(name);
35645 moment.createFromInputFallback = function () {
35646 throw new Error('input not handled by moment');
35647 };
35648 if (lifecycle && lifecycle.setup) {
35649 lifecycle.setup();
35650 }
35651 },
35652 teardown : function () {
35653 moment.locale('en');
35654 if (lifecycle && lifecycle.teardown) {
35655 lifecycle.teardown();
35656 }
35657 }
35658 });
35659 }
35660
35661 module('is date');
35662
35663 test('isDate recognizes Date objects', function (assert) {
35664 assert.ok(moment.isDate(new Date()), 'no args (now)');
35665 assert.ok(moment.isDate(new Date([2014, 2, 15])), 'array args');
35666 assert.ok(moment.isDate(new Date('2014-03-15')), 'string args');
35667 assert.ok(moment.isDate(new Date('does NOT look like a date')), 'invalid date');
35668 });
35669
35670 test('isDate rejects non-Date objects', function (assert) {
35671 assert.ok(!moment.isDate(), 'nothing');
35672 assert.ok(!moment.isDate(undefined), 'undefined');
35673 assert.ok(!moment.isDate(null), 'string args');
35674 assert.ok(!moment.isDate(42), 'number');
35675 assert.ok(!moment.isDate('2014-03-15'), 'string');
35676 assert.ok(!moment.isDate([2014, 2, 15]), 'array');
35677 assert.ok(!moment.isDate({year: 2014, month: 2, day: 15}), 'object');
35678 assert.ok(!moment.isDate({toString: function () {
35679 return '[object Date]';
35680 }}), 'lying object');
35681 });
35682
35683 }));
35684
35685 (function (global, factory) {
35686 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
35687 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
35688 factory(global.moment)
35689 }(this, function (moment) { 'use strict';
35690
35691 /*global QUnit:false*/
35692
35693 var test = QUnit.test;
35694
35695 function module (name, lifecycle) {
35696 QUnit.module(name, {
35697 setup : function () {
35698 moment.locale('en');
35699 moment.createFromInputFallback = function () {
35700 throw new Error('input not handled by moment');
35701 };
35702 if (lifecycle && lifecycle.setup) {
35703 lifecycle.setup();
35704 }
35705 },
35706 teardown : function () {
35707 if (lifecycle && lifecycle.teardown) {
35708 lifecycle.teardown();
35709 }
35710 }
35711 });
35712 }
35713
35714 function localeModule (name, lifecycle) {
35715 QUnit.module('locale:' + name, {
35716 setup : function () {
35717 moment.locale(name);
35718 moment.createFromInputFallback = function () {
35719 throw new Error('input not handled by moment');
35720 };
35721 if (lifecycle && lifecycle.setup) {
35722 lifecycle.setup();
35723 }
35724 },
35725 teardown : function () {
35726 moment.locale('en');
35727 if (lifecycle && lifecycle.teardown) {
35728 lifecycle.teardown();
35729 }
35730 }
35731 });
35732 }
35733
35734 module('is moment');
35735
35736 test('is moment object', function (assert) {
35737 var MyObj = function () {},
35738 extend = function (a, b) {
35739 var i;
35740 for (i in b) {
35741 a[i] = b[i];
35742 }
35743 return a;
35744 };
35745 MyObj.prototype.toDate = function () {
35746 return new Date();
35747 };
35748
35749 assert.ok(moment.isMoment(moment()), 'simple moment object');
35750 assert.ok(moment.isMoment(moment(null)), 'invalid moment object');
35751 assert.ok(moment.isMoment(extend({}, moment())), 'externally cloned moments are moments');
35752 assert.ok(moment.isMoment(extend({}, moment.utc())), 'externally cloned utc moments are moments');
35753
35754 assert.ok(!moment.isMoment(new MyObj()), 'myObj is not moment object');
35755 assert.ok(!moment.isMoment(moment), 'moment function is not moment object');
35756 assert.ok(!moment.isMoment(new Date()), 'date object is not moment object');
35757 assert.ok(!moment.isMoment(Object), 'Object is not moment object');
35758 assert.ok(!moment.isMoment('foo'), 'string is not moment object');
35759 assert.ok(!moment.isMoment(1), 'number is not moment object');
35760 assert.ok(!moment.isMoment(NaN), 'NaN is not moment object');
35761 assert.ok(!moment.isMoment(null), 'null is not moment object');
35762 assert.ok(!moment.isMoment(undefined), 'undefined is not moment object');
35763 });
35764
35765 test('is moment with hacked hasOwnProperty', function (assert) {
35766 var obj = {};
35767 // HACK to suppress jshint warning about bad property name
35768 obj['hasOwnMoney'.replace('Money', 'Property')] = function () {
35769 return true;
35770 };
35771
35772 assert.ok(!moment.isMoment(obj), 'isMoment works even if passed object has a wrong hasOwnProperty implementation (ie8)');
35773 });
35774
35775 }));
35776
35777 (function (global, factory) {
35778 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
35779 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
35780 factory(global.moment)
35781 }(this, function (moment) { 'use strict';
35782
35783 /*global QUnit:false*/
35784
35785 var test = QUnit.test;
35786
35787 function module (name, lifecycle) {
35788 QUnit.module(name, {
35789 setup : function () {
35790 moment.locale('en');
35791 moment.createFromInputFallback = function () {
35792 throw new Error('input not handled by moment');
35793 };
35794 if (lifecycle && lifecycle.setup) {
35795 lifecycle.setup();
35796 }
35797 },
35798 teardown : function () {
35799 if (lifecycle && lifecycle.teardown) {
35800 lifecycle.teardown();
35801 }
35802 }
35803 });
35804 }
35805
35806 function localeModule (name, lifecycle) {
35807 QUnit.module('locale:' + name, {
35808 setup : function () {
35809 moment.locale(name);
35810 moment.createFromInputFallback = function () {
35811 throw new Error('input not handled by moment');
35812 };
35813 if (lifecycle && lifecycle.setup) {
35814 lifecycle.setup();
35815 }
35816 },
35817 teardown : function () {
35818 moment.locale('en');
35819 if (lifecycle && lifecycle.teardown) {
35820 lifecycle.teardown();
35821 }
35822 }
35823 });
35824 }
35825
35826 module('is same');
35827
35828 test('is same without units', function (assert) {
35829 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35830 assert.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, 'year is later');
35831 assert.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, 'year is earlier');
35832 assert.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, 'month is later');
35833 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, 'month is earlier');
35834 assert.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, 'day is later');
35835 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, 'day is earlier');
35836 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, 'hour is later');
35837 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, 'hour is earlier');
35838 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, 'minute is later');
35839 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, 'minute is earlier');
35840 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, 'second is later');
35841 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, 'second is earlier');
35842 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), true, 'millisecond match');
35843 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, 'millisecond is later');
35844 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, 'millisecond is earlier');
35845 assert.equal(m.isSame(m), true, 'moments are the same as themselves');
35846 assert.equal(+m, +mCopy, 'isSame second should not change moment');
35847 });
35848
35849 test('is same year', function (assert) {
35850 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35851 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year match');
35852 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
35853 assert.equal(m.isSame(moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year mismatch');
35854 assert.equal(m.isSame(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), true, 'exact start of year');
35855 assert.equal(m.isSame(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), true, 'exact end of year');
35856 assert.equal(m.isSame(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), false, 'start of next year');
35857 assert.equal(m.isSame(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of previous year');
35858 assert.equal(m.isSame(m, 'year'), true, 'same moments are in the same year');
35859 assert.equal(+m, +mCopy, 'isSame year should not change moment');
35860 });
35861
35862 test('is same month', function (assert) {
35863 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
35864 assert.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), true, 'month match');
35865 assert.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
35866 assert.equal(m.isSame(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year mismatch');
35867 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), false, 'month mismatch');
35868 assert.equal(m.isSame(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), true, 'exact start of month');
35869 assert.equal(m.isSame(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), true, 'exact end of month');
35870 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), false, 'start of next month');
35871 assert.equal(m.isSame(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), false, 'end of previous month');
35872 assert.equal(m.isSame(m, 'month'), true, 'same moments are in the same month');
35873 assert.equal(+m, +mCopy, 'isSame month should not change moment');
35874 });
35875
35876 test('is same day', function (assert) {
35877 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35878 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), true, 'day match');
35879 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');
35880 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 7, 8, 9, 10)), 'day'), false, 'year mismatch');
35881 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), false, 'month mismatch');
35882 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day'), false, 'day mismatch');
35883 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 0, 0, 0, 0)), 'day'), true, 'exact start of day');
35884 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 23, 59, 59, 999)), 'day'), true, 'exact end of day');
35885 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 0, 0, 0, 0)), 'day'), false, 'start of next day');
35886 assert.equal(m.isSame(moment(new Date(2011, 1, 1, 23, 59, 59, 999)), 'day'), false, 'end of previous day');
35887 assert.equal(m.isSame(m, 'day'), true, 'same moments are in the same day');
35888 assert.equal(+m, +mCopy, 'isSame day should not change moment');
35889 });
35890
35891 test('is same hour', function (assert) {
35892 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35893 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), true, 'hour match');
35894 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');
35895 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 8, 9, 10)), 'hour'), false, 'year mismatch');
35896 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 8, 9, 10)), 'hour'), false, 'month mismatch');
35897 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 8, 9, 10)), 'hour'), false, 'day mismatch');
35898 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 8, 9, 10)), 'hour'), false, 'hour mismatch');
35899 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 0, 0, 0)), 'hour'), true, 'exact start of hour');
35900 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 59, 59, 999)), 'hour'), true, 'exact end of hour');
35901 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour'), false, 'start of next hour');
35902 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 2, 59, 59, 999)), 'hour'), false, 'end of previous hour');
35903 assert.equal(m.isSame(m, 'hour'), true, 'same moments are in the same hour');
35904 assert.equal(+m, +mCopy, 'isSame hour should not change moment');
35905 });
35906
35907 test('is same minute', function (assert) {
35908 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35909 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute'), true, 'minute match');
35910 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');
35911 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 9, 10)), 'minute'), false, 'year mismatch');
35912 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), false, 'month mismatch');
35913 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 9, 10)), 'minute'), false, 'day mismatch');
35914 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 9, 10)), 'minute'), false, 'hour mismatch');
35915 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minute'), false, 'minute mismatch');
35916 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 0, 0)), 'minute'), true, 'exact start of minute');
35917 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 59, 999)), 'minute'), true, 'exact end of minute');
35918 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute'), false, 'start of next minute');
35919 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute'), false, 'end of previous minute');
35920 assert.equal(m.isSame(m, 'minute'), true, 'same moments are in the same minute');
35921 assert.equal(+m, +mCopy, 'isSame minute should not change moment');
35922 });
35923
35924 test('is same second', function (assert) {
35925 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
35926 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second'), true, 'second match');
35927 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');
35928 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 5, 10)), 'second'), false, 'year mismatch');
35929 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), false, 'month mismatch');
35930 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 5, 10)), 'second'), false, 'day mismatch');
35931 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 5, 10)), 'second'), false, 'hour mismatch');
35932 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 5, 10)), 'second'), false, 'minute mismatch');
35933 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 10)), 'second'), false, 'second mismatch');
35934 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 0)), 'second'), true, 'exact start of second');
35935 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 999)), 'second'), true, 'exact end of second');
35936 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second'), false, 'start of next second');
35937 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second'), false, 'end of previous second');
35938 assert.equal(m.isSame(m, 'second'), true, 'same moments are in the same second');
35939 assert.equal(+m, +mCopy, 'isSame second should not change moment');
35940 });
35941
35942 test('is same millisecond', function (assert) {
35943 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
35944 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'millisecond match');
35945 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'plural should work');
35946 assert.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is later');
35947 assert.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is earlier');
35948 assert.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is later');
35949 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is earlier');
35950 assert.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), false, 'day is later');
35951 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), false, 'day is earlier');
35952 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), false, 'hour is later');
35953 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), false, 'hour is earlier');
35954 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), false, 'minute is later');
35955 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), false, 'minute is earlier');
35956 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), false, 'second is later');
35957 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), false, 'second is earlier');
35958 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), false, 'millisecond is later');
35959 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), false, 'millisecond is earlier');
35960 assert.equal(m.isSame(m, 'millisecond'), true, 'same moments are in the same millisecond');
35961 assert.equal(+m, +mCopy, 'isSame millisecond should not change moment');
35962 });
35963
35964 test('is same with utc offset moments', function (assert) {
35965 assert.ok(moment.parseZone('2013-02-01T-05:00').isSame(moment('2013-02-01'), 'year'), 'zoned vs local moment');
35966 assert.ok(moment('2013-02-01').isSame(moment('2013-02-01').utcOffset('-05:00'), 'year'), 'local vs zoned moment');
35967 assert.ok(moment.parseZone('2013-02-01T-05:00').isSame(moment.parseZone('2013-02-01T-06:30'), 'year'),
35968 'zoned vs (differently) zoned moment');
35969 });
35970
35971 test('is same with invalid moments', function (assert) {
35972 assert.equal(moment.invalid().isSame(moment.invalid()), false, 'invalid moments are not considered equal');
35973 });
35974
35975 }));
35976
35977 (function (global, factory) {
35978 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
35979 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
35980 factory(global.moment)
35981 }(this, function (moment) { 'use strict';
35982
35983 /*global QUnit:false*/
35984
35985 var test = QUnit.test;
35986
35987 function module (name, lifecycle) {
35988 QUnit.module(name, {
35989 setup : function () {
35990 moment.locale('en');
35991 moment.createFromInputFallback = function () {
35992 throw new Error('input not handled by moment');
35993 };
35994 if (lifecycle && lifecycle.setup) {
35995 lifecycle.setup();
35996 }
35997 },
35998 teardown : function () {
35999 if (lifecycle && lifecycle.teardown) {
36000 lifecycle.teardown();
36001 }
36002 }
36003 });
36004 }
36005
36006 function localeModule (name, lifecycle) {
36007 QUnit.module('locale:' + name, {
36008 setup : function () {
36009 moment.locale(name);
36010 moment.createFromInputFallback = function () {
36011 throw new Error('input not handled by moment');
36012 };
36013 if (lifecycle && lifecycle.setup) {
36014 lifecycle.setup();
36015 }
36016 },
36017 teardown : function () {
36018 moment.locale('en');
36019 if (lifecycle && lifecycle.teardown) {
36020 lifecycle.teardown();
36021 }
36022 }
36023 });
36024 }
36025
36026 module('is valid');
36027
36028 test('array bad month', function (assert) {
36029 assert.equal(moment([2010, -1]).isValid(), false, 'month -1 invalid');
36030 assert.equal(moment([2100, 12]).isValid(), false, 'month 12 invalid');
36031 });
36032
36033 test('array good month', function (assert) {
36034 for (var i = 0; i < 12; i++) {
36035 assert.equal(moment([2010, i]).isValid(), true, 'month ' + i);
36036 assert.equal(moment.utc([2010, i]).isValid(), true, 'month ' + i);
36037 }
36038 });
36039
36040 test('array bad date', function (assert) {
36041 var tests = [
36042 moment([2010, 0, 0]),
36043 moment([2100, 0, 32]),
36044 moment.utc([2010, 0, 0]),
36045 moment.utc([2100, 0, 32])
36046 ],
36047 i, m;
36048
36049 for (i in tests) {
36050 m = tests[i];
36051 assert.equal(m.isValid(), false);
36052 }
36053 });
36054
36055 test('h/hh with hour > 12', function (assert) {
36056 assert.ok(moment('06/20/2014 11:51 PM', 'MM/DD/YYYY hh:mm A', true).isValid(), '11 for hh');
36057 assert.ok(moment('06/20/2014 11:51 AM', 'MM/DD/YYYY hh:mm A', true).isValid(), '11 for hh');
36058 assert.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A').isValid(), 'non-strict validity 23 for hh');
36059 assert.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A').parsingFlags().bigHour, 'non-strict bigHour 23 for hh');
36060 assert.ok(!moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A', true).isValid(), 'validity 23 for hh');
36061 assert.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A', true).parsingFlags().bigHour, 'bigHour 23 for hh');
36062 });
36063
36064 test('array bad date leap year', function (assert) {
36065 assert.equal(moment([2010, 1, 29]).isValid(), false, '2010 feb 29');
36066 assert.equal(moment([2100, 1, 29]).isValid(), false, '2100 feb 29');
36067 assert.equal(moment([2008, 1, 30]).isValid(), false, '2008 feb 30');
36068 assert.equal(moment([2000, 1, 30]).isValid(), false, '2000 feb 30');
36069
36070 assert.equal(moment.utc([2010, 1, 29]).isValid(), false, 'utc 2010 feb 29');
36071 assert.equal(moment.utc([2100, 1, 29]).isValid(), false, 'utc 2100 feb 29');
36072 assert.equal(moment.utc([2008, 1, 30]).isValid(), false, 'utc 2008 feb 30');
36073 assert.equal(moment.utc([2000, 1, 30]).isValid(), false, 'utc 2000 feb 30');
36074 });
36075
36076 test('string + formats bad date', function (assert) {
36077 assert.equal(moment('2020-00-00', []).isValid(), false, 'invalid on empty array');
36078 assert.equal(moment('2020-00-00', ['YYYY-MM-DD', 'DD-MM-YYYY']).isValid(), false, 'invalid on all in array');
36079 assert.equal(moment('2020-00-00', ['DD-MM-YYYY', 'YYYY-MM-DD']).isValid(), false, 'invalid on all in array');
36080 assert.equal(moment('2020-01-01', ['YYYY-MM-DD', 'DD-MM-YYYY']).isValid(), true, 'valid on first');
36081 assert.equal(moment('2020-01-01', ['DD-MM-YYYY', 'YYYY-MM-DD']).isValid(), true, 'valid on last');
36082 assert.equal(moment('2020-01-01', ['YYYY-MM-DD', 'YYYY-DD-MM']).isValid(), true, 'valid on both');
36083 assert.equal(moment('2020-13-01', ['YYYY-MM-DD', 'YYYY-DD-MM']).isValid(), true, 'valid on last');
36084
36085 assert.equal(moment('12-13-2012', ['DD-MM-YYYY', 'YYYY-MM-DD']).isValid(), false, 'month rollover');
36086 assert.equal(moment('12-13-2012', ['DD-MM-YYYY', 'DD-MM-YYYY']).isValid(), false, 'month rollover');
36087 assert.equal(moment('38-12-2012', ['DD-MM-YYYY']).isValid(), false, 'day rollover');
36088 });
36089
36090 test('string nonsensical with format', function (assert) {
36091 assert.equal(moment('fail', 'MM-DD-YYYY').isValid(), false, 'string \'fail\' with format \'MM-DD-YYYY\'');
36092 assert.equal(moment('xx-xx-2001', 'DD-MM-YYY').isValid(), true, 'string \'xx-xx-2001\' with format \'MM-DD-YYYY\'');
36093 });
36094
36095 test('string with bad month name', function (assert) {
36096 assert.equal(moment('01-Nam-2012', 'DD-MMM-YYYY').isValid(), false, '\'Nam\' is an invalid month');
36097 assert.equal(moment('01-Aug-2012', 'DD-MMM-YYYY').isValid(), true, '\'Aug\' is a valid month');
36098 });
36099
36100 test('string with spaceless format', function (assert) {
36101 assert.equal(moment('10Sep2001', 'DDMMMYYYY').isValid(), true, 'Parsing 10Sep2001 should result in a valid date');
36102 });
36103
36104 test('invalid string iso 8601', function (assert) {
36105 var tests = [
36106 '2010-00-00',
36107 '2010-01-00',
36108 '2010-01-40',
36109 '2010-01-01T24:01', // 24:00:00 is actually valid
36110 '2010-01-01T23:60',
36111 '2010-01-01T23:59:60'
36112 ], i;
36113
36114 for (i = 0; i < tests.length; i++) {
36115 assert.equal(moment(tests[i]).isValid(), false, tests[i] + ' should be invalid');
36116 assert.equal(moment.utc(tests[i]).isValid(), false, tests[i] + ' should be invalid');
36117 }
36118 });
36119
36120 test('invalid string iso 8601 + timezone', function (assert) {
36121 var tests = [
36122 '2010-00-00T+00:00',
36123 '2010-01-00T+00:00',
36124 '2010-01-40T+00:00',
36125 '2010-01-40T24:01+00:00',
36126 '2010-01-40T23:60+00:00',
36127 '2010-01-40T23:59:60+00:00',
36128 '2010-01-40T23:59:59.9999+00:00'
36129 ], i;
36130
36131 for (i = 0; i < tests.length; i++) {
36132 assert.equal(moment(tests[i]).isValid(), false, tests[i] + ' should be invalid');
36133 assert.equal(moment.utc(tests[i]).isValid(), false, tests[i] + ' should be invalid');
36134 }
36135 });
36136
36137 test('valid string iso 8601 + timezone', function (assert) {
36138 var tests = [
36139 '2010-01-01',
36140 '2010-01-30',
36141 '2010-01-30T23+00:00',
36142 '2010-01-30T23:59+00:00',
36143 '2010-01-30T23:59:59+00:00',
36144 '2010-01-30T23:59:59.999+00:00',
36145 '2010-01-30T23:59:59.999-07:00',
36146 '2010-01-30T00:00:00.000+07:00',
36147 '2010-01-30 00:00:00.000Z'
36148 ], i;
36149
36150 for (i = 0; i < tests.length; i++) {
36151 assert.equal(moment(tests[i]).isValid(), true, tests[i] + ' should be valid in normal');
36152 assert.equal(moment.utc(tests[i]).isValid(), true, tests[i] + ' should be valid in normal');
36153 assert.equal(moment(tests[i], moment.ISO_8601, true).isValid(), true, tests[i] + ' should be valid in strict');
36154 assert.equal(moment.utc(tests[i], moment.ISO_8601, true).isValid(), true, tests[i] + ' should be valid in strict');
36155 }
36156 });
36157
36158 test('invalidAt', function (assert) {
36159 assert.equal(moment([2000, 12]).invalidAt(), 1, 'month 12 is invalid: 0-11');
36160 assert.equal(moment([2000, 1, 30]).invalidAt(), 2, '30 is not a valid february day');
36161 assert.equal(moment([2000, 1, 29, 25]).invalidAt(), 3, '25 is invalid hour');
36162 assert.equal(moment([2000, 1, 29, 24, 1]).invalidAt(), 3, '24:01 is invalid hour');
36163 assert.equal(moment([2000, 1, 29, 23, 60]).invalidAt(), 4, '60 is invalid minute');
36164 assert.equal(moment([2000, 1, 29, 23, 59, 60]).invalidAt(), 5, '60 is invalid second');
36165 assert.equal(moment([2000, 1, 29, 23, 59, 59, 1000]).invalidAt(), 6, '1000 is invalid millisecond');
36166 assert.equal(moment([2000, 1, 29, 23, 59, 59, 999]).invalidAt(), -1, '-1 if everything is fine');
36167 });
36168
36169 test('valid Unix timestamp', function (assert) {
36170 assert.equal(moment(1371065286, 'X').isValid(), true, 'number integer');
36171 assert.equal(moment(1379066897.0, 'X').isValid(), true, 'number whole 1dp');
36172 assert.equal(moment(1379066897.7, 'X').isValid(), true, 'number 1dp');
36173 assert.equal(moment(1379066897.00, 'X').isValid(), true, 'number whole 2dp');
36174 assert.equal(moment(1379066897.07, 'X').isValid(), true, 'number 2dp');
36175 assert.equal(moment(1379066897.17, 'X').isValid(), true, 'number 2dp');
36176 assert.equal(moment(1379066897.000, 'X').isValid(), true, 'number whole 3dp');
36177 assert.equal(moment(1379066897.007, 'X').isValid(), true, 'number 3dp');
36178 assert.equal(moment(1379066897.017, 'X').isValid(), true, 'number 3dp');
36179 assert.equal(moment(1379066897.157, 'X').isValid(), true, 'number 3dp');
36180 assert.equal(moment('1371065286', 'X').isValid(), true, 'string integer');
36181 assert.equal(moment('1379066897.', 'X').isValid(), true, 'string trailing .');
36182 assert.equal(moment('1379066897.0', 'X').isValid(), true, 'string whole 1dp');
36183 assert.equal(moment('1379066897.7', 'X').isValid(), true, 'string 1dp');
36184 assert.equal(moment('1379066897.00', 'X').isValid(), true, 'string whole 2dp');
36185 assert.equal(moment('1379066897.07', 'X').isValid(), true, 'string 2dp');
36186 assert.equal(moment('1379066897.17', 'X').isValid(), true, 'string 2dp');
36187 assert.equal(moment('1379066897.000', 'X').isValid(), true, 'string whole 3dp');
36188 assert.equal(moment('1379066897.007', 'X').isValid(), true, 'string 3dp');
36189 assert.equal(moment('1379066897.017', 'X').isValid(), true, 'string 3dp');
36190 assert.equal(moment('1379066897.157', 'X').isValid(), true, 'string 3dp');
36191 });
36192
36193 test('invalid Unix timestamp', function (assert) {
36194 assert.equal(moment(undefined, 'X').isValid(), false, 'undefined');
36195 assert.equal(moment('undefined', 'X').isValid(), false, 'string undefined');
36196 try {
36197 assert.equal(moment(null, 'X').isValid(), false, 'null');
36198 } catch (e) {
36199 assert.ok(true, 'null');
36200 }
36201
36202 assert.equal(moment('null', 'X').isValid(), false, 'string null');
36203 assert.equal(moment([], 'X').isValid(), false, 'array');
36204 assert.equal(moment('{}', 'X').isValid(), false, 'object');
36205 try {
36206 assert.equal(moment('', 'X').isValid(), false, 'string empty');
36207 } catch (e) {
36208 assert.ok(true, 'string empty');
36209 }
36210
36211 assert.equal(moment(' ', 'X').isValid(), false, 'string space');
36212 });
36213
36214 test('valid Unix offset milliseconds', function (assert) {
36215 assert.equal(moment(1234567890123, 'x').isValid(), true, 'number integer');
36216 assert.equal(moment('1234567890123', 'x').isValid(), true, 'string integer');
36217 });
36218
36219 test('invalid Unix offset milliseconds', function (assert) {
36220 assert.equal(moment(undefined, 'x').isValid(), false, 'undefined');
36221 assert.equal(moment('undefined', 'x').isValid(), false, 'string undefined');
36222 try {
36223 assert.equal(moment(null, 'x').isValid(), false, 'null');
36224 } catch (e) {
36225 assert.ok(true, 'null');
36226 }
36227
36228 assert.equal(moment('null', 'x').isValid(), false, 'string null');
36229 assert.equal(moment([], 'x').isValid(), false, 'array');
36230 assert.equal(moment('{}', 'x').isValid(), false, 'object');
36231 try {
36232 assert.equal(moment('', 'x').isValid(), false, 'string empty');
36233 } catch (e) {
36234 assert.ok(true, 'string empty');
36235 }
36236
36237 assert.equal(moment(' ', 'x').isValid(), false, 'string space');
36238 });
36239
36240 test('empty', function (assert) {
36241 assert.equal(moment(null).isValid(), false, 'null');
36242 assert.equal(moment('').isValid(), false, 'empty string');
36243 assert.equal(moment(null, 'YYYY').isValid(), false, 'format + null');
36244 assert.equal(moment('', 'YYYY').isValid(), false, 'format + empty string');
36245 assert.equal(moment(' ', 'YYYY').isValid(), false, 'format + empty when trimmed');
36246 });
36247
36248 test('days of the year', function (assert) {
36249 assert.equal(moment('2010 300', 'YYYY DDDD').isValid(), true, 'day 300 of year valid');
36250 assert.equal(moment('2010 365', 'YYYY DDDD').isValid(), true, 'day 365 of year valid');
36251 assert.equal(moment('2010 366', 'YYYY DDDD').isValid(), false, 'day 366 of year invalid');
36252 assert.equal(moment('2012 365', 'YYYY DDDD').isValid(), true, 'day 365 of leap year valid');
36253 assert.equal(moment('2012 366', 'YYYY DDDD').isValid(), true, 'day 366 of leap year valid');
36254 assert.equal(moment('2012 367', 'YYYY DDDD').isValid(), false, 'day 367 of leap year invalid');
36255 });
36256
36257 test('24:00:00.000 is valid', function (assert) {
36258 assert.equal(moment('2014-01-01 24', 'YYYY-MM-DD HH').isValid(), true, '24 is valid');
36259 assert.equal(moment('2014-01-01 24:00', 'YYYY-MM-DD HH:mm').isValid(), true, '24:00 is valid');
36260 assert.equal(moment('2014-01-01 24:01', 'YYYY-MM-DD HH:mm').isValid(), false, '24:01 is not valid');
36261 });
36262
36263 test('oddball permissiveness', function (assert) {
36264 //https://github.com/moment/moment/issues/1128
36265 assert.ok(moment('2010-10-3199', ['MM/DD/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']).isValid());
36266
36267 //https://github.com/moment/moment/issues/1122
36268 assert.ok(moment('3:25', ['h:mma', 'hh:mma', 'H:mm', 'HH:mm']).isValid());
36269 });
36270
36271 test('0 hour is invalid in strict', function (assert) {
36272 assert.equal(moment('00:01', 'hh:mm', true).isValid(), false, '00 hour is invalid in strict');
36273 assert.equal(moment('00:01', 'hh:mm').isValid(), true, '00 hour is valid in normal');
36274 assert.equal(moment('0:01', 'h:mm', true).isValid(), false, '0 hour is invalid in strict');
36275 assert.equal(moment('0:01', 'h:mm').isValid(), true, '0 hour is valid in normal');
36276 });
36277
36278 }));
36279
36280 (function (global, factory) {
36281 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
36282 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
36283 factory(global.moment)
36284 }(this, function (moment) { 'use strict';
36285
36286 /*global QUnit:false*/
36287
36288 var test = QUnit.test;
36289
36290 function module (name, lifecycle) {
36291 QUnit.module(name, {
36292 setup : function () {
36293 moment.locale('en');
36294 moment.createFromInputFallback = function () {
36295 throw new Error('input not handled by moment');
36296 };
36297 if (lifecycle && lifecycle.setup) {
36298 lifecycle.setup();
36299 }
36300 },
36301 teardown : function () {
36302 if (lifecycle && lifecycle.teardown) {
36303 lifecycle.teardown();
36304 }
36305 }
36306 });
36307 }
36308
36309 function localeModule (name, lifecycle) {
36310 QUnit.module('locale:' + name, {
36311 setup : function () {
36312 moment.locale(name);
36313 moment.createFromInputFallback = function () {
36314 throw new Error('input not handled by moment');
36315 };
36316 if (lifecycle && lifecycle.setup) {
36317 lifecycle.setup();
36318 }
36319 },
36320 teardown : function () {
36321 moment.locale('en');
36322 if (lifecycle && lifecycle.teardown) {
36323 lifecycle.teardown();
36324 }
36325 }
36326 });
36327 }
36328
36329 module('leap year');
36330
36331 test('leap year', function (assert) {
36332 assert.equal(moment([2010, 0, 1]).isLeapYear(), false, '2010');
36333 assert.equal(moment([2100, 0, 1]).isLeapYear(), false, '2100');
36334 assert.equal(moment([2008, 0, 1]).isLeapYear(), true, '2008');
36335 assert.equal(moment([2000, 0, 1]).isLeapYear(), true, '2000');
36336 });
36337
36338 }));
36339
36340 (function (global, factory) {
36341 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
36342 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
36343 factory(global.moment)
36344 }(this, function (moment) { 'use strict';
36345
36346 /*global QUnit:false*/
36347
36348 var test = QUnit.test;
36349
36350 function module (name, lifecycle) {
36351 QUnit.module(name, {
36352 setup : function () {
36353 moment.locale('en');
36354 moment.createFromInputFallback = function () {
36355 throw new Error('input not handled by moment');
36356 };
36357 if (lifecycle && lifecycle.setup) {
36358 lifecycle.setup();
36359 }
36360 },
36361 teardown : function () {
36362 if (lifecycle && lifecycle.teardown) {
36363 lifecycle.teardown();
36364 }
36365 }
36366 });
36367 }
36368
36369 function localeModule (name, lifecycle) {
36370 QUnit.module('locale:' + name, {
36371 setup : function () {
36372 moment.locale(name);
36373 moment.createFromInputFallback = function () {
36374 throw new Error('input not handled by moment');
36375 };
36376 if (lifecycle && lifecycle.setup) {
36377 lifecycle.setup();
36378 }
36379 },
36380 teardown : function () {
36381 moment.locale('en');
36382 if (lifecycle && lifecycle.teardown) {
36383 lifecycle.teardown();
36384 }
36385 }
36386 });
36387 }
36388
36389 module('listers');
36390
36391 test('default', function (assert) {
36392 assert.deepEqual(moment.months(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
36393 assert.deepEqual(moment.monthsShort(), ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
36394 assert.deepEqual(moment.weekdays(), ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']);
36395 assert.deepEqual(moment.weekdaysShort(), ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
36396 assert.deepEqual(moment.weekdaysMin(), ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']);
36397 });
36398
36399 test('index', function (assert) {
36400 assert.equal(moment.months(0), 'January');
36401 assert.equal(moment.months(2), 'March');
36402 assert.equal(moment.monthsShort(0), 'Jan');
36403 assert.equal(moment.monthsShort(2), 'Mar');
36404 assert.equal(moment.weekdays(0), 'Sunday');
36405 assert.equal(moment.weekdays(2), 'Tuesday');
36406 assert.equal(moment.weekdaysShort(0), 'Sun');
36407 assert.equal(moment.weekdaysShort(2), 'Tue');
36408 assert.equal(moment.weekdaysMin(0), 'Su');
36409 assert.equal(moment.weekdaysMin(2), 'Tu');
36410 });
36411
36412 test('localized', function (assert) {
36413 var months = 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_'),
36414 monthsShort = 'on_tw_th_fo_fi_si_se_ei_ni_te_el_tw'.split('_'),
36415 weekdays = 'one_two_three_four_five_six_seven'.split('_'),
36416 weekdaysShort = 'on_tw_th_fo_fi_si_se'.split('_'),
36417 weekdaysMin = '1_2_3_4_5_6_7'.split('_');
36418
36419 moment.locale('numerologists', {
36420 months : months,
36421 monthsShort : monthsShort,
36422 weekdays : weekdays,
36423 weekdaysShort: weekdaysShort,
36424 weekdaysMin: weekdaysMin
36425 });
36426
36427 assert.deepEqual(moment.months(), months);
36428 assert.deepEqual(moment.monthsShort(), monthsShort);
36429 assert.deepEqual(moment.weekdays(), weekdays);
36430 assert.deepEqual(moment.weekdaysShort(), weekdaysShort);
36431 assert.deepEqual(moment.weekdaysMin(), weekdaysMin);
36432
36433 assert.equal(moment.months(0), 'one');
36434 assert.equal(moment.monthsShort(0), 'on');
36435 assert.equal(moment.weekdays(0), 'one');
36436 assert.equal(moment.weekdaysShort(0), 'on');
36437 assert.equal(moment.weekdaysMin(0), '1');
36438
36439 assert.equal(moment.months(2), 'three');
36440 assert.equal(moment.monthsShort(2), 'th');
36441 assert.equal(moment.weekdays(2), 'three');
36442 assert.equal(moment.weekdaysShort(2), 'th');
36443 assert.equal(moment.weekdaysMin(2), '3');
36444 });
36445
36446 test('with functions', function (assert) {
36447 var monthsShort = 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_'),
36448 monthsShortWeird = 'onesy_twosy_threesy_foursy_fivesy_sixsy_sevensy_eightsy_ninesy_tensy_elevensy_twelvesy'.split('_');
36449
36450 moment.locale('difficult', {
36451
36452 monthsShort: function (m, format) {
36453 var arr = format.match(/-MMM-/) ? monthsShortWeird : monthsShort;
36454 return arr[m.month()];
36455 }
36456 });
36457
36458 assert.deepEqual(moment.monthsShort(), monthsShort);
36459 assert.deepEqual(moment.monthsShort('MMM'), monthsShort);
36460 assert.deepEqual(moment.monthsShort('-MMM-'), monthsShortWeird);
36461
36462 assert.deepEqual(moment.monthsShort('MMM', 2), 'three');
36463 assert.deepEqual(moment.monthsShort('-MMM-', 2), 'threesy');
36464 assert.deepEqual(moment.monthsShort(2), 'three');
36465 });
36466
36467 }));
36468
36469 (function (global, factory) {
36470 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
36471 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
36472 factory(global.moment)
36473 }(this, function (moment) { 'use strict';
36474
36475 /*global QUnit:false*/
36476
36477 var test = QUnit.test;
36478
36479 function module (name, lifecycle) {
36480 QUnit.module(name, {
36481 setup : function () {
36482 moment.locale('en');
36483 moment.createFromInputFallback = function () {
36484 throw new Error('input not handled by moment');
36485 };
36486 if (lifecycle && lifecycle.setup) {
36487 lifecycle.setup();
36488 }
36489 },
36490 teardown : function () {
36491 if (lifecycle && lifecycle.teardown) {
36492 lifecycle.teardown();
36493 }
36494 }
36495 });
36496 }
36497
36498 function localeModule (name, lifecycle) {
36499 QUnit.module('locale:' + name, {
36500 setup : function () {
36501 moment.locale(name);
36502 moment.createFromInputFallback = function () {
36503 throw new Error('input not handled by moment');
36504 };
36505 if (lifecycle && lifecycle.setup) {
36506 lifecycle.setup();
36507 }
36508 },
36509 teardown : function () {
36510 moment.locale('en');
36511 if (lifecycle && lifecycle.teardown) {
36512 lifecycle.teardown();
36513 }
36514 }
36515 });
36516 }
36517
36518 function each(array, callback) {
36519 var i;
36520 for (i = 0; i < array.length; i++) {
36521 callback(array[i], i, array);
36522 }
36523 }
36524
36525 module('locale', {
36526 setup : function () {
36527 // TODO: Remove once locales are switched to ES6
36528 each([{
36529 name: 'en-gb',
36530 data: {}
36531 }, {
36532 name: 'en-ca',
36533 data: {}
36534 }, {
36535 name: 'es',
36536 data: {
36537 relativeTime: {past: 'hace %s', s: 'unos segundos', d: 'un día'},
36538 months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_')
36539 }
36540 }, {
36541 name: 'fr',
36542 data: {}
36543 }, {
36544 name: 'fr-ca',
36545 data: {}
36546 }, {
36547 name: 'it',
36548 data: {}
36549 }, {
36550 name: 'zh-cn',
36551 data: {
36552 months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_')
36553 }
36554 }], function (locale) {
36555 if (moment.locale(locale.name) !== locale.name) {
36556 moment.defineLocale(locale.name, locale.data);
36557 }
36558 });
36559 moment.locale('en');
36560 }
36561 });
36562
36563 test('library getters and setters', function (assert) {
36564 var r = moment.locale('en');
36565
36566 assert.equal(r, 'en', 'locale should return en by default');
36567 assert.equal(moment.locale(), 'en', 'locale should return en by default');
36568
36569 moment.locale('fr');
36570 assert.equal(moment.locale(), 'fr', 'locale should return the changed locale');
36571
36572 moment.locale('en-gb');
36573 assert.equal(moment.locale(), 'en-gb', 'locale should return the changed locale');
36574
36575 moment.locale('en');
36576 assert.equal(moment.locale(), 'en', 'locale should reset');
36577
36578 moment.locale('does-not-exist');
36579 assert.equal(moment.locale(), 'en', 'locale should reset');
36580
36581 moment.locale('EN');
36582 assert.equal(moment.locale(), 'en', 'Normalize locale key case');
36583
36584 moment.locale('EN_gb');
36585 assert.equal(moment.locale(), 'en-gb', 'Normalize locale key underscore');
36586 });
36587
36588 test('library setter array of locales', function (assert) {
36589 assert.equal(moment.locale(['non-existent', 'fr', 'also-non-existent']), 'fr', 'passing an array uses the first valid locale');
36590 assert.equal(moment.locale(['es', 'fr', 'also-non-existent']), 'es', 'passing an array uses the first valid locale');
36591 });
36592
36593 test('library setter locale substrings', function (assert) {
36594 assert.equal(moment.locale('fr-crap'), 'fr', 'use substrings');
36595 assert.equal(moment.locale('fr-does-not-exist'), 'fr', 'uses deep substrings');
36596 assert.equal(moment.locale('fr-CA-does-not-exist'), 'fr-ca', 'uses deepest substring');
36597 });
36598
36599 test('library getter locale array and substrings', function (assert) {
36600 assert.equal(moment.locale(['en-CH', 'fr']), 'en', 'prefer root locale to shallower ones');
36601 assert.equal(moment.locale(['en-gb-leeds', 'en-CA']), 'en-gb', 'prefer root locale to shallower ones');
36602 assert.equal(moment.locale(['en-fake', 'en-CA']), 'en-ca', 'prefer alternatives with shared roots');
36603 assert.equal(moment.locale(['en-fake', 'en-fake2', 'en-ca']), 'en-ca', 'prefer alternatives with shared roots');
36604 assert.equal(moment.locale(['fake-CA', 'fake-MX', 'fr']), 'fr', 'always find something if possible');
36605 assert.equal(moment.locale(['fake-CA', 'fake-MX', 'fr']), 'fr', 'always find something if possible');
36606 assert.equal(moment.locale(['fake-CA', 'fake-MX', 'fr-fake-fake-fake']), 'fr', 'always find something if possible');
36607 assert.equal(moment.locale(['en', 'en-CA']), 'en', 'prefer earlier if it works');
36608 });
36609
36610 test('library ensure inheritance', function (assert) {
36611 moment.locale('made-up', {
36612 // I put them out of order
36613 months : 'February_March_April_May_June_July_August_September_October_November_December_January'.split('_')
36614 // the rest of the properties should be inherited.
36615 });
36616
36617 assert.equal(moment([2012, 5, 6]).format('MMMM'), 'July', 'Override some of the configs');
36618 assert.equal(moment([2012, 5, 6]).format('MMM'), 'Jun', 'But not all of them');
36619 });
36620
36621 test('library ensure inheritance LT L LL LLL LLLL', function (assert) {
36622 var locale = 'test-inherit-lt';
36623
36624 moment.defineLocale(locale, {
36625 longDateFormat : {
36626 LT : '-[LT]-',
36627 L : '-[L]-',
36628 LL : '-[LL]-',
36629 LLL : '-[LLL]-',
36630 LLLL : '-[LLLL]-'
36631 },
36632 calendar : {
36633 sameDay : '[sameDay] LT',
36634 nextDay : '[nextDay] L',
36635 nextWeek : '[nextWeek] LL',
36636 lastDay : '[lastDay] LLL',
36637 lastWeek : '[lastWeek] LLLL',
36638 sameElse : 'L'
36639 }
36640 });
36641
36642 moment.locale('es');
36643
36644 assert.equal(moment().locale(locale).calendar(), 'sameDay -LT-', 'Should use instance locale in LT formatting');
36645 assert.equal(moment().add(1, 'days').locale(locale).calendar(), 'nextDay -L-', 'Should use instance locale in L formatting');
36646 assert.equal(moment().add(-1, 'days').locale(locale).calendar(), 'lastDay -LLL-', 'Should use instance locale in LL formatting');
36647 assert.equal(moment().add(4, 'days').locale(locale).calendar(), 'nextWeek -LL-', 'Should use instance locale in LLL formatting');
36648 assert.equal(moment().add(-4, 'days').locale(locale).calendar(), 'lastWeek -LLLL-', 'Should use instance locale in LLLL formatting');
36649 });
36650
36651 test('library localeData', function (assert) {
36652 moment.locale('en');
36653
36654 var jan = moment([2000, 0]);
36655
36656 assert.equal(moment.localeData().months(jan), 'January', 'no arguments returns global');
36657 assert.equal(moment.localeData('zh-cn').months(jan), '一月', 'a string returns the locale based on key');
36658 assert.equal(moment.localeData(moment().locale('es')).months(jan), 'Enero', 'if you pass in a moment it uses the moment\'s locale');
36659 });
36660
36661 test('library deprecations', function (assert) {
36662 moment.lang('dude', {months: ['Movember']});
36663 assert.equal(moment.locale(), 'dude', 'setting the lang sets the locale');
36664 assert.equal(moment.lang(), moment.locale());
36665 assert.equal(moment.langData(), moment.localeData(), 'langData is localeData');
36666 });
36667
36668 test('defineLocale', function (assert) {
36669 moment.locale('en');
36670 moment.defineLocale('dude', {months: ['Movember']});
36671 assert.equal(moment().locale(), 'dude', 'defineLocale also sets it');
36672 assert.equal(moment().locale('dude').locale(), 'dude', 'defineLocale defines a locale');
36673 });
36674
36675 test('library convenience', function (assert) {
36676 moment.locale('something', {week: {dow: 3}});
36677 moment.locale('something');
36678 assert.equal(moment.locale(), 'something', 'locale can be used to create the locale too');
36679 });
36680
36681 test('firstDayOfWeek firstDayOfYear locale getters', function (assert) {
36682 moment.locale('something', {week: {dow: 3, doy: 4}});
36683 moment.locale('something');
36684 assert.equal(moment.localeData().firstDayOfWeek(), 3, 'firstDayOfWeek');
36685 assert.equal(moment.localeData().firstDayOfYear(), 4, 'firstDayOfYear');
36686 });
36687
36688 test('instance locale method', function (assert) {
36689 moment.locale('en');
36690
36691 assert.equal(moment([2012, 5, 6]).format('MMMM'), 'June', 'Normally default to global');
36692 assert.equal(moment([2012, 5, 6]).locale('es').format('MMMM'), 'Junio', 'Use the instance specific locale');
36693 assert.equal(moment([2012, 5, 6]).format('MMMM'), 'June', 'Using an instance specific locale does not affect other moments');
36694 });
36695
36696 test('instance locale method with array', function (assert) {
36697 var m = moment().locale(['non-existent', 'fr', 'also-non-existent']);
36698 assert.equal(m.locale(), 'fr', 'passing an array uses the first valid locale');
36699 m = moment().locale(['es', 'fr', 'also-non-existent']);
36700 assert.equal(m.locale(), 'es', 'passing an array uses the first valid locale');
36701 });
36702
36703 test('instance getter locale substrings', function (assert) {
36704 var m = moment();
36705
36706 m.locale('fr-crap');
36707 assert.equal(m.locale(), 'fr', 'use substrings');
36708
36709 m.locale('fr-does-not-exist');
36710 assert.equal(m.locale(), 'fr', 'uses deep substrings');
36711 });
36712
36713 test('instance locale persists with manipulation', function (assert) {
36714 moment.locale('en');
36715
36716 assert.equal(moment([2012, 5, 6]).locale('es').add({days: 1}).format('MMMM'), 'Junio', 'With addition');
36717 assert.equal(moment([2012, 5, 6]).locale('es').day(0).format('MMMM'), 'Junio', 'With day getter');
36718 assert.equal(moment([2012, 5, 6]).locale('es').endOf('day').format('MMMM'), 'Junio', 'With endOf');
36719 });
36720
36721 test('instance locale persists with cloning', function (assert) {
36722 moment.locale('en');
36723
36724 var a = moment([2012, 5, 6]).locale('es'),
36725 b = a.clone(),
36726 c = moment(a);
36727
36728 assert.equal(b.format('MMMM'), 'Junio', 'using moment.fn.clone()');
36729 assert.equal(b.format('MMMM'), 'Junio', 'using moment()');
36730 });
36731
36732 test('duration locale method', function (assert) {
36733 moment.locale('en');
36734
36735 assert.equal(moment.duration({seconds: 44}).humanize(), 'a few seconds', 'Normally default to global');
36736 assert.equal(moment.duration({seconds: 44}).locale('es').humanize(), 'unos segundos', 'Use the instance specific locale');
36737 assert.equal(moment.duration({seconds: 44}).humanize(), 'a few seconds', 'Using an instance specific locale does not affect other durations');
36738 });
36739
36740 test('duration locale persists with cloning', function (assert) {
36741 moment.locale('en');
36742
36743 var a = moment.duration({seconds: 44}).locale('es'),
36744 b = moment.duration(a);
36745
36746 assert.equal(b.humanize(), 'unos segundos', 'using moment.duration()');
36747 });
36748
36749 test('changing the global locale doesn\'t affect existing duration instances', function (assert) {
36750 var mom = moment.duration();
36751 moment.locale('fr');
36752 assert.equal('en', mom.locale());
36753 });
36754
36755 test('duration deprecations', function (assert) {
36756 assert.equal(moment.duration().lang(), moment.duration().localeData(), 'duration.lang is the same as duration.localeData');
36757 });
36758
36759 test('from and fromNow with invalid date', function (assert) {
36760 assert.equal(moment(NaN).from(), 'Invalid date', 'moment.from with invalid moment');
36761 assert.equal(moment(NaN).fromNow(), 'Invalid date', 'moment.fromNow with invalid moment');
36762 });
36763
36764 test('from relative time future', function (assert) {
36765 var start = moment([2007, 1, 28]);
36766
36767 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 44})), 'in a few seconds', '44 seconds = a few seconds');
36768 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 45})), 'in a minute', '45 seconds = a minute');
36769 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 89})), 'in a minute', '89 seconds = a minute');
36770 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 90})), 'in 2 minutes', '90 seconds = 2 minutes');
36771 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 44})), 'in 44 minutes', '44 minutes = 44 minutes');
36772 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 45})), 'in an hour', '45 minutes = an hour');
36773 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 89})), 'in an hour', '89 minutes = an hour');
36774 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 90})), 'in 2 hours', '90 minutes = 2 hours');
36775 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 5})), 'in 5 hours', '5 hours = 5 hours');
36776 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 21})), 'in 21 hours', '21 hours = 21 hours');
36777 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 22})), 'in a day', '22 hours = a day');
36778 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 35})), 'in a day', '35 hours = a day');
36779 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 36})), 'in 2 days', '36 hours = 2 days');
36780 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 1})), 'in a day', '1 day = a day');
36781 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 5})), 'in 5 days', '5 days = 5 days');
36782 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 25})), 'in 25 days', '25 days = 25 days');
36783 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 26})), 'in a month', '26 days = a month');
36784 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 30})), 'in a month', '30 days = a month');
36785 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 45})), 'in a month', '45 days = a month');
36786 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 47})), 'in 2 months', '47 days = 2 months');
36787 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 74})), 'in 2 months', '74 days = 2 months');
36788 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 78})), 'in 3 months', '78 days = 3 months');
36789 assert.equal(start.from(moment([2007, 1, 28]).subtract({M: 1})), 'in a month', '1 month = a month');
36790 assert.equal(start.from(moment([2007, 1, 28]).subtract({M: 5})), 'in 5 months', '5 months = 5 months');
36791 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 315})), 'in 10 months', '315 days = 10 months');
36792 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 344})), 'in a year', '344 days = a year');
36793 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 345})), 'in a year', '345 days = a year');
36794 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 548})), 'in 2 years', '548 days = in 2 years');
36795 assert.equal(start.from(moment([2007, 1, 28]).subtract({y: 1})), 'in a year', '1 year = a year');
36796 assert.equal(start.from(moment([2007, 1, 28]).subtract({y: 5})), 'in 5 years', '5 years = 5 years');
36797 });
36798
36799 test('from relative time past', function (assert) {
36800 var start = moment([2007, 1, 28]);
36801
36802 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44})), 'a few seconds ago', '44 seconds = a few seconds');
36803 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45})), 'a minute ago', '45 seconds = a minute');
36804 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89})), 'a minute ago', '89 seconds = a minute');
36805 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90})), '2 minutes ago', '90 seconds = 2 minutes');
36806 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44})), '44 minutes ago', '44 minutes = 44 minutes');
36807 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45})), 'an hour ago', '45 minutes = an hour');
36808 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89})), 'an hour ago', '89 minutes = an hour');
36809 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90})), '2 hours ago', '90 minutes = 2 hours');
36810 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5})), '5 hours ago', '5 hours = 5 hours');
36811 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21})), '21 hours ago', '21 hours = 21 hours');
36812 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22})), 'a day ago', '22 hours = a day');
36813 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35})), 'a day ago', '35 hours = a day');
36814 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36})), '2 days ago', '36 hours = 2 days');
36815 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1})), 'a day ago', '1 day = a day');
36816 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5})), '5 days ago', '5 days = 5 days');
36817 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25})), '25 days ago', '25 days = 25 days');
36818 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26})), 'a month ago', '26 days = a month');
36819 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30})), 'a month ago', '30 days = a month');
36820 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43})), 'a month ago', '43 days = a month');
36821 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46})), '2 months ago', '46 days = 2 months');
36822 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74})), '2 months ago', '75 days = 2 months');
36823 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76})), '3 months ago', '76 days = 3 months');
36824 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1})), 'a month ago', '1 month = a month');
36825 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5})), '5 months ago', '5 months = 5 months');
36826 assert.equal(start.from(moment([2007, 1, 28]).add({d: 315})), '10 months ago', '315 days = 10 months');
36827 assert.equal(start.from(moment([2007, 1, 28]).add({d: 344})), 'a year ago', '344 days = a year');
36828 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345})), 'a year ago', '345 days = a year');
36829 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548})), '2 years ago', '548 days = 2 years');
36830 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1})), 'a year ago', '1 year = a year');
36831 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5})), '5 years ago', '5 years = 5 years');
36832 });
36833
36834 test('instance locale used with from', function (assert) {
36835 moment.locale('en');
36836
36837 var a = moment([2012, 5, 6]).locale('es'),
36838 b = moment([2012, 5, 7]);
36839
36840 assert.equal(a.from(b), 'hace un día', 'preserve locale of first moment');
36841 assert.equal(b.from(a), 'in a day', 'do not preserve locale of second moment');
36842 });
36843
36844 test('instance localeData', function (assert) {
36845 moment.defineLocale('dude', {week: {dow: 3}});
36846 assert.equal(moment().locale('dude').localeData()._week.dow, 3);
36847 });
36848
36849 test('month name callback function', function (assert) {
36850 function fakeReplace(m, format) {
36851 if (/test/.test(format)) {
36852 return 'test';
36853 }
36854 if (m.date() === 1) {
36855 return 'date';
36856 }
36857 return 'default';
36858 }
36859
36860 moment.locale('made-up-2', {
36861 months : fakeReplace,
36862 monthsShort : fakeReplace,
36863 weekdays : fakeReplace,
36864 weekdaysShort : fakeReplace,
36865 weekdaysMin : fakeReplace
36866 });
36867
36868 assert.equal(moment().format('[test] dd ddd dddd MMM MMMM'), 'test test test test test test', 'format month name function should be able to access the format string');
36869 assert.equal(moment([2011, 0, 1]).format('dd ddd dddd MMM MMMM'), 'date date date date date', 'format month name function should be able to access the moment object');
36870 assert.equal(moment([2011, 0, 2]).format('dd ddd dddd MMM MMMM'), 'default default default default default', 'format month name function should be able to access the moment object');
36871 });
36872
36873 test('changing parts of a locale config', function (assert) {
36874 moment.locale('partial-lang', {
36875 months : 'a b c d e f g h i j k l'.split(' ')
36876 });
36877
36878 assert.equal(moment([2011, 0, 1]).format('MMMM'), 'a', 'should be able to set locale values when creating the localeuage');
36879
36880 moment.locale('partial-lang', {
36881 monthsShort : 'A B C D E F G H I J K L'.split(' ')
36882 });
36883
36884 assert.equal(moment([2011, 0, 1]).format('MMMM MMM'), 'a A', 'should be able to set locale values after creating the localeuage');
36885 });
36886
36887 test('start/endOf week feature for first-day-is-monday locales', function (assert) {
36888 moment.locale('monday-lang', {
36889 week : {
36890 dow : 1 // Monday is the first day of the week
36891 }
36892 });
36893
36894 moment.locale('monday-lang');
36895 assert.equal(moment([2013, 0, 1]).startOf('week').day(), 1, 'for locale monday-lang first day of the week should be monday');
36896 assert.equal(moment([2013, 0, 1]).endOf('week').day(), 0, 'for locale monday-lang last day of the week should be sunday');
36897 });
36898
36899 test('meridiem parsing', function (assert) {
36900 moment.locale('meridiem-parsing', {
36901 meridiemParse : /[bd]/i,
36902 isPM : function (input) {
36903 return input === 'b';
36904 }
36905 });
36906
36907 moment.locale('meridiem-parsing');
36908 assert.equal(moment('2012-01-01 3b', 'YYYY-MM-DD ha').hour(), 15, 'Custom parsing of meridiem should work');
36909 assert.equal(moment('2012-01-01 3d', 'YYYY-MM-DD ha').hour(), 3, 'Custom parsing of meridiem should work');
36910 });
36911
36912 test('invalid date formatting', function (assert) {
36913 moment.locale('has-invalid', {
36914 invalidDate: 'KHAAAAAAAAAAAN!'
36915 });
36916
36917 assert.equal(moment.invalid().format(), 'KHAAAAAAAAAAAN!');
36918 assert.equal(moment.invalid().format('YYYY-MM-DD'), 'KHAAAAAAAAAAAN!');
36919 });
36920
36921 test('return locale name', function (assert) {
36922 var registered = moment.locale('return-this', {});
36923
36924 assert.equal(registered, 'return-this', 'returns the locale configured');
36925 });
36926
36927 test('changing the global locale doesn\'t affect existing instances', function (assert) {
36928 var mom = moment();
36929 moment.locale('fr');
36930 assert.equal('en', mom.locale());
36931 });
36932
36933 test('setting a language on instance returns the original moment for chaining', function (assert) {
36934 var mom = moment();
36935
36936 assert.equal(mom.lang('fr'), mom, 'setting the language (lang) returns the original moment for chaining');
36937 assert.equal(mom.locale('it'), mom, 'setting the language (locale) returns the original moment for chaining');
36938 });
36939
36940 test('lang(key) changes the language of the instance', function (assert) {
36941 var m = moment().month(0);
36942 m.lang('fr');
36943 assert.equal(m.locale(), 'fr', 'm.lang(key) changes instance locale');
36944 });
36945
36946 test('moment#locale(false) resets to global locale', function (assert) {
36947 var m = moment();
36948
36949 moment.locale('fr');
36950 m.locale('it');
36951
36952 assert.equal(moment.locale(), 'fr', 'global locale is it');
36953 assert.equal(m.locale(), 'it', 'instance locale is it');
36954 m.locale(false);
36955 assert.equal(m.locale(), 'fr', 'instance locale reset to global locale');
36956 });
36957
36958 test('moment().locale with missing key doesn\'t change locale', function (assert) {
36959 assert.equal(moment().locale('boo').localeData(), moment.localeData(),
36960 'preserve global locale in case of bad locale id');
36961 });
36962
36963 test('moment().lang with missing key doesn\'t change locale', function (assert) {
36964 assert.equal(moment().lang('boo').localeData(), moment.localeData(),
36965 'preserve global locale in case of bad locale id');
36966 });
36967
36968 }));
36969
36970 (function (global, factory) {
36971 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
36972 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
36973 factory(global.moment)
36974 }(this, function (moment) { 'use strict';
36975
36976 /*global QUnit:false*/
36977
36978 var test = QUnit.test;
36979
36980 function module (name, lifecycle) {
36981 QUnit.module(name, {
36982 setup : function () {
36983 moment.locale('en');
36984 moment.createFromInputFallback = function () {
36985 throw new Error('input not handled by moment');
36986 };
36987 if (lifecycle && lifecycle.setup) {
36988 lifecycle.setup();
36989 }
36990 },
36991 teardown : function () {
36992 if (lifecycle && lifecycle.teardown) {
36993 lifecycle.teardown();
36994 }
36995 }
36996 });
36997 }
36998
36999 function localeModule (name, lifecycle) {
37000 QUnit.module('locale:' + name, {
37001 setup : function () {
37002 moment.locale(name);
37003 moment.createFromInputFallback = function () {
37004 throw new Error('input not handled by moment');
37005 };
37006 if (lifecycle && lifecycle.setup) {
37007 lifecycle.setup();
37008 }
37009 },
37010 teardown : function () {
37011 moment.locale('en');
37012 if (lifecycle && lifecycle.teardown) {
37013 lifecycle.teardown();
37014 }
37015 }
37016 });
37017 }
37018
37019 module('min max');
37020
37021 test('min', function (assert) {
37022 var now = moment(),
37023 future = now.clone().add(1, 'month'),
37024 past = now.clone().subtract(1, 'month'),
37025 invalid = moment.invalid();
37026
37027 assert.equal(moment.min(now, future, past), past, 'min(now, future, past)');
37028 assert.equal(moment.min(future, now, past), past, 'min(future, now, past)');
37029 assert.equal(moment.min(future, past, now), past, 'min(future, past, now)');
37030 assert.equal(moment.min(past, future, now), past, 'min(past, future, now)');
37031 assert.equal(moment.min(now, past), past, 'min(now, past)');
37032 assert.equal(moment.min(past, now), past, 'min(past, now)');
37033 assert.equal(moment.min(now), now, 'min(now, past)');
37034
37035 assert.equal(moment.min([now, future, past]), past, 'min([now, future, past])');
37036 assert.equal(moment.min([now, past]), past, 'min(now, past)');
37037 assert.equal(moment.min([now]), now, 'min(now)');
37038
37039 assert.equal(moment.min([now, invalid]), invalid, 'min(now, invalid)');
37040 assert.equal(moment.min([invalid, now]), invalid, 'min(invalid, now)');
37041 });
37042
37043 test('max', function (assert) {
37044 var now = moment(),
37045 future = now.clone().add(1, 'month'),
37046 past = now.clone().subtract(1, 'month'),
37047 invalid = moment.invalid();
37048
37049 assert.equal(moment.max(now, future, past), future, 'max(now, future, past)');
37050 assert.equal(moment.max(future, now, past), future, 'max(future, now, past)');
37051 assert.equal(moment.max(future, past, now), future, 'max(future, past, now)');
37052 assert.equal(moment.max(past, future, now), future, 'max(past, future, now)');
37053 assert.equal(moment.max(now, past), now, 'max(now, past)');
37054 assert.equal(moment.max(past, now), now, 'max(past, now)');
37055 assert.equal(moment.max(now), now, 'max(now, past)');
37056
37057 assert.equal(moment.max([now, future, past]), future, 'max([now, future, past])');
37058 assert.equal(moment.max([now, past]), now, 'max(now, past)');
37059 assert.equal(moment.max([now]), now, 'max(now)');
37060
37061 assert.equal(moment.max([now, invalid]), invalid, 'max(now, invalid)');
37062 assert.equal(moment.max([invalid, now]), invalid, 'max(invalid, now)');
37063 });
37064
37065 }));
37066
37067 (function (global, factory) {
37068 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
37069 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
37070 factory(global.moment)
37071 }(this, function (moment) { 'use strict';
37072
37073 /*global QUnit:false*/
37074
37075 var test = QUnit.test;
37076
37077 function module (name, lifecycle) {
37078 QUnit.module(name, {
37079 setup : function () {
37080 moment.locale('en');
37081 moment.createFromInputFallback = function () {
37082 throw new Error('input not handled by moment');
37083 };
37084 if (lifecycle && lifecycle.setup) {
37085 lifecycle.setup();
37086 }
37087 },
37088 teardown : function () {
37089 if (lifecycle && lifecycle.teardown) {
37090 lifecycle.teardown();
37091 }
37092 }
37093 });
37094 }
37095
37096 function localeModule (name, lifecycle) {
37097 QUnit.module('locale:' + name, {
37098 setup : function () {
37099 moment.locale(name);
37100 moment.createFromInputFallback = function () {
37101 throw new Error('input not handled by moment');
37102 };
37103 if (lifecycle && lifecycle.setup) {
37104 lifecycle.setup();
37105 }
37106 },
37107 teardown : function () {
37108 moment.locale('en');
37109 if (lifecycle && lifecycle.teardown) {
37110 lifecycle.teardown();
37111 }
37112 }
37113 });
37114 }
37115
37116 module('mutable');
37117
37118 test('manipulation methods', function (assert) {
37119 var m = moment();
37120
37121 assert.equal(m, m.year(2011), 'year() should be mutable');
37122 assert.equal(m, m.month(1), 'month() should be mutable');
37123 assert.equal(m, m.hours(7), 'hours() should be mutable');
37124 assert.equal(m, m.minutes(33), 'minutes() should be mutable');
37125 assert.equal(m, m.seconds(44), 'seconds() should be mutable');
37126 assert.equal(m, m.milliseconds(55), 'milliseconds() should be mutable');
37127 assert.equal(m, m.day(2), 'day() should be mutable');
37128 assert.equal(m, m.startOf('week'), 'startOf() should be mutable');
37129 assert.equal(m, m.add(1, 'days'), 'add() should be mutable');
37130 assert.equal(m, m.subtract(2, 'years'), 'subtract() should be mutable');
37131 assert.equal(m, m.local(), 'local() should be mutable');
37132 assert.equal(m, m.utc(), 'utc() should be mutable');
37133 });
37134
37135 test('non mutable methods', function (assert) {
37136 var m = moment();
37137 assert.notEqual(m, m.clone(), 'clone() should not be mutable');
37138 });
37139
37140 }));
37141
37142 (function (global, factory) {
37143 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
37144 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
37145 factory(global.moment)
37146 }(this, function (moment) { 'use strict';
37147
37148 /*global QUnit:false*/
37149
37150 var test = QUnit.test;
37151
37152 function module (name, lifecycle) {
37153 QUnit.module(name, {
37154 setup : function () {
37155 moment.locale('en');
37156 moment.createFromInputFallback = function () {
37157 throw new Error('input not handled by moment');
37158 };
37159 if (lifecycle && lifecycle.setup) {
37160 lifecycle.setup();
37161 }
37162 },
37163 teardown : function () {
37164 if (lifecycle && lifecycle.teardown) {
37165 lifecycle.teardown();
37166 }
37167 }
37168 });
37169 }
37170
37171 function localeModule (name, lifecycle) {
37172 QUnit.module('locale:' + name, {
37173 setup : function () {
37174 moment.locale(name);
37175 moment.createFromInputFallback = function () {
37176 throw new Error('input not handled by moment');
37177 };
37178 if (lifecycle && lifecycle.setup) {
37179 lifecycle.setup();
37180 }
37181 },
37182 teardown : function () {
37183 moment.locale('en');
37184 if (lifecycle && lifecycle.teardown) {
37185 lifecycle.teardown();
37186 }
37187 }
37188 });
37189 }
37190
37191 module('normalize units');
37192
37193 test('normalize units', function (assert) {
37194 var fullKeys = ['year', 'quarter', 'month', 'isoWeek', 'week', 'day', 'hour', 'minute', 'second', 'millisecond', 'date', 'dayOfYear', 'weekday', 'isoWeekday', 'weekYear', 'isoWeekYear'],
37195 aliases = ['y', 'Q', 'M', 'W', 'w', 'd', 'h', 'm', 's', 'ms', 'D', 'DDD', 'e', 'E', 'gg', 'GG'],
37196 length = fullKeys.length,
37197 fullKey,
37198 fullKeyCaps,
37199 fullKeyPlural,
37200 fullKeyCapsPlural,
37201 fullKeyLower,
37202 alias,
37203 index;
37204
37205 for (index = 0; index < length; index += 1) {
37206 fullKey = fullKeys[index];
37207 fullKeyCaps = fullKey.toUpperCase();
37208 fullKeyLower = fullKey.toLowerCase();
37209 fullKeyPlural = fullKey + 's';
37210 fullKeyCapsPlural = fullKeyCaps + 's';
37211 alias = aliases[index];
37212 assert.equal(moment.normalizeUnits(fullKey), fullKey, 'Testing full key ' + fullKey);
37213 assert.equal(moment.normalizeUnits(fullKeyCaps), fullKey, 'Testing full key capitalised ' + fullKey);
37214 assert.equal(moment.normalizeUnits(fullKeyPlural), fullKey, 'Testing full key plural ' + fullKey);
37215 assert.equal(moment.normalizeUnits(fullKeyCapsPlural), fullKey, 'Testing full key capitalised and plural ' + fullKey);
37216 assert.equal(moment.normalizeUnits(alias), fullKey, 'Testing alias ' + fullKey);
37217 }
37218 });
37219
37220 }));
37221
37222 (function (global, factory) {
37223 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
37224 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
37225 factory(global.moment)
37226 }(this, function (moment) { 'use strict';
37227
37228 /*global QUnit:false*/
37229
37230 var test = QUnit.test;
37231
37232 function module (name, lifecycle) {
37233 QUnit.module(name, {
37234 setup : function () {
37235 moment.locale('en');
37236 moment.createFromInputFallback = function () {
37237 throw new Error('input not handled by moment');
37238 };
37239 if (lifecycle && lifecycle.setup) {
37240 lifecycle.setup();
37241 }
37242 },
37243 teardown : function () {
37244 if (lifecycle && lifecycle.teardown) {
37245 lifecycle.teardown();
37246 }
37247 }
37248 });
37249 }
37250
37251 function localeModule (name, lifecycle) {
37252 QUnit.module('locale:' + name, {
37253 setup : function () {
37254 moment.locale(name);
37255 moment.createFromInputFallback = function () {
37256 throw new Error('input not handled by moment');
37257 };
37258 if (lifecycle && lifecycle.setup) {
37259 lifecycle.setup();
37260 }
37261 },
37262 teardown : function () {
37263 moment.locale('en');
37264 if (lifecycle && lifecycle.teardown) {
37265 lifecycle.teardown();
37266 }
37267 }
37268 });
37269 }
37270
37271 module('parsing flags');
37272
37273 function flags () {
37274 return moment.apply(null, arguments).parsingFlags();
37275 }
37276
37277 test('overflow with array', function (assert) {
37278 //months
37279 assert.equal(flags([2010, 0]).overflow, -1, 'month 0 valid');
37280 assert.equal(flags([2010, 1]).overflow, -1, 'month 1 valid');
37281 assert.equal(flags([2010, -1]).overflow, 1, 'month -1 invalid');
37282 assert.equal(flags([2100, 12]).overflow, 1, 'month 12 invalid');
37283
37284 //days
37285 assert.equal(flags([2010, 1, 16]).overflow, -1, 'date valid');
37286 assert.equal(flags([2010, 1, -1]).overflow, 2, 'date -1 invalid');
37287 assert.equal(flags([2010, 1, 0]).overflow, 2, 'date 0 invalid');
37288 assert.equal(flags([2010, 1, 32]).overflow, 2, 'date 32 invalid');
37289 assert.equal(flags([2012, 1, 29]).overflow, -1, 'date leap year valid');
37290 assert.equal(flags([2010, 1, 29]).overflow, 2, 'date leap year invalid');
37291
37292 //hours
37293 assert.equal(flags([2010, 1, 1, 8]).overflow, -1, 'hour valid');
37294 assert.equal(flags([2010, 1, 1, 0]).overflow, -1, 'hour 0 valid');
37295 assert.equal(flags([2010, 1, 1, -1]).overflow, 3, 'hour -1 invalid');
37296 assert.equal(flags([2010, 1, 1, 25]).overflow, 3, 'hour 25 invalid');
37297 assert.equal(flags([2010, 1, 1, 24, 1]).overflow, 3, 'hour 24:01 invalid');
37298
37299 //minutes
37300 assert.equal(flags([2010, 1, 1, 8, 15]).overflow, -1, 'minute valid');
37301 assert.equal(flags([2010, 1, 1, 8, 0]).overflow, -1, 'minute 0 valid');
37302 assert.equal(flags([2010, 1, 1, 8, -1]).overflow, 4, 'minute -1 invalid');
37303 assert.equal(flags([2010, 1, 1, 8, 60]).overflow, 4, 'minute 60 invalid');
37304
37305 //seconds
37306 assert.equal(flags([2010, 1, 1, 8, 15, 12]).overflow, -1, 'second valid');
37307 assert.equal(flags([2010, 1, 1, 8, 15, 0]).overflow, -1, 'second 0 valid');
37308 assert.equal(flags([2010, 1, 1, 8, 15, -1]).overflow, 5, 'second -1 invalid');
37309 assert.equal(flags([2010, 1, 1, 8, 15, 60]).overflow, 5, 'second 60 invalid');
37310
37311 //milliseconds
37312 assert.equal(flags([2010, 1, 1, 8, 15, 12, 345]).overflow, -1, 'millisecond valid');
37313 assert.equal(flags([2010, 1, 1, 8, 15, 12, 0]).overflow, -1, 'millisecond 0 valid');
37314 assert.equal(flags([2010, 1, 1, 8, 15, 12, -1]).overflow, 6, 'millisecond -1 invalid');
37315 assert.equal(flags([2010, 1, 1, 8, 15, 12, 1000]).overflow, 6, 'millisecond 1000 invalid');
37316
37317 // 24 hrs
37318 assert.equal(flags([2010, 1, 1, 24, 0, 0, 0]).overflow, -1, '24:00:00.000 is fine');
37319 assert.equal(flags([2010, 1, 1, 24, 1, 0, 0]).overflow, 3, '24:01:00.000 is wrong hour');
37320 assert.equal(flags([2010, 1, 1, 24, 0, 1, 0]).overflow, 3, '24:00:01.000 is wrong hour');
37321 assert.equal(flags([2010, 1, 1, 24, 0, 0, 1]).overflow, 3, '24:00:00.001 is wrong hour');
37322 });
37323
37324 test('overflow without format', function (assert) {
37325 //months
37326 assert.equal(flags('2001-01', 'YYYY-MM').overflow, -1, 'month 1 valid');
37327 assert.equal(flags('2001-12', 'YYYY-MM').overflow, -1, 'month 12 valid');
37328 assert.equal(flags('2001-13', 'YYYY-MM').overflow, 1, 'month 13 invalid');
37329
37330 //days
37331 assert.equal(flags('2010-01-16', 'YYYY-MM-DD').overflow, -1, 'date 16 valid');
37332 assert.equal(flags('2010-01-0', 'YYYY-MM-DD').overflow, 2, 'date 0 invalid');
37333 assert.equal(flags('2010-01-32', 'YYYY-MM-DD').overflow, 2, 'date 32 invalid');
37334 assert.equal(flags('2012-02-29', 'YYYY-MM-DD').overflow, -1, 'date leap year valid');
37335 assert.equal(flags('2010-02-29', 'YYYY-MM-DD').overflow, 2, 'date leap year invalid');
37336
37337 //days of the year
37338 assert.equal(flags('2010 300', 'YYYY DDDD').overflow, -1, 'day 300 of year valid');
37339 assert.equal(flags('2010 365', 'YYYY DDDD').overflow, -1, 'day 365 of year valid');
37340 assert.equal(flags('2010 366', 'YYYY DDDD').overflow, 2, 'day 366 of year invalid');
37341 assert.equal(flags('2012 366', 'YYYY DDDD').overflow, -1, 'day 366 of leap year valid');
37342 assert.equal(flags('2012 367', 'YYYY DDDD').overflow, 2, 'day 367 of leap year invalid');
37343
37344 //hours
37345 assert.equal(flags('08', 'HH').overflow, -1, 'hour valid');
37346 assert.equal(flags('00', 'HH').overflow, -1, 'hour 0 valid');
37347 assert.equal(flags('25', 'HH').overflow, 3, 'hour 25 invalid');
37348 assert.equal(flags('24:01', 'HH:mm').overflow, 3, 'hour 24:01 invalid');
37349
37350 //minutes
37351 assert.equal(flags('08:15', 'HH:mm').overflow, -1, 'minute valid');
37352 assert.equal(flags('08:00', 'HH:mm').overflow, -1, 'minute 0 valid');
37353 assert.equal(flags('08:60', 'HH:mm').overflow, 4, 'minute 60 invalid');
37354
37355 //seconds
37356 assert.equal(flags('08:15:12', 'HH:mm:ss').overflow, -1, 'second valid');
37357 assert.equal(flags('08:15:00', 'HH:mm:ss').overflow, -1, 'second 0 valid');
37358 assert.equal(flags('08:15:60', 'HH:mm:ss').overflow, 5, 'second 60 invalid');
37359
37360 //milliseconds
37361 assert.equal(flags('08:15:12:345', 'HH:mm:ss:SSSS').overflow, -1, 'millisecond valid');
37362 assert.equal(flags('08:15:12:000', 'HH:mm:ss:SSSS').overflow, -1, 'millisecond 0 valid');
37363
37364 //this is OK because we don't match the last digit, so it's 100 ms
37365 assert.equal(flags('08:15:12:1000', 'HH:mm:ss:SSSS').overflow, -1, 'millisecond 1000 actually valid');
37366 });
37367
37368 test('extra tokens', function (assert) {
37369 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD').unusedTokens, [], 'nothing extra');
37370 assert.deepEqual(flags('1982-05', 'YYYY-MM-DD').unusedTokens, ['DD'], 'extra formatting token');
37371 assert.deepEqual(flags('1982', 'YYYY-MM-DD').unusedTokens, ['MM', 'DD'], 'multiple extra formatting tokens');
37372 assert.deepEqual(flags('1982-05', 'YYYY-MM-').unusedTokens, [], 'extra non-formatting token');
37373 assert.deepEqual(flags('1982-05-', 'YYYY-MM-DD').unusedTokens, ['DD'], 'non-extra non-formatting token');
37374 assert.deepEqual(flags('1982 05 1982', 'YYYY-MM-DD').unusedTokens, [], 'different non-formatting token');
37375 });
37376
37377 test('extra tokens strict', function (assert) {
37378 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD', true).unusedTokens, [], 'nothing extra');
37379 assert.deepEqual(flags('1982-05', 'YYYY-MM-DD', true).unusedTokens, ['-', 'DD'], 'extra formatting token');
37380 assert.deepEqual(flags('1982', 'YYYY-MM-DD', true).unusedTokens, ['-', 'MM', '-', 'DD'], 'multiple extra formatting tokens');
37381 assert.deepEqual(flags('1982-05', 'YYYY-MM-', true).unusedTokens, ['-'], 'extra non-formatting token');
37382 assert.deepEqual(flags('1982-05-', 'YYYY-MM-DD', true).unusedTokens, ['DD'], 'non-extra non-formatting token');
37383 assert.deepEqual(flags('1982 05 1982', 'YYYY-MM-DD', true).unusedTokens, ['-', '-'], 'different non-formatting token');
37384 });
37385
37386 test('unused input', function (assert) {
37387 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD').unusedInput, [], 'normal input');
37388 assert.deepEqual(flags('1982-05-25 this is more stuff', 'YYYY-MM-DD').unusedInput, [' this is more stuff'], 'trailing nonsense');
37389 assert.deepEqual(flags('1982-05-25 09:30', 'YYYY-MM-DD').unusedInput, [' 09:30'], ['trailing legit-looking input']);
37390 assert.deepEqual(flags('1982-05-25 some junk', 'YYYY-MM-DD [some junk]').unusedInput, [], 'junk that actually gets matched');
37391 assert.deepEqual(flags('stuff at beginning 1982-05-25', 'YYYY-MM-DD').unusedInput, ['stuff at beginning '], 'leading junk');
37392 assert.deepEqual(flags('junk 1982 more junk 05 yet more junk25', 'YYYY-MM-DD').unusedInput, ['junk ', ' more junk ', ' yet more junk'], 'interstitial junk');
37393 });
37394
37395 test('unused input strict', function (assert) {
37396 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD', true).unusedInput, [], 'normal input');
37397 assert.deepEqual(flags('1982-05-25 this is more stuff', 'YYYY-MM-DD', true).unusedInput, [' this is more stuff'], 'trailing nonsense');
37398 assert.deepEqual(flags('1982-05-25 09:30', 'YYYY-MM-DD', true).unusedInput, [' 09:30'], ['trailing legit-looking input']);
37399 assert.deepEqual(flags('1982-05-25 some junk', 'YYYY-MM-DD [some junk]', true).unusedInput, [], 'junk that actually gets matched');
37400 assert.deepEqual(flags('stuff at beginning 1982-05-25', 'YYYY-MM-DD', true).unusedInput, ['stuff at beginning '], 'leading junk');
37401 assert.deepEqual(flags('junk 1982 more junk 05 yet more junk25', 'YYYY-MM-DD', true).unusedInput, ['junk ', ' more junk ', ' yet more junk'], 'interstitial junk');
37402 });
37403
37404 test('chars left over', function (assert) {
37405 assert.equal(flags('1982-05-25', 'YYYY-MM-DD').charsLeftOver, 0, 'normal input');
37406 assert.equal(flags('1982-05-25 this is more stuff', 'YYYY-MM-DD').charsLeftOver, ' this is more stuff'.length, 'trailing nonsense');
37407 assert.equal(flags('1982-05-25 09:30', 'YYYY-MM-DD').charsLeftOver, ' 09:30'.length, 'trailing legit-looking input');
37408 assert.equal(flags('stuff at beginning 1982-05-25', 'YYYY-MM-DD').charsLeftOver, 'stuff at beginning '.length, 'leading junk');
37409 assert.equal(flags('1982 junk 05 more junk25', 'YYYY-MM-DD').charsLeftOver, [' junk ', ' more junk'].join('').length, 'interstitial junk');
37410 assert.equal(flags('stuff at beginning 1982 junk 05 more junk25', 'YYYY-MM-DD').charsLeftOver, ['stuff at beginning ', ' junk ', ' more junk'].join('').length, 'leading and interstitial junk');
37411 });
37412
37413 test('empty', function (assert) {
37414 assert.equal(flags('1982-05-25', 'YYYY-MM-DD').empty, false, 'normal input');
37415 assert.equal(flags('nothing here', 'YYYY-MM-DD').empty, true, 'pure garbage');
37416 assert.equal(flags('junk but has the number 2000 in it', 'YYYY-MM-DD').empty, false, 'only mostly garbage');
37417 assert.equal(flags('', 'YYYY-MM-DD').empty, true, 'empty string');
37418 assert.equal(flags('', 'YYYY-MM-DD').empty, true, 'blank string');
37419 });
37420
37421 test('null', function (assert) {
37422 assert.equal(flags('1982-05-25', 'YYYY-MM-DD').nullInput, false, 'normal input');
37423 assert.equal(flags(null).nullInput, true, 'just null');
37424 assert.equal(flags(null, 'YYYY-MM-DD').nullInput, true, 'null with format');
37425 });
37426
37427 test('invalid month', function (assert) {
37428 assert.equal(flags('1982 May', 'YYYY MMMM').invalidMonth, null, 'normal input');
37429 assert.equal(flags('1982 Laser', 'YYYY MMMM').invalidMonth, 'Laser', 'bad month name');
37430 });
37431
37432 test('empty format array', function (assert) {
37433 assert.equal(flags('1982 May', ['YYYY MMM']).invalidFormat, false, 'empty format array');
37434 assert.equal(flags('1982 May', []).invalidFormat, true, 'empty format array');
37435 });
37436
37437 }));
37438
37439 (function (global, factory) {
37440 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
37441 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
37442 factory(global.moment)
37443 }(this, function (moment) { 'use strict';
37444
37445 /*global QUnit:false*/
37446
37447 var test = QUnit.test;
37448
37449 function module (name, lifecycle) {
37450 QUnit.module(name, {
37451 setup : function () {
37452 moment.locale('en');
37453 moment.createFromInputFallback = function () {
37454 throw new Error('input not handled by moment');
37455 };
37456 if (lifecycle && lifecycle.setup) {
37457 lifecycle.setup();
37458 }
37459 },
37460 teardown : function () {
37461 if (lifecycle && lifecycle.teardown) {
37462 lifecycle.teardown();
37463 }
37464 }
37465 });
37466 }
37467
37468 function localeModule (name, lifecycle) {
37469 QUnit.module('locale:' + name, {
37470 setup : function () {
37471 moment.locale(name);
37472 moment.createFromInputFallback = function () {
37473 throw new Error('input not handled by moment');
37474 };
37475 if (lifecycle && lifecycle.setup) {
37476 lifecycle.setup();
37477 }
37478 },
37479 teardown : function () {
37480 moment.locale('en');
37481 if (lifecycle && lifecycle.teardown) {
37482 lifecycle.teardown();
37483 }
37484 }
37485 });
37486 }
37487
37488 var symbolMap = {
37489 '1': '!',
37490 '2': '@',
37491 '3': '#',
37492 '4': '$',
37493 '5': '%',
37494 '6': '^',
37495 '7': '&',
37496 '8': '*',
37497 '9': '(',
37498 '0': ')'
37499 },
37500 numberMap = {
37501 '!': '1',
37502 '@': '2',
37503 '#': '3',
37504 '$': '4',
37505 '%': '5',
37506 '^': '6',
37507 '&': '7',
37508 '*': '8',
37509 '(': '9',
37510 ')': '0'
37511 };
37512
37513 module('preparse and postformat', {
37514 setup: function () {
37515 moment.locale('symbol', {
37516 preparse: function (string) {
37517 return string.replace(/[!@#$%\^&*()]/g, function (match) {
37518 return numberMap[match];
37519 });
37520 },
37521
37522 postformat: function (string) {
37523 return string.replace(/\d/g, function (match) {
37524 return symbolMap[match];
37525 });
37526 }
37527 });
37528 }
37529 });
37530
37531 test('transform', function (assert) {
37532 assert.equal(moment.utc('@)!@-)*-@&', 'YYYY-MM-DD').unix(), 1346025600, 'preparse string + format');
37533 assert.equal(moment.utc('@)!@-)*-@&').unix(), 1346025600, 'preparse ISO8601 string');
37534 assert.equal(moment.unix(1346025600).utc().format('YYYY-MM-DD'), '@)!@-)*-@&', 'postformat');
37535 });
37536
37537 test('transform from', function (assert) {
37538 var start = moment([2007, 1, 28]);
37539
37540 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '@ minutes', 'postformat should work on moment.fn.from');
37541 assert.equal(moment().add(6, 'd').fromNow(true), '^ days', 'postformat should work on moment.fn.fromNow');
37542 assert.equal(moment.duration(10, 'h').humanize(), '!) hours', 'postformat should work on moment.duration.fn.humanize');
37543 });
37544
37545 test('calendar day', function (assert) {
37546 var a = moment().hours(2).minutes(0).seconds(0);
37547
37548 assert.equal(moment(a).calendar(), 'Today at @:)) AM', 'today at the same time');
37549 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at @:@% AM', 'Now plus 25 min');
37550 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at #:)) AM', 'Now plus 1 hour');
37551 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at @:)) AM', 'tomorrow at the same time');
37552 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at !:)) AM', 'Now minus 1 hour');
37553 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at @:)) AM', 'yesterday at the same time');
37554 });
37555
37556 }));
37557
37558 (function (global, factory) {
37559 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
37560 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
37561 factory(global.moment)
37562 }(this, function (moment) { 'use strict';
37563
37564 /*global QUnit:false*/
37565
37566 var test = QUnit.test;
37567
37568 function module (name, lifecycle) {
37569 QUnit.module(name, {
37570 setup : function () {
37571 moment.locale('en');
37572 moment.createFromInputFallback = function () {
37573 throw new Error('input not handled by moment');
37574 };
37575 if (lifecycle && lifecycle.setup) {
37576 lifecycle.setup();
37577 }
37578 },
37579 teardown : function () {
37580 if (lifecycle && lifecycle.teardown) {
37581 lifecycle.teardown();
37582 }
37583 }
37584 });
37585 }
37586
37587 function localeModule (name, lifecycle) {
37588 QUnit.module('locale:' + name, {
37589 setup : function () {
37590 moment.locale(name);
37591 moment.createFromInputFallback = function () {
37592 throw new Error('input not handled by moment');
37593 };
37594 if (lifecycle && lifecycle.setup) {
37595 lifecycle.setup();
37596 }
37597 },
37598 teardown : function () {
37599 moment.locale('en');
37600 if (lifecycle && lifecycle.teardown) {
37601 lifecycle.teardown();
37602 }
37603 }
37604 });
37605 }
37606
37607 module('quarter');
37608
37609 test('library quarter getter', function (assert) {
37610 assert.equal(moment([1985, 1, 4]).quarter(), 1, 'Feb 4 1985 is Q1');
37611 assert.equal(moment([2029, 8, 18]).quarter(), 3, 'Sep 18 2029 is Q3');
37612 assert.equal(moment([2013, 3, 24]).quarter(), 2, 'Apr 24 2013 is Q2');
37613 assert.equal(moment([2015, 2, 5]).quarter(), 1, 'Mar 5 2015 is Q1');
37614 assert.equal(moment([1970, 0, 2]).quarter(), 1, 'Jan 2 1970 is Q1');
37615 assert.equal(moment([2001, 11, 12]).quarter(), 4, 'Dec 12 2001 is Q4');
37616 assert.equal(moment([2000, 0, 2]).quarter(), 1, 'Jan 2 2000 is Q1');
37617 });
37618
37619 test('quarter setter singular', function (assert) {
37620 var m = moment([2014, 4, 11]);
37621 assert.equal(m.quarter(2).month(), 4, 'set same quarter');
37622 assert.equal(m.quarter(3).month(), 7, 'set 3rd quarter');
37623 assert.equal(m.quarter(1).month(), 1, 'set 1st quarter');
37624 assert.equal(m.quarter(4).month(), 10, 'set 4th quarter');
37625 });
37626
37627 test('quarter setter plural', function (assert) {
37628 var m = moment([2014, 4, 11]);
37629 assert.equal(m.quarters(2).month(), 4, 'set same quarter');
37630 assert.equal(m.quarters(3).month(), 7, 'set 3rd quarter');
37631 assert.equal(m.quarters(1).month(), 1, 'set 1st quarter');
37632 assert.equal(m.quarters(4).month(), 10, 'set 4th quarter');
37633 });
37634
37635 test('quarter setter programmatic', function (assert) {
37636 var m = moment([2014, 4, 11]);
37637 assert.equal(m.set('quarter', 2).month(), 4, 'set same quarter');
37638 assert.equal(m.set('quarter', 3).month(), 7, 'set 3rd quarter');
37639 assert.equal(m.set('quarter', 1).month(), 1, 'set 1st quarter');
37640 assert.equal(m.set('quarter', 4).month(), 10, 'set 4th quarter');
37641 });
37642
37643 test('quarter setter programmatic plural', function (assert) {
37644 var m = moment([2014, 4, 11]);
37645 assert.equal(m.set('quarters', 2).month(), 4, 'set same quarter');
37646 assert.equal(m.set('quarters', 3).month(), 7, 'set 3rd quarter');
37647 assert.equal(m.set('quarters', 1).month(), 1, 'set 1st quarter');
37648 assert.equal(m.set('quarters', 4).month(), 10, 'set 4th quarter');
37649 });
37650
37651 test('quarter setter programmatic abbr', function (assert) {
37652 var m = moment([2014, 4, 11]);
37653 assert.equal(m.set('Q', 2).month(), 4, 'set same quarter');
37654 assert.equal(m.set('Q', 3).month(), 7, 'set 3rd quarter');
37655 assert.equal(m.set('Q', 1).month(), 1, 'set 1st quarter');
37656 assert.equal(m.set('Q', 4).month(), 10, 'set 4th quarter');
37657 });
37658
37659 test('quarter setter only month changes', function (assert) {
37660 var m = moment([2014, 4, 11, 1, 2, 3, 4]).quarter(4);
37661 assert.equal(m.year(), 2014, 'keep year');
37662 assert.equal(m.month(), 10, 'set month');
37663 assert.equal(m.date(), 11, 'keep date');
37664 assert.equal(m.hour(), 1, 'keep hour');
37665 assert.equal(m.minute(), 2, 'keep minutes');
37666 assert.equal(m.second(), 3, 'keep seconds');
37667 assert.equal(m.millisecond(), 4, 'keep milliseconds');
37668 });
37669
37670 test('quarter setter bubble to next year', function (assert) {
37671 var m = moment([2014, 4, 11, 1, 2, 3, 4]).quarter(7);
37672 assert.equal(m.year(), 2015, 'year bubbled');
37673 assert.equal(m.month(), 7, 'set month');
37674 assert.equal(m.date(), 11, 'keep date');
37675 assert.equal(m.hour(), 1, 'keep hour');
37676 assert.equal(m.minute(), 2, 'keep minutes');
37677 assert.equal(m.second(), 3, 'keep seconds');
37678 assert.equal(m.millisecond(), 4, 'keep milliseconds');
37679 });
37680
37681 test('quarter diff', function (assert) {
37682 assert.equal(moment('2014-01-01').diff(moment('2014-04-01'), 'quarter'),
37683 -1, 'diff -1 quarter');
37684 assert.equal(moment('2014-04-01').diff(moment('2014-01-01'), 'quarter'),
37685 1, 'diff 1 quarter');
37686 assert.equal(moment('2014-05-01').diff(moment('2014-01-01'), 'quarter'),
37687 1, 'diff 1 quarter');
37688 assert.ok(Math.abs((4 / 3) - moment('2014-05-01').diff(
37689 moment('2014-01-01'), 'quarter', true)) < 0.00001,
37690 'diff 1 1/3 quarter');
37691 assert.equal(moment('2015-01-01').diff(moment('2014-01-01'), 'quarter'),
37692 4, 'diff 4 quarters');
37693 });
37694
37695 test('quarter setter bubble to previous year', function (assert) {
37696 var m = moment([2014, 4, 11, 1, 2, 3, 4]).quarter(-3);
37697 assert.equal(m.year(), 2013, 'year bubbled');
37698 assert.equal(m.month(), 1, 'set month');
37699 assert.equal(m.date(), 11, 'keep date');
37700 assert.equal(m.hour(), 1, 'keep hour');
37701 assert.equal(m.minute(), 2, 'keep minutes');
37702 assert.equal(m.second(), 3, 'keep seconds');
37703 assert.equal(m.millisecond(), 4, 'keep milliseconds');
37704 });
37705
37706 }));
37707
37708 (function (global, factory) {
37709 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
37710 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
37711 factory(global.moment)
37712 }(this, function (moment) { 'use strict';
37713
37714 /*global QUnit:false*/
37715
37716 var test = QUnit.test;
37717
37718 function module (name, lifecycle) {
37719 QUnit.module(name, {
37720 setup : function () {
37721 moment.locale('en');
37722 moment.createFromInputFallback = function () {
37723 throw new Error('input not handled by moment');
37724 };
37725 if (lifecycle && lifecycle.setup) {
37726 lifecycle.setup();
37727 }
37728 },
37729 teardown : function () {
37730 if (lifecycle && lifecycle.teardown) {
37731 lifecycle.teardown();
37732 }
37733 }
37734 });
37735 }
37736
37737 function localeModule (name, lifecycle) {
37738 QUnit.module('locale:' + name, {
37739 setup : function () {
37740 moment.locale(name);
37741 moment.createFromInputFallback = function () {
37742 throw new Error('input not handled by moment');
37743 };
37744 if (lifecycle && lifecycle.setup) {
37745 lifecycle.setup();
37746 }
37747 },
37748 teardown : function () {
37749 moment.locale('en');
37750 if (lifecycle && lifecycle.teardown) {
37751 lifecycle.teardown();
37752 }
37753 }
37754 });
37755 }
37756
37757 module('relative time');
37758
37759 test('default thresholds fromNow', function (assert) {
37760 var a = moment();
37761
37762 // Seconds to minutes threshold
37763 a.subtract(44, 'seconds');
37764 assert.equal(a.fromNow(), 'a few seconds ago', 'Below default seconds to minutes threshold');
37765 a.subtract(1, 'seconds');
37766 assert.equal(a.fromNow(), 'a minute ago', 'Above default seconds to minutes threshold');
37767
37768 // Minutes to hours threshold
37769 a = moment();
37770 a.subtract(44, 'minutes');
37771 assert.equal(a.fromNow(), '44 minutes ago', 'Below default minute to hour threshold');
37772 a.subtract(1, 'minutes');
37773 assert.equal(a.fromNow(), 'an hour ago', 'Above default minute to hour threshold');
37774
37775 // Hours to days threshold
37776 a = moment();
37777 a.subtract(21, 'hours');
37778 assert.equal(a.fromNow(), '21 hours ago', 'Below default hours to day threshold');
37779 a.subtract(1, 'hours');
37780 assert.equal(a.fromNow(), 'a day ago', 'Above default hours to day threshold');
37781
37782 // Days to month threshold
37783 a = moment();
37784 a.subtract(25, 'days');
37785 assert.equal(a.fromNow(), '25 days ago', 'Below default days to month (singular) threshold');
37786 a.subtract(1, 'days');
37787 assert.equal(a.fromNow(), 'a month ago', 'Above default days to month (singular) threshold');
37788
37789 // months to year threshold
37790 a = moment();
37791 a.subtract(10, 'months');
37792 assert.equal(a.fromNow(), '10 months ago', 'Below default days to years threshold');
37793 a.subtract(1, 'month');
37794 assert.equal(a.fromNow(), 'a year ago', 'Above default days to years threshold');
37795 });
37796
37797 test('default thresholds toNow', function (assert) {
37798 var a = moment();
37799
37800 // Seconds to minutes threshold
37801 a.subtract(44, 'seconds');
37802 assert.equal(a.toNow(), 'in a few seconds', 'Below default seconds to minutes threshold');
37803 a.subtract(1, 'seconds');
37804 assert.equal(a.toNow(), 'in a minute', 'Above default seconds to minutes threshold');
37805
37806 // Minutes to hours threshold
37807 a = moment();
37808 a.subtract(44, 'minutes');
37809 assert.equal(a.toNow(), 'in 44 minutes', 'Below default minute to hour threshold');
37810 a.subtract(1, 'minutes');
37811 assert.equal(a.toNow(), 'in an hour', 'Above default minute to hour threshold');
37812
37813 // Hours to days threshold
37814 a = moment();
37815 a.subtract(21, 'hours');
37816 assert.equal(a.toNow(), 'in 21 hours', 'Below default hours to day threshold');
37817 a.subtract(1, 'hours');
37818 assert.equal(a.toNow(), 'in a day', 'Above default hours to day threshold');
37819
37820 // Days to month threshold
37821 a = moment();
37822 a.subtract(25, 'days');
37823 assert.equal(a.toNow(), 'in 25 days', 'Below default days to month (singular) threshold');
37824 a.subtract(1, 'days');
37825 assert.equal(a.toNow(), 'in a month', 'Above default days to month (singular) threshold');
37826
37827 // months to year threshold
37828 a = moment();
37829 a.subtract(10, 'months');
37830 assert.equal(a.toNow(), 'in 10 months', 'Below default days to years threshold');
37831 a.subtract(1, 'month');
37832 assert.equal(a.toNow(), 'in a year', 'Above default days to years threshold');
37833 });
37834
37835 test('custom thresholds', function (assert) {
37836 // Seconds to minutes threshold
37837 moment.relativeTimeThreshold('s', 55);
37838
37839 var a = moment();
37840 a.subtract(54, 'seconds');
37841 assert.equal(a.fromNow(), 'a few seconds ago', 'Below custom seconds to minutes threshold');
37842 a.subtract(1, 'seconds');
37843 assert.equal(a.fromNow(), 'a minute ago', 'Above custom seconds to minutes threshold');
37844
37845 moment.relativeTimeThreshold('s', 45);
37846
37847 // Minutes to hours threshold
37848 moment.relativeTimeThreshold('m', 55);
37849 a = moment();
37850 a.subtract(54, 'minutes');
37851 assert.equal(a.fromNow(), '54 minutes ago', 'Below custom minutes to hours threshold');
37852 a.subtract(1, 'minutes');
37853 assert.equal(a.fromNow(), 'an hour ago', 'Above custom minutes to hours threshold');
37854 moment.relativeTimeThreshold('m', 45);
37855
37856 // Hours to days threshold
37857 moment.relativeTimeThreshold('h', 24);
37858 a = moment();
37859 a.subtract(23, 'hours');
37860 assert.equal(a.fromNow(), '23 hours ago', 'Below custom hours to days threshold');
37861 a.subtract(1, 'hours');
37862 assert.equal(a.fromNow(), 'a day ago', 'Above custom hours to days threshold');
37863 moment.relativeTimeThreshold('h', 22);
37864
37865 // Days to month threshold
37866 moment.relativeTimeThreshold('d', 28);
37867 a = moment();
37868 a.subtract(27, 'days');
37869 assert.equal(a.fromNow(), '27 days ago', 'Below custom days to month (singular) threshold');
37870 a.subtract(1, 'days');
37871 assert.equal(a.fromNow(), 'a month ago', 'Above custom days to month (singular) threshold');
37872 moment.relativeTimeThreshold('d', 26);
37873
37874 // months to years threshold
37875 moment.relativeTimeThreshold('M', 9);
37876 a = moment();
37877 a.subtract(8, 'months');
37878 assert.equal(a.fromNow(), '8 months ago', 'Below custom days to years threshold');
37879 a.subtract(1, 'months');
37880 assert.equal(a.fromNow(), 'a year ago', 'Above custom days to years threshold');
37881 moment.relativeTimeThreshold('M', 11);
37882 });
37883
37884 test('retrive threshold settings', function (assert) {
37885 moment.relativeTimeThreshold('m', 45);
37886 var minuteThreshold = moment.relativeTimeThreshold('m');
37887
37888 assert.equal(minuteThreshold, 45, 'Can retrieve minute setting');
37889 });
37890
37891 }));
37892
37893 (function (global, factory) {
37894 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
37895 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
37896 factory(global.moment)
37897 }(this, function (moment) { 'use strict';
37898
37899 /*global QUnit:false*/
37900
37901 var test = QUnit.test;
37902
37903 function module (name, lifecycle) {
37904 QUnit.module(name, {
37905 setup : function () {
37906 moment.locale('en');
37907 moment.createFromInputFallback = function () {
37908 throw new Error('input not handled by moment');
37909 };
37910 if (lifecycle && lifecycle.setup) {
37911 lifecycle.setup();
37912 }
37913 },
37914 teardown : function () {
37915 if (lifecycle && lifecycle.teardown) {
37916 lifecycle.teardown();
37917 }
37918 }
37919 });
37920 }
37921
37922 function localeModule (name, lifecycle) {
37923 QUnit.module('locale:' + name, {
37924 setup : function () {
37925 moment.locale(name);
37926 moment.createFromInputFallback = function () {
37927 throw new Error('input not handled by moment');
37928 };
37929 if (lifecycle && lifecycle.setup) {
37930 lifecycle.setup();
37931 }
37932 },
37933 teardown : function () {
37934 moment.locale('en');
37935 if (lifecycle && lifecycle.teardown) {
37936 lifecycle.teardown();
37937 }
37938 }
37939 });
37940 }
37941
37942 module('start and end of units');
37943
37944 test('start of year', function (assert) {
37945 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('year'),
37946 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('years'),
37947 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('y');
37948 assert.equal(+m, +ms, 'Plural or singular should work');
37949 assert.equal(+m, +ma, 'Full or abbreviated should work');
37950 assert.equal(m.year(), 2011, 'keep the year');
37951 assert.equal(m.month(), 0, 'strip out the month');
37952 assert.equal(m.date(), 1, 'strip out the day');
37953 assert.equal(m.hours(), 0, 'strip out the hours');
37954 assert.equal(m.minutes(), 0, 'strip out the minutes');
37955 assert.equal(m.seconds(), 0, 'strip out the seconds');
37956 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
37957 });
37958
37959 test('end of year', function (assert) {
37960 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('year'),
37961 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('years'),
37962 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('y');
37963 assert.equal(+m, +ms, 'Plural or singular should work');
37964 assert.equal(+m, +ma, 'Full or abbreviated should work');
37965 assert.equal(m.year(), 2011, 'keep the year');
37966 assert.equal(m.month(), 11, 'set the month');
37967 assert.equal(m.date(), 31, 'set the day');
37968 assert.equal(m.hours(), 23, 'set the hours');
37969 assert.equal(m.minutes(), 59, 'set the minutes');
37970 assert.equal(m.seconds(), 59, 'set the seconds');
37971 assert.equal(m.milliseconds(), 999, 'set the seconds');
37972 });
37973
37974 test('start of quarter', function (assert) {
37975 var m = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).startOf('quarter'),
37976 ms = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).startOf('quarters'),
37977 ma = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).startOf('Q');
37978 assert.equal(+m, +ms, 'Plural or singular should work');
37979 assert.equal(+m, +ma, 'Full or abbreviated should work');
37980 assert.equal(m.year(), 2011, 'keep the year');
37981 assert.equal(m.quarter(), 2, 'keep the quarter');
37982 assert.equal(m.month(), 3, 'strip out the month');
37983 assert.equal(m.date(), 1, 'strip out the day');
37984 assert.equal(m.hours(), 0, 'strip out the hours');
37985 assert.equal(m.minutes(), 0, 'strip out the minutes');
37986 assert.equal(m.seconds(), 0, 'strip out the seconds');
37987 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
37988 });
37989
37990 test('end of quarter', function (assert) {
37991 var m = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).endOf('quarter'),
37992 ms = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).endOf('quarters'),
37993 ma = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).endOf('Q');
37994 assert.equal(+m, +ms, 'Plural or singular should work');
37995 assert.equal(+m, +ma, 'Full or abbreviated should work');
37996 assert.equal(m.year(), 2011, 'keep the year');
37997 assert.equal(m.quarter(), 2, 'keep the quarter');
37998 assert.equal(m.month(), 5, 'set the month');
37999 assert.equal(m.date(), 30, 'set the day');
38000 assert.equal(m.hours(), 23, 'set the hours');
38001 assert.equal(m.minutes(), 59, 'set the minutes');
38002 assert.equal(m.seconds(), 59, 'set the seconds');
38003 assert.equal(m.milliseconds(), 999, 'set the seconds');
38004 });
38005
38006 test('start of month', function (assert) {
38007 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('month'),
38008 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('months'),
38009 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('M');
38010 assert.equal(+m, +ms, 'Plural or singular should work');
38011 assert.equal(+m, +ma, 'Full or abbreviated should work');
38012 assert.equal(m.year(), 2011, 'keep the year');
38013 assert.equal(m.month(), 1, 'keep the month');
38014 assert.equal(m.date(), 1, 'strip out the day');
38015 assert.equal(m.hours(), 0, 'strip out the hours');
38016 assert.equal(m.minutes(), 0, 'strip out the minutes');
38017 assert.equal(m.seconds(), 0, 'strip out the seconds');
38018 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
38019 });
38020
38021 test('end of month', function (assert) {
38022 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('month'),
38023 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('months'),
38024 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('M');
38025 assert.equal(+m, +ms, 'Plural or singular should work');
38026 assert.equal(+m, +ma, 'Full or abbreviated should work');
38027 assert.equal(m.year(), 2011, 'keep the year');
38028 assert.equal(m.month(), 1, 'keep the month');
38029 assert.equal(m.date(), 28, 'set the day');
38030 assert.equal(m.hours(), 23, 'set the hours');
38031 assert.equal(m.minutes(), 59, 'set the minutes');
38032 assert.equal(m.seconds(), 59, 'set the seconds');
38033 assert.equal(m.milliseconds(), 999, 'set the seconds');
38034 });
38035
38036 test('start of week', function (assert) {
38037 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('week'),
38038 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('weeks'),
38039 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('w');
38040 assert.equal(+m, +ms, 'Plural or singular should work');
38041 assert.equal(+m, +ma, 'Full or abbreviated should work');
38042 assert.equal(m.year(), 2011, 'keep the year');
38043 assert.equal(m.month(), 0, 'rolls back to January');
38044 assert.equal(m.day(), 0, 'set day of week');
38045 assert.equal(m.date(), 30, 'set correct date');
38046 assert.equal(m.hours(), 0, 'strip out the hours');
38047 assert.equal(m.minutes(), 0, 'strip out the minutes');
38048 assert.equal(m.seconds(), 0, 'strip out the seconds');
38049 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
38050 });
38051
38052 test('end of week', function (assert) {
38053 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('week'),
38054 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks'),
38055 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks');
38056 assert.equal(+m, +ms, 'Plural or singular should work');
38057 assert.equal(+m, +ma, 'Full or abbreviated should work');
38058 assert.equal(m.year(), 2011, 'keep the year');
38059 assert.equal(m.month(), 1, 'keep the month');
38060 assert.equal(m.day(), 6, 'set the day of the week');
38061 assert.equal(m.date(), 5, 'set the day');
38062 assert.equal(m.hours(), 23, 'set the hours');
38063 assert.equal(m.minutes(), 59, 'set the minutes');
38064 assert.equal(m.seconds(), 59, 'set the seconds');
38065 assert.equal(m.milliseconds(), 999, 'set the seconds');
38066 });
38067
38068 test('start of iso-week', function (assert) {
38069 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('isoWeek'),
38070 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('isoWeeks'),
38071 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('W');
38072 assert.equal(+m, +ms, 'Plural or singular should work');
38073 assert.equal(+m, +ma, 'Full or abbreviated should work');
38074 assert.equal(m.year(), 2011, 'keep the year');
38075 assert.equal(m.month(), 0, 'rollback to January');
38076 assert.equal(m.isoWeekday(), 1, 'set day of iso-week');
38077 assert.equal(m.date(), 31, 'set correct date');
38078 assert.equal(m.hours(), 0, 'strip out the hours');
38079 assert.equal(m.minutes(), 0, 'strip out the minutes');
38080 assert.equal(m.seconds(), 0, 'strip out the seconds');
38081 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
38082 });
38083
38084 test('end of iso-week', function (assert) {
38085 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('isoWeek'),
38086 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('isoWeeks'),
38087 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('W');
38088 assert.equal(+m, +ms, 'Plural or singular should work');
38089 assert.equal(+m, +ma, 'Full or abbreviated should work');
38090 assert.equal(m.year(), 2011, 'keep the year');
38091 assert.equal(m.month(), 1, 'keep the month');
38092 assert.equal(m.isoWeekday(), 7, 'set the day of the week');
38093 assert.equal(m.date(), 6, 'set the day');
38094 assert.equal(m.hours(), 23, 'set the hours');
38095 assert.equal(m.minutes(), 59, 'set the minutes');
38096 assert.equal(m.seconds(), 59, 'set the seconds');
38097 assert.equal(m.milliseconds(), 999, 'set the seconds');
38098 });
38099
38100 test('start of day', function (assert) {
38101 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('day'),
38102 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('days'),
38103 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('d');
38104 assert.equal(+m, +ms, 'Plural or singular should work');
38105 assert.equal(+m, +ma, 'Full or abbreviated should work');
38106 assert.equal(m.year(), 2011, 'keep the year');
38107 assert.equal(m.month(), 1, 'keep the month');
38108 assert.equal(m.date(), 2, 'keep the day');
38109 assert.equal(m.hours(), 0, 'strip out the hours');
38110 assert.equal(m.minutes(), 0, 'strip out the minutes');
38111 assert.equal(m.seconds(), 0, 'strip out the seconds');
38112 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
38113 });
38114
38115 test('end of day', function (assert) {
38116 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('day'),
38117 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('days'),
38118 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('d');
38119 assert.equal(+m, +ms, 'Plural or singular should work');
38120 assert.equal(+m, +ma, 'Full or abbreviated should work');
38121 assert.equal(m.year(), 2011, 'keep the year');
38122 assert.equal(m.month(), 1, 'keep the month');
38123 assert.equal(m.date(), 2, 'keep the day');
38124 assert.equal(m.hours(), 23, 'set the hours');
38125 assert.equal(m.minutes(), 59, 'set the minutes');
38126 assert.equal(m.seconds(), 59, 'set the seconds');
38127 assert.equal(m.milliseconds(), 999, 'set the seconds');
38128 });
38129
38130 test('start of hour', function (assert) {
38131 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hour'),
38132 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hours'),
38133 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('h');
38134 assert.equal(+m, +ms, 'Plural or singular should work');
38135 assert.equal(+m, +ma, 'Full or abbreviated should work');
38136 assert.equal(m.year(), 2011, 'keep the year');
38137 assert.equal(m.month(), 1, 'keep the month');
38138 assert.equal(m.date(), 2, 'keep the day');
38139 assert.equal(m.hours(), 3, 'keep the hours');
38140 assert.equal(m.minutes(), 0, 'strip out the minutes');
38141 assert.equal(m.seconds(), 0, 'strip out the seconds');
38142 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
38143 });
38144
38145 test('end of hour', function (assert) {
38146 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hour'),
38147 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hours'),
38148 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('h');
38149 assert.equal(+m, +ms, 'Plural or singular should work');
38150 assert.equal(+m, +ma, 'Full or abbreviated should work');
38151 assert.equal(m.year(), 2011, 'keep the year');
38152 assert.equal(m.month(), 1, 'keep the month');
38153 assert.equal(m.date(), 2, 'keep the day');
38154 assert.equal(m.hours(), 3, 'keep the hours');
38155 assert.equal(m.minutes(), 59, 'set the minutes');
38156 assert.equal(m.seconds(), 59, 'set the seconds');
38157 assert.equal(m.milliseconds(), 999, 'set the seconds');
38158 });
38159
38160 test('start of minute', function (assert) {
38161 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minute'),
38162 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minutes'),
38163 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('m');
38164 assert.equal(+m, +ms, 'Plural or singular should work');
38165 assert.equal(+m, +ma, 'Full or abbreviated should work');
38166 assert.equal(m.year(), 2011, 'keep the year');
38167 assert.equal(m.month(), 1, 'keep the month');
38168 assert.equal(m.date(), 2, 'keep the day');
38169 assert.equal(m.hours(), 3, 'keep the hours');
38170 assert.equal(m.minutes(), 4, 'keep the minutes');
38171 assert.equal(m.seconds(), 0, 'strip out the seconds');
38172 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
38173 });
38174
38175 test('end of minute', function (assert) {
38176 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minute'),
38177 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minutes'),
38178 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('m');
38179 assert.equal(+m, +ms, 'Plural or singular should work');
38180 assert.equal(+m, +ma, 'Full or abbreviated should work');
38181 assert.equal(m.year(), 2011, 'keep the year');
38182 assert.equal(m.month(), 1, 'keep the month');
38183 assert.equal(m.date(), 2, 'keep the day');
38184 assert.equal(m.hours(), 3, 'keep the hours');
38185 assert.equal(m.minutes(), 4, 'keep the minutes');
38186 assert.equal(m.seconds(), 59, 'set the seconds');
38187 assert.equal(m.milliseconds(), 999, 'set the seconds');
38188 });
38189
38190 test('start of second', function (assert) {
38191 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('second'),
38192 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('seconds'),
38193 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('s');
38194 assert.equal(+m, +ms, 'Plural or singular should work');
38195 assert.equal(+m, +ma, 'Full or abbreviated should work');
38196 assert.equal(m.year(), 2011, 'keep the year');
38197 assert.equal(m.month(), 1, 'keep the month');
38198 assert.equal(m.date(), 2, 'keep the day');
38199 assert.equal(m.hours(), 3, 'keep the hours');
38200 assert.equal(m.minutes(), 4, 'keep the minutes');
38201 assert.equal(m.seconds(), 5, 'keep the the seconds');
38202 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
38203 });
38204
38205 test('end of second', function (assert) {
38206 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('second'),
38207 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('seconds'),
38208 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('s');
38209 assert.equal(+m, +ms, 'Plural or singular should work');
38210 assert.equal(+m, +ma, 'Full or abbreviated should work');
38211 assert.equal(m.year(), 2011, 'keep the year');
38212 assert.equal(m.month(), 1, 'keep the month');
38213 assert.equal(m.date(), 2, 'keep the day');
38214 assert.equal(m.hours(), 3, 'keep the hours');
38215 assert.equal(m.minutes(), 4, 'keep the minutes');
38216 assert.equal(m.seconds(), 5, 'keep the seconds');
38217 assert.equal(m.milliseconds(), 999, 'set the seconds');
38218 });
38219
38220 test('startOf across DST +1', function (assert) {
38221 var oldUpdateOffset = moment.updateOffset,
38222 // Based on a real story somewhere in America/Los_Angeles
38223 dstAt = moment('2014-03-09T02:00:00-08:00').parseZone(),
38224 m;
38225
38226 moment.updateOffset = function (mom, keepTime) {
38227 if (mom.isBefore(dstAt)) {
38228 mom.utcOffset(-8, keepTime);
38229 } else {
38230 mom.utcOffset(-7, keepTime);
38231 }
38232 };
38233
38234 m = moment('2014-03-15T00:00:00-07:00').parseZone();
38235 m.startOf('M');
38236 assert.equal(m.format(), '2014-03-01T00:00:00-08:00', 'startOf(\'month\') across +1');
38237
38238 m = moment('2014-03-09T09:00:00-07:00').parseZone();
38239 m.startOf('d');
38240 assert.equal(m.format(), '2014-03-09T00:00:00-08:00', 'startOf(\'day\') across +1');
38241
38242 m = moment('2014-03-09T03:05:00-07:00').parseZone();
38243 m.startOf('h');
38244 assert.equal(m.format(), '2014-03-09T03:00:00-07:00', 'startOf(\'hour\') after +1');
38245
38246 m = moment('2014-03-09T01:35:00-08:00').parseZone();
38247 m.startOf('h');
38248 assert.equal(m.format(), '2014-03-09T01:00:00-08:00', 'startOf(\'hour\') before +1');
38249
38250 // There is no such time as 2:30-7 to try startOf('hour') across that
38251
38252 moment.updateOffset = oldUpdateOffset;
38253 });
38254
38255 test('startOf across DST -1', function (assert) {
38256 var oldUpdateOffset = moment.updateOffset,
38257 // Based on a real story somewhere in America/Los_Angeles
38258 dstAt = moment('2014-11-02T02:00:00-07:00').parseZone(),
38259 m;
38260
38261 moment.updateOffset = function (mom, keepTime) {
38262 if (mom.isBefore(dstAt)) {
38263 mom.utcOffset(-7, keepTime);
38264 } else {
38265 mom.utcOffset(-8, keepTime);
38266 }
38267 };
38268
38269 m = moment('2014-11-15T00:00:00-08:00').parseZone();
38270 m.startOf('M');
38271 assert.equal(m.format(), '2014-11-01T00:00:00-07:00', 'startOf(\'month\') across -1');
38272
38273 m = moment('2014-11-02T09:00:00-08:00').parseZone();
38274 m.startOf('d');
38275 assert.equal(m.format(), '2014-11-02T00:00:00-07:00', 'startOf(\'day\') across -1');
38276
38277 // note that utc offset is -8
38278 m = moment('2014-11-02T01:30:00-08:00').parseZone();
38279 m.startOf('h');
38280 assert.equal(m.format(), '2014-11-02T01:00:00-08:00', 'startOf(\'hour\') after +1');
38281
38282 // note that utc offset is -7
38283 m = moment('2014-11-02T01:30:00-07:00').parseZone();
38284 m.startOf('h');
38285 assert.equal(m.format(), '2014-11-02T01:00:00-07:00', 'startOf(\'hour\') before +1');
38286
38287 moment.updateOffset = oldUpdateOffset;
38288 });
38289
38290 test('endOf millisecond and no-arg', function (assert) {
38291 var m = moment();
38292 assert.equal(+m, +m.clone().endOf(), 'endOf without argument should change time');
38293 assert.equal(+m, +m.clone().endOf('ms'), 'endOf with ms argument should change time');
38294 assert.equal(+m, +m.clone().endOf('millisecond'), 'endOf with millisecond argument should change time');
38295 assert.equal(+m, +m.clone().endOf('milliseconds'), 'endOf with milliseconds argument should change time');
38296 });
38297
38298 }));
38299
38300 (function (global, factory) {
38301 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
38302 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
38303 factory(global.moment)
38304 }(this, function (moment) { 'use strict';
38305
38306 /*global QUnit:false*/
38307
38308 var test = QUnit.test;
38309
38310 function module (name, lifecycle) {
38311 QUnit.module(name, {
38312 setup : function () {
38313 moment.locale('en');
38314 moment.createFromInputFallback = function () {
38315 throw new Error('input not handled by moment');
38316 };
38317 if (lifecycle && lifecycle.setup) {
38318 lifecycle.setup();
38319 }
38320 },
38321 teardown : function () {
38322 if (lifecycle && lifecycle.teardown) {
38323 lifecycle.teardown();
38324 }
38325 }
38326 });
38327 }
38328
38329 function localeModule (name, lifecycle) {
38330 QUnit.module('locale:' + name, {
38331 setup : function () {
38332 moment.locale(name);
38333 moment.createFromInputFallback = function () {
38334 throw new Error('input not handled by moment');
38335 };
38336 if (lifecycle && lifecycle.setup) {
38337 lifecycle.setup();
38338 }
38339 },
38340 teardown : function () {
38341 moment.locale('en');
38342 if (lifecycle && lifecycle.teardown) {
38343 lifecycle.teardown();
38344 }
38345 }
38346 });
38347 }
38348
38349 module('string prototype');
38350
38351 test('string prototype overrides call', function (assert) {
38352 var prior = String.prototype.call, b;
38353 String.prototype.call = function () {
38354 return null;
38355 };
38356
38357 b = moment(new Date(2011, 7, 28, 15, 25, 50, 125));
38358 assert.equal(b.format('MMMM Do YYYY, h:mm a'), 'August 28th 2011, 3:25 pm');
38359
38360 String.prototype.call = prior;
38361 });
38362
38363 }));
38364
38365 (function (global, factory) {
38366 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
38367 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
38368 factory(global.moment)
38369 }(this, function (moment) { 'use strict';
38370
38371 /*global QUnit:false*/
38372
38373 var test = QUnit.test;
38374
38375 function module (name, lifecycle) {
38376 QUnit.module(name, {
38377 setup : function () {
38378 moment.locale('en');
38379 moment.createFromInputFallback = function () {
38380 throw new Error('input not handled by moment');
38381 };
38382 if (lifecycle && lifecycle.setup) {
38383 lifecycle.setup();
38384 }
38385 },
38386 teardown : function () {
38387 if (lifecycle && lifecycle.teardown) {
38388 lifecycle.teardown();
38389 }
38390 }
38391 });
38392 }
38393
38394 function localeModule (name, lifecycle) {
38395 QUnit.module('locale:' + name, {
38396 setup : function () {
38397 moment.locale(name);
38398 moment.createFromInputFallback = function () {
38399 throw new Error('input not handled by moment');
38400 };
38401 if (lifecycle && lifecycle.setup) {
38402 lifecycle.setup();
38403 }
38404 },
38405 teardown : function () {
38406 moment.locale('en');
38407 if (lifecycle && lifecycle.teardown) {
38408 lifecycle.teardown();
38409 }
38410 }
38411 });
38412 }
38413
38414 module('to type');
38415
38416 test('toObject', function (assert) {
38417 var expected = {
38418 years:2010,
38419 months:3,
38420 date:5,
38421 hours:15,
38422 minutes:10,
38423 seconds:3,
38424 milliseconds:123
38425 };
38426 assert.deepEqual(moment(expected).toObject(), expected, 'toObject invalid');
38427 });
38428
38429 test('toArray', function (assert) {
38430 var expected = [2014, 11, 26, 11, 46, 58, 17];
38431 assert.deepEqual(moment(expected).toArray(), expected, 'toArray invalid');
38432 });
38433
38434 }));
38435
38436 (function (global, factory) {
38437 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
38438 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
38439 factory(global.moment)
38440 }(this, function (moment) { 'use strict';
38441
38442 /*global QUnit:false*/
38443
38444 var test = QUnit.test;
38445
38446 function module (name, lifecycle) {
38447 QUnit.module(name, {
38448 setup : function () {
38449 moment.locale('en');
38450 moment.createFromInputFallback = function () {
38451 throw new Error('input not handled by moment');
38452 };
38453 if (lifecycle && lifecycle.setup) {
38454 lifecycle.setup();
38455 }
38456 },
38457 teardown : function () {
38458 if (lifecycle && lifecycle.teardown) {
38459 lifecycle.teardown();
38460 }
38461 }
38462 });
38463 }
38464
38465 function localeModule (name, lifecycle) {
38466 QUnit.module('locale:' + name, {
38467 setup : function () {
38468 moment.locale(name);
38469 moment.createFromInputFallback = function () {
38470 throw new Error('input not handled by moment');
38471 };
38472 if (lifecycle && lifecycle.setup) {
38473 lifecycle.setup();
38474 }
38475 },
38476 teardown : function () {
38477 moment.locale('en');
38478 if (lifecycle && lifecycle.teardown) {
38479 lifecycle.teardown();
38480 }
38481 }
38482 });
38483 }
38484
38485 module('utc');
38486
38487 test('utc and local', function (assert) {
38488 var m = moment(Date.UTC(2011, 1, 2, 3, 4, 5, 6)), offset, expected;
38489 m.utc();
38490 // utc
38491 assert.equal(m.date(), 2, 'the day should be correct for utc');
38492 assert.equal(m.day(), 3, 'the date should be correct for utc');
38493 assert.equal(m.hours(), 3, 'the hours should be correct for utc');
38494
38495 // local
38496 m.local();
38497 if (m.zone() > 180) {
38498 assert.equal(m.date(), 1, 'the date should be correct for local');
38499 assert.equal(m.day(), 2, 'the day should be correct for local');
38500 } else {
38501 assert.equal(m.date(), 2, 'the date should be correct for local');
38502 assert.equal(m.day(), 3, 'the day should be correct for local');
38503 }
38504 offset = Math.floor(m.utcOffset() / 60);
38505 expected = (24 + 3 + offset) % 24;
38506 assert.equal(m.hours(), expected, 'the hours (' + m.hours() + ') should be correct for local');
38507 assert.equal(moment().utc().utcOffset(), 0, 'timezone in utc should always be zero');
38508 });
38509
38510 test('creating with utc and no arguments', function (assert) {
38511 var startOfTest = new Date().valueOf(),
38512 momentDefaultUtcTime = moment.utc().valueOf(),
38513 afterMomentCreationTime = new Date().valueOf();
38514
38515 assert.ok(startOfTest <= momentDefaultUtcTime, 'moment UTC default time should be now, not in the past');
38516 assert.ok(momentDefaultUtcTime <= afterMomentCreationTime, 'moment UTC default time should be now, not in the future');
38517 });
38518
38519 test('creating with utc and a date parameter array', function (assert) {
38520 var m = moment.utc([2011, 1, 2, 3, 4, 5, 6]);
38521 assert.equal(m.date(), 2, 'the day should be correct for utc array');
38522 assert.equal(m.hours(), 3, 'the hours should be correct for utc array');
38523
38524 m = moment.utc('2011-02-02 3:04:05', 'YYYY-MM-DD HH:mm:ss');
38525 assert.equal(m.date(), 2, 'the day should be correct for utc parsing format');
38526 assert.equal(m.hours(), 3, 'the hours should be correct for utc parsing format');
38527
38528 m = moment.utc('2011-02-02T03:04:05+00:00');
38529 assert.equal(m.date(), 2, 'the day should be correct for utc parsing iso');
38530 assert.equal(m.hours(), 3, 'the hours should be correct for utc parsing iso');
38531 });
38532
38533 test('creating with utc without timezone', function (assert) {
38534 var m = moment.utc('2012-01-02T08:20:00');
38535 assert.equal(m.date(), 2, 'the day should be correct for utc parse without timezone');
38536 assert.equal(m.hours(), 8, 'the hours should be correct for utc parse without timezone');
38537
38538 m = moment.utc('2012-01-02T08:20:00+09:00');
38539 assert.equal(m.date(), 1, 'the day should be correct for utc parse with timezone');
38540 assert.equal(m.hours(), 23, 'the hours should be correct for utc parse with timezone');
38541 });
38542
38543 test('cloning with utc offset', function (assert) {
38544 var m = moment.utc('2012-01-02T08:20:00');
38545 assert.equal(moment.utc(m)._isUTC, true, 'the local offset should be converted to UTC');
38546 assert.equal(moment.utc(m.clone().utc())._isUTC, true, 'the local offset should stay in UTC');
38547
38548 m.utcOffset(120);
38549 assert.equal(moment.utc(m)._isUTC, true, 'the explicit utc offset should stay in UTC');
38550 assert.equal(moment.utc(m).utcOffset(), 0, 'the explicit utc offset should have an offset of 0');
38551 });
38552
38553 test('weekday with utc', function (assert) {
38554 assert.equal(
38555 moment('2013-09-15T00:00:00Z').utc().weekday(), // first minute of the day
38556 moment('2013-09-15T23:59:00Z').utc().weekday(), // last minute of the day
38557 'a UTC-moment\'s .weekday() should not be affected by the local timezone'
38558 );
38559 });
38560
38561 }));
38562
38563 (function (global, factory) {
38564 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
38565 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
38566 factory(global.moment)
38567 }(this, function (moment) { 'use strict';
38568
38569 /*global QUnit:false*/
38570
38571 var test = QUnit.test;
38572
38573 function module (name, lifecycle) {
38574 QUnit.module(name, {
38575 setup : function () {
38576 moment.locale('en');
38577 moment.createFromInputFallback = function () {
38578 throw new Error('input not handled by moment');
38579 };
38580 if (lifecycle && lifecycle.setup) {
38581 lifecycle.setup();
38582 }
38583 },
38584 teardown : function () {
38585 if (lifecycle && lifecycle.teardown) {
38586 lifecycle.teardown();
38587 }
38588 }
38589 });
38590 }
38591
38592 function localeModule (name, lifecycle) {
38593 QUnit.module('locale:' + name, {
38594 setup : function () {
38595 moment.locale(name);
38596 moment.createFromInputFallback = function () {
38597 throw new Error('input not handled by moment');
38598 };
38599 if (lifecycle && lifecycle.setup) {
38600 lifecycle.setup();
38601 }
38602 },
38603 teardown : function () {
38604 moment.locale('en');
38605 if (lifecycle && lifecycle.teardown) {
38606 lifecycle.teardown();
38607 }
38608 }
38609 });
38610 }
38611
38612 module('utc offset');
38613
38614 test('setter / getter blackbox', function (assert) {
38615 var m = moment([2010]);
38616
38617 assert.equal(m.clone().utcOffset(0).utcOffset(), 0, 'utcOffset 0');
38618
38619 assert.equal(m.clone().utcOffset(1).utcOffset(), 60, 'utcOffset 1 is 60');
38620 assert.equal(m.clone().utcOffset(60).utcOffset(), 60, 'utcOffset 60');
38621 assert.equal(m.clone().utcOffset('+01:00').utcOffset(), 60, 'utcOffset +01:00 is 60');
38622 assert.equal(m.clone().utcOffset('+0100').utcOffset(), 60, 'utcOffset +0100 is 60');
38623
38624 assert.equal(m.clone().utcOffset(-1).utcOffset(), -60, 'utcOffset -1 is -60');
38625 assert.equal(m.clone().utcOffset(-60).utcOffset(), -60, 'utcOffset -60');
38626 assert.equal(m.clone().utcOffset('-01:00').utcOffset(), -60, 'utcOffset -01:00 is -60');
38627 assert.equal(m.clone().utcOffset('-0100').utcOffset(), -60, 'utcOffset -0100 is -60');
38628
38629 assert.equal(m.clone().utcOffset(1.5).utcOffset(), 90, 'utcOffset 1.5 is 90');
38630 assert.equal(m.clone().utcOffset(90).utcOffset(), 90, 'utcOffset 1.5 is 90');
38631 assert.equal(m.clone().utcOffset('+01:30').utcOffset(), 90, 'utcOffset +01:30 is 90');
38632 assert.equal(m.clone().utcOffset('+0130').utcOffset(), 90, 'utcOffset +0130 is 90');
38633
38634 assert.equal(m.clone().utcOffset(-1.5).utcOffset(), -90, 'utcOffset -1.5');
38635 assert.equal(m.clone().utcOffset(-90).utcOffset(), -90, 'utcOffset -90');
38636 assert.equal(m.clone().utcOffset('-01:30').utcOffset(), -90, 'utcOffset +01:30 is 90');
38637 assert.equal(m.clone().utcOffset('-0130').utcOffset(), -90, 'utcOffset +0130 is 90');
38638 });
38639
38640 test('utcOffset shorthand hours -> minutes', function (assert) {
38641 var i;
38642 for (i = -15; i <= 15; ++i) {
38643 assert.equal(moment().utcOffset(i).utcOffset(), i * 60,
38644 '' + i + ' -> ' + i * 60);
38645 }
38646 assert.equal(moment().utcOffset(-16).utcOffset(), -16, '-16 -> -16');
38647 assert.equal(moment().utcOffset(16).utcOffset(), 16, '16 -> 16');
38648 });
38649
38650 test('isLocal, isUtc, isUtcOffset', function (assert) {
38651 assert.ok(moment().isLocal(), 'moment() creates objects in local time');
38652 assert.ok(!moment.utc().isLocal(), 'moment.utc creates objects NOT in local time');
38653 assert.ok(moment.utc().local().isLocal(), 'moment.fn.local() converts to local time');
38654 assert.ok(!moment().utcOffset(5).isLocal(), 'moment.fn.utcOffset(N) puts objects NOT in local time');
38655 assert.ok(moment().utcOffset(5).local().isLocal(), 'moment.fn.local() converts to local time');
38656
38657 assert.ok(moment.utc().isUtc(), 'moment.utc() creates objects in utc time');
38658 assert.ok(moment().utcOffset(0).isUtc(), 'utcOffset(0) is equivalent to utc mode');
38659 assert.ok(!moment().utcOffset(1).isUtc(), 'utcOffset(1) is NOT equivalent to utc mode');
38660
38661 assert.ok(!moment().isUtcOffset(), 'moment() creates objects NOT in utc-offset mode');
38662 assert.ok(moment.utc().isUtcOffset(), 'moment.utc() creates objects in utc-offset mode');
38663 assert.ok(moment().utcOffset(3).isUtcOffset(), 'utcOffset(N != 0) creates objects in utc-offset mode');
38664 assert.ok(moment().utcOffset(0).isUtcOffset(), 'utcOffset(0) creates objects in utc-offset mode');
38665 });
38666
38667 test('isUTC', function (assert) {
38668 assert.ok(moment.utc().isUTC(), 'moment.utc() creates objects in utc time');
38669 assert.ok(moment().utcOffset(0).isUTC(), 'utcOffset(0) is equivalent to utc mode');
38670 assert.ok(!moment().utcOffset(1).isUTC(), 'utcOffset(1) is NOT equivalent to utc mode');
38671 });
38672
38673 test('change hours when changing the utc offset', function (assert) {
38674 var m = moment.utc([2000, 0, 1, 6]);
38675 assert.equal(m.hour(), 6, 'UTC 6AM should be 6AM at +0000');
38676
38677 // sanity check
38678 m.utcOffset(0);
38679 assert.equal(m.hour(), 6, 'UTC 6AM should be 6AM at +0000');
38680
38681 m.utcOffset(-60);
38682 assert.equal(m.hour(), 5, 'UTC 6AM should be 5AM at -0100');
38683
38684 m.utcOffset(60);
38685 assert.equal(m.hour(), 7, 'UTC 6AM should be 7AM at +0100');
38686 });
38687
38688 test('change minutes when changing the utc offset', function (assert) {
38689 var m = moment.utc([2000, 0, 1, 6, 31]);
38690
38691 m.utcOffset(0);
38692 assert.equal(m.format('HH:mm'), '06:31', 'UTC 6:31AM should be 6:31AM at +0000');
38693
38694 m.utcOffset(-30);
38695 assert.equal(m.format('HH:mm'), '06:01', 'UTC 6:31AM should be 6:01AM at -0030');
38696
38697 m.utcOffset(30);
38698 assert.equal(m.format('HH:mm'), '07:01', 'UTC 6:31AM should be 7:01AM at +0030');
38699
38700 m.utcOffset(-1380);
38701 assert.equal(m.format('HH:mm'), '07:31', 'UTC 6:31AM should be 7:31AM at +1380');
38702 });
38703
38704 test('distance from the unix epoch', function (assert) {
38705 var zoneA = moment(),
38706 zoneB = moment(zoneA),
38707 zoneC = moment(zoneA),
38708 zoneD = moment(zoneA),
38709 zoneE = moment(zoneA);
38710
38711 zoneB.utc();
38712 assert.equal(+zoneA, +zoneB, 'moment should equal moment.utc');
38713
38714 zoneC.utcOffset(60);
38715 assert.equal(+zoneA, +zoneC, 'moment should equal moment.utcOffset(60)');
38716
38717 zoneD.utcOffset(-480);
38718 assert.equal(+zoneA, +zoneD,
38719 'moment should equal moment.utcOffset(-480)');
38720
38721 zoneE.utcOffset(-1000);
38722 assert.equal(+zoneA, +zoneE,
38723 'moment should equal moment.utcOffset(-1000)');
38724 });
38725
38726 test('update offset after changing any values', function (assert) {
38727 var oldOffset = moment.updateOffset,
38728 m = moment.utc([2000, 6, 1]);
38729
38730 moment.updateOffset = function (mom, keepTime) {
38731 if (mom.__doChange) {
38732 if (+mom > 962409600000) {
38733 mom.utcOffset(-120, keepTime);
38734 } else {
38735 mom.utcOffset(-60, keepTime);
38736 }
38737 }
38738 };
38739
38740 assert.equal(m.format('ZZ'), '+0000', 'should be at +0000');
38741 assert.equal(m.format('HH:mm'), '00:00', 'should start 12AM at +0000 timezone');
38742
38743 m.__doChange = true;
38744 m.add(1, 'h');
38745
38746 assert.equal(m.format('ZZ'), '-0200', 'should be at -0200');
38747 assert.equal(m.format('HH:mm'), '23:00', '1AM at +0000 should be 11PM at -0200 timezone');
38748
38749 m.subtract(1, 'h');
38750
38751 assert.equal(m.format('ZZ'), '-0100', 'should be at -0100');
38752 assert.equal(m.format('HH:mm'), '23:00', '12AM at +0000 should be 11PM at -0100 timezone');
38753
38754 moment.updateOffset = oldOffset;
38755 });
38756
38757 //////////////////
38758 test('getters and setters', function (assert) {
38759 var a = moment([2011, 5, 20]);
38760
38761 assert.equal(a.clone().utcOffset(-120).year(2012).year(), 2012, 'should get and set year correctly');
38762 assert.equal(a.clone().utcOffset(-120).month(1).month(), 1, 'should get and set month correctly');
38763 assert.equal(a.clone().utcOffset(-120).date(2).date(), 2, 'should get and set date correctly');
38764 assert.equal(a.clone().utcOffset(-120).day(1).day(), 1, 'should get and set day correctly');
38765 assert.equal(a.clone().utcOffset(-120).hour(1).hour(), 1, 'should get and set hour correctly');
38766 assert.equal(a.clone().utcOffset(-120).minute(1).minute(), 1, 'should get and set minute correctly');
38767 });
38768
38769 test('getters', function (assert) {
38770 var a = moment.utc([2012, 0, 1, 0, 0, 0]);
38771
38772 assert.equal(a.clone().utcOffset(-120).year(), 2011, 'should get year correctly');
38773 assert.equal(a.clone().utcOffset(-120).month(), 11, 'should get month correctly');
38774 assert.equal(a.clone().utcOffset(-120).date(), 31, 'should get date correctly');
38775 assert.equal(a.clone().utcOffset(-120).hour(), 22, 'should get hour correctly');
38776 assert.equal(a.clone().utcOffset(-120).minute(), 0, 'should get minute correctly');
38777
38778 assert.equal(a.clone().utcOffset(120).year(), 2012, 'should get year correctly');
38779 assert.equal(a.clone().utcOffset(120).month(), 0, 'should get month correctly');
38780 assert.equal(a.clone().utcOffset(120).date(), 1, 'should get date correctly');
38781 assert.equal(a.clone().utcOffset(120).hour(), 2, 'should get hour correctly');
38782 assert.equal(a.clone().utcOffset(120).minute(), 0, 'should get minute correctly');
38783
38784 assert.equal(a.clone().utcOffset(90).year(), 2012, 'should get year correctly');
38785 assert.equal(a.clone().utcOffset(90).month(), 0, 'should get month correctly');
38786 assert.equal(a.clone().utcOffset(90).date(), 1, 'should get date correctly');
38787 assert.equal(a.clone().utcOffset(90).hour(), 1, 'should get hour correctly');
38788 assert.equal(a.clone().utcOffset(90).minute(), 30, 'should get minute correctly');
38789 });
38790
38791 test('from', function (assert) {
38792 var zoneA = moment(),
38793 zoneB = moment(zoneA).utcOffset(-720),
38794 zoneC = moment(zoneA).utcOffset(-360),
38795 zoneD = moment(zoneA).utcOffset(690),
38796 other = moment(zoneA).add(35, 'm');
38797
38798 assert.equal(zoneA.from(other), zoneB.from(other), 'moment#from should be the same in all zones');
38799 assert.equal(zoneA.from(other), zoneC.from(other), 'moment#from should be the same in all zones');
38800 assert.equal(zoneA.from(other), zoneD.from(other), 'moment#from should be the same in all zones');
38801 });
38802
38803 test('diff', function (assert) {
38804 var zoneA = moment(),
38805 zoneB = moment(zoneA).utcOffset(-720),
38806 zoneC = moment(zoneA).utcOffset(-360),
38807 zoneD = moment(zoneA).utcOffset(690),
38808 other = moment(zoneA).add(35, 'm');
38809
38810 assert.equal(zoneA.diff(other), zoneB.diff(other), 'moment#diff should be the same in all zones');
38811 assert.equal(zoneA.diff(other), zoneC.diff(other), 'moment#diff should be the same in all zones');
38812 assert.equal(zoneA.diff(other), zoneD.diff(other), 'moment#diff should be the same in all zones');
38813
38814 assert.equal(zoneA.diff(other, 'minute', true), zoneB.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
38815 assert.equal(zoneA.diff(other, 'minute', true), zoneC.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
38816 assert.equal(zoneA.diff(other, 'minute', true), zoneD.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
38817
38818 assert.equal(zoneA.diff(other, 'hour', true), zoneB.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
38819 assert.equal(zoneA.diff(other, 'hour', true), zoneC.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
38820 assert.equal(zoneA.diff(other, 'hour', true), zoneD.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
38821 });
38822
38823 test('unix offset and timestamp', function (assert) {
38824 var zoneA = moment(),
38825 zoneB = moment(zoneA).utcOffset(-720),
38826 zoneC = moment(zoneA).utcOffset(-360),
38827 zoneD = moment(zoneA).utcOffset(690);
38828
38829 assert.equal(zoneA.unix(), zoneB.unix(), 'moment#unix should be the same in all zones');
38830 assert.equal(zoneA.unix(), zoneC.unix(), 'moment#unix should be the same in all zones');
38831 assert.equal(zoneA.unix(), zoneD.unix(), 'moment#unix should be the same in all zones');
38832
38833 assert.equal(+zoneA, +zoneB, 'moment#valueOf should be the same in all zones');
38834 assert.equal(+zoneA, +zoneC, 'moment#valueOf should be the same in all zones');
38835 assert.equal(+zoneA, +zoneD, 'moment#valueOf should be the same in all zones');
38836 });
38837
38838 test('cloning', function (assert) {
38839 assert.equal(moment().utcOffset(-120).clone().utcOffset(), -120,
38840 'explicit cloning should retain the offset');
38841 assert.equal(moment().utcOffset(120).clone().utcOffset(), 120,
38842 'explicit cloning should retain the offset');
38843 assert.equal(moment(moment().utcOffset(-120)).utcOffset(), -120,
38844 'implicit cloning should retain the offset');
38845 assert.equal(moment(moment().utcOffset(120)).utcOffset(), 120,
38846 'implicit cloning should retain the offset');
38847 });
38848
38849 test('start of / end of', function (assert) {
38850 var a = moment.utc([2010, 1, 2, 0, 0, 0]).utcOffset(-450);
38851
38852 assert.equal(a.clone().startOf('day').hour(), 0,
38853 'start of day should work on moments with utc offset');
38854 assert.equal(a.clone().startOf('day').minute(), 0,
38855 'start of day should work on moments with utc offset');
38856 assert.equal(a.clone().startOf('hour').minute(), 0,
38857 'start of hour should work on moments with utc offset');
38858
38859 assert.equal(a.clone().endOf('day').hour(), 23,
38860 'end of day should work on moments with utc offset');
38861 assert.equal(a.clone().endOf('day').minute(), 59,
38862 'end of day should work on moments with utc offset');
38863 assert.equal(a.clone().endOf('hour').minute(), 59,
38864 'end of hour should work on moments with utc offset');
38865 });
38866
38867 test('reset offset with moment#utc', function (assert) {
38868 var a = moment.utc([2012]).utcOffset(-480);
38869
38870 assert.equal(a.clone().hour(), 16, 'different utc offset should have different hour');
38871 assert.equal(a.clone().utc().hour(), 0, 'calling moment#utc should reset the offset');
38872 });
38873
38874 test('reset offset with moment#local', function (assert) {
38875 var a = moment([2012]).utcOffset(-480);
38876
38877 assert.equal(a.clone().local().hour(), 0, 'calling moment#local should reset the offset');
38878 });
38879
38880 test('toDate', function (assert) {
38881 var zoneA = new Date(),
38882 zoneB = moment(zoneA).utcOffset(-720).toDate(),
38883 zoneC = moment(zoneA).utcOffset(-360).toDate(),
38884 zoneD = moment(zoneA).utcOffset(690).toDate();
38885
38886 assert.equal(+zoneA, +zoneB, 'moment#toDate should output a date with the right unix timestamp');
38887 assert.equal(+zoneA, +zoneC, 'moment#toDate should output a date with the right unix timestamp');
38888 assert.equal(+zoneA, +zoneD, 'moment#toDate should output a date with the right unix timestamp');
38889 });
38890
38891 test('same / before / after', function (assert) {
38892 var zoneA = moment().utc(),
38893 zoneB = moment(zoneA).utcOffset(-120),
38894 zoneC = moment(zoneA).utcOffset(120);
38895
38896 assert.ok(zoneA.isSame(zoneB), 'two moments with different offsets should be the same');
38897 assert.ok(zoneA.isSame(zoneC), 'two moments with different offsets should be the same');
38898
38899 assert.ok(zoneA.isSame(zoneB, 'hour'), 'two moments with different offsets should be the same hour');
38900 assert.ok(zoneA.isSame(zoneC, 'hour'), 'two moments with different offsets should be the same hour');
38901
38902 zoneA.add(1, 'hour');
38903
38904 assert.ok(zoneA.isAfter(zoneB), 'isAfter should work with two moments with different offsets');
38905 assert.ok(zoneA.isAfter(zoneC), 'isAfter should work with two moments with different offsets');
38906
38907 assert.ok(zoneA.isAfter(zoneB, 'hour'), 'isAfter:hour should work with two moments with different offsets');
38908 assert.ok(zoneA.isAfter(zoneC, 'hour'), 'isAfter:hour should work with two moments with different offsets');
38909
38910 zoneA.subtract(2, 'hour');
38911
38912 assert.ok(zoneA.isBefore(zoneB), 'isBefore should work with two moments with different offsets');
38913 assert.ok(zoneA.isBefore(zoneC), 'isBefore should work with two moments with different offsets');
38914
38915 assert.ok(zoneA.isBefore(zoneB, 'hour'), 'isBefore:hour should work with two moments with different offsets');
38916 assert.ok(zoneA.isBefore(zoneC, 'hour'), 'isBefore:hour should work with two moments with different offsets');
38917 });
38918
38919 test('add / subtract over dst', function (assert) {
38920 var oldOffset = moment.updateOffset,
38921 m = moment.utc([2000, 2, 31, 3]);
38922
38923 moment.updateOffset = function (mom, keepTime) {
38924 if (mom.clone().utc().month() > 2) {
38925 mom.utcOffset(60, keepTime);
38926 } else {
38927 mom.utcOffset(0, keepTime);
38928 }
38929 };
38930
38931 assert.equal(m.hour(), 3, 'should start at 00:00');
38932
38933 m.add(24, 'hour');
38934
38935 assert.equal(m.hour(), 4, 'adding 24 hours should disregard dst');
38936
38937 m.subtract(24, 'hour');
38938
38939 assert.equal(m.hour(), 3, 'subtracting 24 hours should disregard dst');
38940
38941 m.add(1, 'day');
38942
38943 assert.equal(m.hour(), 3, 'adding 1 day should have the same hour');
38944
38945 m.subtract(1, 'day');
38946
38947 assert.equal(m.hour(), 3, 'subtracting 1 day should have the same hour');
38948
38949 m.add(1, 'month');
38950
38951 assert.equal(m.hour(), 3, 'adding 1 month should have the same hour');
38952
38953 m.subtract(1, 'month');
38954
38955 assert.equal(m.hour(), 3, 'subtracting 1 month should have the same hour');
38956
38957 moment.updateOffset = oldOffset;
38958 });
38959
38960 test('isDST', function (assert) {
38961 var oldOffset = moment.updateOffset;
38962
38963 moment.updateOffset = function (mom, keepTime) {
38964 if (mom.month() > 2 && mom.month() < 9) {
38965 mom.utcOffset(60, keepTime);
38966 } else {
38967 mom.utcOffset(0, keepTime);
38968 }
38969 };
38970
38971 assert.ok(!moment().month(0).isDST(), 'Jan should not be summer dst');
38972 assert.ok(moment().month(6).isDST(), 'Jul should be summer dst');
38973 assert.ok(!moment().month(11).isDST(), 'Dec should not be summer dst');
38974
38975 moment.updateOffset = function (mom) {
38976 if (mom.month() > 2 && mom.month() < 9) {
38977 mom.utcOffset(0);
38978 } else {
38979 mom.utcOffset(60);
38980 }
38981 };
38982
38983 assert.ok(moment().month(0).isDST(), 'Jan should be winter dst');
38984 assert.ok(!moment().month(6).isDST(), 'Jul should not be winter dst');
38985 assert.ok(moment().month(11).isDST(), 'Dec should be winter dst');
38986
38987 moment.updateOffset = oldOffset;
38988 });
38989
38990 test('zone names', function (assert) {
38991 assert.equal(moment().zoneAbbr(), '', 'Local zone abbr should be empty');
38992 assert.equal(moment().format('z'), '', 'Local zone formatted abbr should be empty');
38993 assert.equal(moment().zoneName(), '', 'Local zone name should be empty');
38994 assert.equal(moment().format('zz'), '', 'Local zone formatted name should be empty');
38995
38996 assert.equal(moment.utc().zoneAbbr(), 'UTC', 'UTC zone abbr should be UTC');
38997 assert.equal(moment.utc().format('z'), 'UTC', 'UTC zone formatted abbr should be UTC');
38998 assert.equal(moment.utc().zoneName(), 'Coordinated Universal Time', 'UTC zone abbr should be Coordinated Universal Time');
38999 assert.equal(moment.utc().format('zz'), 'Coordinated Universal Time', 'UTC zone formatted abbr should be Coordinated Universal Time');
39000 });
39001
39002 test('hours alignment with UTC', function (assert) {
39003 assert.equal(moment().utcOffset(-120).hasAlignedHourOffset(), true);
39004 assert.equal(moment().utcOffset(180).hasAlignedHourOffset(), true);
39005 assert.equal(moment().utcOffset(-90).hasAlignedHourOffset(), false);
39006 assert.equal(moment().utcOffset(90).hasAlignedHourOffset(), false);
39007 });
39008
39009 test('hours alignment with other zone', function (assert) {
39010 var m = moment().utcOffset(-120);
39011
39012 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-180)), true);
39013 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(180)), true);
39014 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-90)), false);
39015 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(90)), false);
39016
39017 m = moment().utcOffset(-90);
39018
39019 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-180)), false);
39020 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(180)), false);
39021 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-30)), true);
39022 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(30)), true);
39023
39024 m = moment().utcOffset(60);
39025
39026 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-180)), true);
39027 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(180)), true);
39028 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-90)), false);
39029 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(90)), false);
39030
39031 m = moment().utcOffset(-25);
39032
39033 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(35)), true);
39034 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-85)), true);
39035
39036 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-35)), false);
39037 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(85)), false);
39038 });
39039
39040 test('parse zone', function (assert) {
39041 var m = moment('2013-01-01T00:00:00-13:00').parseZone();
39042 assert.equal(m.utcOffset(), -13 * 60);
39043 assert.equal(m.hours(), 0);
39044 });
39045
39046 test('parse zone static', function (assert) {
39047 var m = moment.parseZone('2013-01-01T00:00:00-13:00');
39048 assert.equal(m.utcOffset(), -13 * 60);
39049 assert.equal(m.hours(), 0);
39050 });
39051
39052 test('parse zone with more arguments', function (assert) {
39053 var m;
39054 m = moment.parseZone('2013 01 01 05 -13:00', 'YYYY MM DD HH ZZ');
39055 assert.equal(m.format(), '2013-01-01T05:00:00-13:00', 'accept input and format');
39056 m = moment.parseZone('2013-01-01-13:00', 'YYYY MM DD ZZ', true);
39057 assert.equal(m.isValid(), false, 'accept input, format and strict flag');
39058 m = moment.parseZone('2013-01-01-13:00', ['DD MM YYYY ZZ', 'YYYY MM DD ZZ']);
39059 assert.equal(m.format(), '2013-01-01T00:00:00-13:00', 'accept input and array of formats');
39060 });
39061
39062 test('parse zone with a timezone from the format string', function (assert) {
39063 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY ZZ #####').parseZone();
39064
39065 assert.equal(m.utcOffset(), -4 * 60);
39066 });
39067
39068 test('parse zone without a timezone included in the format string', function (assert) {
39069 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY').parseZone();
39070
39071 assert.equal(m.utcOffset(), 11 * 60);
39072 });
39073
39074 test('timezone format', function (assert) {
39075 assert.equal(moment().utcOffset(60).format('ZZ'), '+0100', '-60 -> +0100');
39076 assert.equal(moment().utcOffset(90).format('ZZ'), '+0130', '-90 -> +0130');
39077 assert.equal(moment().utcOffset(120).format('ZZ'), '+0200', '-120 -> +0200');
39078
39079 assert.equal(moment().utcOffset(-60).format('ZZ'), '-0100', '+60 -> -0100');
39080 assert.equal(moment().utcOffset(-90).format('ZZ'), '-0130', '+90 -> -0130');
39081 assert.equal(moment().utcOffset(-120).format('ZZ'), '-0200', '+120 -> -0200');
39082 });
39083
39084 test('local to utc, keepLocalTime = true', function (assert) {
39085 var m = moment(),
39086 fmt = 'YYYY-DD-MM HH:mm:ss';
39087 assert.equal(m.clone().utc(true).format(fmt), m.format(fmt), 'local to utc failed to keep local time');
39088 });
39089
39090 test('local to utc, keepLocalTime = false', function (assert) {
39091 var m = moment();
39092 assert.equal(m.clone().utc().valueOf(), m.valueOf(), 'local to utc failed to keep utc time (implicit)');
39093 assert.equal(m.clone().utc(false).valueOf(), m.valueOf(), 'local to utc failed to keep utc time (explicit)');
39094 });
39095
39096 test('local to zone, keepLocalTime = true', function (assert) {
39097 var m = moment(),
39098 fmt = 'YYYY-DD-MM HH:mm:ss',
39099 z;
39100
39101 // Apparently there is -12:00 and +14:00
39102 // http://en.wikipedia.org/wiki/UTC+14:00
39103 // http://en.wikipedia.org/wiki/UTC-12:00
39104 for (z = -12; z <= 14; ++z) {
39105 assert.equal(m.clone().utcOffset(z * 60, true).format(fmt),
39106 m.format(fmt),
39107 'local to utcOffset(' + z + ':00) failed to keep local time');
39108 }
39109 });
39110
39111 test('local to zone, keepLocalTime = false', function (assert) {
39112 var m = moment(),
39113 z;
39114
39115 // Apparently there is -12:00 and +14:00
39116 // http://en.wikipedia.org/wiki/UTC+14:00
39117 // http://en.wikipedia.org/wiki/UTC-12:00
39118 for (z = -12; z <= 14; ++z) {
39119 assert.equal(m.clone().utcOffset(z * 60).valueOf(),
39120 m.valueOf(),
39121 'local to utcOffset(' + z + ':00) failed to keep utc time (implicit)');
39122 assert.equal(m.clone().utcOffset(z * 60, false).valueOf(),
39123 m.valueOf(),
39124 'local to utcOffset(' + z + ':00) failed to keep utc time (explicit)');
39125 }
39126 });
39127
39128 test('utc to local, keepLocalTime = true', function (assert) {
39129 var um = moment.utc(),
39130 fmt = 'YYYY-DD-MM HH:mm:ss';
39131
39132 assert.equal(um.clone().local(true).format(fmt), um.format(fmt), 'utc to local failed to keep local time');
39133 });
39134
39135 test('utc to local, keepLocalTime = false', function (assert) {
39136 var um = moment.utc();
39137 assert.equal(um.clone().local().valueOf(), um.valueOf(), 'utc to local failed to keep utc time (implicit)');
39138 assert.equal(um.clone().local(false).valueOf(), um.valueOf(), 'utc to local failed to keep utc time (explicit)');
39139 });
39140
39141 test('zone to local, keepLocalTime = true', function (assert) {
39142 var m = moment(),
39143 fmt = 'YYYY-DD-MM HH:mm:ss',
39144 z;
39145
39146 // Apparently there is -12:00 and +14:00
39147 // http://en.wikipedia.org/wiki/UTC+14:00
39148 // http://en.wikipedia.org/wiki/UTC-12:00
39149 for (z = -12; z <= 14; ++z) {
39150 m.utcOffset(z * 60);
39151
39152 assert.equal(m.clone().local(true).format(fmt),
39153 m.format(fmt),
39154 'utcOffset(' + z + ':00) to local failed to keep local time');
39155 }
39156 });
39157
39158 test('zone to local, keepLocalTime = false', function (assert) {
39159 var m = moment(),
39160 z;
39161
39162 // Apparently there is -12:00 and +14:00
39163 // http://en.wikipedia.org/wiki/UTC+14:00
39164 // http://en.wikipedia.org/wiki/UTC-12:00
39165 for (z = -12; z <= 14; ++z) {
39166 m.utcOffset(z * 60);
39167
39168 assert.equal(m.clone().local(false).valueOf(), m.valueOf(),
39169 'utcOffset(' + z + ':00) to local failed to keep utc time (explicit)');
39170 assert.equal(m.clone().local().valueOf(), m.valueOf(),
39171 'utcOffset(' + z + ':00) to local failed to keep utc time (implicit)');
39172 }
39173 });
39174
39175 }));
39176
39177 (function (global, factory) {
39178 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
39179 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
39180 factory(global.moment)
39181 }(this, function (moment) { 'use strict';
39182
39183 /*global QUnit:false*/
39184
39185 var test = QUnit.test;
39186
39187 function module (name, lifecycle) {
39188 QUnit.module(name, {
39189 setup : function () {
39190 moment.locale('en');
39191 moment.createFromInputFallback = function () {
39192 throw new Error('input not handled by moment');
39193 };
39194 if (lifecycle && lifecycle.setup) {
39195 lifecycle.setup();
39196 }
39197 },
39198 teardown : function () {
39199 if (lifecycle && lifecycle.teardown) {
39200 lifecycle.teardown();
39201 }
39202 }
39203 });
39204 }
39205
39206 function localeModule (name, lifecycle) {
39207 QUnit.module('locale:' + name, {
39208 setup : function () {
39209 moment.locale(name);
39210 moment.createFromInputFallback = function () {
39211 throw new Error('input not handled by moment');
39212 };
39213 if (lifecycle && lifecycle.setup) {
39214 lifecycle.setup();
39215 }
39216 },
39217 teardown : function () {
39218 moment.locale('en');
39219 if (lifecycle && lifecycle.teardown) {
39220 lifecycle.teardown();
39221 }
39222 }
39223 });
39224 }
39225
39226 module('week year');
39227
39228 test('iso week year', function (assert) {
39229 // Some examples taken from http://en.wikipedia.org/wiki/ISO_week
39230 assert.equal(moment([2005, 0, 1]).isoWeekYear(), 2004);
39231 assert.equal(moment([2005, 0, 2]).isoWeekYear(), 2004);
39232 assert.equal(moment([2005, 0, 3]).isoWeekYear(), 2005);
39233 assert.equal(moment([2005, 11, 31]).isoWeekYear(), 2005);
39234 assert.equal(moment([2006, 0, 1]).isoWeekYear(), 2005);
39235 assert.equal(moment([2006, 0, 2]).isoWeekYear(), 2006);
39236 assert.equal(moment([2007, 0, 1]).isoWeekYear(), 2007);
39237 assert.equal(moment([2007, 11, 30]).isoWeekYear(), 2007);
39238 assert.equal(moment([2007, 11, 31]).isoWeekYear(), 2008);
39239 assert.equal(moment([2008, 0, 1]).isoWeekYear(), 2008);
39240 assert.equal(moment([2008, 11, 28]).isoWeekYear(), 2008);
39241 assert.equal(moment([2008, 11, 29]).isoWeekYear(), 2009);
39242 assert.equal(moment([2008, 11, 30]).isoWeekYear(), 2009);
39243 assert.equal(moment([2008, 11, 31]).isoWeekYear(), 2009);
39244 assert.equal(moment([2009, 0, 1]).isoWeekYear(), 2009);
39245 assert.equal(moment([2010, 0, 1]).isoWeekYear(), 2009);
39246 assert.equal(moment([2010, 0, 2]).isoWeekYear(), 2009);
39247 assert.equal(moment([2010, 0, 3]).isoWeekYear(), 2009);
39248 assert.equal(moment([2010, 0, 4]).isoWeekYear(), 2010);
39249 });
39250
39251 test('week year', function (assert) {
39252 // Some examples taken from http://en.wikipedia.org/wiki/ISO_week
39253 moment.locale('dow: 1,doy: 4', {week: {dow: 1, doy: 4}}); // like iso
39254 assert.equal(moment([2005, 0, 1]).weekYear(), 2004);
39255 assert.equal(moment([2005, 0, 2]).weekYear(), 2004);
39256 assert.equal(moment([2005, 0, 3]).weekYear(), 2005);
39257 assert.equal(moment([2005, 11, 31]).weekYear(), 2005);
39258 assert.equal(moment([2006, 0, 1]).weekYear(), 2005);
39259 assert.equal(moment([2006, 0, 2]).weekYear(), 2006);
39260 assert.equal(moment([2007, 0, 1]).weekYear(), 2007);
39261 assert.equal(moment([2007, 11, 30]).weekYear(), 2007);
39262 assert.equal(moment([2007, 11, 31]).weekYear(), 2008);
39263 assert.equal(moment([2008, 0, 1]).weekYear(), 2008);
39264 assert.equal(moment([2008, 11, 28]).weekYear(), 2008);
39265 assert.equal(moment([2008, 11, 29]).weekYear(), 2009);
39266 assert.equal(moment([2008, 11, 30]).weekYear(), 2009);
39267 assert.equal(moment([2008, 11, 31]).weekYear(), 2009);
39268 assert.equal(moment([2009, 0, 1]).weekYear(), 2009);
39269 assert.equal(moment([2010, 0, 1]).weekYear(), 2009);
39270 assert.equal(moment([2010, 0, 2]).weekYear(), 2009);
39271 assert.equal(moment([2010, 0, 3]).weekYear(), 2009);
39272 assert.equal(moment([2010, 0, 4]).weekYear(), 2010);
39273
39274 moment.locale('dow: 1,doy: 7', {week: {dow: 1, doy: 7}});
39275 assert.equal(moment([2004, 11, 26]).weekYear(), 2004);
39276 assert.equal(moment([2004, 11, 27]).weekYear(), 2005);
39277 assert.equal(moment([2005, 11, 25]).weekYear(), 2005);
39278 assert.equal(moment([2005, 11, 26]).weekYear(), 2006);
39279 assert.equal(moment([2006, 11, 31]).weekYear(), 2006);
39280 assert.equal(moment([2007, 0, 1]).weekYear(), 2007);
39281 assert.equal(moment([2007, 11, 30]).weekYear(), 2007);
39282 assert.equal(moment([2007, 11, 31]).weekYear(), 2008);
39283 assert.equal(moment([2008, 11, 28]).weekYear(), 2008);
39284 assert.equal(moment([2008, 11, 29]).weekYear(), 2009);
39285 assert.equal(moment([2009, 11, 27]).weekYear(), 2009);
39286 assert.equal(moment([2009, 11, 28]).weekYear(), 2010);
39287 });
39288
39289 // Verifies that the week number, week day computation is correct for all dow, doy combinations
39290 test('week year roundtrip', function (assert) {
39291 var dow, doy, wd, m;
39292 for (dow = 0; dow < 7; ++dow) {
39293 for (doy = dow; doy < dow + 7; ++doy) {
39294 for (wd = 0; wd < 7; ++wd) {
39295 moment.locale('dow: ' + dow + ', doy: ' + doy, {week: {dow: dow, doy: doy}});
39296 // We use the 10th week as the 1st one can spill to the previous year
39297 m = moment('2015 10 ' + wd, 'gggg w d', true);
39298 assert.equal(m.format('gggg w d'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
39299 m = moment('2015 10 ' + wd, 'gggg w e', true);
39300 assert.equal(m.format('gggg w e'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
39301 }
39302 }
39303 }
39304 });
39305
39306 test('week numbers 2012/2013', function (assert) {
39307 moment.locale('dow: 6, doy: 12', {week: {dow: 6, doy: 12}});
39308 assert.equal(52, moment('2012-12-28', 'YYYY-MM-DD').week()); // 51 -- should be 52?
39309 assert.equal(1, moment('2012-12-29', 'YYYY-MM-DD').week()); // 52 -- should be 1
39310 assert.equal(1, moment('2013-01-01', 'YYYY-MM-DD').week()); // 52 -- should be 1
39311 assert.equal(2, moment('2013-01-08', 'YYYY-MM-DD').week()); // 53 -- should be 2
39312 assert.equal(2, moment('2013-01-11', 'YYYY-MM-DD').week()); // 53 -- should be 2
39313 assert.equal(3, moment('2013-01-12', 'YYYY-MM-DD').week()); // 1 -- should be 3
39314 assert.equal(52, moment().weeksInYear(2012)); // 52
39315 });
39316
39317 }));
39318
39319 (function (global, factory) {
39320 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
39321 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
39322 factory(global.moment)
39323 }(this, function (moment) { 'use strict';
39324
39325 /*global QUnit:false*/
39326
39327 var test = QUnit.test;
39328
39329 function module (name, lifecycle) {
39330 QUnit.module(name, {
39331 setup : function () {
39332 moment.locale('en');
39333 moment.createFromInputFallback = function () {
39334 throw new Error('input not handled by moment');
39335 };
39336 if (lifecycle && lifecycle.setup) {
39337 lifecycle.setup();
39338 }
39339 },
39340 teardown : function () {
39341 if (lifecycle && lifecycle.teardown) {
39342 lifecycle.teardown();
39343 }
39344 }
39345 });
39346 }
39347
39348 function localeModule (name, lifecycle) {
39349 QUnit.module('locale:' + name, {
39350 setup : function () {
39351 moment.locale(name);
39352 moment.createFromInputFallback = function () {
39353 throw new Error('input not handled by moment');
39354 };
39355 if (lifecycle && lifecycle.setup) {
39356 lifecycle.setup();
39357 }
39358 },
39359 teardown : function () {
39360 moment.locale('en');
39361 if (lifecycle && lifecycle.teardown) {
39362 lifecycle.teardown();
39363 }
39364 }
39365 });
39366 }
39367
39368 module('week day');
39369
39370 test('iso weekday', function (assert) {
39371 var i;
39372
39373 for (i = 0; i < 7; ++i) {
39374 moment.locale('dow:' + i + ',doy: 6', {week: {dow: i, doy: 6}});
39375 assert.equal(moment([1985, 1, 4]).isoWeekday(), 1, 'Feb 4 1985 is Monday -- 1st day');
39376 assert.equal(moment([2029, 8, 18]).isoWeekday(), 2, 'Sep 18 2029 is Tuesday -- 2nd day');
39377 assert.equal(moment([2013, 3, 24]).isoWeekday(), 3, 'Apr 24 2013 is Wednesday -- 3rd day');
39378 assert.equal(moment([2015, 2, 5]).isoWeekday(), 4, 'Mar 5 2015 is Thursday -- 4th day');
39379 assert.equal(moment([1970, 0, 2]).isoWeekday(), 5, 'Jan 2 1970 is Friday -- 5th day');
39380 assert.equal(moment([2001, 4, 12]).isoWeekday(), 6, 'May 12 2001 is Saturday -- 6th day');
39381 assert.equal(moment([2000, 0, 2]).isoWeekday(), 7, 'Jan 2 2000 is Sunday -- 7th day');
39382 }
39383 });
39384
39385 test('iso weekday setter', function (assert) {
39386 var a = moment([2011, 0, 10]);
39387 assert.equal(moment(a).isoWeekday(1).date(), 10, 'set from mon to mon');
39388 assert.equal(moment(a).isoWeekday(4).date(), 13, 'set from mon to thu');
39389 assert.equal(moment(a).isoWeekday(7).date(), 16, 'set from mon to sun');
39390 assert.equal(moment(a).isoWeekday(-6).date(), 3, 'set from mon to last mon');
39391 assert.equal(moment(a).isoWeekday(-3).date(), 6, 'set from mon to last thu');
39392 assert.equal(moment(a).isoWeekday(0).date(), 9, 'set from mon to last sun');
39393 assert.equal(moment(a).isoWeekday(8).date(), 17, 'set from mon to next mon');
39394 assert.equal(moment(a).isoWeekday(11).date(), 20, 'set from mon to next thu');
39395 assert.equal(moment(a).isoWeekday(14).date(), 23, 'set from mon to next sun');
39396
39397 a = moment([2011, 0, 13]);
39398 assert.equal(moment(a).isoWeekday(1).date(), 10, 'set from thu to mon');
39399 assert.equal(moment(a).isoWeekday(4).date(), 13, 'set from thu to thu');
39400 assert.equal(moment(a).isoWeekday(7).date(), 16, 'set from thu to sun');
39401 assert.equal(moment(a).isoWeekday(-6).date(), 3, 'set from thu to last mon');
39402 assert.equal(moment(a).isoWeekday(-3).date(), 6, 'set from thu to last thu');
39403 assert.equal(moment(a).isoWeekday(0).date(), 9, 'set from thu to last sun');
39404 assert.equal(moment(a).isoWeekday(8).date(), 17, 'set from thu to next mon');
39405 assert.equal(moment(a).isoWeekday(11).date(), 20, 'set from thu to next thu');
39406 assert.equal(moment(a).isoWeekday(14).date(), 23, 'set from thu to next sun');
39407
39408 a = moment([2011, 0, 16]);
39409 assert.equal(moment(a).isoWeekday(1).date(), 10, 'set from sun to mon');
39410 assert.equal(moment(a).isoWeekday(4).date(), 13, 'set from sun to thu');
39411 assert.equal(moment(a).isoWeekday(7).date(), 16, 'set from sun to sun');
39412 assert.equal(moment(a).isoWeekday(-6).date(), 3, 'set from sun to last mon');
39413 assert.equal(moment(a).isoWeekday(-3).date(), 6, 'set from sun to last thu');
39414 assert.equal(moment(a).isoWeekday(0).date(), 9, 'set from sun to last sun');
39415 assert.equal(moment(a).isoWeekday(8).date(), 17, 'set from sun to next mon');
39416 assert.equal(moment(a).isoWeekday(11).date(), 20, 'set from sun to next thu');
39417 assert.equal(moment(a).isoWeekday(14).date(), 23, 'set from sun to next sun');
39418 });
39419
39420 test('weekday first day of week Sunday (dow 0)', function (assert) {
39421 moment.locale('dow: 0,doy: 6', {week: {dow: 0, doy: 6}});
39422 assert.equal(moment([1985, 1, 3]).weekday(), 0, 'Feb 3 1985 is Sunday -- 0th day');
39423 assert.equal(moment([2029, 8, 17]).weekday(), 1, 'Sep 17 2029 is Monday -- 1st day');
39424 assert.equal(moment([2013, 3, 23]).weekday(), 2, 'Apr 23 2013 is Tuesday -- 2nd day');
39425 assert.equal(moment([2015, 2, 4]).weekday(), 3, 'Mar 4 2015 is Wednesday -- 3nd day');
39426 assert.equal(moment([1970, 0, 1]).weekday(), 4, 'Jan 1 1970 is Thursday -- 4th day');
39427 assert.equal(moment([2001, 4, 11]).weekday(), 5, 'May 11 2001 is Friday -- 5th day');
39428 assert.equal(moment([2000, 0, 1]).weekday(), 6, 'Jan 1 2000 is Saturday -- 6th day');
39429 });
39430
39431 test('weekday first day of week Monday (dow 1)', function (assert) {
39432 moment.locale('dow: 1,doy: 6', {week: {dow: 1, doy: 6}});
39433 assert.equal(moment([1985, 1, 4]).weekday(), 0, 'Feb 4 1985 is Monday -- 0th day');
39434 assert.equal(moment([2029, 8, 18]).weekday(), 1, 'Sep 18 2029 is Tuesday -- 1st day');
39435 assert.equal(moment([2013, 3, 24]).weekday(), 2, 'Apr 24 2013 is Wednesday -- 2nd day');
39436 assert.equal(moment([2015, 2, 5]).weekday(), 3, 'Mar 5 2015 is Thursday -- 3nd day');
39437 assert.equal(moment([1970, 0, 2]).weekday(), 4, 'Jan 2 1970 is Friday -- 4th day');
39438 assert.equal(moment([2001, 4, 12]).weekday(), 5, 'May 12 2001 is Saturday -- 5th day');
39439 assert.equal(moment([2000, 0, 2]).weekday(), 6, 'Jan 2 2000 is Sunday -- 6th day');
39440 });
39441
39442 test('weekday first day of week Tuesday (dow 2)', function (assert) {
39443 moment.locale('dow: 2,doy: 6', {week: {dow: 2, doy: 6}});
39444 assert.equal(moment([1985, 1, 5]).weekday(), 0, 'Feb 5 1985 is Tuesday -- 0th day');
39445 assert.equal(moment([2029, 8, 19]).weekday(), 1, 'Sep 19 2029 is Wednesday -- 1st day');
39446 assert.equal(moment([2013, 3, 25]).weekday(), 2, 'Apr 25 2013 is Thursday -- 2nd day');
39447 assert.equal(moment([2015, 2, 6]).weekday(), 3, 'Mar 6 2015 is Friday -- 3nd day');
39448 assert.equal(moment([1970, 0, 3]).weekday(), 4, 'Jan 3 1970 is Staturday -- 4th day');
39449 assert.equal(moment([2001, 4, 13]).weekday(), 5, 'May 13 2001 is Sunday -- 5th day');
39450 assert.equal(moment([2000, 0, 3]).weekday(), 6, 'Jan 3 2000 is Monday -- 6th day');
39451 });
39452
39453 test('weekday first day of week Wednesday (dow 3)', function (assert) {
39454 moment.locale('dow: 3,doy: 6', {week: {dow: 3, doy: 6}});
39455 assert.equal(moment([1985, 1, 6]).weekday(), 0, 'Feb 6 1985 is Wednesday -- 0th day');
39456 assert.equal(moment([2029, 8, 20]).weekday(), 1, 'Sep 20 2029 is Thursday -- 1st day');
39457 assert.equal(moment([2013, 3, 26]).weekday(), 2, 'Apr 26 2013 is Friday -- 2nd day');
39458 assert.equal(moment([2015, 2, 7]).weekday(), 3, 'Mar 7 2015 is Saturday -- 3nd day');
39459 assert.equal(moment([1970, 0, 4]).weekday(), 4, 'Jan 4 1970 is Sunday -- 4th day');
39460 assert.equal(moment([2001, 4, 14]).weekday(), 5, 'May 14 2001 is Monday -- 5th day');
39461 assert.equal(moment([2000, 0, 4]).weekday(), 6, 'Jan 4 2000 is Tuesday -- 6th day');
39462 moment.locale('dow:3,doy:6', null);
39463 });
39464
39465 test('weekday first day of week Thursday (dow 4)', function (assert) {
39466 moment.locale('dow: 4,doy: 6', {week: {dow: 4, doy: 6}});
39467 assert.equal(moment([1985, 1, 7]).weekday(), 0, 'Feb 7 1985 is Thursday -- 0th day');
39468 assert.equal(moment([2029, 8, 21]).weekday(), 1, 'Sep 21 2029 is Friday -- 1st day');
39469 assert.equal(moment([2013, 3, 27]).weekday(), 2, 'Apr 27 2013 is Saturday -- 2nd day');
39470 assert.equal(moment([2015, 2, 8]).weekday(), 3, 'Mar 8 2015 is Sunday -- 3nd day');
39471 assert.equal(moment([1970, 0, 5]).weekday(), 4, 'Jan 5 1970 is Monday -- 4th day');
39472 assert.equal(moment([2001, 4, 15]).weekday(), 5, 'May 15 2001 is Tuesday -- 5th day');
39473 assert.equal(moment([2000, 0, 5]).weekday(), 6, 'Jan 5 2000 is Wednesday -- 6th day');
39474 });
39475
39476 test('weekday first day of week Friday (dow 5)', function (assert) {
39477 moment.locale('dow: 5,doy: 6', {week: {dow: 5, doy: 6}});
39478 assert.equal(moment([1985, 1, 8]).weekday(), 0, 'Feb 8 1985 is Friday -- 0th day');
39479 assert.equal(moment([2029, 8, 22]).weekday(), 1, 'Sep 22 2029 is Staturday -- 1st day');
39480 assert.equal(moment([2013, 3, 28]).weekday(), 2, 'Apr 28 2013 is Sunday -- 2nd day');
39481 assert.equal(moment([2015, 2, 9]).weekday(), 3, 'Mar 9 2015 is Monday -- 3nd day');
39482 assert.equal(moment([1970, 0, 6]).weekday(), 4, 'Jan 6 1970 is Tuesday -- 4th day');
39483 assert.equal(moment([2001, 4, 16]).weekday(), 5, 'May 16 2001 is Wednesday -- 5th day');
39484 assert.equal(moment([2000, 0, 6]).weekday(), 6, 'Jan 6 2000 is Thursday -- 6th day');
39485 });
39486
39487 test('weekday first day of week Saturday (dow 6)', function (assert) {
39488 moment.locale('dow: 6,doy: 6', {week: {dow: 6, doy: 6}});
39489 assert.equal(moment([1985, 1, 9]).weekday(), 0, 'Feb 9 1985 is Staturday -- 0th day');
39490 assert.equal(moment([2029, 8, 23]).weekday(), 1, 'Sep 23 2029 is Sunday -- 1st day');
39491 assert.equal(moment([2013, 3, 29]).weekday(), 2, 'Apr 29 2013 is Monday -- 2nd day');
39492 assert.equal(moment([2015, 2, 10]).weekday(), 3, 'Mar 10 2015 is Tuesday -- 3nd day');
39493 assert.equal(moment([1970, 0, 7]).weekday(), 4, 'Jan 7 1970 is Wednesday -- 4th day');
39494 assert.equal(moment([2001, 4, 17]).weekday(), 5, 'May 17 2001 is Thursday -- 5th day');
39495 assert.equal(moment([2000, 0, 7]).weekday(), 6, 'Jan 7 2000 is Friday -- 6th day');
39496 });
39497
39498 }));
39499
39500 (function (global, factory) {
39501 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
39502 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
39503 factory(global.moment)
39504 }(this, function (moment) { 'use strict';
39505
39506 /*global QUnit:false*/
39507
39508 var test = QUnit.test;
39509
39510 function module (name, lifecycle) {
39511 QUnit.module(name, {
39512 setup : function () {
39513 moment.locale('en');
39514 moment.createFromInputFallback = function () {
39515 throw new Error('input not handled by moment');
39516 };
39517 if (lifecycle && lifecycle.setup) {
39518 lifecycle.setup();
39519 }
39520 },
39521 teardown : function () {
39522 if (lifecycle && lifecycle.teardown) {
39523 lifecycle.teardown();
39524 }
39525 }
39526 });
39527 }
39528
39529 function localeModule (name, lifecycle) {
39530 QUnit.module('locale:' + name, {
39531 setup : function () {
39532 moment.locale(name);
39533 moment.createFromInputFallback = function () {
39534 throw new Error('input not handled by moment');
39535 };
39536 if (lifecycle && lifecycle.setup) {
39537 lifecycle.setup();
39538 }
39539 },
39540 teardown : function () {
39541 moment.locale('en');
39542 if (lifecycle && lifecycle.teardown) {
39543 lifecycle.teardown();
39544 }
39545 }
39546 });
39547 }
39548
39549 module('weeks');
39550
39551 test('day of year', function (assert) {
39552 assert.equal(moment([2000, 0, 1]).dayOfYear(), 1, 'Jan 1 2000 should be day 1 of the year');
39553 assert.equal(moment([2000, 1, 28]).dayOfYear(), 59, 'Feb 28 2000 should be day 59 of the year');
39554 assert.equal(moment([2000, 1, 29]).dayOfYear(), 60, 'Feb 28 2000 should be day 60 of the year');
39555 assert.equal(moment([2000, 11, 31]).dayOfYear(), 366, 'Dec 31 2000 should be day 366 of the year');
39556 assert.equal(moment([2001, 0, 1]).dayOfYear(), 1, 'Jan 1 2001 should be day 1 of the year');
39557 assert.equal(moment([2001, 1, 28]).dayOfYear(), 59, 'Feb 28 2001 should be day 59 of the year');
39558 assert.equal(moment([2001, 2, 1]).dayOfYear(), 60, 'Mar 1 2001 should be day 60 of the year');
39559 assert.equal(moment([2001, 11, 31]).dayOfYear(), 365, 'Dec 31 2001 should be day 365 of the year');
39560 });
39561
39562 test('day of year setters', function (assert) {
39563 assert.equal(moment([2000, 0, 1]).dayOfYear(200).dayOfYear(), 200, 'Setting Jan 1 2000 day of the year to 200 should work');
39564 assert.equal(moment([2000, 1, 28]).dayOfYear(200).dayOfYear(), 200, 'Setting Feb 28 2000 day of the year to 200 should work');
39565 assert.equal(moment([2000, 1, 29]).dayOfYear(200).dayOfYear(), 200, 'Setting Feb 28 2000 day of the year to 200 should work');
39566 assert.equal(moment([2000, 11, 31]).dayOfYear(200).dayOfYear(), 200, 'Setting Dec 31 2000 day of the year to 200 should work');
39567 assert.equal(moment().dayOfYear(1).dayOfYear(), 1, 'Setting day of the year to 1 should work');
39568 assert.equal(moment().dayOfYear(59).dayOfYear(), 59, 'Setting day of the year to 59 should work');
39569 assert.equal(moment().dayOfYear(60).dayOfYear(), 60, 'Setting day of the year to 60 should work');
39570 assert.equal(moment().dayOfYear(365).dayOfYear(), 365, 'Setting day of the year to 365 should work');
39571 });
39572
39573 test('iso weeks year starting sunday', function (assert) {
39574 assert.equal(moment([2012, 0, 1]).isoWeek(), 52, 'Jan 1 2012 should be iso week 52');
39575 assert.equal(moment([2012, 0, 2]).isoWeek(), 1, 'Jan 2 2012 should be iso week 1');
39576 assert.equal(moment([2012, 0, 8]).isoWeek(), 1, 'Jan 8 2012 should be iso week 1');
39577 assert.equal(moment([2012, 0, 9]).isoWeek(), 2, 'Jan 9 2012 should be iso week 2');
39578 assert.equal(moment([2012, 0, 15]).isoWeek(), 2, 'Jan 15 2012 should be iso week 2');
39579 });
39580
39581 test('iso weeks year starting monday', function (assert) {
39582 assert.equal(moment([2007, 0, 1]).isoWeek(), 1, 'Jan 1 2007 should be iso week 1');
39583 assert.equal(moment([2007, 0, 7]).isoWeek(), 1, 'Jan 7 2007 should be iso week 1');
39584 assert.equal(moment([2007, 0, 8]).isoWeek(), 2, 'Jan 8 2007 should be iso week 2');
39585 assert.equal(moment([2007, 0, 14]).isoWeek(), 2, 'Jan 14 2007 should be iso week 2');
39586 assert.equal(moment([2007, 0, 15]).isoWeek(), 3, 'Jan 15 2007 should be iso week 3');
39587 });
39588
39589 test('iso weeks year starting tuesday', function (assert) {
39590 assert.equal(moment([2007, 11, 31]).isoWeek(), 1, 'Dec 31 2007 should be iso week 1');
39591 assert.equal(moment([2008, 0, 1]).isoWeek(), 1, 'Jan 1 2008 should be iso week 1');
39592 assert.equal(moment([2008, 0, 6]).isoWeek(), 1, 'Jan 6 2008 should be iso week 1');
39593 assert.equal(moment([2008, 0, 7]).isoWeek(), 2, 'Jan 7 2008 should be iso week 2');
39594 assert.equal(moment([2008, 0, 13]).isoWeek(), 2, 'Jan 13 2008 should be iso week 2');
39595 assert.equal(moment([2008, 0, 14]).isoWeek(), 3, 'Jan 14 2008 should be iso week 3');
39596 });
39597
39598 test('iso weeks year starting wednesday', function (assert) {
39599 assert.equal(moment([2002, 11, 30]).isoWeek(), 1, 'Dec 30 2002 should be iso week 1');
39600 assert.equal(moment([2003, 0, 1]).isoWeek(), 1, 'Jan 1 2003 should be iso week 1');
39601 assert.equal(moment([2003, 0, 5]).isoWeek(), 1, 'Jan 5 2003 should be iso week 1');
39602 assert.equal(moment([2003, 0, 6]).isoWeek(), 2, 'Jan 6 2003 should be iso week 2');
39603 assert.equal(moment([2003, 0, 12]).isoWeek(), 2, 'Jan 12 2003 should be iso week 2');
39604 assert.equal(moment([2003, 0, 13]).isoWeek(), 3, 'Jan 13 2003 should be iso week 3');
39605 });
39606
39607 test('iso weeks year starting thursday', function (assert) {
39608 assert.equal(moment([2008, 11, 29]).isoWeek(), 1, 'Dec 29 2008 should be iso week 1');
39609 assert.equal(moment([2009, 0, 1]).isoWeek(), 1, 'Jan 1 2009 should be iso week 1');
39610 assert.equal(moment([2009, 0, 4]).isoWeek(), 1, 'Jan 4 2009 should be iso week 1');
39611 assert.equal(moment([2009, 0, 5]).isoWeek(), 2, 'Jan 5 2009 should be iso week 2');
39612 assert.equal(moment([2009, 0, 11]).isoWeek(), 2, 'Jan 11 2009 should be iso week 2');
39613 assert.equal(moment([2009, 0, 13]).isoWeek(), 3, 'Jan 12 2009 should be iso week 3');
39614 });
39615
39616 test('iso weeks year starting friday', function (assert) {
39617 assert.equal(moment([2009, 11, 28]).isoWeek(), 53, 'Dec 28 2009 should be iso week 53');
39618 assert.equal(moment([2010, 0, 1]).isoWeek(), 53, 'Jan 1 2010 should be iso week 53');
39619 assert.equal(moment([2010, 0, 3]).isoWeek(), 53, 'Jan 3 2010 should be iso week 53');
39620 assert.equal(moment([2010, 0, 4]).isoWeek(), 1, 'Jan 4 2010 should be iso week 1');
39621 assert.equal(moment([2010, 0, 10]).isoWeek(), 1, 'Jan 10 2010 should be iso week 1');
39622 assert.equal(moment([2010, 0, 11]).isoWeek(), 2, 'Jan 11 2010 should be iso week 2');
39623 });
39624
39625 test('iso weeks year starting saturday', function (assert) {
39626 assert.equal(moment([2010, 11, 27]).isoWeek(), 52, 'Dec 27 2010 should be iso week 52');
39627 assert.equal(moment([2011, 0, 1]).isoWeek(), 52, 'Jan 1 2011 should be iso week 52');
39628 assert.equal(moment([2011, 0, 2]).isoWeek(), 52, 'Jan 2 2011 should be iso week 52');
39629 assert.equal(moment([2011, 0, 3]).isoWeek(), 1, 'Jan 3 2011 should be iso week 1');
39630 assert.equal(moment([2011, 0, 9]).isoWeek(), 1, 'Jan 9 2011 should be iso week 1');
39631 assert.equal(moment([2011, 0, 10]).isoWeek(), 2, 'Jan 10 2011 should be iso week 2');
39632 });
39633
39634 test('iso weeks year starting sunday formatted', function (assert) {
39635 assert.equal(moment([2012, 0, 1]).format('W WW Wo'), '52 52 52nd', 'Jan 1 2012 should be iso week 52');
39636 assert.equal(moment([2012, 0, 2]).format('W WW Wo'), '1 01 1st', 'Jan 2 2012 should be iso week 1');
39637 assert.equal(moment([2012, 0, 8]).format('W WW Wo'), '1 01 1st', 'Jan 8 2012 should be iso week 1');
39638 assert.equal(moment([2012, 0, 9]).format('W WW Wo'), '2 02 2nd', 'Jan 9 2012 should be iso week 2');
39639 assert.equal(moment([2012, 0, 15]).format('W WW Wo'), '2 02 2nd', 'Jan 15 2012 should be iso week 2');
39640 });
39641
39642 test('weeks plural year starting sunday', function (assert) {
39643 assert.equal(moment([2012, 0, 1]).weeks(), 1, 'Jan 1 2012 should be week 1');
39644 assert.equal(moment([2012, 0, 7]).weeks(), 1, 'Jan 7 2012 should be week 1');
39645 assert.equal(moment([2012, 0, 8]).weeks(), 2, 'Jan 8 2012 should be week 2');
39646 assert.equal(moment([2012, 0, 14]).weeks(), 2, 'Jan 14 2012 should be week 2');
39647 assert.equal(moment([2012, 0, 15]).weeks(), 3, 'Jan 15 2012 should be week 3');
39648 });
39649
39650 test('iso weeks plural year starting sunday', function (assert) {
39651 assert.equal(moment([2012, 0, 1]).isoWeeks(), 52, 'Jan 1 2012 should be iso week 52');
39652 assert.equal(moment([2012, 0, 2]).isoWeeks(), 1, 'Jan 2 2012 should be iso week 1');
39653 assert.equal(moment([2012, 0, 8]).isoWeeks(), 1, 'Jan 8 2012 should be iso week 1');
39654 assert.equal(moment([2012, 0, 9]).isoWeeks(), 2, 'Jan 9 2012 should be iso week 2');
39655 assert.equal(moment([2012, 0, 15]).isoWeeks(), 2, 'Jan 15 2012 should be iso week 2');
39656 });
39657
39658 test('weeks setter', function (assert) {
39659 assert.equal(moment([2012, 0, 1]).week(30).week(), 30, 'Setting Jan 1 2012 to week 30 should work');
39660 assert.equal(moment([2012, 0, 7]).week(30).week(), 30, 'Setting Jan 7 2012 to week 30 should work');
39661 assert.equal(moment([2012, 0, 8]).week(30).week(), 30, 'Setting Jan 8 2012 to week 30 should work');
39662 assert.equal(moment([2012, 0, 14]).week(30).week(), 30, 'Setting Jan 14 2012 to week 30 should work');
39663 assert.equal(moment([2012, 0, 15]).week(30).week(), 30, 'Setting Jan 15 2012 to week 30 should work');
39664 });
39665
39666 test('iso weeks setter', function (assert) {
39667 assert.equal(moment([2012, 0, 1]).isoWeeks(25).isoWeeks(), 25, 'Setting Jan 1 2012 to week 25 should work');
39668 assert.equal(moment([2012, 0, 2]).isoWeeks(24).isoWeeks(), 24, 'Setting Jan 2 2012 to week 24 should work');
39669 assert.equal(moment([2012, 0, 8]).isoWeeks(23).isoWeeks(), 23, 'Setting Jan 8 2012 to week 23 should work');
39670 assert.equal(moment([2012, 0, 9]).isoWeeks(22).isoWeeks(), 22, 'Setting Jan 9 2012 to week 22 should work');
39671 assert.equal(moment([2012, 0, 15]).isoWeeks(21).isoWeeks(), 21, 'Setting Jan 15 2012 to week 21 should work');
39672 });
39673
39674 test('iso weeks setter day of year', function (assert) {
39675 assert.equal(moment([2012, 0, 1]).isoWeek(1).dayOfYear(), 9, 'Setting Jan 1 2012 to week 1 should be day of year 8');
39676 assert.equal(moment([2012, 0, 1]).isoWeek(1).year(), 2011, 'Setting Jan 1 2012 to week 1 should be year 2011');
39677 assert.equal(moment([2012, 0, 2]).isoWeek(1).dayOfYear(), 2, 'Setting Jan 2 2012 to week 1 should be day of year 2');
39678 assert.equal(moment([2012, 0, 8]).isoWeek(1).dayOfYear(), 8, 'Setting Jan 8 2012 to week 1 should be day of year 8');
39679 assert.equal(moment([2012, 0, 9]).isoWeek(1).dayOfYear(), 2, 'Setting Jan 9 2012 to week 1 should be day of year 2');
39680 assert.equal(moment([2012, 0, 15]).isoWeek(1).dayOfYear(), 8, 'Setting Jan 15 2012 to week 1 should be day of year 8');
39681 });
39682
39683 test('years with iso week 53', function (assert) {
39684 // Based on a table taken from http://en.wikipedia.org/wiki/ISO_week_date
39685 // (as downloaded on 2014-01-06) listing the 71 years in a 400-year cycle
39686 // that have 53 weeks; in this case reflecting the 2000 based cycle
39687 assert.equal(moment([2004, 11, 31]).isoWeek(), 53, 'Dec 31 2004 should be iso week 53');
39688 assert.equal(moment([2009, 11, 31]).isoWeek(), 53, 'Dec 31 2009 should be iso week 53');
39689 assert.equal(moment([2015, 11, 31]).isoWeek(), 53, 'Dec 31 2015 should be iso week 53');
39690 assert.equal(moment([2020, 11, 31]).isoWeek(), 53, 'Dec 31 2020 should be iso week 53');
39691 assert.equal(moment([2026, 11, 31]).isoWeek(), 53, 'Dec 31 2026 should be iso week 53');
39692 assert.equal(moment([2032, 11, 31]).isoWeek(), 53, 'Dec 31 2032 should be iso week 53');
39693 assert.equal(moment([2037, 11, 31]).isoWeek(), 53, 'Dec 31 2037 should be iso week 53');
39694 assert.equal(moment([2043, 11, 31]).isoWeek(), 53, 'Dec 31 2043 should be iso week 53');
39695 assert.equal(moment([2048, 11, 31]).isoWeek(), 53, 'Dec 31 2048 should be iso week 53');
39696 assert.equal(moment([2054, 11, 31]).isoWeek(), 53, 'Dec 31 2054 should be iso week 53');
39697 assert.equal(moment([2060, 11, 31]).isoWeek(), 53, 'Dec 31 2060 should be iso week 53');
39698 assert.equal(moment([2065, 11, 31]).isoWeek(), 53, 'Dec 31 2065 should be iso week 53');
39699 assert.equal(moment([2071, 11, 31]).isoWeek(), 53, 'Dec 31 2071 should be iso week 53');
39700 assert.equal(moment([2076, 11, 31]).isoWeek(), 53, 'Dec 31 2076 should be iso week 53');
39701 assert.equal(moment([2082, 11, 31]).isoWeek(), 53, 'Dec 31 2082 should be iso week 53');
39702 assert.equal(moment([2088, 11, 31]).isoWeek(), 53, 'Dec 31 2088 should be iso week 53');
39703 assert.equal(moment([2093, 11, 31]).isoWeek(), 53, 'Dec 31 2093 should be iso week 53');
39704 assert.equal(moment([2099, 11, 31]).isoWeek(), 53, 'Dec 31 2099 should be iso week 53');
39705 assert.equal(moment([2105, 11, 31]).isoWeek(), 53, 'Dec 31 2105 should be iso week 53');
39706 assert.equal(moment([2111, 11, 31]).isoWeek(), 53, 'Dec 31 2111 should be iso week 53');
39707 assert.equal(moment([2116, 11, 31]).isoWeek(), 53, 'Dec 31 2116 should be iso week 53');
39708 assert.equal(moment([2122, 11, 31]).isoWeek(), 53, 'Dec 31 2122 should be iso week 53');
39709 assert.equal(moment([2128, 11, 31]).isoWeek(), 53, 'Dec 31 2128 should be iso week 53');
39710 assert.equal(moment([2133, 11, 31]).isoWeek(), 53, 'Dec 31 2133 should be iso week 53');
39711 assert.equal(moment([2139, 11, 31]).isoWeek(), 53, 'Dec 31 2139 should be iso week 53');
39712 assert.equal(moment([2144, 11, 31]).isoWeek(), 53, 'Dec 31 2144 should be iso week 53');
39713 assert.equal(moment([2150, 11, 31]).isoWeek(), 53, 'Dec 31 2150 should be iso week 53');
39714 assert.equal(moment([2156, 11, 31]).isoWeek(), 53, 'Dec 31 2156 should be iso week 53');
39715 assert.equal(moment([2161, 11, 31]).isoWeek(), 53, 'Dec 31 2161 should be iso week 53');
39716 assert.equal(moment([2167, 11, 31]).isoWeek(), 53, 'Dec 31 2167 should be iso week 53');
39717 assert.equal(moment([2172, 11, 31]).isoWeek(), 53, 'Dec 31 2172 should be iso week 53');
39718 assert.equal(moment([2178, 11, 31]).isoWeek(), 53, 'Dec 31 2178 should be iso week 53');
39719 assert.equal(moment([2184, 11, 31]).isoWeek(), 53, 'Dec 31 2184 should be iso week 53');
39720 assert.equal(moment([2189, 11, 31]).isoWeek(), 53, 'Dec 31 2189 should be iso week 53');
39721 assert.equal(moment([2195, 11, 31]).isoWeek(), 53, 'Dec 31 2195 should be iso week 53');
39722 assert.equal(moment([2201, 11, 31]).isoWeek(), 53, 'Dec 31 2201 should be iso week 53');
39723 assert.equal(moment([2207, 11, 31]).isoWeek(), 53, 'Dec 31 2207 should be iso week 53');
39724 assert.equal(moment([2212, 11, 31]).isoWeek(), 53, 'Dec 31 2212 should be iso week 53');
39725 assert.equal(moment([2218, 11, 31]).isoWeek(), 53, 'Dec 31 2218 should be iso week 53');
39726 assert.equal(moment([2224, 11, 31]).isoWeek(), 53, 'Dec 31 2224 should be iso week 53');
39727 assert.equal(moment([2229, 11, 31]).isoWeek(), 53, 'Dec 31 2229 should be iso week 53');
39728 assert.equal(moment([2235, 11, 31]).isoWeek(), 53, 'Dec 31 2235 should be iso week 53');
39729 assert.equal(moment([2240, 11, 31]).isoWeek(), 53, 'Dec 31 2240 should be iso week 53');
39730 assert.equal(moment([2246, 11, 31]).isoWeek(), 53, 'Dec 31 2246 should be iso week 53');
39731 assert.equal(moment([2252, 11, 31]).isoWeek(), 53, 'Dec 31 2252 should be iso week 53');
39732 assert.equal(moment([2257, 11, 31]).isoWeek(), 53, 'Dec 31 2257 should be iso week 53');
39733 assert.equal(moment([2263, 11, 31]).isoWeek(), 53, 'Dec 31 2263 should be iso week 53');
39734 assert.equal(moment([2268, 11, 31]).isoWeek(), 53, 'Dec 31 2268 should be iso week 53');
39735 assert.equal(moment([2274, 11, 31]).isoWeek(), 53, 'Dec 31 2274 should be iso week 53');
39736 assert.equal(moment([2280, 11, 31]).isoWeek(), 53, 'Dec 31 2280 should be iso week 53');
39737 assert.equal(moment([2285, 11, 31]).isoWeek(), 53, 'Dec 31 2285 should be iso week 53');
39738 assert.equal(moment([2291, 11, 31]).isoWeek(), 53, 'Dec 31 2291 should be iso week 53');
39739 assert.equal(moment([2296, 11, 31]).isoWeek(), 53, 'Dec 31 2296 should be iso week 53');
39740 assert.equal(moment([2303, 11, 31]).isoWeek(), 53, 'Dec 31 2303 should be iso week 53');
39741 assert.equal(moment([2308, 11, 31]).isoWeek(), 53, 'Dec 31 2308 should be iso week 53');
39742 assert.equal(moment([2314, 11, 31]).isoWeek(), 53, 'Dec 31 2314 should be iso week 53');
39743 assert.equal(moment([2320, 11, 31]).isoWeek(), 53, 'Dec 31 2320 should be iso week 53');
39744 assert.equal(moment([2325, 11, 31]).isoWeek(), 53, 'Dec 31 2325 should be iso week 53');
39745 assert.equal(moment([2331, 11, 31]).isoWeek(), 53, 'Dec 31 2331 should be iso week 53');
39746 assert.equal(moment([2336, 11, 31]).isoWeek(), 53, 'Dec 31 2336 should be iso week 53');
39747 assert.equal(moment([2342, 11, 31]).isoWeek(), 53, 'Dec 31 2342 should be iso week 53');
39748 assert.equal(moment([2348, 11, 31]).isoWeek(), 53, 'Dec 31 2348 should be iso week 53');
39749 assert.equal(moment([2353, 11, 31]).isoWeek(), 53, 'Dec 31 2353 should be iso week 53');
39750 assert.equal(moment([2359, 11, 31]).isoWeek(), 53, 'Dec 31 2359 should be iso week 53');
39751 assert.equal(moment([2364, 11, 31]).isoWeek(), 53, 'Dec 31 2364 should be iso week 53');
39752 assert.equal(moment([2370, 11, 31]).isoWeek(), 53, 'Dec 31 2370 should be iso week 53');
39753 assert.equal(moment([2376, 11, 31]).isoWeek(), 53, 'Dec 31 2376 should be iso week 53');
39754 assert.equal(moment([2381, 11, 31]).isoWeek(), 53, 'Dec 31 2381 should be iso week 53');
39755 assert.equal(moment([2387, 11, 31]).isoWeek(), 53, 'Dec 31 2387 should be iso week 53');
39756 assert.equal(moment([2392, 11, 31]).isoWeek(), 53, 'Dec 31 2392 should be iso week 53');
39757 assert.equal(moment([2398, 11, 31]).isoWeek(), 53, 'Dec 31 2398 should be iso week 53');
39758 });
39759
39760 test('count years with iso week 53', function (assert) {
39761 // Based on http://en.wikipedia.org/wiki/ISO_week_date (as seen on 2014-01-06)
39762 // stating that there are 71 years in a 400-year cycle that have 53 weeks;
39763 // in this case reflecting the 2000 based cycle
39764 var count = 0, i;
39765 for (i = 0; i < 400; i++) {
39766 count += (moment([2000 + i, 11, 31]).isoWeek() === 53) ? 1 : 0;
39767 }
39768 assert.equal(count, 71, 'Should have 71 years in 400-year cycle with iso week 53');
39769 });
39770
39771 }));
39772
39773 (function (global, factory) {
39774 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
39775 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
39776 factory(global.moment)
39777 }(this, function (moment) { 'use strict';
39778
39779 /*global QUnit:false*/
39780
39781 var test = QUnit.test;
39782
39783 function module (name, lifecycle) {
39784 QUnit.module(name, {
39785 setup : function () {
39786 moment.locale('en');
39787 moment.createFromInputFallback = function () {
39788 throw new Error('input not handled by moment');
39789 };
39790 if (lifecycle && lifecycle.setup) {
39791 lifecycle.setup();
39792 }
39793 },
39794 teardown : function () {
39795 if (lifecycle && lifecycle.teardown) {
39796 lifecycle.teardown();
39797 }
39798 }
39799 });
39800 }
39801
39802 function localeModule (name, lifecycle) {
39803 QUnit.module('locale:' + name, {
39804 setup : function () {
39805 moment.locale(name);
39806 moment.createFromInputFallback = function () {
39807 throw new Error('input not handled by moment');
39808 };
39809 if (lifecycle && lifecycle.setup) {
39810 lifecycle.setup();
39811 }
39812 },
39813 teardown : function () {
39814 moment.locale('en');
39815 if (lifecycle && lifecycle.teardown) {
39816 lifecycle.teardown();
39817 }
39818 }
39819 });
39820 }
39821
39822 module('weeks in year');
39823
39824 test('isoWeeksInYear', function (assert) {
39825 assert.equal(moment([2004]).isoWeeksInYear(), 53, '2004 has 53 iso weeks');
39826 assert.equal(moment([2005]).isoWeeksInYear(), 52, '2005 has 53 iso weeks');
39827 assert.equal(moment([2006]).isoWeeksInYear(), 52, '2006 has 53 iso weeks');
39828 assert.equal(moment([2007]).isoWeeksInYear(), 52, '2007 has 52 iso weeks');
39829 assert.equal(moment([2008]).isoWeeksInYear(), 52, '2008 has 53 iso weeks');
39830 assert.equal(moment([2009]).isoWeeksInYear(), 53, '2009 has 53 iso weeks');
39831 assert.equal(moment([2010]).isoWeeksInYear(), 52, '2010 has 52 iso weeks');
39832 assert.equal(moment([2011]).isoWeeksInYear(), 52, '2011 has 52 iso weeks');
39833 assert.equal(moment([2012]).isoWeeksInYear(), 52, '2012 has 52 iso weeks');
39834 assert.equal(moment([2013]).isoWeeksInYear(), 52, '2013 has 52 iso weeks');
39835 assert.equal(moment([2014]).isoWeeksInYear(), 52, '2014 has 52 iso weeks');
39836 assert.equal(moment([2015]).isoWeeksInYear(), 53, '2015 has 53 iso weeks');
39837 });
39838
39839 test('weeksInYear doy/dow = 1/4', function (assert) {
39840 moment.locale('1/4', {week: {dow: 1, doy: 4}});
39841
39842 assert.equal(moment([2004]).weeksInYear(), 53, '2004 has 53 weeks');
39843 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');
39844 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');
39845 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
39846 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
39847 assert.equal(moment([2009]).weeksInYear(), 53, '2009 has 53 weeks');
39848 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');
39849 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');
39850 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');
39851 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
39852 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
39853 assert.equal(moment([2015]).weeksInYear(), 53, '2015 has 53 weeks');
39854 });
39855
39856 test('weeksInYear doy/dow = 6/12', function (assert) {
39857 moment.locale('6/12', {week: {dow: 6, doy: 12}});
39858
39859 assert.equal(moment([2004]).weeksInYear(), 53, '2004 has 53 weeks');
39860 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');
39861 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');
39862 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
39863 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
39864 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');
39865 assert.equal(moment([2010]).weeksInYear(), 53, '2010 has 52 weeks');
39866 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');
39867 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');
39868 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
39869 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
39870 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');
39871 });
39872
39873 test('weeksInYear doy/dow = 1/7', function (assert) {
39874 moment.locale('1/7', {week: {dow: 1, doy: 7}});
39875
39876 assert.equal(moment([2004]).weeksInYear(), 52, '2004 has 53 weeks');
39877 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');
39878 assert.equal(moment([2006]).weeksInYear(), 53, '2006 has 53 weeks');
39879 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
39880 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
39881 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');
39882 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');
39883 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');
39884 assert.equal(moment([2012]).weeksInYear(), 53, '2012 has 52 weeks');
39885 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
39886 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
39887 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');
39888 });
39889
39890 test('weeksInYear doy/dow = 0/6', function (assert) {
39891 moment.locale('0/6', {week: {dow: 0, doy: 6}});
39892
39893 assert.equal(moment([2004]).weeksInYear(), 52, '2004 has 53 weeks');
39894 assert.equal(moment([2005]).weeksInYear(), 53, '2005 has 53 weeks');
39895 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');
39896 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
39897 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
39898 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');
39899 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');
39900 assert.equal(moment([2011]).weeksInYear(), 53, '2011 has 52 weeks');
39901 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');
39902 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
39903 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
39904 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');
39905 });
39906
39907 }));
39908
39909 (function (global, factory) {
39910 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
39911 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
39912 factory(global.moment)
39913 }(this, function (moment) { 'use strict';
39914
39915 /*global QUnit:false*/
39916
39917 var test = QUnit.test;
39918
39919 function module (name, lifecycle) {
39920 QUnit.module(name, {
39921 setup : function () {
39922 moment.locale('en');
39923 moment.createFromInputFallback = function () {
39924 throw new Error('input not handled by moment');
39925 };
39926 if (lifecycle && lifecycle.setup) {
39927 lifecycle.setup();
39928 }
39929 },
39930 teardown : function () {
39931 if (lifecycle && lifecycle.teardown) {
39932 lifecycle.teardown();
39933 }
39934 }
39935 });
39936 }
39937
39938 function localeModule (name, lifecycle) {
39939 QUnit.module('locale:' + name, {
39940 setup : function () {
39941 moment.locale(name);
39942 moment.createFromInputFallback = function () {
39943 throw new Error('input not handled by moment');
39944 };
39945 if (lifecycle && lifecycle.setup) {
39946 lifecycle.setup();
39947 }
39948 },
39949 teardown : function () {
39950 moment.locale('en');
39951 if (lifecycle && lifecycle.teardown) {
39952 lifecycle.teardown();
39953 }
39954 }
39955 });
39956 }
39957
39958 module('zone switching');
39959
39960 test('local to utc, keepLocalTime = true', function (assert) {
39961 var m = moment(),
39962 fmt = 'YYYY-DD-MM HH:mm:ss';
39963 assert.equal(m.clone().utc(true).format(fmt), m.format(fmt), 'local to utc failed to keep local time');
39964 });
39965
39966 test('local to utc, keepLocalTime = false', function (assert) {
39967 var m = moment();
39968 assert.equal(m.clone().utc().valueOf(), m.valueOf(), 'local to utc failed to keep utc time (implicit)');
39969 assert.equal(m.clone().utc(false).valueOf(), m.valueOf(), 'local to utc failed to keep utc time (explicit)');
39970 });
39971
39972 test('local to zone, keepLocalTime = true', function (assert) {
39973 var m = moment(),
39974 fmt = 'YYYY-DD-MM HH:mm:ss',
39975 z;
39976
39977 // Apparently there is -12:00 and +14:00
39978 // http://en.wikipedia.org/wiki/UTC+14:00
39979 // http://en.wikipedia.org/wiki/UTC-12:00
39980 for (z = -12; z <= 14; ++z) {
39981 assert.equal(m.clone().zone(z * 60, true).format(fmt), m.format(fmt),
39982 'local to zone(' + z + ':00) failed to keep local time');
39983 }
39984 });
39985
39986 test('local to zone, keepLocalTime = false', function (assert) {
39987 var m = moment(),
39988 z;
39989
39990 // Apparently there is -12:00 and +14:00
39991 // http://en.wikipedia.org/wiki/UTC+14:00
39992 // http://en.wikipedia.org/wiki/UTC-12:00
39993 for (z = -12; z <= 14; ++z) {
39994 assert.equal(m.clone().zone(z * 60).valueOf(), m.valueOf(),
39995 'local to zone(' + z + ':00) failed to keep utc time (implicit)');
39996 assert.equal(m.clone().zone(z * 60, false).valueOf(), m.valueOf(),
39997 'local to zone(' + z + ':00) failed to keep utc time (explicit)');
39998 }
39999 });
40000
40001 test('utc to local, keepLocalTime = true', function (assert) {
40002 var um = moment.utc(),
40003 fmt = 'YYYY-DD-MM HH:mm:ss';
40004
40005 assert.equal(um.clone().local(true).format(fmt), um.format(fmt), 'utc to local failed to keep local time');
40006 });
40007
40008 test('utc to local, keepLocalTime = false', function (assert) {
40009 var um = moment.utc();
40010 assert.equal(um.clone().local().valueOf(), um.valueOf(), 'utc to local failed to keep utc time (implicit)');
40011 assert.equal(um.clone().local(false).valueOf(), um.valueOf(), 'utc to local failed to keep utc time (explicit)');
40012 });
40013
40014 test('zone to local, keepLocalTime = true', function (assert) {
40015 var m = moment(),
40016 fmt = 'YYYY-DD-MM HH:mm:ss',
40017 z;
40018
40019 // Apparently there is -12:00 and +14:00
40020 // http://en.wikipedia.org/wiki/UTC+14:00
40021 // http://en.wikipedia.org/wiki/UTC-12:00
40022 for (z = -12; z <= 14; ++z) {
40023 m.zone(z * 60);
40024
40025 assert.equal(m.clone().local(true).format(fmt), m.format(fmt),
40026 'zone(' + z + ':00) to local failed to keep local time');
40027 }
40028 });
40029
40030 test('zone to local, keepLocalTime = false', function (assert) {
40031 var m = moment(),
40032 z;
40033
40034 // Apparently there is -12:00 and +14:00
40035 // http://en.wikipedia.org/wiki/UTC+14:00
40036 // http://en.wikipedia.org/wiki/UTC-12:00
40037 for (z = -12; z <= 14; ++z) {
40038 m.zone(z * 60);
40039
40040 assert.equal(m.clone().local(false).valueOf(), m.valueOf(),
40041 'zone(' + z + ':00) to local failed to keep utc time (explicit)');
40042 assert.equal(m.clone().local().valueOf(), m.valueOf(),
40043 'zone(' + z + ':00) to local failed to keep utc time (implicit)');
40044 }
40045 });
40046
40047 }));
40048
40049 (function (global, factory) {
40050 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
40051 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
40052 factory(global.moment)
40053 }(this, function (moment) { 'use strict';
40054
40055 /*global QUnit:false*/
40056
40057 var test = QUnit.test;
40058
40059 function module (name, lifecycle) {
40060 QUnit.module(name, {
40061 setup : function () {
40062 moment.locale('en');
40063 moment.createFromInputFallback = function () {
40064 throw new Error('input not handled by moment');
40065 };
40066 if (lifecycle && lifecycle.setup) {
40067 lifecycle.setup();
40068 }
40069 },
40070 teardown : function () {
40071 if (lifecycle && lifecycle.teardown) {
40072 lifecycle.teardown();
40073 }
40074 }
40075 });
40076 }
40077
40078 function localeModule (name, lifecycle) {
40079 QUnit.module('locale:' + name, {
40080 setup : function () {
40081 moment.locale(name);
40082 moment.createFromInputFallback = function () {
40083 throw new Error('input not handled by moment');
40084 };
40085 if (lifecycle && lifecycle.setup) {
40086 lifecycle.setup();
40087 }
40088 },
40089 teardown : function () {
40090 moment.locale('en');
40091 if (lifecycle && lifecycle.teardown) {
40092 lifecycle.teardown();
40093 }
40094 }
40095 });
40096 }
40097
40098 module('zones');
40099
40100 test('set zone', function (assert) {
40101 var zone = moment();
40102
40103 zone.zone(0);
40104 assert.equal(zone.zone(), 0, 'should be able to set the zone to 0');
40105
40106 zone.zone(60);
40107 assert.equal(zone.zone(), 60, 'should be able to set the zone to 60');
40108
40109 zone.zone(-60);
40110 assert.equal(zone.zone(), -60, 'should be able to set the zone to -60');
40111 });
40112
40113 test('set zone shorthand', function (assert) {
40114 var zone = moment();
40115
40116 zone.zone(1);
40117 assert.equal(zone.zone(), 60, 'setting the zone to 1 should imply hours and convert to 60');
40118
40119 zone.zone(-1);
40120 assert.equal(zone.zone(), -60, 'setting the zone to -1 should imply hours and convert to -60');
40121
40122 zone.zone(15);
40123 assert.equal(zone.zone(), 900, 'setting the zone to 15 should imply hours and convert to 900');
40124
40125 zone.zone(-15);
40126 assert.equal(zone.zone(), -900, 'setting the zone to -15 should imply hours and convert to -900');
40127
40128 zone.zone(16);
40129 assert.equal(zone.zone(), 16, 'setting the zone to 16 should imply minutes');
40130
40131 zone.zone(-16);
40132 assert.equal(zone.zone(), -16, 'setting the zone to -16 should imply minutes');
40133 });
40134
40135 test('set zone with string', function (assert) {
40136 var zone = moment();
40137
40138 zone.zone('+00:00');
40139 assert.equal(zone.zone(), 0, 'set the zone with a timezone string');
40140
40141 zone.zone('2013-03-07T07:00:00-08:00');
40142 assert.equal(zone.zone(), 480, 'set the zone with a string that does not begin with the timezone');
40143
40144 zone.zone('2013-03-07T07:00:00+0100');
40145 assert.equal(zone.zone(), -60, 'set the zone with a string that uses the +0000 syntax');
40146
40147 zone.zone('03-07-2013T07:00:00-08:00');
40148 assert.equal(zone.zone(), 480, 'set the zone with a string with a non-ISO 8601 date');
40149 });
40150
40151 test('change hours when changing the zone', function (assert) {
40152 var zone = moment.utc([2000, 0, 1, 6]);
40153
40154 zone.zone(0);
40155 assert.equal(zone.hour(), 6, 'UTC 6AM should be 6AM at +0000');
40156
40157 zone.zone(60);
40158 assert.equal(zone.hour(), 5, 'UTC 6AM should be 5AM at -0100');
40159
40160 zone.zone(-60);
40161 assert.equal(zone.hour(), 7, 'UTC 6AM should be 7AM at +0100');
40162 });
40163
40164 test('change minutes when changing the zone', function (assert) {
40165 var zone = moment.utc([2000, 0, 1, 6, 31]);
40166
40167 zone.zone(0);
40168 assert.equal(zone.format('HH:mm'), '06:31', 'UTC 6:31AM should be 6:31AM at +0000');
40169
40170 zone.zone(30);
40171 assert.equal(zone.format('HH:mm'), '06:01', 'UTC 6:31AM should be 6:01AM at -0030');
40172
40173 zone.zone(-30);
40174 assert.equal(zone.format('HH:mm'), '07:01', 'UTC 6:31AM should be 7:01AM at +0030');
40175
40176 zone.zone(1380);
40177 assert.equal(zone.format('HH:mm'), '07:31', 'UTC 6:31AM should be 7:31AM at +1380');
40178 });
40179
40180 test('distance from the unix epoch', function (assert) {
40181 var zoneA = moment(),
40182 zoneB = moment(zoneA),
40183 zoneC = moment(zoneA),
40184 zoneD = moment(zoneA),
40185 zoneE = moment(zoneA);
40186
40187 zoneB.utc();
40188 assert.equal(+zoneA, +zoneB, 'moment should equal moment.utc');
40189
40190 zoneC.zone(-60);
40191 assert.equal(+zoneA, +zoneC, 'moment should equal moment.zone(-60)');
40192
40193 zoneD.zone(480);
40194 assert.equal(+zoneA, +zoneD, 'moment should equal moment.zone(480)');
40195
40196 zoneE.zone(1000);
40197 assert.equal(+zoneA, +zoneE, 'moment should equal moment.zone(1000)');
40198 });
40199
40200 test('update offset after changing any values', function (assert) {
40201 var oldOffset = moment.updateOffset,
40202 m = moment.utc([2000, 6, 1]);
40203
40204 moment.updateOffset = function (mom, keepTime) {
40205 if (mom.__doChange) {
40206 if (+mom > 962409600000) {
40207 mom.zone(120, keepTime);
40208 } else {
40209 mom.zone(60, keepTime);
40210 }
40211 }
40212 };
40213
40214 assert.equal(m.format('ZZ'), '+0000', 'should be at +0000');
40215 assert.equal(m.format('HH:mm'), '00:00', 'should start 12AM at +0000 timezone');
40216
40217 m.__doChange = true;
40218 m.add(1, 'h');
40219
40220 assert.equal(m.format('ZZ'), '-0200', 'should be at -0200');
40221 assert.equal(m.format('HH:mm'), '23:00', '1AM at +0000 should be 11PM at -0200 timezone');
40222
40223 m.subtract(1, 'h');
40224
40225 assert.equal(m.format('ZZ'), '-0100', 'should be at -0100');
40226 assert.equal(m.format('HH:mm'), '23:00', '12AM at +0000 should be 11PM at -0100 timezone');
40227
40228 moment.updateOffset = oldOffset;
40229 });
40230
40231 test('getters and setters', function (assert) {
40232 var a = moment([2011, 5, 20]);
40233
40234 assert.equal(a.clone().zone(120).year(2012).year(), 2012, 'should get and set year correctly');
40235 assert.equal(a.clone().zone(120).month(1).month(), 1, 'should get and set month correctly');
40236 assert.equal(a.clone().zone(120).date(2).date(), 2, 'should get and set date correctly');
40237 assert.equal(a.clone().zone(120).day(1).day(), 1, 'should get and set day correctly');
40238 assert.equal(a.clone().zone(120).hour(1).hour(), 1, 'should get and set hour correctly');
40239 assert.equal(a.clone().zone(120).minute(1).minute(), 1, 'should get and set minute correctly');
40240 });
40241
40242 test('getters', function (assert) {
40243 var a = moment.utc([2012, 0, 1, 0, 0, 0]);
40244
40245 assert.equal(a.clone().zone(120).year(), 2011, 'should get year correctly');
40246 assert.equal(a.clone().zone(120).month(), 11, 'should get month correctly');
40247 assert.equal(a.clone().zone(120).date(), 31, 'should get date correctly');
40248 assert.equal(a.clone().zone(120).hour(), 22, 'should get hour correctly');
40249 assert.equal(a.clone().zone(120).minute(), 0, 'should get minute correctly');
40250
40251 assert.equal(a.clone().zone(-120).year(), 2012, 'should get year correctly');
40252 assert.equal(a.clone().zone(-120).month(), 0, 'should get month correctly');
40253 assert.equal(a.clone().zone(-120).date(), 1, 'should get date correctly');
40254 assert.equal(a.clone().zone(-120).hour(), 2, 'should get hour correctly');
40255 assert.equal(a.clone().zone(-120).minute(), 0, 'should get minute correctly');
40256
40257 assert.equal(a.clone().zone(-90).year(), 2012, 'should get year correctly');
40258 assert.equal(a.clone().zone(-90).month(), 0, 'should get month correctly');
40259 assert.equal(a.clone().zone(-90).date(), 1, 'should get date correctly');
40260 assert.equal(a.clone().zone(-90).hour(), 1, 'should get hour correctly');
40261 assert.equal(a.clone().zone(-90).minute(), 30, 'should get minute correctly');
40262 });
40263
40264 test('from', function (assert) {
40265 var zoneA = moment(),
40266 zoneB = moment(zoneA).zone(720),
40267 zoneC = moment(zoneA).zone(360),
40268 zoneD = moment(zoneA).zone(-690),
40269 other = moment(zoneA).add(35, 'm');
40270
40271 assert.equal(zoneA.from(other), zoneB.from(other), 'moment#from should be the same in all zones');
40272 assert.equal(zoneA.from(other), zoneC.from(other), 'moment#from should be the same in all zones');
40273 assert.equal(zoneA.from(other), zoneD.from(other), 'moment#from should be the same in all zones');
40274 });
40275
40276 test('diff', function (assert) {
40277 var zoneA = moment(),
40278 zoneB = moment(zoneA).zone(720),
40279 zoneC = moment(zoneA).zone(360),
40280 zoneD = moment(zoneA).zone(-690),
40281 other = moment(zoneA).add(35, 'm');
40282
40283 assert.equal(zoneA.diff(other), zoneB.diff(other), 'moment#diff should be the same in all zones');
40284 assert.equal(zoneA.diff(other), zoneC.diff(other), 'moment#diff should be the same in all zones');
40285 assert.equal(zoneA.diff(other), zoneD.diff(other), 'moment#diff should be the same in all zones');
40286
40287 assert.equal(zoneA.diff(other, 'minute', true), zoneB.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
40288 assert.equal(zoneA.diff(other, 'minute', true), zoneC.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
40289 assert.equal(zoneA.diff(other, 'minute', true), zoneD.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
40290
40291 assert.equal(zoneA.diff(other, 'hour', true), zoneB.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
40292 assert.equal(zoneA.diff(other, 'hour', true), zoneC.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
40293 assert.equal(zoneA.diff(other, 'hour', true), zoneD.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
40294 });
40295
40296 test('unix offset and timestamp', function (assert) {
40297 var zoneA = moment(),
40298 zoneB = moment(zoneA).zone(720),
40299 zoneC = moment(zoneA).zone(360),
40300 zoneD = moment(zoneA).zone(-690);
40301
40302 assert.equal(zoneA.unix(), zoneB.unix(), 'moment#unix should be the same in all zones');
40303 assert.equal(zoneA.unix(), zoneC.unix(), 'moment#unix should be the same in all zones');
40304 assert.equal(zoneA.unix(), zoneD.unix(), 'moment#unix should be the same in all zones');
40305
40306 assert.equal(+zoneA, +zoneB, 'moment#valueOf should be the same in all zones');
40307 assert.equal(+zoneA, +zoneC, 'moment#valueOf should be the same in all zones');
40308 assert.equal(+zoneA, +zoneD, 'moment#valueOf should be the same in all zones');
40309 });
40310
40311 test('cloning', function (assert) {
40312 assert.equal(moment().zone(120).clone().zone(), 120, 'explicit cloning should retain the zone');
40313 assert.equal(moment().zone(-120).clone().zone(), -120, 'explicit cloning should retain the zone');
40314 assert.equal(moment(moment().zone(120)).zone(), 120, 'implicit cloning should retain the zone');
40315 assert.equal(moment(moment().zone(-120)).zone(), -120, 'implicit cloning should retain the zone');
40316 });
40317
40318 test('start of / end of', function (assert) {
40319 var a = moment.utc([2010, 1, 2, 0, 0, 0]).zone(450);
40320
40321 assert.equal(a.clone().startOf('day').hour(), 0, 'start of day should work on moments with a zone');
40322 assert.equal(a.clone().startOf('day').minute(), 0, 'start of day should work on moments with a zone');
40323 assert.equal(a.clone().startOf('hour').minute(), 0, 'start of hour should work on moments with a zone');
40324
40325 assert.equal(a.clone().endOf('day').hour(), 23, 'end of day should work on moments with a zone');
40326 assert.equal(a.clone().endOf('day').minute(), 59, 'end of day should work on moments with a zone');
40327 assert.equal(a.clone().endOf('hour').minute(), 59, 'end of hour should work on moments with a zone');
40328 });
40329
40330 test('reset zone with moment#utc', function (assert) {
40331 var a = moment.utc([2012]).zone(480);
40332
40333 assert.equal(a.clone().hour(), 16, 'different zone should have different hour');
40334 assert.equal(a.clone().utc().hour(), 0, 'calling moment#utc should reset the offset');
40335 });
40336
40337 test('reset zone with moment#local', function (assert) {
40338 var a = moment([2012]).zone(480);
40339
40340 assert.equal(a.clone().local().hour(), 0, 'calling moment#local should reset the offset');
40341 });
40342
40343 test('toDate', function (assert) {
40344 var zoneA = new Date(),
40345 zoneB = moment(zoneA).zone(720).toDate(),
40346 zoneC = moment(zoneA).zone(360).toDate(),
40347 zoneD = moment(zoneA).zone(-690).toDate();
40348
40349 assert.equal(+zoneA, +zoneB, 'moment#toDate should output a date with the right unix timestamp');
40350 assert.equal(+zoneA, +zoneC, 'moment#toDate should output a date with the right unix timestamp');
40351 assert.equal(+zoneA, +zoneD, 'moment#toDate should output a date with the right unix timestamp');
40352 });
40353
40354 test('same / before / after', function (assert) {
40355 var zoneA = moment().utc(),
40356 zoneB = moment(zoneA).zone(120),
40357 zoneC = moment(zoneA).zone(-120);
40358
40359 assert.ok(zoneA.isSame(zoneB), 'two moments with different offsets should be the same');
40360 assert.ok(zoneA.isSame(zoneC), 'two moments with different offsets should be the same');
40361
40362 assert.ok(zoneA.isSame(zoneB, 'hour'), 'two moments with different offsets should be the same hour');
40363 assert.ok(zoneA.isSame(zoneC, 'hour'), 'two moments with different offsets should be the same hour');
40364
40365 zoneA.add(1, 'hour');
40366
40367 assert.ok(zoneA.isAfter(zoneB), 'isAfter should work with two moments with different offsets');
40368 assert.ok(zoneA.isAfter(zoneC), 'isAfter should work with two moments with different offsets');
40369
40370 assert.ok(zoneA.isAfter(zoneB, 'hour'), 'isAfter:hour should work with two moments with different offsets');
40371 assert.ok(zoneA.isAfter(zoneC, 'hour'), 'isAfter:hour should work with two moments with different offsets');
40372
40373 zoneA.subtract(2, 'hour');
40374
40375 assert.ok(zoneA.isBefore(zoneB), 'isBefore should work with two moments with different offsets');
40376 assert.ok(zoneA.isBefore(zoneC), 'isBefore should work with two moments with different offsets');
40377
40378 assert.ok(zoneA.isBefore(zoneB, 'hour'), 'isBefore:hour should work with two moments with different offsets');
40379 assert.ok(zoneA.isBefore(zoneC, 'hour'), 'isBefore:hour should work with two moments with different offsets');
40380 });
40381
40382 test('add / subtract over dst', function (assert) {
40383 var oldOffset = moment.updateOffset,
40384 m = moment.utc([2000, 2, 31, 3]);
40385
40386 moment.updateOffset = function (mom, keepTime) {
40387 if (mom.clone().utc().month() > 2) {
40388 mom.zone(-60, keepTime);
40389 } else {
40390 mom.zone(0, keepTime);
40391 }
40392 };
40393
40394 assert.equal(m.hour(), 3, 'should start at 00:00');
40395
40396 m.add(24, 'hour');
40397
40398 assert.equal(m.hour(), 4, 'adding 24 hours should disregard dst');
40399
40400 m.subtract(24, 'hour');
40401
40402 assert.equal(m.hour(), 3, 'subtracting 24 hours should disregard dst');
40403
40404 m.add(1, 'day');
40405
40406 assert.equal(m.hour(), 3, 'adding 1 day should have the same hour');
40407
40408 m.subtract(1, 'day');
40409
40410 assert.equal(m.hour(), 3, 'subtracting 1 day should have the same hour');
40411
40412 m.add(1, 'month');
40413
40414 assert.equal(m.hour(), 3, 'adding 1 month should have the same hour');
40415
40416 m.subtract(1, 'month');
40417
40418 assert.equal(m.hour(), 3, 'subtracting 1 month should have the same hour');
40419
40420 moment.updateOffset = oldOffset;
40421 });
40422
40423 test('isDST', function (assert) {
40424 var oldOffset = moment.updateOffset;
40425
40426 moment.updateOffset = function (mom, keepTime) {
40427 if (mom.month() > 2 && mom.month() < 9) {
40428 mom.zone(-60, keepTime);
40429 } else {
40430 mom.zone(0, keepTime);
40431 }
40432 };
40433
40434 assert.ok(!moment().month(0).isDST(), 'Jan should not be summer dst');
40435 assert.ok(moment().month(6).isDST(), 'Jul should be summer dst');
40436 assert.ok(!moment().month(11).isDST(), 'Dec should not be summer dst');
40437
40438 moment.updateOffset = function (mom) {
40439 if (mom.month() > 2 && mom.month() < 9) {
40440 mom.zone(0);
40441 } else {
40442 mom.zone(-60);
40443 }
40444 };
40445
40446 assert.ok(moment().month(0).isDST(), 'Jan should be winter dst');
40447 assert.ok(!moment().month(6).isDST(), 'Jul should not be winter dst');
40448 assert.ok(moment().month(11).isDST(), 'Dec should be winter dst');
40449
40450 moment.updateOffset = oldOffset;
40451 });
40452
40453 test('zone names', function (assert) {
40454 assert.equal(moment().zoneAbbr(), '', 'Local zone abbr should be empty');
40455 assert.equal(moment().format('z'), '', 'Local zone formatted abbr should be empty');
40456 assert.equal(moment().zoneName(), '', 'Local zone name should be empty');
40457 assert.equal(moment().format('zz'), '', 'Local zone formatted name should be empty');
40458
40459 assert.equal(moment.utc().zoneAbbr(), 'UTC', 'UTC zone abbr should be UTC');
40460 assert.equal(moment.utc().format('z'), 'UTC', 'UTC zone formatted abbr should be UTC');
40461 assert.equal(moment.utc().zoneName(), 'Coordinated Universal Time', 'UTC zone abbr should be Coordinated Universal Time');
40462 assert.equal(moment.utc().format('zz'), 'Coordinated Universal Time', 'UTC zone formatted abbr should be Coordinated Universal Time');
40463 });
40464
40465 test('hours alignment with UTC', function (assert) {
40466 assert.equal(moment().zone(120).hasAlignedHourOffset(), true);
40467 assert.equal(moment().zone(-180).hasAlignedHourOffset(), true);
40468 assert.equal(moment().zone(90).hasAlignedHourOffset(), false);
40469 assert.equal(moment().zone(-90).hasAlignedHourOffset(), false);
40470 });
40471
40472 test('hours alignment with other zone', function (assert) {
40473 var m = moment().zone(120);
40474
40475 assert.equal(m.hasAlignedHourOffset(moment().zone(180)), true);
40476 assert.equal(m.hasAlignedHourOffset(moment().zone(-180)), true);
40477 assert.equal(m.hasAlignedHourOffset(moment().zone(90)), false);
40478 assert.equal(m.hasAlignedHourOffset(moment().zone(-90)), false);
40479
40480 m = moment().zone(90);
40481
40482 assert.equal(m.hasAlignedHourOffset(moment().zone(180)), false);
40483 assert.equal(m.hasAlignedHourOffset(moment().zone(-180)), false);
40484 assert.equal(m.hasAlignedHourOffset(moment().zone(30)), true);
40485 assert.equal(m.hasAlignedHourOffset(moment().zone(-30)), true);
40486
40487 m = moment().zone(-60);
40488
40489 assert.equal(m.hasAlignedHourOffset(moment().zone(180)), true);
40490 assert.equal(m.hasAlignedHourOffset(moment().zone(-180)), true);
40491 assert.equal(m.hasAlignedHourOffset(moment().zone(90)), false);
40492 assert.equal(m.hasAlignedHourOffset(moment().zone(-90)), false);
40493
40494 m = moment().zone(25);
40495
40496 assert.equal(m.hasAlignedHourOffset(moment().zone(-35)), true);
40497 assert.equal(m.hasAlignedHourOffset(moment().zone(85)), true);
40498
40499 assert.equal(m.hasAlignedHourOffset(moment().zone(35)), false);
40500 assert.equal(m.hasAlignedHourOffset(moment().zone(-85)), false);
40501 });
40502
40503 test('parse zone', function (assert) {
40504 var m = moment('2013-01-01T00:00:00-13:00').parseZone();
40505 assert.equal(m.zone(), 13 * 60);
40506 assert.equal(m.hours(), 0);
40507 });
40508
40509 test('parse zone static', function (assert) {
40510 var m = moment.parseZone('2013-01-01T00:00:00-13:00');
40511 assert.equal(m.zone(), 13 * 60);
40512 assert.equal(m.hours(), 0);
40513 });
40514
40515 test('parse zone with more arguments', function (assert) {
40516 var m;
40517 m = moment.parseZone('2013 01 01 05 -13:00', 'YYYY MM DD HH ZZ');
40518 assert.equal(m.format(), '2013-01-01T05:00:00-13:00', 'accept input and format');
40519 m = moment.parseZone('2013-01-01-13:00', 'YYYY MM DD ZZ', true);
40520 assert.equal(m.isValid(), false, 'accept input, format and strict flag');
40521 m = moment.parseZone('2013-01-01-13:00', ['DD MM YYYY ZZ', 'YYYY MM DD ZZ']);
40522 assert.equal(m.format(), '2013-01-01T00:00:00-13:00', 'accept input and array of formats');
40523 });
40524
40525 test('parse zone with a timezone from the format string', function (assert) {
40526 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY ZZ #####').parseZone();
40527
40528 assert.equal(m.zone(), 4 * 60);
40529 });
40530
40531 test('parse zone without a timezone included in the format string', function (assert) {
40532 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY').parseZone();
40533
40534 assert.equal(m.zone(), -11 * 60);
40535 });
40536
40537 test('timezone format', function (assert) {
40538 assert.equal(moment().zone(-60).format('ZZ'), '+0100', '-60 -> +0100');
40539 assert.equal(moment().zone(-90).format('ZZ'), '+0130', '-90 -> +0130');
40540 assert.equal(moment().zone(-120).format('ZZ'), '+0200', '-120 -> +0200');
40541
40542 assert.equal(moment().zone(+60).format('ZZ'), '-0100', '+60 -> -0100');
40543 assert.equal(moment().zone(+90).format('ZZ'), '-0130', '+90 -> -0130');
40544 assert.equal(moment().zone(+120).format('ZZ'), '-0200', '+120 -> -0200');
40545 });
40546
40547 }));
0 //! moment.js
1 //! version : 2.10.6
2 //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
3 //! license : MIT
4 //! momentjs.com
5
6 (function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
8 typeof define === 'function' && define.amd ? define(factory) :
9 global.moment = factory()
10 }(this, function () { 'use strict';
11
12 var hookCallback;
13
14 function utils_hooks__hooks () {
15 return hookCallback.apply(null, arguments);
16 }
17
18 // This is done to register the method called with moment()
19 // without creating circular dependencies.
20 function setHookCallback (callback) {
21 hookCallback = callback;
22 }
23
24 function isArray(input) {
25 return Object.prototype.toString.call(input) === '[object Array]';
26 }
27
28 function isDate(input) {
29 return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
30 }
31
32 function map(arr, fn) {
33 var res = [], i;
34 for (i = 0; i < arr.length; ++i) {
35 res.push(fn(arr[i], i));
36 }
37 return res;
38 }
39
40 function hasOwnProp(a, b) {
41 return Object.prototype.hasOwnProperty.call(a, b);
42 }
43
44 function extend(a, b) {
45 for (var i in b) {
46 if (hasOwnProp(b, i)) {
47 a[i] = b[i];
48 }
49 }
50
51 if (hasOwnProp(b, 'toString')) {
52 a.toString = b.toString;
53 }
54
55 if (hasOwnProp(b, 'valueOf')) {
56 a.valueOf = b.valueOf;
57 }
58
59 return a;
60 }
61
62 function create_utc__createUTC (input, format, locale, strict) {
63 return createLocalOrUTC(input, format, locale, strict, true).utc();
64 }
65
66 function defaultParsingFlags() {
67 // We need to deep clone this object.
68 return {
69 empty : false,
70 unusedTokens : [],
71 unusedInput : [],
72 overflow : -2,
73 charsLeftOver : 0,
74 nullInput : false,
75 invalidMonth : null,
76 invalidFormat : false,
77 userInvalidated : false,
78 iso : false
79 };
80 }
81
82 function getParsingFlags(m) {
83 if (m._pf == null) {
84 m._pf = defaultParsingFlags();
85 }
86 return m._pf;
87 }
88
89 function valid__isValid(m) {
90 if (m._isValid == null) {
91 var flags = getParsingFlags(m);
92 m._isValid = !isNaN(m._d.getTime()) &&
93 flags.overflow < 0 &&
94 !flags.empty &&
95 !flags.invalidMonth &&
96 !flags.invalidWeekday &&
97 !flags.nullInput &&
98 !flags.invalidFormat &&
99 !flags.userInvalidated;
100
101 if (m._strict) {
102 m._isValid = m._isValid &&
103 flags.charsLeftOver === 0 &&
104 flags.unusedTokens.length === 0 &&
105 flags.bigHour === undefined;
106 }
107 }
108 return m._isValid;
109 }
110
111 function valid__createInvalid (flags) {
112 var m = create_utc__createUTC(NaN);
113 if (flags != null) {
114 extend(getParsingFlags(m), flags);
115 }
116 else {
117 getParsingFlags(m).userInvalidated = true;
118 }
119
120 return m;
121 }
122
123 var momentProperties = utils_hooks__hooks.momentProperties = [];
124
125 function copyConfig(to, from) {
126 var i, prop, val;
127
128 if (typeof from._isAMomentObject !== 'undefined') {
129 to._isAMomentObject = from._isAMomentObject;
130 }
131 if (typeof from._i !== 'undefined') {
132 to._i = from._i;
133 }
134 if (typeof from._f !== 'undefined') {
135 to._f = from._f;
136 }
137 if (typeof from._l !== 'undefined') {
138 to._l = from._l;
139 }
140 if (typeof from._strict !== 'undefined') {
141 to._strict = from._strict;
142 }
143 if (typeof from._tzm !== 'undefined') {
144 to._tzm = from._tzm;
145 }
146 if (typeof from._isUTC !== 'undefined') {
147 to._isUTC = from._isUTC;
148 }
149 if (typeof from._offset !== 'undefined') {
150 to._offset = from._offset;
151 }
152 if (typeof from._pf !== 'undefined') {
153 to._pf = getParsingFlags(from);
154 }
155 if (typeof from._locale !== 'undefined') {
156 to._locale = from._locale;
157 }
158
159 if (momentProperties.length > 0) {
160 for (i in momentProperties) {
161 prop = momentProperties[i];
162 val = from[prop];
163 if (typeof val !== 'undefined') {
164 to[prop] = val;
165 }
166 }
167 }
168
169 return to;
170 }
171
172 var updateInProgress = false;
173
174 // Moment prototype object
175 function Moment(config) {
176 copyConfig(this, config);
177 this._d = new Date(config._d != null ? config._d.getTime() : NaN);
178 // Prevent infinite loop in case updateOffset creates new moment
179 // objects.
180 if (updateInProgress === false) {
181 updateInProgress = true;
182 utils_hooks__hooks.updateOffset(this);
183 updateInProgress = false;
184 }
185 }
186
187 function isMoment (obj) {
188 return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
189 }
190
191 function absFloor (number) {
192 if (number < 0) {
193 return Math.ceil(number);
194 } else {
195 return Math.floor(number);
196 }
197 }
198
199 function toInt(argumentForCoercion) {
200 var coercedNumber = +argumentForCoercion,
201 value = 0;
202
203 if (coercedNumber !== 0 && isFinite(coercedNumber)) {
204 value = absFloor(coercedNumber);
205 }
206
207 return value;
208 }
209
210 function compareArrays(array1, array2, dontConvert) {
211 var len = Math.min(array1.length, array2.length),
212 lengthDiff = Math.abs(array1.length - array2.length),
213 diffs = 0,
214 i;
215 for (i = 0; i < len; i++) {
216 if ((dontConvert && array1[i] !== array2[i]) ||
217 (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
218 diffs++;
219 }
220 }
221 return diffs + lengthDiff;
222 }
223
224 function Locale() {
225 }
226
227 var locales = {};
228 var globalLocale;
229
230 function normalizeLocale(key) {
231 return key ? key.toLowerCase().replace('_', '-') : key;
232 }
233
234 // pick the locale from the array
235 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
236 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
237 function chooseLocale(names) {
238 var i = 0, j, next, locale, split;
239
240 while (i < names.length) {
241 split = normalizeLocale(names[i]).split('-');
242 j = split.length;
243 next = normalizeLocale(names[i + 1]);
244 next = next ? next.split('-') : null;
245 while (j > 0) {
246 locale = loadLocale(split.slice(0, j).join('-'));
247 if (locale) {
248 return locale;
249 }
250 if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
251 //the next array item is better than a shallower substring of this one
252 break;
253 }
254 j--;
255 }
256 i++;
257 }
258 return null;
259 }
260
261 function loadLocale(name) {
262 var oldLocale = null;
263 // TODO: Find a better way to register and load all the locales in Node
264 if (!locales[name] && typeof module !== 'undefined' &&
265 module && module.exports) {
266 try {
267 oldLocale = globalLocale._abbr;
268 require('./locale/' + name);
269 // because defineLocale currently also sets the global locale, we
270 // want to undo that for lazy loaded locales
271 locale_locales__getSetGlobalLocale(oldLocale);
272 } catch (e) { }
273 }
274 return locales[name];
275 }
276
277 // This function will load locale and then set the global locale. If
278 // no arguments are passed in, it will simply return the current global
279 // locale key.
280 function locale_locales__getSetGlobalLocale (key, values) {
281 var data;
282 if (key) {
283 if (typeof values === 'undefined') {
284 data = locale_locales__getLocale(key);
285 }
286 else {
287 data = defineLocale(key, values);
288 }
289
290 if (data) {
291 // moment.duration._locale = moment._locale = data;
292 globalLocale = data;
293 }
294 }
295
296 return globalLocale._abbr;
297 }
298
299 function defineLocale (name, values) {
300 if (values !== null) {
301 values.abbr = name;
302 locales[name] = locales[name] || new Locale();
303 locales[name].set(values);
304
305 // backwards compat for now: also set the locale
306 locale_locales__getSetGlobalLocale(name);
307
308 return locales[name];
309 } else {
310 // useful for testing
311 delete locales[name];
312 return null;
313 }
314 }
315
316 // returns locale data
317 function locale_locales__getLocale (key) {
318 var locale;
319
320 if (key && key._locale && key._locale._abbr) {
321 key = key._locale._abbr;
322 }
323
324 if (!key) {
325 return globalLocale;
326 }
327
328 if (!isArray(key)) {
329 //short-circuit everything else
330 locale = loadLocale(key);
331 if (locale) {
332 return locale;
333 }
334 key = [key];
335 }
336
337 return chooseLocale(key);
338 }
339
340 var aliases = {};
341
342 function addUnitAlias (unit, shorthand) {
343 var lowerCase = unit.toLowerCase();
344 aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
345 }
346
347 function normalizeUnits(units) {
348 return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
349 }
350
351 function normalizeObjectUnits(inputObject) {
352 var normalizedInput = {},
353 normalizedProp,
354 prop;
355
356 for (prop in inputObject) {
357 if (hasOwnProp(inputObject, prop)) {
358 normalizedProp = normalizeUnits(prop);
359 if (normalizedProp) {
360 normalizedInput[normalizedProp] = inputObject[prop];
361 }
362 }
363 }
364
365 return normalizedInput;
366 }
367
368 function makeGetSet (unit, keepTime) {
369 return function (value) {
370 if (value != null) {
371 get_set__set(this, unit, value);
372 utils_hooks__hooks.updateOffset(this, keepTime);
373 return this;
374 } else {
375 return get_set__get(this, unit);
376 }
377 };
378 }
379
380 function get_set__get (mom, unit) {
381 return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
382 }
383
384 function get_set__set (mom, unit, value) {
385 return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
386 }
387
388 // MOMENTS
389
390 function getSet (units, value) {
391 var unit;
392 if (typeof units === 'object') {
393 for (unit in units) {
394 this.set(unit, units[unit]);
395 }
396 } else {
397 units = normalizeUnits(units);
398 if (typeof this[units] === 'function') {
399 return this[units](value);
400 }
401 }
402 return this;
403 }
404
405 function zeroFill(number, targetLength, forceSign) {
406 var absNumber = '' + Math.abs(number),
407 zerosToFill = targetLength - absNumber.length,
408 sign = number >= 0;
409 return (sign ? (forceSign ? '+' : '') : '-') +
410 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
411 }
412
413 var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
414
415 var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
416
417 var formatFunctions = {};
418
419 var formatTokenFunctions = {};
420
421 // token: 'M'
422 // padded: ['MM', 2]
423 // ordinal: 'Mo'
424 // callback: function () { this.month() + 1 }
425 function addFormatToken (token, padded, ordinal, callback) {
426 var func = callback;
427 if (typeof callback === 'string') {
428 func = function () {
429 return this[callback]();
430 };
431 }
432 if (token) {
433 formatTokenFunctions[token] = func;
434 }
435 if (padded) {
436 formatTokenFunctions[padded[0]] = function () {
437 return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
438 };
439 }
440 if (ordinal) {
441 formatTokenFunctions[ordinal] = function () {
442 return this.localeData().ordinal(func.apply(this, arguments), token);
443 };
444 }
445 }
446
447 function removeFormattingTokens(input) {
448 if (input.match(/\[[\s\S]/)) {
449 return input.replace(/^\[|\]$/g, '');
450 }
451 return input.replace(/\\/g, '');
452 }
453
454 function makeFormatFunction(format) {
455 var array = format.match(formattingTokens), i, length;
456
457 for (i = 0, length = array.length; i < length; i++) {
458 if (formatTokenFunctions[array[i]]) {
459 array[i] = formatTokenFunctions[array[i]];
460 } else {
461 array[i] = removeFormattingTokens(array[i]);
462 }
463 }
464
465 return function (mom) {
466 var output = '';
467 for (i = 0; i < length; i++) {
468 output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
469 }
470 return output;
471 };
472 }
473
474 // format date using native date object
475 function formatMoment(m, format) {
476 if (!m.isValid()) {
477 return m.localeData().invalidDate();
478 }
479
480 format = expandFormat(format, m.localeData());
481 formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
482
483 return formatFunctions[format](m);
484 }
485
486 function expandFormat(format, locale) {
487 var i = 5;
488
489 function replaceLongDateFormatTokens(input) {
490 return locale.longDateFormat(input) || input;
491 }
492
493 localFormattingTokens.lastIndex = 0;
494 while (i >= 0 && localFormattingTokens.test(format)) {
495 format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
496 localFormattingTokens.lastIndex = 0;
497 i -= 1;
498 }
499
500 return format;
501 }
502
503 var match1 = /\d/; // 0 - 9
504 var match2 = /\d\d/; // 00 - 99
505 var match3 = /\d{3}/; // 000 - 999
506 var match4 = /\d{4}/; // 0000 - 9999
507 var match6 = /[+-]?\d{6}/; // -999999 - 999999
508 var match1to2 = /\d\d?/; // 0 - 99
509 var match1to3 = /\d{1,3}/; // 0 - 999
510 var match1to4 = /\d{1,4}/; // 0 - 9999
511 var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
512
513 var matchUnsigned = /\d+/; // 0 - inf
514 var matchSigned = /[+-]?\d+/; // -inf - inf
515
516 var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
517
518 var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
519
520 // any word (or two) characters or numbers including two/three word month in arabic.
521 var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
522
523 var regexes = {};
524
525 function isFunction (sth) {
526 // https://github.com/moment/moment/issues/2325
527 return typeof sth === 'function' &&
528 Object.prototype.toString.call(sth) === '[object Function]';
529 }
530
531
532 function addRegexToken (token, regex, strictRegex) {
533 regexes[token] = isFunction(regex) ? regex : function (isStrict) {
534 return (isStrict && strictRegex) ? strictRegex : regex;
535 };
536 }
537
538 function getParseRegexForToken (token, config) {
539 if (!hasOwnProp(regexes, token)) {
540 return new RegExp(unescapeFormat(token));
541 }
542
543 return regexes[token](config._strict, config._locale);
544 }
545
546 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
547 function unescapeFormat(s) {
548 return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
549 return p1 || p2 || p3 || p4;
550 }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
551 }
552
553 var tokens = {};
554
555 function addParseToken (token, callback) {
556 var i, func = callback;
557 if (typeof token === 'string') {
558 token = [token];
559 }
560 if (typeof callback === 'number') {
561 func = function (input, array) {
562 array[callback] = toInt(input);
563 };
564 }
565 for (i = 0; i < token.length; i++) {
566 tokens[token[i]] = func;
567 }
568 }
569
570 function addWeekParseToken (token, callback) {
571 addParseToken(token, function (input, array, config, token) {
572 config._w = config._w || {};
573 callback(input, config._w, config, token);
574 });
575 }
576
577 function addTimeToArrayFromToken(token, input, config) {
578 if (input != null && hasOwnProp(tokens, token)) {
579 tokens[token](input, config._a, config, token);
580 }
581 }
582
583 var YEAR = 0;
584 var MONTH = 1;
585 var DATE = 2;
586 var HOUR = 3;
587 var MINUTE = 4;
588 var SECOND = 5;
589 var MILLISECOND = 6;
590
591 function daysInMonth(year, month) {
592 return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
593 }
594
595 // FORMATTING
596
597 addFormatToken('M', ['MM', 2], 'Mo', function () {
598 return this.month() + 1;
599 });
600
601 addFormatToken('MMM', 0, 0, function (format) {
602 return this.localeData().monthsShort(this, format);
603 });
604
605 addFormatToken('MMMM', 0, 0, function (format) {
606 return this.localeData().months(this, format);
607 });
608
609 // ALIASES
610
611 addUnitAlias('month', 'M');
612
613 // PARSING
614
615 addRegexToken('M', match1to2);
616 addRegexToken('MM', match1to2, match2);
617 addRegexToken('MMM', matchWord);
618 addRegexToken('MMMM', matchWord);
619
620 addParseToken(['M', 'MM'], function (input, array) {
621 array[MONTH] = toInt(input) - 1;
622 });
623
624 addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
625 var month = config._locale.monthsParse(input, token, config._strict);
626 // if we didn't find a month name, mark the date as invalid.
627 if (month != null) {
628 array[MONTH] = month;
629 } else {
630 getParsingFlags(config).invalidMonth = input;
631 }
632 });
633
634 // LOCALES
635
636 var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
637 function localeMonths (m) {
638 return this._months[m.month()];
639 }
640
641 var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
642 function localeMonthsShort (m) {
643 return this._monthsShort[m.month()];
644 }
645
646 function localeMonthsParse (monthName, format, strict) {
647 var i, mom, regex;
648
649 if (!this._monthsParse) {
650 this._monthsParse = [];
651 this._longMonthsParse = [];
652 this._shortMonthsParse = [];
653 }
654
655 for (i = 0; i < 12; i++) {
656 // make the regex if we don't have it already
657 mom = create_utc__createUTC([2000, i]);
658 if (strict && !this._longMonthsParse[i]) {
659 this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
660 this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
661 }
662 if (!strict && !this._monthsParse[i]) {
663 regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
664 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
665 }
666 // test the regex
667 if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
668 return i;
669 } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
670 return i;
671 } else if (!strict && this._monthsParse[i].test(monthName)) {
672 return i;
673 }
674 }
675 }
676
677 // MOMENTS
678
679 function setMonth (mom, value) {
680 var dayOfMonth;
681
682 // TODO: Move this out of here!
683 if (typeof value === 'string') {
684 value = mom.localeData().monthsParse(value);
685 // TODO: Another silent failure?
686 if (typeof value !== 'number') {
687 return mom;
688 }
689 }
690
691 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
692 mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
693 return mom;
694 }
695
696 function getSetMonth (value) {
697 if (value != null) {
698 setMonth(this, value);
699 utils_hooks__hooks.updateOffset(this, true);
700 return this;
701 } else {
702 return get_set__get(this, 'Month');
703 }
704 }
705
706 function getDaysInMonth () {
707 return daysInMonth(this.year(), this.month());
708 }
709
710 function checkOverflow (m) {
711 var overflow;
712 var a = m._a;
713
714 if (a && getParsingFlags(m).overflow === -2) {
715 overflow =
716 a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
717 a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
718 a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
719 a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
720 a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
721 a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
722 -1;
723
724 if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
725 overflow = DATE;
726 }
727
728 getParsingFlags(m).overflow = overflow;
729 }
730
731 return m;
732 }
733
734 function warn(msg) {
735 if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
736 console.warn('Deprecation warning: ' + msg);
737 }
738 }
739
740 function deprecate(msg, fn) {
741 var firstTime = true;
742
743 return extend(function () {
744 if (firstTime) {
745 warn(msg + '\n' + (new Error()).stack);
746 firstTime = false;
747 }
748 return fn.apply(this, arguments);
749 }, fn);
750 }
751
752 var deprecations = {};
753
754 function deprecateSimple(name, msg) {
755 if (!deprecations[name]) {
756 warn(msg);
757 deprecations[name] = true;
758 }
759 }
760
761 utils_hooks__hooks.suppressDeprecationWarnings = false;
762
763 var from_string__isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
764
765 var isoDates = [
766 ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
767 ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
768 ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
769 ['GGGG-[W]WW', /\d{4}-W\d{2}/],
770 ['YYYY-DDD', /\d{4}-\d{3}/]
771 ];
772
773 // iso time formats and regexes
774 var isoTimes = [
775 ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
776 ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
777 ['HH:mm', /(T| )\d\d:\d\d/],
778 ['HH', /(T| )\d\d/]
779 ];
780
781 var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
782
783 // date from iso format
784 function configFromISO(config) {
785 var i, l,
786 string = config._i,
787 match = from_string__isoRegex.exec(string);
788
789 if (match) {
790 getParsingFlags(config).iso = true;
791 for (i = 0, l = isoDates.length; i < l; i++) {
792 if (isoDates[i][1].exec(string)) {
793 config._f = isoDates[i][0];
794 break;
795 }
796 }
797 for (i = 0, l = isoTimes.length; i < l; i++) {
798 if (isoTimes[i][1].exec(string)) {
799 // match[6] should be 'T' or space
800 config._f += (match[6] || ' ') + isoTimes[i][0];
801 break;
802 }
803 }
804 if (string.match(matchOffset)) {
805 config._f += 'Z';
806 }
807 configFromStringAndFormat(config);
808 } else {
809 config._isValid = false;
810 }
811 }
812
813 // date from iso format or fallback
814 function configFromString(config) {
815 var matched = aspNetJsonRegex.exec(config._i);
816
817 if (matched !== null) {
818 config._d = new Date(+matched[1]);
819 return;
820 }
821
822 configFromISO(config);
823 if (config._isValid === false) {
824 delete config._isValid;
825 utils_hooks__hooks.createFromInputFallback(config);
826 }
827 }
828
829 utils_hooks__hooks.createFromInputFallback = deprecate(
830 'moment construction falls back to js Date. This is ' +
831 'discouraged and will be removed in upcoming major ' +
832 'release. Please refer to ' +
833 'https://github.com/moment/moment/issues/1407 for more info.',
834 function (config) {
835 config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
836 }
837 );
838
839 function createDate (y, m, d, h, M, s, ms) {
840 //can't just apply() to create a date:
841 //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
842 var date = new Date(y, m, d, h, M, s, ms);
843
844 //the date constructor doesn't accept years < 1970
845 if (y < 1970) {
846 date.setFullYear(y);
847 }
848 return date;
849 }
850
851 function createUTCDate (y) {
852 var date = new Date(Date.UTC.apply(null, arguments));
853 if (y < 1970) {
854 date.setUTCFullYear(y);
855 }
856 return date;
857 }
858
859 addFormatToken(0, ['YY', 2], 0, function () {
860 return this.year() % 100;
861 });
862
863 addFormatToken(0, ['YYYY', 4], 0, 'year');
864 addFormatToken(0, ['YYYYY', 5], 0, 'year');
865 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
866
867 // ALIASES
868
869 addUnitAlias('year', 'y');
870
871 // PARSING
872
873 addRegexToken('Y', matchSigned);
874 addRegexToken('YY', match1to2, match2);
875 addRegexToken('YYYY', match1to4, match4);
876 addRegexToken('YYYYY', match1to6, match6);
877 addRegexToken('YYYYYY', match1to6, match6);
878
879 addParseToken(['YYYYY', 'YYYYYY'], YEAR);
880 addParseToken('YYYY', function (input, array) {
881 array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
882 });
883 addParseToken('YY', function (input, array) {
884 array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
885 });
886
887 // HELPERS
888
889 function daysInYear(year) {
890 return isLeapYear(year) ? 366 : 365;
891 }
892
893 function isLeapYear(year) {
894 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
895 }
896
897 // HOOKS
898
899 utils_hooks__hooks.parseTwoDigitYear = function (input) {
900 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
901 };
902
903 // MOMENTS
904
905 var getSetYear = makeGetSet('FullYear', false);
906
907 function getIsLeapYear () {
908 return isLeapYear(this.year());
909 }
910
911 addFormatToken('w', ['ww', 2], 'wo', 'week');
912 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
913
914 // ALIASES
915
916 addUnitAlias('week', 'w');
917 addUnitAlias('isoWeek', 'W');
918
919 // PARSING
920
921 addRegexToken('w', match1to2);
922 addRegexToken('ww', match1to2, match2);
923 addRegexToken('W', match1to2);
924 addRegexToken('WW', match1to2, match2);
925
926 addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
927 week[token.substr(0, 1)] = toInt(input);
928 });
929
930 // HELPERS
931
932 // firstDayOfWeek 0 = sun, 6 = sat
933 // the day of the week that starts the week
934 // (usually sunday or monday)
935 // firstDayOfWeekOfYear 0 = sun, 6 = sat
936 // the first week is the week that contains the first
937 // of this day of the week
938 // (eg. ISO weeks use thursday (4))
939 function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
940 var end = firstDayOfWeekOfYear - firstDayOfWeek,
941 daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
942 adjustedMoment;
943
944
945 if (daysToDayOfWeek > end) {
946 daysToDayOfWeek -= 7;
947 }
948
949 if (daysToDayOfWeek < end - 7) {
950 daysToDayOfWeek += 7;
951 }
952
953 adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
954 return {
955 week: Math.ceil(adjustedMoment.dayOfYear() / 7),
956 year: adjustedMoment.year()
957 };
958 }
959
960 // LOCALES
961
962 function localeWeek (mom) {
963 return weekOfYear(mom, this._week.dow, this._week.doy).week;
964 }
965
966 var defaultLocaleWeek = {
967 dow : 0, // Sunday is the first day of the week.
968 doy : 6 // The week that contains Jan 1st is the first week of the year.
969 };
970
971 function localeFirstDayOfWeek () {
972 return this._week.dow;
973 }
974
975 function localeFirstDayOfYear () {
976 return this._week.doy;
977 }
978
979 // MOMENTS
980
981 function getSetWeek (input) {
982 var week = this.localeData().week(this);
983 return input == null ? week : this.add((input - week) * 7, 'd');
984 }
985
986 function getSetISOWeek (input) {
987 var week = weekOfYear(this, 1, 4).week;
988 return input == null ? week : this.add((input - week) * 7, 'd');
989 }
990
991 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
992
993 // ALIASES
994
995 addUnitAlias('dayOfYear', 'DDD');
996
997 // PARSING
998
999 addRegexToken('DDD', match1to3);
1000 addRegexToken('DDDD', match3);
1001 addParseToken(['DDD', 'DDDD'], function (input, array, config) {
1002 config._dayOfYear = toInt(input);
1003 });
1004
1005 // HELPERS
1006
1007 //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1008 function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
1009 var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear;
1010 if (d < firstDayOfWeek) {
1011 d += 7;
1012 }
1013
1014 weekday = weekday != null ? 1 * weekday : firstDayOfWeek;
1015
1016 dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday;
1017
1018 return {
1019 year: dayOfYear > 0 ? year : year - 1,
1020 dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
1021 };
1022 }
1023
1024 // MOMENTS
1025
1026 function getSetDayOfYear (input) {
1027 var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
1028 return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
1029 }
1030
1031 // Pick the first defined of two or three arguments.
1032 function defaults(a, b, c) {
1033 if (a != null) {
1034 return a;
1035 }
1036 if (b != null) {
1037 return b;
1038 }
1039 return c;
1040 }
1041
1042 function currentDateArray(config) {
1043 var now = new Date();
1044 if (config._useUTC) {
1045 return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
1046 }
1047 return [now.getFullYear(), now.getMonth(), now.getDate()];
1048 }
1049
1050 // convert an array to a date.
1051 // the array should mirror the parameters below
1052 // note: all values past the year are optional and will default to the lowest possible value.
1053 // [year, month, day , hour, minute, second, millisecond]
1054 function configFromArray (config) {
1055 var i, date, input = [], currentDate, yearToUse;
1056
1057 if (config._d) {
1058 return;
1059 }
1060
1061 currentDate = currentDateArray(config);
1062
1063 //compute day of the year from weeks and weekdays
1064 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
1065 dayOfYearFromWeekInfo(config);
1066 }
1067
1068 //if the day of the year is set, figure out what it is
1069 if (config._dayOfYear) {
1070 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
1071
1072 if (config._dayOfYear > daysInYear(yearToUse)) {
1073 getParsingFlags(config)._overflowDayOfYear = true;
1074 }
1075
1076 date = createUTCDate(yearToUse, 0, config._dayOfYear);
1077 config._a[MONTH] = date.getUTCMonth();
1078 config._a[DATE] = date.getUTCDate();
1079 }
1080
1081 // Default to current date.
1082 // * if no year, month, day of month are given, default to today
1083 // * if day of month is given, default month and year
1084 // * if month is given, default only year
1085 // * if year is given, don't default anything
1086 for (i = 0; i < 3 && config._a[i] == null; ++i) {
1087 config._a[i] = input[i] = currentDate[i];
1088 }
1089
1090 // Zero out whatever was not defaulted, including time
1091 for (; i < 7; i++) {
1092 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
1093 }
1094
1095 // Check for 24:00:00.000
1096 if (config._a[HOUR] === 24 &&
1097 config._a[MINUTE] === 0 &&
1098 config._a[SECOND] === 0 &&
1099 config._a[MILLISECOND] === 0) {
1100 config._nextDay = true;
1101 config._a[HOUR] = 0;
1102 }
1103
1104 config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
1105 // Apply timezone offset from input. The actual utcOffset can be changed
1106 // with parseZone.
1107 if (config._tzm != null) {
1108 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
1109 }
1110
1111 if (config._nextDay) {
1112 config._a[HOUR] = 24;
1113 }
1114 }
1115
1116 function dayOfYearFromWeekInfo(config) {
1117 var w, weekYear, week, weekday, dow, doy, temp;
1118
1119 w = config._w;
1120 if (w.GG != null || w.W != null || w.E != null) {
1121 dow = 1;
1122 doy = 4;
1123
1124 // TODO: We need to take the current isoWeekYear, but that depends on
1125 // how we interpret now (local, utc, fixed offset). So create
1126 // a now version of current config (take local/utc/offset flags, and
1127 // create now).
1128 weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
1129 week = defaults(w.W, 1);
1130 weekday = defaults(w.E, 1);
1131 } else {
1132 dow = config._locale._week.dow;
1133 doy = config._locale._week.doy;
1134
1135 weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
1136 week = defaults(w.w, 1);
1137
1138 if (w.d != null) {
1139 // weekday -- low day numbers are considered next week
1140 weekday = w.d;
1141 if (weekday < dow) {
1142 ++week;
1143 }
1144 } else if (w.e != null) {
1145 // local weekday -- counting starts from begining of week
1146 weekday = w.e + dow;
1147 } else {
1148 // default to begining of week
1149 weekday = dow;
1150 }
1151 }
1152 temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
1153
1154 config._a[YEAR] = temp.year;
1155 config._dayOfYear = temp.dayOfYear;
1156 }
1157
1158 utils_hooks__hooks.ISO_8601 = function () {};
1159
1160 // date from string and format string
1161 function configFromStringAndFormat(config) {
1162 // TODO: Move this to another part of the creation flow to prevent circular deps
1163 if (config._f === utils_hooks__hooks.ISO_8601) {
1164 configFromISO(config);
1165 return;
1166 }
1167
1168 config._a = [];
1169 getParsingFlags(config).empty = true;
1170
1171 // This array is used to make a Date, either with `new Date` or `Date.UTC`
1172 var string = '' + config._i,
1173 i, parsedInput, tokens, token, skipped,
1174 stringLength = string.length,
1175 totalParsedInputLength = 0;
1176
1177 tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
1178
1179 for (i = 0; i < tokens.length; i++) {
1180 token = tokens[i];
1181 parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
1182 if (parsedInput) {
1183 skipped = string.substr(0, string.indexOf(parsedInput));
1184 if (skipped.length > 0) {
1185 getParsingFlags(config).unusedInput.push(skipped);
1186 }
1187 string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
1188 totalParsedInputLength += parsedInput.length;
1189 }
1190 // don't parse if it's not a known token
1191 if (formatTokenFunctions[token]) {
1192 if (parsedInput) {
1193 getParsingFlags(config).empty = false;
1194 }
1195 else {
1196 getParsingFlags(config).unusedTokens.push(token);
1197 }
1198 addTimeToArrayFromToken(token, parsedInput, config);
1199 }
1200 else if (config._strict && !parsedInput) {
1201 getParsingFlags(config).unusedTokens.push(token);
1202 }
1203 }
1204
1205 // add remaining unparsed input length to the string
1206 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
1207 if (string.length > 0) {
1208 getParsingFlags(config).unusedInput.push(string);
1209 }
1210
1211 // clear _12h flag if hour is <= 12
1212 if (getParsingFlags(config).bigHour === true &&
1213 config._a[HOUR] <= 12 &&
1214 config._a[HOUR] > 0) {
1215 getParsingFlags(config).bigHour = undefined;
1216 }
1217 // handle meridiem
1218 config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
1219
1220 configFromArray(config);
1221 checkOverflow(config);
1222 }
1223
1224
1225 function meridiemFixWrap (locale, hour, meridiem) {
1226 var isPm;
1227
1228 if (meridiem == null) {
1229 // nothing to do
1230 return hour;
1231 }
1232 if (locale.meridiemHour != null) {
1233 return locale.meridiemHour(hour, meridiem);
1234 } else if (locale.isPM != null) {
1235 // Fallback
1236 isPm = locale.isPM(meridiem);
1237 if (isPm && hour < 12) {
1238 hour += 12;
1239 }
1240 if (!isPm && hour === 12) {
1241 hour = 0;
1242 }
1243 return hour;
1244 } else {
1245 // this is not supposed to happen
1246 return hour;
1247 }
1248 }
1249
1250 function configFromStringAndArray(config) {
1251 var tempConfig,
1252 bestMoment,
1253
1254 scoreToBeat,
1255 i,
1256 currentScore;
1257
1258 if (config._f.length === 0) {
1259 getParsingFlags(config).invalidFormat = true;
1260 config._d = new Date(NaN);
1261 return;
1262 }
1263
1264 for (i = 0; i < config._f.length; i++) {
1265 currentScore = 0;
1266 tempConfig = copyConfig({}, config);
1267 if (config._useUTC != null) {
1268 tempConfig._useUTC = config._useUTC;
1269 }
1270 tempConfig._f = config._f[i];
1271 configFromStringAndFormat(tempConfig);
1272
1273 if (!valid__isValid(tempConfig)) {
1274 continue;
1275 }
1276
1277 // if there is any input that was not parsed add a penalty for that format
1278 currentScore += getParsingFlags(tempConfig).charsLeftOver;
1279
1280 //or tokens
1281 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
1282
1283 getParsingFlags(tempConfig).score = currentScore;
1284
1285 if (scoreToBeat == null || currentScore < scoreToBeat) {
1286 scoreToBeat = currentScore;
1287 bestMoment = tempConfig;
1288 }
1289 }
1290
1291 extend(config, bestMoment || tempConfig);
1292 }
1293
1294 function configFromObject(config) {
1295 if (config._d) {
1296 return;
1297 }
1298
1299 var i = normalizeObjectUnits(config._i);
1300 config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
1301
1302 configFromArray(config);
1303 }
1304
1305 function createFromConfig (config) {
1306 var res = new Moment(checkOverflow(prepareConfig(config)));
1307 if (res._nextDay) {
1308 // Adding is smart enough around DST
1309 res.add(1, 'd');
1310 res._nextDay = undefined;
1311 }
1312
1313 return res;
1314 }
1315
1316 function prepareConfig (config) {
1317 var input = config._i,
1318 format = config._f;
1319
1320 config._locale = config._locale || locale_locales__getLocale(config._l);
1321
1322 if (input === null || (format === undefined && input === '')) {
1323 return valid__createInvalid({nullInput: true});
1324 }
1325
1326 if (typeof input === 'string') {
1327 config._i = input = config._locale.preparse(input);
1328 }
1329
1330 if (isMoment(input)) {
1331 return new Moment(checkOverflow(input));
1332 } else if (isArray(format)) {
1333 configFromStringAndArray(config);
1334 } else if (format) {
1335 configFromStringAndFormat(config);
1336 } else if (isDate(input)) {
1337 config._d = input;
1338 } else {
1339 configFromInput(config);
1340 }
1341
1342 return config;
1343 }
1344
1345 function configFromInput(config) {
1346 var input = config._i;
1347 if (input === undefined) {
1348 config._d = new Date();
1349 } else if (isDate(input)) {
1350 config._d = new Date(+input);
1351 } else if (typeof input === 'string') {
1352 configFromString(config);
1353 } else if (isArray(input)) {
1354 config._a = map(input.slice(0), function (obj) {
1355 return parseInt(obj, 10);
1356 });
1357 configFromArray(config);
1358 } else if (typeof(input) === 'object') {
1359 configFromObject(config);
1360 } else if (typeof(input) === 'number') {
1361 // from milliseconds
1362 config._d = new Date(input);
1363 } else {
1364 utils_hooks__hooks.createFromInputFallback(config);
1365 }
1366 }
1367
1368 function createLocalOrUTC (input, format, locale, strict, isUTC) {
1369 var c = {};
1370
1371 if (typeof(locale) === 'boolean') {
1372 strict = locale;
1373 locale = undefined;
1374 }
1375 // object construction must be done this way.
1376 // https://github.com/moment/moment/issues/1423
1377 c._isAMomentObject = true;
1378 c._useUTC = c._isUTC = isUTC;
1379 c._l = locale;
1380 c._i = input;
1381 c._f = format;
1382 c._strict = strict;
1383
1384 return createFromConfig(c);
1385 }
1386
1387 function local__createLocal (input, format, locale, strict) {
1388 return createLocalOrUTC(input, format, locale, strict, false);
1389 }
1390
1391 var prototypeMin = deprecate(
1392 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
1393 function () {
1394 var other = local__createLocal.apply(null, arguments);
1395 return other < this ? this : other;
1396 }
1397 );
1398
1399 var prototypeMax = deprecate(
1400 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
1401 function () {
1402 var other = local__createLocal.apply(null, arguments);
1403 return other > this ? this : other;
1404 }
1405 );
1406
1407 // Pick a moment m from moments so that m[fn](other) is true for all
1408 // other. This relies on the function fn to be transitive.
1409 //
1410 // moments should either be an array of moment objects or an array, whose
1411 // first element is an array of moment objects.
1412 function pickBy(fn, moments) {
1413 var res, i;
1414 if (moments.length === 1 && isArray(moments[0])) {
1415 moments = moments[0];
1416 }
1417 if (!moments.length) {
1418 return local__createLocal();
1419 }
1420 res = moments[0];
1421 for (i = 1; i < moments.length; ++i) {
1422 if (!moments[i].isValid() || moments[i][fn](res)) {
1423 res = moments[i];
1424 }
1425 }
1426 return res;
1427 }
1428
1429 // TODO: Use [].sort instead?
1430 function min () {
1431 var args = [].slice.call(arguments, 0);
1432
1433 return pickBy('isBefore', args);
1434 }
1435
1436 function max () {
1437 var args = [].slice.call(arguments, 0);
1438
1439 return pickBy('isAfter', args);
1440 }
1441
1442 function Duration (duration) {
1443 var normalizedInput = normalizeObjectUnits(duration),
1444 years = normalizedInput.year || 0,
1445 quarters = normalizedInput.quarter || 0,
1446 months = normalizedInput.month || 0,
1447 weeks = normalizedInput.week || 0,
1448 days = normalizedInput.day || 0,
1449 hours = normalizedInput.hour || 0,
1450 minutes = normalizedInput.minute || 0,
1451 seconds = normalizedInput.second || 0,
1452 milliseconds = normalizedInput.millisecond || 0;
1453
1454 // representation for dateAddRemove
1455 this._milliseconds = +milliseconds +
1456 seconds * 1e3 + // 1000
1457 minutes * 6e4 + // 1000 * 60
1458 hours * 36e5; // 1000 * 60 * 60
1459 // Because of dateAddRemove treats 24 hours as different from a
1460 // day when working around DST, we need to store them separately
1461 this._days = +days +
1462 weeks * 7;
1463 // It is impossible translate months into days without knowing
1464 // which months you are are talking about, so we have to store
1465 // it separately.
1466 this._months = +months +
1467 quarters * 3 +
1468 years * 12;
1469
1470 this._data = {};
1471
1472 this._locale = locale_locales__getLocale();
1473
1474 this._bubble();
1475 }
1476
1477 function isDuration (obj) {
1478 return obj instanceof Duration;
1479 }
1480
1481 function offset (token, separator) {
1482 addFormatToken(token, 0, 0, function () {
1483 var offset = this.utcOffset();
1484 var sign = '+';
1485 if (offset < 0) {
1486 offset = -offset;
1487 sign = '-';
1488 }
1489 return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
1490 });
1491 }
1492
1493 offset('Z', ':');
1494 offset('ZZ', '');
1495
1496 // PARSING
1497
1498 addRegexToken('Z', matchOffset);
1499 addRegexToken('ZZ', matchOffset);
1500 addParseToken(['Z', 'ZZ'], function (input, array, config) {
1501 config._useUTC = true;
1502 config._tzm = offsetFromString(input);
1503 });
1504
1505 // HELPERS
1506
1507 // timezone chunker
1508 // '+10:00' > ['10', '00']
1509 // '-1530' > ['-15', '30']
1510 var chunkOffset = /([\+\-]|\d\d)/gi;
1511
1512 function offsetFromString(string) {
1513 var matches = ((string || '').match(matchOffset) || []);
1514 var chunk = matches[matches.length - 1] || [];
1515 var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
1516 var minutes = +(parts[1] * 60) + toInt(parts[2]);
1517
1518 return parts[0] === '+' ? minutes : -minutes;
1519 }
1520
1521 // Return a moment from input, that is local/utc/zone equivalent to model.
1522 function cloneWithOffset(input, model) {
1523 var res, diff;
1524 if (model._isUTC) {
1525 res = model.clone();
1526 diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
1527 // Use low-level api, because this fn is low-level api.
1528 res._d.setTime(+res._d + diff);
1529 utils_hooks__hooks.updateOffset(res, false);
1530 return res;
1531 } else {
1532 return local__createLocal(input).local();
1533 }
1534 }
1535
1536 function getDateOffset (m) {
1537 // On Firefox.24 Date#getTimezoneOffset returns a floating point.
1538 // https://github.com/moment/moment/pull/1871
1539 return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
1540 }
1541
1542 // HOOKS
1543
1544 // This function will be called whenever a moment is mutated.
1545 // It is intended to keep the offset in sync with the timezone.
1546 utils_hooks__hooks.updateOffset = function () {};
1547
1548 // MOMENTS
1549
1550 // keepLocalTime = true means only change the timezone, without
1551 // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
1552 // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
1553 // +0200, so we adjust the time as needed, to be valid.
1554 //
1555 // Keeping the time actually adds/subtracts (one hour)
1556 // from the actual represented time. That is why we call updateOffset
1557 // a second time. In case it wants us to change the offset again
1558 // _changeInProgress == true case, then we have to adjust, because
1559 // there is no such time in the given timezone.
1560 function getSetOffset (input, keepLocalTime) {
1561 var offset = this._offset || 0,
1562 localAdjust;
1563 if (input != null) {
1564 if (typeof input === 'string') {
1565 input = offsetFromString(input);
1566 }
1567 if (Math.abs(input) < 16) {
1568 input = input * 60;
1569 }
1570 if (!this._isUTC && keepLocalTime) {
1571 localAdjust = getDateOffset(this);
1572 }
1573 this._offset = input;
1574 this._isUTC = true;
1575 if (localAdjust != null) {
1576 this.add(localAdjust, 'm');
1577 }
1578 if (offset !== input) {
1579 if (!keepLocalTime || this._changeInProgress) {
1580 add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
1581 } else if (!this._changeInProgress) {
1582 this._changeInProgress = true;
1583 utils_hooks__hooks.updateOffset(this, true);
1584 this._changeInProgress = null;
1585 }
1586 }
1587 return this;
1588 } else {
1589 return this._isUTC ? offset : getDateOffset(this);
1590 }
1591 }
1592
1593 function getSetZone (input, keepLocalTime) {
1594 if (input != null) {
1595 if (typeof input !== 'string') {
1596 input = -input;
1597 }
1598
1599 this.utcOffset(input, keepLocalTime);
1600
1601 return this;
1602 } else {
1603 return -this.utcOffset();
1604 }
1605 }
1606
1607 function setOffsetToUTC (keepLocalTime) {
1608 return this.utcOffset(0, keepLocalTime);
1609 }
1610
1611 function setOffsetToLocal (keepLocalTime) {
1612 if (this._isUTC) {
1613 this.utcOffset(0, keepLocalTime);
1614 this._isUTC = false;
1615
1616 if (keepLocalTime) {
1617 this.subtract(getDateOffset(this), 'm');
1618 }
1619 }
1620 return this;
1621 }
1622
1623 function setOffsetToParsedOffset () {
1624 if (this._tzm) {
1625 this.utcOffset(this._tzm);
1626 } else if (typeof this._i === 'string') {
1627 this.utcOffset(offsetFromString(this._i));
1628 }
1629 return this;
1630 }
1631
1632 function hasAlignedHourOffset (input) {
1633 input = input ? local__createLocal(input).utcOffset() : 0;
1634
1635 return (this.utcOffset() - input) % 60 === 0;
1636 }
1637
1638 function isDaylightSavingTime () {
1639 return (
1640 this.utcOffset() > this.clone().month(0).utcOffset() ||
1641 this.utcOffset() > this.clone().month(5).utcOffset()
1642 );
1643 }
1644
1645 function isDaylightSavingTimeShifted () {
1646 if (typeof this._isDSTShifted !== 'undefined') {
1647 return this._isDSTShifted;
1648 }
1649
1650 var c = {};
1651
1652 copyConfig(c, this);
1653 c = prepareConfig(c);
1654
1655 if (c._a) {
1656 var other = c._isUTC ? create_utc__createUTC(c._a) : local__createLocal(c._a);
1657 this._isDSTShifted = this.isValid() &&
1658 compareArrays(c._a, other.toArray()) > 0;
1659 } else {
1660 this._isDSTShifted = false;
1661 }
1662
1663 return this._isDSTShifted;
1664 }
1665
1666 function isLocal () {
1667 return !this._isUTC;
1668 }
1669
1670 function isUtcOffset () {
1671 return this._isUTC;
1672 }
1673
1674 function isUtc () {
1675 return this._isUTC && this._offset === 0;
1676 }
1677
1678 var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
1679
1680 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
1681 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
1682 var create__isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
1683
1684 function create__createDuration (input, key) {
1685 var duration = input,
1686 // matching against regexp is expensive, do it on demand
1687 match = null,
1688 sign,
1689 ret,
1690 diffRes;
1691
1692 if (isDuration(input)) {
1693 duration = {
1694 ms : input._milliseconds,
1695 d : input._days,
1696 M : input._months
1697 };
1698 } else if (typeof input === 'number') {
1699 duration = {};
1700 if (key) {
1701 duration[key] = input;
1702 } else {
1703 duration.milliseconds = input;
1704 }
1705 } else if (!!(match = aspNetRegex.exec(input))) {
1706 sign = (match[1] === '-') ? -1 : 1;
1707 duration = {
1708 y : 0,
1709 d : toInt(match[DATE]) * sign,
1710 h : toInt(match[HOUR]) * sign,
1711 m : toInt(match[MINUTE]) * sign,
1712 s : toInt(match[SECOND]) * sign,
1713 ms : toInt(match[MILLISECOND]) * sign
1714 };
1715 } else if (!!(match = create__isoRegex.exec(input))) {
1716 sign = (match[1] === '-') ? -1 : 1;
1717 duration = {
1718 y : parseIso(match[2], sign),
1719 M : parseIso(match[3], sign),
1720 d : parseIso(match[4], sign),
1721 h : parseIso(match[5], sign),
1722 m : parseIso(match[6], sign),
1723 s : parseIso(match[7], sign),
1724 w : parseIso(match[8], sign)
1725 };
1726 } else if (duration == null) {// checks for null or undefined
1727 duration = {};
1728 } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
1729 diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
1730
1731 duration = {};
1732 duration.ms = diffRes.milliseconds;
1733 duration.M = diffRes.months;
1734 }
1735
1736 ret = new Duration(duration);
1737
1738 if (isDuration(input) && hasOwnProp(input, '_locale')) {
1739 ret._locale = input._locale;
1740 }
1741
1742 return ret;
1743 }
1744
1745 create__createDuration.fn = Duration.prototype;
1746
1747 function parseIso (inp, sign) {
1748 // We'd normally use ~~inp for this, but unfortunately it also
1749 // converts floats to ints.
1750 // inp may be undefined, so careful calling replace on it.
1751 var res = inp && parseFloat(inp.replace(',', '.'));
1752 // apply sign while we're at it
1753 return (isNaN(res) ? 0 : res) * sign;
1754 }
1755
1756 function positiveMomentsDifference(base, other) {
1757 var res = {milliseconds: 0, months: 0};
1758
1759 res.months = other.month() - base.month() +
1760 (other.year() - base.year()) * 12;
1761 if (base.clone().add(res.months, 'M').isAfter(other)) {
1762 --res.months;
1763 }
1764
1765 res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
1766
1767 return res;
1768 }
1769
1770 function momentsDifference(base, other) {
1771 var res;
1772 other = cloneWithOffset(other, base);
1773 if (base.isBefore(other)) {
1774 res = positiveMomentsDifference(base, other);
1775 } else {
1776 res = positiveMomentsDifference(other, base);
1777 res.milliseconds = -res.milliseconds;
1778 res.months = -res.months;
1779 }
1780
1781 return res;
1782 }
1783
1784 function createAdder(direction, name) {
1785 return function (val, period) {
1786 var dur, tmp;
1787 //invert the arguments, but complain about it
1788 if (period !== null && !isNaN(+period)) {
1789 deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
1790 tmp = val; val = period; period = tmp;
1791 }
1792
1793 val = typeof val === 'string' ? +val : val;
1794 dur = create__createDuration(val, period);
1795 add_subtract__addSubtract(this, dur, direction);
1796 return this;
1797 };
1798 }
1799
1800 function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
1801 var milliseconds = duration._milliseconds,
1802 days = duration._days,
1803 months = duration._months;
1804 updateOffset = updateOffset == null ? true : updateOffset;
1805
1806 if (milliseconds) {
1807 mom._d.setTime(+mom._d + milliseconds * isAdding);
1808 }
1809 if (days) {
1810 get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
1811 }
1812 if (months) {
1813 setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
1814 }
1815 if (updateOffset) {
1816 utils_hooks__hooks.updateOffset(mom, days || months);
1817 }
1818 }
1819
1820 var add_subtract__add = createAdder(1, 'add');
1821 var add_subtract__subtract = createAdder(-1, 'subtract');
1822
1823 function moment_calendar__calendar (time, formats) {
1824 // We want to compare the start of today, vs this.
1825 // Getting start-of-today depends on whether we're local/utc/offset or not.
1826 var now = time || local__createLocal(),
1827 sod = cloneWithOffset(now, this).startOf('day'),
1828 diff = this.diff(sod, 'days', true),
1829 format = diff < -6 ? 'sameElse' :
1830 diff < -1 ? 'lastWeek' :
1831 diff < 0 ? 'lastDay' :
1832 diff < 1 ? 'sameDay' :
1833 diff < 2 ? 'nextDay' :
1834 diff < 7 ? 'nextWeek' : 'sameElse';
1835 return this.format(formats && formats[format] || this.localeData().calendar(format, this, local__createLocal(now)));
1836 }
1837
1838 function clone () {
1839 return new Moment(this);
1840 }
1841
1842 function isAfter (input, units) {
1843 var inputMs;
1844 units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
1845 if (units === 'millisecond') {
1846 input = isMoment(input) ? input : local__createLocal(input);
1847 return +this > +input;
1848 } else {
1849 inputMs = isMoment(input) ? +input : +local__createLocal(input);
1850 return inputMs < +this.clone().startOf(units);
1851 }
1852 }
1853
1854 function isBefore (input, units) {
1855 var inputMs;
1856 units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
1857 if (units === 'millisecond') {
1858 input = isMoment(input) ? input : local__createLocal(input);
1859 return +this < +input;
1860 } else {
1861 inputMs = isMoment(input) ? +input : +local__createLocal(input);
1862 return +this.clone().endOf(units) < inputMs;
1863 }
1864 }
1865
1866 function isBetween (from, to, units) {
1867 return this.isAfter(from, units) && this.isBefore(to, units);
1868 }
1869
1870 function isSame (input, units) {
1871 var inputMs;
1872 units = normalizeUnits(units || 'millisecond');
1873 if (units === 'millisecond') {
1874 input = isMoment(input) ? input : local__createLocal(input);
1875 return +this === +input;
1876 } else {
1877 inputMs = +local__createLocal(input);
1878 return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
1879 }
1880 }
1881
1882 function diff (input, units, asFloat) {
1883 var that = cloneWithOffset(input, this),
1884 zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
1885 delta, output;
1886
1887 units = normalizeUnits(units);
1888
1889 if (units === 'year' || units === 'month' || units === 'quarter') {
1890 output = monthDiff(this, that);
1891 if (units === 'quarter') {
1892 output = output / 3;
1893 } else if (units === 'year') {
1894 output = output / 12;
1895 }
1896 } else {
1897 delta = this - that;
1898 output = units === 'second' ? delta / 1e3 : // 1000
1899 units === 'minute' ? delta / 6e4 : // 1000 * 60
1900 units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
1901 units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
1902 units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
1903 delta;
1904 }
1905 return asFloat ? output : absFloor(output);
1906 }
1907
1908 function monthDiff (a, b) {
1909 // difference in months
1910 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
1911 // b is in (anchor - 1 month, anchor + 1 month)
1912 anchor = a.clone().add(wholeMonthDiff, 'months'),
1913 anchor2, adjust;
1914
1915 if (b - anchor < 0) {
1916 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
1917 // linear across the month
1918 adjust = (b - anchor) / (anchor - anchor2);
1919 } else {
1920 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
1921 // linear across the month
1922 adjust = (b - anchor) / (anchor2 - anchor);
1923 }
1924
1925 return -(wholeMonthDiff + adjust);
1926 }
1927
1928 utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
1929
1930 function toString () {
1931 return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
1932 }
1933
1934 function moment_format__toISOString () {
1935 var m = this.clone().utc();
1936 if (0 < m.year() && m.year() <= 9999) {
1937 if ('function' === typeof Date.prototype.toISOString) {
1938 // native implementation is ~50x faster, use it when we can
1939 return this.toDate().toISOString();
1940 } else {
1941 return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1942 }
1943 } else {
1944 return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1945 }
1946 }
1947
1948 function format (inputString) {
1949 var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
1950 return this.localeData().postformat(output);
1951 }
1952
1953 function from (time, withoutSuffix) {
1954 if (!this.isValid()) {
1955 return this.localeData().invalidDate();
1956 }
1957 return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
1958 }
1959
1960 function fromNow (withoutSuffix) {
1961 return this.from(local__createLocal(), withoutSuffix);
1962 }
1963
1964 function to (time, withoutSuffix) {
1965 if (!this.isValid()) {
1966 return this.localeData().invalidDate();
1967 }
1968 return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
1969 }
1970
1971 function toNow (withoutSuffix) {
1972 return this.to(local__createLocal(), withoutSuffix);
1973 }
1974
1975 function locale (key) {
1976 var newLocaleData;
1977
1978 if (key === undefined) {
1979 return this._locale._abbr;
1980 } else {
1981 newLocaleData = locale_locales__getLocale(key);
1982 if (newLocaleData != null) {
1983 this._locale = newLocaleData;
1984 }
1985 return this;
1986 }
1987 }
1988
1989 var lang = deprecate(
1990 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
1991 function (key) {
1992 if (key === undefined) {
1993 return this.localeData();
1994 } else {
1995 return this.locale(key);
1996 }
1997 }
1998 );
1999
2000 function localeData () {
2001 return this._locale;
2002 }
2003
2004 function startOf (units) {
2005 units = normalizeUnits(units);
2006 // the following switch intentionally omits break keywords
2007 // to utilize falling through the cases.
2008 switch (units) {
2009 case 'year':
2010 this.month(0);
2011 /* falls through */
2012 case 'quarter':
2013 case 'month':
2014 this.date(1);
2015 /* falls through */
2016 case 'week':
2017 case 'isoWeek':
2018 case 'day':
2019 this.hours(0);
2020 /* falls through */
2021 case 'hour':
2022 this.minutes(0);
2023 /* falls through */
2024 case 'minute':
2025 this.seconds(0);
2026 /* falls through */
2027 case 'second':
2028 this.milliseconds(0);
2029 }
2030
2031 // weeks are a special case
2032 if (units === 'week') {
2033 this.weekday(0);
2034 }
2035 if (units === 'isoWeek') {
2036 this.isoWeekday(1);
2037 }
2038
2039 // quarters are also special
2040 if (units === 'quarter') {
2041 this.month(Math.floor(this.month() / 3) * 3);
2042 }
2043
2044 return this;
2045 }
2046
2047 function endOf (units) {
2048 units = normalizeUnits(units);
2049 if (units === undefined || units === 'millisecond') {
2050 return this;
2051 }
2052 return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
2053 }
2054
2055 function to_type__valueOf () {
2056 return +this._d - ((this._offset || 0) * 60000);
2057 }
2058
2059 function unix () {
2060 return Math.floor(+this / 1000);
2061 }
2062
2063 function toDate () {
2064 return this._offset ? new Date(+this) : this._d;
2065 }
2066
2067 function toArray () {
2068 var m = this;
2069 return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
2070 }
2071
2072 function toObject () {
2073 var m = this;
2074 return {
2075 years: m.year(),
2076 months: m.month(),
2077 date: m.date(),
2078 hours: m.hours(),
2079 minutes: m.minutes(),
2080 seconds: m.seconds(),
2081 milliseconds: m.milliseconds()
2082 };
2083 }
2084
2085 function moment_valid__isValid () {
2086 return valid__isValid(this);
2087 }
2088
2089 function parsingFlags () {
2090 return extend({}, getParsingFlags(this));
2091 }
2092
2093 function invalidAt () {
2094 return getParsingFlags(this).overflow;
2095 }
2096
2097 addFormatToken(0, ['gg', 2], 0, function () {
2098 return this.weekYear() % 100;
2099 });
2100
2101 addFormatToken(0, ['GG', 2], 0, function () {
2102 return this.isoWeekYear() % 100;
2103 });
2104
2105 function addWeekYearFormatToken (token, getter) {
2106 addFormatToken(0, [token, token.length], 0, getter);
2107 }
2108
2109 addWeekYearFormatToken('gggg', 'weekYear');
2110 addWeekYearFormatToken('ggggg', 'weekYear');
2111 addWeekYearFormatToken('GGGG', 'isoWeekYear');
2112 addWeekYearFormatToken('GGGGG', 'isoWeekYear');
2113
2114 // ALIASES
2115
2116 addUnitAlias('weekYear', 'gg');
2117 addUnitAlias('isoWeekYear', 'GG');
2118
2119 // PARSING
2120
2121 addRegexToken('G', matchSigned);
2122 addRegexToken('g', matchSigned);
2123 addRegexToken('GG', match1to2, match2);
2124 addRegexToken('gg', match1to2, match2);
2125 addRegexToken('GGGG', match1to4, match4);
2126 addRegexToken('gggg', match1to4, match4);
2127 addRegexToken('GGGGG', match1to6, match6);
2128 addRegexToken('ggggg', match1to6, match6);
2129
2130 addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
2131 week[token.substr(0, 2)] = toInt(input);
2132 });
2133
2134 addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
2135 week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
2136 });
2137
2138 // HELPERS
2139
2140 function weeksInYear(year, dow, doy) {
2141 return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
2142 }
2143
2144 // MOMENTS
2145
2146 function getSetWeekYear (input) {
2147 var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
2148 return input == null ? year : this.add((input - year), 'y');
2149 }
2150
2151 function getSetISOWeekYear (input) {
2152 var year = weekOfYear(this, 1, 4).year;
2153 return input == null ? year : this.add((input - year), 'y');
2154 }
2155
2156 function getISOWeeksInYear () {
2157 return weeksInYear(this.year(), 1, 4);
2158 }
2159
2160 function getWeeksInYear () {
2161 var weekInfo = this.localeData()._week;
2162 return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
2163 }
2164
2165 addFormatToken('Q', 0, 0, 'quarter');
2166
2167 // ALIASES
2168
2169 addUnitAlias('quarter', 'Q');
2170
2171 // PARSING
2172
2173 addRegexToken('Q', match1);
2174 addParseToken('Q', function (input, array) {
2175 array[MONTH] = (toInt(input) - 1) * 3;
2176 });
2177
2178 // MOMENTS
2179
2180 function getSetQuarter (input) {
2181 return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
2182 }
2183
2184 addFormatToken('D', ['DD', 2], 'Do', 'date');
2185
2186 // ALIASES
2187
2188 addUnitAlias('date', 'D');
2189
2190 // PARSING
2191
2192 addRegexToken('D', match1to2);
2193 addRegexToken('DD', match1to2, match2);
2194 addRegexToken('Do', function (isStrict, locale) {
2195 return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
2196 });
2197
2198 addParseToken(['D', 'DD'], DATE);
2199 addParseToken('Do', function (input, array) {
2200 array[DATE] = toInt(input.match(match1to2)[0], 10);
2201 });
2202
2203 // MOMENTS
2204
2205 var getSetDayOfMonth = makeGetSet('Date', true);
2206
2207 addFormatToken('d', 0, 'do', 'day');
2208
2209 addFormatToken('dd', 0, 0, function (format) {
2210 return this.localeData().weekdaysMin(this, format);
2211 });
2212
2213 addFormatToken('ddd', 0, 0, function (format) {
2214 return this.localeData().weekdaysShort(this, format);
2215 });
2216
2217 addFormatToken('dddd', 0, 0, function (format) {
2218 return this.localeData().weekdays(this, format);
2219 });
2220
2221 addFormatToken('e', 0, 0, 'weekday');
2222 addFormatToken('E', 0, 0, 'isoWeekday');
2223
2224 // ALIASES
2225
2226 addUnitAlias('day', 'd');
2227 addUnitAlias('weekday', 'e');
2228 addUnitAlias('isoWeekday', 'E');
2229
2230 // PARSING
2231
2232 addRegexToken('d', match1to2);
2233 addRegexToken('e', match1to2);
2234 addRegexToken('E', match1to2);
2235 addRegexToken('dd', matchWord);
2236 addRegexToken('ddd', matchWord);
2237 addRegexToken('dddd', matchWord);
2238
2239 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
2240 var weekday = config._locale.weekdaysParse(input);
2241 // if we didn't get a weekday name, mark the date as invalid
2242 if (weekday != null) {
2243 week.d = weekday;
2244 } else {
2245 getParsingFlags(config).invalidWeekday = input;
2246 }
2247 });
2248
2249 addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
2250 week[token] = toInt(input);
2251 });
2252
2253 // HELPERS
2254
2255 function parseWeekday(input, locale) {
2256 if (typeof input !== 'string') {
2257 return input;
2258 }
2259
2260 if (!isNaN(input)) {
2261 return parseInt(input, 10);
2262 }
2263
2264 input = locale.weekdaysParse(input);
2265 if (typeof input === 'number') {
2266 return input;
2267 }
2268
2269 return null;
2270 }
2271
2272 // LOCALES
2273
2274 var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
2275 function localeWeekdays (m) {
2276 return this._weekdays[m.day()];
2277 }
2278
2279 var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
2280 function localeWeekdaysShort (m) {
2281 return this._weekdaysShort[m.day()];
2282 }
2283
2284 var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
2285 function localeWeekdaysMin (m) {
2286 return this._weekdaysMin[m.day()];
2287 }
2288
2289 function localeWeekdaysParse (weekdayName) {
2290 var i, mom, regex;
2291
2292 this._weekdaysParse = this._weekdaysParse || [];
2293
2294 for (i = 0; i < 7; i++) {
2295 // make the regex if we don't have it already
2296 if (!this._weekdaysParse[i]) {
2297 mom = local__createLocal([2000, 1]).day(i);
2298 regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
2299 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
2300 }
2301 // test the regex
2302 if (this._weekdaysParse[i].test(weekdayName)) {
2303 return i;
2304 }
2305 }
2306 }
2307
2308 // MOMENTS
2309
2310 function getSetDayOfWeek (input) {
2311 var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
2312 if (input != null) {
2313 input = parseWeekday(input, this.localeData());
2314 return this.add(input - day, 'd');
2315 } else {
2316 return day;
2317 }
2318 }
2319
2320 function getSetLocaleDayOfWeek (input) {
2321 var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
2322 return input == null ? weekday : this.add(input - weekday, 'd');
2323 }
2324
2325 function getSetISODayOfWeek (input) {
2326 // behaves the same as moment#day except
2327 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
2328 // as a setter, sunday should belong to the previous week.
2329 return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
2330 }
2331
2332 addFormatToken('H', ['HH', 2], 0, 'hour');
2333 addFormatToken('h', ['hh', 2], 0, function () {
2334 return this.hours() % 12 || 12;
2335 });
2336
2337 function meridiem (token, lowercase) {
2338 addFormatToken(token, 0, 0, function () {
2339 return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
2340 });
2341 }
2342
2343 meridiem('a', true);
2344 meridiem('A', false);
2345
2346 // ALIASES
2347
2348 addUnitAlias('hour', 'h');
2349
2350 // PARSING
2351
2352 function matchMeridiem (isStrict, locale) {
2353 return locale._meridiemParse;
2354 }
2355
2356 addRegexToken('a', matchMeridiem);
2357 addRegexToken('A', matchMeridiem);
2358 addRegexToken('H', match1to2);
2359 addRegexToken('h', match1to2);
2360 addRegexToken('HH', match1to2, match2);
2361 addRegexToken('hh', match1to2, match2);
2362
2363 addParseToken(['H', 'HH'], HOUR);
2364 addParseToken(['a', 'A'], function (input, array, config) {
2365 config._isPm = config._locale.isPM(input);
2366 config._meridiem = input;
2367 });
2368 addParseToken(['h', 'hh'], function (input, array, config) {
2369 array[HOUR] = toInt(input);
2370 getParsingFlags(config).bigHour = true;
2371 });
2372
2373 // LOCALES
2374
2375 function localeIsPM (input) {
2376 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
2377 // Using charAt should be more compatible.
2378 return ((input + '').toLowerCase().charAt(0) === 'p');
2379 }
2380
2381 var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
2382 function localeMeridiem (hours, minutes, isLower) {
2383 if (hours > 11) {
2384 return isLower ? 'pm' : 'PM';
2385 } else {
2386 return isLower ? 'am' : 'AM';
2387 }
2388 }
2389
2390
2391 // MOMENTS
2392
2393 // Setting the hour should keep the time, because the user explicitly
2394 // specified which hour he wants. So trying to maintain the same hour (in
2395 // a new timezone) makes sense. Adding/subtracting hours does not follow
2396 // this rule.
2397 var getSetHour = makeGetSet('Hours', true);
2398
2399 addFormatToken('m', ['mm', 2], 0, 'minute');
2400
2401 // ALIASES
2402
2403 addUnitAlias('minute', 'm');
2404
2405 // PARSING
2406
2407 addRegexToken('m', match1to2);
2408 addRegexToken('mm', match1to2, match2);
2409 addParseToken(['m', 'mm'], MINUTE);
2410
2411 // MOMENTS
2412
2413 var getSetMinute = makeGetSet('Minutes', false);
2414
2415 addFormatToken('s', ['ss', 2], 0, 'second');
2416
2417 // ALIASES
2418
2419 addUnitAlias('second', 's');
2420
2421 // PARSING
2422
2423 addRegexToken('s', match1to2);
2424 addRegexToken('ss', match1to2, match2);
2425 addParseToken(['s', 'ss'], SECOND);
2426
2427 // MOMENTS
2428
2429 var getSetSecond = makeGetSet('Seconds', false);
2430
2431 addFormatToken('S', 0, 0, function () {
2432 return ~~(this.millisecond() / 100);
2433 });
2434
2435 addFormatToken(0, ['SS', 2], 0, function () {
2436 return ~~(this.millisecond() / 10);
2437 });
2438
2439 addFormatToken(0, ['SSS', 3], 0, 'millisecond');
2440 addFormatToken(0, ['SSSS', 4], 0, function () {
2441 return this.millisecond() * 10;
2442 });
2443 addFormatToken(0, ['SSSSS', 5], 0, function () {
2444 return this.millisecond() * 100;
2445 });
2446 addFormatToken(0, ['SSSSSS', 6], 0, function () {
2447 return this.millisecond() * 1000;
2448 });
2449 addFormatToken(0, ['SSSSSSS', 7], 0, function () {
2450 return this.millisecond() * 10000;
2451 });
2452 addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
2453 return this.millisecond() * 100000;
2454 });
2455 addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
2456 return this.millisecond() * 1000000;
2457 });
2458
2459
2460 // ALIASES
2461
2462 addUnitAlias('millisecond', 'ms');
2463
2464 // PARSING
2465
2466 addRegexToken('S', match1to3, match1);
2467 addRegexToken('SS', match1to3, match2);
2468 addRegexToken('SSS', match1to3, match3);
2469
2470 var token;
2471 for (token = 'SSSS'; token.length <= 9; token += 'S') {
2472 addRegexToken(token, matchUnsigned);
2473 }
2474
2475 function parseMs(input, array) {
2476 array[MILLISECOND] = toInt(('0.' + input) * 1000);
2477 }
2478
2479 for (token = 'S'; token.length <= 9; token += 'S') {
2480 addParseToken(token, parseMs);
2481 }
2482 // MOMENTS
2483
2484 var getSetMillisecond = makeGetSet('Milliseconds', false);
2485
2486 addFormatToken('z', 0, 0, 'zoneAbbr');
2487 addFormatToken('zz', 0, 0, 'zoneName');
2488
2489 // MOMENTS
2490
2491 function getZoneAbbr () {
2492 return this._isUTC ? 'UTC' : '';
2493 }
2494
2495 function getZoneName () {
2496 return this._isUTC ? 'Coordinated Universal Time' : '';
2497 }
2498
2499 var momentPrototype__proto = Moment.prototype;
2500
2501 momentPrototype__proto.add = add_subtract__add;
2502 momentPrototype__proto.calendar = moment_calendar__calendar;
2503 momentPrototype__proto.clone = clone;
2504 momentPrototype__proto.diff = diff;
2505 momentPrototype__proto.endOf = endOf;
2506 momentPrototype__proto.format = format;
2507 momentPrototype__proto.from = from;
2508 momentPrototype__proto.fromNow = fromNow;
2509 momentPrototype__proto.to = to;
2510 momentPrototype__proto.toNow = toNow;
2511 momentPrototype__proto.get = getSet;
2512 momentPrototype__proto.invalidAt = invalidAt;
2513 momentPrototype__proto.isAfter = isAfter;
2514 momentPrototype__proto.isBefore = isBefore;
2515 momentPrototype__proto.isBetween = isBetween;
2516 momentPrototype__proto.isSame = isSame;
2517 momentPrototype__proto.isValid = moment_valid__isValid;
2518 momentPrototype__proto.lang = lang;
2519 momentPrototype__proto.locale = locale;
2520 momentPrototype__proto.localeData = localeData;
2521 momentPrototype__proto.max = prototypeMax;
2522 momentPrototype__proto.min = prototypeMin;
2523 momentPrototype__proto.parsingFlags = parsingFlags;
2524 momentPrototype__proto.set = getSet;
2525 momentPrototype__proto.startOf = startOf;
2526 momentPrototype__proto.subtract = add_subtract__subtract;
2527 momentPrototype__proto.toArray = toArray;
2528 momentPrototype__proto.toObject = toObject;
2529 momentPrototype__proto.toDate = toDate;
2530 momentPrototype__proto.toISOString = moment_format__toISOString;
2531 momentPrototype__proto.toJSON = moment_format__toISOString;
2532 momentPrototype__proto.toString = toString;
2533 momentPrototype__proto.unix = unix;
2534 momentPrototype__proto.valueOf = to_type__valueOf;
2535
2536 // Year
2537 momentPrototype__proto.year = getSetYear;
2538 momentPrototype__proto.isLeapYear = getIsLeapYear;
2539
2540 // Week Year
2541 momentPrototype__proto.weekYear = getSetWeekYear;
2542 momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
2543
2544 // Quarter
2545 momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
2546
2547 // Month
2548 momentPrototype__proto.month = getSetMonth;
2549 momentPrototype__proto.daysInMonth = getDaysInMonth;
2550
2551 // Week
2552 momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
2553 momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
2554 momentPrototype__proto.weeksInYear = getWeeksInYear;
2555 momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
2556
2557 // Day
2558 momentPrototype__proto.date = getSetDayOfMonth;
2559 momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
2560 momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
2561 momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
2562 momentPrototype__proto.dayOfYear = getSetDayOfYear;
2563
2564 // Hour
2565 momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
2566
2567 // Minute
2568 momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
2569
2570 // Second
2571 momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
2572
2573 // Millisecond
2574 momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
2575
2576 // Offset
2577 momentPrototype__proto.utcOffset = getSetOffset;
2578 momentPrototype__proto.utc = setOffsetToUTC;
2579 momentPrototype__proto.local = setOffsetToLocal;
2580 momentPrototype__proto.parseZone = setOffsetToParsedOffset;
2581 momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
2582 momentPrototype__proto.isDST = isDaylightSavingTime;
2583 momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
2584 momentPrototype__proto.isLocal = isLocal;
2585 momentPrototype__proto.isUtcOffset = isUtcOffset;
2586 momentPrototype__proto.isUtc = isUtc;
2587 momentPrototype__proto.isUTC = isUtc;
2588
2589 // Timezone
2590 momentPrototype__proto.zoneAbbr = getZoneAbbr;
2591 momentPrototype__proto.zoneName = getZoneName;
2592
2593 // Deprecations
2594 momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
2595 momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
2596 momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
2597 momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
2598
2599 var momentPrototype = momentPrototype__proto;
2600
2601 function moment__createUnix (input) {
2602 return local__createLocal(input * 1000);
2603 }
2604
2605 function moment__createInZone () {
2606 return local__createLocal.apply(null, arguments).parseZone();
2607 }
2608
2609 var defaultCalendar = {
2610 sameDay : '[Today at] LT',
2611 nextDay : '[Tomorrow at] LT',
2612 nextWeek : 'dddd [at] LT',
2613 lastDay : '[Yesterday at] LT',
2614 lastWeek : '[Last] dddd [at] LT',
2615 sameElse : 'L'
2616 };
2617
2618 function locale_calendar__calendar (key, mom, now) {
2619 var output = this._calendar[key];
2620 return typeof output === 'function' ? output.call(mom, now) : output;
2621 }
2622
2623 var defaultLongDateFormat = {
2624 LTS : 'h:mm:ss A',
2625 LT : 'h:mm A',
2626 L : 'MM/DD/YYYY',
2627 LL : 'MMMM D, YYYY',
2628 LLL : 'MMMM D, YYYY h:mm A',
2629 LLLL : 'dddd, MMMM D, YYYY h:mm A'
2630 };
2631
2632 function longDateFormat (key) {
2633 var format = this._longDateFormat[key],
2634 formatUpper = this._longDateFormat[key.toUpperCase()];
2635
2636 if (format || !formatUpper) {
2637 return format;
2638 }
2639
2640 this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
2641 return val.slice(1);
2642 });
2643
2644 return this._longDateFormat[key];
2645 }
2646
2647 var defaultInvalidDate = 'Invalid date';
2648
2649 function invalidDate () {
2650 return this._invalidDate;
2651 }
2652
2653 var defaultOrdinal = '%d';
2654 var defaultOrdinalParse = /\d{1,2}/;
2655
2656 function ordinal (number) {
2657 return this._ordinal.replace('%d', number);
2658 }
2659
2660 function preParsePostFormat (string) {
2661 return string;
2662 }
2663
2664 var defaultRelativeTime = {
2665 future : 'in %s',
2666 past : '%s ago',
2667 s : 'a few seconds',
2668 m : 'a minute',
2669 mm : '%d minutes',
2670 h : 'an hour',
2671 hh : '%d hours',
2672 d : 'a day',
2673 dd : '%d days',
2674 M : 'a month',
2675 MM : '%d months',
2676 y : 'a year',
2677 yy : '%d years'
2678 };
2679
2680 function relative__relativeTime (number, withoutSuffix, string, isFuture) {
2681 var output = this._relativeTime[string];
2682 return (typeof output === 'function') ?
2683 output(number, withoutSuffix, string, isFuture) :
2684 output.replace(/%d/i, number);
2685 }
2686
2687 function pastFuture (diff, output) {
2688 var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
2689 return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
2690 }
2691
2692 function locale_set__set (config) {
2693 var prop, i;
2694 for (i in config) {
2695 prop = config[i];
2696 if (typeof prop === 'function') {
2697 this[i] = prop;
2698 } else {
2699 this['_' + i] = prop;
2700 }
2701 }
2702 // Lenient ordinal parsing accepts just a number in addition to
2703 // number + (possibly) stuff coming from _ordinalParseLenient.
2704 this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
2705 }
2706
2707 var prototype__proto = Locale.prototype;
2708
2709 prototype__proto._calendar = defaultCalendar;
2710 prototype__proto.calendar = locale_calendar__calendar;
2711 prototype__proto._longDateFormat = defaultLongDateFormat;
2712 prototype__proto.longDateFormat = longDateFormat;
2713 prototype__proto._invalidDate = defaultInvalidDate;
2714 prototype__proto.invalidDate = invalidDate;
2715 prototype__proto._ordinal = defaultOrdinal;
2716 prototype__proto.ordinal = ordinal;
2717 prototype__proto._ordinalParse = defaultOrdinalParse;
2718 prototype__proto.preparse = preParsePostFormat;
2719 prototype__proto.postformat = preParsePostFormat;
2720 prototype__proto._relativeTime = defaultRelativeTime;
2721 prototype__proto.relativeTime = relative__relativeTime;
2722 prototype__proto.pastFuture = pastFuture;
2723 prototype__proto.set = locale_set__set;
2724
2725 // Month
2726 prototype__proto.months = localeMonths;
2727 prototype__proto._months = defaultLocaleMonths;
2728 prototype__proto.monthsShort = localeMonthsShort;
2729 prototype__proto._monthsShort = defaultLocaleMonthsShort;
2730 prototype__proto.monthsParse = localeMonthsParse;
2731
2732 // Week
2733 prototype__proto.week = localeWeek;
2734 prototype__proto._week = defaultLocaleWeek;
2735 prototype__proto.firstDayOfYear = localeFirstDayOfYear;
2736 prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
2737
2738 // Day of Week
2739 prototype__proto.weekdays = localeWeekdays;
2740 prototype__proto._weekdays = defaultLocaleWeekdays;
2741 prototype__proto.weekdaysMin = localeWeekdaysMin;
2742 prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
2743 prototype__proto.weekdaysShort = localeWeekdaysShort;
2744 prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
2745 prototype__proto.weekdaysParse = localeWeekdaysParse;
2746
2747 // Hours
2748 prototype__proto.isPM = localeIsPM;
2749 prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
2750 prototype__proto.meridiem = localeMeridiem;
2751
2752 function lists__get (format, index, field, setter) {
2753 var locale = locale_locales__getLocale();
2754 var utc = create_utc__createUTC().set(setter, index);
2755 return locale[field](utc, format);
2756 }
2757
2758 function list (format, index, field, count, setter) {
2759 if (typeof format === 'number') {
2760 index = format;
2761 format = undefined;
2762 }
2763
2764 format = format || '';
2765
2766 if (index != null) {
2767 return lists__get(format, index, field, setter);
2768 }
2769
2770 var i;
2771 var out = [];
2772 for (i = 0; i < count; i++) {
2773 out[i] = lists__get(format, i, field, setter);
2774 }
2775 return out;
2776 }
2777
2778 function lists__listMonths (format, index) {
2779 return list(format, index, 'months', 12, 'month');
2780 }
2781
2782 function lists__listMonthsShort (format, index) {
2783 return list(format, index, 'monthsShort', 12, 'month');
2784 }
2785
2786 function lists__listWeekdays (format, index) {
2787 return list(format, index, 'weekdays', 7, 'day');
2788 }
2789
2790 function lists__listWeekdaysShort (format, index) {
2791 return list(format, index, 'weekdaysShort', 7, 'day');
2792 }
2793
2794 function lists__listWeekdaysMin (format, index) {
2795 return list(format, index, 'weekdaysMin', 7, 'day');
2796 }
2797
2798 locale_locales__getSetGlobalLocale('en', {
2799 ordinalParse: /\d{1,2}(th|st|nd|rd)/,
2800 ordinal : function (number) {
2801 var b = number % 10,
2802 output = (toInt(number % 100 / 10) === 1) ? 'th' :
2803 (b === 1) ? 'st' :
2804 (b === 2) ? 'nd' :
2805 (b === 3) ? 'rd' : 'th';
2806 return number + output;
2807 }
2808 });
2809
2810 // Side effect imports
2811 utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
2812 utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
2813
2814 var mathAbs = Math.abs;
2815
2816 function duration_abs__abs () {
2817 var data = this._data;
2818
2819 this._milliseconds = mathAbs(this._milliseconds);
2820 this._days = mathAbs(this._days);
2821 this._months = mathAbs(this._months);
2822
2823 data.milliseconds = mathAbs(data.milliseconds);
2824 data.seconds = mathAbs(data.seconds);
2825 data.minutes = mathAbs(data.minutes);
2826 data.hours = mathAbs(data.hours);
2827 data.months = mathAbs(data.months);
2828 data.years = mathAbs(data.years);
2829
2830 return this;
2831 }
2832
2833 function duration_add_subtract__addSubtract (duration, input, value, direction) {
2834 var other = create__createDuration(input, value);
2835
2836 duration._milliseconds += direction * other._milliseconds;
2837 duration._days += direction * other._days;
2838 duration._months += direction * other._months;
2839
2840 return duration._bubble();
2841 }
2842
2843 // supports only 2.0-style add(1, 's') or add(duration)
2844 function duration_add_subtract__add (input, value) {
2845 return duration_add_subtract__addSubtract(this, input, value, 1);
2846 }
2847
2848 // supports only 2.0-style subtract(1, 's') or subtract(duration)
2849 function duration_add_subtract__subtract (input, value) {
2850 return duration_add_subtract__addSubtract(this, input, value, -1);
2851 }
2852
2853 function absCeil (number) {
2854 if (number < 0) {
2855 return Math.floor(number);
2856 } else {
2857 return Math.ceil(number);
2858 }
2859 }
2860
2861 function bubble () {
2862 var milliseconds = this._milliseconds;
2863 var days = this._days;
2864 var months = this._months;
2865 var data = this._data;
2866 var seconds, minutes, hours, years, monthsFromDays;
2867
2868 // if we have a mix of positive and negative values, bubble down first
2869 // check: https://github.com/moment/moment/issues/2166
2870 if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
2871 (milliseconds <= 0 && days <= 0 && months <= 0))) {
2872 milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
2873 days = 0;
2874 months = 0;
2875 }
2876
2877 // The following code bubbles up values, see the tests for
2878 // examples of what that means.
2879 data.milliseconds = milliseconds % 1000;
2880
2881 seconds = absFloor(milliseconds / 1000);
2882 data.seconds = seconds % 60;
2883
2884 minutes = absFloor(seconds / 60);
2885 data.minutes = minutes % 60;
2886
2887 hours = absFloor(minutes / 60);
2888 data.hours = hours % 24;
2889
2890 days += absFloor(hours / 24);
2891
2892 // convert days to months
2893 monthsFromDays = absFloor(daysToMonths(days));
2894 months += monthsFromDays;
2895 days -= absCeil(monthsToDays(monthsFromDays));
2896
2897 // 12 months -> 1 year
2898 years = absFloor(months / 12);
2899 months %= 12;
2900
2901 data.days = days;
2902 data.months = months;
2903 data.years = years;
2904
2905 return this;
2906 }
2907
2908 function daysToMonths (days) {
2909 // 400 years have 146097 days (taking into account leap year rules)
2910 // 400 years have 12 months === 4800
2911 return days * 4800 / 146097;
2912 }
2913
2914 function monthsToDays (months) {
2915 // the reverse of daysToMonths
2916 return months * 146097 / 4800;
2917 }
2918
2919 function as (units) {
2920 var days;
2921 var months;
2922 var milliseconds = this._milliseconds;
2923
2924 units = normalizeUnits(units);
2925
2926 if (units === 'month' || units === 'year') {
2927 days = this._days + milliseconds / 864e5;
2928 months = this._months + daysToMonths(days);
2929 return units === 'month' ? months : months / 12;
2930 } else {
2931 // handle milliseconds separately because of floating point math errors (issue #1867)
2932 days = this._days + Math.round(monthsToDays(this._months));
2933 switch (units) {
2934 case 'week' : return days / 7 + milliseconds / 6048e5;
2935 case 'day' : return days + milliseconds / 864e5;
2936 case 'hour' : return days * 24 + milliseconds / 36e5;
2937 case 'minute' : return days * 1440 + milliseconds / 6e4;
2938 case 'second' : return days * 86400 + milliseconds / 1000;
2939 // Math.floor prevents floating point math errors here
2940 case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
2941 default: throw new Error('Unknown unit ' + units);
2942 }
2943 }
2944 }
2945
2946 // TODO: Use this.as('ms')?
2947 function duration_as__valueOf () {
2948 return (
2949 this._milliseconds +
2950 this._days * 864e5 +
2951 (this._months % 12) * 2592e6 +
2952 toInt(this._months / 12) * 31536e6
2953 );
2954 }
2955
2956 function makeAs (alias) {
2957 return function () {
2958 return this.as(alias);
2959 };
2960 }
2961
2962 var asMilliseconds = makeAs('ms');
2963 var asSeconds = makeAs('s');
2964 var asMinutes = makeAs('m');
2965 var asHours = makeAs('h');
2966 var asDays = makeAs('d');
2967 var asWeeks = makeAs('w');
2968 var asMonths = makeAs('M');
2969 var asYears = makeAs('y');
2970
2971 function duration_get__get (units) {
2972 units = normalizeUnits(units);
2973 return this[units + 's']();
2974 }
2975
2976 function makeGetter(name) {
2977 return function () {
2978 return this._data[name];
2979 };
2980 }
2981
2982 var milliseconds = makeGetter('milliseconds');
2983 var seconds = makeGetter('seconds');
2984 var minutes = makeGetter('minutes');
2985 var hours = makeGetter('hours');
2986 var days = makeGetter('days');
2987 var months = makeGetter('months');
2988 var years = makeGetter('years');
2989
2990 function weeks () {
2991 return absFloor(this.days() / 7);
2992 }
2993
2994 var round = Math.round;
2995 var thresholds = {
2996 s: 45, // seconds to minute
2997 m: 45, // minutes to hour
2998 h: 22, // hours to day
2999 d: 26, // days to month
3000 M: 11 // months to year
3001 };
3002
3003 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
3004 function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
3005 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
3006 }
3007
3008 function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
3009 var duration = create__createDuration(posNegDuration).abs();
3010 var seconds = round(duration.as('s'));
3011 var minutes = round(duration.as('m'));
3012 var hours = round(duration.as('h'));
3013 var days = round(duration.as('d'));
3014 var months = round(duration.as('M'));
3015 var years = round(duration.as('y'));
3016
3017 var a = seconds < thresholds.s && ['s', seconds] ||
3018 minutes === 1 && ['m'] ||
3019 minutes < thresholds.m && ['mm', minutes] ||
3020 hours === 1 && ['h'] ||
3021 hours < thresholds.h && ['hh', hours] ||
3022 days === 1 && ['d'] ||
3023 days < thresholds.d && ['dd', days] ||
3024 months === 1 && ['M'] ||
3025 months < thresholds.M && ['MM', months] ||
3026 years === 1 && ['y'] || ['yy', years];
3027
3028 a[2] = withoutSuffix;
3029 a[3] = +posNegDuration > 0;
3030 a[4] = locale;
3031 return substituteTimeAgo.apply(null, a);
3032 }
3033
3034 // This function allows you to set a threshold for relative time strings
3035 function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
3036 if (thresholds[threshold] === undefined) {
3037 return false;
3038 }
3039 if (limit === undefined) {
3040 return thresholds[threshold];
3041 }
3042 thresholds[threshold] = limit;
3043 return true;
3044 }
3045
3046 function humanize (withSuffix) {
3047 var locale = this.localeData();
3048 var output = duration_humanize__relativeTime(this, !withSuffix, locale);
3049
3050 if (withSuffix) {
3051 output = locale.pastFuture(+this, output);
3052 }
3053
3054 return locale.postformat(output);
3055 }
3056
3057 var iso_string__abs = Math.abs;
3058
3059 function iso_string__toISOString() {
3060 // for ISO strings we do not use the normal bubbling rules:
3061 // * milliseconds bubble up until they become hours
3062 // * days do not bubble at all
3063 // * months bubble up until they become years
3064 // This is because there is no context-free conversion between hours and days
3065 // (think of clock changes)
3066 // and also not between days and months (28-31 days per month)
3067 var seconds = iso_string__abs(this._milliseconds) / 1000;
3068 var days = iso_string__abs(this._days);
3069 var months = iso_string__abs(this._months);
3070 var minutes, hours, years;
3071
3072 // 3600 seconds -> 60 minutes -> 1 hour
3073 minutes = absFloor(seconds / 60);
3074 hours = absFloor(minutes / 60);
3075 seconds %= 60;
3076 minutes %= 60;
3077
3078 // 12 months -> 1 year
3079 years = absFloor(months / 12);
3080 months %= 12;
3081
3082
3083 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
3084 var Y = years;
3085 var M = months;
3086 var D = days;
3087 var h = hours;
3088 var m = minutes;
3089 var s = seconds;
3090 var total = this.asSeconds();
3091
3092 if (!total) {
3093 // this is the same as C#'s (Noda) and python (isodate)...
3094 // but not other JS (goog.date)
3095 return 'P0D';
3096 }
3097
3098 return (total < 0 ? '-' : '') +
3099 'P' +
3100 (Y ? Y + 'Y' : '') +
3101 (M ? M + 'M' : '') +
3102 (D ? D + 'D' : '') +
3103 ((h || m || s) ? 'T' : '') +
3104 (h ? h + 'H' : '') +
3105 (m ? m + 'M' : '') +
3106 (s ? s + 'S' : '');
3107 }
3108
3109 var duration_prototype__proto = Duration.prototype;
3110
3111 duration_prototype__proto.abs = duration_abs__abs;
3112 duration_prototype__proto.add = duration_add_subtract__add;
3113 duration_prototype__proto.subtract = duration_add_subtract__subtract;
3114 duration_prototype__proto.as = as;
3115 duration_prototype__proto.asMilliseconds = asMilliseconds;
3116 duration_prototype__proto.asSeconds = asSeconds;
3117 duration_prototype__proto.asMinutes = asMinutes;
3118 duration_prototype__proto.asHours = asHours;
3119 duration_prototype__proto.asDays = asDays;
3120 duration_prototype__proto.asWeeks = asWeeks;
3121 duration_prototype__proto.asMonths = asMonths;
3122 duration_prototype__proto.asYears = asYears;
3123 duration_prototype__proto.valueOf = duration_as__valueOf;
3124 duration_prototype__proto._bubble = bubble;
3125 duration_prototype__proto.get = duration_get__get;
3126 duration_prototype__proto.milliseconds = milliseconds;
3127 duration_prototype__proto.seconds = seconds;
3128 duration_prototype__proto.minutes = minutes;
3129 duration_prototype__proto.hours = hours;
3130 duration_prototype__proto.days = days;
3131 duration_prototype__proto.weeks = weeks;
3132 duration_prototype__proto.months = months;
3133 duration_prototype__proto.years = years;
3134 duration_prototype__proto.humanize = humanize;
3135 duration_prototype__proto.toISOString = iso_string__toISOString;
3136 duration_prototype__proto.toString = iso_string__toISOString;
3137 duration_prototype__proto.toJSON = iso_string__toISOString;
3138 duration_prototype__proto.locale = locale;
3139 duration_prototype__proto.localeData = localeData;
3140
3141 // Deprecations
3142 duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
3143 duration_prototype__proto.lang = lang;
3144
3145 // Side effect imports
3146
3147 addFormatToken('X', 0, 0, 'unix');
3148 addFormatToken('x', 0, 0, 'valueOf');
3149
3150 // PARSING
3151
3152 addRegexToken('x', matchSigned);
3153 addRegexToken('X', matchTimestamp);
3154 addParseToken('X', function (input, array, config) {
3155 config._d = new Date(parseFloat(input, 10) * 1000);
3156 });
3157 addParseToken('x', function (input, array, config) {
3158 config._d = new Date(toInt(input));
3159 });
3160
3161 // Side effect imports
3162
3163
3164 utils_hooks__hooks.version = '2.10.6';
3165
3166 setHookCallback(local__createLocal);
3167
3168 utils_hooks__hooks.fn = momentPrototype;
3169 utils_hooks__hooks.min = min;
3170 utils_hooks__hooks.max = max;
3171 utils_hooks__hooks.utc = create_utc__createUTC;
3172 utils_hooks__hooks.unix = moment__createUnix;
3173 utils_hooks__hooks.months = lists__listMonths;
3174 utils_hooks__hooks.isDate = isDate;
3175 utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
3176 utils_hooks__hooks.invalid = valid__createInvalid;
3177 utils_hooks__hooks.duration = create__createDuration;
3178 utils_hooks__hooks.isMoment = isMoment;
3179 utils_hooks__hooks.weekdays = lists__listWeekdays;
3180 utils_hooks__hooks.parseZone = moment__createInZone;
3181 utils_hooks__hooks.localeData = locale_locales__getLocale;
3182 utils_hooks__hooks.isDuration = isDuration;
3183 utils_hooks__hooks.monthsShort = lists__listMonthsShort;
3184 utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
3185 utils_hooks__hooks.defineLocale = defineLocale;
3186 utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
3187 utils_hooks__hooks.normalizeUnits = normalizeUnits;
3188 utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
3189
3190 var _moment = utils_hooks__hooks;
3191
3192 return _moment;
3193
3194 }));
0 var profile = {
1 resourceTags: {
2 ignore: function(filename, mid){
3 // only include moment/moment
4 return mid != "moment/moment";
5 },
6 amd: function(filename, mid){
7 return /\.js$/.test(filename);
8 }
9 }
10 };
0 {
1 "name": "moment",
2 "version": "2.10.6",
3 "description": "Parse, validate, manipulate, and display dates",
4 "homepage": "http://momentjs.com",
5 "author": "Iskren Ivov Chernev <iskren.chernev@gmail.com> (https://github.com/ichernev)",
6 "contributors": [
7 "Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)",
8 "Rocky Meza (http://rockymeza.com)",
9 "Matt Johnson <mj1856@hotmail.com> (http://codeofmatt.com)",
10 "Isaac Cambron <isaac@isaaccambron.com> (http://isaaccambron.com)",
11 "Andre Polykanine <andre@oire.org> (https://github.com/oire)"
12 ],
13 "keywords": [
14 "moment",
15 "date",
16 "time",
17 "parse",
18 "format",
19 "validate",
20 "i18n",
21 "l10n",
22 "ender"
23 ],
24 "main": "./moment.js",
25 "engines": {
26 "node": "*"
27 },
28 "repository": {
29 "type": "git",
30 "url": "https://github.com/moment/moment.git"
31 },
32 "bugs": {
33 "url": "https://github.com/moment/moment/issues"
34 },
35 "license": "MIT",
36 "devDependencies": {
37 "uglify-js": "latest",
38 "es6-promise": "latest",
39 "grunt": "latest",
40 "benchmark": "latest",
41 "esperanto": "latest",
42 "grunt-contrib-clean": "latest",
43 "grunt-contrib-concat": "latest",
44 "grunt-contrib-copy": "latest",
45 "grunt-contrib-jshint": "latest",
46 "grunt-contrib-uglify": "latest",
47 "grunt-contrib-watch": "latest",
48 "grunt-env": "latest",
49 "grunt-jscs": "latest",
50 "grunt-karma": "latest",
51 "grunt-nuget": "latest",
52 "grunt-benchmark": "latest",
53 "grunt-string-replace": "latest",
54 "grunt-exec": "latest",
55 "load-grunt-tasks": "latest",
56 "karma": "latest",
57 "karma-chrome-launcher": "latest",
58 "karma-firefox-launcher": "latest",
59 "karma-qunit": "latest",
60 "karma-sauce-launcher": "latest",
61 "qunit": "^0.7.5",
62 "qunit-cli": "^0.1.4",
63 "spacejam": "latest",
64 "coveralls": "^2.11.2",
65 "nyc": "^2.1.4"
66 },
67 "ender": "./ender.js",
68 "dojoBuild": "package.js",
69 "jspm": {
70 "files": [
71 "moment.js",
72 "locale"
73 ],
74 "map": {
75 "moment": "./moment"
76 },
77 "buildConfig": {
78 "uglify": true
79 }
80 },
81 "scripts": {
82 "test": "grunt test",
83 "coverage": "nyc npm test && nyc report",
84 "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls"
85 },
86 "spm": {
87 "main": "moment.js",
88 "output": [
89 "locale/*.js"
90 ]
91 }
92 }
0 #!/bin/bash
1
2 set -e
3
4 if [ "$#" != 1 ]; then
5 echo "Please provide tag to checkout" >&2
6 exit 1
7 fi
8 tag="$1"
9
10 while [ "$PWD" != '/' -a ! -f moment.js ]; do
11 cd ..
12 done
13
14 if [ ! -f moment.js ]; then
15 echo "Run me from the moment repo" >&2
16 exit 1
17 fi
18
19 basename=$(basename $PWD)
20 src=moment-npm-git
21 dest=moment-npm
22
23 cd ..
24
25 rm -rf $src $dest
26
27 git clone $basename $src
28 mkdir $dest
29
30
31 cp $src/moment.js $dest
32 cp $src/package.json $dest
33 cp $src/README.md $dest
34 cp $src/LICENSE $dest
35 cp -r $src/locale $dest
36 cp -r $src/min $dest
37 cp $src/ender.js $dest
38 cp $src/package.js $dest
39
40 rm -rf $src
41
42 echo "Check out $dest"
0 import { daysInMonth } from '../units/month';
1 import { YEAR, MONTH, DATE, HOUR, MINUTE, SECOND, MILLISECOND } from '../units/constants';
2 import getParsingFlags from '../create/parsing-flags';
3
4 export default function checkOverflow (m) {
5 var overflow;
6 var a = m._a;
7
8 if (a && getParsingFlags(m).overflow === -2) {
9 overflow =
10 a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
11 a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
12 a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
13 a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
14 a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
15 a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
16 -1;
17
18 if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
19 overflow = DATE;
20 }
21
22 getParsingFlags(m).overflow = overflow;
23 }
24
25 return m;
26 }
27
0 export function createDate (y, m, d, h, M, s, ms) {
1 //can't just apply() to create a date:
2 //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
3 var date = new Date(y, m, d, h, M, s, ms);
4
5 //the date constructor doesn't accept years < 1970
6 if (y < 1970) {
7 date.setFullYear(y);
8 }
9 return date;
10 }
11
12 export function createUTCDate (y) {
13 var date = new Date(Date.UTC.apply(null, arguments));
14 if (y < 1970) {
15 date.setUTCFullYear(y);
16 }
17 return date;
18 }
0 import isArray from '../utils/is-array';
1 import isDate from '../utils/is-date';
2 import map from '../utils/map';
3 import { createInvalid } from './valid';
4 import { Moment, isMoment } from '../moment/constructor';
5 import { getLocale } from '../locale/locales';
6 import { hooks } from '../utils/hooks';
7 import checkOverflow from './check-overflow';
8
9 import { configFromStringAndArray } from './from-string-and-array';
10 import { configFromStringAndFormat } from './from-string-and-format';
11 import { configFromString } from './from-string';
12 import { configFromArray } from './from-array';
13 import { configFromObject } from './from-object';
14
15 function createFromConfig (config) {
16 var res = new Moment(checkOverflow(prepareConfig(config)));
17 if (res._nextDay) {
18 // Adding is smart enough around DST
19 res.add(1, 'd');
20 res._nextDay = undefined;
21 }
22
23 return res;
24 }
25
26 export function prepareConfig (config) {
27 var input = config._i,
28 format = config._f;
29
30 config._locale = config._locale || getLocale(config._l);
31
32 if (input === null || (format === undefined && input === '')) {
33 return createInvalid({nullInput: true});
34 }
35
36 if (typeof input === 'string') {
37 config._i = input = config._locale.preparse(input);
38 }
39
40 if (isMoment(input)) {
41 return new Moment(checkOverflow(input));
42 } else if (isArray(format)) {
43 configFromStringAndArray(config);
44 } else if (format) {
45 configFromStringAndFormat(config);
46 } else if (isDate(input)) {
47 config._d = input;
48 } else {
49 configFromInput(config);
50 }
51
52 return config;
53 }
54
55 function configFromInput(config) {
56 var input = config._i;
57 if (input === undefined) {
58 config._d = new Date();
59 } else if (isDate(input)) {
60 config._d = new Date(+input);
61 } else if (typeof input === 'string') {
62 configFromString(config);
63 } else if (isArray(input)) {
64 config._a = map(input.slice(0), function (obj) {
65 return parseInt(obj, 10);
66 });
67 configFromArray(config);
68 } else if (typeof(input) === 'object') {
69 configFromObject(config);
70 } else if (typeof(input) === 'number') {
71 // from milliseconds
72 config._d = new Date(input);
73 } else {
74 hooks.createFromInputFallback(config);
75 }
76 }
77
78 export function createLocalOrUTC (input, format, locale, strict, isUTC) {
79 var c = {};
80
81 if (typeof(locale) === 'boolean') {
82 strict = locale;
83 locale = undefined;
84 }
85 // object construction must be done this way.
86 // https://github.com/moment/moment/issues/1423
87 c._isAMomentObject = true;
88 c._useUTC = c._isUTC = isUTC;
89 c._l = locale;
90 c._i = input;
91 c._f = format;
92 c._strict = strict;
93
94 return createFromConfig(c);
95 }
0 import { createDate, createUTCDate } from './date-from-array';
1 import { daysInYear } from '../units/year';
2 import { weekOfYear } from '../units/week';
3 import { dayOfYearFromWeeks } from '../units/day-of-year';
4 import { YEAR, MONTH, DATE, HOUR, MINUTE, SECOND, MILLISECOND } from '../units/constants';
5 import { createLocal } from './local';
6 import defaults from '../utils/defaults';
7 import getParsingFlags from './parsing-flags';
8
9 function currentDateArray(config) {
10 var now = new Date();
11 if (config._useUTC) {
12 return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
13 }
14 return [now.getFullYear(), now.getMonth(), now.getDate()];
15 }
16
17 // convert an array to a date.
18 // the array should mirror the parameters below
19 // note: all values past the year are optional and will default to the lowest possible value.
20 // [year, month, day , hour, minute, second, millisecond]
21 export function configFromArray (config) {
22 var i, date, input = [], currentDate, yearToUse;
23
24 if (config._d) {
25 return;
26 }
27
28 currentDate = currentDateArray(config);
29
30 //compute day of the year from weeks and weekdays
31 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
32 dayOfYearFromWeekInfo(config);
33 }
34
35 //if the day of the year is set, figure out what it is
36 if (config._dayOfYear) {
37 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
38
39 if (config._dayOfYear > daysInYear(yearToUse)) {
40 getParsingFlags(config)._overflowDayOfYear = true;
41 }
42
43 date = createUTCDate(yearToUse, 0, config._dayOfYear);
44 config._a[MONTH] = date.getUTCMonth();
45 config._a[DATE] = date.getUTCDate();
46 }
47
48 // Default to current date.
49 // * if no year, month, day of month are given, default to today
50 // * if day of month is given, default month and year
51 // * if month is given, default only year
52 // * if year is given, don't default anything
53 for (i = 0; i < 3 && config._a[i] == null; ++i) {
54 config._a[i] = input[i] = currentDate[i];
55 }
56
57 // Zero out whatever was not defaulted, including time
58 for (; i < 7; i++) {
59 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
60 }
61
62 // Check for 24:00:00.000
63 if (config._a[HOUR] === 24 &&
64 config._a[MINUTE] === 0 &&
65 config._a[SECOND] === 0 &&
66 config._a[MILLISECOND] === 0) {
67 config._nextDay = true;
68 config._a[HOUR] = 0;
69 }
70
71 config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
72 // Apply timezone offset from input. The actual utcOffset can be changed
73 // with parseZone.
74 if (config._tzm != null) {
75 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
76 }
77
78 if (config._nextDay) {
79 config._a[HOUR] = 24;
80 }
81 }
82
83 function dayOfYearFromWeekInfo(config) {
84 var w, weekYear, week, weekday, dow, doy, temp;
85
86 w = config._w;
87 if (w.GG != null || w.W != null || w.E != null) {
88 dow = 1;
89 doy = 4;
90
91 // TODO: We need to take the current isoWeekYear, but that depends on
92 // how we interpret now (local, utc, fixed offset). So create
93 // a now version of current config (take local/utc/offset flags, and
94 // create now).
95 weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
96 week = defaults(w.W, 1);
97 weekday = defaults(w.E, 1);
98 } else {
99 dow = config._locale._week.dow;
100 doy = config._locale._week.doy;
101
102 weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(createLocal(), dow, doy).year);
103 week = defaults(w.w, 1);
104
105 if (w.d != null) {
106 // weekday -- low day numbers are considered next week
107 weekday = w.d;
108 if (weekday < dow) {
109 ++week;
110 }
111 } else if (w.e != null) {
112 // local weekday -- counting starts from begining of week
113 weekday = w.e + dow;
114 } else {
115 // default to begining of week
116 weekday = dow;
117 }
118 }
119 temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
120
121 config._a[YEAR] = temp.year;
122 config._dayOfYear = temp.dayOfYear;
123 }
0 import { normalizeObjectUnits } from '../units/aliases';
1 import { configFromArray } from './from-array';
2
3 export function configFromObject(config) {
4 if (config._d) {
5 return;
6 }
7
8 var i = normalizeObjectUnits(config._i);
9 config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
10
11 configFromArray(config);
12 }
0 import { copyConfig } from '../moment/constructor';
1 import { configFromStringAndFormat } from './from-string-and-format';
2 import getParsingFlags from './parsing-flags';
3 import { isValid } from './valid';
4 import extend from '../utils/extend';
5
6 // date from string and array of format strings
7 export function configFromStringAndArray(config) {
8 var tempConfig,
9 bestMoment,
10
11 scoreToBeat,
12 i,
13 currentScore;
14
15 if (config._f.length === 0) {
16 getParsingFlags(config).invalidFormat = true;
17 config._d = new Date(NaN);
18 return;
19 }
20
21 for (i = 0; i < config._f.length; i++) {
22 currentScore = 0;
23 tempConfig = copyConfig({}, config);
24 if (config._useUTC != null) {
25 tempConfig._useUTC = config._useUTC;
26 }
27 tempConfig._f = config._f[i];
28 configFromStringAndFormat(tempConfig);
29
30 if (!isValid(tempConfig)) {
31 continue;
32 }
33
34 // if there is any input that was not parsed add a penalty for that format
35 currentScore += getParsingFlags(tempConfig).charsLeftOver;
36
37 //or tokens
38 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
39
40 getParsingFlags(tempConfig).score = currentScore;
41
42 if (scoreToBeat == null || currentScore < scoreToBeat) {
43 scoreToBeat = currentScore;
44 bestMoment = tempConfig;
45 }
46 }
47
48 extend(config, bestMoment || tempConfig);
49 }
0 import { configFromISO } from './from-string';
1 import { configFromArray } from './from-array';
2 import { getParseRegexForToken } from '../parse/regex';
3 import { addTimeToArrayFromToken } from '../parse/token';
4 import { expandFormat, formatTokenFunctions, formattingTokens } from '../format/format';
5 import checkOverflow from './check-overflow';
6 import { HOUR } from '../units/constants';
7 import { hooks } from '../utils/hooks';
8 import getParsingFlags from './parsing-flags';
9
10 // constant that refers to the ISO standard
11 hooks.ISO_8601 = function () {};
12
13 // date from string and format string
14 export function configFromStringAndFormat(config) {
15 // TODO: Move this to another part of the creation flow to prevent circular deps
16 if (config._f === hooks.ISO_8601) {
17 configFromISO(config);
18 return;
19 }
20
21 config._a = [];
22 getParsingFlags(config).empty = true;
23
24 // This array is used to make a Date, either with `new Date` or `Date.UTC`
25 var string = '' + config._i,
26 i, parsedInput, tokens, token, skipped,
27 stringLength = string.length,
28 totalParsedInputLength = 0;
29
30 tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
31
32 for (i = 0; i < tokens.length; i++) {
33 token = tokens[i];
34 parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
35 if (parsedInput) {
36 skipped = string.substr(0, string.indexOf(parsedInput));
37 if (skipped.length > 0) {
38 getParsingFlags(config).unusedInput.push(skipped);
39 }
40 string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
41 totalParsedInputLength += parsedInput.length;
42 }
43 // don't parse if it's not a known token
44 if (formatTokenFunctions[token]) {
45 if (parsedInput) {
46 getParsingFlags(config).empty = false;
47 }
48 else {
49 getParsingFlags(config).unusedTokens.push(token);
50 }
51 addTimeToArrayFromToken(token, parsedInput, config);
52 }
53 else if (config._strict && !parsedInput) {
54 getParsingFlags(config).unusedTokens.push(token);
55 }
56 }
57
58 // add remaining unparsed input length to the string
59 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
60 if (string.length > 0) {
61 getParsingFlags(config).unusedInput.push(string);
62 }
63
64 // clear _12h flag if hour is <= 12
65 if (getParsingFlags(config).bigHour === true &&
66 config._a[HOUR] <= 12 &&
67 config._a[HOUR] > 0) {
68 getParsingFlags(config).bigHour = undefined;
69 }
70 // handle meridiem
71 config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
72
73 configFromArray(config);
74 checkOverflow(config);
75 }
76
77
78 function meridiemFixWrap (locale, hour, meridiem) {
79 var isPm;
80
81 if (meridiem == null) {
82 // nothing to do
83 return hour;
84 }
85 if (locale.meridiemHour != null) {
86 return locale.meridiemHour(hour, meridiem);
87 } else if (locale.isPM != null) {
88 // Fallback
89 isPm = locale.isPM(meridiem);
90 if (isPm && hour < 12) {
91 hour += 12;
92 }
93 if (!isPm && hour === 12) {
94 hour = 0;
95 }
96 return hour;
97 } else {
98 // this is not supposed to happen
99 return hour;
100 }
101 }
0 import { matchOffset } from '../parse/regex';
1 import { configFromStringAndFormat } from './from-string-and-format';
2 import { hooks } from '../utils/hooks';
3 import { deprecate } from '../utils/deprecate';
4 import getParsingFlags from './parsing-flags';
5
6 // iso 8601 regex
7 // 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)
8 var isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
9
10 var isoDates = [
11 ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
12 ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
13 ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
14 ['GGGG-[W]WW', /\d{4}-W\d{2}/],
15 ['YYYY-DDD', /\d{4}-\d{3}/]
16 ];
17
18 // iso time formats and regexes
19 var isoTimes = [
20 ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
21 ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
22 ['HH:mm', /(T| )\d\d:\d\d/],
23 ['HH', /(T| )\d\d/]
24 ];
25
26 var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
27
28 // date from iso format
29 export function configFromISO(config) {
30 var i, l,
31 string = config._i,
32 match = isoRegex.exec(string);
33
34 if (match) {
35 getParsingFlags(config).iso = true;
36 for (i = 0, l = isoDates.length; i < l; i++) {
37 if (isoDates[i][1].exec(string)) {
38 config._f = isoDates[i][0];
39 break;
40 }
41 }
42 for (i = 0, l = isoTimes.length; i < l; i++) {
43 if (isoTimes[i][1].exec(string)) {
44 // match[6] should be 'T' or space
45 config._f += (match[6] || ' ') + isoTimes[i][0];
46 break;
47 }
48 }
49 if (string.match(matchOffset)) {
50 config._f += 'Z';
51 }
52 configFromStringAndFormat(config);
53 } else {
54 config._isValid = false;
55 }
56 }
57
58 // date from iso format or fallback
59 export function configFromString(config) {
60 var matched = aspNetJsonRegex.exec(config._i);
61
62 if (matched !== null) {
63 config._d = new Date(+matched[1]);
64 return;
65 }
66
67 configFromISO(config);
68 if (config._isValid === false) {
69 delete config._isValid;
70 hooks.createFromInputFallback(config);
71 }
72 }
73
74 hooks.createFromInputFallback = deprecate(
75 'moment construction falls back to js Date. This is ' +
76 'discouraged and will be removed in upcoming major ' +
77 'release. Please refer to ' +
78 'https://github.com/moment/moment/issues/1407 for more info.',
79 function (config) {
80 config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
81 }
82 );
0 import { createLocalOrUTC } from './from-anything';
1
2 export function createLocal (input, format, locale, strict) {
3 return createLocalOrUTC(input, format, locale, strict, false);
4 }
0 function defaultParsingFlags() {
1 // We need to deep clone this object.
2 return {
3 empty : false,
4 unusedTokens : [],
5 unusedInput : [],
6 overflow : -2,
7 charsLeftOver : 0,
8 nullInput : false,
9 invalidMonth : null,
10 invalidFormat : false,
11 userInvalidated : false,
12 iso : false
13 };
14 }
15
16 export default function getParsingFlags(m) {
17 if (m._pf == null) {
18 m._pf = defaultParsingFlags();
19 }
20 return m._pf;
21 }
0 import { createLocalOrUTC } from './from-anything';
1
2 export function createUTC (input, format, locale, strict) {
3 return createLocalOrUTC(input, format, locale, strict, true).utc();
4 }
0 import extend from '../utils/extend';
1 import { createUTC } from './utc';
2 import getParsingFlags from '../create/parsing-flags';
3
4 export function isValid(m) {
5 if (m._isValid == null) {
6 var flags = getParsingFlags(m);
7 m._isValid = !isNaN(m._d.getTime()) &&
8 flags.overflow < 0 &&
9 !flags.empty &&
10 !flags.invalidMonth &&
11 !flags.invalidWeekday &&
12 !flags.nullInput &&
13 !flags.invalidFormat &&
14 !flags.userInvalidated;
15
16 if (m._strict) {
17 m._isValid = m._isValid &&
18 flags.charsLeftOver === 0 &&
19 flags.unusedTokens.length === 0 &&
20 flags.bigHour === undefined;
21 }
22 }
23 return m._isValid;
24 }
25
26 export function createInvalid (flags) {
27 var m = createUTC(NaN);
28 if (flags != null) {
29 extend(getParsingFlags(m), flags);
30 }
31 else {
32 getParsingFlags(m).userInvalidated = true;
33 }
34
35 return m;
36 }
0 var mathAbs = Math.abs;
1
2 export function abs () {
3 var data = this._data;
4
5 this._milliseconds = mathAbs(this._milliseconds);
6 this._days = mathAbs(this._days);
7 this._months = mathAbs(this._months);
8
9 data.milliseconds = mathAbs(data.milliseconds);
10 data.seconds = mathAbs(data.seconds);
11 data.minutes = mathAbs(data.minutes);
12 data.hours = mathAbs(data.hours);
13 data.months = mathAbs(data.months);
14 data.years = mathAbs(data.years);
15
16 return this;
17 }
0 import { createDuration } from './create';
1
2 function addSubtract (duration, input, value, direction) {
3 var other = createDuration(input, value);
4
5 duration._milliseconds += direction * other._milliseconds;
6 duration._days += direction * other._days;
7 duration._months += direction * other._months;
8
9 return duration._bubble();
10 }
11
12 // supports only 2.0-style add(1, 's') or add(duration)
13 export function add (input, value) {
14 return addSubtract(this, input, value, 1);
15 }
16
17 // supports only 2.0-style subtract(1, 's') or subtract(duration)
18 export function subtract (input, value) {
19 return addSubtract(this, input, value, -1);
20 }
0 import { daysToMonths, monthsToDays } from './bubble';
1 import { normalizeUnits } from '../units/aliases';
2 import toInt from '../utils/to-int';
3
4 export function as (units) {
5 var days;
6 var months;
7 var milliseconds = this._milliseconds;
8
9 units = normalizeUnits(units);
10
11 if (units === 'month' || units === 'year') {
12 days = this._days + milliseconds / 864e5;
13 months = this._months + daysToMonths(days);
14 return units === 'month' ? months : months / 12;
15 } else {
16 // handle milliseconds separately because of floating point math errors (issue #1867)
17 days = this._days + Math.round(monthsToDays(this._months));
18 switch (units) {
19 case 'week' : return days / 7 + milliseconds / 6048e5;
20 case 'day' : return days + milliseconds / 864e5;
21 case 'hour' : return days * 24 + milliseconds / 36e5;
22 case 'minute' : return days * 1440 + milliseconds / 6e4;
23 case 'second' : return days * 86400 + milliseconds / 1000;
24 // Math.floor prevents floating point math errors here
25 case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
26 default: throw new Error('Unknown unit ' + units);
27 }
28 }
29 }
30
31 // TODO: Use this.as('ms')?
32 export function valueOf () {
33 return (
34 this._milliseconds +
35 this._days * 864e5 +
36 (this._months % 12) * 2592e6 +
37 toInt(this._months / 12) * 31536e6
38 );
39 }
40
41 function makeAs (alias) {
42 return function () {
43 return this.as(alias);
44 };
45 }
46
47 export var asMilliseconds = makeAs('ms');
48 export var asSeconds = makeAs('s');
49 export var asMinutes = makeAs('m');
50 export var asHours = makeAs('h');
51 export var asDays = makeAs('d');
52 export var asWeeks = makeAs('w');
53 export var asMonths = makeAs('M');
54 export var asYears = makeAs('y');
0 import absFloor from '../utils/abs-floor';
1 import absCeil from '../utils/abs-ceil';
2 import { createUTCDate } from '../create/date-from-array';
3
4 export function bubble () {
5 var milliseconds = this._milliseconds;
6 var days = this._days;
7 var months = this._months;
8 var data = this._data;
9 var seconds, minutes, hours, years, monthsFromDays;
10
11 // if we have a mix of positive and negative values, bubble down first
12 // check: https://github.com/moment/moment/issues/2166
13 if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
14 (milliseconds <= 0 && days <= 0 && months <= 0))) {
15 milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
16 days = 0;
17 months = 0;
18 }
19
20 // The following code bubbles up values, see the tests for
21 // examples of what that means.
22 data.milliseconds = milliseconds % 1000;
23
24 seconds = absFloor(milliseconds / 1000);
25 data.seconds = seconds % 60;
26
27 minutes = absFloor(seconds / 60);
28 data.minutes = minutes % 60;
29
30 hours = absFloor(minutes / 60);
31 data.hours = hours % 24;
32
33 days += absFloor(hours / 24);
34
35 // convert days to months
36 monthsFromDays = absFloor(daysToMonths(days));
37 months += monthsFromDays;
38 days -= absCeil(monthsToDays(monthsFromDays));
39
40 // 12 months -> 1 year
41 years = absFloor(months / 12);
42 months %= 12;
43
44 data.days = days;
45 data.months = months;
46 data.years = years;
47
48 return this;
49 }
50
51 export function daysToMonths (days) {
52 // 400 years have 146097 days (taking into account leap year rules)
53 // 400 years have 12 months === 4800
54 return days * 4800 / 146097;
55 }
56
57 export function monthsToDays (months) {
58 // the reverse of daysToMonths
59 return months * 146097 / 4800;
60 }
0 import { normalizeObjectUnits } from '../units/aliases';
1 import { getLocale } from '../locale/locales';
2
3 export function Duration (duration) {
4 var normalizedInput = normalizeObjectUnits(duration),
5 years = normalizedInput.year || 0,
6 quarters = normalizedInput.quarter || 0,
7 months = normalizedInput.month || 0,
8 weeks = normalizedInput.week || 0,
9 days = normalizedInput.day || 0,
10 hours = normalizedInput.hour || 0,
11 minutes = normalizedInput.minute || 0,
12 seconds = normalizedInput.second || 0,
13 milliseconds = normalizedInput.millisecond || 0;
14
15 // representation for dateAddRemove
16 this._milliseconds = +milliseconds +
17 seconds * 1e3 + // 1000
18 minutes * 6e4 + // 1000 * 60
19 hours * 36e5; // 1000 * 60 * 60
20 // Because of dateAddRemove treats 24 hours as different from a
21 // day when working around DST, we need to store them separately
22 this._days = +days +
23 weeks * 7;
24 // It is impossible translate months into days without knowing
25 // which months you are are talking about, so we have to store
26 // it separately.
27 this._months = +months +
28 quarters * 3 +
29 years * 12;
30
31 this._data = {};
32
33 this._locale = getLocale();
34
35 this._bubble();
36 }
37
38 export function isDuration (obj) {
39 return obj instanceof Duration;
40 }
0 import { Duration, isDuration } from './constructor';
1 import toInt from '../utils/to-int';
2 import hasOwnProp from '../utils/has-own-prop';
3 import { DATE, HOUR, MINUTE, SECOND, MILLISECOND } from '../units/constants';
4 import { cloneWithOffset } from '../units/offset';
5 import { createLocal } from '../create/local';
6
7 // ASP.NET json date format regex
8 var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
9
10 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
11 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
12 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)$/;
13
14 export function createDuration (input, key) {
15 var duration = input,
16 // matching against regexp is expensive, do it on demand
17 match = null,
18 sign,
19 ret,
20 diffRes;
21
22 if (isDuration(input)) {
23 duration = {
24 ms : input._milliseconds,
25 d : input._days,
26 M : input._months
27 };
28 } else if (typeof input === 'number') {
29 duration = {};
30 if (key) {
31 duration[key] = input;
32 } else {
33 duration.milliseconds = input;
34 }
35 } else if (!!(match = aspNetRegex.exec(input))) {
36 sign = (match[1] === '-') ? -1 : 1;
37 duration = {
38 y : 0,
39 d : toInt(match[DATE]) * sign,
40 h : toInt(match[HOUR]) * sign,
41 m : toInt(match[MINUTE]) * sign,
42 s : toInt(match[SECOND]) * sign,
43 ms : toInt(match[MILLISECOND]) * sign
44 };
45 } else if (!!(match = isoRegex.exec(input))) {
46 sign = (match[1] === '-') ? -1 : 1;
47 duration = {
48 y : parseIso(match[2], sign),
49 M : parseIso(match[3], sign),
50 d : parseIso(match[4], sign),
51 h : parseIso(match[5], sign),
52 m : parseIso(match[6], sign),
53 s : parseIso(match[7], sign),
54 w : parseIso(match[8], sign)
55 };
56 } else if (duration == null) {// checks for null or undefined
57 duration = {};
58 } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
59 diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
60
61 duration = {};
62 duration.ms = diffRes.milliseconds;
63 duration.M = diffRes.months;
64 }
65
66 ret = new Duration(duration);
67
68 if (isDuration(input) && hasOwnProp(input, '_locale')) {
69 ret._locale = input._locale;
70 }
71
72 return ret;
73 }
74
75 createDuration.fn = Duration.prototype;
76
77 function parseIso (inp, sign) {
78 // We'd normally use ~~inp for this, but unfortunately it also
79 // converts floats to ints.
80 // inp may be undefined, so careful calling replace on it.
81 var res = inp && parseFloat(inp.replace(',', '.'));
82 // apply sign while we're at it
83 return (isNaN(res) ? 0 : res) * sign;
84 }
85
86 function positiveMomentsDifference(base, other) {
87 var res = {milliseconds: 0, months: 0};
88
89 res.months = other.month() - base.month() +
90 (other.year() - base.year()) * 12;
91 if (base.clone().add(res.months, 'M').isAfter(other)) {
92 --res.months;
93 }
94
95 res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
96
97 return res;
98 }
99
100 function momentsDifference(base, other) {
101 var res;
102 other = cloneWithOffset(other, base);
103 if (base.isBefore(other)) {
104 res = positiveMomentsDifference(base, other);
105 } else {
106 res = positiveMomentsDifference(other, base);
107 res.milliseconds = -res.milliseconds;
108 res.months = -res.months;
109 }
110
111 return res;
112 }
0 // Side effect imports
1 import './prototype';
2
3 import { createDuration } from './create';
4 import { isDuration } from './constructor';
5 import { getSetRelativeTimeThreshold } from './humanize';
6
7 export {
8 createDuration,
9 isDuration,
10 getSetRelativeTimeThreshold
11 };
0 import { normalizeUnits } from '../units/aliases';
1 import absFloor from '../utils/abs-floor';
2
3 export function get (units) {
4 units = normalizeUnits(units);
5 return this[units + 's']();
6 }
7
8 function makeGetter(name) {
9 return function () {
10 return this._data[name];
11 };
12 }
13
14 export var milliseconds = makeGetter('milliseconds');
15 export var seconds = makeGetter('seconds');
16 export var minutes = makeGetter('minutes');
17 export var hours = makeGetter('hours');
18 export var days = makeGetter('days');
19 export var months = makeGetter('months');
20 export var years = makeGetter('years');
21
22 export function weeks () {
23 return absFloor(this.days() / 7);
24 }
0 import { createDuration } from './create';
1
2 var round = Math.round;
3 var thresholds = {
4 s: 45, // seconds to minute
5 m: 45, // minutes to hour
6 h: 22, // hours to day
7 d: 26, // days to month
8 M: 11 // months to year
9 };
10
11 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
12 function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
13 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
14 }
15
16 function relativeTime (posNegDuration, withoutSuffix, locale) {
17 var duration = createDuration(posNegDuration).abs();
18 var seconds = round(duration.as('s'));
19 var minutes = round(duration.as('m'));
20 var hours = round(duration.as('h'));
21 var days = round(duration.as('d'));
22 var months = round(duration.as('M'));
23 var years = round(duration.as('y'));
24
25 var a = seconds < thresholds.s && ['s', seconds] ||
26 minutes === 1 && ['m'] ||
27 minutes < thresholds.m && ['mm', minutes] ||
28 hours === 1 && ['h'] ||
29 hours < thresholds.h && ['hh', hours] ||
30 days === 1 && ['d'] ||
31 days < thresholds.d && ['dd', days] ||
32 months === 1 && ['M'] ||
33 months < thresholds.M && ['MM', months] ||
34 years === 1 && ['y'] || ['yy', years];
35
36 a[2] = withoutSuffix;
37 a[3] = +posNegDuration > 0;
38 a[4] = locale;
39 return substituteTimeAgo.apply(null, a);
40 }
41
42 // This function allows you to set a threshold for relative time strings
43 export function getSetRelativeTimeThreshold (threshold, limit) {
44 if (thresholds[threshold] === undefined) {
45 return false;
46 }
47 if (limit === undefined) {
48 return thresholds[threshold];
49 }
50 thresholds[threshold] = limit;
51 return true;
52 }
53
54 export function humanize (withSuffix) {
55 var locale = this.localeData();
56 var output = relativeTime(this, !withSuffix, locale);
57
58 if (withSuffix) {
59 output = locale.pastFuture(+this, output);
60 }
61
62 return locale.postformat(output);
63 }
0 import absFloor from '../utils/abs-floor';
1 var abs = Math.abs;
2
3 export function toISOString() {
4 // for ISO strings we do not use the normal bubbling rules:
5 // * milliseconds bubble up until they become hours
6 // * days do not bubble at all
7 // * months bubble up until they become years
8 // This is because there is no context-free conversion between hours and days
9 // (think of clock changes)
10 // and also not between days and months (28-31 days per month)
11 var seconds = abs(this._milliseconds) / 1000;
12 var days = abs(this._days);
13 var months = abs(this._months);
14 var minutes, hours, years;
15
16 // 3600 seconds -> 60 minutes -> 1 hour
17 minutes = absFloor(seconds / 60);
18 hours = absFloor(minutes / 60);
19 seconds %= 60;
20 minutes %= 60;
21
22 // 12 months -> 1 year
23 years = absFloor(months / 12);
24 months %= 12;
25
26
27 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
28 var Y = years;
29 var M = months;
30 var D = days;
31 var h = hours;
32 var m = minutes;
33 var s = seconds;
34 var total = this.asSeconds();
35
36 if (!total) {
37 // this is the same as C#'s (Noda) and python (isodate)...
38 // but not other JS (goog.date)
39 return 'P0D';
40 }
41
42 return (total < 0 ? '-' : '') +
43 'P' +
44 (Y ? Y + 'Y' : '') +
45 (M ? M + 'M' : '') +
46 (D ? D + 'D' : '') +
47 ((h || m || s) ? 'T' : '') +
48 (h ? h + 'H' : '') +
49 (m ? m + 'M' : '') +
50 (s ? s + 'S' : '');
51 }
0 import { Duration } from './constructor';
1
2 var proto = Duration.prototype;
3
4 import { abs } from './abs';
5 import { add, subtract } from './add-subtract';
6 import { as, asMilliseconds, asSeconds, asMinutes, asHours, asDays, asWeeks, asMonths, asYears, valueOf } from './as';
7 import { bubble } from './bubble';
8 import { get, milliseconds, seconds, minutes, hours, days, months, years, weeks } from './get';
9 import { humanize } from './humanize';
10 import { toISOString } from './iso-string';
11 import { lang, locale, localeData } from '../moment/locale';
12
13 proto.abs = abs;
14 proto.add = add;
15 proto.subtract = subtract;
16 proto.as = as;
17 proto.asMilliseconds = asMilliseconds;
18 proto.asSeconds = asSeconds;
19 proto.asMinutes = asMinutes;
20 proto.asHours = asHours;
21 proto.asDays = asDays;
22 proto.asWeeks = asWeeks;
23 proto.asMonths = asMonths;
24 proto.asYears = asYears;
25 proto.valueOf = valueOf;
26 proto._bubble = bubble;
27 proto.get = get;
28 proto.milliseconds = milliseconds;
29 proto.seconds = seconds;
30 proto.minutes = minutes;
31 proto.hours = hours;
32 proto.days = days;
33 proto.weeks = weeks;
34 proto.months = months;
35 proto.years = years;
36 proto.humanize = humanize;
37 proto.toISOString = toISOString;
38 proto.toString = toISOString;
39 proto.toJSON = toISOString;
40 proto.locale = locale;
41 proto.localeData = localeData;
42
43 // Deprecations
44 import { deprecate } from '../utils/deprecate';
45
46 proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString);
47 proto.lang = lang;
0 import zeroFill from '../utils/zero-fill';
1
2 export var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
3
4 var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
5
6 var formatFunctions = {};
7
8 export var formatTokenFunctions = {};
9
10 // token: 'M'
11 // padded: ['MM', 2]
12 // ordinal: 'Mo'
13 // callback: function () { this.month() + 1 }
14 export function addFormatToken (token, padded, ordinal, callback) {
15 var func = callback;
16 if (typeof callback === 'string') {
17 func = function () {
18 return this[callback]();
19 };
20 }
21 if (token) {
22 formatTokenFunctions[token] = func;
23 }
24 if (padded) {
25 formatTokenFunctions[padded[0]] = function () {
26 return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
27 };
28 }
29 if (ordinal) {
30 formatTokenFunctions[ordinal] = function () {
31 return this.localeData().ordinal(func.apply(this, arguments), token);
32 };
33 }
34 }
35
36 function removeFormattingTokens(input) {
37 if (input.match(/\[[\s\S]/)) {
38 return input.replace(/^\[|\]$/g, '');
39 }
40 return input.replace(/\\/g, '');
41 }
42
43 function makeFormatFunction(format) {
44 var array = format.match(formattingTokens), i, length;
45
46 for (i = 0, length = array.length; i < length; i++) {
47 if (formatTokenFunctions[array[i]]) {
48 array[i] = formatTokenFunctions[array[i]];
49 } else {
50 array[i] = removeFormattingTokens(array[i]);
51 }
52 }
53
54 return function (mom) {
55 var output = '';
56 for (i = 0; i < length; i++) {
57 output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
58 }
59 return output;
60 };
61 }
62
63 // format date using native date object
64 export function formatMoment(m, format) {
65 if (!m.isValid()) {
66 return m.localeData().invalidDate();
67 }
68
69 format = expandFormat(format, m.localeData());
70 formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
71
72 return formatFunctions[format](m);
73 }
74
75 export function expandFormat(format, locale) {
76 var i = 5;
77
78 function replaceLongDateFormatTokens(input) {
79 return locale.longDateFormat(input) || input;
80 }
81
82 localFormattingTokens.lastIndex = 0;
83 while (i >= 0 && localFormattingTokens.test(format)) {
84 format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
85 localFormattingTokens.lastIndex = 0;
86 i -= 1;
87 }
88
89 return format;
90 }
91
0 export var defaultCalendar = {
1 sameDay : '[Today at] LT',
2 nextDay : '[Tomorrow at] LT',
3 nextWeek : 'dddd [at] LT',
4 lastDay : '[Yesterday at] LT',
5 lastWeek : '[Last] dddd [at] LT',
6 sameElse : 'L'
7 };
8
9 export function calendar (key, mom, now) {
10 var output = this._calendar[key];
11 return typeof output === 'function' ? output.call(mom, now) : output;
12 }
0 export function Locale() {
1 }
0 import './prototype';
1 import { getSetGlobalLocale } from './locales';
2 import toInt from '../utils/to-int';
3
4 getSetGlobalLocale('en', {
5 ordinalParse: /\d{1,2}(th|st|nd|rd)/,
6 ordinal : function (number) {
7 var b = number % 10,
8 output = (toInt(number % 100 / 10) === 1) ? 'th' :
9 (b === 1) ? 'st' :
10 (b === 2) ? 'nd' :
11 (b === 3) ? 'rd' : 'th';
12 return number + output;
13 }
14 });
0 export var defaultLongDateFormat = {
1 LTS : 'h:mm:ss A',
2 LT : 'h:mm A',
3 L : 'MM/DD/YYYY',
4 LL : 'MMMM D, YYYY',
5 LLL : 'MMMM D, YYYY h:mm A',
6 LLLL : 'dddd, MMMM D, YYYY h:mm A'
7 };
8
9 export function longDateFormat (key) {
10 var format = this._longDateFormat[key],
11 formatUpper = this._longDateFormat[key.toUpperCase()];
12
13 if (format || !formatUpper) {
14 return format;
15 }
16
17 this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
18 return val.slice(1);
19 });
20
21 return this._longDateFormat[key];
22 }
0 export var defaultInvalidDate = 'Invalid date';
1
2 export function invalidDate () {
3 return this._invalidDate;
4 }
0 import { getLocale } from './locales';
1 import { createUTC } from '../create/utc';
2
3 function get (format, index, field, setter) {
4 var locale = getLocale();
5 var utc = createUTC().set(setter, index);
6 return locale[field](utc, format);
7 }
8
9 function list (format, index, field, count, setter) {
10 if (typeof format === 'number') {
11 index = format;
12 format = undefined;
13 }
14
15 format = format || '';
16
17 if (index != null) {
18 return get(format, index, field, setter);
19 }
20
21 var i;
22 var out = [];
23 for (i = 0; i < count; i++) {
24 out[i] = get(format, i, field, setter);
25 }
26 return out;
27 }
28
29 export function listMonths (format, index) {
30 return list(format, index, 'months', 12, 'month');
31 }
32
33 export function listMonthsShort (format, index) {
34 return list(format, index, 'monthsShort', 12, 'month');
35 }
36
37 export function listWeekdays (format, index) {
38 return list(format, index, 'weekdays', 7, 'day');
39 }
40
41 export function listWeekdaysShort (format, index) {
42 return list(format, index, 'weekdaysShort', 7, 'day');
43 }
44
45 export function listWeekdaysMin (format, index) {
46 return list(format, index, 'weekdaysMin', 7, 'day');
47 }
0 // Side effect imports
1 import './prototype';
2
3 import {
4 getSetGlobalLocale,
5 defineLocale,
6 getLocale
7 } from './locales';
8
9 import {
10 listMonths,
11 listMonthsShort,
12 listWeekdays,
13 listWeekdaysShort,
14 listWeekdaysMin
15 } from './lists';
16
17 export {
18 getSetGlobalLocale,
19 defineLocale,
20 getLocale,
21 listMonths,
22 listMonthsShort,
23 listWeekdays,
24 listWeekdaysShort,
25 listWeekdaysMin
26 };
27
28 import { deprecate } from '../utils/deprecate';
29 import { hooks } from '../utils/hooks';
30
31 hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
32 hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
33
34 import './en';
0 import isArray from '../utils/is-array';
1 import compareArrays from '../utils/compare-arrays';
2 import { Locale } from './constructor';
3
4 // internal storage for locale config files
5 var locales = {};
6 var globalLocale;
7
8 function normalizeLocale(key) {
9 return key ? key.toLowerCase().replace('_', '-') : key;
10 }
11
12 // pick the locale from the array
13 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
14 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
15 function chooseLocale(names) {
16 var i = 0, j, next, locale, split;
17
18 while (i < names.length) {
19 split = normalizeLocale(names[i]).split('-');
20 j = split.length;
21 next = normalizeLocale(names[i + 1]);
22 next = next ? next.split('-') : null;
23 while (j > 0) {
24 locale = loadLocale(split.slice(0, j).join('-'));
25 if (locale) {
26 return locale;
27 }
28 if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
29 //the next array item is better than a shallower substring of this one
30 break;
31 }
32 j--;
33 }
34 i++;
35 }
36 return null;
37 }
38
39 function loadLocale(name) {
40 var oldLocale = null;
41 // TODO: Find a better way to register and load all the locales in Node
42 if (!locales[name] && typeof module !== 'undefined' &&
43 module && module.exports) {
44 try {
45 oldLocale = globalLocale._abbr;
46 require('./locale/' + name);
47 // because defineLocale currently also sets the global locale, we
48 // want to undo that for lazy loaded locales
49 getSetGlobalLocale(oldLocale);
50 } catch (e) { }
51 }
52 return locales[name];
53 }
54
55 // This function will load locale and then set the global locale. If
56 // no arguments are passed in, it will simply return the current global
57 // locale key.
58 export function getSetGlobalLocale (key, values) {
59 var data;
60 if (key) {
61 if (typeof values === 'undefined') {
62 data = getLocale(key);
63 }
64 else {
65 data = defineLocale(key, values);
66 }
67
68 if (data) {
69 // moment.duration._locale = moment._locale = data;
70 globalLocale = data;
71 }
72 }
73
74 return globalLocale._abbr;
75 }
76
77 export function defineLocale (name, values) {
78 if (values !== null) {
79 values.abbr = name;
80 locales[name] = locales[name] || new Locale();
81 locales[name].set(values);
82
83 // backwards compat for now: also set the locale
84 getSetGlobalLocale(name);
85
86 return locales[name];
87 } else {
88 // useful for testing
89 delete locales[name];
90 return null;
91 }
92 }
93
94 // returns locale data
95 export function getLocale (key) {
96 var locale;
97
98 if (key && key._locale && key._locale._abbr) {
99 key = key._locale._abbr;
100 }
101
102 if (!key) {
103 return globalLocale;
104 }
105
106 if (!isArray(key)) {
107 //short-circuit everything else
108 locale = loadLocale(key);
109 if (locale) {
110 return locale;
111 }
112 key = [key];
113 }
114
115 return chooseLocale(key);
116 }
0 export var defaultOrdinal = '%d';
1 export var defaultOrdinalParse = /\d{1,2}/;
2
3 export function ordinal (number) {
4 return this._ordinal.replace('%d', number);
5 }
6
0 export function preParsePostFormat (string) {
1 return string;
2 }
0 import { Locale } from './constructor';
1
2 var proto = Locale.prototype;
3
4 import { defaultCalendar, calendar } from './calendar';
5 import { defaultLongDateFormat, longDateFormat } from './formats';
6 import { defaultInvalidDate, invalidDate } from './invalid';
7 import { defaultOrdinal, ordinal, defaultOrdinalParse } from './ordinal';
8 import { preParsePostFormat } from './pre-post-format';
9 import { defaultRelativeTime, relativeTime, pastFuture } from './relative';
10 import { set } from './set';
11
12 proto._calendar = defaultCalendar;
13 proto.calendar = calendar;
14 proto._longDateFormat = defaultLongDateFormat;
15 proto.longDateFormat = longDateFormat;
16 proto._invalidDate = defaultInvalidDate;
17 proto.invalidDate = invalidDate;
18 proto._ordinal = defaultOrdinal;
19 proto.ordinal = ordinal;
20 proto._ordinalParse = defaultOrdinalParse;
21 proto.preparse = preParsePostFormat;
22 proto.postformat = preParsePostFormat;
23 proto._relativeTime = defaultRelativeTime;
24 proto.relativeTime = relativeTime;
25 proto.pastFuture = pastFuture;
26 proto.set = set;
27
28 // Month
29 import {
30 localeMonthsParse,
31 defaultLocaleMonths, localeMonths,
32 defaultLocaleMonthsShort, localeMonthsShort
33 } from '../units/month';
34
35 proto.months = localeMonths;
36 proto._months = defaultLocaleMonths;
37 proto.monthsShort = localeMonthsShort;
38 proto._monthsShort = defaultLocaleMonthsShort;
39 proto.monthsParse = localeMonthsParse;
40
41 // Week
42 import { localeWeek, defaultLocaleWeek, localeFirstDayOfYear, localeFirstDayOfWeek } from '../units/week';
43 proto.week = localeWeek;
44 proto._week = defaultLocaleWeek;
45 proto.firstDayOfYear = localeFirstDayOfYear;
46 proto.firstDayOfWeek = localeFirstDayOfWeek;
47
48 // Day of Week
49 import {
50 localeWeekdaysParse,
51 defaultLocaleWeekdays, localeWeekdays,
52 defaultLocaleWeekdaysMin, localeWeekdaysMin,
53 defaultLocaleWeekdaysShort, localeWeekdaysShort
54 } from '../units/day-of-week';
55
56 proto.weekdays = localeWeekdays;
57 proto._weekdays = defaultLocaleWeekdays;
58 proto.weekdaysMin = localeWeekdaysMin;
59 proto._weekdaysMin = defaultLocaleWeekdaysMin;
60 proto.weekdaysShort = localeWeekdaysShort;
61 proto._weekdaysShort = defaultLocaleWeekdaysShort;
62 proto.weekdaysParse = localeWeekdaysParse;
63
64 // Hours
65 import { localeIsPM, defaultLocaleMeridiemParse, localeMeridiem } from '../units/hour';
66
67 proto.isPM = localeIsPM;
68 proto._meridiemParse = defaultLocaleMeridiemParse;
69 proto.meridiem = localeMeridiem;
0 export var defaultRelativeTime = {
1 future : 'in %s',
2 past : '%s ago',
3 s : 'a few seconds',
4 m : 'a minute',
5 mm : '%d minutes',
6 h : 'an hour',
7 hh : '%d hours',
8 d : 'a day',
9 dd : '%d days',
10 M : 'a month',
11 MM : '%d months',
12 y : 'a year',
13 yy : '%d years'
14 };
15
16 export function relativeTime (number, withoutSuffix, string, isFuture) {
17 var output = this._relativeTime[string];
18 return (typeof output === 'function') ?
19 output(number, withoutSuffix, string, isFuture) :
20 output.replace(/%d/i, number);
21 }
22
23 export function pastFuture (diff, output) {
24 var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
25 return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
26 }
0 export function set (config) {
1 var prop, i;
2 for (i in config) {
3 prop = config[i];
4 if (typeof prop === 'function') {
5 this[i] = prop;
6 } else {
7 this['_' + i] = prop;
8 }
9 }
10 // Lenient ordinal parsing accepts just a number in addition to
11 // number + (possibly) stuff coming from _ordinalParseLenient.
12 this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
13 }
0 import { get, set } from './get-set';
1 import { setMonth } from '../units/month';
2 import { createDuration } from '../duration/create';
3 import { deprecateSimple } from '../utils/deprecate';
4 import { hooks } from '../utils/hooks';
5
6 // TODO: remove 'name' arg after deprecation is removed
7 function createAdder(direction, name) {
8 return function (val, period) {
9 var dur, tmp;
10 //invert the arguments, but complain about it
11 if (period !== null && !isNaN(+period)) {
12 deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
13 tmp = val; val = period; period = tmp;
14 }
15
16 val = typeof val === 'string' ? +val : val;
17 dur = createDuration(val, period);
18 addSubtract(this, dur, direction);
19 return this;
20 };
21 }
22
23 export function addSubtract (mom, duration, isAdding, updateOffset) {
24 var milliseconds = duration._milliseconds,
25 days = duration._days,
26 months = duration._months;
27 updateOffset = updateOffset == null ? true : updateOffset;
28
29 if (milliseconds) {
30 mom._d.setTime(+mom._d + milliseconds * isAdding);
31 }
32 if (days) {
33 set(mom, 'Date', get(mom, 'Date') + days * isAdding);
34 }
35 if (months) {
36 setMonth(mom, get(mom, 'Month') + months * isAdding);
37 }
38 if (updateOffset) {
39 hooks.updateOffset(mom, days || months);
40 }
41 }
42
43 export var add = createAdder(1, 'add');
44 export var subtract = createAdder(-1, 'subtract');
45
0 import { createLocal } from '../create/local';
1 import { cloneWithOffset } from '../units/offset';
2
3 export function calendar (time, formats) {
4 // We want to compare the start of today, vs this.
5 // Getting start-of-today depends on whether we're local/utc/offset or not.
6 var now = time || createLocal(),
7 sod = cloneWithOffset(now, this).startOf('day'),
8 diff = this.diff(sod, 'days', true),
9 format = diff < -6 ? 'sameElse' :
10 diff < -1 ? 'lastWeek' :
11 diff < 0 ? 'lastDay' :
12 diff < 1 ? 'sameDay' :
13 diff < 2 ? 'nextDay' :
14 diff < 7 ? 'nextWeek' : 'sameElse';
15 return this.format(formats && formats[format] || this.localeData().calendar(format, this, createLocal(now)));
16 }
0 import { Moment } from './constructor';
1
2 export function clone () {
3 return new Moment(this);
4 }
0 import { isMoment } from './constructor';
1 import { normalizeUnits } from '../units/aliases';
2 import { createLocal } from '../create/local';
3
4 export function isAfter (input, units) {
5 var inputMs;
6 units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
7 if (units === 'millisecond') {
8 input = isMoment(input) ? input : createLocal(input);
9 return +this > +input;
10 } else {
11 inputMs = isMoment(input) ? +input : +createLocal(input);
12 return inputMs < +this.clone().startOf(units);
13 }
14 }
15
16 export function isBefore (input, units) {
17 var inputMs;
18 units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
19 if (units === 'millisecond') {
20 input = isMoment(input) ? input : createLocal(input);
21 return +this < +input;
22 } else {
23 inputMs = isMoment(input) ? +input : +createLocal(input);
24 return +this.clone().endOf(units) < inputMs;
25 }
26 }
27
28 export function isBetween (from, to, units) {
29 return this.isAfter(from, units) && this.isBefore(to, units);
30 }
31
32 export function isSame (input, units) {
33 var inputMs;
34 units = normalizeUnits(units || 'millisecond');
35 if (units === 'millisecond') {
36 input = isMoment(input) ? input : createLocal(input);
37 return +this === +input;
38 } else {
39 inputMs = +createLocal(input);
40 return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
41 }
42 }
0 import { hooks } from '../utils/hooks';
1 import hasOwnProp from '../utils/has-own-prop';
2 import getParsingFlags from '../create/parsing-flags';
3
4 // Plugins that add properties should also add the key here (null value),
5 // so we can properly clone ourselves.
6 var momentProperties = hooks.momentProperties = [];
7
8 export function copyConfig(to, from) {
9 var i, prop, val;
10
11 if (typeof from._isAMomentObject !== 'undefined') {
12 to._isAMomentObject = from._isAMomentObject;
13 }
14 if (typeof from._i !== 'undefined') {
15 to._i = from._i;
16 }
17 if (typeof from._f !== 'undefined') {
18 to._f = from._f;
19 }
20 if (typeof from._l !== 'undefined') {
21 to._l = from._l;
22 }
23 if (typeof from._strict !== 'undefined') {
24 to._strict = from._strict;
25 }
26 if (typeof from._tzm !== 'undefined') {
27 to._tzm = from._tzm;
28 }
29 if (typeof from._isUTC !== 'undefined') {
30 to._isUTC = from._isUTC;
31 }
32 if (typeof from._offset !== 'undefined') {
33 to._offset = from._offset;
34 }
35 if (typeof from._pf !== 'undefined') {
36 to._pf = getParsingFlags(from);
37 }
38 if (typeof from._locale !== 'undefined') {
39 to._locale = from._locale;
40 }
41
42 if (momentProperties.length > 0) {
43 for (i in momentProperties) {
44 prop = momentProperties[i];
45 val = from[prop];
46 if (typeof val !== 'undefined') {
47 to[prop] = val;
48 }
49 }
50 }
51
52 return to;
53 }
54
55 var updateInProgress = false;
56
57 // Moment prototype object
58 export function Moment(config) {
59 copyConfig(this, config);
60 this._d = new Date(config._d != null ? config._d.getTime() : NaN);
61 // Prevent infinite loop in case updateOffset creates new moment
62 // objects.
63 if (updateInProgress === false) {
64 updateInProgress = true;
65 hooks.updateOffset(this);
66 updateInProgress = false;
67 }
68 }
69
70 export function isMoment (obj) {
71 return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
72 }
0 import absFloor from '../utils/abs-floor';
1 import { cloneWithOffset } from '../units/offset';
2 import { normalizeUnits } from '../units/aliases';
3
4 export function diff (input, units, asFloat) {
5 var that = cloneWithOffset(input, this),
6 zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
7 delta, output;
8
9 units = normalizeUnits(units);
10
11 if (units === 'year' || units === 'month' || units === 'quarter') {
12 output = monthDiff(this, that);
13 if (units === 'quarter') {
14 output = output / 3;
15 } else if (units === 'year') {
16 output = output / 12;
17 }
18 } else {
19 delta = this - that;
20 output = units === 'second' ? delta / 1e3 : // 1000
21 units === 'minute' ? delta / 6e4 : // 1000 * 60
22 units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
23 units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
24 units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
25 delta;
26 }
27 return asFloat ? output : absFloor(output);
28 }
29
30 function monthDiff (a, b) {
31 // difference in months
32 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
33 // b is in (anchor - 1 month, anchor + 1 month)
34 anchor = a.clone().add(wholeMonthDiff, 'months'),
35 anchor2, adjust;
36
37 if (b - anchor < 0) {
38 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
39 // linear across the month
40 adjust = (b - anchor) / (anchor - anchor2);
41 } else {
42 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
43 // linear across the month
44 adjust = (b - anchor) / (anchor2 - anchor);
45 }
46
47 return -(wholeMonthDiff + adjust);
48 }
0 import { formatMoment } from '../format/format';
1 import { hooks } from '../utils/hooks';
2
3 hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
4
5 export function toString () {
6 return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
7 }
8
9 export function toISOString () {
10 var m = this.clone().utc();
11 if (0 < m.year() && m.year() <= 9999) {
12 if ('function' === typeof Date.prototype.toISOString) {
13 // native implementation is ~50x faster, use it when we can
14 return this.toDate().toISOString();
15 } else {
16 return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
17 }
18 } else {
19 return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
20 }
21 }
22
23 export function format (inputString) {
24 var output = formatMoment(this, inputString || hooks.defaultFormat);
25 return this.localeData().postformat(output);
26 }
0 import { createDuration } from '../duration/create';
1 import { createLocal } from '../create/local';
2
3 export function from (time, withoutSuffix) {
4 if (!this.isValid()) {
5 return this.localeData().invalidDate();
6 }
7 return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
8 }
9
10 export function fromNow (withoutSuffix) {
11 return this.from(createLocal(), withoutSuffix);
12 }
0 import { normalizeUnits } from '../units/aliases';
1 import { hooks } from '../utils/hooks';
2
3 export function makeGetSet (unit, keepTime) {
4 return function (value) {
5 if (value != null) {
6 set(this, unit, value);
7 hooks.updateOffset(this, keepTime);
8 return this;
9 } else {
10 return get(this, unit);
11 }
12 };
13 }
14
15 export function get (mom, unit) {
16 return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
17 }
18
19 export function set (mom, unit, value) {
20 return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
21 }
22
23 // MOMENTS
24
25 export function getSet (units, value) {
26 var unit;
27 if (typeof units === 'object') {
28 for (unit in units) {
29 this.set(unit, units[unit]);
30 }
31 } else {
32 units = normalizeUnits(units);
33 if (typeof this[units] === 'function') {
34 return this[units](value);
35 }
36 }
37 return this;
38 }
0 import { getLocale } from '../locale/locales';
1 import { deprecate } from '../utils/deprecate';
2
3 // If passed a locale key, it will set the locale for this
4 // instance. Otherwise, it will return the locale configuration
5 // variables for this instance.
6 export function locale (key) {
7 var newLocaleData;
8
9 if (key === undefined) {
10 return this._locale._abbr;
11 } else {
12 newLocaleData = getLocale(key);
13 if (newLocaleData != null) {
14 this._locale = newLocaleData;
15 }
16 return this;
17 }
18 }
19
20 export var lang = deprecate(
21 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
22 function (key) {
23 if (key === undefined) {
24 return this.localeData();
25 } else {
26 return this.locale(key);
27 }
28 }
29 );
30
31 export function localeData () {
32 return this._locale;
33 }
0 import { deprecate } from '../utils/deprecate';
1 import isArray from '../utils/is-array';
2 import { createLocal } from '../create/local';
3
4 export var prototypeMin = deprecate(
5 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
6 function () {
7 var other = createLocal.apply(null, arguments);
8 return other < this ? this : other;
9 }
10 );
11
12 export var prototypeMax = deprecate(
13 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
14 function () {
15 var other = createLocal.apply(null, arguments);
16 return other > this ? this : other;
17 }
18 );
19
20 // Pick a moment m from moments so that m[fn](other) is true for all
21 // other. This relies on the function fn to be transitive.
22 //
23 // moments should either be an array of moment objects or an array, whose
24 // first element is an array of moment objects.
25 function pickBy(fn, moments) {
26 var res, i;
27 if (moments.length === 1 && isArray(moments[0])) {
28 moments = moments[0];
29 }
30 if (!moments.length) {
31 return createLocal();
32 }
33 res = moments[0];
34 for (i = 1; i < moments.length; ++i) {
35 if (!moments[i].isValid() || moments[i][fn](res)) {
36 res = moments[i];
37 }
38 }
39 return res;
40 }
41
42 // TODO: Use [].sort instead?
43 export function min () {
44 var args = [].slice.call(arguments, 0);
45
46 return pickBy('isBefore', args);
47 }
48
49 export function max () {
50 var args = [].slice.call(arguments, 0);
51
52 return pickBy('isAfter', args);
53 }
0 import { createLocal } from '../create/local';
1 import { createUTC } from '../create/utc';
2 import { createInvalid } from '../create/valid';
3 import { isMoment } from './constructor';
4 import { min, max } from './min-max';
5 import momentPrototype from './prototype';
6
7 function createUnix (input) {
8 return createLocal(input * 1000);
9 }
10
11 function createInZone () {
12 return createLocal.apply(null, arguments).parseZone();
13 }
14
15 export {
16 min,
17 max,
18 isMoment,
19 createUTC,
20 createUnix,
21 createLocal,
22 createInZone,
23 createInvalid,
24 momentPrototype
25 };
0 import { Moment } from './constructor';
1
2 var proto = Moment.prototype;
3
4 import { add, subtract } from './add-subtract';
5 import { calendar } from './calendar';
6 import { clone } from './clone';
7 import { isBefore, isBetween, isSame, isAfter } from './compare';
8 import { diff } from './diff';
9 import { format, toString, toISOString } from './format';
10 import { from, fromNow } from './from';
11 import { to, toNow } from './to';
12 import { getSet } from './get-set';
13 import { locale, localeData, lang } from './locale';
14 import { prototypeMin, prototypeMax } from './min-max';
15 import { startOf, endOf } from './start-end-of';
16 import { valueOf, toDate, toArray, toObject, unix } from './to-type';
17 import { isValid, parsingFlags, invalidAt } from './valid';
18
19 proto.add = add;
20 proto.calendar = calendar;
21 proto.clone = clone;
22 proto.diff = diff;
23 proto.endOf = endOf;
24 proto.format = format;
25 proto.from = from;
26 proto.fromNow = fromNow;
27 proto.to = to;
28 proto.toNow = toNow;
29 proto.get = getSet;
30 proto.invalidAt = invalidAt;
31 proto.isAfter = isAfter;
32 proto.isBefore = isBefore;
33 proto.isBetween = isBetween;
34 proto.isSame = isSame;
35 proto.isValid = isValid;
36 proto.lang = lang;
37 proto.locale = locale;
38 proto.localeData = localeData;
39 proto.max = prototypeMax;
40 proto.min = prototypeMin;
41 proto.parsingFlags = parsingFlags;
42 proto.set = getSet;
43 proto.startOf = startOf;
44 proto.subtract = subtract;
45 proto.toArray = toArray;
46 proto.toObject = toObject;
47 proto.toDate = toDate;
48 proto.toISOString = toISOString;
49 proto.toJSON = toISOString;
50 proto.toString = toString;
51 proto.unix = unix;
52 proto.valueOf = valueOf;
53
54 // Year
55 import { getSetYear, getIsLeapYear } from '../units/year';
56 proto.year = getSetYear;
57 proto.isLeapYear = getIsLeapYear;
58
59 // Week Year
60 import { getSetWeekYear, getSetISOWeekYear, getWeeksInYear, getISOWeeksInYear } from '../units/week-year';
61 proto.weekYear = getSetWeekYear;
62 proto.isoWeekYear = getSetISOWeekYear;
63
64 // Quarter
65 import { getSetQuarter } from '../units/quarter';
66 proto.quarter = proto.quarters = getSetQuarter;
67
68 // Month
69 import { getSetMonth, getDaysInMonth } from '../units/month';
70 proto.month = getSetMonth;
71 proto.daysInMonth = getDaysInMonth;
72
73 // Week
74 import { getSetWeek, getSetISOWeek } from '../units/week';
75 proto.week = proto.weeks = getSetWeek;
76 proto.isoWeek = proto.isoWeeks = getSetISOWeek;
77 proto.weeksInYear = getWeeksInYear;
78 proto.isoWeeksInYear = getISOWeeksInYear;
79
80 // Day
81 import { getSetDayOfMonth } from '../units/day-of-month';
82 import { getSetDayOfWeek, getSetISODayOfWeek, getSetLocaleDayOfWeek } from '../units/day-of-week';
83 import { getSetDayOfYear } from '../units/day-of-year';
84 proto.date = getSetDayOfMonth;
85 proto.day = proto.days = getSetDayOfWeek;
86 proto.weekday = getSetLocaleDayOfWeek;
87 proto.isoWeekday = getSetISODayOfWeek;
88 proto.dayOfYear = getSetDayOfYear;
89
90 // Hour
91 import { getSetHour } from '../units/hour';
92 proto.hour = proto.hours = getSetHour;
93
94 // Minute
95 import { getSetMinute } from '../units/minute';
96 proto.minute = proto.minutes = getSetMinute;
97
98 // Second
99 import { getSetSecond } from '../units/second';
100 proto.second = proto.seconds = getSetSecond;
101
102 // Millisecond
103 import { getSetMillisecond } from '../units/millisecond';
104 proto.millisecond = proto.milliseconds = getSetMillisecond;
105
106 // Offset
107 import {
108 getSetOffset,
109 setOffsetToUTC,
110 setOffsetToLocal,
111 setOffsetToParsedOffset,
112 hasAlignedHourOffset,
113 isDaylightSavingTime,
114 isDaylightSavingTimeShifted,
115 getSetZone,
116 isLocal,
117 isUtcOffset,
118 isUtc
119 } from '../units/offset';
120 proto.utcOffset = getSetOffset;
121 proto.utc = setOffsetToUTC;
122 proto.local = setOffsetToLocal;
123 proto.parseZone = setOffsetToParsedOffset;
124 proto.hasAlignedHourOffset = hasAlignedHourOffset;
125 proto.isDST = isDaylightSavingTime;
126 proto.isDSTShifted = isDaylightSavingTimeShifted;
127 proto.isLocal = isLocal;
128 proto.isUtcOffset = isUtcOffset;
129 proto.isUtc = isUtc;
130 proto.isUTC = isUtc;
131
132 // Timezone
133 import { getZoneAbbr, getZoneName } from '../units/timezone';
134 proto.zoneAbbr = getZoneAbbr;
135 proto.zoneName = getZoneName;
136
137 // Deprecations
138 import { deprecate } from '../utils/deprecate';
139 proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
140 proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
141 proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
142 proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
143
144 export default proto;
0 import { normalizeUnits } from '../units/aliases';
1
2 export function startOf (units) {
3 units = normalizeUnits(units);
4 // the following switch intentionally omits break keywords
5 // to utilize falling through the cases.
6 switch (units) {
7 case 'year':
8 this.month(0);
9 /* falls through */
10 case 'quarter':
11 case 'month':
12 this.date(1);
13 /* falls through */
14 case 'week':
15 case 'isoWeek':
16 case 'day':
17 this.hours(0);
18 /* falls through */
19 case 'hour':
20 this.minutes(0);
21 /* falls through */
22 case 'minute':
23 this.seconds(0);
24 /* falls through */
25 case 'second':
26 this.milliseconds(0);
27 }
28
29 // weeks are a special case
30 if (units === 'week') {
31 this.weekday(0);
32 }
33 if (units === 'isoWeek') {
34 this.isoWeekday(1);
35 }
36
37 // quarters are also special
38 if (units === 'quarter') {
39 this.month(Math.floor(this.month() / 3) * 3);
40 }
41
42 return this;
43 }
44
45 export function endOf (units) {
46 units = normalizeUnits(units);
47 if (units === undefined || units === 'millisecond') {
48 return this;
49 }
50 return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
51 }
0 export function valueOf () {
1 return +this._d - ((this._offset || 0) * 60000);
2 }
3
4 export function unix () {
5 return Math.floor(+this / 1000);
6 }
7
8 export function toDate () {
9 return this._offset ? new Date(+this) : this._d;
10 }
11
12 export function toArray () {
13 var m = this;
14 return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
15 }
16
17 export function toObject () {
18 var m = this;
19 return {
20 years: m.year(),
21 months: m.month(),
22 date: m.date(),
23 hours: m.hours(),
24 minutes: m.minutes(),
25 seconds: m.seconds(),
26 milliseconds: m.milliseconds()
27 };
28 }
0 import { createDuration } from '../duration/create';
1 import { createLocal } from '../create/local';
2
3 export function to (time, withoutSuffix) {
4 if (!this.isValid()) {
5 return this.localeData().invalidDate();
6 }
7 return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
8 }
9
10 export function toNow (withoutSuffix) {
11 return this.to(createLocal(), withoutSuffix);
12 }
0 import { isValid as _isValid } from '../create/valid';
1 import extend from '../utils/extend';
2 import getParsingFlags from '../create/parsing-flags';
3
4 export function isValid () {
5 return _isValid(this);
6 }
7
8 export function parsingFlags () {
9 return extend({}, getParsingFlags(this));
10 }
11
12 export function invalidAt () {
13 return getParsingFlags(this).overflow;
14 }
0 export var match1 = /\d/; // 0 - 9
1 export var match2 = /\d\d/; // 00 - 99
2 export var match3 = /\d{3}/; // 000 - 999
3 export var match4 = /\d{4}/; // 0000 - 9999
4 export var match6 = /[+-]?\d{6}/; // -999999 - 999999
5 export var match1to2 = /\d\d?/; // 0 - 99
6 export var match1to3 = /\d{1,3}/; // 0 - 999
7 export var match1to4 = /\d{1,4}/; // 0 - 9999
8 export var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
9
10 export var matchUnsigned = /\d+/; // 0 - inf
11 export var matchSigned = /[+-]?\d+/; // -inf - inf
12
13 export var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
14
15 export var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
16
17 // any word (or two) characters or numbers including two/three word month in arabic.
18 export var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
19
20 import hasOwnProp from '../utils/has-own-prop';
21
22 var regexes = {};
23
24 function isFunction (sth) {
25 // https://github.com/moment/moment/issues/2325
26 return typeof sth === 'function' &&
27 Object.prototype.toString.call(sth) === '[object Function]';
28 }
29
30
31 export function addRegexToken (token, regex, strictRegex) {
32 regexes[token] = isFunction(regex) ? regex : function (isStrict) {
33 return (isStrict && strictRegex) ? strictRegex : regex;
34 };
35 }
36
37 export function getParseRegexForToken (token, config) {
38 if (!hasOwnProp(regexes, token)) {
39 return new RegExp(unescapeFormat(token));
40 }
41
42 return regexes[token](config._strict, config._locale);
43 }
44
45 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
46 function unescapeFormat(s) {
47 return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
48 return p1 || p2 || p3 || p4;
49 }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
50 }
0 import hasOwnProp from '../utils/has-own-prop';
1 import toInt from '../utils/to-int';
2
3 var tokens = {};
4
5 export function addParseToken (token, callback) {
6 var i, func = callback;
7 if (typeof token === 'string') {
8 token = [token];
9 }
10 if (typeof callback === 'number') {
11 func = function (input, array) {
12 array[callback] = toInt(input);
13 };
14 }
15 for (i = 0; i < token.length; i++) {
16 tokens[token[i]] = func;
17 }
18 }
19
20 export function addWeekParseToken (token, callback) {
21 addParseToken(token, function (input, array, config, token) {
22 config._w = config._w || {};
23 callback(input, config._w, config, token);
24 });
25 }
26
27 export function addTimeToArrayFromToken(token, input, config) {
28 if (input != null && hasOwnProp(tokens, token)) {
29 tokens[token](input, config._a, config, token);
30 }
31 }
0 import hasOwnProp from '../utils/has-own-prop';
1
2 var aliases = {};
3
4 export function addUnitAlias (unit, shorthand) {
5 var lowerCase = unit.toLowerCase();
6 aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
7 }
8
9 export function normalizeUnits(units) {
10 return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
11 }
12
13 export function normalizeObjectUnits(inputObject) {
14 var normalizedInput = {},
15 normalizedProp,
16 prop;
17
18 for (prop in inputObject) {
19 if (hasOwnProp(inputObject, prop)) {
20 normalizedProp = normalizeUnits(prop);
21 if (normalizedProp) {
22 normalizedInput[normalizedProp] = inputObject[prop];
23 }
24 }
25 }
26
27 return normalizedInput;
28 }
0 export var YEAR = 0;
1 export var MONTH = 1;
2 export var DATE = 2;
3 export var HOUR = 3;
4 export var MINUTE = 4;
5 export var SECOND = 5;
6 export var MILLISECOND = 6;
0 import { makeGetSet } from '../moment/get-set';
1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1to2, match2 } from '../parse/regex';
4 import { addParseToken } from '../parse/token';
5 import { DATE } from './constants';
6 import toInt from '../utils/to-int';
7
8 // FORMATTING
9
10 addFormatToken('D', ['DD', 2], 'Do', 'date');
11
12 // ALIASES
13
14 addUnitAlias('date', 'D');
15
16 // PARSING
17
18 addRegexToken('D', match1to2);
19 addRegexToken('DD', match1to2, match2);
20 addRegexToken('Do', function (isStrict, locale) {
21 return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
22 });
23
24 addParseToken(['D', 'DD'], DATE);
25 addParseToken('Do', function (input, array) {
26 array[DATE] = toInt(input.match(match1to2)[0], 10);
27 });
28
29 // MOMENTS
30
31 export var getSetDayOfMonth = makeGetSet('Date', true);
0 import { addFormatToken } from '../format/format';
1 import { addUnitAlias } from './aliases';
2 import { addRegexToken, match1to2, matchWord } from '../parse/regex';
3 import { addWeekParseToken } from '../parse/token';
4 import toInt from '../utils/to-int';
5 import { createLocal } from '../create/local';
6 import getParsingFlags from '../create/parsing-flags';
7
8 // FORMATTING
9
10 addFormatToken('d', 0, 'do', 'day');
11
12 addFormatToken('dd', 0, 0, function (format) {
13 return this.localeData().weekdaysMin(this, format);
14 });
15
16 addFormatToken('ddd', 0, 0, function (format) {
17 return this.localeData().weekdaysShort(this, format);
18 });
19
20 addFormatToken('dddd', 0, 0, function (format) {
21 return this.localeData().weekdays(this, format);
22 });
23
24 addFormatToken('e', 0, 0, 'weekday');
25 addFormatToken('E', 0, 0, 'isoWeekday');
26
27 // ALIASES
28
29 addUnitAlias('day', 'd');
30 addUnitAlias('weekday', 'e');
31 addUnitAlias('isoWeekday', 'E');
32
33 // PARSING
34
35 addRegexToken('d', match1to2);
36 addRegexToken('e', match1to2);
37 addRegexToken('E', match1to2);
38 addRegexToken('dd', matchWord);
39 addRegexToken('ddd', matchWord);
40 addRegexToken('dddd', matchWord);
41
42 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
43 var weekday = config._locale.weekdaysParse(input);
44 // if we didn't get a weekday name, mark the date as invalid
45 if (weekday != null) {
46 week.d = weekday;
47 } else {
48 getParsingFlags(config).invalidWeekday = input;
49 }
50 });
51
52 addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
53 week[token] = toInt(input);
54 });
55
56 // HELPERS
57
58 function parseWeekday(input, locale) {
59 if (typeof input !== 'string') {
60 return input;
61 }
62
63 if (!isNaN(input)) {
64 return parseInt(input, 10);
65 }
66
67 input = locale.weekdaysParse(input);
68 if (typeof input === 'number') {
69 return input;
70 }
71
72 return null;
73 }
74
75 // LOCALES
76
77 export var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
78 export function localeWeekdays (m) {
79 return this._weekdays[m.day()];
80 }
81
82 export var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
83 export function localeWeekdaysShort (m) {
84 return this._weekdaysShort[m.day()];
85 }
86
87 export var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
88 export function localeWeekdaysMin (m) {
89 return this._weekdaysMin[m.day()];
90 }
91
92 export function localeWeekdaysParse (weekdayName) {
93 var i, mom, regex;
94
95 this._weekdaysParse = this._weekdaysParse || [];
96
97 for (i = 0; i < 7; i++) {
98 // make the regex if we don't have it already
99 if (!this._weekdaysParse[i]) {
100 mom = createLocal([2000, 1]).day(i);
101 regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
102 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
103 }
104 // test the regex
105 if (this._weekdaysParse[i].test(weekdayName)) {
106 return i;
107 }
108 }
109 }
110
111 // MOMENTS
112
113 export function getSetDayOfWeek (input) {
114 var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
115 if (input != null) {
116 input = parseWeekday(input, this.localeData());
117 return this.add(input - day, 'd');
118 } else {
119 return day;
120 }
121 }
122
123 export function getSetLocaleDayOfWeek (input) {
124 var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
125 return input == null ? weekday : this.add(input - weekday, 'd');
126 }
127
128 export function getSetISODayOfWeek (input) {
129 // behaves the same as moment#day except
130 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
131 // as a setter, sunday should belong to the previous week.
132 return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
133 }
0 import { addFormatToken } from '../format/format';
1 import { addUnitAlias } from './aliases';
2 import { addRegexToken, match3, match1to3 } from '../parse/regex';
3 import { daysInYear } from './year';
4 import { createUTCDate } from '../create/date-from-array';
5 import { addParseToken } from '../parse/token';
6 import toInt from '../utils/to-int';
7
8 // FORMATTING
9
10 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
11
12 // ALIASES
13
14 addUnitAlias('dayOfYear', 'DDD');
15
16 // PARSING
17
18 addRegexToken('DDD', match1to3);
19 addRegexToken('DDDD', match3);
20 addParseToken(['DDD', 'DDDD'], function (input, array, config) {
21 config._dayOfYear = toInt(input);
22 });
23
24 // HELPERS
25
26 //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
27 export function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
28 var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear;
29 if (d < firstDayOfWeek) {
30 d += 7;
31 }
32
33 weekday = weekday != null ? 1 * weekday : firstDayOfWeek;
34
35 dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday;
36
37 return {
38 year: dayOfYear > 0 ? year : year - 1,
39 dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
40 };
41 }
42
43 // MOMENTS
44
45 export function getSetDayOfYear (input) {
46 var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
47 return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
48 }
0 import { makeGetSet } from '../moment/get-set';
1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1to2, match2 } from '../parse/regex';
4 import { addParseToken } from '../parse/token';
5 import { HOUR } from './constants';
6 import toInt from '../utils/to-int';
7 import getParsingFlags from '../create/parsing-flags';
8
9 // FORMATTING
10
11 addFormatToken('H', ['HH', 2], 0, 'hour');
12 addFormatToken('h', ['hh', 2], 0, function () {
13 return this.hours() % 12 || 12;
14 });
15
16 function meridiem (token, lowercase) {
17 addFormatToken(token, 0, 0, function () {
18 return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
19 });
20 }
21
22 meridiem('a', true);
23 meridiem('A', false);
24
25 // ALIASES
26
27 addUnitAlias('hour', 'h');
28
29 // PARSING
30
31 function matchMeridiem (isStrict, locale) {
32 return locale._meridiemParse;
33 }
34
35 addRegexToken('a', matchMeridiem);
36 addRegexToken('A', matchMeridiem);
37 addRegexToken('H', match1to2);
38 addRegexToken('h', match1to2);
39 addRegexToken('HH', match1to2, match2);
40 addRegexToken('hh', match1to2, match2);
41
42 addParseToken(['H', 'HH'], HOUR);
43 addParseToken(['a', 'A'], function (input, array, config) {
44 config._isPm = config._locale.isPM(input);
45 config._meridiem = input;
46 });
47 addParseToken(['h', 'hh'], function (input, array, config) {
48 array[HOUR] = toInt(input);
49 getParsingFlags(config).bigHour = true;
50 });
51
52 // LOCALES
53
54 export function localeIsPM (input) {
55 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
56 // Using charAt should be more compatible.
57 return ((input + '').toLowerCase().charAt(0) === 'p');
58 }
59
60 export var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
61 export function localeMeridiem (hours, minutes, isLower) {
62 if (hours > 11) {
63 return isLower ? 'pm' : 'PM';
64 } else {
65 return isLower ? 'am' : 'AM';
66 }
67 }
68
69
70 // MOMENTS
71
72 // Setting the hour should keep the time, because the user explicitly
73 // specified which hour he wants. So trying to maintain the same hour (in
74 // a new timezone) makes sense. Adding/subtracting hours does not follow
75 // this rule.
76 export var getSetHour = makeGetSet('Hours', true);
0 import { makeGetSet } from '../moment/get-set';
1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1, match2, match3, match1to3, matchUnsigned } from '../parse/regex';
4 import { addParseToken } from '../parse/token';
5 import { MILLISECOND } from './constants';
6 import toInt from '../utils/to-int';
7
8 // FORMATTING
9
10 addFormatToken('S', 0, 0, function () {
11 return ~~(this.millisecond() / 100);
12 });
13
14 addFormatToken(0, ['SS', 2], 0, function () {
15 return ~~(this.millisecond() / 10);
16 });
17
18 addFormatToken(0, ['SSS', 3], 0, 'millisecond');
19 addFormatToken(0, ['SSSS', 4], 0, function () {
20 return this.millisecond() * 10;
21 });
22 addFormatToken(0, ['SSSSS', 5], 0, function () {
23 return this.millisecond() * 100;
24 });
25 addFormatToken(0, ['SSSSSS', 6], 0, function () {
26 return this.millisecond() * 1000;
27 });
28 addFormatToken(0, ['SSSSSSS', 7], 0, function () {
29 return this.millisecond() * 10000;
30 });
31 addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
32 return this.millisecond() * 100000;
33 });
34 addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
35 return this.millisecond() * 1000000;
36 });
37
38
39 // ALIASES
40
41 addUnitAlias('millisecond', 'ms');
42
43 // PARSING
44
45 addRegexToken('S', match1to3, match1);
46 addRegexToken('SS', match1to3, match2);
47 addRegexToken('SSS', match1to3, match3);
48
49 var token;
50 for (token = 'SSSS'; token.length <= 9; token += 'S') {
51 addRegexToken(token, matchUnsigned);
52 }
53
54 function parseMs(input, array) {
55 array[MILLISECOND] = toInt(('0.' + input) * 1000);
56 }
57
58 for (token = 'S'; token.length <= 9; token += 'S') {
59 addParseToken(token, parseMs);
60 }
61 // MOMENTS
62
63 export var getSetMillisecond = makeGetSet('Milliseconds', false);
0 import { makeGetSet } from '../moment/get-set';
1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1to2, match2 } from '../parse/regex';
4 import { addParseToken } from '../parse/token';
5 import { MINUTE } from './constants';
6
7 // FORMATTING
8
9 addFormatToken('m', ['mm', 2], 0, 'minute');
10
11 // ALIASES
12
13 addUnitAlias('minute', 'm');
14
15 // PARSING
16
17 addRegexToken('m', match1to2);
18 addRegexToken('mm', match1to2, match2);
19 addParseToken(['m', 'mm'], MINUTE);
20
21 // MOMENTS
22
23 export var getSetMinute = makeGetSet('Minutes', false);
0 import { get } from '../moment/get-set';
1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1to2, match2, matchWord } from '../parse/regex';
4 import { addParseToken } from '../parse/token';
5 import { hooks } from '../utils/hooks';
6 import { MONTH } from './constants';
7 import toInt from '../utils/to-int';
8 import { createUTC } from '../create/utc';
9 import getParsingFlags from '../create/parsing-flags';
10
11 export function daysInMonth(year, month) {
12 return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
13 }
14
15 // FORMATTING
16
17 addFormatToken('M', ['MM', 2], 'Mo', function () {
18 return this.month() + 1;
19 });
20
21 addFormatToken('MMM', 0, 0, function (format) {
22 return this.localeData().monthsShort(this, format);
23 });
24
25 addFormatToken('MMMM', 0, 0, function (format) {
26 return this.localeData().months(this, format);
27 });
28
29 // ALIASES
30
31 addUnitAlias('month', 'M');
32
33 // PARSING
34
35 addRegexToken('M', match1to2);
36 addRegexToken('MM', match1to2, match2);
37 addRegexToken('MMM', matchWord);
38 addRegexToken('MMMM', matchWord);
39
40 addParseToken(['M', 'MM'], function (input, array) {
41 array[MONTH] = toInt(input) - 1;
42 });
43
44 addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
45 var month = config._locale.monthsParse(input, token, config._strict);
46 // if we didn't find a month name, mark the date as invalid.
47 if (month != null) {
48 array[MONTH] = month;
49 } else {
50 getParsingFlags(config).invalidMonth = input;
51 }
52 });
53
54 // LOCALES
55
56 export var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
57 export function localeMonths (m) {
58 return this._months[m.month()];
59 }
60
61 export var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
62 export function localeMonthsShort (m) {
63 return this._monthsShort[m.month()];
64 }
65
66 export function localeMonthsParse (monthName, format, strict) {
67 var i, mom, regex;
68
69 if (!this._monthsParse) {
70 this._monthsParse = [];
71 this._longMonthsParse = [];
72 this._shortMonthsParse = [];
73 }
74
75 for (i = 0; i < 12; i++) {
76 // make the regex if we don't have it already
77 mom = createUTC([2000, i]);
78 if (strict && !this._longMonthsParse[i]) {
79 this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
80 this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
81 }
82 if (!strict && !this._monthsParse[i]) {
83 regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
84 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
85 }
86 // test the regex
87 if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
88 return i;
89 } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
90 return i;
91 } else if (!strict && this._monthsParse[i].test(monthName)) {
92 return i;
93 }
94 }
95 }
96
97 // MOMENTS
98
99 export function setMonth (mom, value) {
100 var dayOfMonth;
101
102 // TODO: Move this out of here!
103 if (typeof value === 'string') {
104 value = mom.localeData().monthsParse(value);
105 // TODO: Another silent failure?
106 if (typeof value !== 'number') {
107 return mom;
108 }
109 }
110
111 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
112 mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
113 return mom;
114 }
115
116 export function getSetMonth (value) {
117 if (value != null) {
118 setMonth(this, value);
119 hooks.updateOffset(this, true);
120 return this;
121 } else {
122 return get(this, 'Month');
123 }
124 }
125
126 export function getDaysInMonth () {
127 return daysInMonth(this.year(), this.month());
128 }
0 import zeroFill from '../utils/zero-fill';
1 import { createDuration } from '../duration/create';
2 import { addSubtract } from '../moment/add-subtract';
3 import { isMoment, copyConfig } from '../moment/constructor';
4 import { addFormatToken } from '../format/format';
5 import { addRegexToken, matchOffset } from '../parse/regex';
6 import { addParseToken } from '../parse/token';
7 import { createLocal } from '../create/local';
8 import { prepareConfig } from '../create/from-anything';
9 import { createUTC } from '../create/utc';
10 import isDate from '../utils/is-date';
11 import toInt from '../utils/to-int';
12 import compareArrays from '../utils/compare-arrays';
13 import { hooks } from '../utils/hooks';
14
15 // FORMATTING
16
17 function offset (token, separator) {
18 addFormatToken(token, 0, 0, function () {
19 var offset = this.utcOffset();
20 var sign = '+';
21 if (offset < 0) {
22 offset = -offset;
23 sign = '-';
24 }
25 return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
26 });
27 }
28
29 offset('Z', ':');
30 offset('ZZ', '');
31
32 // PARSING
33
34 addRegexToken('Z', matchOffset);
35 addRegexToken('ZZ', matchOffset);
36 addParseToken(['Z', 'ZZ'], function (input, array, config) {
37 config._useUTC = true;
38 config._tzm = offsetFromString(input);
39 });
40
41 // HELPERS
42
43 // timezone chunker
44 // '+10:00' > ['10', '00']
45 // '-1530' > ['-15', '30']
46 var chunkOffset = /([\+\-]|\d\d)/gi;
47
48 function offsetFromString(string) {
49 var matches = ((string || '').match(matchOffset) || []);
50 var chunk = matches[matches.length - 1] || [];
51 var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
52 var minutes = +(parts[1] * 60) + toInt(parts[2]);
53
54 return parts[0] === '+' ? minutes : -minutes;
55 }
56
57 // Return a moment from input, that is local/utc/zone equivalent to model.
58 export function cloneWithOffset(input, model) {
59 var res, diff;
60 if (model._isUTC) {
61 res = model.clone();
62 diff = (isMoment(input) || isDate(input) ? +input : +createLocal(input)) - (+res);
63 // Use low-level api, because this fn is low-level api.
64 res._d.setTime(+res._d + diff);
65 hooks.updateOffset(res, false);
66 return res;
67 } else {
68 return createLocal(input).local();
69 }
70 }
71
72 function getDateOffset (m) {
73 // On Firefox.24 Date#getTimezoneOffset returns a floating point.
74 // https://github.com/moment/moment/pull/1871
75 return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
76 }
77
78 // HOOKS
79
80 // This function will be called whenever a moment is mutated.
81 // It is intended to keep the offset in sync with the timezone.
82 hooks.updateOffset = function () {};
83
84 // MOMENTS
85
86 // keepLocalTime = true means only change the timezone, without
87 // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
88 // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
89 // +0200, so we adjust the time as needed, to be valid.
90 //
91 // Keeping the time actually adds/subtracts (one hour)
92 // from the actual represented time. That is why we call updateOffset
93 // a second time. In case it wants us to change the offset again
94 // _changeInProgress == true case, then we have to adjust, because
95 // there is no such time in the given timezone.
96 export function getSetOffset (input, keepLocalTime) {
97 var offset = this._offset || 0,
98 localAdjust;
99 if (input != null) {
100 if (typeof input === 'string') {
101 input = offsetFromString(input);
102 }
103 if (Math.abs(input) < 16) {
104 input = input * 60;
105 }
106 if (!this._isUTC && keepLocalTime) {
107 localAdjust = getDateOffset(this);
108 }
109 this._offset = input;
110 this._isUTC = true;
111 if (localAdjust != null) {
112 this.add(localAdjust, 'm');
113 }
114 if (offset !== input) {
115 if (!keepLocalTime || this._changeInProgress) {
116 addSubtract(this, createDuration(input - offset, 'm'), 1, false);
117 } else if (!this._changeInProgress) {
118 this._changeInProgress = true;
119 hooks.updateOffset(this, true);
120 this._changeInProgress = null;
121 }
122 }
123 return this;
124 } else {
125 return this._isUTC ? offset : getDateOffset(this);
126 }
127 }
128
129 export function getSetZone (input, keepLocalTime) {
130 if (input != null) {
131 if (typeof input !== 'string') {
132 input = -input;
133 }
134
135 this.utcOffset(input, keepLocalTime);
136
137 return this;
138 } else {
139 return -this.utcOffset();
140 }
141 }
142
143 export function setOffsetToUTC (keepLocalTime) {
144 return this.utcOffset(0, keepLocalTime);
145 }
146
147 export function setOffsetToLocal (keepLocalTime) {
148 if (this._isUTC) {
149 this.utcOffset(0, keepLocalTime);
150 this._isUTC = false;
151
152 if (keepLocalTime) {
153 this.subtract(getDateOffset(this), 'm');
154 }
155 }
156 return this;
157 }
158
159 export function setOffsetToParsedOffset () {
160 if (this._tzm) {
161 this.utcOffset(this._tzm);
162 } else if (typeof this._i === 'string') {
163 this.utcOffset(offsetFromString(this._i));
164 }
165 return this;
166 }
167
168 export function hasAlignedHourOffset (input) {
169 input = input ? createLocal(input).utcOffset() : 0;
170
171 return (this.utcOffset() - input) % 60 === 0;
172 }
173
174 export function isDaylightSavingTime () {
175 return (
176 this.utcOffset() > this.clone().month(0).utcOffset() ||
177 this.utcOffset() > this.clone().month(5).utcOffset()
178 );
179 }
180
181 export function isDaylightSavingTimeShifted () {
182 if (typeof this._isDSTShifted !== 'undefined') {
183 return this._isDSTShifted;
184 }
185
186 var c = {};
187
188 copyConfig(c, this);
189 c = prepareConfig(c);
190
191 if (c._a) {
192 var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
193 this._isDSTShifted = this.isValid() &&
194 compareArrays(c._a, other.toArray()) > 0;
195 } else {
196 this._isDSTShifted = false;
197 }
198
199 return this._isDSTShifted;
200 }
201
202 export function isLocal () {
203 return !this._isUTC;
204 }
205
206 export function isUtcOffset () {
207 return this._isUTC;
208 }
209
210 export function isUtc () {
211 return this._isUTC && this._offset === 0;
212 }
0 import { addFormatToken } from '../format/format';
1 import { addUnitAlias } from './aliases';
2 import { addRegexToken, match1 } from '../parse/regex';
3 import { addParseToken } from '../parse/token';
4 import { MONTH } from './constants';
5 import toInt from '../utils/to-int';
6
7 // FORMATTING
8
9 addFormatToken('Q', 0, 0, 'quarter');
10
11 // ALIASES
12
13 addUnitAlias('quarter', 'Q');
14
15 // PARSING
16
17 addRegexToken('Q', match1);
18 addParseToken('Q', function (input, array) {
19 array[MONTH] = (toInt(input) - 1) * 3;
20 });
21
22 // MOMENTS
23
24 export function getSetQuarter (input) {
25 return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
26 }
0 import { makeGetSet } from '../moment/get-set';
1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1to2, match2 } from '../parse/regex';
4 import { addParseToken } from '../parse/token';
5 import { SECOND } from './constants';
6
7 // FORMATTING
8
9 addFormatToken('s', ['ss', 2], 0, 'second');
10
11 // ALIASES
12
13 addUnitAlias('second', 's');
14
15 // PARSING
16
17 addRegexToken('s', match1to2);
18 addRegexToken('ss', match1to2, match2);
19 addParseToken(['s', 'ss'], SECOND);
20
21 // MOMENTS
22
23 export var getSetSecond = makeGetSet('Seconds', false);
0 import { addFormatToken } from '../format/format';
1 import { addRegexToken, matchTimestamp, matchSigned } from '../parse/regex';
2 import { addParseToken } from '../parse/token';
3 import toInt from '../utils/to-int';
4
5 // FORMATTING
6
7 addFormatToken('X', 0, 0, 'unix');
8 addFormatToken('x', 0, 0, 'valueOf');
9
10 // PARSING
11
12 addRegexToken('x', matchSigned);
13 addRegexToken('X', matchTimestamp);
14 addParseToken('X', function (input, array, config) {
15 config._d = new Date(parseFloat(input, 10) * 1000);
16 });
17 addParseToken('x', function (input, array, config) {
18 config._d = new Date(toInt(input));
19 });
0 import { addFormatToken } from '../format/format';
1
2 // FORMATTING
3
4 addFormatToken('z', 0, 0, 'zoneAbbr');
5 addFormatToken('zz', 0, 0, 'zoneName');
6
7 // MOMENTS
8
9 export function getZoneAbbr () {
10 return this._isUTC ? 'UTC' : '';
11 }
12
13 export function getZoneName () {
14 return this._isUTC ? 'Coordinated Universal Time' : '';
15 }
0 // Side effect imports
1 import './day-of-month';
2 import './day-of-week';
3 import './day-of-year';
4 import './hour';
5 import './millisecond';
6 import './minute';
7 import './month';
8 import './offset';
9 import './quarter';
10 import './second';
11 import './timestamp';
12 import './timezone';
13 import './week-year';
14 import './week';
15 import './year';
16
17 import { normalizeUnits } from './aliases';
18
19 export { normalizeUnits };
0 import { addFormatToken } from '../format/format';
1 import { addUnitAlias } from './aliases';
2 import { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from '../parse/regex';
3 import { addWeekParseToken } from '../parse/token';
4 import { weekOfYear } from './week';
5 import toInt from '../utils/to-int';
6 import { hooks } from '../utils/hooks';
7 import { createLocal } from '../create/local';
8
9 // FORMATTING
10
11 addFormatToken(0, ['gg', 2], 0, function () {
12 return this.weekYear() % 100;
13 });
14
15 addFormatToken(0, ['GG', 2], 0, function () {
16 return this.isoWeekYear() % 100;
17 });
18
19 function addWeekYearFormatToken (token, getter) {
20 addFormatToken(0, [token, token.length], 0, getter);
21 }
22
23 addWeekYearFormatToken('gggg', 'weekYear');
24 addWeekYearFormatToken('ggggg', 'weekYear');
25 addWeekYearFormatToken('GGGG', 'isoWeekYear');
26 addWeekYearFormatToken('GGGGG', 'isoWeekYear');
27
28 // ALIASES
29
30 addUnitAlias('weekYear', 'gg');
31 addUnitAlias('isoWeekYear', 'GG');
32
33 // PARSING
34
35 addRegexToken('G', matchSigned);
36 addRegexToken('g', matchSigned);
37 addRegexToken('GG', match1to2, match2);
38 addRegexToken('gg', match1to2, match2);
39 addRegexToken('GGGG', match1to4, match4);
40 addRegexToken('gggg', match1to4, match4);
41 addRegexToken('GGGGG', match1to6, match6);
42 addRegexToken('ggggg', match1to6, match6);
43
44 addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
45 week[token.substr(0, 2)] = toInt(input);
46 });
47
48 addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
49 week[token] = hooks.parseTwoDigitYear(input);
50 });
51
52 // HELPERS
53
54 function weeksInYear(year, dow, doy) {
55 return weekOfYear(createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
56 }
57
58 // MOMENTS
59
60 export function getSetWeekYear (input) {
61 var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
62 return input == null ? year : this.add((input - year), 'y');
63 }
64
65 export function getSetISOWeekYear (input) {
66 var year = weekOfYear(this, 1, 4).year;
67 return input == null ? year : this.add((input - year), 'y');
68 }
69
70 export function getISOWeeksInYear () {
71 return weeksInYear(this.year(), 1, 4);
72 }
73
74 export function getWeeksInYear () {
75 var weekInfo = this.localeData()._week;
76 return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
77 }
0 import { addFormatToken } from '../format/format';
1 import { addUnitAlias } from './aliases';
2 import { addRegexToken, match1to2, match2 } from '../parse/regex';
3 import { addWeekParseToken } from '../parse/token';
4 import toInt from '../utils/to-int';
5 import { createLocal } from '../create/local';
6
7 // FORMATTING
8
9 addFormatToken('w', ['ww', 2], 'wo', 'week');
10 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
11
12 // ALIASES
13
14 addUnitAlias('week', 'w');
15 addUnitAlias('isoWeek', 'W');
16
17 // PARSING
18
19 addRegexToken('w', match1to2);
20 addRegexToken('ww', match1to2, match2);
21 addRegexToken('W', match1to2);
22 addRegexToken('WW', match1to2, match2);
23
24 addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
25 week[token.substr(0, 1)] = toInt(input);
26 });
27
28 // HELPERS
29
30 // firstDayOfWeek 0 = sun, 6 = sat
31 // the day of the week that starts the week
32 // (usually sunday or monday)
33 // firstDayOfWeekOfYear 0 = sun, 6 = sat
34 // the first week is the week that contains the first
35 // of this day of the week
36 // (eg. ISO weeks use thursday (4))
37 export function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
38 var end = firstDayOfWeekOfYear - firstDayOfWeek,
39 daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
40 adjustedMoment;
41
42
43 if (daysToDayOfWeek > end) {
44 daysToDayOfWeek -= 7;
45 }
46
47 if (daysToDayOfWeek < end - 7) {
48 daysToDayOfWeek += 7;
49 }
50
51 adjustedMoment = createLocal(mom).add(daysToDayOfWeek, 'd');
52 return {
53 week: Math.ceil(adjustedMoment.dayOfYear() / 7),
54 year: adjustedMoment.year()
55 };
56 }
57
58 // LOCALES
59
60 export function localeWeek (mom) {
61 return weekOfYear(mom, this._week.dow, this._week.doy).week;
62 }
63
64 export var defaultLocaleWeek = {
65 dow : 0, // Sunday is the first day of the week.
66 doy : 6 // The week that contains Jan 1st is the first week of the year.
67 };
68
69 export function localeFirstDayOfWeek () {
70 return this._week.dow;
71 }
72
73 export function localeFirstDayOfYear () {
74 return this._week.doy;
75 }
76
77 // MOMENTS
78
79 export function getSetWeek (input) {
80 var week = this.localeData().week(this);
81 return input == null ? week : this.add((input - week) * 7, 'd');
82 }
83
84 export function getSetISOWeek (input) {
85 var week = weekOfYear(this, 1, 4).week;
86 return input == null ? week : this.add((input - week) * 7, 'd');
87 }
0 import { makeGetSet } from '../moment/get-set';
1 import { addFormatToken } from '../format/format';
2 import { addUnitAlias } from './aliases';
3 import { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from '../parse/regex';
4 import { addParseToken } from '../parse/token';
5 import { hooks } from '../utils/hooks';
6 import { YEAR } from './constants';
7 import toInt from '../utils/to-int';
8
9 // FORMATTING
10
11 addFormatToken(0, ['YY', 2], 0, function () {
12 return this.year() % 100;
13 });
14
15 addFormatToken(0, ['YYYY', 4], 0, 'year');
16 addFormatToken(0, ['YYYYY', 5], 0, 'year');
17 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
18
19 // ALIASES
20
21 addUnitAlias('year', 'y');
22
23 // PARSING
24
25 addRegexToken('Y', matchSigned);
26 addRegexToken('YY', match1to2, match2);
27 addRegexToken('YYYY', match1to4, match4);
28 addRegexToken('YYYYY', match1to6, match6);
29 addRegexToken('YYYYYY', match1to6, match6);
30
31 addParseToken(['YYYYY', 'YYYYYY'], YEAR);
32 addParseToken('YYYY', function (input, array) {
33 array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
34 });
35 addParseToken('YY', function (input, array) {
36 array[YEAR] = hooks.parseTwoDigitYear(input);
37 });
38
39 // HELPERS
40
41 export function daysInYear(year) {
42 return isLeapYear(year) ? 366 : 365;
43 }
44
45 function isLeapYear(year) {
46 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
47 }
48
49 // HOOKS
50
51 hooks.parseTwoDigitYear = function (input) {
52 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
53 };
54
55 // MOMENTS
56
57 export var getSetYear = makeGetSet('FullYear', false);
58
59 export function getIsLeapYear () {
60 return isLeapYear(this.year());
61 }
0 export default function absCeil (number) {
1 if (number < 0) {
2 return Math.floor(number);
3 } else {
4 return Math.ceil(number);
5 }
6 }
0 export default function absFloor (number) {
1 if (number < 0) {
2 return Math.ceil(number);
3 } else {
4 return Math.floor(number);
5 }
6 }
0 import toInt from './to-int';
1
2 // compare two arrays, return the number of differences
3 export default function compareArrays(array1, array2, dontConvert) {
4 var len = Math.min(array1.length, array2.length),
5 lengthDiff = Math.abs(array1.length - array2.length),
6 diffs = 0,
7 i;
8 for (i = 0; i < len; i++) {
9 if ((dontConvert && array1[i] !== array2[i]) ||
10 (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
11 diffs++;
12 }
13 }
14 return diffs + lengthDiff;
15 }
0 // Pick the first defined of two or three arguments.
1 export default function defaults(a, b, c) {
2 if (a != null) {
3 return a;
4 }
5 if (b != null) {
6 return b;
7 }
8 return c;
9 }
0 import extend from './extend';
1 import { hooks } from './hooks';
2
3 function warn(msg) {
4 if (hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
5 console.warn('Deprecation warning: ' + msg);
6 }
7 }
8
9 export function deprecate(msg, fn) {
10 var firstTime = true;
11
12 return extend(function () {
13 if (firstTime) {
14 warn(msg + '\n' + (new Error()).stack);
15 firstTime = false;
16 }
17 return fn.apply(this, arguments);
18 }, fn);
19 }
20
21 var deprecations = {};
22
23 export function deprecateSimple(name, msg) {
24 if (!deprecations[name]) {
25 warn(msg);
26 deprecations[name] = true;
27 }
28 }
29
30 hooks.suppressDeprecationWarnings = false;
31
0 import hasOwnProp from './has-own-prop';
1
2 export default function extend(a, b) {
3 for (var i in b) {
4 if (hasOwnProp(b, i)) {
5 a[i] = b[i];
6 }
7 }
8
9 if (hasOwnProp(b, 'toString')) {
10 a.toString = b.toString;
11 }
12
13 if (hasOwnProp(b, 'valueOf')) {
14 a.valueOf = b.valueOf;
15 }
16
17 return a;
18 }
0 export default function hasOwnProp(a, b) {
1 return Object.prototype.hasOwnProperty.call(a, b);
2 }
0 export { hooks, setHookCallback };
1
2 var hookCallback;
3
4 function hooks () {
5 return hookCallback.apply(null, arguments);
6 }
7
8 // This is done to register the method called with moment()
9 // without creating circular dependencies.
10 function setHookCallback (callback) {
11 hookCallback = callback;
12 }
0 export default function isArray(input) {
1 return Object.prototype.toString.call(input) === '[object Array]';
2 }
0 export default function isDate(input) {
1 return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
2 }
0 export default function map(arr, fn) {
1 var res = [], i;
2 for (i = 0; i < arr.length; ++i) {
3 res.push(fn(arr[i], i));
4 }
5 return res;
6 }
0 import absFloor from './abs-floor';
1
2 export default function toInt(argumentForCoercion) {
3 var coercedNumber = +argumentForCoercion,
4 value = 0;
5
6 if (coercedNumber !== 0 && isFinite(coercedNumber)) {
7 value = absFloor(coercedNumber);
8 }
9
10 return value;
11 }
0 export default function zeroFill(number, targetLength, forceSign) {
1 var absNumber = '' + Math.abs(number),
2 zerosToFill = targetLength - absNumber.length,
3 sign = number >= 0;
4 return (sign ? (forceSign ? '+' : '') : '-') +
5 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
6 }
0 //! moment.js locale configuration
1 //! locale : afrikaans (af)
2 //! author : Werner Mollentze : https://github.com/wernerm
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('af', {
7 months : 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'),
8 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'),
9 weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
10 weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
11 weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
12 meridiemParse: /vm|nm/i,
13 isPM : function (input) {
14 return /^nm$/i.test(input);
15 },
16 meridiem : function (hours, minutes, isLower) {
17 if (hours < 12) {
18 return isLower ? 'vm' : 'VM';
19 } else {
20 return isLower ? 'nm' : 'NM';
21 }
22 },
23 longDateFormat : {
24 LT : 'HH:mm',
25 LTS : 'HH:mm:ss',
26 L : 'DD/MM/YYYY',
27 LL : 'D MMMM YYYY',
28 LLL : 'D MMMM YYYY HH:mm',
29 LLLL : 'dddd, D MMMM YYYY HH:mm'
30 },
31 calendar : {
32 sameDay : '[Vandag om] LT',
33 nextDay : '[Môre om] LT',
34 nextWeek : 'dddd [om] LT',
35 lastDay : '[Gister om] LT',
36 lastWeek : '[Laas] dddd [om] LT',
37 sameElse : 'L'
38 },
39 relativeTime : {
40 future : 'oor %s',
41 past : '%s gelede',
42 s : '\'n paar sekondes',
43 m : '\'n minuut',
44 mm : '%d minute',
45 h : '\'n uur',
46 hh : '%d ure',
47 d : '\'n dag',
48 dd : '%d dae',
49 M : '\'n maand',
50 MM : '%d maande',
51 y : '\'n jaar',
52 yy : '%d jaar'
53 },
54 ordinalParse: /\d{1,2}(ste|de)/,
55 ordinal : function (number) {
56 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); // Thanks to Joris Röling : https://github.com/jjupiter
57 },
58 week : {
59 dow : 1, // Maandag is die eerste dag van die week.
60 doy : 4 // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
61 }
62 });
0 //! moment.js locale configuration
1 //! locale : Moroccan Arabic (ar-ma)
2 //! author : ElFadili Yassine : https://github.com/ElFadiliY
3 //! author : Abdel Said : https://github.com/abdelsaid
4
5 import moment from '../moment';
6
7 export default moment.defineLocale('ar-ma', {
8 months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
9 monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
10 weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
11 weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
12 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
13 longDateFormat : {
14 LT : 'HH:mm',
15 LTS : 'HH:mm:ss',
16 L : 'DD/MM/YYYY',
17 LL : 'D MMMM YYYY',
18 LLL : 'D MMMM YYYY HH:mm',
19 LLLL : 'dddd D MMMM YYYY HH:mm'
20 },
21 calendar : {
22 sameDay: '[اليوم على الساعة] LT',
23 nextDay: '[غدا على الساعة] LT',
24 nextWeek: 'dddd [على الساعة] LT',
25 lastDay: '[أمس على الساعة] LT',
26 lastWeek: 'dddd [على الساعة] LT',
27 sameElse: 'L'
28 },
29 relativeTime : {
30 future : 'في %s',
31 past : 'منذ %s',
32 s : 'ثوان',
33 m : 'دقيقة',
34 mm : '%d دقائق',
35 h : 'ساعة',
36 hh : '%d ساعات',
37 d : 'يوم',
38 dd : '%d أيام',
39 M : 'شهر',
40 MM : '%d أشهر',
41 y : 'سنة',
42 yy : '%d سنوات'
43 },
44 week : {
45 dow : 6, // Saturday is the first day of the week.
46 doy : 12 // The week that contains Jan 1st is the first week of the year.
47 }
48 });
49
0 //! moment.js locale configuration
1 //! locale : Arabic Saudi Arabia (ar-sa)
2 //! author : Suhail Alkowaileet : https://github.com/xsoh
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '١',
8 '2': '٢',
9 '3': '٣',
10 '4': '٤',
11 '5': '٥',
12 '6': '٦',
13 '7': '٧',
14 '8': '٨',
15 '9': '٩',
16 '0': '٠'
17 }, numberMap = {
18 '١': '1',
19 '٢': '2',
20 '٣': '3',
21 '٤': '4',
22 '٥': '5',
23 '٦': '6',
24 '٧': '7',
25 '٨': '8',
26 '٩': '9',
27 '٠': '0'
28 };
29
30 export default moment.defineLocale('ar-sa', {
31 months : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
32 monthsShort : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
33 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
34 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
35 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
36 longDateFormat : {
37 LT : 'HH:mm',
38 LTS : 'HH:mm:ss',
39 L : 'DD/MM/YYYY',
40 LL : 'D MMMM YYYY',
41 LLL : 'D MMMM YYYY HH:mm',
42 LLLL : 'dddd D MMMM YYYY HH:mm'
43 },
44 meridiemParse: /ص|م/,
45 isPM : function (input) {
46 return 'م' === input;
47 },
48 meridiem : function (hour, minute, isLower) {
49 if (hour < 12) {
50 return 'ص';
51 } else {
52 return 'م';
53 }
54 },
55 calendar : {
56 sameDay: '[اليوم على الساعة] LT',
57 nextDay: '[غدا على الساعة] LT',
58 nextWeek: 'dddd [على الساعة] LT',
59 lastDay: '[أمس على الساعة] LT',
60 lastWeek: 'dddd [على الساعة] LT',
61 sameElse: 'L'
62 },
63 relativeTime : {
64 future : 'في %s',
65 past : 'منذ %s',
66 s : 'ثوان',
67 m : 'دقيقة',
68 mm : '%d دقائق',
69 h : 'ساعة',
70 hh : '%d ساعات',
71 d : 'يوم',
72 dd : '%d أيام',
73 M : 'شهر',
74 MM : '%d أشهر',
75 y : 'سنة',
76 yy : '%d سنوات'
77 },
78 preparse: function (string) {
79 return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
80 return numberMap[match];
81 }).replace(/،/g, ',');
82 },
83 postformat: function (string) {
84 return string.replace(/\d/g, function (match) {
85 return symbolMap[match];
86 }).replace(/,/g, '،');
87 },
88 week : {
89 dow : 6, // Saturday is the first day of the week.
90 doy : 12 // The week that contains Jan 1st is the first week of the year.
91 }
92 });
93
0 //! moment.js locale configuration
1 //! locale : Tunisian Arabic (ar-tn)
2
3 import moment from '../moment';
4
5 export default moment.defineLocale('ar-tn', {
6 months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
7 monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
8 weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
9 weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
10 weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
11 longDateFormat: {
12 LT: 'HH:mm',
13 LTS: 'HH:mm:ss',
14 L: 'DD/MM/YYYY',
15 LL: 'D MMMM YYYY',
16 LLL: 'D MMMM YYYY HH:mm',
17 LLLL: 'dddd D MMMM YYYY HH:mm'
18 },
19 calendar: {
20 sameDay: '[اليوم على الساعة] LT',
21 nextDay: '[غدا على الساعة] LT',
22 nextWeek: 'dddd [على الساعة] LT',
23 lastDay: '[أمس على الساعة] LT',
24 lastWeek: 'dddd [على الساعة] LT',
25 sameElse: 'L'
26 },
27 relativeTime: {
28 future: 'في %s',
29 past: 'منذ %s',
30 s: 'ثوان',
31 m: 'دقيقة',
32 mm: '%d دقائق',
33 h: 'ساعة',
34 hh: '%d ساعات',
35 d: 'يوم',
36 dd: '%d أيام',
37 M: 'شهر',
38 MM: '%d أشهر',
39 y: 'سنة',
40 yy: '%d سنوات'
41 },
42 week: {
43 dow: 1, // Monday is the first day of the week.
44 doy: 4 // The week that contains Jan 4th is the first week of the year.
45 }
46 });
47
0 //! moment.js locale configuration
1 //! Locale: Arabic (ar)
2 //! Author: Abdel Said: https://github.com/abdelsaid
3 //! Changes in months, weekdays: Ahmed Elkhatib
4 //! Native plural forms: forabi https://github.com/forabi
5
6 import moment from '../moment';
7
8 var symbolMap = {
9 '1': '١',
10 '2': '٢',
11 '3': '٣',
12 '4': '٤',
13 '5': '٥',
14 '6': '٦',
15 '7': '٧',
16 '8': '٨',
17 '9': '٩',
18 '0': '٠'
19 }, numberMap = {
20 '١': '1',
21 '٢': '2',
22 '٣': '3',
23 '٤': '4',
24 '٥': '5',
25 '٦': '6',
26 '٧': '7',
27 '٨': '8',
28 '٩': '9',
29 '٠': '0'
30 }, pluralForm = function (n) {
31 return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
32 }, plurals = {
33 s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
34 m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
35 h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
36 d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
37 M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
38 y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
39 }, pluralize = function (u) {
40 return function (number, withoutSuffix, string, isFuture) {
41 var f = pluralForm(number),
42 str = plurals[u][pluralForm(number)];
43 if (f === 2) {
44 str = str[withoutSuffix ? 0 : 1];
45 }
46 return str.replace(/%d/i, number);
47 };
48 }, months = [
49 'كانون الثاني يناير',
50 'شباط فبراير',
51 'آذار مارس',
52 'نيسان أبريل',
53 'أيار مايو',
54 'حزيران يونيو',
55 'تموز يوليو',
56 'آب أغسطس',
57 'أيلول سبتمبر',
58 'تشرين الأول أكتوبر',
59 'تشرين الثاني نوفمبر',
60 'كانون الأول ديسمبر'
61 ];
62
63 export default moment.defineLocale('ar', {
64 months : months,
65 monthsShort : months,
66 weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
67 weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
68 weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
69 longDateFormat : {
70 LT : 'HH:mm',
71 LTS : 'HH:mm:ss',
72 L : 'D/\u200FM/\u200FYYYY',
73 LL : 'D MMMM YYYY',
74 LLL : 'D MMMM YYYY HH:mm',
75 LLLL : 'dddd D MMMM YYYY HH:mm'
76 },
77 meridiemParse: /ص|م/,
78 isPM : function (input) {
79 return 'م' === input;
80 },
81 meridiem : function (hour, minute, isLower) {
82 if (hour < 12) {
83 return 'ص';
84 } else {
85 return 'م';
86 }
87 },
88 calendar : {
89 sameDay: '[اليوم عند الساعة] LT',
90 nextDay: '[غدًا عند الساعة] LT',
91 nextWeek: 'dddd [عند الساعة] LT',
92 lastDay: '[أمس عند الساعة] LT',
93 lastWeek: 'dddd [عند الساعة] LT',
94 sameElse: 'L'
95 },
96 relativeTime : {
97 future : 'بعد %s',
98 past : 'منذ %s',
99 s : pluralize('s'),
100 m : pluralize('m'),
101 mm : pluralize('m'),
102 h : pluralize('h'),
103 hh : pluralize('h'),
104 d : pluralize('d'),
105 dd : pluralize('d'),
106 M : pluralize('M'),
107 MM : pluralize('M'),
108 y : pluralize('y'),
109 yy : pluralize('y')
110 },
111 preparse: function (string) {
112 return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
113 return numberMap[match];
114 }).replace(/،/g, ',');
115 },
116 postformat: function (string) {
117 return string.replace(/\d/g, function (match) {
118 return symbolMap[match];
119 }).replace(/,/g, '،');
120 },
121 week : {
122 dow : 6, // Saturday is the first day of the week.
123 doy : 12 // The week that contains Jan 1st is the first week of the year.
124 }
125 });
126
0 //! moment.js locale configuration
1 //! locale : azerbaijani (az)
2 //! author : topchiyev : https://github.com/topchiyev
3
4 import moment from '../moment';
5
6 var suffixes = {
7 1: '-inci',
8 5: '-inci',
9 8: '-inci',
10 70: '-inci',
11 80: '-inci',
12 2: '-nci',
13 7: '-nci',
14 20: '-nci',
15 50: '-nci',
16 3: '-üncü',
17 4: '-üncü',
18 100: '-üncü',
19 6: '-ncı',
20 9: '-uncu',
21 10: '-uncu',
22 30: '-uncu',
23 60: '-ıncı',
24 90: '-ıncı'
25 };
26
27 export default moment.defineLocale('az', {
28 months : 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split('_'),
29 monthsShort : 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'),
30 weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
31 weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
32 weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
33 longDateFormat : {
34 LT : 'HH:mm',
35 LTS : 'HH:mm:ss',
36 L : 'DD.MM.YYYY',
37 LL : 'D MMMM YYYY',
38 LLL : 'D MMMM YYYY HH:mm',
39 LLLL : 'dddd, D MMMM YYYY HH:mm'
40 },
41 calendar : {
42 sameDay : '[bugün saat] LT',
43 nextDay : '[sabah saat] LT',
44 nextWeek : '[gələn həftə] dddd [saat] LT',
45 lastDay : '[dünən] LT',
46 lastWeek : '[keçən həftə] dddd [saat] LT',
47 sameElse : 'L'
48 },
49 relativeTime : {
50 future : '%s sonra',
51 past : '%s əvvəl',
52 s : 'birneçə saniyyə',
53 m : 'bir dəqiqə',
54 mm : '%d dəqiqə',
55 h : 'bir saat',
56 hh : '%d saat',
57 d : 'bir gün',
58 dd : '%d gün',
59 M : 'bir ay',
60 MM : '%d ay',
61 y : 'bir il',
62 yy : '%d il'
63 },
64 meridiemParse: /gecə|səhər|gündüz|axşam/,
65 isPM : function (input) {
66 return /^(gündüz|axşam)$/.test(input);
67 },
68 meridiem : function (hour, minute, isLower) {
69 if (hour < 4) {
70 return 'gecə';
71 } else if (hour < 12) {
72 return 'səhər';
73 } else if (hour < 17) {
74 return 'gündüz';
75 } else {
76 return 'axşam';
77 }
78 },
79 ordinalParse: /\d{1,2}-(ıncı|inci|nci|üncü|ncı|uncu)/,
80 ordinal : function (number) {
81 if (number === 0) { // special case for zero
82 return number + '-ıncı';
83 }
84 var a = number % 10,
85 b = number % 100 - a,
86 c = number >= 100 ? 100 : null;
87 return number + (suffixes[a] || suffixes[b] || suffixes[c]);
88 },
89 week : {
90 dow : 1, // Monday is the first day of the week.
91 doy : 7 // The week that contains Jan 1st is the first week of the year.
92 }
93 });
94
0 //! moment.js locale configuration
1 //! locale : belarusian (be)
2 //! author : Dmitry Demidov : https://github.com/demidov91
3 //! author: Praleska: http://praleska.pro/
4 //! Author : Menelion Elensúle : https://github.com/Oire
5
6 import moment from '../moment';
7
8 function plural(word, num) {
9 var forms = word.split('_');
10 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
11 }
12 function relativeTimeWithPlural(number, withoutSuffix, key) {
13 var format = {
14 'mm': withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін',
15 'hh': withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін',
16 'dd': 'дзень_дні_дзён',
17 'MM': 'месяц_месяцы_месяцаў',
18 'yy': 'год_гады_гадоў'
19 };
20 if (key === 'm') {
21 return withoutSuffix ? 'хвіліна' : 'хвіліну';
22 }
23 else if (key === 'h') {
24 return withoutSuffix ? 'гадзіна' : 'гадзіну';
25 }
26 else {
27 return number + ' ' + plural(format[key], +number);
28 }
29 }
30 function monthsCaseReplace(m, format) {
31 var months = {
32 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
33 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
34 },
35 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
36 'accusative' :
37 'nominative';
38 return months[nounCase][m.month()];
39 }
40 function weekdaysCaseReplace(m, format) {
41 var weekdays = {
42 'nominative': 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'),
43 'accusative': 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_')
44 },
45 nounCase = (/\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/).test(format) ?
46 'accusative' :
47 'nominative';
48 return weekdays[nounCase][m.day()];
49 }
50
51 export default moment.defineLocale('be', {
52 months : monthsCaseReplace,
53 monthsShort : 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'),
54 weekdays : weekdaysCaseReplace,
55 weekdaysShort : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
56 weekdaysMin : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
57 longDateFormat : {
58 LT : 'HH:mm',
59 LTS : 'HH:mm:ss',
60 L : 'DD.MM.YYYY',
61 LL : 'D MMMM YYYY г.',
62 LLL : 'D MMMM YYYY г., HH:mm',
63 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
64 },
65 calendar : {
66 sameDay: '[Сёння ў] LT',
67 nextDay: '[Заўтра ў] LT',
68 lastDay: '[Учора ў] LT',
69 nextWeek: function () {
70 return '[У] dddd [ў] LT';
71 },
72 lastWeek: function () {
73 switch (this.day()) {
74 case 0:
75 case 3:
76 case 5:
77 case 6:
78 return '[У мінулую] dddd [ў] LT';
79 case 1:
80 case 2:
81 case 4:
82 return '[У мінулы] dddd [ў] LT';
83 }
84 },
85 sameElse: 'L'
86 },
87 relativeTime : {
88 future : 'праз %s',
89 past : '%s таму',
90 s : 'некалькі секунд',
91 m : relativeTimeWithPlural,
92 mm : relativeTimeWithPlural,
93 h : relativeTimeWithPlural,
94 hh : relativeTimeWithPlural,
95 d : 'дзень',
96 dd : relativeTimeWithPlural,
97 M : 'месяц',
98 MM : relativeTimeWithPlural,
99 y : 'год',
100 yy : relativeTimeWithPlural
101 },
102 meridiemParse: /ночы|раніцы|дня|вечара/,
103 isPM : function (input) {
104 return /^(дня|вечара)$/.test(input);
105 },
106 meridiem : function (hour, minute, isLower) {
107 if (hour < 4) {
108 return 'ночы';
109 } else if (hour < 12) {
110 return 'раніцы';
111 } else if (hour < 17) {
112 return 'дня';
113 } else {
114 return 'вечара';
115 }
116 },
117 ordinalParse: /\d{1,2}-(і|ы|га)/,
118 ordinal: function (number, period) {
119 switch (period) {
120 case 'M':
121 case 'd':
122 case 'DDD':
123 case 'w':
124 case 'W':
125 return (number % 10 === 2 || number % 10 === 3) && (number % 100 !== 12 && number % 100 !== 13) ? number + '-і' : number + '-ы';
126 case 'D':
127 return number + '-га';
128 default:
129 return number;
130 }
131 },
132 week : {
133 dow : 1, // Monday is the first day of the week.
134 doy : 7 // The week that contains Jan 1st is the first week of the year.
135 }
136 });
137
0 //! moment.js locale configuration
1 //! locale : bulgarian (bg)
2 //! author : Krasen Borisov : https://github.com/kraz
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('bg', {
7 months : 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'.split('_'),
8 monthsShort : 'янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'.split('_'),
9 weekdays : 'неделя_понеделник_вторник_сряда_четвъртък_петък_събота'.split('_'),
10 weekdaysShort : 'нед_пон_вто_сря_чет_пет_съб'.split('_'),
11 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
12 longDateFormat : {
13 LT : 'H:mm',
14 LTS : 'H:mm:ss',
15 L : 'D.MM.YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY H:mm',
18 LLLL : 'dddd, D MMMM YYYY H:mm'
19 },
20 calendar : {
21 sameDay : '[Днес в] LT',
22 nextDay : '[Утре в] LT',
23 nextWeek : 'dddd [в] LT',
24 lastDay : '[Вчера в] LT',
25 lastWeek : function () {
26 switch (this.day()) {
27 case 0:
28 case 3:
29 case 6:
30 return '[В изминалата] dddd [в] LT';
31 case 1:
32 case 2:
33 case 4:
34 case 5:
35 return '[В изминалия] dddd [в] LT';
36 }
37 },
38 sameElse : 'L'
39 },
40 relativeTime : {
41 future : 'след %s',
42 past : 'преди %s',
43 s : 'няколко секунди',
44 m : 'минута',
45 mm : '%d минути',
46 h : 'час',
47 hh : '%d часа',
48 d : 'ден',
49 dd : '%d дни',
50 M : 'месец',
51 MM : '%d месеца',
52 y : 'година',
53 yy : '%d години'
54 },
55 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
56 ordinal : function (number) {
57 var lastDigit = number % 10,
58 last2Digits = number % 100;
59 if (number === 0) {
60 return number + '-ев';
61 } else if (last2Digits === 0) {
62 return number + '-ен';
63 } else if (last2Digits > 10 && last2Digits < 20) {
64 return number + '-ти';
65 } else if (lastDigit === 1) {
66 return number + '-ви';
67 } else if (lastDigit === 2) {
68 return number + '-ри';
69 } else if (lastDigit === 7 || lastDigit === 8) {
70 return number + '-ми';
71 } else {
72 return number + '-ти';
73 }
74 },
75 week : {
76 dow : 1, // Monday is the first day of the week.
77 doy : 7 // The week that contains Jan 1st is the first week of the year.
78 }
79 });
80
0 //! moment.js locale configuration
1 //! locale : Bengali (bn)
2 //! author : Kaushik Gandhi : https://github.com/kaushikgandhi
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '১',
8 '2': '২',
9 '3': '৩',
10 '4': '৪',
11 '5': '৫',
12 '6': '৬',
13 '7': '৭',
14 '8': '৮',
15 '9': '৯',
16 '0': '০'
17 },
18 numberMap = {
19 '১': '1',
20 '২': '2',
21 '৩': '3',
22 '৪': '4',
23 '৫': '5',
24 '৬': '6',
25 '৭': '7',
26 '৮': '8',
27 '৯': '9',
28 '০': '0'
29 };
30
31 export default moment.defineLocale('bn', {
32 months : 'জানুয়ারী_ফেবুয়ারী_মার্চ_এপ্রিল_মে_জুন_জুলাই_অগাস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'),
33 monthsShort : 'জানু_ফেব_মার্চ_এপর_মে_জুন_জুল_অগ_সেপ্ট_অক্টো_নভ_ডিসেম্'.split('_'),
34 weekdays : 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পত্তিবার_শুক্রুবার_শনিবার'.split('_'),
35 weekdaysShort : 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পত্তি_শুক্রু_শনি'.split('_'),
36 weekdaysMin : 'রব_সম_মঙ্গ_বু_ব্রিহ_শু_শনি'.split('_'),
37 longDateFormat : {
38 LT : 'A h:mm সময়',
39 LTS : 'A h:mm:ss সময়',
40 L : 'DD/MM/YYYY',
41 LL : 'D MMMM YYYY',
42 LLL : 'D MMMM YYYY, A h:mm সময়',
43 LLLL : 'dddd, D MMMM YYYY, A h:mm সময়'
44 },
45 calendar : {
46 sameDay : '[আজ] LT',
47 nextDay : '[আগামীকাল] LT',
48 nextWeek : 'dddd, LT',
49 lastDay : '[গতকাল] LT',
50 lastWeek : '[গত] dddd, LT',
51 sameElse : 'L'
52 },
53 relativeTime : {
54 future : '%s পরে',
55 past : '%s আগে',
56 s : 'কএক সেকেন্ড',
57 m : 'এক মিনিট',
58 mm : '%d মিনিট',
59 h : 'এক ঘন্টা',
60 hh : '%d ঘন্টা',
61 d : 'এক দিন',
62 dd : '%d দিন',
63 M : 'এক মাস',
64 MM : '%d মাস',
65 y : 'এক বছর',
66 yy : '%d বছর'
67 },
68 preparse: function (string) {
69 return string.replace(/[১২৩৪৫৬৭৮৯০]/g, function (match) {
70 return numberMap[match];
71 });
72 },
73 postformat: function (string) {
74 return string.replace(/\d/g, function (match) {
75 return symbolMap[match];
76 });
77 },
78 meridiemParse: /রাত|সকাল|দুপুর|বিকেল|রাত/,
79 isPM: function (input) {
80 return /^(দুপুর|বিকেল|রাত)$/.test(input);
81 },
82 //Bengali is a vast language its spoken
83 //in different forms in various parts of the world.
84 //I have just generalized with most common one used
85 meridiem : function (hour, minute, isLower) {
86 if (hour < 4) {
87 return 'রাত';
88 } else if (hour < 10) {
89 return 'সকাল';
90 } else if (hour < 17) {
91 return 'দুপুর';
92 } else if (hour < 20) {
93 return 'বিকেল';
94 } else {
95 return 'রাত';
96 }
97 },
98 week : {
99 dow : 0, // Sunday is the first day of the week.
100 doy : 6 // The week that contains Jan 1st is the first week of the year.
101 }
102 });
103
0 //! moment.js locale configuration
1 //! locale : tibetan (bo)
2 //! author : Thupten N. Chakrishar : https://github.com/vajradog
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '༡',
8 '2': '༢',
9 '3': '༣',
10 '4': '༤',
11 '5': '༥',
12 '6': '༦',
13 '7': '༧',
14 '8': '༨',
15 '9': '༩',
16 '0': '༠'
17 },
18 numberMap = {
19 '༡': '1',
20 '༢': '2',
21 '༣': '3',
22 '༤': '4',
23 '༥': '5',
24 '༦': '6',
25 '༧': '7',
26 '༨': '8',
27 '༩': '9',
28 '༠': '0'
29 };
30
31 export default moment.defineLocale('bo', {
32 months : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
33 monthsShort : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
34 weekdays : 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'),
35 weekdaysShort : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
36 weekdaysMin : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
37 longDateFormat : {
38 LT : 'A h:mm',
39 LTS : 'A h:mm:ss',
40 L : 'DD/MM/YYYY',
41 LL : 'D MMMM YYYY',
42 LLL : 'D MMMM YYYY, A h:mm',
43 LLLL : 'dddd, D MMMM YYYY, A h:mm'
44 },
45 calendar : {
46 sameDay : '[དི་རིང] LT',
47 nextDay : '[སང་ཉིན] LT',
48 nextWeek : '[བདུན་ཕྲག་རྗེས་མ], LT',
49 lastDay : '[ཁ་སང] LT',
50 lastWeek : '[བདུན་ཕྲག་མཐའ་མ] dddd, LT',
51 sameElse : 'L'
52 },
53 relativeTime : {
54 future : '%s ལ་',
55 past : '%s སྔན་ལ',
56 s : 'ལམ་སང',
57 m : 'སྐར་མ་གཅིག',
58 mm : '%d སྐར་མ',
59 h : 'ཆུ་ཚོད་གཅིག',
60 hh : '%d ཆུ་ཚོད',
61 d : 'ཉིན་གཅིག',
62 dd : '%d ཉིན་',
63 M : 'ཟླ་བ་གཅིག',
64 MM : '%d ཟླ་བ',
65 y : 'ལོ་གཅིག',
66 yy : '%d ལོ'
67 },
68 preparse: function (string) {
69 return string.replace(/[༡༢༣༤༥༦༧༨༩༠]/g, function (match) {
70 return numberMap[match];
71 });
72 },
73 postformat: function (string) {
74 return string.replace(/\d/g, function (match) {
75 return symbolMap[match];
76 });
77 },
78 meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
79 isPM: function (input) {
80 return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
81 },
82 meridiem : function (hour, minute, isLower) {
83 if (hour < 4) {
84 return 'མཚན་མོ';
85 } else if (hour < 10) {
86 return 'ཞོགས་ཀས';
87 } else if (hour < 17) {
88 return 'ཉིན་གུང';
89 } else if (hour < 20) {
90 return 'དགོང་དག';
91 } else {
92 return 'མཚན་མོ';
93 }
94 },
95 week : {
96 dow : 0, // Sunday is the first day of the week.
97 doy : 6 // The week that contains Jan 1st is the first week of the year.
98 }
99 });
100
0 //! moment.js locale configuration
1 //! locale : breton (br)
2 //! author : Jean-Baptiste Le Duigou : https://github.com/jbleduigou
3
4 import moment from '../moment';
5
6 function relativeTimeWithMutation(number, withoutSuffix, key) {
7 var format = {
8 'mm': 'munutenn',
9 'MM': 'miz',
10 'dd': 'devezh'
11 };
12 return number + ' ' + mutation(format[key], number);
13 }
14 function specialMutationForYears(number) {
15 switch (lastNumber(number)) {
16 case 1:
17 case 3:
18 case 4:
19 case 5:
20 case 9:
21 return number + ' bloaz';
22 default:
23 return number + ' vloaz';
24 }
25 }
26 function lastNumber(number) {
27 if (number > 9) {
28 return lastNumber(number % 10);
29 }
30 return number;
31 }
32 function mutation(text, number) {
33 if (number === 2) {
34 return softMutation(text);
35 }
36 return text;
37 }
38 function softMutation(text) {
39 var mutationTable = {
40 'm': 'v',
41 'b': 'v',
42 'd': 'z'
43 };
44 if (mutationTable[text.charAt(0)] === undefined) {
45 return text;
46 }
47 return mutationTable[text.charAt(0)] + text.substring(1);
48 }
49
50 export default moment.defineLocale('br', {
51 months : 'Genver_C\'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'),
52 monthsShort : 'Gen_C\'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'),
53 weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
54 weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
55 weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
56 longDateFormat : {
57 LT : 'h[e]mm A',
58 LTS : 'h[e]mm:ss A',
59 L : 'DD/MM/YYYY',
60 LL : 'D [a viz] MMMM YYYY',
61 LLL : 'D [a viz] MMMM YYYY h[e]mm A',
62 LLLL : 'dddd, D [a viz] MMMM YYYY h[e]mm A'
63 },
64 calendar : {
65 sameDay : '[Hiziv da] LT',
66 nextDay : '[Warc\'hoazh da] LT',
67 nextWeek : 'dddd [da] LT',
68 lastDay : '[Dec\'h da] LT',
69 lastWeek : 'dddd [paset da] LT',
70 sameElse : 'L'
71 },
72 relativeTime : {
73 future : 'a-benn %s',
74 past : '%s \'zo',
75 s : 'un nebeud segondennoù',
76 m : 'ur vunutenn',
77 mm : relativeTimeWithMutation,
78 h : 'un eur',
79 hh : '%d eur',
80 d : 'un devezh',
81 dd : relativeTimeWithMutation,
82 M : 'ur miz',
83 MM : relativeTimeWithMutation,
84 y : 'ur bloaz',
85 yy : specialMutationForYears
86 },
87 ordinalParse: /\d{1,2}(añ|vet)/,
88 ordinal : function (number) {
89 var output = (number === 1) ? 'añ' : 'vet';
90 return number + output;
91 },
92 week : {
93 dow : 1, // Monday is the first day of the week.
94 doy : 4 // The week that contains Jan 4th is the first week of the year.
95 }
96 });
97
0 //! moment.js locale configuration
1 //! locale : bosnian (bs)
2 //! author : Nedim Cholich : https://github.com/frontyard
3 //! based on (hr) translation by Bojan Marković
4
5 import moment from '../moment';
6
7 function translate(number, withoutSuffix, key) {
8 var result = number + ' ';
9 switch (key) {
10 case 'm':
11 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
12 case 'mm':
13 if (number === 1) {
14 result += 'minuta';
15 } else if (number === 2 || number === 3 || number === 4) {
16 result += 'minute';
17 } else {
18 result += 'minuta';
19 }
20 return result;
21 case 'h':
22 return withoutSuffix ? 'jedan sat' : 'jednog sata';
23 case 'hh':
24 if (number === 1) {
25 result += 'sat';
26 } else if (number === 2 || number === 3 || number === 4) {
27 result += 'sata';
28 } else {
29 result += 'sati';
30 }
31 return result;
32 case 'dd':
33 if (number === 1) {
34 result += 'dan';
35 } else {
36 result += 'dana';
37 }
38 return result;
39 case 'MM':
40 if (number === 1) {
41 result += 'mjesec';
42 } else if (number === 2 || number === 3 || number === 4) {
43 result += 'mjeseca';
44 } else {
45 result += 'mjeseci';
46 }
47 return result;
48 case 'yy':
49 if (number === 1) {
50 result += 'godina';
51 } else if (number === 2 || number === 3 || number === 4) {
52 result += 'godine';
53 } else {
54 result += 'godina';
55 }
56 return result;
57 }
58 }
59
60 export default moment.defineLocale('bs', {
61 months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
62 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
63 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
64 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
65 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
66 longDateFormat : {
67 LT : 'H:mm',
68 LTS : 'H:mm:ss',
69 L : 'DD. MM. YYYY',
70 LL : 'D. MMMM YYYY',
71 LLL : 'D. MMMM YYYY H:mm',
72 LLLL : 'dddd, D. MMMM YYYY H:mm'
73 },
74 calendar : {
75 sameDay : '[danas u] LT',
76 nextDay : '[sutra u] LT',
77 nextWeek : function () {
78 switch (this.day()) {
79 case 0:
80 return '[u] [nedjelju] [u] LT';
81 case 3:
82 return '[u] [srijedu] [u] LT';
83 case 6:
84 return '[u] [subotu] [u] LT';
85 case 1:
86 case 2:
87 case 4:
88 case 5:
89 return '[u] dddd [u] LT';
90 }
91 },
92 lastDay : '[jučer u] LT',
93 lastWeek : function () {
94 switch (this.day()) {
95 case 0:
96 case 3:
97 return '[prošlu] dddd [u] LT';
98 case 6:
99 return '[prošle] [subote] [u] LT';
100 case 1:
101 case 2:
102 case 4:
103 case 5:
104 return '[prošli] dddd [u] LT';
105 }
106 },
107 sameElse : 'L'
108 },
109 relativeTime : {
110 future : 'za %s',
111 past : 'prije %s',
112 s : 'par sekundi',
113 m : translate,
114 mm : translate,
115 h : translate,
116 hh : translate,
117 d : 'dan',
118 dd : translate,
119 M : 'mjesec',
120 MM : translate,
121 y : 'godinu',
122 yy : translate
123 },
124 ordinalParse: /\d{1,2}\./,
125 ordinal : '%d.',
126 week : {
127 dow : 1, // Monday is the first day of the week.
128 doy : 7 // The week that contains Jan 1st is the first week of the year.
129 }
130 });
131
0 //! moment.js locale configuration
1 //! locale : catalan (ca)
2 //! author : Juan G. Hurtado : https://github.com/juanghurtado
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('ca', {
7 months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
8 monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
9 weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
10 weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
11 weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
12 longDateFormat : {
13 LT : 'H:mm',
14 LTS : 'LT:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY H:mm',
18 LLLL : 'dddd D MMMM YYYY H:mm'
19 },
20 calendar : {
21 sameDay : function () {
22 return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
23 },
24 nextDay : function () {
25 return '[demà a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
26 },
27 nextWeek : function () {
28 return 'dddd [a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
29 },
30 lastDay : function () {
31 return '[ahir a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
32 },
33 lastWeek : function () {
34 return '[el] dddd [passat a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
35 },
36 sameElse : 'L'
37 },
38 relativeTime : {
39 future : 'en %s',
40 past : 'fa %s',
41 s : 'uns segons',
42 m : 'un minut',
43 mm : '%d minuts',
44 h : 'una hora',
45 hh : '%d hores',
46 d : 'un dia',
47 dd : '%d dies',
48 M : 'un mes',
49 MM : '%d mesos',
50 y : 'un any',
51 yy : '%d anys'
52 },
53 ordinalParse: /\d{1,2}(r|n|t|è|a)/,
54 ordinal : function (number, period) {
55 var output = (number === 1) ? 'r' :
56 (number === 2) ? 'n' :
57 (number === 3) ? 'r' :
58 (number === 4) ? 't' : 'è';
59 if (period === 'w' || period === 'W') {
60 output = 'a';
61 }
62 return number + output;
63 },
64 week : {
65 dow : 1, // Monday is the first day of the week.
66 doy : 4 // The week that contains Jan 4th is the first week of the year.
67 }
68 });
69
0 //! moment.js locale configuration
1 //! locale : czech (cs)
2 //! author : petrbela : https://github.com/petrbela
3
4 import moment from '../moment';
5
6 var months = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_'),
7 monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_');
8 function plural(n) {
9 return (n > 1) && (n < 5) && (~~(n / 10) !== 1);
10 }
11 function translate(number, withoutSuffix, key, isFuture) {
12 var result = number + ' ';
13 switch (key) {
14 case 's': // a few seconds / in a few seconds / a few seconds ago
15 return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
16 case 'm': // a minute / in a minute / a minute ago
17 return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
18 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
19 if (withoutSuffix || isFuture) {
20 return result + (plural(number) ? 'minuty' : 'minut');
21 } else {
22 return result + 'minutami';
23 }
24 break;
25 case 'h': // an hour / in an hour / an hour ago
26 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
27 case 'hh': // 9 hours / in 9 hours / 9 hours ago
28 if (withoutSuffix || isFuture) {
29 return result + (plural(number) ? 'hodiny' : 'hodin');
30 } else {
31 return result + 'hodinami';
32 }
33 break;
34 case 'd': // a day / in a day / a day ago
35 return (withoutSuffix || isFuture) ? 'den' : 'dnem';
36 case 'dd': // 9 days / in 9 days / 9 days ago
37 if (withoutSuffix || isFuture) {
38 return result + (plural(number) ? 'dny' : 'dní');
39 } else {
40 return result + 'dny';
41 }
42 break;
43 case 'M': // a month / in a month / a month ago
44 return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
45 case 'MM': // 9 months / in 9 months / 9 months ago
46 if (withoutSuffix || isFuture) {
47 return result + (plural(number) ? 'měsíce' : 'měsíců');
48 } else {
49 return result + 'měsíci';
50 }
51 break;
52 case 'y': // a year / in a year / a year ago
53 return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
54 case 'yy': // 9 years / in 9 years / 9 years ago
55 if (withoutSuffix || isFuture) {
56 return result + (plural(number) ? 'roky' : 'let');
57 } else {
58 return result + 'lety';
59 }
60 break;
61 }
62 }
63
64 export default moment.defineLocale('cs', {
65 months : months,
66 monthsShort : monthsShort,
67 monthsParse : (function (months, monthsShort) {
68 var i, _monthsParse = [];
69 for (i = 0; i < 12; i++) {
70 // use custom parser to solve problem with July (červenec)
71 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
72 }
73 return _monthsParse;
74 }(months, monthsShort)),
75 weekdays : 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
76 weekdaysShort : 'ne_po_út_st_čt_pá_so'.split('_'),
77 weekdaysMin : 'ne_po_út_st_čt_pá_so'.split('_'),
78 longDateFormat : {
79 LT: 'H:mm',
80 LTS : 'H:mm:ss',
81 L : 'DD.MM.YYYY',
82 LL : 'D. MMMM YYYY',
83 LLL : 'D. MMMM YYYY H:mm',
84 LLLL : 'dddd D. MMMM YYYY H:mm'
85 },
86 calendar : {
87 sameDay: '[dnes v] LT',
88 nextDay: '[zítra v] LT',
89 nextWeek: function () {
90 switch (this.day()) {
91 case 0:
92 return '[v neděli v] LT';
93 case 1:
94 case 2:
95 return '[v] dddd [v] LT';
96 case 3:
97 return '[ve středu v] LT';
98 case 4:
99 return '[ve čtvrtek v] LT';
100 case 5:
101 return '[v pátek v] LT';
102 case 6:
103 return '[v sobotu v] LT';
104 }
105 },
106 lastDay: '[včera v] LT',
107 lastWeek: function () {
108 switch (this.day()) {
109 case 0:
110 return '[minulou neděli v] LT';
111 case 1:
112 case 2:
113 return '[minulé] dddd [v] LT';
114 case 3:
115 return '[minulou středu v] LT';
116 case 4:
117 case 5:
118 return '[minulý] dddd [v] LT';
119 case 6:
120 return '[minulou sobotu v] LT';
121 }
122 },
123 sameElse: 'L'
124 },
125 relativeTime : {
126 future : 'za %s',
127 past : 'před %s',
128 s : translate,
129 m : translate,
130 mm : translate,
131 h : translate,
132 hh : translate,
133 d : translate,
134 dd : translate,
135 M : translate,
136 MM : translate,
137 y : translate,
138 yy : translate
139 },
140 ordinalParse : /\d{1,2}\./,
141 ordinal : '%d.',
142 week : {
143 dow : 1, // Monday is the first day of the week.
144 doy : 4 // The week that contains Jan 4th is the first week of the year.
145 }
146 });
147
0 //! moment.js locale configuration
1 //! locale : chuvash (cv)
2 //! author : Anatoly Mironov : https://github.com/mirontoli
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('cv', {
7 months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
8 monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
9 weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
10 weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
11 weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD-MM-YYYY',
16 LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
17 LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm',
18 LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm'
19 },
20 calendar : {
21 sameDay: '[Паян] LT [сехетре]',
22 nextDay: '[Ыран] LT [сехетре]',
23 lastDay: '[Ӗнер] LT [сехетре]',
24 nextWeek: '[Ҫитес] dddd LT [сехетре]',
25 lastWeek: '[Иртнӗ] dddd LT [сехетре]',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : function (output) {
30 var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
31 return output + affix;
32 },
33 past : '%s каялла',
34 s : 'пӗр-ик ҫеккунт',
35 m : 'пӗр минут',
36 mm : '%d минут',
37 h : 'пӗр сехет',
38 hh : '%d сехет',
39 d : 'пӗр кун',
40 dd : '%d кун',
41 M : 'пӗр уйӑх',
42 MM : '%d уйӑх',
43 y : 'пӗр ҫул',
44 yy : '%d ҫул'
45 },
46 ordinalParse: /\d{1,2}-мӗш/,
47 ordinal : '%d-мӗш',
48 week : {
49 dow : 1, // Monday is the first day of the week.
50 doy : 7 // The week that contains Jan 1st is the first week of the year.
51 }
52 });
0 //! moment.js locale configuration
1 //! locale : Welsh (cy)
2 //! author : Robert Allen
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('cy', {
7 months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'),
8 monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'),
9 weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
10 weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
11 weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
12 // time formats are the same as en-gb
13 longDateFormat: {
14 LT: 'HH:mm',
15 LTS : 'HH:mm:ss',
16 L: 'DD/MM/YYYY',
17 LL: 'D MMMM YYYY',
18 LLL: 'D MMMM YYYY HH:mm',
19 LLLL: 'dddd, D MMMM YYYY HH:mm'
20 },
21 calendar: {
22 sameDay: '[Heddiw am] LT',
23 nextDay: '[Yfory am] LT',
24 nextWeek: 'dddd [am] LT',
25 lastDay: '[Ddoe am] LT',
26 lastWeek: 'dddd [diwethaf am] LT',
27 sameElse: 'L'
28 },
29 relativeTime: {
30 future: 'mewn %s',
31 past: '%s yn ôl',
32 s: 'ychydig eiliadau',
33 m: 'munud',
34 mm: '%d munud',
35 h: 'awr',
36 hh: '%d awr',
37 d: 'diwrnod',
38 dd: '%d diwrnod',
39 M: 'mis',
40 MM: '%d mis',
41 y: 'blwyddyn',
42 yy: '%d flynedd'
43 },
44 ordinalParse: /\d{1,2}(fed|ain|af|il|ydd|ed|eg)/,
45 // traditional ordinal numbers above 31 are not commonly used in colloquial Welsh
46 ordinal: function (number) {
47 var b = number,
48 output = '',
49 lookup = [
50 '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed
51 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed
52 ];
53 if (b > 20) {
54 if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) {
55 output = 'fed'; // not 30ain, 70ain or 90ain
56 } else {
57 output = 'ain';
58 }
59 } else if (b > 0) {
60 output = lookup[b];
61 }
62 return number + output;
63 },
64 week : {
65 dow : 1, // Monday is the first day of the week.
66 doy : 4 // The week that contains Jan 4th is the first week of the year.
67 }
68 });
69
0 //! moment.js locale configuration
1 //! locale : danish (da)
2 //! author : Ulrik Nielsen : https://github.com/mrbase
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('da', {
7 months : 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'),
8 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
9 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
10 weekdaysShort : 'søn_man_tir_ons_tor_fre_lør'.split('_'),
11 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D. MMMM YYYY',
17 LLL : 'D. MMMM YYYY HH:mm',
18 LLLL : 'dddd [d.] D. MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay : '[I dag kl.] LT',
22 nextDay : '[I morgen kl.] LT',
23 nextWeek : 'dddd [kl.] LT',
24 lastDay : '[I går kl.] LT',
25 lastWeek : '[sidste] dddd [kl] LT',
26 sameElse : 'L'
27 },
28 relativeTime : {
29 future : 'om %s',
30 past : '%s siden',
31 s : 'få sekunder',
32 m : 'et minut',
33 mm : '%d minutter',
34 h : 'en time',
35 hh : '%d timer',
36 d : 'en dag',
37 dd : '%d dage',
38 M : 'en måned',
39 MM : '%d måneder',
40 y : 'et år',
41 yy : '%d år'
42 },
43 ordinalParse: /\d{1,2}\./,
44 ordinal : '%d.',
45 week : {
46 dow : 1, // Monday is the first day of the week.
47 doy : 4 // The week that contains Jan 4th is the first week of the year.
48 }
49 });
50
0 //! moment.js locale configuration
1 //! locale : austrian german (de-at)
2 //! author : lluchs : https://github.com/lluchs
3 //! author: Menelion Elensúle: https://github.com/Oire
4 //! author : Martin Groller : https://github.com/MadMG
5
6 import moment from '../moment';
7
8 function processRelativeTime(number, withoutSuffix, key, isFuture) {
9 var format = {
10 'm': ['eine Minute', 'einer Minute'],
11 'h': ['eine Stunde', 'einer Stunde'],
12 'd': ['ein Tag', 'einem Tag'],
13 'dd': [number + ' Tage', number + ' Tagen'],
14 'M': ['ein Monat', 'einem Monat'],
15 'MM': [number + ' Monate', number + ' Monaten'],
16 'y': ['ein Jahr', 'einem Jahr'],
17 'yy': [number + ' Jahre', number + ' Jahren']
18 };
19 return withoutSuffix ? format[key][0] : format[key][1];
20 }
21
22 export default moment.defineLocale('de-at', {
23 months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
24 monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
25 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
26 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
27 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
28 longDateFormat : {
29 LT: 'HH:mm',
30 LTS: 'HH:mm:ss',
31 L : 'DD.MM.YYYY',
32 LL : 'D. MMMM YYYY',
33 LLL : 'D. MMMM YYYY HH:mm',
34 LLLL : 'dddd, D. MMMM YYYY HH:mm'
35 },
36 calendar : {
37 sameDay: '[Heute um] LT [Uhr]',
38 sameElse: 'L',
39 nextDay: '[Morgen um] LT [Uhr]',
40 nextWeek: 'dddd [um] LT [Uhr]',
41 lastDay: '[Gestern um] LT [Uhr]',
42 lastWeek: '[letzten] dddd [um] LT [Uhr]'
43 },
44 relativeTime : {
45 future : 'in %s',
46 past : 'vor %s',
47 s : 'ein paar Sekunden',
48 m : processRelativeTime,
49 mm : '%d Minuten',
50 h : processRelativeTime,
51 hh : '%d Stunden',
52 d : processRelativeTime,
53 dd : processRelativeTime,
54 M : processRelativeTime,
55 MM : processRelativeTime,
56 y : processRelativeTime,
57 yy : processRelativeTime
58 },
59 ordinalParse: /\d{1,2}\./,
60 ordinal : '%d.',
61 week : {
62 dow : 1, // Monday is the first day of the week.
63 doy : 4 // The week that contains Jan 4th is the first week of the year.
64 }
65 });
66
0 //! moment.js locale configuration
1 //! locale : german (de)
2 //! author : lluchs : https://github.com/lluchs
3 //! author: Menelion Elensúle: https://github.com/Oire
4
5 import moment from '../moment';
6
7 function processRelativeTime(number, withoutSuffix, key, isFuture) {
8 var format = {
9 'm': ['eine Minute', 'einer Minute'],
10 'h': ['eine Stunde', 'einer Stunde'],
11 'd': ['ein Tag', 'einem Tag'],
12 'dd': [number + ' Tage', number + ' Tagen'],
13 'M': ['ein Monat', 'einem Monat'],
14 'MM': [number + ' Monate', number + ' Monaten'],
15 'y': ['ein Jahr', 'einem Jahr'],
16 'yy': [number + ' Jahre', number + ' Jahren']
17 };
18 return withoutSuffix ? format[key][0] : format[key][1];
19 }
20
21 export default moment.defineLocale('de', {
22 months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
23 monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
24 weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
25 weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
26 weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
27 longDateFormat : {
28 LT: 'HH:mm',
29 LTS: 'HH:mm:ss',
30 L : 'DD.MM.YYYY',
31 LL : 'D. MMMM YYYY',
32 LLL : 'D. MMMM YYYY HH:mm',
33 LLLL : 'dddd, D. MMMM YYYY HH:mm'
34 },
35 calendar : {
36 sameDay: '[Heute um] LT [Uhr]',
37 sameElse: 'L',
38 nextDay: '[Morgen um] LT [Uhr]',
39 nextWeek: 'dddd [um] LT [Uhr]',
40 lastDay: '[Gestern um] LT [Uhr]',
41 lastWeek: '[letzten] dddd [um] LT [Uhr]'
42 },
43 relativeTime : {
44 future : 'in %s',
45 past : 'vor %s',
46 s : 'ein paar Sekunden',
47 m : processRelativeTime,
48 mm : '%d Minuten',
49 h : processRelativeTime,
50 hh : '%d Stunden',
51 d : processRelativeTime,
52 dd : processRelativeTime,
53 M : processRelativeTime,
54 MM : processRelativeTime,
55 y : processRelativeTime,
56 yy : processRelativeTime
57 },
58 ordinalParse: /\d{1,2}\./,
59 ordinal : '%d.',
60 week : {
61 dow : 1, // Monday is the first day of the week.
62 doy : 4 // The week that contains Jan 4th is the first week of the year.
63 }
64 });
65
0 //! moment.js locale configuration
1 //! locale : modern greek (el)
2 //! author : Aggelos Karalias : https://github.com/mehiel
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('el', {
7 monthsNominativeEl : 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'),
8 monthsGenitiveEl : 'Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου'.split('_'),
9 months : function (momentToFormat, format) {
10 if (/D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
11 return this._monthsGenitiveEl[momentToFormat.month()];
12 } else {
13 return this._monthsNominativeEl[momentToFormat.month()];
14 }
15 },
16 monthsShort : 'Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ'.split('_'),
17 weekdays : 'Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο'.split('_'),
18 weekdaysShort : 'Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ'.split('_'),
19 weekdaysMin : 'Κυ_Δε_Τρ_Τε_Πε_Πα_Σα'.split('_'),
20 meridiem : function (hours, minutes, isLower) {
21 if (hours > 11) {
22 return isLower ? 'μμ' : 'ΜΜ';
23 } else {
24 return isLower ? 'πμ' : 'ΠΜ';
25 }
26 },
27 isPM : function (input) {
28 return ((input + '').toLowerCase()[0] === 'μ');
29 },
30 meridiemParse : /[ΠΜ]\.?Μ?\.?/i,
31 longDateFormat : {
32 LT : 'h:mm A',
33 LTS : 'h:mm:ss A',
34 L : 'DD/MM/YYYY',
35 LL : 'D MMMM YYYY',
36 LLL : 'D MMMM YYYY h:mm A',
37 LLLL : 'dddd, D MMMM YYYY h:mm A'
38 },
39 calendarEl : {
40 sameDay : '[Σήμερα {}] LT',
41 nextDay : '[Αύριο {}] LT',
42 nextWeek : 'dddd [{}] LT',
43 lastDay : '[Χθες {}] LT',
44 lastWeek : function () {
45 switch (this.day()) {
46 case 6:
47 return '[το προηγούμενο] dddd [{}] LT';
48 default:
49 return '[την προηγούμενη] dddd [{}] LT';
50 }
51 },
52 sameElse : 'L'
53 },
54 calendar : function (key, mom) {
55 var output = this._calendarEl[key],
56 hours = mom && mom.hours();
57 if (typeof output === 'function') {
58 output = output.apply(mom);
59 }
60 return output.replace('{}', (hours % 12 === 1 ? 'στη' : 'στις'));
61 },
62 relativeTime : {
63 future : 'σε %s',
64 past : '%s πριν',
65 s : 'λίγα δευτερόλεπτα',
66 m : 'ένα λεπτό',
67 mm : '%d λεπτά',
68 h : 'μία ώρα',
69 hh : '%d ώρες',
70 d : 'μία μέρα',
71 dd : '%d μέρες',
72 M : 'ένας μήνας',
73 MM : '%d μήνες',
74 y : 'ένας χρόνος',
75 yy : '%d χρόνια'
76 },
77 ordinalParse: /\d{1,2}η/,
78 ordinal: '%dη',
79 week : {
80 dow : 1, // Monday is the first day of the week.
81 doy : 4 // The week that contains Jan 4st is the first week of the year.
82 }
83 });
84
0 //! moment.js locale configuration
1 //! locale : australian english (en-au)
2
3 import moment from '../moment';
4
5 export default moment.defineLocale('en-au', {
6 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
7 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
8 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
9 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
10 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
11 longDateFormat : {
12 LT : 'h:mm A',
13 LTS : 'h:mm:ss A',
14 L : 'DD/MM/YYYY',
15 LL : 'D MMMM YYYY',
16 LLL : 'D MMMM YYYY h:mm A',
17 LLLL : 'dddd, D MMMM YYYY h:mm A'
18 },
19 calendar : {
20 sameDay : '[Today at] LT',
21 nextDay : '[Tomorrow at] LT',
22 nextWeek : 'dddd [at] LT',
23 lastDay : '[Yesterday at] LT',
24 lastWeek : '[Last] dddd [at] LT',
25 sameElse : 'L'
26 },
27 relativeTime : {
28 future : 'in %s',
29 past : '%s ago',
30 s : 'a few seconds',
31 m : 'a minute',
32 mm : '%d minutes',
33 h : 'an hour',
34 hh : '%d hours',
35 d : 'a day',
36 dd : '%d days',
37 M : 'a month',
38 MM : '%d months',
39 y : 'a year',
40 yy : '%d years'
41 },
42 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
43 ordinal : function (number) {
44 var b = number % 10,
45 output = (~~(number % 100 / 10) === 1) ? 'th' :
46 (b === 1) ? 'st' :
47 (b === 2) ? 'nd' :
48 (b === 3) ? 'rd' : 'th';
49 return number + output;
50 },
51 week : {
52 dow : 1, // Monday is the first day of the week.
53 doy : 4 // The week that contains Jan 4th is the first week of the year.
54 }
55 });
56
0 //! moment.js locale configuration
1 //! locale : canadian english (en-ca)
2 //! author : Jonathan Abourbih : https://github.com/jonbca
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('en-ca', {
7 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
8 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
9 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
10 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
11 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
12 longDateFormat : {
13 LT : 'h:mm A',
14 LTS : 'h:mm:ss A',
15 L : 'YYYY-MM-DD',
16 LL : 'D MMMM, YYYY',
17 LLL : 'D MMMM, YYYY h:mm A',
18 LLLL : 'dddd, D MMMM, YYYY h:mm A'
19 },
20 calendar : {
21 sameDay : '[Today at] LT',
22 nextDay : '[Tomorrow at] LT',
23 nextWeek : 'dddd [at] LT',
24 lastDay : '[Yesterday at] LT',
25 lastWeek : '[Last] dddd [at] LT',
26 sameElse : 'L'
27 },
28 relativeTime : {
29 future : 'in %s',
30 past : '%s ago',
31 s : 'a few seconds',
32 m : 'a minute',
33 mm : '%d minutes',
34 h : 'an hour',
35 hh : '%d hours',
36 d : 'a day',
37 dd : '%d days',
38 M : 'a month',
39 MM : '%d months',
40 y : 'a year',
41 yy : '%d years'
42 },
43 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
44 ordinal : function (number) {
45 var b = number % 10,
46 output = (~~(number % 100 / 10) === 1) ? 'th' :
47 (b === 1) ? 'st' :
48 (b === 2) ? 'nd' :
49 (b === 3) ? 'rd' : 'th';
50 return number + output;
51 }
52 });
53
0 //! moment.js locale configuration
1 //! locale : great britain english (en-gb)
2 //! author : Chris Gedrim : https://github.com/chrisgedrim
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('en-gb', {
7 months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
8 monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
9 weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
10 weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
11 weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd, D MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay : '[Today at] LT',
22 nextDay : '[Tomorrow at] LT',
23 nextWeek : 'dddd [at] LT',
24 lastDay : '[Yesterday at] LT',
25 lastWeek : '[Last] dddd [at] LT',
26 sameElse : 'L'
27 },
28 relativeTime : {
29 future : 'in %s',
30 past : '%s ago',
31 s : 'a few seconds',
32 m : 'a minute',
33 mm : '%d minutes',
34 h : 'an hour',
35 hh : '%d hours',
36 d : 'a day',
37 dd : '%d days',
38 M : 'a month',
39 MM : '%d months',
40 y : 'a year',
41 yy : '%d years'
42 },
43 ordinalParse: /\d{1,2}(st|nd|rd|th)/,
44 ordinal : function (number) {
45 var b = number % 10,
46 output = (~~(number % 100 / 10) === 1) ? 'th' :
47 (b === 1) ? 'st' :
48 (b === 2) ? 'nd' :
49 (b === 3) ? 'rd' : 'th';
50 return number + output;
51 },
52 week : {
53 dow : 1, // Monday is the first day of the week.
54 doy : 4 // The week that contains Jan 4th is the first week of the year.
55 }
56 });
57
0 //! moment.js locale configuration
1 //! locale : esperanto (eo)
2 //! author : Colin Dean : https://github.com/colindean
3 //! komento: Mi estas malcerta se mi korekte traktis akuzativojn en tiu traduko.
4 //! Se ne, bonvolu korekti kaj avizi min por ke mi povas lerni!
5
6 import moment from '../moment';
7
8 export default moment.defineLocale('eo', {
9 months : 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'),
10 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'),
11 weekdays : 'Dimanĉo_Lundo_Mardo_Merkredo_Ĵaŭdo_Vendredo_Sabato'.split('_'),
12 weekdaysShort : 'Dim_Lun_Mard_Merk_Ĵaŭ_Ven_Sab'.split('_'),
13 weekdaysMin : 'Di_Lu_Ma_Me_Ĵa_Ve_Sa'.split('_'),
14 longDateFormat : {
15 LT : 'HH:mm',
16 LTS : 'HH:mm:ss',
17 L : 'YYYY-MM-DD',
18 LL : 'D[-an de] MMMM, YYYY',
19 LLL : 'D[-an de] MMMM, YYYY HH:mm',
20 LLLL : 'dddd, [la] D[-an de] MMMM, YYYY HH:mm'
21 },
22 meridiemParse: /[ap]\.t\.m/i,
23 isPM: function (input) {
24 return input.charAt(0).toLowerCase() === 'p';
25 },
26 meridiem : function (hours, minutes, isLower) {
27 if (hours > 11) {
28 return isLower ? 'p.t.m.' : 'P.T.M.';
29 } else {
30 return isLower ? 'a.t.m.' : 'A.T.M.';
31 }
32 },
33 calendar : {
34 sameDay : '[Hodiaŭ je] LT',
35 nextDay : '[Morgaŭ je] LT',
36 nextWeek : 'dddd [je] LT',
37 lastDay : '[Hieraŭ je] LT',
38 lastWeek : '[pasinta] dddd [je] LT',
39 sameElse : 'L'
40 },
41 relativeTime : {
42 future : 'je %s',
43 past : 'antaŭ %s',
44 s : 'sekundoj',
45 m : 'minuto',
46 mm : '%d minutoj',
47 h : 'horo',
48 hh : '%d horoj',
49 d : 'tago',//ne 'diurno', ĉar estas uzita por proksimumo
50 dd : '%d tagoj',
51 M : 'monato',
52 MM : '%d monatoj',
53 y : 'jaro',
54 yy : '%d jaroj'
55 },
56 ordinalParse: /\d{1,2}a/,
57 ordinal : '%da',
58 week : {
59 dow : 1, // Monday is the first day of the week.
60 doy : 7 // The week that contains Jan 1st is the first week of the year.
61 }
62 });
63
0 //! moment.js locale configuration
1 //! locale : spanish (es)
2 //! author : Julio Napurí : https://github.com/julionc
3
4 import moment from '../moment';
5
6 var monthsShortDot = 'Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.'.split('_'),
7 monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
8
9 export default moment.defineLocale('es', {
10 months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
11 monthsShort : function (m, format) {
12 if (/-MMM-/.test(format)) {
13 return monthsShort[m.month()];
14 } else {
15 return monthsShortDot[m.month()];
16 }
17 },
18 weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
19 weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
20 weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
21 longDateFormat : {
22 LT : 'H:mm',
23 LTS : 'H:mm:ss',
24 L : 'DD/MM/YYYY',
25 LL : 'D [de] MMMM [de] YYYY',
26 LLL : 'D [de] MMMM [de] YYYY H:mm',
27 LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
28 },
29 calendar : {
30 sameDay : function () {
31 return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
32 },
33 nextDay : function () {
34 return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
35 },
36 nextWeek : function () {
37 return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
38 },
39 lastDay : function () {
40 return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
41 },
42 lastWeek : function () {
43 return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
44 },
45 sameElse : 'L'
46 },
47 relativeTime : {
48 future : 'en %s',
49 past : 'hace %s',
50 s : 'unos segundos',
51 m : 'un minuto',
52 mm : '%d minutos',
53 h : 'una hora',
54 hh : '%d horas',
55 d : 'un día',
56 dd : '%d días',
57 M : 'un mes',
58 MM : '%d meses',
59 y : 'un año',
60 yy : '%d años'
61 },
62 ordinalParse : /\d{1,2}º/,
63 ordinal : '%dº',
64 week : {
65 dow : 1, // Monday is the first day of the week.
66 doy : 4 // The week that contains Jan 4th is the first week of the year.
67 }
68 });
69
0 //! moment.js locale configuration
1 //! locale : estonian (et)
2 //! author : Henry Kehlmann : https://github.com/madhenry
3 //! improvements : Illimar Tambek : https://github.com/ragulka
4
5 import moment from '../moment';
6
7 function processRelativeTime(number, withoutSuffix, key, isFuture) {
8 var format = {
9 's' : ['mõne sekundi', 'mõni sekund', 'paar sekundit'],
10 'm' : ['ühe minuti', 'üks minut'],
11 'mm': [number + ' minuti', number + ' minutit'],
12 'h' : ['ühe tunni', 'tund aega', 'üks tund'],
13 'hh': [number + ' tunni', number + ' tundi'],
14 'd' : ['ühe päeva', 'üks päev'],
15 'M' : ['kuu aja', 'kuu aega', 'üks kuu'],
16 'MM': [number + ' kuu', number + ' kuud'],
17 'y' : ['ühe aasta', 'aasta', 'üks aasta'],
18 'yy': [number + ' aasta', number + ' aastat']
19 };
20 if (withoutSuffix) {
21 return format[key][2] ? format[key][2] : format[key][1];
22 }
23 return isFuture ? format[key][0] : format[key][1];
24 }
25
26 export default moment.defineLocale('et', {
27 months : 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'),
28 monthsShort : 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'),
29 weekdays : 'pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev'.split('_'),
30 weekdaysShort : 'P_E_T_K_N_R_L'.split('_'),
31 weekdaysMin : 'P_E_T_K_N_R_L'.split('_'),
32 longDateFormat : {
33 LT : 'H:mm',
34 LTS : 'H:mm:ss',
35 L : 'DD.MM.YYYY',
36 LL : 'D. MMMM YYYY',
37 LLL : 'D. MMMM YYYY H:mm',
38 LLLL : 'dddd, D. MMMM YYYY H:mm'
39 },
40 calendar : {
41 sameDay : '[Täna,] LT',
42 nextDay : '[Homme,] LT',
43 nextWeek : '[Järgmine] dddd LT',
44 lastDay : '[Eile,] LT',
45 lastWeek : '[Eelmine] dddd LT',
46 sameElse : 'L'
47 },
48 relativeTime : {
49 future : '%s pärast',
50 past : '%s tagasi',
51 s : processRelativeTime,
52 m : processRelativeTime,
53 mm : processRelativeTime,
54 h : processRelativeTime,
55 hh : processRelativeTime,
56 d : processRelativeTime,
57 dd : '%d päeva',
58 M : processRelativeTime,
59 MM : processRelativeTime,
60 y : processRelativeTime,
61 yy : processRelativeTime
62 },
63 ordinalParse: /\d{1,2}\./,
64 ordinal : '%d.',
65 week : {
66 dow : 1, // Monday is the first day of the week.
67 doy : 4 // The week that contains Jan 4th is the first week of the year.
68 }
69 });
70
0 //! moment.js locale configuration
1 //! locale : euskara (eu)
2 //! author : Eneko Illarramendi : https://github.com/eillarra
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('eu', {
7 months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
8 monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
9 weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
10 weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
11 weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'YYYY-MM-DD',
16 LL : 'YYYY[ko] MMMM[ren] D[a]',
17 LLL : 'YYYY[ko] MMMM[ren] D[a] HH:mm',
18 LLLL : 'dddd, YYYY[ko] MMMM[ren] D[a] HH:mm',
19 l : 'YYYY-M-D',
20 ll : 'YYYY[ko] MMM D[a]',
21 lll : 'YYYY[ko] MMM D[a] HH:mm',
22 llll : 'ddd, YYYY[ko] MMM D[a] HH:mm'
23 },
24 calendar : {
25 sameDay : '[gaur] LT[etan]',
26 nextDay : '[bihar] LT[etan]',
27 nextWeek : 'dddd LT[etan]',
28 lastDay : '[atzo] LT[etan]',
29 lastWeek : '[aurreko] dddd LT[etan]',
30 sameElse : 'L'
31 },
32 relativeTime : {
33 future : '%s barru',
34 past : 'duela %s',
35 s : 'segundo batzuk',
36 m : 'minutu bat',
37 mm : '%d minutu',
38 h : 'ordu bat',
39 hh : '%d ordu',
40 d : 'egun bat',
41 dd : '%d egun',
42 M : 'hilabete bat',
43 MM : '%d hilabete',
44 y : 'urte bat',
45 yy : '%d urte'
46 },
47 ordinalParse: /\d{1,2}\./,
48 ordinal : '%d.',
49 week : {
50 dow : 1, // Monday is the first day of the week.
51 doy : 7 // The week that contains Jan 1st is the first week of the year.
52 }
53 });
54
0 //! moment.js locale configuration
1 //! locale : Persian (fa)
2 //! author : Ebrahim Byagowi : https://github.com/ebraminio
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '۱',
8 '2': '۲',
9 '3': '۳',
10 '4': '۴',
11 '5': '۵',
12 '6': '۶',
13 '7': '۷',
14 '8': '۸',
15 '9': '۹',
16 '0': '۰'
17 }, numberMap = {
18 '۱': '1',
19 '۲': '2',
20 '۳': '3',
21 '۴': '4',
22 '۵': '5',
23 '۶': '6',
24 '۷': '7',
25 '۸': '8',
26 '۹': '9',
27 '۰': '0'
28 };
29
30 export default moment.defineLocale('fa', {
31 months : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
32 monthsShort : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
33 weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
34 weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
35 weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
36 longDateFormat : {
37 LT : 'HH:mm',
38 LTS : 'HH:mm:ss',
39 L : 'DD/MM/YYYY',
40 LL : 'D MMMM YYYY',
41 LLL : 'D MMMM YYYY HH:mm',
42 LLLL : 'dddd, D MMMM YYYY HH:mm'
43 },
44 meridiemParse: /قبل از ظهر|بعد از ظهر/,
45 isPM: function (input) {
46 return /بعد از ظهر/.test(input);
47 },
48 meridiem : function (hour, minute, isLower) {
49 if (hour < 12) {
50 return 'قبل از ظهر';
51 } else {
52 return 'بعد از ظهر';
53 }
54 },
55 calendar : {
56 sameDay : '[امروز ساعت] LT',
57 nextDay : '[فردا ساعت] LT',
58 nextWeek : 'dddd [ساعت] LT',
59 lastDay : '[دیروز ساعت] LT',
60 lastWeek : 'dddd [پیش] [ساعت] LT',
61 sameElse : 'L'
62 },
63 relativeTime : {
64 future : 'در %s',
65 past : '%s پیش',
66 s : 'چندین ثانیه',
67 m : 'یک دقیقه',
68 mm : '%d دقیقه',
69 h : 'یک ساعت',
70 hh : '%d ساعت',
71 d : 'یک روز',
72 dd : '%d روز',
73 M : 'یک ماه',
74 MM : '%d ماه',
75 y : 'یک سال',
76 yy : '%d سال'
77 },
78 preparse: function (string) {
79 return string.replace(/[۰-۹]/g, function (match) {
80 return numberMap[match];
81 }).replace(/،/g, ',');
82 },
83 postformat: function (string) {
84 return string.replace(/\d/g, function (match) {
85 return symbolMap[match];
86 }).replace(/,/g, '،');
87 },
88 ordinalParse: /\d{1,2}م/,
89 ordinal : '%dم',
90 week : {
91 dow : 6, // Saturday is the first day of the week.
92 doy : 12 // The week that contains Jan 1st is the first week of the year.
93 }
94 });
95
0 //! moment.js locale configuration
1 //! locale : finnish (fi)
2 //! author : Tarmo Aidantausta : https://github.com/bleadof
3
4 import moment from '../moment';
5
6 var numbersPast = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' '),
7 numbersFuture = [
8 'nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
9 numbersPast[7], numbersPast[8], numbersPast[9]
10 ];
11 function translate(number, withoutSuffix, key, isFuture) {
12 var result = '';
13 switch (key) {
14 case 's':
15 return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
16 case 'm':
17 return isFuture ? 'minuutin' : 'minuutti';
18 case 'mm':
19 result = isFuture ? 'minuutin' : 'minuuttia';
20 break;
21 case 'h':
22 return isFuture ? 'tunnin' : 'tunti';
23 case 'hh':
24 result = isFuture ? 'tunnin' : 'tuntia';
25 break;
26 case 'd':
27 return isFuture ? 'päivän' : 'päivä';
28 case 'dd':
29 result = isFuture ? 'päivän' : 'päivää';
30 break;
31 case 'M':
32 return isFuture ? 'kuukauden' : 'kuukausi';
33 case 'MM':
34 result = isFuture ? 'kuukauden' : 'kuukautta';
35 break;
36 case 'y':
37 return isFuture ? 'vuoden' : 'vuosi';
38 case 'yy':
39 result = isFuture ? 'vuoden' : 'vuotta';
40 break;
41 }
42 result = verbalNumber(number, isFuture) + ' ' + result;
43 return result;
44 }
45 function verbalNumber(number, isFuture) {
46 return number < 10 ? (isFuture ? numbersFuture[number] : numbersPast[number]) : number;
47 }
48
49 export default moment.defineLocale('fi', {
50 months : 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'),
51 monthsShort : 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'),
52 weekdays : 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'),
53 weekdaysShort : 'su_ma_ti_ke_to_pe_la'.split('_'),
54 weekdaysMin : 'su_ma_ti_ke_to_pe_la'.split('_'),
55 longDateFormat : {
56 LT : 'HH.mm',
57 LTS : 'HH.mm.ss',
58 L : 'DD.MM.YYYY',
59 LL : 'Do MMMM[ta] YYYY',
60 LLL : 'Do MMMM[ta] YYYY, [klo] HH.mm',
61 LLLL : 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm',
62 l : 'D.M.YYYY',
63 ll : 'Do MMM YYYY',
64 lll : 'Do MMM YYYY, [klo] HH.mm',
65 llll : 'ddd, Do MMM YYYY, [klo] HH.mm'
66 },
67 calendar : {
68 sameDay : '[tänään] [klo] LT',
69 nextDay : '[huomenna] [klo] LT',
70 nextWeek : 'dddd [klo] LT',
71 lastDay : '[eilen] [klo] LT',
72 lastWeek : '[viime] dddd[na] [klo] LT',
73 sameElse : 'L'
74 },
75 relativeTime : {
76 future : '%s päästä',
77 past : '%s sitten',
78 s : translate,
79 m : translate,
80 mm : translate,
81 h : translate,
82 hh : translate,
83 d : translate,
84 dd : translate,
85 M : translate,
86 MM : translate,
87 y : translate,
88 yy : translate
89 },
90 ordinalParse: /\d{1,2}\./,
91 ordinal : '%d.',
92 week : {
93 dow : 1, // Monday is the first day of the week.
94 doy : 4 // The week that contains Jan 4th is the first week of the year.
95 }
96 });
97
0 //! moment.js locale configuration
1 //! locale : faroese (fo)
2 //! author : Ragnar Johannesen : https://github.com/ragnar123
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('fo', {
7 months : 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
8 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
9 weekdays : 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'),
10 weekdaysShort : 'sun_mán_týs_mik_hós_frí_ley'.split('_'),
11 weekdaysMin : 'su_má_tý_mi_hó_fr_le'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd D. MMMM, YYYY HH:mm'
19 },
20 calendar : {
21 sameDay : '[Í dag kl.] LT',
22 nextDay : '[Í morgin kl.] LT',
23 nextWeek : 'dddd [kl.] LT',
24 lastDay : '[Í gjár kl.] LT',
25 lastWeek : '[síðstu] dddd [kl] LT',
26 sameElse : 'L'
27 },
28 relativeTime : {
29 future : 'um %s',
30 past : '%s síðani',
31 s : 'fá sekund',
32 m : 'ein minutt',
33 mm : '%d minuttir',
34 h : 'ein tími',
35 hh : '%d tímar',
36 d : 'ein dagur',
37 dd : '%d dagar',
38 M : 'ein mánaði',
39 MM : '%d mánaðir',
40 y : 'eitt ár',
41 yy : '%d ár'
42 },
43 ordinalParse: /\d{1,2}\./,
44 ordinal : '%d.',
45 week : {
46 dow : 1, // Monday is the first day of the week.
47 doy : 4 // The week that contains Jan 4th is the first week of the year.
48 }
49 });
50
0 //! moment.js locale configuration
1 //! locale : canadian french (fr-ca)
2 //! author : Jonathan Abourbih : https://github.com/jonbca
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('fr-ca', {
7 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
8 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
9 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
10 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
11 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'YYYY-MM-DD',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd D MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[Aujourd\'hui à] LT',
22 nextDay: '[Demain à] LT',
23 nextWeek: 'dddd [à] LT',
24 lastDay: '[Hier à] LT',
25 lastWeek: 'dddd [dernier à] LT',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : 'dans %s',
30 past : 'il y a %s',
31 s : 'quelques secondes',
32 m : 'une minute',
33 mm : '%d minutes',
34 h : 'une heure',
35 hh : '%d heures',
36 d : 'un jour',
37 dd : '%d jours',
38 M : 'un mois',
39 MM : '%d mois',
40 y : 'un an',
41 yy : '%d ans'
42 },
43 ordinalParse: /\d{1,2}(er|e)/,
44 ordinal : function (number) {
45 return number + (number === 1 ? 'er' : 'e');
46 }
47 });
48
0 //! moment.js locale configuration
1 //! locale : french (fr)
2 //! author : John Fischer : https://github.com/jfroffice
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('fr', {
7 months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
8 monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
9 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
10 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
11 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd D MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[Aujourd\'hui à] LT',
22 nextDay: '[Demain à] LT',
23 nextWeek: 'dddd [à] LT',
24 lastDay: '[Hier à] LT',
25 lastWeek: 'dddd [dernier à] LT',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : 'dans %s',
30 past : 'il y a %s',
31 s : 'quelques secondes',
32 m : 'une minute',
33 mm : '%d minutes',
34 h : 'une heure',
35 hh : '%d heures',
36 d : 'un jour',
37 dd : '%d jours',
38 M : 'un mois',
39 MM : '%d mois',
40 y : 'un an',
41 yy : '%d ans'
42 },
43 ordinalParse: /\d{1,2}(er|)/,
44 ordinal : function (number) {
45 return number + (number === 1 ? 'er' : '');
46 },
47 week : {
48 dow : 1, // Monday is the first day of the week.
49 doy : 4 // The week that contains Jan 4th is the first week of the year.
50 }
51 });
52
0 //! moment.js locale configuration
1 //! locale : frisian (fy)
2 //! author : Robin van der Vliet : https://github.com/robin0van0der0v
3
4 import moment from '../moment';
5
6 var monthsShortWithDots = 'jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.'.split('_'),
7 monthsShortWithoutDots = 'jan_feb_mrt_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_');
8
9 export default moment.defineLocale('fy', {
10 months : 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'),
11 monthsShort : function (m, format) {
12 if (/-MMM-/.test(format)) {
13 return monthsShortWithoutDots[m.month()];
14 } else {
15 return monthsShortWithDots[m.month()];
16 }
17 },
18 weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
19 weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
20 weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
21 longDateFormat : {
22 LT : 'HH:mm',
23 LTS : 'HH:mm:ss',
24 L : 'DD-MM-YYYY',
25 LL : 'D MMMM YYYY',
26 LLL : 'D MMMM YYYY HH:mm',
27 LLLL : 'dddd D MMMM YYYY HH:mm'
28 },
29 calendar : {
30 sameDay: '[hjoed om] LT',
31 nextDay: '[moarn om] LT',
32 nextWeek: 'dddd [om] LT',
33 lastDay: '[juster om] LT',
34 lastWeek: '[ôfrûne] dddd [om] LT',
35 sameElse: 'L'
36 },
37 relativeTime : {
38 future : 'oer %s',
39 past : '%s lyn',
40 s : 'in pear sekonden',
41 m : 'ien minút',
42 mm : '%d minuten',
43 h : 'ien oere',
44 hh : '%d oeren',
45 d : 'ien dei',
46 dd : '%d dagen',
47 M : 'ien moanne',
48 MM : '%d moannen',
49 y : 'ien jier',
50 yy : '%d jierren'
51 },
52 ordinalParse: /\d{1,2}(ste|de)/,
53 ordinal : function (number) {
54 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
55 },
56 week : {
57 dow : 1, // Monday is the first day of the week.
58 doy : 4 // The week that contains Jan 4th is the first week of the year.
59 }
60 });
61
0 //! moment.js locale configuration
1 //! locale : galician (gl)
2 //! author : Juan G. Hurtado : https://github.com/juanghurtado
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('gl', {
7 months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
8 monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
9 weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
10 weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
11 weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
12 longDateFormat : {
13 LT : 'H:mm',
14 LTS : 'H:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY H:mm',
18 LLLL : 'dddd D MMMM YYYY H:mm'
19 },
20 calendar : {
21 sameDay : function () {
22 return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
23 },
24 nextDay : function () {
25 return '[mañá ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
26 },
27 nextWeek : function () {
28 return 'dddd [' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
29 },
30 lastDay : function () {
31 return '[onte ' + ((this.hours() !== 1) ? 'á' : 'a') + '] LT';
32 },
33 lastWeek : function () {
34 return '[o] dddd [pasado ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
35 },
36 sameElse : 'L'
37 },
38 relativeTime : {
39 future : function (str) {
40 if (str === 'uns segundos') {
41 return 'nuns segundos';
42 }
43 return 'en ' + str;
44 },
45 past : 'hai %s',
46 s : 'uns segundos',
47 m : 'un minuto',
48 mm : '%d minutos',
49 h : 'unha hora',
50 hh : '%d horas',
51 d : 'un día',
52 dd : '%d días',
53 M : 'un mes',
54 MM : '%d meses',
55 y : 'un ano',
56 yy : '%d anos'
57 },
58 ordinalParse : /\d{1,2}º/,
59 ordinal : '%dº',
60 week : {
61 dow : 1, // Monday is the first day of the week.
62 doy : 7 // The week that contains Jan 1st is the first week of the year.
63 }
64 });
65
0 //! moment.js locale configuration
1 //! locale : Hebrew (he)
2 //! author : Tomer Cohen : https://github.com/tomer
3 //! author : Moshe Simantov : https://github.com/DevelopmentIL
4 //! author : Tal Ater : https://github.com/TalAter
5
6 import moment from '../moment';
7
8 export default moment.defineLocale('he', {
9 months : 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'),
10 monthsShort : 'ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳'.split('_'),
11 weekdays : 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'),
12 weekdaysShort : 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'),
13 weekdaysMin : 'א_ב_ג_ד_ה_ו_ש'.split('_'),
14 longDateFormat : {
15 LT : 'HH:mm',
16 LTS : 'HH:mm:ss',
17 L : 'DD/MM/YYYY',
18 LL : 'D [ב]MMMM YYYY',
19 LLL : 'D [ב]MMMM YYYY HH:mm',
20 LLLL : 'dddd, D [ב]MMMM YYYY HH:mm',
21 l : 'D/M/YYYY',
22 ll : 'D MMM YYYY',
23 lll : 'D MMM YYYY HH:mm',
24 llll : 'ddd, D MMM YYYY HH:mm'
25 },
26 calendar : {
27 sameDay : '[היום ב־]LT',
28 nextDay : '[מחר ב־]LT',
29 nextWeek : 'dddd [בשעה] LT',
30 lastDay : '[אתמול ב־]LT',
31 lastWeek : '[ביום] dddd [האחרון בשעה] LT',
32 sameElse : 'L'
33 },
34 relativeTime : {
35 future : 'בעוד %s',
36 past : 'לפני %s',
37 s : 'מספר שניות',
38 m : 'דקה',
39 mm : '%d דקות',
40 h : 'שעה',
41 hh : function (number) {
42 if (number === 2) {
43 return 'שעתיים';
44 }
45 return number + ' שעות';
46 },
47 d : 'יום',
48 dd : function (number) {
49 if (number === 2) {
50 return 'יומיים';
51 }
52 return number + ' ימים';
53 },
54 M : 'חודש',
55 MM : function (number) {
56 if (number === 2) {
57 return 'חודשיים';
58 }
59 return number + ' חודשים';
60 },
61 y : 'שנה',
62 yy : function (number) {
63 if (number === 2) {
64 return 'שנתיים';
65 } else if (number % 10 === 0 && number !== 10) {
66 return number + ' שנה';
67 }
68 return number + ' שנים';
69 }
70 }
71 });
72
0 //! moment.js locale configuration
1 //! locale : hindi (hi)
2 //! author : Mayank Singhal : https://github.com/mayanksinghal
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '१',
8 '2': '२',
9 '3': '३',
10 '4': '४',
11 '5': '५',
12 '6': '६',
13 '7': '७',
14 '8': '८',
15 '9': '९',
16 '0': '०'
17 },
18 numberMap = {
19 '१': '1',
20 '२': '2',
21 '३': '3',
22 '४': '4',
23 '५': '5',
24 '६': '6',
25 '७': '7',
26 '८': '8',
27 '९': '9',
28 '०': '0'
29 };
30
31 export default moment.defineLocale('hi', {
32 months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
33 monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
34 weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
35 weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
36 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
37 longDateFormat : {
38 LT : 'A h:mm बजे',
39 LTS : 'A h:mm:ss बजे',
40 L : 'DD/MM/YYYY',
41 LL : 'D MMMM YYYY',
42 LLL : 'D MMMM YYYY, A h:mm बजे',
43 LLLL : 'dddd, D MMMM YYYY, A h:mm बजे'
44 },
45 calendar : {
46 sameDay : '[आज] LT',
47 nextDay : '[कल] LT',
48 nextWeek : 'dddd, LT',
49 lastDay : '[कल] LT',
50 lastWeek : '[पिछले] dddd, LT',
51 sameElse : 'L'
52 },
53 relativeTime : {
54 future : '%s में',
55 past : '%s पहले',
56 s : 'कुछ ही क्षण',
57 m : 'एक मिनट',
58 mm : '%d मिनट',
59 h : 'एक घंटा',
60 hh : '%d घंटे',
61 d : 'एक दिन',
62 dd : '%d दिन',
63 M : 'एक महीने',
64 MM : '%d महीने',
65 y : 'एक वर्ष',
66 yy : '%d वर्ष'
67 },
68 preparse: function (string) {
69 return string.replace(/[१२३४५६७८९०]/g, function (match) {
70 return numberMap[match];
71 });
72 },
73 postformat: function (string) {
74 return string.replace(/\d/g, function (match) {
75 return symbolMap[match];
76 });
77 },
78 // Hindi notation for meridiems are quite fuzzy in practice. While there exists
79 // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
80 meridiemParse: /रात|सुबह|दोपहर|शाम/,
81 meridiemHour : function (hour, meridiem) {
82 if (hour === 12) {
83 hour = 0;
84 }
85 if (meridiem === 'रात') {
86 return hour < 4 ? hour : hour + 12;
87 } else if (meridiem === 'सुबह') {
88 return hour;
89 } else if (meridiem === 'दोपहर') {
90 return hour >= 10 ? hour : hour + 12;
91 } else if (meridiem === 'शाम') {
92 return hour + 12;
93 }
94 },
95 meridiem : function (hour, minute, isLower) {
96 if (hour < 4) {
97 return 'रात';
98 } else if (hour < 10) {
99 return 'सुबह';
100 } else if (hour < 17) {
101 return 'दोपहर';
102 } else if (hour < 20) {
103 return 'शाम';
104 } else {
105 return 'रात';
106 }
107 },
108 week : {
109 dow : 0, // Sunday is the first day of the week.
110 doy : 6 // The week that contains Jan 1st is the first week of the year.
111 }
112 });
113
0 //! moment.js locale configuration
1 //! locale : hrvatski (hr)
2 //! author : Bojan Marković : https://github.com/bmarkovic
3
4 import moment from '../moment';
5
6 function translate(number, withoutSuffix, key) {
7 var result = number + ' ';
8 switch (key) {
9 case 'm':
10 return withoutSuffix ? 'jedna minuta' : 'jedne minute';
11 case 'mm':
12 if (number === 1) {
13 result += 'minuta';
14 } else if (number === 2 || number === 3 || number === 4) {
15 result += 'minute';
16 } else {
17 result += 'minuta';
18 }
19 return result;
20 case 'h':
21 return withoutSuffix ? 'jedan sat' : 'jednog sata';
22 case 'hh':
23 if (number === 1) {
24 result += 'sat';
25 } else if (number === 2 || number === 3 || number === 4) {
26 result += 'sata';
27 } else {
28 result += 'sati';
29 }
30 return result;
31 case 'dd':
32 if (number === 1) {
33 result += 'dan';
34 } else {
35 result += 'dana';
36 }
37 return result;
38 case 'MM':
39 if (number === 1) {
40 result += 'mjesec';
41 } else if (number === 2 || number === 3 || number === 4) {
42 result += 'mjeseca';
43 } else {
44 result += 'mjeseci';
45 }
46 return result;
47 case 'yy':
48 if (number === 1) {
49 result += 'godina';
50 } else if (number === 2 || number === 3 || number === 4) {
51 result += 'godine';
52 } else {
53 result += 'godina';
54 }
55 return result;
56 }
57 }
58
59 export default moment.defineLocale('hr', {
60 months : 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
61 monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
62 weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
63 weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
64 weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
65 longDateFormat : {
66 LT : 'H:mm',
67 LTS : 'H:mm:ss',
68 L : 'DD. MM. YYYY',
69 LL : 'D. MMMM YYYY',
70 LLL : 'D. MMMM YYYY H:mm',
71 LLLL : 'dddd, D. MMMM YYYY H:mm'
72 },
73 calendar : {
74 sameDay : '[danas u] LT',
75 nextDay : '[sutra u] LT',
76 nextWeek : function () {
77 switch (this.day()) {
78 case 0:
79 return '[u] [nedjelju] [u] LT';
80 case 3:
81 return '[u] [srijedu] [u] LT';
82 case 6:
83 return '[u] [subotu] [u] LT';
84 case 1:
85 case 2:
86 case 4:
87 case 5:
88 return '[u] dddd [u] LT';
89 }
90 },
91 lastDay : '[jučer u] LT',
92 lastWeek : function () {
93 switch (this.day()) {
94 case 0:
95 case 3:
96 return '[prošlu] dddd [u] LT';
97 case 6:
98 return '[prošle] [subote] [u] LT';
99 case 1:
100 case 2:
101 case 4:
102 case 5:
103 return '[prošli] dddd [u] LT';
104 }
105 },
106 sameElse : 'L'
107 },
108 relativeTime : {
109 future : 'za %s',
110 past : 'prije %s',
111 s : 'par sekundi',
112 m : translate,
113 mm : translate,
114 h : translate,
115 hh : translate,
116 d : 'dan',
117 dd : translate,
118 M : 'mjesec',
119 MM : translate,
120 y : 'godinu',
121 yy : translate
122 },
123 ordinalParse: /\d{1,2}\./,
124 ordinal : '%d.',
125 week : {
126 dow : 1, // Monday is the first day of the week.
127 doy : 7 // The week that contains Jan 1st is the first week of the year.
128 }
129 });
130
0 //! moment.js locale configuration
1 //! locale : hungarian (hu)
2 //! author : Adam Brunner : https://github.com/adambrunner
3
4 import moment from '../moment';
5
6 var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
7 function translate(number, withoutSuffix, key, isFuture) {
8 var num = number,
9 suffix;
10 switch (key) {
11 case 's':
12 return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
13 case 'm':
14 return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
15 case 'mm':
16 return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
17 case 'h':
18 return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
19 case 'hh':
20 return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
21 case 'd':
22 return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
23 case 'dd':
24 return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
25 case 'M':
26 return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
27 case 'MM':
28 return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
29 case 'y':
30 return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
31 case 'yy':
32 return num + (isFuture || withoutSuffix ? ' év' : ' éve');
33 }
34 return '';
35 }
36 function week(isFuture) {
37 return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[this.day()] + '] LT[-kor]';
38 }
39
40 export default moment.defineLocale('hu', {
41 months : 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
42 monthsShort : 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
43 weekdays : 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'),
44 weekdaysShort : 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'),
45 weekdaysMin : 'v_h_k_sze_cs_p_szo'.split('_'),
46 longDateFormat : {
47 LT : 'H:mm',
48 LTS : 'H:mm:ss',
49 L : 'YYYY.MM.DD.',
50 LL : 'YYYY. MMMM D.',
51 LLL : 'YYYY. MMMM D. H:mm',
52 LLLL : 'YYYY. MMMM D., dddd H:mm'
53 },
54 meridiemParse: /de|du/i,
55 isPM: function (input) {
56 return input.charAt(1).toLowerCase() === 'u';
57 },
58 meridiem : function (hours, minutes, isLower) {
59 if (hours < 12) {
60 return isLower === true ? 'de' : 'DE';
61 } else {
62 return isLower === true ? 'du' : 'DU';
63 }
64 },
65 calendar : {
66 sameDay : '[ma] LT[-kor]',
67 nextDay : '[holnap] LT[-kor]',
68 nextWeek : function () {
69 return week.call(this, true);
70 },
71 lastDay : '[tegnap] LT[-kor]',
72 lastWeek : function () {
73 return week.call(this, false);
74 },
75 sameElse : 'L'
76 },
77 relativeTime : {
78 future : '%s múlva',
79 past : '%s',
80 s : translate,
81 m : translate,
82 mm : translate,
83 h : translate,
84 hh : translate,
85 d : translate,
86 dd : translate,
87 M : translate,
88 MM : translate,
89 y : translate,
90 yy : translate
91 },
92 ordinalParse: /\d{1,2}\./,
93 ordinal : '%d.',
94 week : {
95 dow : 1, // Monday is the first day of the week.
96 doy : 7 // The week that contains Jan 1st is the first week of the year.
97 }
98 });
99
0 //! moment.js locale configuration
1 //! locale : Armenian (hy-am)
2 //! author : Armendarabyan : https://github.com/armendarabyan
3
4 import moment from '../moment';
5
6 function monthsCaseReplace(m, format) {
7 var months = {
8 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
9 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
10 },
11 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
12 'accusative' :
13 'nominative';
14 return months[nounCase][m.month()];
15 }
16 function monthsShortCaseReplace(m, format) {
17 var monthsShort = 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_');
18 return monthsShort[m.month()];
19 }
20 function weekdaysCaseReplace(m, format) {
21 var weekdays = 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_');
22 return weekdays[m.day()];
23 }
24
25 export default moment.defineLocale('hy-am', {
26 months : monthsCaseReplace,
27 monthsShort : monthsShortCaseReplace,
28 weekdays : weekdaysCaseReplace,
29 weekdaysShort : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
30 weekdaysMin : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
31 longDateFormat : {
32 LT : 'HH:mm',
33 LTS : 'HH:mm:ss',
34 L : 'DD.MM.YYYY',
35 LL : 'D MMMM YYYY թ.',
36 LLL : 'D MMMM YYYY թ., HH:mm',
37 LLLL : 'dddd, D MMMM YYYY թ., HH:mm'
38 },
39 calendar : {
40 sameDay: '[այսօր] LT',
41 nextDay: '[վաղը] LT',
42 lastDay: '[երեկ] LT',
43 nextWeek: function () {
44 return 'dddd [օրը ժամը] LT';
45 },
46 lastWeek: function () {
47 return '[անցած] dddd [օրը ժամը] LT';
48 },
49 sameElse: 'L'
50 },
51 relativeTime : {
52 future : '%s հետո',
53 past : '%s առաջ',
54 s : 'մի քանի վայրկյան',
55 m : 'րոպե',
56 mm : '%d րոպե',
57 h : 'ժամ',
58 hh : '%d ժամ',
59 d : 'օր',
60 dd : '%d օր',
61 M : 'ամիս',
62 MM : '%d ամիս',
63 y : 'տարի',
64 yy : '%d տարի'
65 },
66 meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
67 isPM: function (input) {
68 return /^(ցերեկվա|երեկոյան)$/.test(input);
69 },
70 meridiem : function (hour) {
71 if (hour < 4) {
72 return 'գիշերվա';
73 } else if (hour < 12) {
74 return 'առավոտվա';
75 } else if (hour < 17) {
76 return 'ցերեկվա';
77 } else {
78 return 'երեկոյան';
79 }
80 },
81 ordinalParse: /\d{1,2}|\d{1,2}-(ին|րդ)/,
82 ordinal: function (number, period) {
83 switch (period) {
84 case 'DDD':
85 case 'w':
86 case 'W':
87 case 'DDDo':
88 if (number === 1) {
89 return number + '-ին';
90 }
91 return number + '-րդ';
92 default:
93 return number;
94 }
95 },
96 week : {
97 dow : 1, // Monday is the first day of the week.
98 doy : 7 // The week that contains Jan 1st is the first week of the year.
99 }
100 });
101
0 //! moment.js locale configuration
1 //! locale : Bahasa Indonesia (id)
2 //! author : Mohammad Satrio Utomo : https://github.com/tyok
3 //! reference: http://id.wikisource.org/wiki/Pedoman_Umum_Ejaan_Bahasa_Indonesia_yang_Disempurnakan
4
5 import moment from '../moment';
6
7 export default moment.defineLocale('id', {
8 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
9 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des'.split('_'),
10 weekdays : 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
11 weekdaysShort : 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'),
12 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'),
13 longDateFormat : {
14 LT : 'HH.mm',
15 LTS : 'HH.mm.ss',
16 L : 'DD/MM/YYYY',
17 LL : 'D MMMM YYYY',
18 LLL : 'D MMMM YYYY [pukul] HH.mm',
19 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
20 },
21 meridiemParse: /pagi|siang|sore|malam/,
22 meridiemHour : function (hour, meridiem) {
23 if (hour === 12) {
24 hour = 0;
25 }
26 if (meridiem === 'pagi') {
27 return hour;
28 } else if (meridiem === 'siang') {
29 return hour >= 11 ? hour : hour + 12;
30 } else if (meridiem === 'sore' || meridiem === 'malam') {
31 return hour + 12;
32 }
33 },
34 meridiem : function (hours, minutes, isLower) {
35 if (hours < 11) {
36 return 'pagi';
37 } else if (hours < 15) {
38 return 'siang';
39 } else if (hours < 19) {
40 return 'sore';
41 } else {
42 return 'malam';
43 }
44 },
45 calendar : {
46 sameDay : '[Hari ini pukul] LT',
47 nextDay : '[Besok pukul] LT',
48 nextWeek : 'dddd [pukul] LT',
49 lastDay : '[Kemarin pukul] LT',
50 lastWeek : 'dddd [lalu pukul] LT',
51 sameElse : 'L'
52 },
53 relativeTime : {
54 future : 'dalam %s',
55 past : '%s yang lalu',
56 s : 'beberapa detik',
57 m : 'semenit',
58 mm : '%d menit',
59 h : 'sejam',
60 hh : '%d jam',
61 d : 'sehari',
62 dd : '%d hari',
63 M : 'sebulan',
64 MM : '%d bulan',
65 y : 'setahun',
66 yy : '%d tahun'
67 },
68 week : {
69 dow : 1, // Monday is the first day of the week.
70 doy : 7 // The week that contains Jan 1st is the first week of the year.
71 }
72 });
73
0 //! moment.js locale configuration
1 //! locale : icelandic (is)
2 //! author : Hinrik Örn Sigurðsson : https://github.com/hinrik
3
4 import moment from '../moment';
5
6 function plural(n) {
7 if (n % 100 === 11) {
8 return true;
9 } else if (n % 10 === 1) {
10 return false;
11 }
12 return true;
13 }
14 function translate(number, withoutSuffix, key, isFuture) {
15 var result = number + ' ';
16 switch (key) {
17 case 's':
18 return withoutSuffix || isFuture ? 'nokkrar sekúndur' : 'nokkrum sekúndum';
19 case 'm':
20 return withoutSuffix ? 'mínúta' : 'mínútu';
21 case 'mm':
22 if (plural(number)) {
23 return result + (withoutSuffix || isFuture ? 'mínútur' : 'mínútum');
24 } else if (withoutSuffix) {
25 return result + 'mínúta';
26 }
27 return result + 'mínútu';
28 case 'hh':
29 if (plural(number)) {
30 return result + (withoutSuffix || isFuture ? 'klukkustundir' : 'klukkustundum');
31 }
32 return result + 'klukkustund';
33 case 'd':
34 if (withoutSuffix) {
35 return 'dagur';
36 }
37 return isFuture ? 'dag' : 'degi';
38 case 'dd':
39 if (plural(number)) {
40 if (withoutSuffix) {
41 return result + 'dagar';
42 }
43 return result + (isFuture ? 'daga' : 'dögum');
44 } else if (withoutSuffix) {
45 return result + 'dagur';
46 }
47 return result + (isFuture ? 'dag' : 'degi');
48 case 'M':
49 if (withoutSuffix) {
50 return 'mánuður';
51 }
52 return isFuture ? 'mánuð' : 'mánuði';
53 case 'MM':
54 if (plural(number)) {
55 if (withoutSuffix) {
56 return result + 'mánuðir';
57 }
58 return result + (isFuture ? 'mánuði' : 'mánuðum');
59 } else if (withoutSuffix) {
60 return result + 'mánuður';
61 }
62 return result + (isFuture ? 'mánuð' : 'mánuði');
63 case 'y':
64 return withoutSuffix || isFuture ? 'ár' : 'ári';
65 case 'yy':
66 if (plural(number)) {
67 return result + (withoutSuffix || isFuture ? 'ár' : 'árum');
68 }
69 return result + (withoutSuffix || isFuture ? 'ár' : 'ári');
70 }
71 }
72
73 export default moment.defineLocale('is', {
74 months : 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'),
75 monthsShort : 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'),
76 weekdays : 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
77 weekdaysShort : 'sun_mán_þri_mið_fim_fös_lau'.split('_'),
78 weekdaysMin : 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'),
79 longDateFormat : {
80 LT : 'H:mm',
81 LTS : 'H:mm:ss',
82 L : 'DD/MM/YYYY',
83 LL : 'D. MMMM YYYY',
84 LLL : 'D. MMMM YYYY [kl.] H:mm',
85 LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
86 },
87 calendar : {
88 sameDay : '[í dag kl.] LT',
89 nextDay : '[á morgun kl.] LT',
90 nextWeek : 'dddd [kl.] LT',
91 lastDay : '[í gær kl.] LT',
92 lastWeek : '[síðasta] dddd [kl.] LT',
93 sameElse : 'L'
94 },
95 relativeTime : {
96 future : 'eftir %s',
97 past : 'fyrir %s síðan',
98 s : translate,
99 m : translate,
100 mm : translate,
101 h : 'klukkustund',
102 hh : translate,
103 d : translate,
104 dd : translate,
105 M : translate,
106 MM : translate,
107 y : translate,
108 yy : translate
109 },
110 ordinalParse: /\d{1,2}\./,
111 ordinal : '%d.',
112 week : {
113 dow : 1, // Monday is the first day of the week.
114 doy : 4 // The week that contains Jan 4th is the first week of the year.
115 }
116 });
117
0 //! moment.js locale configuration
1 //! locale : italian (it)
2 //! author : Lorenzo : https://github.com/aliem
3 //! author: Mattia Larentis: https://github.com/nostalgiaz
4
5 import moment from '../moment';
6
7 export default moment.defineLocale('it', {
8 months : 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
9 monthsShort : 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
10 weekdays : 'Domenica_Lunedì_Martedì_Mercoledì_Giovedì_Venerdì_Sabato'.split('_'),
11 weekdaysShort : 'Dom_Lun_Mar_Mer_Gio_Ven_Sab'.split('_'),
12 weekdaysMin : 'D_L_Ma_Me_G_V_S'.split('_'),
13 longDateFormat : {
14 LT : 'HH:mm',
15 LTS : 'HH:mm:ss',
16 L : 'DD/MM/YYYY',
17 LL : 'D MMMM YYYY',
18 LLL : 'D MMMM YYYY HH:mm',
19 LLLL : 'dddd, D MMMM YYYY HH:mm'
20 },
21 calendar : {
22 sameDay: '[Oggi alle] LT',
23 nextDay: '[Domani alle] LT',
24 nextWeek: 'dddd [alle] LT',
25 lastDay: '[Ieri alle] LT',
26 lastWeek: function () {
27 switch (this.day()) {
28 case 0:
29 return '[la scorsa] dddd [alle] LT';
30 default:
31 return '[lo scorso] dddd [alle] LT';
32 }
33 },
34 sameElse: 'L'
35 },
36 relativeTime : {
37 future : function (s) {
38 return ((/^[0-9].+$/).test(s) ? 'tra' : 'in') + ' ' + s;
39 },
40 past : '%s fa',
41 s : 'alcuni secondi',
42 m : 'un minuto',
43 mm : '%d minuti',
44 h : 'un\'ora',
45 hh : '%d ore',
46 d : 'un giorno',
47 dd : '%d giorni',
48 M : 'un mese',
49 MM : '%d mesi',
50 y : 'un anno',
51 yy : '%d anni'
52 },
53 ordinalParse : /\d{1,2}º/,
54 ordinal: '%dº',
55 week : {
56 dow : 1, // Monday is the first day of the week.
57 doy : 4 // The week that contains Jan 4th is the first week of the year.
58 }
59 });
60
0 //! moment.js locale configuration
1 //! locale : japanese (ja)
2 //! author : LI Long : https://github.com/baryon
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('ja', {
7 months : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
8 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
9 weekdays : '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
10 weekdaysShort : '日_月_火_水_木_金_土'.split('_'),
11 weekdaysMin : '日_月_火_水_木_金_土'.split('_'),
12 longDateFormat : {
13 LT : 'Ah時m分',
14 LTS : 'Ah時m分s秒',
15 L : 'YYYY/MM/DD',
16 LL : 'YYYY年M月D日',
17 LLL : 'YYYY年M月D日Ah時m分',
18 LLLL : 'YYYY年M月D日Ah時m分 dddd'
19 },
20 meridiemParse: /午前|午後/i,
21 isPM : function (input) {
22 return input === '午後';
23 },
24 meridiem : function (hour, minute, isLower) {
25 if (hour < 12) {
26 return '午前';
27 } else {
28 return '午後';
29 }
30 },
31 calendar : {
32 sameDay : '[今日] LT',
33 nextDay : '[明日] LT',
34 nextWeek : '[来週]dddd LT',
35 lastDay : '[昨日] LT',
36 lastWeek : '[前週]dddd LT',
37 sameElse : 'L'
38 },
39 relativeTime : {
40 future : '%s後',
41 past : '%s前',
42 s : '数秒',
43 m : '1分',
44 mm : '%d分',
45 h : '1時間',
46 hh : '%d時間',
47 d : '1日',
48 dd : '%d日',
49 M : '1ヶ月',
50 MM : '%dヶ月',
51 y : '1年',
52 yy : '%d年'
53 }
54 });
55
0 //! moment.js locale configuration
1 //! locale : Boso Jowo (jv)
2 //! author : Rony Lantip : https://github.com/lantip
3 //! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
4
5 import moment from '../moment';
6
7 export default moment.defineLocale('jv', {
8 months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
9 monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
10 weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
11 weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
12 weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
13 longDateFormat : {
14 LT : 'HH.mm',
15 LTS : 'HH.mm.ss',
16 L : 'DD/MM/YYYY',
17 LL : 'D MMMM YYYY',
18 LLL : 'D MMMM YYYY [pukul] HH.mm',
19 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
20 },
21 meridiemParse: /enjing|siyang|sonten|ndalu/,
22 meridiemHour : function (hour, meridiem) {
23 if (hour === 12) {
24 hour = 0;
25 }
26 if (meridiem === 'enjing') {
27 return hour;
28 } else if (meridiem === 'siyang') {
29 return hour >= 11 ? hour : hour + 12;
30 } else if (meridiem === 'sonten' || meridiem === 'ndalu') {
31 return hour + 12;
32 }
33 },
34 meridiem : function (hours, minutes, isLower) {
35 if (hours < 11) {
36 return 'enjing';
37 } else if (hours < 15) {
38 return 'siyang';
39 } else if (hours < 19) {
40 return 'sonten';
41 } else {
42 return 'ndalu';
43 }
44 },
45 calendar : {
46 sameDay : '[Dinten puniko pukul] LT',
47 nextDay : '[Mbenjang pukul] LT',
48 nextWeek : 'dddd [pukul] LT',
49 lastDay : '[Kala wingi pukul] LT',
50 lastWeek : 'dddd [kepengker pukul] LT',
51 sameElse : 'L'
52 },
53 relativeTime : {
54 future : 'wonten ing %s',
55 past : '%s ingkang kepengker',
56 s : 'sawetawis detik',
57 m : 'setunggal menit',
58 mm : '%d menit',
59 h : 'setunggal jam',
60 hh : '%d jam',
61 d : 'sedinten',
62 dd : '%d dinten',
63 M : 'sewulan',
64 MM : '%d wulan',
65 y : 'setaun',
66 yy : '%d taun'
67 },
68 week : {
69 dow : 1, // Monday is the first day of the week.
70 doy : 7 // The week that contains Jan 1st is the first week of the year.
71 }
72 });
0 //! moment.js locale configuration
1 //! locale : Georgian (ka)
2 //! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
3
4 import moment from '../moment';
5
6 function monthsCaseReplace(m, format) {
7 var months = {
8 'nominative': 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
9 'accusative': 'იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს'.split('_')
10 },
11 nounCase = (/D[oD] *MMMM?/).test(format) ?
12 'accusative' :
13 'nominative';
14 return months[nounCase][m.month()];
15 }
16 function weekdaysCaseReplace(m, format) {
17 var weekdays = {
18 'nominative': 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'),
19 'accusative': 'კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს'.split('_')
20 },
21 nounCase = (/(წინა|შემდეგ)/).test(format) ?
22 'accusative' :
23 'nominative';
24 return weekdays[nounCase][m.day()];
25 }
26
27 export default moment.defineLocale('ka', {
28 months : monthsCaseReplace,
29 monthsShort : 'იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ'.split('_'),
30 weekdays : weekdaysCaseReplace,
31 weekdaysShort : 'კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ'.split('_'),
32 weekdaysMin : 'კვ_ორ_სა_ოთ_ხუ_პა_შა'.split('_'),
33 longDateFormat : {
34 LT : 'h:mm A',
35 LTS : 'h:mm:ss A',
36 L : 'DD/MM/YYYY',
37 LL : 'D MMMM YYYY',
38 LLL : 'D MMMM YYYY h:mm A',
39 LLLL : 'dddd, D MMMM YYYY h:mm A'
40 },
41 calendar : {
42 sameDay : '[დღეს] LT[-ზე]',
43 nextDay : '[ხვალ] LT[-ზე]',
44 lastDay : '[გუშინ] LT[-ზე]',
45 nextWeek : '[შემდეგ] dddd LT[-ზე]',
46 lastWeek : '[წინა] dddd LT-ზე',
47 sameElse : 'L'
48 },
49 relativeTime : {
50 future : function (s) {
51 return (/(წამი|წუთი|საათი|წელი)/).test(s) ?
52 s.replace(/ი$/, 'ში') :
53 s + 'ში';
54 },
55 past : function (s) {
56 if ((/(წამი|წუთი|საათი|დღე|თვე)/).test(s)) {
57 return s.replace(/(ი|ე)$/, 'ის წინ');
58 }
59 if ((/წელი/).test(s)) {
60 return s.replace(/წელი$/, 'წლის წინ');
61 }
62 },
63 s : 'რამდენიმე წამი',
64 m : 'წუთი',
65 mm : '%d წუთი',
66 h : 'საათი',
67 hh : '%d საათი',
68 d : 'დღე',
69 dd : '%d დღე',
70 M : 'თვე',
71 MM : '%d თვე',
72 y : 'წელი',
73 yy : '%d წელი'
74 },
75 ordinalParse: /0|1-ლი|მე-\d{1,2}|\d{1,2}-ე/,
76 ordinal : function (number) {
77 if (number === 0) {
78 return number;
79 }
80 if (number === 1) {
81 return number + '-ლი';
82 }
83 if ((number < 20) || (number <= 100 && (number % 20 === 0)) || (number % 100 === 0)) {
84 return 'მე-' + number;
85 }
86 return number + '-ე';
87 },
88 week : {
89 dow : 1,
90 doy : 7
91 }
92 });
93
0 //! moment.js locale configuration
1 //! locale : khmer (km)
2 //! author : Kruy Vanna : https://github.com/kruyvanna
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('km', {
7 months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
8 monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
9 weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
10 weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
11 weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
12 longDateFormat: {
13 LT: 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L: 'DD/MM/YYYY',
16 LL: 'D MMMM YYYY',
17 LLL: 'D MMMM YYYY HH:mm',
18 LLLL: 'dddd, D MMMM YYYY HH:mm'
19 },
20 calendar: {
21 sameDay: '[ថ្ងៃនៈ ម៉ោង] LT',
22 nextDay: '[ស្អែក ម៉ោង] LT',
23 nextWeek: 'dddd [ម៉ោង] LT',
24 lastDay: '[ម្សិលមិញ ម៉ោង] LT',
25 lastWeek: 'dddd [សប្តាហ៍មុន] [ម៉ោង] LT',
26 sameElse: 'L'
27 },
28 relativeTime: {
29 future: '%sទៀត',
30 past: '%sមុន',
31 s: 'ប៉ុន្មានវិនាទី',
32 m: 'មួយនាទី',
33 mm: '%d នាទី',
34 h: 'មួយម៉ោង',
35 hh: '%d ម៉ោង',
36 d: 'មួយថ្ងៃ',
37 dd: '%d ថ្ងៃ',
38 M: 'មួយខែ',
39 MM: '%d ខែ',
40 y: 'មួយឆ្នាំ',
41 yy: '%d ឆ្នាំ'
42 },
43 week: {
44 dow: 1, // Monday is the first day of the week.
45 doy: 4 // The week that contains Jan 4th is the first week of the year.
46 }
47 });
48
0 //! moment.js locale configuration
1 //! locale : korean (ko)
2 //!
3 //! authors
4 //!
5 //! - Kyungwook, Park : https://github.com/kyungw00k
6 //! - Jeeeyul Lee <jeeeyul@gmail.com>
7
8 import moment from '../moment';
9
10 export default moment.defineLocale('ko', {
11 months : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
12 monthsShort : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
13 weekdays : '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
14 weekdaysShort : '일_월_화_수_목_금_토'.split('_'),
15 weekdaysMin : '일_월_화_수_목_금_토'.split('_'),
16 longDateFormat : {
17 LT : 'A h시 m분',
18 LTS : 'A h시 m분 s초',
19 L : 'YYYY.MM.DD',
20 LL : 'YYYY년 MMMM D일',
21 LLL : 'YYYY년 MMMM D일 A h시 m분',
22 LLLL : 'YYYY년 MMMM D일 dddd A h시 m분'
23 },
24 calendar : {
25 sameDay : '오늘 LT',
26 nextDay : '내일 LT',
27 nextWeek : 'dddd LT',
28 lastDay : '어제 LT',
29 lastWeek : '지난주 dddd LT',
30 sameElse : 'L'
31 },
32 relativeTime : {
33 future : '%s 후',
34 past : '%s 전',
35 s : '몇초',
36 ss : '%d초',
37 m : '일분',
38 mm : '%d분',
39 h : '한시간',
40 hh : '%d시간',
41 d : '하루',
42 dd : '%d일',
43 M : '한달',
44 MM : '%d달',
45 y : '일년',
46 yy : '%d년'
47 },
48 ordinalParse : /\d{1,2}일/,
49 ordinal : '%d일',
50 meridiemParse : /오전|오후/,
51 isPM : function (token) {
52 return token === '오후';
53 },
54 meridiem : function (hour, minute, isUpper) {
55 return hour < 12 ? '오전' : '오후';
56 }
57 });
58
0 //! moment.js locale configuration
1 //! locale : Luxembourgish (lb)
2 //! author : mweimerskirch : https://github.com/mweimerskirch, David Raison : https://github.com/kwisatz
3
4 import moment from '../moment';
5
6 function processRelativeTime(number, withoutSuffix, key, isFuture) {
7 var format = {
8 'm': ['eng Minutt', 'enger Minutt'],
9 'h': ['eng Stonn', 'enger Stonn'],
10 'd': ['een Dag', 'engem Dag'],
11 'M': ['ee Mount', 'engem Mount'],
12 'y': ['ee Joer', 'engem Joer']
13 };
14 return withoutSuffix ? format[key][0] : format[key][1];
15 }
16 function processFutureTime(string) {
17 var number = string.substr(0, string.indexOf(' '));
18 if (eifelerRegelAppliesToNumber(number)) {
19 return 'a ' + string;
20 }
21 return 'an ' + string;
22 }
23 function processPastTime(string) {
24 var number = string.substr(0, string.indexOf(' '));
25 if (eifelerRegelAppliesToNumber(number)) {
26 return 'viru ' + string;
27 }
28 return 'virun ' + string;
29 }
30 /**
31 * Returns true if the word before the given number loses the '-n' ending.
32 * e.g. 'an 10 Deeg' but 'a 5 Deeg'
33 *
34 * @param number {integer}
35 * @returns {boolean}
36 */
37 function eifelerRegelAppliesToNumber(number) {
38 number = parseInt(number, 10);
39 if (isNaN(number)) {
40 return false;
41 }
42 if (number < 0) {
43 // Negative Number --> always true
44 return true;
45 } else if (number < 10) {
46 // Only 1 digit
47 if (4 <= number && number <= 7) {
48 return true;
49 }
50 return false;
51 } else if (number < 100) {
52 // 2 digits
53 var lastDigit = number % 10, firstDigit = number / 10;
54 if (lastDigit === 0) {
55 return eifelerRegelAppliesToNumber(firstDigit);
56 }
57 return eifelerRegelAppliesToNumber(lastDigit);
58 } else if (number < 10000) {
59 // 3 or 4 digits --> recursively check first digit
60 while (number >= 10) {
61 number = number / 10;
62 }
63 return eifelerRegelAppliesToNumber(number);
64 } else {
65 // Anything larger than 4 digits: recursively check first n-3 digits
66 number = number / 1000;
67 return eifelerRegelAppliesToNumber(number);
68 }
69 }
70
71 export default moment.defineLocale('lb', {
72 months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
73 monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
74 weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
75 weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
76 weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
77 longDateFormat: {
78 LT: 'H:mm [Auer]',
79 LTS: 'H:mm:ss [Auer]',
80 L: 'DD.MM.YYYY',
81 LL: 'D. MMMM YYYY',
82 LLL: 'D. MMMM YYYY H:mm [Auer]',
83 LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]'
84 },
85 calendar: {
86 sameDay: '[Haut um] LT',
87 sameElse: 'L',
88 nextDay: '[Muer um] LT',
89 nextWeek: 'dddd [um] LT',
90 lastDay: '[Gëschter um] LT',
91 lastWeek: function () {
92 // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
93 switch (this.day()) {
94 case 2:
95 case 4:
96 return '[Leschten] dddd [um] LT';
97 default:
98 return '[Leschte] dddd [um] LT';
99 }
100 }
101 },
102 relativeTime : {
103 future : processFutureTime,
104 past : processPastTime,
105 s : 'e puer Sekonnen',
106 m : processRelativeTime,
107 mm : '%d Minutten',
108 h : processRelativeTime,
109 hh : '%d Stonnen',
110 d : processRelativeTime,
111 dd : '%d Deeg',
112 M : processRelativeTime,
113 MM : '%d Méint',
114 y : processRelativeTime,
115 yy : '%d Joer'
116 },
117 ordinalParse: /\d{1,2}\./,
118 ordinal: '%d.',
119 week: {
120 dow: 1, // Monday is the first day of the week.
121 doy: 4 // The week that contains Jan 4th is the first week of the year.
122 }
123 });
124
0 //! moment.js locale configuration
1 //! locale : Lithuanian (lt)
2 //! author : Mindaugas Mozūras : https://github.com/mmozuras
3
4 import moment from '../moment';
5
6 var units = {
7 'm' : 'minutė_minutės_minutę',
8 'mm': 'minutės_minučių_minutes',
9 'h' : 'valanda_valandos_valandą',
10 'hh': 'valandos_valandų_valandas',
11 'd' : 'diena_dienos_dieną',
12 'dd': 'dienos_dienų_dienas',
13 'M' : 'mėnuo_mėnesio_mėnesį',
14 'MM': 'mėnesiai_mėnesių_mėnesius',
15 'y' : 'metai_metų_metus',
16 'yy': 'metai_metų_metus'
17 },
18 weekDays = 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_');
19 function translateSeconds(number, withoutSuffix, key, isFuture) {
20 if (withoutSuffix) {
21 return 'kelios sekundės';
22 } else {
23 return isFuture ? 'kelių sekundžių' : 'kelias sekundes';
24 }
25 }
26 function monthsCaseReplace(m, format) {
27 var months = {
28 'nominative': 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
29 'accusative': 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_')
30 },
31 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
32 'accusative' :
33 'nominative';
34 return months[nounCase][m.month()];
35 }
36 function translateSingular(number, withoutSuffix, key, isFuture) {
37 return withoutSuffix ? forms(key)[0] : (isFuture ? forms(key)[1] : forms(key)[2]);
38 }
39 function special(number) {
40 return number % 10 === 0 || (number > 10 && number < 20);
41 }
42 function forms(key) {
43 return units[key].split('_');
44 }
45 function translate(number, withoutSuffix, key, isFuture) {
46 var result = number + ' ';
47 if (number === 1) {
48 return result + translateSingular(number, withoutSuffix, key[0], isFuture);
49 } else if (withoutSuffix) {
50 return result + (special(number) ? forms(key)[1] : forms(key)[0]);
51 } else {
52 if (isFuture) {
53 return result + forms(key)[1];
54 } else {
55 return result + (special(number) ? forms(key)[1] : forms(key)[2]);
56 }
57 }
58 }
59 function relativeWeekDay(moment, format) {
60 var nominative = format.indexOf('dddd HH:mm') === -1,
61 weekDay = weekDays[moment.day()];
62 return nominative ? weekDay : weekDay.substring(0, weekDay.length - 2) + 'į';
63 }
64
65 export default moment.defineLocale('lt', {
66 months : monthsCaseReplace,
67 monthsShort : 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'),
68 weekdays : relativeWeekDay,
69 weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
70 weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
71 longDateFormat : {
72 LT : 'HH:mm',
73 LTS : 'HH:mm:ss',
74 L : 'YYYY-MM-DD',
75 LL : 'YYYY [m.] MMMM D [d.]',
76 LLL : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
77 LLLL : 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]',
78 l : 'YYYY-MM-DD',
79 ll : 'YYYY [m.] MMMM D [d.]',
80 lll : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
81 llll : 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]'
82 },
83 calendar : {
84 sameDay : '[Šiandien] LT',
85 nextDay : '[Rytoj] LT',
86 nextWeek : 'dddd LT',
87 lastDay : '[Vakar] LT',
88 lastWeek : '[Praėjusį] dddd LT',
89 sameElse : 'L'
90 },
91 relativeTime : {
92 future : 'po %s',
93 past : 'prieš %s',
94 s : translateSeconds,
95 m : translateSingular,
96 mm : translate,
97 h : translateSingular,
98 hh : translate,
99 d : translateSingular,
100 dd : translate,
101 M : translateSingular,
102 MM : translate,
103 y : translateSingular,
104 yy : translate
105 },
106 ordinalParse: /\d{1,2}-oji/,
107 ordinal : function (number) {
108 return number + '-oji';
109 },
110 week : {
111 dow : 1, // Monday is the first day of the week.
112 doy : 4 // The week that contains Jan 4th is the first week of the year.
113 }
114 });
115
0 //! moment.js locale configuration
1 //! locale : latvian (lv)
2 //! author : Kristaps Karlsons : https://github.com/skakri
3 //! author : Jānis Elmeris : https://github.com/JanisE
4
5 import moment from '../moment';
6
7 var units = {
8 'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
9 'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
10 'h': 'stundas_stundām_stunda_stundas'.split('_'),
11 'hh': 'stundas_stundām_stunda_stundas'.split('_'),
12 'd': 'dienas_dienām_diena_dienas'.split('_'),
13 'dd': 'dienas_dienām_diena_dienas'.split('_'),
14 'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
15 'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
16 'y': 'gada_gadiem_gads_gadi'.split('_'),
17 'yy': 'gada_gadiem_gads_gadi'.split('_')
18 };
19 /**
20 * @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
21 */
22 function format(forms, number, withoutSuffix) {
23 if (withoutSuffix) {
24 // E.g. "21 minūte", "3 minūtes".
25 return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
26 } else {
27 // E.g. "21 minūtes" as in "pēc 21 minūtes".
28 // E.g. "3 minūtēm" as in "pēc 3 minūtēm".
29 return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
30 }
31 }
32 function relativeTimeWithPlural(number, withoutSuffix, key) {
33 return number + ' ' + format(units[key], number, withoutSuffix);
34 }
35 function relativeTimeWithSingular(number, withoutSuffix, key) {
36 return format(units[key], number, withoutSuffix);
37 }
38 function relativeSeconds(number, withoutSuffix) {
39 return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
40 }
41
42 export default moment.defineLocale('lv', {
43 months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
44 monthsShort : 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'),
45 weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
46 weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
47 weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
48 longDateFormat : {
49 LT : 'HH:mm',
50 LTS : 'HH:mm:ss',
51 L : 'DD.MM.YYYY.',
52 LL : 'YYYY. [gada] D. MMMM',
53 LLL : 'YYYY. [gada] D. MMMM, HH:mm',
54 LLLL : 'YYYY. [gada] D. MMMM, dddd, HH:mm'
55 },
56 calendar : {
57 sameDay : '[Šodien pulksten] LT',
58 nextDay : '[Rīt pulksten] LT',
59 nextWeek : 'dddd [pulksten] LT',
60 lastDay : '[Vakar pulksten] LT',
61 lastWeek : '[Pagājušā] dddd [pulksten] LT',
62 sameElse : 'L'
63 },
64 relativeTime : {
65 future : 'pēc %s',
66 past : 'pirms %s',
67 s : relativeSeconds,
68 m : relativeTimeWithSingular,
69 mm : relativeTimeWithPlural,
70 h : relativeTimeWithSingular,
71 hh : relativeTimeWithPlural,
72 d : relativeTimeWithSingular,
73 dd : relativeTimeWithPlural,
74 M : relativeTimeWithSingular,
75 MM : relativeTimeWithPlural,
76 y : relativeTimeWithSingular,
77 yy : relativeTimeWithPlural
78 },
79 ordinalParse: /\d{1,2}\./,
80 ordinal : '%d.',
81 week : {
82 dow : 1, // Monday is the first day of the week.
83 doy : 4 // The week that contains Jan 4th is the first week of the year.
84 }
85 });
86
0 //! moment.js locale configuration
1 //! locale : Montenegrin (me)
2 //! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
3
4 import moment from '../moment';
5
6 var translator = {
7 words: { //Different grammatical cases
8 m: ['jedan minut', 'jednog minuta'],
9 mm: ['minut', 'minuta', 'minuta'],
10 h: ['jedan sat', 'jednog sata'],
11 hh: ['sat', 'sata', 'sati'],
12 dd: ['dan', 'dana', 'dana'],
13 MM: ['mjesec', 'mjeseca', 'mjeseci'],
14 yy: ['godina', 'godine', 'godina']
15 },
16 correctGrammaticalCase: function (number, wordKey) {
17 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
18 },
19 translate: function (number, withoutSuffix, key) {
20 var wordKey = translator.words[key];
21 if (key.length === 1) {
22 return withoutSuffix ? wordKey[0] : wordKey[1];
23 } else {
24 return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
25 }
26 }
27 };
28
29 export default moment.defineLocale('me', {
30 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
31 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
32 weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
33 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
34 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
35 longDateFormat: {
36 LT: 'H:mm',
37 LTS : 'H:mm:ss',
38 L: 'DD. MM. YYYY',
39 LL: 'D. MMMM YYYY',
40 LLL: 'D. MMMM YYYY H:mm',
41 LLLL: 'dddd, D. MMMM YYYY H:mm'
42 },
43 calendar: {
44 sameDay: '[danas u] LT',
45 nextDay: '[sjutra u] LT',
46
47 nextWeek: function () {
48 switch (this.day()) {
49 case 0:
50 return '[u] [nedjelju] [u] LT';
51 case 3:
52 return '[u] [srijedu] [u] LT';
53 case 6:
54 return '[u] [subotu] [u] LT';
55 case 1:
56 case 2:
57 case 4:
58 case 5:
59 return '[u] dddd [u] LT';
60 }
61 },
62 lastDay : '[juče u] LT',
63 lastWeek : function () {
64 var lastWeekDays = [
65 '[prošle] [nedjelje] [u] LT',
66 '[prošlog] [ponedjeljka] [u] LT',
67 '[prošlog] [utorka] [u] LT',
68 '[prošle] [srijede] [u] LT',
69 '[prošlog] [četvrtka] [u] LT',
70 '[prošlog] [petka] [u] LT',
71 '[prošle] [subote] [u] LT'
72 ];
73 return lastWeekDays[this.day()];
74 },
75 sameElse : 'L'
76 },
77 relativeTime : {
78 future : 'za %s',
79 past : 'prije %s',
80 s : 'nekoliko sekundi',
81 m : translator.translate,
82 mm : translator.translate,
83 h : translator.translate,
84 hh : translator.translate,
85 d : 'dan',
86 dd : translator.translate,
87 M : 'mjesec',
88 MM : translator.translate,
89 y : 'godinu',
90 yy : translator.translate
91 },
92 ordinalParse: /\d{1,2}\./,
93 ordinal : '%d.',
94 week : {
95 dow : 1, // Monday is the first day of the week.
96 doy : 7 // The week that contains Jan 1st is the first week of the year.
97 }
98 });
0 //! moment.js locale configuration
1 //! locale : macedonian (mk)
2 //! author : Borislav Mickov : https://github.com/B0k0
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('mk', {
7 months : 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'),
8 monthsShort : 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'),
9 weekdays : 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'),
10 weekdaysShort : 'нед_пон_вто_сре_чет_пет_саб'.split('_'),
11 weekdaysMin : 'нe_пo_вт_ср_че_пе_сa'.split('_'),
12 longDateFormat : {
13 LT : 'H:mm',
14 LTS : 'H:mm:ss',
15 L : 'D.MM.YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY H:mm',
18 LLLL : 'dddd, D MMMM YYYY H:mm'
19 },
20 calendar : {
21 sameDay : '[Денес во] LT',
22 nextDay : '[Утре во] LT',
23 nextWeek : 'dddd [во] LT',
24 lastDay : '[Вчера во] LT',
25 lastWeek : function () {
26 switch (this.day()) {
27 case 0:
28 case 3:
29 case 6:
30 return '[Во изминатата] dddd [во] LT';
31 case 1:
32 case 2:
33 case 4:
34 case 5:
35 return '[Во изминатиот] dddd [во] LT';
36 }
37 },
38 sameElse : 'L'
39 },
40 relativeTime : {
41 future : 'после %s',
42 past : 'пред %s',
43 s : 'неколку секунди',
44 m : 'минута',
45 mm : '%d минути',
46 h : 'час',
47 hh : '%d часа',
48 d : 'ден',
49 dd : '%d дена',
50 M : 'месец',
51 MM : '%d месеци',
52 y : 'година',
53 yy : '%d години'
54 },
55 ordinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
56 ordinal : function (number) {
57 var lastDigit = number % 10,
58 last2Digits = number % 100;
59 if (number === 0) {
60 return number + '-ев';
61 } else if (last2Digits === 0) {
62 return number + '-ен';
63 } else if (last2Digits > 10 && last2Digits < 20) {
64 return number + '-ти';
65 } else if (lastDigit === 1) {
66 return number + '-ви';
67 } else if (lastDigit === 2) {
68 return number + '-ри';
69 } else if (lastDigit === 7 || lastDigit === 8) {
70 return number + '-ми';
71 } else {
72 return number + '-ти';
73 }
74 },
75 week : {
76 dow : 1, // Monday is the first day of the week.
77 doy : 7 // The week that contains Jan 1st is the first week of the year.
78 }
79 });
80
0 //! moment.js locale configuration
1 //! locale : malayalam (ml)
2 //! author : Floyd Pink : https://github.com/floydpink
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('ml', {
7 months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
8 monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
9 weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
10 weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
11 weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
12 longDateFormat : {
13 LT : 'A h:mm -നു',
14 LTS : 'A h:mm:ss -നു',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY, A h:mm -നു',
18 LLLL : 'dddd, D MMMM YYYY, A h:mm -നു'
19 },
20 calendar : {
21 sameDay : '[ഇന്ന്] LT',
22 nextDay : '[നാളെ] LT',
23 nextWeek : 'dddd, LT',
24 lastDay : '[ഇന്നലെ] LT',
25 lastWeek : '[കഴിഞ്ഞ] dddd, LT',
26 sameElse : 'L'
27 },
28 relativeTime : {
29 future : '%s കഴിഞ്ഞ്',
30 past : '%s മുൻപ്',
31 s : 'അൽപ നിമിഷങ്ങൾ',
32 m : 'ഒരു മിനിറ്റ്',
33 mm : '%d മിനിറ്റ്',
34 h : 'ഒരു മണിക്കൂർ',
35 hh : '%d മണിക്കൂർ',
36 d : 'ഒരു ദിവസം',
37 dd : '%d ദിവസം',
38 M : 'ഒരു മാസം',
39 MM : '%d മാസം',
40 y : 'ഒരു വർഷം',
41 yy : '%d വർഷം'
42 },
43 meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
44 isPM : function (input) {
45 return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
46 },
47 meridiem : function (hour, minute, isLower) {
48 if (hour < 4) {
49 return 'രാത്രി';
50 } else if (hour < 12) {
51 return 'രാവിലെ';
52 } else if (hour < 17) {
53 return 'ഉച്ച കഴിഞ്ഞ്';
54 } else if (hour < 20) {
55 return 'വൈകുന്നേരം';
56 } else {
57 return 'രാത്രി';
58 }
59 }
60 });
61
0 //! moment.js locale configuration
1 //! locale : Marathi (mr)
2 //! author : Harshad Kale : https://github.com/kalehv
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '१',
8 '2': '२',
9 '3': '३',
10 '4': '४',
11 '5': '५',
12 '6': '६',
13 '7': '७',
14 '8': '८',
15 '9': '९',
16 '0': '०'
17 },
18 numberMap = {
19 '१': '1',
20 '२': '2',
21 '३': '3',
22 '४': '4',
23 '५': '5',
24 '६': '6',
25 '७': '7',
26 '८': '8',
27 '९': '9',
28 '०': '0'
29 };
30
31 export default moment.defineLocale('mr', {
32 months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
33 monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
34 weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
35 weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
36 weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
37 longDateFormat : {
38 LT : 'A h:mm वाजता',
39 LTS : 'A h:mm:ss वाजता',
40 L : 'DD/MM/YYYY',
41 LL : 'D MMMM YYYY',
42 LLL : 'D MMMM YYYY, A h:mm वाजता',
43 LLLL : 'dddd, D MMMM YYYY, A h:mm वाजता'
44 },
45 calendar : {
46 sameDay : '[आज] LT',
47 nextDay : '[उद्या] LT',
48 nextWeek : 'dddd, LT',
49 lastDay : '[काल] LT',
50 lastWeek: '[मागील] dddd, LT',
51 sameElse : 'L'
52 },
53 relativeTime : {
54 future : '%s नंतर',
55 past : '%s पूर्वी',
56 s : 'सेकंद',
57 m: 'एक मिनिट',
58 mm: '%d मिनिटे',
59 h : 'एक तास',
60 hh : '%d तास',
61 d : 'एक दिवस',
62 dd : '%d दिवस',
63 M : 'एक महिना',
64 MM : '%d महिने',
65 y : 'एक वर्ष',
66 yy : '%d वर्षे'
67 },
68 preparse: function (string) {
69 return string.replace(/[१२३४५६७८९०]/g, function (match) {
70 return numberMap[match];
71 });
72 },
73 postformat: function (string) {
74 return string.replace(/\d/g, function (match) {
75 return symbolMap[match];
76 });
77 },
78 meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी/,
79 meridiemHour : function (hour, meridiem) {
80 if (hour === 12) {
81 hour = 0;
82 }
83 if (meridiem === 'रात्री') {
84 return hour < 4 ? hour : hour + 12;
85 } else if (meridiem === 'सकाळी') {
86 return hour;
87 } else if (meridiem === 'दुपारी') {
88 return hour >= 10 ? hour : hour + 12;
89 } else if (meridiem === 'सायंकाळी') {
90 return hour + 12;
91 }
92 },
93 meridiem: function (hour, minute, isLower) {
94 if (hour < 4) {
95 return 'रात्री';
96 } else if (hour < 10) {
97 return 'सकाळी';
98 } else if (hour < 17) {
99 return 'दुपारी';
100 } else if (hour < 20) {
101 return 'सायंकाळी';
102 } else {
103 return 'रात्री';
104 }
105 },
106 week : {
107 dow : 0, // Sunday is the first day of the week.
108 doy : 6 // The week that contains Jan 1st is the first week of the year.
109 }
110 });
111
0 //! moment.js locale configuration
1 //! locale : Bahasa Malaysia (ms-MY)
2 //! author : Weldan Jamili : https://github.com/weldan
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('ms-my', {
7 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
8 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
9 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
10 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
11 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
12 longDateFormat : {
13 LT : 'HH.mm',
14 LTS : 'HH.mm.ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY [pukul] HH.mm',
18 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
19 },
20 meridiemParse: /pagi|tengahari|petang|malam/,
21 meridiemHour: function (hour, meridiem) {
22 if (hour === 12) {
23 hour = 0;
24 }
25 if (meridiem === 'pagi') {
26 return hour;
27 } else if (meridiem === 'tengahari') {
28 return hour >= 11 ? hour : hour + 12;
29 } else if (meridiem === 'petang' || meridiem === 'malam') {
30 return hour + 12;
31 }
32 },
33 meridiem : function (hours, minutes, isLower) {
34 if (hours < 11) {
35 return 'pagi';
36 } else if (hours < 15) {
37 return 'tengahari';
38 } else if (hours < 19) {
39 return 'petang';
40 } else {
41 return 'malam';
42 }
43 },
44 calendar : {
45 sameDay : '[Hari ini pukul] LT',
46 nextDay : '[Esok pukul] LT',
47 nextWeek : 'dddd [pukul] LT',
48 lastDay : '[Kelmarin pukul] LT',
49 lastWeek : 'dddd [lepas pukul] LT',
50 sameElse : 'L'
51 },
52 relativeTime : {
53 future : 'dalam %s',
54 past : '%s yang lepas',
55 s : 'beberapa saat',
56 m : 'seminit',
57 mm : '%d minit',
58 h : 'sejam',
59 hh : '%d jam',
60 d : 'sehari',
61 dd : '%d hari',
62 M : 'sebulan',
63 MM : '%d bulan',
64 y : 'setahun',
65 yy : '%d tahun'
66 },
67 week : {
68 dow : 1, // Monday is the first day of the week.
69 doy : 7 // The week that contains Jan 1st is the first week of the year.
70 }
71 });
72
0 //! moment.js locale configuration
1 //! locale : Bahasa Malaysia (ms-MY)
2 //! author : Weldan Jamili : https://github.com/weldan
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('ms', {
7 months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
8 monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
9 weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
10 weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
11 weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
12 longDateFormat : {
13 LT : 'HH.mm',
14 LTS : 'HH.mm.ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY [pukul] HH.mm',
18 LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
19 },
20 meridiemParse: /pagi|tengahari|petang|malam/,
21 meridiemHour: function (hour, meridiem) {
22 if (hour === 12) {
23 hour = 0;
24 }
25 if (meridiem === 'pagi') {
26 return hour;
27 } else if (meridiem === 'tengahari') {
28 return hour >= 11 ? hour : hour + 12;
29 } else if (meridiem === 'petang' || meridiem === 'malam') {
30 return hour + 12;
31 }
32 },
33 meridiem : function (hours, minutes, isLower) {
34 if (hours < 11) {
35 return 'pagi';
36 } else if (hours < 15) {
37 return 'tengahari';
38 } else if (hours < 19) {
39 return 'petang';
40 } else {
41 return 'malam';
42 }
43 },
44 calendar : {
45 sameDay : '[Hari ini pukul] LT',
46 nextDay : '[Esok pukul] LT',
47 nextWeek : 'dddd [pukul] LT',
48 lastDay : '[Kelmarin pukul] LT',
49 lastWeek : 'dddd [lepas pukul] LT',
50 sameElse : 'L'
51 },
52 relativeTime : {
53 future : 'dalam %s',
54 past : '%s yang lepas',
55 s : 'beberapa saat',
56 m : 'seminit',
57 mm : '%d minit',
58 h : 'sejam',
59 hh : '%d jam',
60 d : 'sehari',
61 dd : '%d hari',
62 M : 'sebulan',
63 MM : '%d bulan',
64 y : 'setahun',
65 yy : '%d tahun'
66 },
67 week : {
68 dow : 1, // Monday is the first day of the week.
69 doy : 7 // The week that contains Jan 1st is the first week of the year.
70 }
71 });
72
0 //! moment.js locale configuration
1 //! locale : Burmese (my)
2 //! author : Squar team, mysquar.com
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '၁',
8 '2': '၂',
9 '3': '၃',
10 '4': '၄',
11 '5': '၅',
12 '6': '၆',
13 '7': '၇',
14 '8': '၈',
15 '9': '၉',
16 '0': '၀'
17 }, numberMap = {
18 '၁': '1',
19 '၂': '2',
20 '၃': '3',
21 '၄': '4',
22 '၅': '5',
23 '၆': '6',
24 '၇': '7',
25 '၈': '8',
26 '၉': '9',
27 '၀': '0'
28 };
29
30 export default moment.defineLocale('my', {
31 months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
32 monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
33 weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
34 weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
35 weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
36
37 longDateFormat: {
38 LT: 'HH:mm',
39 LTS: 'HH:mm:ss',
40 L: 'DD/MM/YYYY',
41 LL: 'D MMMM YYYY',
42 LLL: 'D MMMM YYYY HH:mm',
43 LLLL: 'dddd D MMMM YYYY HH:mm'
44 },
45 calendar: {
46 sameDay: '[ယနေ.] LT [မှာ]',
47 nextDay: '[မနက်ဖြန်] LT [မှာ]',
48 nextWeek: 'dddd LT [မှာ]',
49 lastDay: '[မနေ.က] LT [မှာ]',
50 lastWeek: '[ပြီးခဲ့သော] dddd LT [မှာ]',
51 sameElse: 'L'
52 },
53 relativeTime: {
54 future: 'လာမည့် %s မှာ',
55 past: 'လွန်ခဲ့သော %s က',
56 s: 'စက္ကန်.အနည်းငယ်',
57 m: 'တစ်မိနစ်',
58 mm: '%d မိနစ်',
59 h: 'တစ်နာရီ',
60 hh: '%d နာရီ',
61 d: 'တစ်ရက်',
62 dd: '%d ရက်',
63 M: 'တစ်လ',
64 MM: '%d လ',
65 y: 'တစ်နှစ်',
66 yy: '%d နှစ်'
67 },
68 preparse: function (string) {
69 return string.replace(/[၁၂၃၄၅၆၇၈၉၀]/g, function (match) {
70 return numberMap[match];
71 });
72 },
73 postformat: function (string) {
74 return string.replace(/\d/g, function (match) {
75 return symbolMap[match];
76 });
77 },
78 week: {
79 dow: 1, // Monday is the first day of the week.
80 doy: 4 // The week that contains Jan 1st is the first week of the year.
81 }
82 });
83
0 //! moment.js locale configuration
1 //! locale : norwegian bokmål (nb)
2 //! authors : Espen Hovlandsdal : https://github.com/rexxars
3 //! Sigurd Gartmann : https://github.com/sigurdga
4
5 import moment from '../moment';
6
7 export default moment.defineLocale('nb', {
8 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
9 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
10 weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
11 weekdaysShort : 'søn_man_tirs_ons_tors_fre_lør'.split('_'),
12 weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
13 longDateFormat : {
14 LT : 'H.mm',
15 LTS : 'H.mm.ss',
16 L : 'DD.MM.YYYY',
17 LL : 'D. MMMM YYYY',
18 LLL : 'D. MMMM YYYY [kl.] H.mm',
19 LLLL : 'dddd D. MMMM YYYY [kl.] H.mm'
20 },
21 calendar : {
22 sameDay: '[i dag kl.] LT',
23 nextDay: '[i morgen kl.] LT',
24 nextWeek: 'dddd [kl.] LT',
25 lastDay: '[i går kl.] LT',
26 lastWeek: '[forrige] dddd [kl.] LT',
27 sameElse: 'L'
28 },
29 relativeTime : {
30 future : 'om %s',
31 past : 'for %s siden',
32 s : 'noen sekunder',
33 m : 'ett minutt',
34 mm : '%d minutter',
35 h : 'en time',
36 hh : '%d timer',
37 d : 'en dag',
38 dd : '%d dager',
39 M : 'en måned',
40 MM : '%d måneder',
41 y : 'ett år',
42 yy : '%d år'
43 },
44 ordinalParse: /\d{1,2}\./,
45 ordinal : '%d.',
46 week : {
47 dow : 1, // Monday is the first day of the week.
48 doy : 4 // The week that contains Jan 4th is the first week of the year.
49 }
50 });
51
0 //! moment.js locale configuration
1 //! locale : nepali/nepalese
2 //! author : suvash : https://github.com/suvash
3
4 import moment from '../moment';
5
6 var symbolMap = {
7 '1': '१',
8 '2': '२',
9 '3': '३',
10 '4': '४',
11 '5': '५',
12 '6': '६',
13 '7': '७',
14 '8': '८',
15 '9': '९',
16 '0': '०'
17 },
18 numberMap = {
19 '१': '1',
20 '२': '2',
21 '३': '3',
22 '४': '4',
23 '५': '5',
24 '६': '6',
25 '७': '7',
26 '८': '8',
27 '९': '9',
28 '०': '0'
29 };
30
31 export default moment.defineLocale('ne', {
32 months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
33 monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
34 weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
35 weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
36 weekdaysMin : 'आइ._सो._मङ्_बु._बि._शु._श.'.split('_'),
37 longDateFormat : {
38 LT : 'Aको h:mm बजे',
39 LTS : 'Aको h:mm:ss बजे',
40 L : 'DD/MM/YYYY',
41 LL : 'D MMMM YYYY',
42 LLL : 'D MMMM YYYY, Aको h:mm बजे',
43 LLLL : 'dddd, D MMMM YYYY, Aको h:mm बजे'
44 },
45 preparse: function (string) {
46 return string.replace(/[१२३४५६७८९०]/g, function (match) {
47 return numberMap[match];
48 });
49 },
50 postformat: function (string) {
51 return string.replace(/\d/g, function (match) {
52 return symbolMap[match];
53 });
54 },
55 meridiemParse: /राती|बिहान|दिउँसो|बेलुका|साँझ|राती/,
56 meridiemHour : function (hour, meridiem) {
57 if (hour === 12) {
58 hour = 0;
59 }
60 if (meridiem === 'राती') {
61 return hour < 3 ? hour : hour + 12;
62 } else if (meridiem === 'बिहान') {
63 return hour;
64 } else if (meridiem === 'दिउँसो') {
65 return hour >= 10 ? hour : hour + 12;
66 } else if (meridiem === 'बेलुका' || meridiem === 'साँझ') {
67 return hour + 12;
68 }
69 },
70 meridiem : function (hour, minute, isLower) {
71 if (hour < 3) {
72 return 'राती';
73 } else if (hour < 10) {
74 return 'बिहान';
75 } else if (hour < 15) {
76 return 'दिउँसो';
77 } else if (hour < 18) {
78 return 'बेलुका';
79 } else if (hour < 20) {
80 return 'साँझ';
81 } else {
82 return 'राती';
83 }
84 },
85 calendar : {
86 sameDay : '[आज] LT',
87 nextDay : '[भोली] LT',
88 nextWeek : '[आउँदो] dddd[,] LT',
89 lastDay : '[हिजो] LT',
90 lastWeek : '[गएको] dddd[,] LT',
91 sameElse : 'L'
92 },
93 relativeTime : {
94 future : '%sमा',
95 past : '%s अगाडी',
96 s : 'केही समय',
97 m : 'एक मिनेट',
98 mm : '%d मिनेट',
99 h : 'एक घण्टा',
100 hh : '%d घण्टा',
101 d : 'एक दिन',
102 dd : '%d दिन',
103 M : 'एक महिना',
104 MM : '%d महिना',
105 y : 'एक बर्ष',
106 yy : '%d बर्ष'
107 },
108 week : {
109 dow : 1, // Monday is the first day of the week.
110 doy : 7 // The week that contains Jan 1st is the first week of the year.
111 }
112 });
113
0 //! moment.js locale configuration
1 //! locale : dutch (nl)
2 //! author : Joris Röling : https://github.com/jjupiter
3
4 import moment from '../moment';
5
6 var monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'),
7 monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
8
9 export default moment.defineLocale('nl', {
10 months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
11 monthsShort : function (m, format) {
12 if (/-MMM-/.test(format)) {
13 return monthsShortWithoutDots[m.month()];
14 } else {
15 return monthsShortWithDots[m.month()];
16 }
17 },
18 weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
19 weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
20 weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
21 longDateFormat : {
22 LT : 'HH:mm',
23 LTS : 'HH:mm:ss',
24 L : 'DD-MM-YYYY',
25 LL : 'D MMMM YYYY',
26 LLL : 'D MMMM YYYY HH:mm',
27 LLLL : 'dddd D MMMM YYYY HH:mm'
28 },
29 calendar : {
30 sameDay: '[vandaag om] LT',
31 nextDay: '[morgen om] LT',
32 nextWeek: 'dddd [om] LT',
33 lastDay: '[gisteren om] LT',
34 lastWeek: '[afgelopen] dddd [om] LT',
35 sameElse: 'L'
36 },
37 relativeTime : {
38 future : 'over %s',
39 past : '%s geleden',
40 s : 'een paar seconden',
41 m : 'één minuut',
42 mm : '%d minuten',
43 h : 'één uur',
44 hh : '%d uur',
45 d : 'één dag',
46 dd : '%d dagen',
47 M : 'één maand',
48 MM : '%d maanden',
49 y : 'één jaar',
50 yy : '%d jaar'
51 },
52 ordinalParse: /\d{1,2}(ste|de)/,
53 ordinal : function (number) {
54 return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
55 },
56 week : {
57 dow : 1, // Monday is the first day of the week.
58 doy : 4 // The week that contains Jan 4th is the first week of the year.
59 }
60 });
61
0 //! moment.js locale configuration
1 //! locale : norwegian nynorsk (nn)
2 //! author : https://github.com/mechuwind
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('nn', {
7 months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
8 monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
9 weekdays : 'sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag'.split('_'),
10 weekdaysShort : 'sun_mån_tys_ons_tor_fre_lau'.split('_'),
11 weekdaysMin : 'su_må_ty_on_to_fr_lø'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD.MM.YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd D MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[I dag klokka] LT',
22 nextDay: '[I morgon klokka] LT',
23 nextWeek: 'dddd [klokka] LT',
24 lastDay: '[I går klokka] LT',
25 lastWeek: '[Føregåande] dddd [klokka] LT',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : 'om %s',
30 past : 'for %s sidan',
31 s : 'nokre sekund',
32 m : 'eit minutt',
33 mm : '%d minutt',
34 h : 'ein time',
35 hh : '%d timar',
36 d : 'ein dag',
37 dd : '%d dagar',
38 M : 'ein månad',
39 MM : '%d månader',
40 y : 'eit år',
41 yy : '%d år'
42 },
43 ordinalParse: /\d{1,2}\./,
44 ordinal : '%d.',
45 week : {
46 dow : 1, // Monday is the first day of the week.
47 doy : 4 // The week that contains Jan 4th is the first week of the year.
48 }
49 });
50
0 //! moment.js locale configuration
1 //! locale : polish (pl)
2 //! author : Rafal Hirsz : https://github.com/evoL
3
4 import moment from '../moment';
5
6 var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_'),
7 monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
8 function plural(n) {
9 return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1);
10 }
11 function translate(number, withoutSuffix, key) {
12 var result = number + ' ';
13 switch (key) {
14 case 'm':
15 return withoutSuffix ? 'minuta' : 'minutę';
16 case 'mm':
17 return result + (plural(number) ? 'minuty' : 'minut');
18 case 'h':
19 return withoutSuffix ? 'godzina' : 'godzinę';
20 case 'hh':
21 return result + (plural(number) ? 'godziny' : 'godzin');
22 case 'MM':
23 return result + (plural(number) ? 'miesiące' : 'miesięcy');
24 case 'yy':
25 return result + (plural(number) ? 'lata' : 'lat');
26 }
27 }
28
29 export default moment.defineLocale('pl', {
30 months : function (momentToFormat, format) {
31 if (format === '') {
32 // Hack: if format empty we know this is used to generate
33 // RegExp by moment. Give then back both valid forms of months
34 // in RegExp ready format.
35 return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
36 } else if (/D MMMM/.test(format)) {
37 return monthsSubjective[momentToFormat.month()];
38 } else {
39 return monthsNominative[momentToFormat.month()];
40 }
41 },
42 monthsShort : 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
43 weekdays : 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
44 weekdaysShort : 'nie_pon_wt_śr_czw_pt_sb'.split('_'),
45 weekdaysMin : 'N_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
46 longDateFormat : {
47 LT : 'HH:mm',
48 LTS : 'HH:mm:ss',
49 L : 'DD.MM.YYYY',
50 LL : 'D MMMM YYYY',
51 LLL : 'D MMMM YYYY HH:mm',
52 LLLL : 'dddd, D MMMM YYYY HH:mm'
53 },
54 calendar : {
55 sameDay: '[Dziś o] LT',
56 nextDay: '[Jutro o] LT',
57 nextWeek: '[W] dddd [o] LT',
58 lastDay: '[Wczoraj o] LT',
59 lastWeek: function () {
60 switch (this.day()) {
61 case 0:
62 return '[W zeszłą niedzielę o] LT';
63 case 3:
64 return '[W zeszłą środę o] LT';
65 case 6:
66 return '[W zeszłą sobotę o] LT';
67 default:
68 return '[W zeszły] dddd [o] LT';
69 }
70 },
71 sameElse: 'L'
72 },
73 relativeTime : {
74 future : 'za %s',
75 past : '%s temu',
76 s : 'kilka sekund',
77 m : translate,
78 mm : translate,
79 h : translate,
80 hh : translate,
81 d : '1 dzień',
82 dd : '%d dni',
83 M : 'miesiąc',
84 MM : translate,
85 y : 'rok',
86 yy : translate
87 },
88 ordinalParse: /\d{1,2}\./,
89 ordinal : '%d.',
90 week : {
91 dow : 1, // Monday is the first day of the week.
92 doy : 4 // The week that contains Jan 4th is the first week of the year.
93 }
94 });
0 //! moment.js locale configuration
1 //! locale : brazilian portuguese (pt-br)
2 //! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('pt-br', {
7 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
8 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
9 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
10 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
11 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D [de] MMMM [de] YYYY',
17 LLL : 'D [de] MMMM [de] YYYY [às] HH:mm',
18 LLLL : 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'
19 },
20 calendar : {
21 sameDay: '[Hoje às] LT',
22 nextDay: '[Amanhã às] LT',
23 nextWeek: 'dddd [às] LT',
24 lastDay: '[Ontem às] LT',
25 lastWeek: function () {
26 return (this.day() === 0 || this.day() === 6) ?
27 '[Último] dddd [às] LT' : // Saturday + Sunday
28 '[Última] dddd [às] LT'; // Monday - Friday
29 },
30 sameElse: 'L'
31 },
32 relativeTime : {
33 future : 'em %s',
34 past : '%s atrás',
35 s : 'poucos segundos',
36 m : 'um minuto',
37 mm : '%d minutos',
38 h : 'uma hora',
39 hh : '%d horas',
40 d : 'um dia',
41 dd : '%d dias',
42 M : 'um mês',
43 MM : '%d meses',
44 y : 'um ano',
45 yy : '%d anos'
46 },
47 ordinalParse: /\d{1,2}º/,
48 ordinal : '%dº'
49 });
50
0 //! moment.js locale configuration
1 //! locale : portuguese (pt)
2 //! author : Jefferson : https://github.com/jalex79
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('pt', {
7 months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
8 monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
9 weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
10 weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
11 weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D [de] MMMM [de] YYYY',
17 LLL : 'D [de] MMMM [de] YYYY HH:mm',
18 LLLL : 'dddd, D [de] MMMM [de] YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[Hoje às] LT',
22 nextDay: '[Amanhã às] LT',
23 nextWeek: 'dddd [às] LT',
24 lastDay: '[Ontem às] LT',
25 lastWeek: function () {
26 return (this.day() === 0 || this.day() === 6) ?
27 '[Último] dddd [às] LT' : // Saturday + Sunday
28 '[Última] dddd [às] LT'; // Monday - Friday
29 },
30 sameElse: 'L'
31 },
32 relativeTime : {
33 future : 'em %s',
34 past : 'há %s',
35 s : 'segundos',
36 m : 'um minuto',
37 mm : '%d minutos',
38 h : 'uma hora',
39 hh : '%d horas',
40 d : 'um dia',
41 dd : '%d dias',
42 M : 'um mês',
43 MM : '%d meses',
44 y : 'um ano',
45 yy : '%d anos'
46 },
47 ordinalParse: /\d{1,2}º/,
48 ordinal : '%dº',
49 week : {
50 dow : 1, // Monday is the first day of the week.
51 doy : 4 // The week that contains Jan 4th is the first week of the year.
52 }
53 });
54
0 //! moment.js locale configuration
1 //! locale : romanian (ro)
2 //! author : Vlad Gurdiga : https://github.com/gurdiga
3 //! author : Valentin Agachi : https://github.com/avaly
4
5 import moment from '../moment';
6
7 function relativeTimeWithPlural(number, withoutSuffix, key) {
8 var format = {
9 'mm': 'minute',
10 'hh': 'ore',
11 'dd': 'zile',
12 'MM': 'luni',
13 'yy': 'ani'
14 },
15 separator = ' ';
16 if (number % 100 >= 20 || (number >= 100 && number % 100 === 0)) {
17 separator = ' de ';
18 }
19 return number + separator + format[key];
20 }
21
22 export default moment.defineLocale('ro', {
23 months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
24 monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
25 weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
26 weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
27 weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
28 longDateFormat : {
29 LT : 'H:mm',
30 LTS : 'H:mm:ss',
31 L : 'DD.MM.YYYY',
32 LL : 'D MMMM YYYY',
33 LLL : 'D MMMM YYYY H:mm',
34 LLLL : 'dddd, D MMMM YYYY H:mm'
35 },
36 calendar : {
37 sameDay: '[azi la] LT',
38 nextDay: '[mâine la] LT',
39 nextWeek: 'dddd [la] LT',
40 lastDay: '[ieri la] LT',
41 lastWeek: '[fosta] dddd [la] LT',
42 sameElse: 'L'
43 },
44 relativeTime : {
45 future : 'peste %s',
46 past : '%s în urmă',
47 s : 'câteva secunde',
48 m : 'un minut',
49 mm : relativeTimeWithPlural,
50 h : 'o oră',
51 hh : relativeTimeWithPlural,
52 d : 'o zi',
53 dd : relativeTimeWithPlural,
54 M : 'o lună',
55 MM : relativeTimeWithPlural,
56 y : 'un an',
57 yy : relativeTimeWithPlural
58 },
59 week : {
60 dow : 1, // Monday is the first day of the week.
61 doy : 7 // The week that contains Jan 1st is the first week of the year.
62 }
63 });
64
0 //! moment.js locale configuration
1 //! locale : russian (ru)
2 //! author : Viktorminator : https://github.com/Viktorminator
3 //! Author : Menelion Elensúle : https://github.com/Oire
4
5 import moment from '../moment';
6
7 function plural(word, num) {
8 var forms = word.split('_');
9 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
10 }
11 function relativeTimeWithPlural(number, withoutSuffix, key) {
12 var format = {
13 'mm': withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
14 'hh': 'час_часа_часов',
15 'dd': 'день_дня_дней',
16 'MM': 'месяц_месяца_месяцев',
17 'yy': 'год_года_лет'
18 };
19 if (key === 'm') {
20 return withoutSuffix ? 'минута' : 'минуту';
21 }
22 else {
23 return number + ' ' + plural(format[key], +number);
24 }
25 }
26 function monthsCaseReplace(m, format) {
27 var months = {
28 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
29 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
30 },
31 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
32 'accusative' :
33 'nominative';
34 return months[nounCase][m.month()];
35 }
36 function monthsShortCaseReplace(m, format) {
37 var monthsShort = {
38 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
39 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
40 },
41 nounCase = (/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/).test(format) ?
42 'accusative' :
43 'nominative';
44 return monthsShort[nounCase][m.month()];
45 }
46 function weekdaysCaseReplace(m, format) {
47 var weekdays = {
48 'nominative': 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
49 'accusative': 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_')
50 },
51 nounCase = (/\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/).test(format) ?
52 'accusative' :
53 'nominative';
54 return weekdays[nounCase][m.day()];
55 }
56
57 export default moment.defineLocale('ru', {
58 months : monthsCaseReplace,
59 monthsShort : monthsShortCaseReplace,
60 weekdays : weekdaysCaseReplace,
61 weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
62 weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
63 monthsParse : [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i],
64 longDateFormat : {
65 LT : 'HH:mm',
66 LTS : 'HH:mm:ss',
67 L : 'DD.MM.YYYY',
68 LL : 'D MMMM YYYY г.',
69 LLL : 'D MMMM YYYY г., HH:mm',
70 LLLL : 'dddd, D MMMM YYYY г., HH:mm'
71 },
72 calendar : {
73 sameDay: '[Сегодня в] LT',
74 nextDay: '[Завтра в] LT',
75 lastDay: '[Вчера в] LT',
76 nextWeek: function () {
77 return this.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
78 },
79 lastWeek: function (now) {
80 if (now.week() !== this.week()) {
81 switch (this.day()) {
82 case 0:
83 return '[В прошлое] dddd [в] LT';
84 case 1:
85 case 2:
86 case 4:
87 return '[В прошлый] dddd [в] LT';
88 case 3:
89 case 5:
90 case 6:
91 return '[В прошлую] dddd [в] LT';
92 }
93 } else {
94 if (this.day() === 2) {
95 return '[Во] dddd [в] LT';
96 } else {
97 return '[В] dddd [в] LT';
98 }
99 }
100 },
101 sameElse: 'L'
102 },
103 relativeTime : {
104 future : 'через %s',
105 past : '%s назад',
106 s : 'несколько секунд',
107 m : relativeTimeWithPlural,
108 mm : relativeTimeWithPlural,
109 h : 'час',
110 hh : relativeTimeWithPlural,
111 d : 'день',
112 dd : relativeTimeWithPlural,
113 M : 'месяц',
114 MM : relativeTimeWithPlural,
115 y : 'год',
116 yy : relativeTimeWithPlural
117 },
118 meridiemParse: /ночи|утра|дня|вечера/i,
119 isPM : function (input) {
120 return /^(дня|вечера)$/.test(input);
121 },
122 meridiem : function (hour, minute, isLower) {
123 if (hour < 4) {
124 return 'ночи';
125 } else if (hour < 12) {
126 return 'утра';
127 } else if (hour < 17) {
128 return 'дня';
129 } else {
130 return 'вечера';
131 }
132 },
133 ordinalParse: /\d{1,2}-(й|го|я)/,
134 ordinal: function (number, period) {
135 switch (period) {
136 case 'M':
137 case 'd':
138 case 'DDD':
139 return number + '-й';
140 case 'D':
141 return number + '-го';
142 case 'w':
143 case 'W':
144 return number + '-я';
145 default:
146 return number;
147 }
148 },
149 week : {
150 dow : 1, // Monday is the first day of the week.
151 doy : 7 // The week that contains Jan 1st is the first week of the year.
152 }
153 });
154
0 //! moment.js locale configuration
1 //! locale : Sinhalese (si)
2 //! author : Sampath Sitinamaluwa : https://github.com/sampathsris
3
4 import moment from '../moment';
5
6 /*jshint -W100*/
7 export default moment.defineLocale('si', {
8 months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්‍රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
9 monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
10 weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
11 weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'),
12 weekdaysMin : 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'),
13 longDateFormat : {
14 LT : 'a h:mm',
15 LTS : 'a h:mm:ss',
16 L : 'YYYY/MM/DD',
17 LL : 'YYYY MMMM D',
18 LLL : 'YYYY MMMM D, a h:mm',
19 LLLL : 'YYYY MMMM D [වැනි] dddd, a h:mm:ss'
20 },
21 calendar : {
22 sameDay : '[අද] LT[ට]',
23 nextDay : '[හෙට] LT[ට]',
24 nextWeek : 'dddd LT[ට]',
25 lastDay : '[ඊයේ] LT[ට]',
26 lastWeek : '[පසුගිය] dddd LT[ට]',
27 sameElse : 'L'
28 },
29 relativeTime : {
30 future : '%sකින්',
31 past : '%sකට පෙර',
32 s : 'තත්පර කිහිපය',
33 m : 'මිනිත්තුව',
34 mm : 'මිනිත්තු %d',
35 h : 'පැය',
36 hh : 'පැය %d',
37 d : 'දිනය',
38 dd : 'දින %d',
39 M : 'මාසය',
40 MM : 'මාස %d',
41 y : 'වසර',
42 yy : 'වසර %d'
43 },
44 ordinalParse: /\d{1,2} වැනි/,
45 ordinal : function (number) {
46 return number + ' වැනි';
47 },
48 meridiem : function (hours, minutes, isLower) {
49 if (hours > 11) {
50 return isLower ? 'ප.ව.' : 'පස් වරු';
51 } else {
52 return isLower ? 'පෙ.ව.' : 'පෙර වරු';
53 }
54 }
55 });
0 //! moment.js locale configuration
1 //! locale : slovak (sk)
2 //! author : Martin Minka : https://github.com/k2s
3 //! based on work of petrbela : https://github.com/petrbela
4
5 import moment from '../moment';
6
7 var months = 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_'),
8 monthsShort = 'jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec'.split('_');
9 function plural(n) {
10 return (n > 1) && (n < 5);
11 }
12 function translate(number, withoutSuffix, key, isFuture) {
13 var result = number + ' ';
14 switch (key) {
15 case 's': // a few seconds / in a few seconds / a few seconds ago
16 return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
17 case 'm': // a minute / in a minute / a minute ago
18 return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou');
19 case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
20 if (withoutSuffix || isFuture) {
21 return result + (plural(number) ? 'minúty' : 'minút');
22 } else {
23 return result + 'minútami';
24 }
25 break;
26 case 'h': // an hour / in an hour / an hour ago
27 return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
28 case 'hh': // 9 hours / in 9 hours / 9 hours ago
29 if (withoutSuffix || isFuture) {
30 return result + (plural(number) ? 'hodiny' : 'hodín');
31 } else {
32 return result + 'hodinami';
33 }
34 break;
35 case 'd': // a day / in a day / a day ago
36 return (withoutSuffix || isFuture) ? 'deň' : 'dňom';
37 case 'dd': // 9 days / in 9 days / 9 days ago
38 if (withoutSuffix || isFuture) {
39 return result + (plural(number) ? 'dni' : 'dní');
40 } else {
41 return result + 'dňami';
42 }
43 break;
44 case 'M': // a month / in a month / a month ago
45 return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom';
46 case 'MM': // 9 months / in 9 months / 9 months ago
47 if (withoutSuffix || isFuture) {
48 return result + (plural(number) ? 'mesiace' : 'mesiacov');
49 } else {
50 return result + 'mesiacmi';
51 }
52 break;
53 case 'y': // a year / in a year / a year ago
54 return (withoutSuffix || isFuture) ? 'rok' : 'rokom';
55 case 'yy': // 9 years / in 9 years / 9 years ago
56 if (withoutSuffix || isFuture) {
57 return result + (plural(number) ? 'roky' : 'rokov');
58 } else {
59 return result + 'rokmi';
60 }
61 break;
62 }
63 }
64
65 export default moment.defineLocale('sk', {
66 months : months,
67 monthsShort : monthsShort,
68 monthsParse : (function (months, monthsShort) {
69 var i, _monthsParse = [];
70 for (i = 0; i < 12; i++) {
71 // use custom parser to solve problem with July (červenec)
72 _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
73 }
74 return _monthsParse;
75 }(months, monthsShort)),
76 weekdays : 'nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota'.split('_'),
77 weekdaysShort : 'ne_po_ut_st_št_pi_so'.split('_'),
78 weekdaysMin : 'ne_po_ut_st_št_pi_so'.split('_'),
79 longDateFormat : {
80 LT: 'H:mm',
81 LTS : 'H:mm:ss',
82 L : 'DD.MM.YYYY',
83 LL : 'D. MMMM YYYY',
84 LLL : 'D. MMMM YYYY H:mm',
85 LLLL : 'dddd D. MMMM YYYY H:mm'
86 },
87 calendar : {
88 sameDay: '[dnes o] LT',
89 nextDay: '[zajtra o] LT',
90 nextWeek: function () {
91 switch (this.day()) {
92 case 0:
93 return '[v nedeľu o] LT';
94 case 1:
95 case 2:
96 return '[v] dddd [o] LT';
97 case 3:
98 return '[v stredu o] LT';
99 case 4:
100 return '[vo štvrtok o] LT';
101 case 5:
102 return '[v piatok o] LT';
103 case 6:
104 return '[v sobotu o] LT';
105 }
106 },
107 lastDay: '[včera o] LT',
108 lastWeek: function () {
109 switch (this.day()) {
110 case 0:
111 return '[minulú nedeľu o] LT';
112 case 1:
113 case 2:
114 return '[minulý] dddd [o] LT';
115 case 3:
116 return '[minulú stredu o] LT';
117 case 4:
118 case 5:
119 return '[minulý] dddd [o] LT';
120 case 6:
121 return '[minulú sobotu o] LT';
122 }
123 },
124 sameElse: 'L'
125 },
126 relativeTime : {
127 future : 'za %s',
128 past : 'pred %s',
129 s : translate,
130 m : translate,
131 mm : translate,
132 h : translate,
133 hh : translate,
134 d : translate,
135 dd : translate,
136 M : translate,
137 MM : translate,
138 y : translate,
139 yy : translate
140 },
141 ordinalParse: /\d{1,2}\./,
142 ordinal : '%d.',
143 week : {
144 dow : 1, // Monday is the first day of the week.
145 doy : 4 // The week that contains Jan 4th is the first week of the year.
146 }
147 });
148
0 //! moment.js locale configuration
1 //! locale : slovenian (sl)
2 //! author : Robert Sedovšek : https://github.com/sedovsek
3
4 import moment from '../moment';
5
6 function processRelativeTime(number, withoutSuffix, key, isFuture) {
7 var result = number + ' ';
8 switch (key) {
9 case 's':
10 return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
11 case 'm':
12 return withoutSuffix ? 'ena minuta' : 'eno minuto';
13 case 'mm':
14 if (number === 1) {
15 result += withoutSuffix ? 'minuta' : 'minuto';
16 } else if (number === 2) {
17 result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
18 } else if (number < 5) {
19 result += withoutSuffix || isFuture ? 'minute' : 'minutami';
20 } else {
21 result += withoutSuffix || isFuture ? 'minut' : 'minutami';
22 }
23 return result;
24 case 'h':
25 return withoutSuffix ? 'ena ura' : 'eno uro';
26 case 'hh':
27 if (number === 1) {
28 result += withoutSuffix ? 'ura' : 'uro';
29 } else if (number === 2) {
30 result += withoutSuffix || isFuture ? 'uri' : 'urama';
31 } else if (number < 5) {
32 result += withoutSuffix || isFuture ? 'ure' : 'urami';
33 } else {
34 result += withoutSuffix || isFuture ? 'ur' : 'urami';
35 }
36 return result;
37 case 'd':
38 return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
39 case 'dd':
40 if (number === 1) {
41 result += withoutSuffix || isFuture ? 'dan' : 'dnem';
42 } else if (number === 2) {
43 result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
44 } else {
45 result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
46 }
47 return result;
48 case 'M':
49 return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
50 case 'MM':
51 if (number === 1) {
52 result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
53 } else if (number === 2) {
54 result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
55 } else if (number < 5) {
56 result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
57 } else {
58 result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
59 }
60 return result;
61 case 'y':
62 return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
63 case 'yy':
64 if (number === 1) {
65 result += withoutSuffix || isFuture ? 'leto' : 'letom';
66 } else if (number === 2) {
67 result += withoutSuffix || isFuture ? 'leti' : 'letoma';
68 } else if (number < 5) {
69 result += withoutSuffix || isFuture ? 'leta' : 'leti';
70 } else {
71 result += withoutSuffix || isFuture ? 'let' : 'leti';
72 }
73 return result;
74 }
75 }
76
77 export default moment.defineLocale('sl', {
78 months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
79 monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
80 weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
81 weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
82 weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
83 longDateFormat : {
84 LT : 'H:mm',
85 LTS : 'H:mm:ss',
86 L : 'DD. MM. YYYY',
87 LL : 'D. MMMM YYYY',
88 LLL : 'D. MMMM YYYY H:mm',
89 LLLL : 'dddd, D. MMMM YYYY H:mm'
90 },
91 calendar : {
92 sameDay : '[danes ob] LT',
93 nextDay : '[jutri ob] LT',
94
95 nextWeek : function () {
96 switch (this.day()) {
97 case 0:
98 return '[v] [nedeljo] [ob] LT';
99 case 3:
100 return '[v] [sredo] [ob] LT';
101 case 6:
102 return '[v] [soboto] [ob] LT';
103 case 1:
104 case 2:
105 case 4:
106 case 5:
107 return '[v] dddd [ob] LT';
108 }
109 },
110 lastDay : '[včeraj ob] LT',
111 lastWeek : function () {
112 switch (this.day()) {
113 case 0:
114 return '[prejšnjo] [nedeljo] [ob] LT';
115 case 3:
116 return '[prejšnjo] [sredo] [ob] LT';
117 case 6:
118 return '[prejšnjo] [soboto] [ob] LT';
119 case 1:
120 case 2:
121 case 4:
122 case 5:
123 return '[prejšnji] dddd [ob] LT';
124 }
125 },
126 sameElse : 'L'
127 },
128 relativeTime : {
129 future : 'čez %s',
130 past : 'pred %s',
131 s : processRelativeTime,
132 m : processRelativeTime,
133 mm : processRelativeTime,
134 h : processRelativeTime,
135 hh : processRelativeTime,
136 d : processRelativeTime,
137 dd : processRelativeTime,
138 M : processRelativeTime,
139 MM : processRelativeTime,
140 y : processRelativeTime,
141 yy : processRelativeTime
142 },
143 ordinalParse: /\d{1,2}\./,
144 ordinal : '%d.',
145 week : {
146 dow : 1, // Monday is the first day of the week.
147 doy : 7 // The week that contains Jan 1st is the first week of the year.
148 }
149 });
0 //! moment.js locale configuration
1 //! locale : Albanian (sq)
2 //! author : Flakërim Ismani : https://github.com/flakerimi
3 //! author: Menelion Elensúle: https://github.com/Oire (tests)
4 //! author : Oerd Cukalla : https://github.com/oerd (fixes)
5
6 import moment from '../moment';
7
8 export default moment.defineLocale('sq', {
9 months : 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'),
10 monthsShort : 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'),
11 weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
12 weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
13 weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
14 meridiemParse: /PD|MD/,
15 isPM: function (input) {
16 return input.charAt(0) === 'M';
17 },
18 meridiem : function (hours, minutes, isLower) {
19 return hours < 12 ? 'PD' : 'MD';
20 },
21 longDateFormat : {
22 LT : 'HH:mm',
23 LTS : 'HH:mm:ss',
24 L : 'DD/MM/YYYY',
25 LL : 'D MMMM YYYY',
26 LLL : 'D MMMM YYYY HH:mm',
27 LLLL : 'dddd, D MMMM YYYY HH:mm'
28 },
29 calendar : {
30 sameDay : '[Sot në] LT',
31 nextDay : '[Nesër në] LT',
32 nextWeek : 'dddd [në] LT',
33 lastDay : '[Dje në] LT',
34 lastWeek : 'dddd [e kaluar në] LT',
35 sameElse : 'L'
36 },
37 relativeTime : {
38 future : 'në %s',
39 past : '%s më parë',
40 s : 'disa sekonda',
41 m : 'një minutë',
42 mm : '%d minuta',
43 h : 'një orë',
44 hh : '%d orë',
45 d : 'një ditë',
46 dd : '%d ditë',
47 M : 'një muaj',
48 MM : '%d muaj',
49 y : 'një vit',
50 yy : '%d vite'
51 },
52 ordinalParse: /\d{1,2}\./,
53 ordinal : '%d.',
54 week : {
55 dow : 1, // Monday is the first day of the week.
56 doy : 4 // The week that contains Jan 4th is the first week of the year.
57 }
58 });
59
0 //! moment.js locale configuration
1 //! locale : Serbian-cyrillic (sr-cyrl)
2 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
3
4 import moment from '../moment';
5
6 var translator = {
7 words: { //Different grammatical cases
8 m: ['један минут', 'једне минуте'],
9 mm: ['минут', 'минуте', 'минута'],
10 h: ['један сат', 'једног сата'],
11 hh: ['сат', 'сата', 'сати'],
12 dd: ['дан', 'дана', 'дана'],
13 MM: ['месец', 'месеца', 'месеци'],
14 yy: ['година', 'године', 'година']
15 },
16 correctGrammaticalCase: function (number, wordKey) {
17 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
18 },
19 translate: function (number, withoutSuffix, key) {
20 var wordKey = translator.words[key];
21 if (key.length === 1) {
22 return withoutSuffix ? wordKey[0] : wordKey[1];
23 } else {
24 return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
25 }
26 }
27 };
28
29 export default moment.defineLocale('sr-cyrl', {
30 months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
31 monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
32 weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
33 weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
34 weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
35 longDateFormat: {
36 LT: 'H:mm',
37 LTS : 'H:mm:ss',
38 L: 'DD. MM. YYYY',
39 LL: 'D. MMMM YYYY',
40 LLL: 'D. MMMM YYYY H:mm',
41 LLLL: 'dddd, D. MMMM YYYY H:mm'
42 },
43 calendar: {
44 sameDay: '[данас у] LT',
45 nextDay: '[сутра у] LT',
46 nextWeek: function () {
47 switch (this.day()) {
48 case 0:
49 return '[у] [недељу] [у] LT';
50 case 3:
51 return '[у] [среду] [у] LT';
52 case 6:
53 return '[у] [суботу] [у] LT';
54 case 1:
55 case 2:
56 case 4:
57 case 5:
58 return '[у] dddd [у] LT';
59 }
60 },
61 lastDay : '[јуче у] LT',
62 lastWeek : function () {
63 var lastWeekDays = [
64 '[прошле] [недеље] [у] LT',
65 '[прошлог] [понедељка] [у] LT',
66 '[прошлог] [уторка] [у] LT',
67 '[прошле] [среде] [у] LT',
68 '[прошлог] [четвртка] [у] LT',
69 '[прошлог] [петка] [у] LT',
70 '[прошле] [суботе] [у] LT'
71 ];
72 return lastWeekDays[this.day()];
73 },
74 sameElse : 'L'
75 },
76 relativeTime : {
77 future : 'за %s',
78 past : 'пре %s',
79 s : 'неколико секунди',
80 m : translator.translate,
81 mm : translator.translate,
82 h : translator.translate,
83 hh : translator.translate,
84 d : 'дан',
85 dd : translator.translate,
86 M : 'месец',
87 MM : translator.translate,
88 y : 'годину',
89 yy : translator.translate
90 },
91 ordinalParse: /\d{1,2}\./,
92 ordinal : '%d.',
93 week : {
94 dow : 1, // Monday is the first day of the week.
95 doy : 7 // The week that contains Jan 1st is the first week of the year.
96 }
97 });
98
0 //! moment.js locale configuration
1 //! locale : Serbian-latin (sr)
2 //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
3
4 import moment from '../moment';
5
6 var translator = {
7 words: { //Different grammatical cases
8 m: ['jedan minut', 'jedne minute'],
9 mm: ['minut', 'minute', 'minuta'],
10 h: ['jedan sat', 'jednog sata'],
11 hh: ['sat', 'sata', 'sati'],
12 dd: ['dan', 'dana', 'dana'],
13 MM: ['mesec', 'meseca', 'meseci'],
14 yy: ['godina', 'godine', 'godina']
15 },
16 correctGrammaticalCase: function (number, wordKey) {
17 return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
18 },
19 translate: function (number, withoutSuffix, key) {
20 var wordKey = translator.words[key];
21 if (key.length === 1) {
22 return withoutSuffix ? wordKey[0] : wordKey[1];
23 } else {
24 return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
25 }
26 }
27 };
28
29 export default moment.defineLocale('sr', {
30 months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
31 monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
32 weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
33 weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
34 weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
35 longDateFormat: {
36 LT: 'H:mm',
37 LTS : 'H:mm:ss',
38 L: 'DD. MM. YYYY',
39 LL: 'D. MMMM YYYY',
40 LLL: 'D. MMMM YYYY H:mm',
41 LLLL: 'dddd, D. MMMM YYYY H:mm'
42 },
43 calendar: {
44 sameDay: '[danas u] LT',
45 nextDay: '[sutra u] LT',
46 nextWeek: function () {
47 switch (this.day()) {
48 case 0:
49 return '[u] [nedelju] [u] LT';
50 case 3:
51 return '[u] [sredu] [u] LT';
52 case 6:
53 return '[u] [subotu] [u] LT';
54 case 1:
55 case 2:
56 case 4:
57 case 5:
58 return '[u] dddd [u] LT';
59 }
60 },
61 lastDay : '[juče u] LT',
62 lastWeek : function () {
63 var lastWeekDays = [
64 '[prošle] [nedelje] [u] LT',
65 '[prošlog] [ponedeljka] [u] LT',
66 '[prošlog] [utorka] [u] LT',
67 '[prošle] [srede] [u] LT',
68 '[prošlog] [četvrtka] [u] LT',
69 '[prošlog] [petka] [u] LT',
70 '[prošle] [subote] [u] LT'
71 ];
72 return lastWeekDays[this.day()];
73 },
74 sameElse : 'L'
75 },
76 relativeTime : {
77 future : 'za %s',
78 past : 'pre %s',
79 s : 'nekoliko sekundi',
80 m : translator.translate,
81 mm : translator.translate,
82 h : translator.translate,
83 hh : translator.translate,
84 d : 'dan',
85 dd : translator.translate,
86 M : 'mesec',
87 MM : translator.translate,
88 y : 'godinu',
89 yy : translator.translate
90 },
91 ordinalParse: /\d{1,2}\./,
92 ordinal : '%d.',
93 week : {
94 dow : 1, // Monday is the first day of the week.
95 doy : 7 // The week that contains Jan 1st is the first week of the year.
96 }
97 });
98
0 //! moment.js locale configuration
1 //! locale : swedish (sv)
2 //! author : Jens Alm : https://github.com/ulmus
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('sv', {
7 months : 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
8 monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
9 weekdays : 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
10 weekdaysShort : 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
11 weekdaysMin : 'sö_må_ti_on_to_fr_lö'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'YYYY-MM-DD',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd D MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[Idag] LT',
22 nextDay: '[Imorgon] LT',
23 lastDay: '[Igår] LT',
24 nextWeek: '[På] dddd LT',
25 lastWeek: '[I] dddd[s] LT',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : 'om %s',
30 past : 'för %s sedan',
31 s : 'några sekunder',
32 m : 'en minut',
33 mm : '%d minuter',
34 h : 'en timme',
35 hh : '%d timmar',
36 d : 'en dag',
37 dd : '%d dagar',
38 M : 'en månad',
39 MM : '%d månader',
40 y : 'ett år',
41 yy : '%d år'
42 },
43 ordinalParse: /\d{1,2}(e|a)/,
44 ordinal : function (number) {
45 var b = number % 10,
46 output = (~~(number % 100 / 10) === 1) ? 'e' :
47 (b === 1) ? 'a' :
48 (b === 2) ? 'a' :
49 (b === 3) ? 'e' : 'e';
50 return number + output;
51 },
52 week : {
53 dow : 1, // Monday is the first day of the week.
54 doy : 4 // The week that contains Jan 4th is the first week of the year.
55 }
56 });
57
0 //! moment.js locale configuration
1 //! locale : tamil (ta)
2 //! author : Arjunkumar Krishnamoorthy : https://github.com/tk120404
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('ta', {
7 months : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
8 monthsShort : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
9 weekdays : 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'),
10 weekdaysShort : 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'),
11 weekdaysMin : 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY, HH:mm',
18 LLLL : 'dddd, D MMMM YYYY, HH:mm'
19 },
20 calendar : {
21 sameDay : '[இன்று] LT',
22 nextDay : '[நாளை] LT',
23 nextWeek : 'dddd, LT',
24 lastDay : '[நேற்று] LT',
25 lastWeek : '[கடந்த வாரம்] dddd, LT',
26 sameElse : 'L'
27 },
28 relativeTime : {
29 future : '%s இல்',
30 past : '%s முன்',
31 s : 'ஒரு சில விநாடிகள்',
32 m : 'ஒரு நிமிடம்',
33 mm : '%d நிமிடங்கள்',
34 h : 'ஒரு மணி நேரம்',
35 hh : '%d மணி நேரம்',
36 d : 'ஒரு நாள்',
37 dd : '%d நாட்கள்',
38 M : 'ஒரு மாதம்',
39 MM : '%d மாதங்கள்',
40 y : 'ஒரு வருடம்',
41 yy : '%d ஆண்டுகள்'
42 },
43 ordinalParse: /\d{1,2}வது/,
44 ordinal : function (number) {
45 return number + 'வது';
46 },
47 // refer http://ta.wikipedia.org/s/1er1
48 meridiemParse: /யாமம்|வைகறை|காலை|நண்பகல்|எற்பாடு|மாலை/,
49 meridiem : function (hour, minute, isLower) {
50 if (hour < 2) {
51 return ' யாமம்';
52 } else if (hour < 6) {
53 return ' வைகறை'; // வைகறை
54 } else if (hour < 10) {
55 return ' காலை'; // காலை
56 } else if (hour < 14) {
57 return ' நண்பகல்'; // நண்பகல்
58 } else if (hour < 18) {
59 return ' எற்பாடு'; // எற்பாடு
60 } else if (hour < 22) {
61 return ' மாலை'; // மாலை
62 } else {
63 return ' யாமம்';
64 }
65 },
66 meridiemHour : function (hour, meridiem) {
67 if (hour === 12) {
68 hour = 0;
69 }
70 if (meridiem === 'யாமம்') {
71 return hour < 2 ? hour : hour + 12;
72 } else if (meridiem === 'வைகறை' || meridiem === 'காலை') {
73 return hour;
74 } else if (meridiem === 'நண்பகல்') {
75 return hour >= 10 ? hour : hour + 12;
76 } else {
77 return hour + 12;
78 }
79 },
80 week : {
81 dow : 0, // Sunday is the first day of the week.
82 doy : 6 // The week that contains Jan 1st is the first week of the year.
83 }
84 });
85
0 //! moment.js locale configuration
1 //! locale : thai (th)
2 //! author : Kridsada Thanabulpong : https://github.com/sirn
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('th', {
7 months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
8 monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
9 weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
10 weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
11 weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
12 longDateFormat : {
13 LT : 'H นาฬิกา m นาที',
14 LTS : 'H นาฬิกา m นาที s วินาที',
15 L : 'YYYY/MM/DD',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY เวลา H นาฬิกา m นาที',
18 LLLL : 'วันddddที่ D MMMM YYYY เวลา H นาฬิกา m นาที'
19 },
20 meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
21 isPM: function (input) {
22 return input === 'หลังเที่ยง';
23 },
24 meridiem : function (hour, minute, isLower) {
25 if (hour < 12) {
26 return 'ก่อนเที่ยง';
27 } else {
28 return 'หลังเที่ยง';
29 }
30 },
31 calendar : {
32 sameDay : '[วันนี้ เวลา] LT',
33 nextDay : '[พรุ่งนี้ เวลา] LT',
34 nextWeek : 'dddd[หน้า เวลา] LT',
35 lastDay : '[เมื่อวานนี้ เวลา] LT',
36 lastWeek : '[วัน]dddd[ที่แล้ว เวลา] LT',
37 sameElse : 'L'
38 },
39 relativeTime : {
40 future : 'อีก %s',
41 past : '%sที่แล้ว',
42 s : 'ไม่กี่วินาที',
43 m : '1 นาที',
44 mm : '%d นาที',
45 h : '1 ชั่วโมง',
46 hh : '%d ชั่วโมง',
47 d : '1 วัน',
48 dd : '%d วัน',
49 M : '1 เดือน',
50 MM : '%d เดือน',
51 y : '1 ปี',
52 yy : '%d ปี'
53 }
54 });
55
0 //! moment.js locale configuration
1 //! locale : Tagalog/Filipino (tl-ph)
2 //! author : Dan Hagman
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('tl-ph', {
7 months : 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'),
8 monthsShort : 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'),
9 weekdays : 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'),
10 weekdaysShort : 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'),
11 weekdaysMin : 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'MM/D/YYYY',
16 LL : 'MMMM D, YYYY',
17 LLL : 'MMMM D, YYYY HH:mm',
18 LLLL : 'dddd, MMMM DD, YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[Ngayon sa] LT',
22 nextDay: '[Bukas sa] LT',
23 nextWeek: 'dddd [sa] LT',
24 lastDay: '[Kahapon sa] LT',
25 lastWeek: 'dddd [huling linggo] LT',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : 'sa loob ng %s',
30 past : '%s ang nakalipas',
31 s : 'ilang segundo',
32 m : 'isang minuto',
33 mm : '%d minuto',
34 h : 'isang oras',
35 hh : '%d oras',
36 d : 'isang araw',
37 dd : '%d araw',
38 M : 'isang buwan',
39 MM : '%d buwan',
40 y : 'isang taon',
41 yy : '%d taon'
42 },
43 ordinalParse: /\d{1,2}/,
44 ordinal : function (number) {
45 return number;
46 },
47 week : {
48 dow : 1, // Monday is the first day of the week.
49 doy : 4 // The week that contains Jan 4th is the first week of the year.
50 }
51 });
52
0 //! moment.js locale configuration
1 //! locale : turkish (tr)
2 //! authors : Erhan Gundogan : https://github.com/erhangundogan,
3 //! Burak Yiğit Kaya: https://github.com/BYK
4
5 import moment from '../moment';
6
7 var suffixes = {
8 1: '\'inci',
9 5: '\'inci',
10 8: '\'inci',
11 70: '\'inci',
12 80: '\'inci',
13 2: '\'nci',
14 7: '\'nci',
15 20: '\'nci',
16 50: '\'nci',
17 3: '\'üncü',
18 4: '\'üncü',
19 100: '\'üncü',
20 6: '\'ncı',
21 9: '\'uncu',
22 10: '\'uncu',
23 30: '\'uncu',
24 60: '\'ıncı',
25 90: '\'ıncı'
26 };
27
28 export default moment.defineLocale('tr', {
29 months : 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
30 monthsShort : 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'),
31 weekdays : 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
32 weekdaysShort : 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'),
33 weekdaysMin : 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'),
34 longDateFormat : {
35 LT : 'HH:mm',
36 LTS : 'HH:mm:ss',
37 L : 'DD.MM.YYYY',
38 LL : 'D MMMM YYYY',
39 LLL : 'D MMMM YYYY HH:mm',
40 LLLL : 'dddd, D MMMM YYYY HH:mm'
41 },
42 calendar : {
43 sameDay : '[bugün saat] LT',
44 nextDay : '[yarın saat] LT',
45 nextWeek : '[haftaya] dddd [saat] LT',
46 lastDay : '[dün] LT',
47 lastWeek : '[geçen hafta] dddd [saat] LT',
48 sameElse : 'L'
49 },
50 relativeTime : {
51 future : '%s sonra',
52 past : '%s önce',
53 s : 'birkaç saniye',
54 m : 'bir dakika',
55 mm : '%d dakika',
56 h : 'bir saat',
57 hh : '%d saat',
58 d : 'bir gün',
59 dd : '%d gün',
60 M : 'bir ay',
61 MM : '%d ay',
62 y : 'bir yıl',
63 yy : '%d yıl'
64 },
65 ordinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
66 ordinal : function (number) {
67 if (number === 0) { // special case for zero
68 return number + '\'ıncı';
69 }
70 var a = number % 10,
71 b = number % 100 - a,
72 c = number >= 100 ? 100 : null;
73 return number + (suffixes[a] || suffixes[b] || suffixes[c]);
74 },
75 week : {
76 dow : 1, // Monday is the first day of the week.
77 doy : 7 // The week that contains Jan 1st is the first week of the year.
78 }
79 });
80
0 //! moment.js locale configuration
1 //! locale : talossan (tzl)
2 //! author : Robin van der Vliet : https://github.com/robin0van0der0v with the help of Iustì Canun
3
4
5 import moment from '../moment';
6
7 // After the year there should be a slash and the amount of years since December 26, 1979 in Roman numerals.
8 // This is currently too difficult (maybe even impossible) to add.
9 export default moment.defineLocale('tzl', {
10 months : 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'),
11 monthsShort : 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'),
12 weekdays : 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'),
13 weekdaysShort : 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'),
14 weekdaysMin : 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'),
15 longDateFormat : {
16 LT : 'HH.mm',
17 LTS : 'LT.ss',
18 L : 'DD.MM.YYYY',
19 LL : 'D. MMMM [dallas] YYYY',
20 LLL : 'D. MMMM [dallas] YYYY LT',
21 LLLL : 'dddd, [li] D. MMMM [dallas] YYYY LT'
22 },
23 meridiem : function (hours, minutes, isLower) {
24 if (hours > 11) {
25 return isLower ? 'd\'o' : 'D\'O';
26 } else {
27 return isLower ? 'd\'a' : 'D\'A';
28 }
29 },
30 calendar : {
31 sameDay : '[oxhi à] LT',
32 nextDay : '[demà à] LT',
33 nextWeek : 'dddd [à] LT',
34 lastDay : '[ieiri à] LT',
35 lastWeek : '[sür el] dddd [lasteu à] LT',
36 sameElse : 'L'
37 },
38 relativeTime : {
39 future : 'osprei %s',
40 past : 'ja%s',
41 s : processRelativeTime,
42 m : processRelativeTime,
43 mm : processRelativeTime,
44 h : processRelativeTime,
45 hh : processRelativeTime,
46 d : processRelativeTime,
47 dd : processRelativeTime,
48 M : processRelativeTime,
49 MM : processRelativeTime,
50 y : processRelativeTime,
51 yy : processRelativeTime
52 },
53 ordinalParse: /\d{1,2}\./,
54 ordinal : '%d.',
55 week : {
56 dow : 1, // Monday is the first day of the week.
57 doy : 4 // The week that contains Jan 4th is the first week of the year.
58 }
59 });
60
61 function processRelativeTime(number, withoutSuffix, key, isFuture) {
62 var format = {
63 's': ['viensas secunds', '\'iensas secunds'],
64 'm': ['\'n míut', '\'iens míut'],
65 'mm': [number + ' míuts', ' ' + number + ' míuts'],
66 'h': ['\'n þora', '\'iensa þora'],
67 'hh': [number + ' þoras', ' ' + number + ' þoras'],
68 'd': ['\'n ziua', '\'iensa ziua'],
69 'dd': [number + ' ziuas', ' ' + number + ' ziuas'],
70 'M': ['\'n mes', '\'iens mes'],
71 'MM': [number + ' mesen', ' ' + number + ' mesen'],
72 'y': ['\'n ar', '\'iens ar'],
73 'yy': [number + ' ars', ' ' + number + ' ars']
74 };
75 return isFuture ? format[key][0] : (withoutSuffix ? format[key][0] : format[key][1].trim());
76 }
77
0 //! moment.js locale configuration
1 //! locale : Morocco Central Atlas Tamaziɣt in Latin (tzm-latn)
2 //! author : Abdel Said : https://github.com/abdelsaid
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('tzm-latn', {
7 months : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
8 monthsShort : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
9 weekdays : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
10 weekdaysShort : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
11 weekdaysMin : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd D MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[asdkh g] LT',
22 nextDay: '[aska g] LT',
23 nextWeek: 'dddd [g] LT',
24 lastDay: '[assant g] LT',
25 lastWeek: 'dddd [g] LT',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : 'dadkh s yan %s',
30 past : 'yan %s',
31 s : 'imik',
32 m : 'minuḍ',
33 mm : '%d minuḍ',
34 h : 'saɛa',
35 hh : '%d tassaɛin',
36 d : 'ass',
37 dd : '%d ossan',
38 M : 'ayowr',
39 MM : '%d iyyirn',
40 y : 'asgas',
41 yy : '%d isgasn'
42 },
43 week : {
44 dow : 6, // Saturday is the first day of the week.
45 doy : 12 // The week that contains Jan 1st is the first week of the year.
46 }
47 });
48
0 //! moment.js locale configuration
1 //! locale : Morocco Central Atlas Tamaziɣt (tzm)
2 //! author : Abdel Said : https://github.com/abdelsaid
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('tzm', {
7 months : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
8 monthsShort : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
9 weekdays : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
10 weekdaysShort : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
11 weekdaysMin : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS: 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'dddd D MMMM YYYY HH:mm'
19 },
20 calendar : {
21 sameDay: '[ⴰⵙⴷⵅ ⴴ] LT',
22 nextDay: '[ⴰⵙⴽⴰ ⴴ] LT',
23 nextWeek: 'dddd [ⴴ] LT',
24 lastDay: '[ⴰⵚⴰⵏⵜ ⴴ] LT',
25 lastWeek: 'dddd [ⴴ] LT',
26 sameElse: 'L'
27 },
28 relativeTime : {
29 future : 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s',
30 past : 'ⵢⴰⵏ %s',
31 s : 'ⵉⵎⵉⴽ',
32 m : 'ⵎⵉⵏⵓⴺ',
33 mm : '%d ⵎⵉⵏⵓⴺ',
34 h : 'ⵙⴰⵄⴰ',
35 hh : '%d ⵜⴰⵙⵙⴰⵄⵉⵏ',
36 d : 'ⴰⵙⵙ',
37 dd : '%d oⵙⵙⴰⵏ',
38 M : 'ⴰⵢoⵓⵔ',
39 MM : '%d ⵉⵢⵢⵉⵔⵏ',
40 y : 'ⴰⵙⴳⴰⵙ',
41 yy : '%d ⵉⵙⴳⴰⵙⵏ'
42 },
43 week : {
44 dow : 6, // Saturday is the first day of the week.
45 doy : 12 // The week that contains Jan 1st is the first week of the year.
46 }
47 });
48
0 //! moment.js locale configuration
1 //! locale : ukrainian (uk)
2 //! author : zemlanin : https://github.com/zemlanin
3 //! Author : Menelion Elensúle : https://github.com/Oire
4
5 import moment from '../moment';
6
7 function plural(word, num) {
8 var forms = word.split('_');
9 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
10 }
11 function relativeTimeWithPlural(number, withoutSuffix, key) {
12 var format = {
13 'mm': 'хвилина_хвилини_хвилин',
14 'hh': 'година_години_годин',
15 'dd': 'день_дні_днів',
16 'MM': 'місяць_місяці_місяців',
17 'yy': 'рік_роки_років'
18 };
19 if (key === 'm') {
20 return withoutSuffix ? 'хвилина' : 'хвилину';
21 }
22 else if (key === 'h') {
23 return withoutSuffix ? 'година' : 'годину';
24 }
25 else {
26 return number + ' ' + plural(format[key], +number);
27 }
28 }
29 function monthsCaseReplace(m, format) {
30 var months = {
31 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
32 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
33 },
34 nounCase = (/D[oD]? *MMMM?/).test(format) ?
35 'accusative' :
36 'nominative';
37 return months[nounCase][m.month()];
38 }
39 function weekdaysCaseReplace(m, format) {
40 var weekdays = {
41 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
42 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
43 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
44 },
45 nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
46 'accusative' :
47 ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
48 'genitive' :
49 'nominative');
50 return weekdays[nounCase][m.day()];
51 }
52 function processHoursFunction(str) {
53 return function () {
54 return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
55 };
56 }
57
58 export default moment.defineLocale('uk', {
59 months : monthsCaseReplace,
60 monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
61 weekdays : weekdaysCaseReplace,
62 weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
63 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
64 longDateFormat : {
65 LT : 'HH:mm',
66 LTS : 'HH:mm:ss',
67 L : 'DD.MM.YYYY',
68 LL : 'D MMMM YYYY р.',
69 LLL : 'D MMMM YYYY р., HH:mm',
70 LLLL : 'dddd, D MMMM YYYY р., HH:mm'
71 },
72 calendar : {
73 sameDay: processHoursFunction('[Сьогодні '),
74 nextDay: processHoursFunction('[Завтра '),
75 lastDay: processHoursFunction('[Вчора '),
76 nextWeek: processHoursFunction('[У] dddd ['),
77 lastWeek: function () {
78 switch (this.day()) {
79 case 0:
80 case 3:
81 case 5:
82 case 6:
83 return processHoursFunction('[Минулої] dddd [').call(this);
84 case 1:
85 case 2:
86 case 4:
87 return processHoursFunction('[Минулого] dddd [').call(this);
88 }
89 },
90 sameElse: 'L'
91 },
92 relativeTime : {
93 future : 'за %s',
94 past : '%s тому',
95 s : 'декілька секунд',
96 m : relativeTimeWithPlural,
97 mm : relativeTimeWithPlural,
98 h : 'годину',
99 hh : relativeTimeWithPlural,
100 d : 'день',
101 dd : relativeTimeWithPlural,
102 M : 'місяць',
103 MM : relativeTimeWithPlural,
104 y : 'рік',
105 yy : relativeTimeWithPlural
106 },
107 // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
108 meridiemParse: /ночі|ранку|дня|вечора/,
109 isPM: function (input) {
110 return /^(дня|вечора)$/.test(input);
111 },
112 meridiem : function (hour, minute, isLower) {
113 if (hour < 4) {
114 return 'ночі';
115 } else if (hour < 12) {
116 return 'ранку';
117 } else if (hour < 17) {
118 return 'дня';
119 } else {
120 return 'вечора';
121 }
122 },
123 ordinalParse: /\d{1,2}-(й|го)/,
124 ordinal: function (number, period) {
125 switch (period) {
126 case 'M':
127 case 'd':
128 case 'DDD':
129 case 'w':
130 case 'W':
131 return number + '-й';
132 case 'D':
133 return number + '-го';
134 default:
135 return number;
136 }
137 },
138 week : {
139 dow : 1, // Monday is the first day of the week.
140 doy : 7 // The week that contains Jan 1st is the first week of the year.
141 }
142 });
143
0 //! moment.js locale configuration
1 //! locale : uzbek (uz)
2 //! author : Sardor Muminov : https://github.com/muminoff
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('uz', {
7 months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
8 monthsShort : 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'),
9 weekdays : 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'),
10 weekdaysShort : 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'),
11 weekdaysMin : 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM YYYY',
17 LLL : 'D MMMM YYYY HH:mm',
18 LLLL : 'D MMMM YYYY, dddd HH:mm'
19 },
20 calendar : {
21 sameDay : '[Бугун соат] LT [да]',
22 nextDay : '[Эртага] LT [да]',
23 nextWeek : 'dddd [куни соат] LT [да]',
24 lastDay : '[Кеча соат] LT [да]',
25 lastWeek : '[Утган] dddd [куни соат] LT [да]',
26 sameElse : 'L'
27 },
28 relativeTime : {
29 future : 'Якин %s ичида',
30 past : 'Бир неча %s олдин',
31 s : 'фурсат',
32 m : 'бир дакика',
33 mm : '%d дакика',
34 h : 'бир соат',
35 hh : '%d соат',
36 d : 'бир кун',
37 dd : '%d кун',
38 M : 'бир ой',
39 MM : '%d ой',
40 y : 'бир йил',
41 yy : '%d йил'
42 },
43 week : {
44 dow : 1, // Monday is the first day of the week.
45 doy : 7 // The week that contains Jan 4th is the first week of the year.
46 }
47 });
48
0 //! moment.js locale configuration
1 //! locale : vietnamese (vi)
2 //! author : Bang Nguyen : https://github.com/bangnk
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('vi', {
7 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('_'),
8 monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
9 weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
10 weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
11 weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
12 longDateFormat : {
13 LT : 'HH:mm',
14 LTS : 'HH:mm:ss',
15 L : 'DD/MM/YYYY',
16 LL : 'D MMMM [năm] YYYY',
17 LLL : 'D MMMM [năm] YYYY HH:mm',
18 LLLL : 'dddd, D MMMM [năm] YYYY HH:mm',
19 l : 'DD/M/YYYY',
20 ll : 'D MMM YYYY',
21 lll : 'D MMM YYYY HH:mm',
22 llll : 'ddd, D MMM YYYY HH:mm'
23 },
24 calendar : {
25 sameDay: '[Hôm nay lúc] LT',
26 nextDay: '[Ngày mai lúc] LT',
27 nextWeek: 'dddd [tuần tới lúc] LT',
28 lastDay: '[Hôm qua lúc] LT',
29 lastWeek: 'dddd [tuần rồi lúc] LT',
30 sameElse: 'L'
31 },
32 relativeTime : {
33 future : '%s tới',
34 past : '%s trước',
35 s : 'vài giây',
36 m : 'một phút',
37 mm : '%d phút',
38 h : 'một giờ',
39 hh : '%d giờ',
40 d : 'một ngày',
41 dd : '%d ngày',
42 M : 'một tháng',
43 MM : '%d tháng',
44 y : 'một năm',
45 yy : '%d năm'
46 },
47 ordinalParse: /\d{1,2}/,
48 ordinal : function (number) {
49 return number;
50 },
51 week : {
52 dow : 1, // Monday is the first day of the week.
53 doy : 4 // The week that contains Jan 4th is the first week of the year.
54 }
55 });
56
0 //! moment.js locale configuration
1 //! locale : chinese (zh-cn)
2 //! author : suupic : https://github.com/suupic
3 //! author : Zeno Zeng : https://github.com/zenozeng
4
5 import moment from '../moment';
6
7 export default moment.defineLocale('zh-cn', {
8 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
9 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
10 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
11 weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
12 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
13 longDateFormat : {
14 LT : 'Ah点mm分',
15 LTS : 'Ah点m分s秒',
16 L : 'YYYY-MM-DD',
17 LL : 'YYYY年MMMD日',
18 LLL : 'YYYY年MMMD日Ah点mm分',
19 LLLL : 'YYYY年MMMD日ddddAh点mm分',
20 l : 'YYYY-MM-DD',
21 ll : 'YYYY年MMMD日',
22 lll : 'YYYY年MMMD日Ah点mm分',
23 llll : 'YYYY年MMMD日ddddAh点mm分'
24 },
25 meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
26 meridiemHour: function (hour, meridiem) {
27 if (hour === 12) {
28 hour = 0;
29 }
30 if (meridiem === '凌晨' || meridiem === '早上' ||
31 meridiem === '上午') {
32 return hour;
33 } else if (meridiem === '下午' || meridiem === '晚上') {
34 return hour + 12;
35 } else {
36 // '中午'
37 return hour >= 11 ? hour : hour + 12;
38 }
39 },
40 meridiem : function (hour, minute, isLower) {
41 var hm = hour * 100 + minute;
42 if (hm < 600) {
43 return '凌晨';
44 } else if (hm < 900) {
45 return '早上';
46 } else if (hm < 1130) {
47 return '上午';
48 } else if (hm < 1230) {
49 return '中午';
50 } else if (hm < 1800) {
51 return '下午';
52 } else {
53 return '晚上';
54 }
55 },
56 calendar : {
57 sameDay : function () {
58 return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT';
59 },
60 nextDay : function () {
61 return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT';
62 },
63 lastDay : function () {
64 return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT';
65 },
66 nextWeek : function () {
67 var startOfWeek, prefix;
68 startOfWeek = moment().startOf('week');
69 prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
70 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
71 },
72 lastWeek : function () {
73 var startOfWeek, prefix;
74 startOfWeek = moment().startOf('week');
75 prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]';
76 return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
77 },
78 sameElse : 'LL'
79 },
80 ordinalParse: /\d{1,2}(日|月|周)/,
81 ordinal : function (number, period) {
82 switch (period) {
83 case 'd':
84 case 'D':
85 case 'DDD':
86 return number + '日';
87 case 'M':
88 return number + '月';
89 case 'w':
90 case 'W':
91 return number + '周';
92 default:
93 return number;
94 }
95 },
96 relativeTime : {
97 future : '%s内',
98 past : '%s前',
99 s : '几秒',
100 m : '1 分钟',
101 mm : '%d 分钟',
102 h : '1 小时',
103 hh : '%d 小时',
104 d : '1 天',
105 dd : '%d 天',
106 M : '1 个月',
107 MM : '%d 个月',
108 y : '1 年',
109 yy : '%d 年'
110 },
111 week : {
112 // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
113 dow : 1, // Monday is the first day of the week.
114 doy : 4 // The week that contains Jan 4th is the first week of the year.
115 }
116 });
117
0 //! moment.js locale configuration
1 //! locale : traditional chinese (zh-tw)
2 //! author : Ben : https://github.com/ben-lin
3
4 import moment from '../moment';
5
6 export default moment.defineLocale('zh-tw', {
7 months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
8 monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
9 weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
10 weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
11 weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
12 longDateFormat : {
13 LT : 'Ah點mm分',
14 LTS : 'Ah點m分s秒',
15 L : 'YYYY年MMMD日',
16 LL : 'YYYY年MMMD日',
17 LLL : 'YYYY年MMMD日Ah點mm分',
18 LLLL : 'YYYY年MMMD日ddddAh點mm分',
19 l : 'YYYY年MMMD日',
20 ll : 'YYYY年MMMD日',
21 lll : 'YYYY年MMMD日Ah點mm分',
22 llll : 'YYYY年MMMD日ddddAh點mm分'
23 },
24 meridiemParse: /早上|上午|中午|下午|晚上/,
25 meridiemHour : function (hour, meridiem) {
26 if (hour === 12) {
27 hour = 0;
28 }
29 if (meridiem === '早上' || meridiem === '上午') {
30 return hour;
31 } else if (meridiem === '中午') {
32 return hour >= 11 ? hour : hour + 12;
33 } else if (meridiem === '下午' || meridiem === '晚上') {
34 return hour + 12;
35 }
36 },
37 meridiem : function (hour, minute, isLower) {
38 var hm = hour * 100 + minute;
39 if (hm < 900) {
40 return '早上';
41 } else if (hm < 1130) {
42 return '上午';
43 } else if (hm < 1230) {
44 return '中午';
45 } else if (hm < 1800) {
46 return '下午';
47 } else {
48 return '晚上';
49 }
50 },
51 calendar : {
52 sameDay : '[今天]LT',
53 nextDay : '[明天]LT',
54 nextWeek : '[下]ddddLT',
55 lastDay : '[昨天]LT',
56 lastWeek : '[上]ddddLT',
57 sameElse : 'L'
58 },
59 ordinalParse: /\d{1,2}(日|月|週)/,
60 ordinal : function (number, period) {
61 switch (period) {
62 case 'd' :
63 case 'D' :
64 case 'DDD' :
65 return number + '日';
66 case 'M' :
67 return number + '月';
68 case 'w' :
69 case 'W' :
70 return number + '週';
71 default :
72 return number;
73 }
74 },
75 relativeTime : {
76 future : '%s內',
77 past : '%s前',
78 s : '幾秒',
79 m : '一分鐘',
80 mm : '%d分鐘',
81 h : '一小時',
82 hh : '%d小時',
83 d : '一天',
84 dd : '%d天',
85 M : '一個月',
86 MM : '%d個月',
87 y : '一年',
88 yy : '%d年'
89 }
90 });
0 //! moment.js
1 //! version : 2.10.6
2 //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
3 //! license : MIT
4 //! momentjs.com
5
6 import { hooks as moment, setHookCallback } from './lib/utils/hooks';
7
8 moment.version = '2.10.6';
9
10 import {
11 min,
12 max,
13 isMoment,
14 momentPrototype as fn,
15 createUTC as utc,
16 createUnix as unix,
17 createLocal as local,
18 createInvalid as invalid,
19 createInZone as parseZone
20 } from './lib/moment/moment';
21
22 import {
23 defineLocale,
24 getSetGlobalLocale as locale,
25 getLocale as localeData,
26 listMonths as months,
27 listMonthsShort as monthsShort,
28 listWeekdays as weekdays,
29 listWeekdaysMin as weekdaysMin,
30 listWeekdaysShort as weekdaysShort
31 } from './lib/locale/locale';
32
33 import {
34 isDuration,
35 createDuration as duration,
36 getSetRelativeTimeThreshold as relativeTimeThreshold
37 } from './lib/duration/duration';
38
39 import { normalizeUnits } from './lib/units/units';
40
41 import isDate from './lib/utils/is-date';
42
43 setHookCallback(local);
44
45 moment.fn = fn;
46 moment.min = min;
47 moment.max = max;
48 moment.utc = utc;
49 moment.unix = unix;
50 moment.months = months;
51 moment.isDate = isDate;
52 moment.locale = locale;
53 moment.invalid = invalid;
54 moment.duration = duration;
55 moment.isMoment = isMoment;
56 moment.weekdays = weekdays;
57 moment.parseZone = parseZone;
58 moment.localeData = localeData;
59 moment.isDuration = isDuration;
60 moment.monthsShort = monthsShort;
61 moment.weekdaysMin = weekdaysMin;
62 moment.defineLocale = defineLocale;
63 moment.weekdaysShort = weekdaysShort;
64 moment.normalizeUnits = normalizeUnits;
65 moment.relativeTimeThreshold = relativeTimeThreshold;
66
67 export default moment;
0 function each(array, callback) {
1 var i;
2 for (i = 0; i < array.length; i++) {
3 callback(array[i], i, array);
4 }
5 }
6
7 export default each;
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('af');
3
4 test('parse', function (assert) {
5 var tests = 'Januarie Jan_Februarie Feb_Maart Mar_April Apr_Mei Mei_Junie Jun_Julie Jul_Augustus Aug_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sondag, Februarie 14de 2010, 3:25:50 nm'],
25 ['ddd, hA', 'Son, 3NM'],
26 ['M Mo MM MMMM MMM', '2 2de 02 Februarie Feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14de 14'],
29 ['d do dddd ddd dd', '0 0de Sondag Son So'],
30 ['DDD DDDo DDDD', '45 45ste 045'],
31 ['w wo ww', '6 6de 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'nm NM'],
37 ['[the] DDDo [day of the year]', 'the 45ste day of the year'],
38 ['LT', '15:25'],
39 ['LTS', '15:25:50'],
40 ['L', '14/02/2010'],
41 ['LL', '14 Februarie 2010'],
42 ['LLL', '14 Februarie 2010 15:25'],
43 ['LLLL', 'Sondag, 14 Februarie 2010 15:25'],
44 ['l', '14/2/2010'],
45 ['ll', '14 Feb 2010'],
46 ['lll', '14 Feb 2010 15:25'],
47 ['llll', 'Son, 14 Feb 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4de', '4de');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5de', '5de');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6de', '6de');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7de', '7de');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14de', '14de');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15de', '15de');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16de', '16de');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17de', '17de');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ste', '24ste');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ste', '25ste');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ste', '26ste');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ste', '27ste');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'Januarie Jan_Februarie Feb_Maart Mar_April Apr_Mei Mei_Junie Jun_Julie Jul_Augustus Aug_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'Sondag Son So_Maandag Maa Ma_Dinsdag Din Di_Woensdag Woe Wo_Donderdag Don Do_Vrydag Vry Vr_Saterdag Sat Sa'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '\'n paar sekondes', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '\'n minuut', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '\'n minuut', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minute', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '\'n uur', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '\'n uur', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ure', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ure', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ure', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '\'n dag', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '\'n dag', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dae', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '\'n dag', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dae', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dae', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '\'n maand', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '\'n maand', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '\'n maand', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 maande', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 maande', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 maande', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '\'n maand', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 maande', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '\'n jaar', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jaar', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '\'n jaar', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jaar', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'oor \'n paar sekondes', 'prefix');
141 assert.equal(moment(0).from(30000), '\'n paar sekondes gelede', 'suffix');
142 });
143
144 test('now from now', function (assert) {
145 assert.equal(moment().fromNow(), '\'n paar sekondes gelede', 'now from now should display as in the past');
146 });
147
148 test('fromNow', function (assert) {
149 assert.equal(moment().add({s: 30}).fromNow(), 'oor \'n paar sekondes', 'in a few seconds');
150 assert.equal(moment().add({d: 5}).fromNow(), 'oor 5 dae', 'in 5 days');
151 });
152
153 test('calendar day', function (assert) {
154 var a = moment().hours(2).minutes(0).seconds(0);
155
156 assert.equal(moment(a).calendar(), 'Vandag om 02:00', 'today at the same time');
157 assert.equal(moment(a).add({m: 25}).calendar(), 'Vandag om 02:25', 'Now plus 25 min');
158 assert.equal(moment(a).add({h: 1}).calendar(), 'Vandag om 03:00', 'Now plus 1 hour');
159 assert.equal(moment(a).add({d: 1}).calendar(), 'Môre om 02:00', 'tomorrow at the same time');
160 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Vandag om 01:00', 'Now minus 1 hour');
161 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gister om 02:00', 'yesterday at the same time');
162 });
163
164 test('calendar next week', function (assert) {
165 var i, m;
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[Laas] dddd [om] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[Laas] dddd [om] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[Laas] dddd [om] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
204 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
206 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
212 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
213 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
214 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
215 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
222 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
223 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
224 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
231 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
232 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
233 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
240 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
241 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
242 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
247 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
248 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
249 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
250 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
251 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
252 });
253
254 test('weeks year starting saturday', function (assert) {
255 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
256 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
257 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
258 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
259 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
260 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
261 });
262
263 test('weeks year starting sunday formatted', function (assert) {
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1ste', 'Jan 8 2012 should be week 1');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2');
268 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
269 });
270
271 test('lenient ordinal parsing', function (assert) {
272 var i, ordinalStr, testMoment;
273 for (i = 1; i <= 31; ++i) {
274 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
275 testMoment = moment(ordinalStr, 'YYYY MM Do');
276 assert.equal(testMoment.year(), 2014,
277 'lenient ordinal parsing ' + i + ' year check');
278 assert.equal(testMoment.month(), 0,
279 'lenient ordinal parsing ' + i + ' month check');
280 assert.equal(testMoment.date(), i,
281 'lenient ordinal parsing ' + i + ' date check');
282 }
283 });
284
285 test('lenient ordinal parsing of number', function (assert) {
286 var i, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
289 assert.equal(testMoment.year(), 2014,
290 'lenient ordinal parsing of number ' + i + ' year check');
291 assert.equal(testMoment.month(), 0,
292 'lenient ordinal parsing of number ' + i + ' month check');
293 assert.equal(testMoment.date(), i,
294 'lenient ordinal parsing of number ' + i + ' date check');
295 }
296 });
297
298 test('strict ordinal parsing', function (assert) {
299 var i, ordinalStr, testMoment;
300 for (i = 1; i <= 31; ++i) {
301 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
302 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
303 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
304 }
305 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ar-ma');
3
4 test('parse', function (assert) {
5 var tests = 'يناير:يناير_فبراير:فبراير_مارس:مارس_أبريل:أبريل_ماي:ماي_يونيو:يونيو_يوليوز:يوليوز_غشت:غشت_شتنبر:شتنبر_أكتوبر:أكتوبر_نونبر:نونبر_دجنبر:دجنبر'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(':');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فبراير 14 2010, 3:25:50 pm'],
25 ['ddd, hA', 'احد, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2 02 فبراير فبراير'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 الأحد احد ح'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '8 8 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
38 ['LT', '15:25'],
39 ['LTS', '15:25:50'],
40 ['L', '14/02/2010'],
41 ['LL', '14 فبراير 2010'],
42 ['LLL', '14 فبراير 2010 15:25'],
43 ['LLLL', 'الأحد 14 فبراير 2010 15:25'],
44 ['l', '14/2/2010'],
45 ['ll', '14 فبراير 2010'],
46 ['lll', '14 فبراير 2010 15:25'],
47 ['llll', 'احد 14 فبراير 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'يناير يناير_فبراير فبراير_مارس مارس_أبريل أبريل_ماي ماي_يونيو يونيو_يوليوز يوليوز_غشت غشت_شتنبر شتنبر_أكتوبر أكتوبر_نونبر نونبر_دجنبر دجنبر'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'الأحد احد ح_الإتنين اتنين ن_الثلاثاء ثلاثاء ث_الأربعاء اربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ثوان', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'دقيقة', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'دقيقة', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 دقائق', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 دقائق', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ساعة', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ساعة', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ساعات', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ساعات', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ساعات', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'يوم', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'يوم', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 أيام', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'يوم', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 أيام', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 أيام', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'شهر', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'شهر', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'شهر', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 أشهر', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 أشهر', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 أشهر', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'شهر', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 أشهر', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'سنة', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 سنوات', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'سنة', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 سنوات', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'في ثوان', 'prefix');
141 assert.equal(moment(0).from(30000), 'منذ ثوان', 'suffix');
142 });
143
144 test('now from now', function (assert) {
145 assert.equal(moment().fromNow(), 'منذ ثوان', 'now from now should display as in the past');
146 });
147
148 test('fromNow', function (assert) {
149 assert.equal(moment().add({s: 30}).fromNow(), 'في ثوان', 'in a few seconds');
150 assert.equal(moment().add({d: 5}).fromNow(), 'في 5 أيام', 'in 5 days');
151 });
152
153 test('calendar day', function (assert) {
154 var a = moment().hours(2).minutes(0).seconds(0);
155
156 assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
157 assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
158 assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
159 assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
160 assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
161 assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
162 });
163
164 test('calendar next week', function (assert) {
165 var i, m;
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
204 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
205 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
206 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
207 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
212 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
213 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
214 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
215 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
222 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
223 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
224 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
231 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
232 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
233 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
240 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
241 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
242 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
247 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
248 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
249 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
250 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
251 });
252
253 test('weeks year starting saturday', function (assert) {
254 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
255 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
256 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
257 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
258 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
259 });
260
261 test('weeks year starting sunday formatted', function (assert) {
262 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
263 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
264 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 should be week 2');
265 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2');
266 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
267 });
268
269 test('lenient ordinal parsing', function (assert) {
270 var i, ordinalStr, testMoment;
271 for (i = 1; i <= 31; ++i) {
272 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
273 testMoment = moment(ordinalStr, 'YYYY MM Do');
274 assert.equal(testMoment.year(), 2014,
275 'lenient ordinal parsing ' + i + ' year check');
276 assert.equal(testMoment.month(), 0,
277 'lenient ordinal parsing ' + i + ' month check');
278 assert.equal(testMoment.date(), i,
279 'lenient ordinal parsing ' + i + ' date check');
280 }
281 });
282
283 test('lenient ordinal parsing of number', function (assert) {
284 var i, testMoment;
285 for (i = 1; i <= 31; ++i) {
286 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
287 assert.equal(testMoment.year(), 2014,
288 'lenient ordinal parsing of number ' + i + ' year check');
289 assert.equal(testMoment.month(), 0,
290 'lenient ordinal parsing of number ' + i + ' month check');
291 assert.equal(testMoment.date(), i,
292 'lenient ordinal parsing of number ' + i + ' date check');
293 }
294 });
295
296 test('strict ordinal parsing', function (assert) {
297 var i, ordinalStr, testMoment;
298 for (i = 1; i <= 31; ++i) {
299 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
300 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
301 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
302 }
303 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ar-sa');
3
4 test('parse', function (assert) {
5 var tests = 'يناير:يناير_فبراير:فبراير_مارس:مارس_أبريل:أبريل_مايو:مايو_يونيو:يونيو_يوليو:يوليو_أغسطس:أغسطس_سبتمبر:سبتمبر_أكتوبر:أكتوبر_نوفمبر:نوفمبر_ديسمبر:ديسمبر'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(':');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد، فبراير ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'],
25 ['ddd, hA', 'أحد، ٣م'],
26 ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ فبراير فبراير'],
27 ['YYYY YY', '٢٠١٠ ١٠'],
28 ['D Do DD', '١٤ ١٤ ١٤'],
29 ['d do dddd ddd dd', '٠ ٠ الأحد أحد ح'],
30 ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'],
31 ['w wo ww', '٨ ٨ ٠٨'],
32 ['h hh', '٣ ٠٣'],
33 ['H HH', '١٥ ١٥'],
34 ['m mm', '٢٥ ٢٥'],
35 ['s ss', '٥٠ ٥٠'],
36 ['a A', 'م م'],
37 ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'],
38 ['LT', '١٥:٢٥'],
39 ['LTS', '١٥:٢٥:٥٠'],
40 ['L', '١٤/٠٢/٢٠١٠'],
41 ['LL', '١٤ فبراير ٢٠١٠'],
42 ['LLL', '١٤ فبراير ٢٠١٠ ١٥:٢٥'],
43 ['LLLL', 'الأحد ١٤ فبراير ٢٠١٠ ١٥:٢٥'],
44 ['l', '١٤/٢/٢٠١٠'],
45 ['ll', '١٤ فبراير ٢٠١٠'],
46 ['lll', '١٤ فبراير ٢٠١٠ ١٥:٢٥'],
47 ['llll', 'أحد ١٤ فبراير ٢٠١٠ ١٥:٢٥']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '١', '1');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '٢', '2');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '٣', '3');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '٤', '4');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '٥', '5');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '٦', '6');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '٧', '7');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '٨', '8');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '٩', '9');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '١٠', '10');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '١١', '11');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '١٢', '12');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '١٣', '13');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '١٤', '14');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '١٥', '15');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '١٦', '16');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '١٧', '17');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '١٨', '18');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '١٩', '19');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '٢١', '21');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '٣١', '31');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'يناير يناير_فبراير فبراير_مارس مارس_أبريل أبريل_مايو مايو_يونيو يونيو_يوليو يوليو_أغسطس أغسطس_سبتمبر سبتمبر_أكتوبر أكتوبر_نوفمبر نوفمبر_ديسمبر ديسمبر'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'الأحد أحد ح_الإثنين إثنين ن_الثلاثاء ثلاثاء ث_الأربعاء أربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ثوان', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'دقيقة', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'دقيقة', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '٢ دقائق', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '٤٤ دقائق', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ساعة', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ساعة', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '٢ ساعات', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '٥ ساعات', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '٢١ ساعات', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'يوم', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'يوم', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '٢ أيام', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'يوم', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '٥ أيام', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '٢٥ أيام', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'شهر', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'شهر', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'شهر', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '٢ أشهر', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '٢ أشهر', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '٣ أشهر', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'شهر', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '٥ أشهر', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'سنة', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '٢ سنوات', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'سنة', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '٥ سنوات', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'في ثوان', 'prefix');
141 assert.equal(moment(0).from(30000), 'منذ ثوان', 'suffix');
142 });
143
144 test('now from now', function (assert) {
145 assert.equal(moment().fromNow(), 'منذ ثوان', 'now from now should display as in the past');
146 });
147
148 test('fromNow', function (assert) {
149 assert.equal(moment().add({s: 30}).fromNow(), 'في ثوان', 'in a few seconds');
150 assert.equal(moment().add({d: 5}).fromNow(), 'في ٥ أيام', 'in 5 days');
151 });
152
153 test('calendar day', function (assert) {
154 var a = moment().hours(2).minutes(0).seconds(0);
155
156 assert.equal(moment(a).calendar(), 'اليوم على الساعة ٠٢:٠٠', 'today at the same time');
157 assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة ٠٢:٢٥', 'Now plus 25 min');
158 assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة ٠٣:٠٠', 'Now plus 1 hour');
159 assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة ٠٢:٠٠', 'tomorrow at the same time');
160 assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة ٠١:٠٠', 'Now minus 1 hour');
161 assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة ٠٢:٠٠', 'yesterday at the same time');
162 });
163
164 test('calendar next week', function (assert) {
165 var i, m;
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
204 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
205 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
206 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
207 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
212 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
213 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
214 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
215 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
222 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
223 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
224 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
231 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
232 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
233 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
234
235 assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
236 assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
237 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');
238 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');
239 });
240
241 test('weeks year starting thursday', function (assert) {
242 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
243 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
244 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
245 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
246 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
247 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
248 });
249
250 test('weeks year starting friday', function (assert) {
251 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
252 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
253 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
254 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
255 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
256 });
257
258 test('weeks year starting saturday', function (assert) {
259 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
260 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
261 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
262 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
263 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
264 });
265
266 test('weeks year starting sunday formatted', function (assert) {
267 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', 'Dec 31 2011 should be week 1');
268 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', 'Jan 6 2012 should be week 1');
269 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2');
270 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2');
271 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
272 });
273
274 test('lenient ordinal parsing', function (assert) {
275 var i, ordinalStr, testMoment;
276 for (i = 1; i <= 31; ++i) {
277 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
278 testMoment = moment(ordinalStr, 'YYYY MM Do');
279 assert.equal(testMoment.year(), 2014,
280 'lenient ordinal parsing ' + i + ' year check');
281 assert.equal(testMoment.month(), 0,
282 'lenient ordinal parsing ' + i + ' month check');
283 assert.equal(testMoment.date(), i,
284 'lenient ordinal parsing ' + i + ' date check');
285 }
286 });
287
288 test('lenient ordinal parsing of number', function (assert) {
289 var i, testMoment;
290 for (i = 1; i <= 31; ++i) {
291 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
292 assert.equal(testMoment.year(), 2014,
293 'lenient ordinal parsing of number ' + i + ' year check');
294 assert.equal(testMoment.month(), 0,
295 'lenient ordinal parsing of number ' + i + ' month check');
296 assert.equal(testMoment.date(), i,
297 'lenient ordinal parsing of number ' + i + ' date check');
298 }
299 });
300
301 test('strict ordinal parsing', function (assert) {
302 var i, ordinalStr, testMoment;
303 for (i = 1; i <= 31; ++i) {
304 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
305 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
306 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
307 }
308 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ar-tn');
3
4 test('parse', function (assert) {
5 var tests = 'جانفي:جانفي_فيفري:فيفري_مارس:مارس_أفريل:أفريل_ماي:ماي_جوان:جوان_جويلية:جويلية_أوت:أوت_سبتمبر:سبتمبر_أكتوبر:أكتوبر_نوفمبر:نوفمبر_ديسمبر:ديسمبر'.split('_'),
6 i;
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11 for (i = 0; i < 12; i++) {
12 tests[i] = tests[i].split(':');
13 equalTest(tests[i][0], 'MMM', i);
14 equalTest(tests[i][1], 'MMM', i);
15 equalTest(tests[i][0], 'MMMM', i);
16 equalTest(tests[i][1], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21 }
22 });
23
24 test('format', function (assert) {
25 var a = [
26 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فيفري 14 2010, 3:25:50 pm'],
27 ['ddd, hA', 'أحد, 3PM'],
28 ['M Mo MM MMMM MMM', '2 2 02 فيفري فيفري'],
29 ['YYYY YY', '2010 10'],
30 ['D Do DD', '14 14 14'],
31 ['d do dddd ddd dd', '0 0 الأحد أحد ح'],
32 ['DDD DDDo DDDD', '45 45 045'],
33 ['w wo ww', '6 6 06'],
34 ['h hh', '3 03'],
35 ['H HH', '15 15'],
36 ['m mm', '25 25'],
37 ['s ss', '50 50'],
38 ['a A', 'pm PM'],
39 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
40 ['LT', '15:25'],
41 ['LTS', '15:25:50'],
42 ['L', '14/02/2010'],
43 ['LL', '14 فيفري 2010'],
44 ['LLL', '14 فيفري 2010 15:25'],
45 ['LLLL', 'الأحد 14 فيفري 2010 15:25'],
46 ['l', '14/2/2010'],
47 ['ll', '14 فيفري 2010'],
48 ['lll', '14 فيفري 2010 15:25'],
49 ['llll', 'أحد 14 فيفري 2010 15:25']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53 for (i = 0; i < a.length; i++) {
54 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
55 }
56 });
57
58 test('format ordinal', function (assert) {
59 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
60 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
61 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
62 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
63 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
64 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
65 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
66 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
67 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
68 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
69
70 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
71 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
72 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
73 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
74 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
75 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
76 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
77 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
78 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
79 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
80
81 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
82 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
83 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
84 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
85 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
86 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
87 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
88 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
89 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
90 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
91
92 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
93 });
94
95 test('format month', function (assert) {
96 var expected = 'جانفي جانفي_فيفري فيفري_مارس مارس_أفريل أفريل_ماي ماي_جوان جوان_جويلية جويلية_أوت أوت_سبتمبر سبتمبر_أكتوبر أكتوبر_نوفمبر نوفمبر_ديسمبر ديسمبر'.split('_'),
97 i;
98 for (i = 0; i < expected.length; i++) {
99 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
100 }
101 });
102
103 test('format week', function (assert) {
104 var expected = 'الأحد أحد ح_الإثنين إثنين ن_الثلاثاء ثلاثاء ث_الأربعاء أربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'),
105 i;
106 for (i = 0; i < expected.length; i++) {
107 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
108 }
109 });
110
111 test('from', function (assert) {
112 var start = moment([2007, 1, 28]);
113 assert.equal(start.from(moment([2007, 1, 28]).add({
114 s: 44
115 }), true), 'ثوان', '44 seconds = a few seconds');
116 assert.equal(start.from(moment([2007, 1, 28]).add({
117 s: 45
118 }), true), 'دقيقة', '45 seconds = a minute');
119 assert.equal(start.from(moment([2007, 1, 28]).add({
120 s: 89
121 }), true), 'دقيقة', '89 seconds = a minute');
122 assert.equal(start.from(moment([2007, 1, 28]).add({
123 s: 90
124 }), true), '2 دقائق', '90 seconds = 2 minutes');
125 assert.equal(start.from(moment([2007, 1, 28]).add({
126 m: 44
127 }), true), '44 دقائق', '44 minutes = 44 minutes');
128 assert.equal(start.from(moment([2007, 1, 28]).add({
129 m: 45
130 }), true), 'ساعة', '45 minutes = an hour');
131 assert.equal(start.from(moment([2007, 1, 28]).add({
132 m: 89
133 }), true), 'ساعة', '89 minutes = an hour');
134 assert.equal(start.from(moment([2007, 1, 28]).add({
135 m: 90
136 }), true), '2 ساعات', '90 minutes = 2 hours');
137 assert.equal(start.from(moment([2007, 1, 28]).add({
138 h: 5
139 }), true), '5 ساعات', '5 hours = 5 hours');
140 assert.equal(start.from(moment([2007, 1, 28]).add({
141 h: 21
142 }), true), '21 ساعات', '21 hours = 21 hours');
143 assert.equal(start.from(moment([2007, 1, 28]).add({
144 h: 22
145 }), true), 'يوم', '22 hours = a day');
146 assert.equal(start.from(moment([2007, 1, 28]).add({
147 h: 35
148 }), true), 'يوم', '35 hours = a day');
149 assert.equal(start.from(moment([2007, 1, 28]).add({
150 h: 36
151 }), true), '2 أيام', '36 hours = 2 days');
152 assert.equal(start.from(moment([2007, 1, 28]).add({
153 d: 1
154 }), true), 'يوم', '1 day = a day');
155 assert.equal(start.from(moment([2007, 1, 28]).add({
156 d: 5
157 }), true), '5 أيام', '5 days = 5 days');
158 assert.equal(start.from(moment([2007, 1, 28]).add({
159 d: 25
160 }), true), '25 أيام', '25 days = 25 days');
161 assert.equal(start.from(moment([2007, 1, 28]).add({
162 d: 26
163 }), true), 'شهر', '26 days = a month');
164 assert.equal(start.from(moment([2007, 1, 28]).add({
165 d: 30
166 }), true), 'شهر', '30 days = a month');
167 assert.equal(start.from(moment([2007, 1, 28]).add({
168 d: 43
169 }), true), 'شهر', '43 days = a month');
170 assert.equal(start.from(moment([2007, 1, 28]).add({
171 d: 46
172 }), true), '2 أشهر', '46 days = 2 months');
173 assert.equal(start.from(moment([2007, 1, 28]).add({
174 d: 74
175 }), true), '2 أشهر', '75 days = 2 months');
176 assert.equal(start.from(moment([2007, 1, 28]).add({
177 d: 76
178 }), true), '3 أشهر', '76 days = 3 months');
179 assert.equal(start.from(moment([2007, 1, 28]).add({
180 M: 1
181 }), true), 'شهر', '1 month = a month');
182 assert.equal(start.from(moment([2007, 1, 28]).add({
183 M: 5
184 }), true), '5 أشهر', '5 months = 5 months');
185 assert.equal(start.from(moment([2007, 1, 28]).add({
186 d: 345
187 }), true), 'سنة', '345 days = a year');
188 assert.equal(start.from(moment([2007, 1, 28]).add({
189 d: 548
190 }), true), '2 سنوات', '548 days = 2 years');
191 assert.equal(start.from(moment([2007, 1, 28]).add({
192 y: 1
193 }), true), 'سنة', '1 year = a year');
194 assert.equal(start.from(moment([2007, 1, 28]).add({
195 y: 5
196 }), true), '5 سنوات', '5 years = 5 years');
197 });
198
199 test('suffix', function (assert) {
200 assert.equal(moment(30000).from(0), 'في ثوان', 'prefix');
201 assert.equal(moment(0).from(30000), 'منذ ثوان', 'suffix');
202 });
203
204 test('now from now', function (assert) {
205 assert.equal(moment().fromNow(), 'منذ ثوان', 'now from now should display as in the past');
206 });
207
208 test('fromNow', function (assert) {
209 assert.equal(moment().add({
210 s: 30
211 }).fromNow(), 'في ثوان', 'in a few seconds');
212 assert.equal(moment().add({
213 d: 5
214 }).fromNow(), 'في 5 أيام', 'in 5 days');
215 });
216
217 test('calendar day', function (assert) {
218 var a = moment().hours(2).minutes(0).seconds(0);
219
220 assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
221 assert.equal(moment(a).add({
222 m: 25
223 }).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
224 assert.equal(moment(a).add({
225 h: 1
226 }).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
227 assert.equal(moment(a).add({
228 d: 1
229 }).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
230 assert.equal(moment(a).subtract({
231 h: 1
232 }).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
233 assert.equal(moment(a).subtract({
234 d: 1
235 }).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
236 });
237
238 test('calendar next week', function (assert) {
239 var i, m;
240 for (i = 2; i < 7; i++) {
241 m = moment().add({
242 d: i
243 });
244 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days current time');
245 m.hours(0).minutes(0).seconds(0).milliseconds(0);
246 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days beginning of day');
247 m.hours(23).minutes(59).seconds(59).milliseconds(999);
248 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today + ' + i + ' days end of day');
249 }
250 });
251
252 test('calendar last week', function (assert) {
253 var i, m;
254 for (i = 2; i < 7; i++) {
255 m = moment().subtract({
256 d: i
257 });
258 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days current time');
259 m.hours(0).minutes(0).seconds(0).milliseconds(0);
260 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days beginning of day');
261 m.hours(23).minutes(59).seconds(59).milliseconds(999);
262 assert.equal(m.calendar(), m.format('dddd [على الساعة] LT'), 'Today - ' + i + ' days end of day');
263 }
264 });
265
266 test('calendar all else', function (assert) {
267 var weeksAgo = moment().subtract({
268 w: 1
269 }),
270 weeksFromNow = moment().add({
271 w: 1
272 });
273
274 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
275 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
276
277 weeksAgo = moment().subtract({
278 w: 2
279 });
280 weeksFromNow = moment().add({
281 w: 2
282 });
283
284 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
285 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
286 });
287
288 test('weeks year starting sunday', function (assert) {
289 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
290 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
291 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
292 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
293 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
294 });
295
296 test('weeks year starting monday', function (assert) {
297 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
298 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
299 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
300 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
301 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
302 });
303
304 test('weeks year starting tuesday', function (assert) {
305 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
306 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
307 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
308 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
309 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
310 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
311 });
312
313 test('weeks year starting wednesday', function (assert) {
314 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
315 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
316 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
317 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
318 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
319 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
320 });
321
322 test('weeks year starting thursday', function (assert) {
323 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
324 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
325 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
326 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
327 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
328 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
329 });
330
331 test('weeks year starting friday', function (assert) {
332 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
333 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
334 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
335 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
336 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
337 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
338 });
339
340 test('weeks year starting saturday', function (assert) {
341 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
342 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
343 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
344 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
345 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
346 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
347 });
348
349 test('weeks year starting sunday formatted', function (assert) {
350 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
351 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
352 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
353 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
354 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
355 });
356
357 test('lenient ordinal parsing', function (assert) {
358 var i, ordinalStr, testMoment;
359 for (i = 1; i <= 31; ++i) {
360 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
361 testMoment = moment(ordinalStr, 'YYYY MM Do');
362 assert.equal(testMoment.year(), 2014,
363 'lenient ordinal parsing ' + i + ' year check');
364 assert.equal(testMoment.month(), 0,
365 'lenient ordinal parsing ' + i + ' month check');
366 assert.equal(testMoment.date(), i,
367 'lenient ordinal parsing ' + i + ' date check');
368 }
369 });
370
371 test('lenient ordinal parsing of number', function (assert) {
372 var i, testMoment;
373 for (i = 1; i <= 31; ++i) {
374 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
375 assert.equal(testMoment.year(), 2014,
376 'lenient ordinal parsing of number ' + i + ' year check');
377 assert.equal(testMoment.month(), 0,
378 'lenient ordinal parsing of number ' + i + ' month check');
379 assert.equal(testMoment.date(), i,
380 'lenient ordinal parsing of number ' + i + ' date check');
381 }
382 });
383
384 test('strict ordinal parsing', function (assert) {
385 var i, ordinalStr, testMoment;
386 for (i = 1; i <= 31; ++i) {
387 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
388 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
389 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
390 }
391 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ar');
3
4 var months = [
5 'كانون الثاني يناير',
6 'شباط فبراير',
7 'آذار مارس',
8 'نيسان أبريل',
9 'أيار مايو',
10 'حزيران يونيو',
11 'تموز يوليو',
12 'آب أغسطس',
13 'أيلول سبتمبر',
14 'تشرين الأول أكتوبر',
15 'تشرين الثاني نوفمبر',
16 'كانون الأول ديسمبر'
17 ];
18
19 test('parse', function (assert) {
20 var tests = months, i;
21 function equalTest(input, mmm, i) {
22 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
23 }
24 for (i = 0; i < 12; i++) {
25 equalTest(tests[i], 'MMM', i);
26 equalTest(tests[i], 'MMM', i);
27 equalTest(tests[i], 'MMMM', i);
28 equalTest(tests[i], 'MMMM', i);
29 equalTest(tests[i].toLocaleLowerCase(), 'MMMM', i);
30 equalTest(tests[i].toLocaleLowerCase(), 'MMMM', i);
31 equalTest(tests[i].toLocaleUpperCase(), 'MMMM', i);
32 equalTest(tests[i].toLocaleUpperCase(), 'MMMM', i);
33 }
34 });
35
36 test('format', function (assert) {
37 var a = [
38 ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد، شباط فبراير ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'],
39 ['ddd, hA', 'أحد، ٣م'],
40 ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ شباط فبراير شباط فبراير'],
41 ['YYYY YY', '٢٠١٠ ١٠'],
42 ['D Do DD', '١٤ ١٤ ١٤'],
43 ['d do dddd ddd dd', '٠ ٠ الأحد أحد ح'],
44 ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'],
45 ['w wo ww', '٨ ٨ ٠٨'],
46 ['h hh', '٣ ٠٣'],
47 ['H HH', '١٥ ١٥'],
48 ['m mm', '٢٥ ٢٥'],
49 ['s ss', '٥٠ ٥٠'],
50 ['a A', 'م م'],
51 ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'],
52 ['LT', '١٥:٢٥'],
53 ['LTS', '١٥:٢٥:٥٠'],
54 ['L', '١٤/\u200f٢/\u200f٢٠١٠'],
55 ['LL', '١٤ شباط فبراير ٢٠١٠'],
56 ['LLL', '١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'],
57 ['LLLL', 'الأحد ١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'],
58 ['l', '١٤/\u200f٢/\u200f٢٠١٠'],
59 ['ll', '١٤ شباط فبراير ٢٠١٠'],
60 ['lll', '١٤ شباط فبراير ٢٠١٠ ١٥:٢٥'],
61 ['llll', 'أحد ١٤ شباط فبراير ٢٠١٠ ١٥:٢٥']
62 ],
63 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
64 i;
65 for (i = 0; i < a.length; i++) {
66 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
67 }
68 });
69
70 test('format ordinal', function (assert) {
71 assert.equal(moment([2011, 0, 1]).format('DDDo'), '١', '1');
72 assert.equal(moment([2011, 0, 2]).format('DDDo'), '٢', '2');
73 assert.equal(moment([2011, 0, 3]).format('DDDo'), '٣', '3');
74 assert.equal(moment([2011, 0, 4]).format('DDDo'), '٤', '4');
75 assert.equal(moment([2011, 0, 5]).format('DDDo'), '٥', '5');
76 assert.equal(moment([2011, 0, 6]).format('DDDo'), '٦', '6');
77 assert.equal(moment([2011, 0, 7]).format('DDDo'), '٧', '7');
78 assert.equal(moment([2011, 0, 8]).format('DDDo'), '٨', '8');
79 assert.equal(moment([2011, 0, 9]).format('DDDo'), '٩', '9');
80 assert.equal(moment([2011, 0, 10]).format('DDDo'), '١٠', '10');
81
82 assert.equal(moment([2011, 0, 11]).format('DDDo'), '١١', '11');
83 assert.equal(moment([2011, 0, 12]).format('DDDo'), '١٢', '12');
84 assert.equal(moment([2011, 0, 13]).format('DDDo'), '١٣', '13');
85 assert.equal(moment([2011, 0, 14]).format('DDDo'), '١٤', '14');
86 assert.equal(moment([2011, 0, 15]).format('DDDo'), '١٥', '15');
87 assert.equal(moment([2011, 0, 16]).format('DDDo'), '١٦', '16');
88 assert.equal(moment([2011, 0, 17]).format('DDDo'), '١٧', '17');
89 assert.equal(moment([2011, 0, 18]).format('DDDo'), '١٨', '18');
90 assert.equal(moment([2011, 0, 19]).format('DDDo'), '١٩', '19');
91 assert.equal(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20');
92
93 assert.equal(moment([2011, 0, 21]).format('DDDo'), '٢١', '21');
94 assert.equal(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22');
95 assert.equal(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23');
96 assert.equal(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24');
97 assert.equal(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25');
98 assert.equal(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26');
99 assert.equal(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27');
100 assert.equal(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28');
101 assert.equal(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29');
102 assert.equal(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30');
103
104 assert.equal(moment([2011, 0, 31]).format('DDDo'), '٣١', '31');
105 });
106
107 test('format month', function (assert) {
108 var expected = months, i;
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, i, 1]).format('MMMM'), expected[i], expected[i]);
111 assert.equal(moment([2011, i, 1]).format('MMM'), expected[i], expected[i]);
112 }
113 });
114
115 test('format week', function (assert) {
116 var expected = 'الأحد أحد ح_الإثنين إثنين ن_الثلاثاء ثلاثاء ث_الأربعاء أربعاء ر_الخميس خميس خ_الجمعة جمعة ج_السبت سبت س'.split('_'), i;
117 for (i = 0; i < expected.length; i++) {
118 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
119 }
120 });
121
122 test('from', function (assert) {
123 var start = moment([2007, 1, 28]);
124 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '٤٤ ثانية', '44 seconds = a few seconds');
125 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'دقيقة واحدة', '45 seconds = a minute');
126 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'دقيقة واحدة', '89 seconds = a minute');
127 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'دقيقتان', '90 seconds = 2 minutes');
128 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '٤٤ دقيقة', '44 minutes = 44 minutes');
129 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ساعة واحدة', '45 minutes = an hour');
130 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ساعة واحدة', '89 minutes = an hour');
131 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'ساعتان', '90 minutes = 2 hours');
132 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '٥ ساعات', '5 hours = 5 hours');
133 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '٢١ ساعة', '21 hours = 21 hours');
134 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'يوم واحد', '22 hours = a day');
135 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'يوم واحد', '35 hours = a day');
136 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'يومان', '36 hours = 2 days');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'يوم واحد', '1 day = a day');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '٥ أيام', '5 days = 5 days');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '٢٥ يومًا', '25 days = 25 days');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'شهر واحد', '26 days = a month');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'شهر واحد', '30 days = a month');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'شهر واحد', '43 days = a month');
143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'شهران', '46 days = 2 months');
144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'شهران', '75 days = 2 months');
145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '٣ أشهر', '76 days = 3 months');
146 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'شهر واحد', '1 month = a month');
147 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '٥ أشهر', '5 months = 5 months');
148 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'عام واحد', '345 days = a year');
149 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'عامان', '548 days = 2 years');
150 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'عام واحد', '1 year = a year');
151 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '٥ أعوام', '5 years = 5 years');
152 });
153
154 test('suffix', function (assert) {
155 assert.equal(moment(30000).from(0), 'بعد ٣٠ ثانية', 'prefix');
156 assert.equal(moment(0).from(30000), 'منذ ٣٠ ثانية', 'suffix');
157 });
158
159 test('now from now', function (assert) {
160 assert.equal(moment().fromNow(), 'منذ ثانية واحدة', 'now from now should display as in the past');
161 });
162
163 test('fromNow', function (assert) {
164 assert.equal(moment().add({s: 30}).fromNow(), 'بعد ٣٠ ثانية', 'in a few seconds');
165 assert.equal(moment().add({d: 5}).fromNow(), 'بعد ٥ أيام', 'in 5 days');
166 });
167
168 test('calendar day', function (assert) {
169 var a = moment().hours(2).minutes(0).seconds(0);
170
171 assert.equal(moment(a).calendar(), 'اليوم عند الساعة ٠٢:٠٠', 'today at the same time');
172 assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم عند الساعة ٠٢:٢٥', 'Now plus 25 min');
173 assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم عند الساعة ٠٣:٠٠', 'Now plus 1 hour');
174 assert.equal(moment(a).add({d: 1}).calendar(), 'غدًا عند الساعة ٠٢:٠٠', 'tomorrow at the same time');
175 assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم عند الساعة ٠١:٠٠', 'Now minus 1 hour');
176 assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس عند الساعة ٠٢:٠٠', 'yesterday at the same time');
177 });
178
179 test('calendar next week', function (assert) {
180 var i, m;
181 for (i = 2; i < 7; i++) {
182 m = moment().add({d: i});
183 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today + ' + i + ' days current time');
184 m.hours(0).minutes(0).seconds(0).milliseconds(0);
185 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today + ' + i + ' days beginning of day');
186 m.hours(23).minutes(59).seconds(59).milliseconds(999);
187 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today + ' + i + ' days end of day');
188 }
189 });
190
191 test('calendar last week', function (assert) {
192 var i, m;
193 for (i = 2; i < 7; i++) {
194 m = moment().subtract({d: i});
195 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today - ' + i + ' days current time');
196 m.hours(0).minutes(0).seconds(0).milliseconds(0);
197 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today - ' + i + ' days beginning of day');
198 m.hours(23).minutes(59).seconds(59).milliseconds(999);
199 assert.equal(m.calendar(), m.format('dddd [عند الساعة] LT'), 'Today - ' + i + ' days end of day');
200 }
201 });
202
203 test('calendar all else', function (assert) {
204 var weeksAgo = moment().subtract({w: 1}),
205 weeksFromNow = moment().add({w: 1});
206
207 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
208 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
209
210 weeksAgo = moment().subtract({w: 2});
211 weeksFromNow = moment().add({w: 2});
212
213 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
214 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
215 });
216
217 test('weeks year starting sunday', function (assert) {
218 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
219 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
220 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
221 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
222 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
223 });
224
225 test('weeks year starting monday', function (assert) {
226 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
227 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
228 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
229 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
230 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
231 });
232
233 test('weeks year starting tuesday', function (assert) {
234 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
235 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
236 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
237 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
238 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
239 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
240 });
241
242 test('weeks year starting wednesday', function (assert) {
243 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
244 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
245 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
246 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
247 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
248 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
249
250 assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
251 assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
252 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');
253 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');
254 });
255
256 test('weeks year starting thursday', function (assert) {
257 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
258 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
259 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
260 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
261 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
262 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
263 });
264
265 test('weeks year starting friday', function (assert) {
266 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
267 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
268 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
269 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
270 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
271 });
272
273 test('weeks year starting saturday', function (assert) {
274 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
275 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
276 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
277 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
278 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
279 });
280
281 test('weeks year starting sunday formatted', function (assert) {
282 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', 'Dec 31 2011 should be week 1');
283 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', 'Jan 6 2012 should be week 1');
284 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2');
285 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2');
286 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
287 });
288
289 test('lenient ordinal parsing', function (assert) {
290 var i, ordinalStr, testMoment;
291 for (i = 1; i <= 31; ++i) {
292 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
293 testMoment = moment(ordinalStr, 'YYYY MM Do');
294 assert.equal(testMoment.year(), 2014,
295 'lenient ordinal parsing ' + i + ' year check');
296 assert.equal(testMoment.month(), 0,
297 'lenient ordinal parsing ' + i + ' month check');
298 assert.equal(testMoment.date(), i,
299 'lenient ordinal parsing ' + i + ' date check');
300 }
301 });
302
303 test('lenient ordinal parsing of number', function (assert) {
304 var i, testMoment;
305 for (i = 1; i <= 31; ++i) {
306 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
307 assert.equal(testMoment.year(), 2014,
308 'lenient ordinal parsing of number ' + i + ' year check');
309 assert.equal(testMoment.month(), 0,
310 'lenient ordinal parsing of number ' + i + ' month check');
311 assert.equal(testMoment.date(), i,
312 'lenient ordinal parsing of number ' + i + ' date check');
313 }
314 });
315
316 test('strict ordinal parsing', function (assert) {
317 var i, ordinalStr, testMoment;
318 for (i = 1; i <= 31; ++i) {
319 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
320 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
321 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
322 }
323 });
324
325 test('no leading zeros in long date formats', function (assert) {
326 var i, j, longDateStr, shortDateStr;
327 for (i = 1; i <= 9; ++i) {
328 for (j = 1; j <= 9; ++j) {
329 longDateStr = moment([2014, i, j]).format('L');
330 shortDateStr = moment([2014, i, j]).format('l');
331 assert.equal(longDateStr, shortDateStr, 'should not have leading zeros in month or day');
332 }
333 }
334 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('az');
3
4 test('parse', function (assert) {
5 var tests = 'yanvar yan_fevral fev_mart mar_Aprel apr_may may_iyun iyn_iyul iyl_Avqust avq_sentyabr sen_oktyabr okt_noyabr noy_dekabr dek'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, D MMMM YYYY, HH:mm:ss', 'Bazar, 14 fevral 2010, 15:25:50'],
25 ['ddd, A h', 'Baz, gündüz 3'],
26 ['M Mo MM MMMM MMM', '2 2-nci 02 fevral fev'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14-üncü 14'],
29 ['d do dddd ddd dd', '0 0-ıncı Bazar Baz Bz'],
30 ['DDD DDDo DDDD', '45 45-inci 045'],
31 ['w wo ww', '7 7-nci 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'gündüz gündüz'],
37 ['[ilin] DDDo [günü]', 'ilin 45-inci günü'],
38 ['LT', '15:25'],
39 ['LTS', '15:25:50'],
40 ['L', '14.02.2010'],
41 ['LL', '14 fevral 2010'],
42 ['LLL', '14 fevral 2010 15:25'],
43 ['LLLL', 'Bazar, 14 fevral 2010 15:25'],
44 ['l', '14.2.2010'],
45 ['ll', '14 fev 2010'],
46 ['lll', '14 fev 2010 15:25'],
47 ['llll', 'Baz, 14 fev 2010 15:25']
48 ],
49 DDDo = [
50 [359, '360-ıncı'],
51 [199, '200-üncü'],
52 [149, '150-nci']
53 ],
54 dt = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
55 DDDoDt,
56 i;
57
58 for (i = 0; i < a.length; i++) {
59 assert.equal(dt.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
60 }
61 for (i = 0; i < DDDo.length; i++) {
62 DDDoDt = moment([2010]);
63 assert.equal(DDDoDt.add(DDDo[i][0], 'days').format('DDDo'), DDDo[i][1], DDDo[i][0] + ' ---> ' + DDDo[i][1]);
64 }
65 });
66
67 test('format ordinal', function (assert) {
68 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-inci', '1st');
69 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-nci', '2nd');
70 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-üncü', '3rd');
71 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-üncü', '4th');
72 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-inci', '5th');
73 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ncı', '6th');
74 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-nci', '7th');
75 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-inci', '8th');
76 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-uncu', '9th');
77 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-uncu', '10th');
78
79 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-inci', '11th');
80 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-nci', '12th');
81 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-üncü', '13th');
82 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-üncü', '14th');
83 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-inci', '15th');
84 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ncı', '16th');
85 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-nci', '17th');
86 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-inci', '18th');
87 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-uncu', '19th');
88 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-nci', '20th');
89
90 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-inci', '21th');
91 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-nci', '22th');
92 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-üncü', '23th');
93 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-üncü', '24th');
94 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-inci', '25th');
95 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ncı', '26th');
96 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-nci', '27th');
97 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-inci', '28th');
98 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-uncu', '29th');
99 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-uncu', '30th');
100
101 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-inci', '31st');
102 });
103
104 test('format month', function (assert) {
105 var expected = 'yanvar yan_fevral fev_mart mar_aprel apr_may may_iyun iyn_iyul iyl_avqust avq_sentyabr sen_oktyabr okt_noyabr noy_dekabr dek'.split('_'), i;
106 for (i = 0; i < expected.length; i++) {
107 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
108 }
109 });
110
111 test('format week', function (assert) {
112 var expected = 'Bazar Baz Bz_Bazar ertəsi BzE BE_Çərşənbə axşamı ÇAx ÇA_Çərşənbə Çər Çə_Cümə axşamı CAx CA_Cümə Cüm Cü_Şənbə Şən Şə'.split('_'), i;
113 for (i = 0; i < expected.length; i++) {
114 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
115 }
116 });
117
118 test('from', function (assert) {
119 var start = moment([2007, 1, 28]);
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'birneçə saniyyə', '44 seconds = a few seconds');
121 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'bir dəqiqə', '45 seconds = a minute');
122 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'bir dəqiqə', '89 seconds = a minute');
123 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 dəqiqə', '90 seconds = 2 minutes');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 dəqiqə', '44 minutes = 44 minutes');
125 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'bir saat', '45 minutes = an hour');
126 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'bir saat', '89 minutes = an hour');
127 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 saat', '90 minutes = 2 hours');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 saat', '5 hours = 5 hours');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 saat', '21 hours = 21 hours');
130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'bir gün', '22 hours = a day');
131 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'bir gün', '35 hours = a day');
132 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 gün', '36 hours = 2 days');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'bir gün', '1 day = a day');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 gün', '5 days = 5 days');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 gün', '25 days = 25 days');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'bir ay', '26 days = a month');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'bir ay', '30 days = a month');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ay', '46 days = 2 months');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ay', '75 days = 2 months');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ay', '76 days = 3 months');
141 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'bir ay', '1 month = a month');
142 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ay', '5 months = 5 months');
143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'bir il', '345 days = a year');
144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 il', '548 days = 2 years');
145 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'bir il', '1 year = a year');
146 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 il', '5 years = 5 years');
147 });
148
149 test('suffix', function (assert) {
150 assert.equal(moment(30000).from(0), 'birneçə saniyyə sonra', 'prefix');
151 assert.equal(moment(0).from(30000), 'birneçə saniyyə əvvəl', 'suffix');
152 });
153
154 test('now from now', function (assert) {
155 assert.equal(moment().fromNow(), 'birneçə saniyyə əvvəl', 'now from now should display as in the past');
156 });
157
158 test('fromNow', function (assert) {
159 assert.equal(moment().add({s: 30}).fromNow(), 'birneçə saniyyə sonra', 'in a few seconds');
160 assert.equal(moment().add({d: 5}).fromNow(), '5 gün sonra', 'in 5 days');
161 });
162
163 test('calendar day', function (assert) {
164 var a = moment().hours(2).minutes(0).seconds(0);
165
166 assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
167 assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
168 assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
169 assert.equal(moment(a).add({d: 1}).calendar(), 'sabah saat 02:00', 'tomorrow at the same time');
170 assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
171 assert.equal(moment(a).subtract({d: 1}).calendar(), 'dünən 02:00', 'yesterday at the same time');
172 });
173
174 test('calendar next week', function (assert) {
175 var i, m;
176 for (i = 2; i < 7; i++) {
177 m = moment().add({d: i});
178 assert.equal(m.calendar(), m.format('[gələn həftə] dddd [saat] LT'), 'Today + ' + i + ' days current time');
179 m.hours(0).minutes(0).seconds(0).milliseconds(0);
180 assert.equal(m.calendar(), m.format('[gələn həftə] dddd [saat] LT'), 'Today + ' + i + ' days beginning of day');
181 m.hours(23).minutes(59).seconds(59).milliseconds(999);
182 assert.equal(m.calendar(), m.format('[gələn həftə] dddd [saat] LT'), 'Today + ' + i + ' days end of day');
183 }
184 });
185
186 test('calendar last week', function (assert) {
187 var i, m;
188 for (i = 2; i < 7; i++) {
189 m = moment().subtract({d: i});
190 assert.equal(m.calendar(), m.format('[keçən həftə] dddd [saat] LT'), 'Today - ' + i + ' days current time');
191 m.hours(0).minutes(0).seconds(0).milliseconds(0);
192 assert.equal(m.calendar(), m.format('[keçən həftə] dddd [saat] LT'), 'Today - ' + i + ' days beginning of day');
193 m.hours(23).minutes(59).seconds(59).milliseconds(999);
194 assert.equal(m.calendar(), m.format('[keçən həftə] dddd [saat] LT'), 'Today - ' + i + ' days end of day');
195 }
196 });
197
198 test('calendar all else', function (assert) {
199 var weeksAgo = moment().subtract({w: 1}),
200 weeksFromNow = moment().add({w: 1});
201
202 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
203 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
204
205 weeksAgo = moment().subtract({w: 2});
206 weeksFromNow = moment().add({w: 2});
207
208 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
209 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
210 });
211
212 test('weeks year starting sunday', function (assert) {
213 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
214 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
215 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
216 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
217 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
218 });
219
220 test('weeks year starting monday', function (assert) {
221 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
222 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
223 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
224 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
225 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
226 });
227
228 test('weeks year starting tuesday', function (assert) {
229 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
230 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
231 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
232 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
233 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
234 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
235 });
236
237 test('weeks year starting wednesday', function (assert) {
238 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
239 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
240 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
241 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
242 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
243 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
244 });
245
246 test('weeks year starting thursday', function (assert) {
247 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
248 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
249 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
250 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
251 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
252 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
253 });
254
255 test('weeks year starting friday', function (assert) {
256 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
257 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
258 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
259 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
260 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
261 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
262 });
263
264 test('weeks year starting saturday', function (assert) {
265 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
266 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
267 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
268 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
269 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
270 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
271 });
272
273 test('weeks year starting sunday formatted', function (assert) {
274 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-inci', 'Dec 26 2011 should be week 1');
275 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-inci', 'Jan 1 2012 should be week 1');
276 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-nci', 'Jan 2 2012 should be week 2');
277 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-nci', 'Jan 8 2012 should be week 2');
278 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-üncü', 'Jan 9 2012 should be week 3');
279 });
280
281 test('lenient ordinal parsing', function (assert) {
282 var i, ordinalStr, testMoment;
283 for (i = 1; i <= 31; ++i) {
284 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
285 testMoment = moment(ordinalStr, 'YYYY MM Do');
286 assert.equal(testMoment.year(), 2014,
287 'lenient ordinal parsing ' + i + ' year check');
288 assert.equal(testMoment.month(), 0,
289 'lenient ordinal parsing ' + i + ' month check');
290 assert.equal(testMoment.date(), i,
291 'lenient ordinal parsing ' + i + ' date check');
292 }
293 });
294
295 test('lenient ordinal parsing of number', function (assert) {
296 var i, testMoment;
297 for (i = 1; i <= 31; ++i) {
298 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
299 assert.equal(testMoment.year(), 2014,
300 'lenient ordinal parsing of number ' + i + ' year check');
301 assert.equal(testMoment.month(), 0,
302 'lenient ordinal parsing of number ' + i + ' month check');
303 assert.equal(testMoment.date(), i,
304 'lenient ordinal parsing of number ' + i + ' date check');
305 }
306 });
307
308 test('strict ordinal parsing', function (assert) {
309 var i, ordinalStr, testMoment;
310 for (i = 1; i <= 31; ++i) {
311 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
312 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
313 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
314 }
315 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('be');
3
4 test('parse', function (assert) {
5 var tests = 'студзень студ_люты лют_сакавік сак_красавік крас_травень трав_чэрвень чэрв_ліпень ліп_жнівень жнів_верасень вер_кастрычнік каст_лістапад ліст_снежань снеж'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, HH:mm:ss', 'нядзеля, 14-га лютага 2010, 15:25:50'],
25 ['ddd, h A', 'нд, 3 дня'],
26 ['M Mo MM MMMM MMM', '2 2-і 02 люты лют'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14-га 14'],
29 ['d do dddd ddd dd', '0 0-ы нядзеля нд нд'],
30 ['DDD DDDo DDDD', '45 45-ы 045'],
31 ['w wo ww', '7 7-ы 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'дня дня'],
37 ['DDDo [дзень года]', '45-ы дзень года'],
38 ['LT', '15:25'],
39 ['LTS', '15:25:50'],
40 ['L', '14.02.2010'],
41 ['LL', '14 лютага 2010 г.'],
42 ['LLL', '14 лютага 2010 г., 15:25'],
43 ['LLLL', 'нядзеля, 14 лютага 2010 г., 15:25'],
44 ['l', '14.2.2010'],
45 ['ll', '14 лют 2010 г.'],
46 ['lll', '14 лют 2010 г., 15:25'],
47 ['llll', 'нд, 14 лют 2010 г., 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format meridiem', function (assert) {
57 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'ночы', 'night');
58 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'ночы', 'night');
59 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'раніцы', 'morning');
60 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'раніцы', 'morning');
61 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'дня', 'afternoon');
62 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'дня', 'afternoon');
63 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'вечара', 'evening');
64 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'вечара', 'evening');
65 });
66
67 test('format ordinal', function (assert) {
68 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ы', '1-ы');
69 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-і', '2-і');
70 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-і', '3-і');
71 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-ы', '4-ы');
72 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-ы', '5-ы');
73 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ы', '6-ы');
74 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-ы', '7-ы');
75 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-ы', '8-ы');
76 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-ы', '9-ы');
77 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-ы', '10-ы');
78
79 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-ы', '11-ы');
80 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-ы', '12-ы');
81 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-ы', '13-ы');
82 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-ы', '14-ы');
83 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-ы', '15-ы');
84 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ы', '16-ы');
85 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-ы', '17-ы');
86 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-ы', '18-ы');
87 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-ы', '19-ы');
88 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-ы', '20-ы');
89
90 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ы', '21-ы');
91 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-і', '22-і');
92 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-і', '23-і');
93 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ы', '24-ы');
94 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ы', '25-ы');
95 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ы', '26-ы');
96 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ы', '27-ы');
97 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ы', '28-ы');
98 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ы', '29-ы');
99 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ы', '30-ы');
100
101 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-ы', '31-ы');
102 });
103
104 test('format month', function (assert) {
105 var expected = 'студзень студ_люты лют_сакавік сак_красавік крас_травень трав_чэрвень чэрв_ліпень ліп_жнівень жнів_верасень вер_кастрычнік каст_лістапад ліст_снежань снеж'.split('_'), i;
106 for (i = 0; i < expected.length; i++) {
107 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
108 }
109 });
110
111 test('format month case', function (assert) {
112 var months = {
113 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
114 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
115 }, i;
116 for (i = 0; i < 12; i++) {
117 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
118 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
119 }
120 });
121
122 test('format month case with escaped symbols', function (assert) {
123 var months = {
124 'nominative': 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_'),
125 'accusative': 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_')
126 }, i;
127 for (i = 0; i < 12; i++) {
128 assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
129 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMMM[</b>]'), '<i>1</i> <b>' + months.accusative[i] + '</b>', '1 <b>' + months.accusative[i] + '</b>');
130 assert.equal(moment([2013, i, 1]).format('D[-ы дзень] MMMM'), '1-ы дзень ' + months.accusative[i], '1-ы дзень ' + months.accusative[i]);
131 assert.equal(moment([2013, i, 1]).format('D, MMMM'), '1, ' + months.nominative[i], '1, ' + months.nominative[i]);
132 }
133 });
134
135 test('format week', function (assert) {
136 var expected = 'нядзеля нд нд_панядзелак пн пн_аўторак ат ат_серада ср ср_чацвер чц чц_пятніца пт пт_субота сб сб'.split('_'), i;
137 for (i = 0; i < expected.length; i++) {
138 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
139 }
140 });
141
142 test('from', function (assert) {
143 var start = moment([2007, 1, 28]);
144 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'некалькі секунд', '44 seconds = a few seconds');
145 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'хвіліна', '45 seconds = a minute');
146 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'хвіліна', '89 seconds = a minute');
147 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 хвіліны', '90 seconds = 2 minutes');
148 assert.equal(start.from(moment([2007, 1, 28]).add({m: 31}), true), '31 хвіліна', '31 minutes = 31 minutes');
149 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 хвіліны', '44 minutes = 44 minutes');
150 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'гадзіна', '45 minutes = an hour');
151 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'гадзіна', '89 minutes = an hour');
152 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 гадзіны', '90 minutes = 2 hours');
153 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 гадзін', '5 hours = 5 hours');
154 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 гадзіна', '21 hours = 21 hours');
155 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'дзень', '22 hours = a day');
156 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'дзень', '35 hours = a day');
157 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дні', '36 hours = 2 days');
158 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'дзень', '1 day = a day');
159 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дзён', '5 days = 5 days');
160 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 дзён', '11 days = 11 days');
161 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 дзень', '21 days = 21 days');
162 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дзён', '25 days = 25 days');
163 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месяц', '26 days = a month');
164 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месяц', '30 days = a month');
165 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месяц', '43 days = a month');
166 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месяцы', '46 days = 2 months');
167 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месяцы', '75 days = 2 months');
168 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месяцы', '76 days = 3 months');
169 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месяц', '1 month = a month');
170 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месяцаў', '5 months = 5 months');
171 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'год', '345 days = a year');
172 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 гады', '548 days = 2 years');
173 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'год', '1 year = a year');
174 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 гадоў', '5 years = 5 years');
175 });
176
177 test('suffix', function (assert) {
178 assert.equal(moment(30000).from(0), 'праз некалькі секунд', 'prefix');
179 assert.equal(moment(0).from(30000), 'некалькі секунд таму', 'suffix');
180 });
181
182 test('fromNow', function (assert) {
183 assert.equal(moment().add({s: 30}).fromNow(), 'праз некалькі секунд', 'in a few seconds');
184 assert.equal(moment().add({d: 5}).fromNow(), 'праз 5 дзён', 'in 5 days');
185 assert.equal(moment().add({m: 31}).fromNow(), 'праз 31 хвіліну', 'in 31 minutes = in 31 minutes');
186 assert.equal(moment().subtract({m: 31}).fromNow(), '31 хвіліну таму', '31 minutes ago = 31 minutes ago');
187 });
188
189 test('calendar day', function (assert) {
190 var a = moment().hours(2).minutes(0).seconds(0);
191
192 assert.equal(moment(a).calendar(), 'Сёння ў 02:00', 'today at the same time');
193 assert.equal(moment(a).add({m: 25}).calendar(), 'Сёння ў 02:25', 'Now plus 25 min');
194 assert.equal(moment(a).add({h: 1}).calendar(), 'Сёння ў 03:00', 'Now plus 1 hour');
195 assert.equal(moment(a).add({d: 1}).calendar(), 'Заўтра ў 02:00', 'tomorrow at the same time');
196 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сёння ў 01:00', 'Now minus 1 hour');
197 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Учора ў 02:00', 'yesterday at the same time');
198 });
199
200 test('calendar next week', function (assert) {
201 var i, m;
202 function makeFormat(d) {
203 return '[У] dddd [ў] LT';
204 }
205
206 for (i = 2; i < 7; i++) {
207 m = moment().add({d: i});
208 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
209 m.hours(0).minutes(0).seconds(0).milliseconds(0);
210 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
211 m.hours(23).minutes(59).seconds(59).milliseconds(999);
212 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
213 }
214 });
215
216 test('calendar last week', function (assert) {
217 var i, m;
218
219 function makeFormat(d) {
220 switch (d.day()) {
221 case 0:
222 case 3:
223 case 5:
224 case 6:
225 return '[У мінулую] dddd [ў] LT';
226 case 1:
227 case 2:
228 case 4:
229 return '[У мінулы] dddd [ў] LT';
230 }
231 }
232
233 for (i = 2; i < 7; i++) {
234 m = moment().subtract({d: i});
235 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
236 m.hours(0).minutes(0).seconds(0).milliseconds(0);
237 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
238 m.hours(23).minutes(59).seconds(59).milliseconds(999);
239 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
240 }
241 });
242
243 test('calendar all else', function (assert) {
244 var weeksAgo = moment().subtract({w: 1}),
245 weeksFromNow = moment().add({w: 1});
246
247 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
248 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
249
250 weeksAgo = moment().subtract({w: 2});
251 weeksFromNow = moment().add({w: 2});
252
253 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
254 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
255 });
256
257 test('weeks year starting sunday', function (assert) {
258 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
259 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
260 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
261 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
262 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
263 });
264
265 test('weeks year starting monday', function (assert) {
266 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
267 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
268 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
269 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
270 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
271 });
272
273 test('weeks year starting tuesday', function (assert) {
274 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
275 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
276 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
277 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
278 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
279 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
280 });
281
282 test('weeks year starting wednesday', function (assert) {
283 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
284 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
285 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
286 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
287 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
288 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
289 });
290
291 test('weeks year starting thursday', function (assert) {
292 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
293 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
294 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
295 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
296 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
297 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
298 });
299
300 test('weeks year starting friday', function (assert) {
301 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
302 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
303 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
304 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
305 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
306 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
307 });
308
309 test('weeks year starting saturday', function (assert) {
310 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
311 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
312 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
313 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
314 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
315 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
316 });
317
318 test('weeks year starting sunday formatted', function (assert) {
319 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ы', 'Dec 26 2011 should be week 1');
320 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ы', 'Jan 1 2012 should be week 1');
321 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-і', 'Jan 2 2012 should be week 2');
322 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-і', 'Jan 8 2012 should be week 2');
323 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-і', 'Jan 9 2012 should be week 3');
324 });
325
326 test('lenient ordinal parsing', function (assert) {
327 var i, ordinalStr, testMoment;
328 for (i = 1; i <= 31; ++i) {
329 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
330 testMoment = moment(ordinalStr, 'YYYY MM Do');
331 assert.equal(testMoment.year(), 2014,
332 'lenient ordinal parsing ' + i + ' year check');
333 assert.equal(testMoment.month(), 0,
334 'lenient ordinal parsing ' + i + ' month check');
335 assert.equal(testMoment.date(), i,
336 'lenient ordinal parsing ' + i + ' date check');
337 }
338 });
339
340 test('lenient ordinal parsing of number', function (assert) {
341 var i, testMoment;
342 for (i = 1; i <= 31; ++i) {
343 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
344 assert.equal(testMoment.year(), 2014,
345 'lenient ordinal parsing of number ' + i + ' year check');
346 assert.equal(testMoment.month(), 0,
347 'lenient ordinal parsing of number ' + i + ' month check');
348 assert.equal(testMoment.date(), i,
349 'lenient ordinal parsing of number ' + i + ' date check');
350 }
351 });
352
353 test('strict ordinal parsing', function (assert) {
354 var i, ordinalStr, testMoment;
355 for (i = 1; i <= 31; ++i) {
356 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
357 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
358 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
359 }
360 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('bg');
3
4 test('parse', function (assert) {
5 var tests = 'януари янр_февруари фев_март мар_април апр_май май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, H:mm:ss', 'неделя, февруари 14-ти 2010, 15:25:50'],
25 ['ddd, hA', 'нед, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2-ри 02 февруари фев'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14-ти 14'],
29 ['d do dddd ddd dd', '0 0-ев неделя нед нд'],
30 ['DDD DDDo DDDD', '45 45-ти 045'],
31 ['w wo ww', '7 7-ми 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45-ти day of the year'],
38 ['LT', '15:25'],
39 ['LTS', '15:25:50'],
40 ['L', '14.02.2010'],
41 ['LL', '14 февруари 2010'],
42 ['LLL', '14 февруари 2010 15:25'],
43 ['LLLL', 'неделя, 14 февруари 2010 15:25'],
44 ['l', '14.2.2010'],
45 ['ll', '14 фев 2010'],
46 ['lll', '14 фев 2010 15:25'],
47 ['llll', 'нед, 14 фев 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ви', '1-ви');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-ри', '2-ри');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-ти', '3-ти');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-ти', '4-ти');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-ти', '5-ти');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ти', '6-ти');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-ми', '7-ми');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-ми', '8-ми');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-ти', '9-ти');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-ти', '10-ти');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-ти', '11-ти');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-ти', '12-ти');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-ти', '13-ти');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-ти', '14-ти');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-ти', '15-ти');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ти', '16-ти');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-ти', '17-ти');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-ти', '18-ти');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-ти', '19-ти');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-ти', '20-ти');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ви', '21-ви');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-ри', '22-ри');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-ти', '23-ти');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ти', '24-ти');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ти', '25-ти');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ти', '26-ти');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ми', '27-ми');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ми', '28-ми');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ти', '29-ти');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ти', '30-ти');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-ви', '31-ви');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'януари янр_февруари фев_март мар_април апр_май май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'неделя нед нд_понеделник пон пн_вторник вто вт_сряда сря ср_четвъртък чет чт_петък пет пт_събота съб сб'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'няколко секунди', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'минута', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'минута', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минути', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минути', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'час', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'час', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 часа', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 часа', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 часа', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ден', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ден', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дни', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ден', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дни', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дни', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месец', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месец', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месец', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месеца', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месеца', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месеца', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месец', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месеца', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'година', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 години', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'година', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 години', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'след няколко секунди', 'prefix');
141 assert.equal(moment(0).from(30000), 'преди няколко секунди', 'suffix');
142 });
143
144 test('now from now', function (assert) {
145 assert.equal(moment().fromNow(), 'преди няколко секунди', 'now from now should display as in the past');
146 });
147
148 test('fromNow', function (assert) {
149 assert.equal(moment().add({s: 30}).fromNow(), 'след няколко секунди', 'in a few seconds');
150 assert.equal(moment().add({d: 5}).fromNow(), 'след 5 дни', 'in 5 days');
151 });
152
153 test('calendar day', function (assert) {
154 var a = moment().hours(2).minutes(0).seconds(0);
155
156 assert.equal(moment(a).calendar(), 'Днес в 2:00', 'today at the same time');
157 assert.equal(moment(a).add({m: 25}).calendar(), 'Днес в 2:25', 'Now plus 25 min');
158 assert.equal(moment(a).add({h: 1}).calendar(), 'Днес в 3:00', 'Now plus 1 hour');
159 assert.equal(moment(a).add({d: 1}).calendar(), 'Утре в 2:00', 'tomorrow at the same time');
160 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Днес в 1:00', 'Now minus 1 hour');
161 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 2:00', 'yesterday at the same time');
162 });
163
164 test('calendar next week', function (assert) {
165 var i, m;
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [в] LT'), 'Today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [в] LT'), 'Today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [в] LT'), 'Today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178
179 function makeFormat(d) {
180 switch (d.day()) {
181 case 0:
182 case 3:
183 case 6:
184 return '[В изминалата] dddd [в] LT';
185 case 1:
186 case 2:
187 case 4:
188 case 5:
189 return '[В изминалия] dddd [в] LT';
190 }
191 }
192
193 for (i = 2; i < 7; i++) {
194 m = moment().subtract({d: i});
195 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
196 m.hours(0).minutes(0).seconds(0).milliseconds(0);
197 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
198 m.hours(23).minutes(59).seconds(59).milliseconds(999);
199 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
200 }
201 });
202
203 test('calendar all else', function (assert) {
204 var weeksAgo = moment().subtract({w: 1}),
205 weeksFromNow = moment().add({w: 1});
206
207 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
208 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
209
210 weeksAgo = moment().subtract({w: 2});
211 weeksFromNow = moment().add({w: 2});
212
213 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
214 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
215 });
216
217 test('weeks year starting sunday', function (assert) {
218 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
219 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
220 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
221 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
222 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
223 });
224
225 test('weeks year starting monday', function (assert) {
226 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
227 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
228 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
229 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
230 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
231 });
232
233 test('weeks year starting tuesday', function (assert) {
234 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
235 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
236 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
237 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
238 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
239 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
240 });
241
242 test('weeks year starting wednesday', function (assert) {
243 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
244 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
245 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
246 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
247 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
248 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
249 });
250
251 test('weeks year starting thursday', function (assert) {
252 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
253 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
254 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
255 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
256 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
257 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
258 });
259
260 test('weeks year starting friday', function (assert) {
261 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
262 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
263 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
264 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
265 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
266 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
267 });
268
269 test('weeks year starting saturday', function (assert) {
270 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
271 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
272 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
273 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
274 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
275 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
276 });
277
278 test('weeks year starting sunday formatted', function (assert) {
279 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
280 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
281 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-ри', 'Jan 2 2012 should be week 2');
282 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-ри', 'Jan 8 2012 should be week 2');
283 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
284 });
285
286 test('lenient ordinal parsing', function (assert) {
287 var i, ordinalStr, testMoment;
288 for (i = 1; i <= 31; ++i) {
289 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
290 testMoment = moment(ordinalStr, 'YYYY MM Do');
291 assert.equal(testMoment.year(), 2014,
292 'lenient ordinal parsing ' + i + ' year check');
293 assert.equal(testMoment.month(), 0,
294 'lenient ordinal parsing ' + i + ' month check');
295 assert.equal(testMoment.date(), i,
296 'lenient ordinal parsing ' + i + ' date check');
297 }
298 });
299
300 test('lenient ordinal parsing of number', function (assert) {
301 var i, testMoment;
302 for (i = 1; i <= 31; ++i) {
303 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
304 assert.equal(testMoment.year(), 2014,
305 'lenient ordinal parsing of number ' + i + ' year check');
306 assert.equal(testMoment.month(), 0,
307 'lenient ordinal parsing of number ' + i + ' month check');
308 assert.equal(testMoment.date(), i,
309 'lenient ordinal parsing of number ' + i + ' date check');
310 }
311 });
312
313 test('strict ordinal parsing', function (assert) {
314 var i, ordinalStr, testMoment;
315 for (i = 1; i <= 31; ++i) {
316 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
317 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
318 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
319 }
320 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('bn');
3
4 test('parse', function (assert) {
5 var tests = 'জানুয়ারী জানু_ফেবুয়ারী ফেব_মার্চ মার্চ_এপ্রিল এপর_মে মে_জুন জুন_জুলাই জুল_অগাস্ট অগ_সেপ্টেম্বর সেপ্ট_অক্টোবর অক্টো_নভেম্বর নভ_ডিসেম্বর ডিসেম্'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, a h:mm:ss সময়', 'রবিবার, ১৪ ফেবুয়ারী ২০১০, দুপুর ৩:২৫:৫০ সময়'],
25 ['ddd, a h সময়', 'রবি, দুপুর ৩ সময়'],
26 ['M Mo MM MMMM MMM', '২ ২ ০২ ফেবুয়ারী ফেব'],
27 ['YYYY YY', '২০১০ ১০'],
28 ['D Do DD', '১৪ ১৪ ১৪'],
29 ['d do dddd ddd dd', '০ ০ রবিবার রবি রব'],
30 ['DDD DDDo DDDD', '৪৫ ৪৫ ০৪৫'],
31 ['w wo ww', '৮ ৮ ০৮'],
32 ['h hh', '৩ ০৩'],
33 ['H HH', '১৫ ১৫'],
34 ['m mm', '২৫ ২৫'],
35 ['s ss', '৫০ ৫০'],
36 ['a A', 'দুপুর দুপুর'],
37 ['LT', 'দুপুর ৩:২৫ সময়'],
38 ['LTS', 'দুপুর ৩:২৫:৫০ সময়'],
39 ['L', '১৪/০২/২০১০'],
40 ['LL', '১৪ ফেবুয়ারী ২০১০'],
41 ['LLL', '১৪ ফেবুয়ারী ২০১০, দুপুর ৩:২৫ সময়'],
42 ['LLLL', 'রবিবার, ১৪ ফেবুয়ারী ২০১০, দুপুর ৩:২৫ সময়'],
43 ['l', '১৪/২/২০১০'],
44 ['ll', '১৪ ফেব ২০১০'],
45 ['lll', '১৪ ফেব ২০১০, দুপুর ৩:২৫ সময়'],
46 ['llll', 'রবি, ১৪ ফেব ২০১০, দুপুর ৩:২৫ সময়']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '১', '১');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '২', '২');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '৩', '৩');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '৪', '৪');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '৫', '৫');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '৬', '৬');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '৭', '৭');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '৮', '৮');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '৯', '৯');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '১০', '১০');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '১১', '১১');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '১২', '১২');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '১৩', '১৩');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '১৪', '১৪');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '১৫', '১৫');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '১৬', '১৬');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '১৭', '১৭');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '১৮', '১৮');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '১৯', '১৯');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '২০', '২০');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '২১', '২১');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '২২', '২২');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '২৩', '২৩');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '২৪', '২৪');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '২৫', '২৫');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '২৬', '২৬');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '২৭', '২৭');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '২৮', '२৮');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '২৯', '২৯');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '৩০', '৩০');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '৩১', '৩১');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'জানুয়ারী জানু_ফেবুয়ারী ফেব_মার্চ মার্চ_এপ্রিল এপর_মে মে_জুন জুন_জুলাই জুল_অগাস্ট অগ_সেপ্টেম্বর সেপ্ট_অক্টোবর অক্টো_নভেম্বর নভ_ডিসেম্বর ডিসেম্'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'রবিবার রবি রব_সোমবার সোম সম_মঙ্গলবার মঙ্গল মঙ্গ_বুধবার বুধ বু_বৃহস্পত্তিবার বৃহস্পত্তি ব্রিহ_শুক্রুবার শুক্রু শু_শনিবার শনি শনি'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'কএক সেকেন্ড', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'এক মিনিট', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'এক মিনিট', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '২ মিনিট', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '৪৪ মিনিট', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'এক ঘন্টা', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'এক ঘন্টা', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '২ ঘন্টা', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '৫ ঘন্টা', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '২১ ঘন্টা', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'এক দিন', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'এক দিন', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '২ দিন', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'এক দিন', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '৫ দিন', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '২৫ দিন', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'এক মাস', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'এক মাস', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '২ মাস', '46 days = 2 months');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '২ মাস', '75 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '৩ মাস', '76 days = 3 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'এক মাস', '1 month = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '৫ মাস', '5 months = 5 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'এক বছর', '345 days = a year');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '২ বছর', '548 days = 2 years');
133 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'এক বছর', '1 year = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '৫ বছর', '5 years = 5 years');
135 });
136
137 test('suffix', function (assert) {
138 assert.equal(moment(30000).from(0), 'কএক সেকেন্ড পরে', 'prefix');
139 assert.equal(moment(0).from(30000), 'কএক সেকেন্ড আগে', 'suffix');
140 });
141
142 test('now from now', function (assert) {
143 assert.equal(moment().fromNow(), 'কএক সেকেন্ড আগে', 'now from now should display as in the past');
144 });
145
146 test('fromNow', function (assert) {
147 assert.equal(moment().add({s: 30}).fromNow(), 'কএক সেকেন্ড পরে', 'কএক সেকেন্ড পরে');
148 assert.equal(moment().add({d: 5}).fromNow(), '৫ দিন পরে', '৫ দিন পরে');
149 });
150
151 test('calendar day', function (assert) {
152 var a = moment().hours(2).minutes(0).seconds(0);
153
154 assert.equal(moment(a).calendar(), 'আজ রাত ২:০০ সময়', 'today at the same time');
155 assert.equal(moment(a).add({m: 25}).calendar(), 'আজ রাত ২:২৫ সময়', 'Now plus 25 min');
156 assert.equal(moment(a).add({h: 3}).calendar(), 'আজ সকাল ৫:০০ সময়', 'Now plus 3 hour');
157 assert.equal(moment(a).add({d: 1}).calendar(), 'আগামীকাল রাত ২:০০ সময়', 'tomorrow at the same time');
158 assert.equal(moment(a).subtract({h: 1}).calendar(), 'আজ রাত ১:০০ সময়', 'Now minus 1 hour');
159 assert.equal(moment(a).subtract({d: 1}).calendar(), 'গতকাল রাত ২:০০ সময়', 'yesterday at the same time');
160 });
161
162 test('calendar next week', function (assert) {
163 var i, m;
164 for (i = 2; i < 7; i++) {
165 m = moment().add({d: i});
166 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
167 m.hours(0).minutes(0).seconds(0).milliseconds(0);
168 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
169 m.hours(23).minutes(59).seconds(59).milliseconds(999);
170 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
171 }
172 });
173
174 test('calendar last week', function (assert) {
175 var i, m;
176
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[গত] dddd[,] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[গত] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[গত] dddd[,] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('meridiem', function (assert) {
202 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'রাত', 'before dawn');
203 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'সকাল', 'morning');
204 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'দুপুর', 'during day');
205 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'বিকেল', 'evening');
206 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'বিকেল', 'late evening');
207 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'রাত', 'night');
208
209 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'রাত', 'before dawn');
210 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'সকাল', 'morning');
211 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'দুপুর', ' during day');
212 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'বিকেল', 'evening');
213 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'বিকেল', 'late evening');
214 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'রাত', 'night');
215 });
216
217 test('weeks year starting sunday', function (assert) {
218 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
219 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
220 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
221 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
222 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
223 });
224
225 test('weeks year starting monday', function (assert) {
226 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
227 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
228 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
229 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
230 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
231 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
232 });
233
234 test('weeks year starting tuesday', function (assert) {
235 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
236 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
237 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
238 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
239 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
240 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
241 });
242
243 test('weeks year starting wednesday', function (assert) {
244 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
245 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
246 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
247 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
248 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
249 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
250 });
251
252 test('weeks year starting thursday', function (assert) {
253 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
254 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
255 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
256 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
257 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
258 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
259 });
260
261 test('weeks year starting friday', function (assert) {
262 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
263 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
264 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
265 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
266 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
267 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
268 });
269
270 test('weeks year starting saturday', function (assert) {
271 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
272 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
273 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
274 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
275 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
276 });
277
278 test('weeks year starting sunday formatted', function (assert) {
279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '১ ০১ ১', 'Jan 1 2012 should be week 1');
280 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '১ ০১ ১', 'Jan 7 2012 should be week 1');
281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '২ ০২ ২', 'Jan 8 2012 should be week 2');
282 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '২ ০২ ২', 'Jan 14 2012 should be week 2');
283 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '৩ ০৩ ৩', 'Jan 15 2012 should be week 3');
284 });
285
286 test('lenient ordinal parsing', function (assert) {
287 var i, ordinalStr, testMoment;
288 for (i = 1; i <= 31; ++i) {
289 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
290 testMoment = moment(ordinalStr, 'YYYY MM Do');
291 assert.equal(testMoment.year(), 2014,
292 'lenient ordinal parsing ' + i + ' year check');
293 assert.equal(testMoment.month(), 0,
294 'lenient ordinal parsing ' + i + ' month check');
295 assert.equal(testMoment.date(), i,
296 'lenient ordinal parsing ' + i + ' date check');
297 }
298 });
299
300 test('lenient ordinal parsing of number', function (assert) {
301 var i, testMoment;
302 for (i = 1; i <= 31; ++i) {
303 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
304 assert.equal(testMoment.year(), 2014,
305 'lenient ordinal parsing of number ' + i + ' year check');
306 assert.equal(testMoment.month(), 0,
307 'lenient ordinal parsing of number ' + i + ' month check');
308 assert.equal(testMoment.date(), i,
309 'lenient ordinal parsing of number ' + i + ' date check');
310 }
311 });
312
313 test('strict ordinal parsing', function (assert) {
314 var i, ordinalStr, testMoment;
315 for (i = 1; i <= 31; ++i) {
316 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
317 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
318 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
319 }
320 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('bo');
3
4 test('parse', function (assert) {
5 var tests = 'ཟླ་བ་དང་པོ ཟླ་བ་དང་པོ._ཟླ་བ་གཉིས་པ ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ ཟླ་བ་བཅུ་གཉིས་པ'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, a h:mm:ss ལ་', 'གཟའ་ཉི་མ་, ༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥:༥༠ ལ་'],
25 ['ddd, a h ལ་', 'ཉི་མ་, ཉིན་གུང ༣ ལ་'],
26 ['M Mo MM MMMM MMM', '༢ ༢ ༠༢ ཟླ་བ་གཉིས་པ ཟླ་བ་གཉིས་པ'],
27 ['YYYY YY', '༢༠༡༠ ༡༠'],
28 ['D Do DD', '༡༤ ༡༤ ༡༤'],
29 ['d do dddd ddd dd', '༠ ༠ གཟའ་ཉི་མ་ ཉི་མ་ ཉི་མ་'],
30 ['DDD DDDo DDDD', '༤༥ ༤༥ ༠༤༥'],
31 ['w wo ww', '༨ ༨ ༠༨'],
32 ['h hh', '༣ ༠༣'],
33 ['H HH', '༡༥ ༡༥'],
34 ['m mm', '༢༥ ༢༥'],
35 ['s ss', '༥༠ ༥༠'],
36 ['a A', 'ཉིན་གུང ཉིན་གུང'],
37 ['LT', 'ཉིན་གུང ༣:༢༥'],
38 ['LTS', 'ཉིན་གུང ༣:༢༥:༥༠'],
39 ['L', '༡༤/༠༢/༢༠༡༠'],
40 ['LL', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠'],
41 ['LLL', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥'],
42 ['LLLL', 'གཟའ་ཉི་མ་, ༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥'],
43 ['l', '༡༤/༢/༢༠༡༠'],
44 ['ll', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠'],
45 ['lll', '༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥'],
46 ['llll', 'ཉི་མ་, ༡༤ ཟླ་བ་གཉིས་པ ༢༠༡༠, ཉིན་གུང ༣:༢༥']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '༡', '༡');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '༢', '༢');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '༣', '༣');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '༤', '༤');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '༥', '༥');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '༦', '༦');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '༧', '༧');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '༨', '༨');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '༩', '༩');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '༡༠', '༡༠');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '༡༡', '༡༡');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '༡༢', '༡༢');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '༡༣', '༡༣');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '༡༤', '༡༤');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '༡༥', '༡༥');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '༡༦', '༡༦');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '༡༧', '༡༧');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '༡༨', '༡༨');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '༡༩', '༡༩');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '༢༠', '༢༠');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '༢༡', '༢༡');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '༢༢', '༢༢');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '༢༣', '༢༣');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '༢༤', '༢༤');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '༢༥', '༢༥');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '༢༦', '༢༦');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '༢༧', '༢༧');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '༢༨', '༢༨');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '༢༩', '༢༩');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '༣༠', '༣༠');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '༣༡', '༣༡');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'ཟླ་བ་དང་པོ ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ ཟླ་བ་བཅུ་གཉིས་པ'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'གཟའ་ཉི་མ་ ཉི་མ་ ཉི་མ་_གཟའ་ཟླ་བ་ ཟླ་བ་ ཟླ་བ་_གཟའ་མིག་དམར་ མིག་དམར་ མིག་དམར་_གཟའ་ལྷག་པ་ ལྷག་པ་ ལྷག་པ་_གཟའ་ཕུར་བུ ཕུར་བུ ཕུར་བུ_གཟའ་པ་སངས་ པ་སངས་ པ་སངས་_གཟའ་སྤེན་པ་ སྤེན་པ་ སྤེན་པ་'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ལམ་སང', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'སྐར་མ་གཅིག', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'སྐར་མ་གཅིག', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '༢ སྐར་མ', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '༤༤ སྐར་མ', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ཆུ་ཚོད་གཅིག', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ཆུ་ཚོད་གཅིག', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '༢ ཆུ་ཚོད', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '༥ ཆུ་ཚོད', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '༢༡ ཆུ་ཚོད', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ཉིན་གཅིག', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ཉིན་གཅིག', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '༢ ཉིན་', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ཉིན་གཅིག', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '༥ ཉིན་', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '༢༥ ཉིན་', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ཟླ་བ་གཅིག', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ཟླ་བ་གཅིག', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ཟླ་བ་གཅིག', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '༢ ཟླ་བ', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '༢ ཟླ་བ', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '༣ ཟླ་བ', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ཟླ་བ་གཅིག', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '༥ ཟླ་བ', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ལོ་གཅིག', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '༢ ལོ', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ལོ་གཅིག', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '༥ ལོ', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'ལམ་སང ལ་', 'prefix');
140 assert.equal(moment(0).from(30000), 'ལམ་སང སྔན་ལ', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'ལམ་སང སྔན་ལ', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'ལམ་སང ལ་', 'ལམ་སང ལ་');
149 assert.equal(moment().add({d: 5}).fromNow(), '༥ ཉིན་ ལ་', '༥ ཉིན་ ལ་');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'དི་རིང མཚན་མོ ༢:༠༠', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'དི་རིང མཚན་མོ ༢:༢༥', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 3}).calendar(), 'དི་རིང ཞོགས་ཀས ༥:༠༠', 'Now plus 3 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'སང་ཉིན མཚན་མོ ༢:༠༠', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'དི་རིང མཚན་མོ ༡:༠༠', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ཁ་སང མཚན་མོ ༢:༠༠', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་རྗེས་མ][,] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་རྗེས་མ][,] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་རྗེས་མ][,] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་མཐའ་མ] dddd[,] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་མཐའ་མ] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[བདུན་ཕྲག་མཐའ་མ] dddd[,] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('meridiem', function (assert) {
203 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'མཚན་མོ', 'before dawn');
204 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'ཞོགས་ཀས', 'morning');
205 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'ཉིན་གུང', 'during day');
206 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'དགོང་དག', 'evening');
207 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'དགོང་དག', 'late evening');
208 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'མཚན་མོ', 'night');
209
210 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'མཚན་མོ', 'before dawn');
211 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'ཞོགས་ཀས', 'morning');
212 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'ཉིན་གུང', ' during day');
213 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'དགོང་དག', 'evening');
214 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'དགོང་དག', 'late evening');
215 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'མཚན་མོ', 'night');
216 });
217
218 test('weeks year starting sunday', function (assert) {
219 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
220 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
221 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
222 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
223 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
224 });
225
226 test('weeks year starting monday', function (assert) {
227 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
228 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
229 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
230 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
231 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
232 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
233 });
234
235 test('weeks year starting tuesday', function (assert) {
236 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
237 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
238 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
239 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
240 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
241 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
242 });
243
244 test('weeks year starting wednesday', function (assert) {
245 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
246 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
247 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
248 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
249 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
250 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
251 });
252
253 test('weeks year starting thursday', function (assert) {
254 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
255 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
256 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
257 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
258 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
259 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
260 });
261
262 test('weeks year starting friday', function (assert) {
263 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
264 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
265 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
266 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
267 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
268 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
269 });
270
271 test('weeks year starting saturday', function (assert) {
272 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
273 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
274 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
275 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
276 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
277 });
278
279 test('weeks year starting sunday formatted', function (assert) {
280 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 1 2012 should be week 1');
281 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 7 2012 should be week 1');
282 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '༢ ༠༢ ༢', 'Jan 8 2012 should be week 2');
283 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '༢ ༠༢ ༢', 'Jan 14 2012 should be week 2');
284 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '༣ ༠༣ ༣', 'Jan 15 2012 should be week 3');
285 });
286
287 test('lenient ordinal parsing', function (assert) {
288 var i, ordinalStr, testMoment;
289 for (i = 1; i <= 31; ++i) {
290 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
291 testMoment = moment(ordinalStr, 'YYYY MM Do');
292 assert.equal(testMoment.year(), 2014,
293 'lenient ordinal parsing ' + i + ' year check');
294 assert.equal(testMoment.month(), 0,
295 'lenient ordinal parsing ' + i + ' month check');
296 assert.equal(testMoment.date(), i,
297 'lenient ordinal parsing ' + i + ' date check');
298 }
299 });
300
301 test('lenient ordinal parsing of number', function (assert) {
302 var i, testMoment;
303 for (i = 1; i <= 31; ++i) {
304 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
305 assert.equal(testMoment.year(), 2014,
306 'lenient ordinal parsing of number ' + i + ' year check');
307 assert.equal(testMoment.month(), 0,
308 'lenient ordinal parsing of number ' + i + ' month check');
309 assert.equal(testMoment.date(), i,
310 'lenient ordinal parsing of number ' + i + ' date check');
311 }
312 });
313
314 test('strict ordinal parsing', function (assert) {
315 var i, ordinalStr, testMoment;
316 for (i = 1; i <= 31; ++i) {
317 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
318 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
319 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
320 }
321 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('br');
3
4 test('parse', function (assert) {
5 var tests = 'Genver Gen_C\'hwevrer C\'hwe_Meurzh Meu_Ebrel Ebr_Mae Mae_Mezheven Eve_Gouere Gou_Eost Eos_Gwengolo Gwe_Here Her_Du Du_Kerzu Ker'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 moment.locale('br');
24 var a = [
25 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sul, C\'hwevrer 14vet 2010, 3:25:50 pm'],
26 ['ddd, h A', 'Sul, 3 PM'],
27 ['M Mo MM MMMM MMM', '2 2vet 02 C\'hwevrer C\'hwe'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14vet 14'],
30 ['d do dddd ddd dd', '0 0vet Sul Sul Su'],
31 ['DDD DDDo DDDD', '45 45vet 045'],
32 ['w wo ww', '6 6vet 06'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['DDDo [devezh] [ar] [vloaz]', '45vet devezh ar vloaz'],
38 ['L', '14/02/2010'],
39 ['LL', '14 a viz C\'hwevrer 2010'],
40 ['LLL', '14 a viz C\'hwevrer 2010 3e25 PM'],
41 ['LLLL', 'Sul, 14 a viz C\'hwevrer 2010 3e25 PM']
42 ],
43 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
44 i;
45 for (i = 0; i < a.length; i++) {
46 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
47 }
48 });
49
50 test('format ordinal', function (assert) {
51 moment.locale('br');
52 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1añ', '1añ');
53 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2vet', '2vet');
54 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3vet', '3vet');
55 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4vet', '4vet');
56 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5vet', '5vet');
57 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6vet', '6vet');
58 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7vet', '7vet');
59 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8vet', '8vet');
60 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9vet', '9vet');
61 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10vet', '10vet');
62
63 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11vet', '11vet');
64 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12vet', '12vet');
65 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13vet', '13vet');
66 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14vet', '14vet');
67 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15vet', '15vet');
68 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16vet', '16vet');
69 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17vet', '17vet');
70 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18vet', '18vet');
71 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19vet', '19vet');
72 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20vet', '20vet');
73
74 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21vet', '21vet');
75 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22vet', '22vet');
76 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23vet', '23vet');
77 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24vet', '24vet');
78 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25vet', '25vet');
79 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26vet', '26vet');
80 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27vet', '27vet');
81 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28vet', '28vet');
82 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29vet', '29vet');
83 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30vet', '30vet');
84
85 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31vet', '31vet');
86 });
87
88 test('format month', function (assert) {
89 moment.locale('br');
90 var expected = 'Genver Gen_C\'hwevrer C\'hwe_Meurzh Meu_Ebrel Ebr_Mae Mae_Mezheven Eve_Gouere Gou_Eost Eos_Gwengolo Gwe_Here Her_Du Du_Kerzu Ker'.split('_'), i;
91 for (i = 0; i < expected.length; i++) {
92 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
93 }
94 });
95
96 test('format week', function (assert) {
97 moment.locale('br');
98 var expected = 'Sul Sul Su_Lun Lun Lu_Meurzh Meu Me_Merc\'her Mer Mer_Yaou Yao Ya_Gwener Gwe Gw_Sadorn Sad Sa'.split('_'), i;
99 for (i = 0; i < expected.length; i++) {
100 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
101 }
102 });
103
104 test('from', function (assert) {
105 moment.locale('br');
106 var start = moment([2007, 1, 28]);
107 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'un nebeud segondennoù', '44 seconds = a few seconds');
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ur vunutenn', '45 seconds = a minute');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ur vunutenn', '89 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 vunutenn', '90 seconds = 2 minutes');
111 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 munutenn', '44 minutes = 44 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'un eur', '45 minutes = an hour');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'un eur', '89 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 eur', '90 minutes = 2 hours');
115 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 eur', '5 hours = 5 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 eur', '21 hours = 21 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un devezh', '22 hours = a day');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un devezh', '35 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 zevezh', '36 hours = 2 days');
120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un devezh', '1 day = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 devezh', '5 days = 5 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 devezh', '25 days = 25 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ur miz', '26 days = a month');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ur miz', '30 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ur miz', '43 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 viz', '46 days = 2 months');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 viz', '75 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 miz', '76 days = 3 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ur miz', '1 month = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 miz', '5 months = 5 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ur bloaz', '345 days = a year');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 vloaz', '548 days = 2 years');
133 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ur bloaz', '1 year = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 bloaz', '5 years = 5 years');
135 });
136
137 test('suffix', function (assert) {
138 moment.locale('br');
139 assert.equal(moment(30000).from(0), 'a-benn un nebeud segondennoù', 'prefix');
140 assert.equal(moment(0).from(30000), 'un nebeud segondennoù \'zo', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 moment.locale('br');
145 assert.equal(moment().fromNow(), 'un nebeud segondennoù \'zo', 'now from now should display as in the past');
146 });
147
148 test('fromNow', function (assert) {
149 moment.locale('br');
150 assert.equal(moment().add({s: 30}).fromNow(), 'a-benn un nebeud segondennoù', 'in a few seconds');
151 assert.equal(moment().add({d: 5}).fromNow(), 'a-benn 5 devezh', 'in 5 days');
152 });
153
154 test('calendar day', function (assert) {
155 moment.locale('br');
156
157 var a = moment().hours(2).minutes(0).seconds(0);
158
159 assert.equal(moment(a).calendar(), 'Hiziv da 2e00 AM', 'today at the same time');
160 assert.equal(moment(a).add({m: 25}).calendar(), 'Hiziv da 2e25 AM', 'Now plus 25 min');
161 assert.equal(moment(a).add({h: 1}).calendar(), 'Hiziv da 3e00 AM', 'Now plus 1 hour');
162 assert.equal(moment(a).add({d: 1}).calendar(), 'Warc\'hoazh da 2e00 AM', 'tomorrow at the same time');
163 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hiziv da 1e00 AM', 'Now minus 1 hour');
164 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dec\'h da 2e00 AM', 'yesterday at the same time');
165 });
166
167 test('calendar next week', function (assert) {
168 moment.locale('br');
169
170 var i, m;
171 for (i = 2; i < 7; i++) {
172 m = moment().add({d: i});
173 assert.equal(m.calendar(), m.format('dddd [da] LT'), 'Today + ' + i + ' days current time');
174 m.hours(0).minutes(0).seconds(0).milliseconds(0);
175 assert.equal(m.calendar(), m.format('dddd [da] LT'), 'Today + ' + i + ' days beginning of day');
176 m.hours(23).minutes(59).seconds(59).milliseconds(999);
177 assert.equal(m.calendar(), m.format('dddd [da] LT'), 'Today + ' + i + ' days end of day');
178 }
179 });
180
181 test('calendar last week', function (assert) {
182 moment.locale('br');
183
184 var i, m;
185 for (i = 2; i < 7; i++) {
186 m = moment().subtract({d: i});
187 assert.equal(m.calendar(), m.format('dddd [paset da] LT'), 'Today - ' + i + ' days current time');
188 m.hours(0).minutes(0).seconds(0).milliseconds(0);
189 assert.equal(m.calendar(), m.format('dddd [paset da] LT'), 'Today - ' + i + ' days beginning of day');
190 m.hours(23).minutes(59).seconds(59).milliseconds(999);
191 assert.equal(m.calendar(), m.format('dddd [paset da] LT'), 'Today - ' + i + ' days end of day');
192 }
193 });
194
195 test('calendar all else', function (assert) {
196 moment.locale('br');
197 var weeksAgo = moment().subtract({w: 1}),
198 weeksFromNow = moment().add({w: 1});
199
200 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
201 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
202
203 weeksAgo = moment().subtract({w: 2});
204 weeksFromNow = moment().add({w: 2});
205
206 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
207 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
208 });
209
210 test('special mutations for years', function (assert) {
211 moment.locale('br');
212 var start = moment([2007, 1, 28]);
213 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ur bloaz', 'mutation 1 year');
214 assert.equal(start.from(moment([2007, 1, 28]).add({y: 2}), true), '2 vloaz', 'mutation 2 years');
215 assert.equal(start.from(moment([2007, 1, 28]).add({y: 3}), true), '3 bloaz', 'mutation 3 years');
216 assert.equal(start.from(moment([2007, 1, 28]).add({y: 4}), true), '4 bloaz', 'mutation 4 years');
217 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 bloaz', 'mutation 5 years');
218 assert.equal(start.from(moment([2007, 1, 28]).add({y: 9}), true), '9 bloaz', 'mutation 9 years');
219 assert.equal(start.from(moment([2007, 1, 28]).add({y: 10}), true), '10 vloaz', 'mutation 10 years');
220 assert.equal(start.from(moment([2007, 1, 28]).add({y: 21}), true), '21 bloaz', 'mutation 21 years');
221 assert.equal(start.from(moment([2007, 1, 28]).add({y: 22}), true), '22 vloaz', 'mutation 22 years');
222 assert.equal(start.from(moment([2007, 1, 28]).add({y: 133}), true), '133 bloaz', 'mutation 133 years');
223 assert.equal(start.from(moment([2007, 1, 28]).add({y: 148}), true), '148 vloaz', 'mutation 148 years');
224 assert.equal(start.from(moment([2007, 1, 28]).add({y: 261}), true), '261 bloaz', 'mutation 261 years');
225 });
226
227 test('lenient ordinal parsing', function (assert) {
228 var i, ordinalStr, testMoment;
229 for (i = 1; i <= 31; ++i) {
230 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
231 testMoment = moment(ordinalStr, 'YYYY MM Do');
232 assert.equal(testMoment.year(), 2014,
233 'lenient ordinal parsing ' + i + ' year check');
234 assert.equal(testMoment.month(), 0,
235 'lenient ordinal parsing ' + i + ' month check');
236 assert.equal(testMoment.date(), i,
237 'lenient ordinal parsing ' + i + ' date check');
238 }
239 });
240
241 test('lenient ordinal parsing of number', function (assert) {
242 var i, testMoment;
243 for (i = 1; i <= 31; ++i) {
244 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
245 assert.equal(testMoment.year(), 2014,
246 'lenient ordinal parsing of number ' + i + ' year check');
247 assert.equal(testMoment.month(), 0,
248 'lenient ordinal parsing of number ' + i + ' month check');
249 assert.equal(testMoment.date(), i,
250 'lenient ordinal parsing of number ' + i + ' date check');
251 }
252 });
253
254 test('strict ordinal parsing', function (assert) {
255 var i, ordinalStr, testMoment;
256 for (i = 1; i <= 31; ++i) {
257 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
258 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
259 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
260 }
261 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('bs');
3
4 test('parse', function (assert) {
5 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;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedjelja, 14. februar 2010, 3:25:50 pm'],
25 ['ddd, hA', 'ned., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. nedjelja ned. ne'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '7 7. 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14. 02. 2010'],
40 ['LL', '14. februar 2010'],
41 ['LLL', '14. februar 2010 15:25'],
42 ['LLLL', 'nedjelja, 14. februar 2010 15:25'],
43 ['l', '14. 2. 2010'],
44 ['ll', '14. feb. 2010'],
45 ['lll', '14. feb. 2010 15:25'],
46 ['llll', 'ned., 14. feb. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = '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;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'nedjelja ned. ne_ponedjeljak pon. po_utorak uto. ut_srijeda sri. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'par sekundi', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedna minuta', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedna minuta', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mjesec', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mjesec', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mjesec', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mjeseca', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mjeseca', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mjeseca', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mjesec', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mjeseci', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'za par sekundi', 'prefix');
140 assert.equal(moment(0).from(30000), 'prije par sekundi', 'prefix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'prije par sekundi', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'za par sekundi', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165
166 function makeFormat(d) {
167 switch (d.day()) {
168 case 0:
169 return '[u] [nedjelju] [u] LT';
170 case 3:
171 return '[u] [srijedu] [u] LT';
172 case 6:
173 return '[u] [subotu] [u] LT';
174 case 1:
175 case 2:
176 case 4:
177 case 5:
178 return '[u] dddd [u] LT';
179 }
180 }
181
182 for (i = 2; i < 7; i++) {
183 m = moment().add({d: i});
184 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
185 m.hours(0).minutes(0).seconds(0).milliseconds(0);
186 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
187 m.hours(23).minutes(59).seconds(59).milliseconds(999);
188 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
189 }
190 });
191
192 test('calendar last week', function (assert) {
193 var i, m;
194
195 function makeFormat(d) {
196 switch (d.day()) {
197 case 0:
198 case 3:
199 return '[prošlu] dddd [u] LT';
200 case 6:
201 return '[prošle] [subote] [u] LT';
202 case 1:
203 case 2:
204 case 4:
205 case 5:
206 return '[prošli] dddd [u] LT';
207 }
208 }
209
210 for (i = 2; i < 7; i++) {
211 m = moment().subtract({d: i});
212 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
213 m.hours(0).minutes(0).seconds(0).milliseconds(0);
214 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
215 m.hours(23).minutes(59).seconds(59).milliseconds(999);
216 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
217 }
218 });
219
220 test('calendar all else', function (assert) {
221 var weeksAgo = moment().subtract({w: 1}),
222 weeksFromNow = moment().add({w: 1});
223
224 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
225 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
226
227 weeksAgo = moment().subtract({w: 2});
228 weeksFromNow = moment().add({w: 2});
229
230 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
231 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
232 });
233
234 test('weeks year starting sunday', function (assert) {
235 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
236 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
237 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
238 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
239 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
240 });
241
242 test('weeks year starting monday', function (assert) {
243 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
244 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
245 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
246 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
247 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
248 });
249
250 test('weeks year starting tuesday', function (assert) {
251 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
252 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
253 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
254 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
255 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
256 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
257 });
258
259 test('weeks year starting wednesday', function (assert) {
260 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
261 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
262 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
263 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
264 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
265 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
266 });
267
268 test('weeks year starting thursday', function (assert) {
269 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
270 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
271 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
272 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
273 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
274 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
275 });
276
277 test('weeks year starting friday', function (assert) {
278 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
279 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
280 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
281 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
282 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
283 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
284 });
285
286 test('weeks year starting saturday', function (assert) {
287 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
288 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
289 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
290 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
291 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
292 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
293 });
294
295 test('weeks year starting sunday formatted', function (assert) {
296 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
297 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
298 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
299 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
300 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
301 });
302
303 test('lenient ordinal parsing', function (assert) {
304 var i, ordinalStr, testMoment;
305 for (i = 1; i <= 31; ++i) {
306 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
307 testMoment = moment(ordinalStr, 'YYYY MM Do');
308 assert.equal(testMoment.year(), 2014,
309 'lenient ordinal parsing ' + i + ' year check');
310 assert.equal(testMoment.month(), 0,
311 'lenient ordinal parsing ' + i + ' month check');
312 assert.equal(testMoment.date(), i,
313 'lenient ordinal parsing ' + i + ' date check');
314 }
315 });
316
317 test('lenient ordinal parsing of number', function (assert) {
318 var i, testMoment;
319 for (i = 1; i <= 31; ++i) {
320 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
321 assert.equal(testMoment.year(), 2014,
322 'lenient ordinal parsing of number ' + i + ' year check');
323 assert.equal(testMoment.month(), 0,
324 'lenient ordinal parsing of number ' + i + ' month check');
325 assert.equal(testMoment.date(), i,
326 'lenient ordinal parsing of number ' + i + ' date check');
327 }
328 });
329
330 test('strict ordinal parsing', function (assert) {
331 var i, ordinalStr, testMoment;
332 for (i = 1; i <= 31; ++i) {
333 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
334 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
335 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
336 }
337 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ca');
3
4 test('parse', function (assert) {
5 var tests = 'gener gen._febrer febr._març mar._abril abr._maig mai._juny jun._juliol jul._agost ag._setembre set._octubre oct._novembre nov._desembre des.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'diumenge, 14è febrer 2010, 3:25:50 pm'],
25 ['ddd, hA', 'dg., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2n 02 febrer febr.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14è 14'],
29 ['d do dddd ddd dd', '0 0è diumenge dg. Dg'],
30 ['DDD DDDo DDDD', '45 45è 045'],
31 ['w wo ww', '6 6a 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45è day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 febrer 2010'],
41 ['LLL', '14 febrer 2010 15:25'],
42 ['LLLL', 'diumenge 14 febrer 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 febr. 2010'],
45 ['lll', '14 febr. 2010 15:25'],
46 ['llll', 'dg. 14 febr. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1r', '1r');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2n', '2n');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3r', '3r');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4t', '4t');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5è', '5è');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6è', '6è');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7è', '7è');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8è', '8è');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9è', '9è');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10è', '10è');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11è', '11è');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12è', '12è');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13è', '13è');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14è', '14è');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15è', '15è');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16è', '16è');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17è', '17è');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18è', '18è');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19è', '19è');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20è', '20è');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21è', '21è');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22è', '22è');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23è', '23è');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24è', '24è');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25è', '25è');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26è', '26è');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27è', '27è');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28è', '28è');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29è', '29è');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30è', '30è');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31è', '31è');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'gener gen._febrer febr._març mar._abril abr._maig mai._juny jun._juliol jul._agost ag._setembre set._octubre oct._novembre nov._desembre des.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'diumenge dg. Dg_dilluns dl. Dl_dimarts dt. Dt_dimecres dc. Dc_dijous dj. Dj_divendres dv. Dv_dissabte ds. Ds'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'uns segons', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minut', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minut', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuts', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuts', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'una hora', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'una hora', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hores', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hores', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hores', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un dia', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un dia', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dies', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un dia', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dies', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dies', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mes', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mes', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mes', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesos', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesos', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesos', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mes', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesos', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un any', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anys', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un any', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anys', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'en uns segons', 'prefix');
140 assert.equal(moment(0).from(30000), 'fa uns segons', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'fa uns segons', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'en uns segons', 'en uns segons');
149 assert.equal(moment().add({d: 5}).fromNow(), 'en 5 dies', 'en 5 dies');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'avui a les 2:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'avui a les 2:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'avui a les 3:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'demà a les 2:00', 'tomorrow at the same time');
159 assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'demà a la 1:00', 'tomorrow minus 1 hour');
160 assert.equal(moment(a).subtract({h: 1}).calendar(), 'avui a la 1:00', 'Now minus 1 hour');
161 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ahir a les 2:00', 'yesterday at the same time');
162 });
163
164 test('calendar next week', function (assert) {
165 var i, m;
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
204 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
206 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
212 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
213 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
214 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
215 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
222 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
223 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
224 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
231 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
232 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
233 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
240 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
241 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
242 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
247 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
248 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
249 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
250 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
251 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
252 });
253
254 test('weeks year starting saturday', function (assert) {
255 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
256 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
257 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
258 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
259 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
260 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
261 });
262
263 test('weeks year starting sunday formatted', function (assert) {
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1a', 'Jan 8 2012 should be week 1');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2a', 'Jan 9 2012 should be week 2');
268 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
269 });
270
271 test('lenient ordinal parsing', function (assert) {
272 var i, ordinalStr, testMoment;
273 for (i = 1; i <= 31; ++i) {
274 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
275 testMoment = moment(ordinalStr, 'YYYY MM Do');
276 assert.equal(testMoment.year(), 2014,
277 'lenient ordinal parsing ' + i + ' year check');
278 assert.equal(testMoment.month(), 0,
279 'lenient ordinal parsing ' + i + ' month check');
280 assert.equal(testMoment.date(), i,
281 'lenient ordinal parsing ' + i + ' date check');
282 }
283 });
284
285 test('lenient ordinal parsing of number', function (assert) {
286 var i, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
289 assert.equal(testMoment.year(), 2014,
290 'lenient ordinal parsing of number ' + i + ' year check');
291 assert.equal(testMoment.month(), 0,
292 'lenient ordinal parsing of number ' + i + ' month check');
293 assert.equal(testMoment.date(), i,
294 'lenient ordinal parsing of number ' + i + ' date check');
295 }
296 });
297
298 test('strict ordinal parsing', function (assert) {
299 var i, ordinalStr, testMoment;
300 for (i = 1; i <= 31; ++i) {
301 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
302 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
303 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
304 }
305 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('cs');
3
4 test('parse', function (assert) {
5 var tests = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split('_'), i;
6 function equalTest(input, mmm, monthIndex) {
7 assert.equal(moment(input, mmm).month(), monthIndex, input + ' should be month ' + (monthIndex + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss', 'neděle, únor 14. 2010, 3:25:50'],
25 ['ddd, h', 'ne, 3'],
26 ['M Mo MM MMMM MMM', '2 2. 02 únor úno'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. neděle ne ne'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['DDDo [den v roce]', '45. den v roce'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14. únor 2010'],
41 ['LLL', '14. únor 2010 15:25'],
42 ['LLLL', 'neděle 14. únor 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14. úno 2010'],
45 ['lll', '14. úno 2010 15:25'],
46 ['llll', 'ne 14. úno 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'neděle ne ne_pondělí po po_úterý út út_středa st st_čtvrtek čt čt_pátek pá pá_sobota so so'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'pár sekund', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuta', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuta', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuty', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minut', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'hodina', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'hodina', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hodiny', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hodin', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hodin', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'den', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'den', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dny', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'den', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dní', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dní', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'měsíc', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'měsíc', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'měsíc', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 měsíce', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 měsíce', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 měsíce', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'měsíc', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 měsíců', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'rok', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 roky', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'rok', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 let', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'za pár sekund', 'prefix');
140 assert.equal(moment(0).from(30000), 'před pár sekundami', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'před pár sekundami', 'now from now should display as in the past');
145 });
146
147 test('fromNow (future)', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'za pár sekund', 'in a few seconds');
149 assert.equal(moment().add({m: 1}).fromNow(), 'za minutu', 'in a minute');
150 assert.equal(moment().add({m: 3}).fromNow(), 'za 3 minuty', 'in 3 minutes');
151 assert.equal(moment().add({m: 10}).fromNow(), 'za 10 minut', 'in 10 minutes');
152 assert.equal(moment().add({h: 1}).fromNow(), 'za hodinu', 'in an hour');
153 assert.equal(moment().add({h: 3}).fromNow(), 'za 3 hodiny', 'in 3 hours');
154 assert.equal(moment().add({h: 10}).fromNow(), 'za 10 hodin', 'in 10 hours');
155 assert.equal(moment().add({d: 1}).fromNow(), 'za den', 'in a day');
156 assert.equal(moment().add({d: 3}).fromNow(), 'za 3 dny', 'in 3 days');
157 assert.equal(moment().add({d: 10}).fromNow(), 'za 10 dní', 'in 10 days');
158 assert.equal(moment().add({M: 1}).fromNow(), 'za měsíc', 'in a month');
159 assert.equal(moment().add({M: 3}).fromNow(), 'za 3 měsíce', 'in 3 months');
160 assert.equal(moment().add({M: 10}).fromNow(), 'za 10 měsíců', 'in 10 months');
161 assert.equal(moment().add({y: 1}).fromNow(), 'za rok', 'in a year');
162 assert.equal(moment().add({y: 3}).fromNow(), 'za 3 roky', 'in 3 years');
163 assert.equal(moment().add({y: 10}).fromNow(), 'za 10 let', 'in 10 years');
164 });
165
166 test('fromNow (past)', function (assert) {
167 assert.equal(moment().subtract({s: 30}).fromNow(), 'před pár sekundami', 'a few seconds ago');
168 assert.equal(moment().subtract({m: 1}).fromNow(), 'před minutou', 'a minute ago');
169 assert.equal(moment().subtract({m: 3}).fromNow(), 'před 3 minutami', '3 minutes ago');
170 assert.equal(moment().subtract({m: 10}).fromNow(), 'před 10 minutami', '10 minutes ago');
171 assert.equal(moment().subtract({h: 1}).fromNow(), 'před hodinou', 'an hour ago');
172 assert.equal(moment().subtract({h: 3}).fromNow(), 'před 3 hodinami', '3 hours ago');
173 assert.equal(moment().subtract({h: 10}).fromNow(), 'před 10 hodinami', '10 hours ago');
174 assert.equal(moment().subtract({d: 1}).fromNow(), 'před dnem', 'a day ago');
175 assert.equal(moment().subtract({d: 3}).fromNow(), 'před 3 dny', '3 days ago');
176 assert.equal(moment().subtract({d: 10}).fromNow(), 'před 10 dny', '10 days ago');
177 assert.equal(moment().subtract({M: 1}).fromNow(), 'před měsícem', 'a month ago');
178 assert.equal(moment().subtract({M: 3}).fromNow(), 'před 3 měsíci', '3 months ago');
179 assert.equal(moment().subtract({M: 10}).fromNow(), 'před 10 měsíci', '10 months ago');
180 assert.equal(moment().subtract({y: 1}).fromNow(), 'před rokem', 'a year ago');
181 assert.equal(moment().subtract({y: 3}).fromNow(), 'před 3 lety', '3 years ago');
182 assert.equal(moment().subtract({y: 10}).fromNow(), 'před 10 lety', '10 years ago');
183 });
184
185 test('calendar day', function (assert) {
186 var a = moment().hours(2).minutes(0).seconds(0);
187
188 assert.equal(moment(a).calendar(), 'dnes v 2:00', 'today at the same time');
189 assert.equal(moment(a).add({m: 25}).calendar(), 'dnes v 2:25', 'Now plus 25 min');
190 assert.equal(moment(a).add({h: 1}).calendar(), 'dnes v 3:00', 'Now plus 1 hour');
191 assert.equal(moment(a).add({d: 1}).calendar(), 'zítra v 2:00', 'tomorrow at the same time');
192 assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes v 1:00', 'Now minus 1 hour');
193 assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera v 2:00', 'yesterday at the same time');
194 });
195
196 test('calendar next week', function (assert) {
197 var i, m, nextDay;
198 for (i = 2; i < 7; i++) {
199 m = moment().add({d: i});
200 nextDay = '';
201 switch (m.day()) {
202 case 0:
203 nextDay = 'v neděli';
204 break;
205 case 1:
206 nextDay = 'v pondělí';
207 break;
208 case 2:
209 nextDay = 'v úterý';
210 break;
211 case 3:
212 nextDay = 've středu';
213 break;
214 case 4:
215 nextDay = 've čtvrtek';
216 break;
217 case 5:
218 nextDay = 'v pátek';
219 break;
220 case 6:
221 nextDay = 'v sobotu';
222 break;
223 }
224 assert.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), 'Today + ' + i + ' days current time');
225 m.hours(0).minutes(0).seconds(0).milliseconds(0);
226 assert.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), 'Today + ' + i + ' days beginning of day');
227 m.hours(23).minutes(59).seconds(59).milliseconds(999);
228 assert.equal(m.calendar(), m.format('[' + nextDay + '] [v] LT'), 'Today + ' + i + ' days end of day');
229 }
230 });
231
232 test('calendar last week', function (assert) {
233 var i, m, lastDay;
234 for (i = 2; i < 7; i++) {
235 m = moment().subtract({d: i});
236 lastDay = '';
237 switch (m.day()) {
238 case 0:
239 lastDay = 'minulou neděli';
240 break;
241 case 1:
242 lastDay = 'minulé pondělí';
243 break;
244 case 2:
245 lastDay = 'minulé úterý';
246 break;
247 case 3:
248 lastDay = 'minulou středu';
249 break;
250 case 4:
251 lastDay = 'minulý čtvrtek';
252 break;
253 case 5:
254 lastDay = 'minulý pátek';
255 break;
256 case 6:
257 lastDay = 'minulou sobotu';
258 break;
259 }
260 assert.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), 'Today - ' + i + ' days current time');
261 m.hours(0).minutes(0).seconds(0).milliseconds(0);
262 assert.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), 'Today - ' + i + ' days beginning of day');
263 m.hours(23).minutes(59).seconds(59).milliseconds(999);
264 assert.equal(m.calendar(), m.format('[' + lastDay + '] [v] LT'), 'Today - ' + i + ' days end of day');
265 }
266 });
267
268 test('calendar all else', function (assert) {
269 var weeksAgo = moment().subtract({w: 1}),
270 weeksFromNow = moment().add({w: 1});
271
272 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
273 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
274
275 weeksAgo = moment().subtract({w: 2});
276 weeksFromNow = moment().add({w: 2});
277
278 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
279 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
280 });
281
282 test('humanize duration', function (assert) {
283 assert.equal(moment.duration(1, 'minutes').humanize(), 'minuta', 'a minute (future)');
284 assert.equal(moment.duration(1, 'minutes').humanize(true), 'za minutu', 'in a minute');
285 assert.equal(moment.duration(-1, 'minutes').humanize(), 'minuta', 'a minute (past)');
286 assert.equal(moment.duration(-1, 'minutes').humanize(true), 'před minutou', 'a minute ago');
287 });
288
289 test('weeks year starting sunday', function (assert) {
290 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
291 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
292 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
293 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
294 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
295 });
296
297 test('weeks year starting monday', function (assert) {
298 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
299 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
300 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
301 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
302 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
303 });
304
305 test('weeks year starting tuesday', function (assert) {
306 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
307 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
308 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
309 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
310 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
311 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
312 });
313
314 test('weeks year starting wednesday', function (assert) {
315 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
316 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
317 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
318 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
319 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
320 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
321 });
322
323 test('weeks year starting thursday', function (assert) {
324 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
325 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
326 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
327 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
328 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
329 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
330 });
331
332 test('weeks year starting friday', function (assert) {
333 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
334 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
335 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
336 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
337 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
338 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
339 });
340
341 test('weeks year starting saturday', function (assert) {
342 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
343 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
344 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
345 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
346 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
347 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
348 });
349
350 test('weeks year starting sunday formatted', function (assert) {
351 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
352 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
353 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
354 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
355 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
356 });
357
358 test('lenient ordinal parsing', function (assert) {
359 var i, ordinalStr, testMoment;
360 for (i = 1; i <= 31; ++i) {
361 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
362 testMoment = moment(ordinalStr, 'YYYY MM Do');
363 assert.equal(testMoment.year(), 2014,
364 'lenient ordinal parsing ' + i + ' year check');
365 assert.equal(testMoment.month(), 0,
366 'lenient ordinal parsing ' + i + ' month check');
367 assert.equal(testMoment.date(), i,
368 'lenient ordinal parsing ' + i + ' date check');
369 }
370 });
371
372 test('lenient ordinal parsing of number', function (assert) {
373 var i, testMoment;
374 for (i = 1; i <= 31; ++i) {
375 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
376 assert.equal(testMoment.year(), 2014,
377 'lenient ordinal parsing of number ' + i + ' year check');
378 assert.equal(testMoment.month(), 0,
379 'lenient ordinal parsing of number ' + i + ' month check');
380 assert.equal(testMoment.date(), i,
381 'lenient ordinal parsing of number ' + i + ' date check');
382 }
383 });
384
385 test('strict ordinal parsing', function (assert) {
386 var i, ordinalStr, testMoment;
387 for (i = 1; i <= 31; ++i) {
388 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
389 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
390 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
391 }
392 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('cv');
3
4 test('parse', function (assert) {
5 var tests = 'кӑрлач кӑр_нарӑс нар_пуш пуш_ака ака_май май_ҫӗртме ҫӗр_утӑ утӑ_ҫурла ҫур_авӑн авн_юпа юпа_чӳк чӳк_раштав раш'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'вырсарникун, нарӑс 14-мӗш 2010, 3:25:50 pm'],
25 ['ddd, hA', 'выр, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2-мӗш 02 нарӑс нар'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14-мӗш 14'],
29 ['d do dddd ddd dd', '0 0-мӗш вырсарникун выр вр'],
30 ['DDD DDDo DDDD', '45 45-мӗш 045'],
31 ['w wo ww', '7 7-мӗш 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['Ҫулӑн DDDo кунӗ', 'Ҫулӑн 45-мӗш кунӗ'],
38 ['LTS', '15:25:50'],
39 ['L', '14-02-2010'],
40 ['LL', '2010 ҫулхи нарӑс уйӑхӗн 14-мӗшӗ'],
41 ['LLL', '2010 ҫулхи нарӑс уйӑхӗн 14-мӗшӗ, 15:25'],
42 ['LLLL', 'вырсарникун, 2010 ҫулхи нарӑс уйӑхӗн 14-мӗшӗ, 15:25'],
43 ['l', '14-2-2010'],
44 ['ll', '2010 ҫулхи нар уйӑхӗн 14-мӗшӗ'],
45 ['lll', '2010 ҫулхи нар уйӑхӗн 14-мӗшӗ, 15:25'],
46 ['llll', 'выр, 2010 ҫулхи нар уйӑхӗн 14-мӗшӗ, 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-мӗш', '1-мӗш');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-мӗш', '2-мӗш');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-мӗш', '3-мӗш');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-мӗш', '4-мӗш');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-мӗш', '5-мӗш');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-мӗш', '6-мӗш');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-мӗш', '7-мӗш');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-мӗш', '8-мӗш');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-мӗш', '9-мӗш');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-мӗш', '10-мӗш');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-мӗш', '11-мӗш');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-мӗш', '12-мӗш');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-мӗш', '13-мӗш');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-мӗш', '14-мӗш');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-мӗш', '15-мӗш');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-мӗш', '16-мӗш');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-мӗш', '17-мӗш');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-мӗш', '18-мӗш');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-мӗш', '19-мӗш');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-мӗш', '20-мӗш');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-мӗш', '21-мӗш');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-мӗш', '22-мӗш');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-мӗш', '23-мӗш');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-мӗш', '24-мӗш');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-мӗш', '25-мӗш');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-мӗш', '26-мӗш');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-мӗш', '27-мӗш');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-мӗш', '28-мӗш');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-мӗш', '29-мӗш');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-мӗш', '30-мӗш');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-мӗш', '31-мӗш');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'кӑрлач кӑр_нарӑс нар_пуш пуш_ака ака_май май_ҫӗртме ҫӗр_утӑ утӑ_ҫурла ҫур_авӑн авн_юпа юпа_чӳк чӳк_раштав раш'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'вырсарникун выр вр_тунтикун тун тн_ытларикун ытл ыт_юнкун юн юн_кӗҫнерникун кӗҫ кҫ_эрнекун эрн эр_шӑматкун шӑм шм'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'пӗр-ик ҫеккунт', '44 sekunder = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'пӗр минут', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'пӗр минут', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минут', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минут', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'пӗр сехет', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'пӗр сехет', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 сехет', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 сехет', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 сехет', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'пӗр кун', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'пӗр кун', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 кун', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'пӗр кун', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 кун', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 кун', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'пӗр уйӑх', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'пӗр уйӑх', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'пӗр уйӑх', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 уйӑх', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 уйӑх', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 уйӑх', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'пӗр уйӑх', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 уйӑх', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'пӗр ҫул', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ҫул', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'пӗр ҫул', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ҫул', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'пӗр-ик ҫеккунтран', 'prefix');
140 assert.equal(moment(0).from(30000), 'пӗр-ик ҫеккунт каялла', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'пӗр-ик ҫеккунт каялла', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'пӗр-ик ҫеккунтран', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), '5 кунран', 'in 5 days');
150 assert.equal(moment().add({h: 2}).fromNow(), '2 сехетрен', 'in 2 hours, the right suffix!');
151 assert.equal(moment().add({y: 3}).fromNow(), '3 ҫултан', 'in 3 years, the right suffix!');
152 });
153
154 test('calendar day', function (assert) {
155 var a = moment().hours(2).minutes(0).seconds(0);
156 assert.equal(moment(a).calendar(), 'Паян 02:00 сехетре', 'today at the same time');
157 assert.equal(moment(a).add({m: 25}).calendar(), 'Паян 02:25 сехетре', 'Now plus 25 min');
158 assert.equal(moment(a).add({h: 1}).calendar(), 'Паян 03:00 сехетре', 'Now plus 1 hour');
159 assert.equal(moment(a).add({d: 1}).calendar(), 'Ыран 02:00 сехетре', 'tomorrow at the same time');
160 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Паян 01:00 сехетре', 'Now minus 1 hour');
161 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ӗнер 02:00 сехетре', 'yesterday at the same time');
162 });
163
164 test('calendar next week', function (assert) {
165 var i, m;
166
167 for (i = 2; i < 7; i++) {
168 m = moment().add({d: i});
169 assert.equal(m.calendar(), m.format('[Ҫитес] dddd LT [сехетре]'), 'Today + ' + i + ' days current time');
170 m.hours(0).minutes(0).seconds(0).milliseconds(0);
171 assert.equal(m.calendar(), m.format('[Ҫитес] dddd LT [сехетре]'), 'Today + ' + i + ' days beginning of day');
172 m.hours(23).minutes(59).seconds(59).milliseconds(999);
173 assert.equal(m.calendar(), m.format('[Ҫитес] dddd LT [сехетре]'), 'Today + ' + i + ' days end of day');
174 }
175 });
176
177 test('calendar last week', function (assert) {
178 var i, m;
179
180 for (i = 2; i < 7; i++) {
181 m = moment().subtract({d: i});
182 assert.equal(m.calendar(), m.format('[Иртнӗ] dddd LT [сехетре]'), 'Today - ' + i + ' days current time');
183 m.hours(0).minutes(0).seconds(0).milliseconds(0);
184 assert.equal(m.calendar(), m.format('[Иртнӗ] dddd LT [сехетре]'), 'Today - ' + i + ' days beginning of day');
185 m.hours(23).minutes(59).seconds(59).milliseconds(999);
186 assert.equal(m.calendar(), m.format('[Иртнӗ] dddd LT [сехетре]'), 'Today - ' + i + ' days end of day');
187 }
188 });
189
190 test('calendar all else', function (assert) {
191 var weeksAgo = moment().subtract({w: 1}),
192 weeksFromNow = moment().add({w: 1});
193
194 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
195 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
196
197 weeksAgo = moment().subtract({w: 2});
198 weeksFromNow = moment().add({w: 2});
199
200 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
201 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
202 });
203
204 // Monday is the first day of the week.
205 // The week that contains Jan 1st is the first week of the year.
206
207 test('weeks year starting sunday', function (assert) {
208 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
209 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
210 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
211 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
212 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
213 });
214
215 test('weeks year starting monday', function (assert) {
216 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
217 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
218 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
219 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
220 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
221 });
222
223 test('weeks year starting tuesday', function (assert) {
224 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
225 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
226 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
227 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
228 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
229 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
230 });
231
232 test('weeks year starting wednesday', function (assert) {
233 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
234 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
235 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
236 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
237 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
238 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
239 });
240
241 test('weeks year starting thursday', function (assert) {
242 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
243 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
244 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
245 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
246 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
247 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
248 });
249
250 test('weeks year starting friday', function (assert) {
251 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
252 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
253 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
254 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
255 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
256 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
257 });
258
259 test('weeks year starting saturday', function (assert) {
260 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
261 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
262 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
263 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
264 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
265 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
266 });
267
268 test('weeks year starting sunday formatted', function (assert) {
269 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-мӗш', 'Dec 26 2011 should be week 1');
270 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-мӗш', 'Jan 1 2012 should be week 1');
271 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-мӗш', 'Jan 2 2012 should be week 2');
272 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-мӗш', 'Jan 8 2012 should be week 2');
273 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-мӗш', 'Jan 9 2012 should be week 3');
274 });
275
276 test('lenient ordinal parsing', function (assert) {
277 var i, ordinalStr, testMoment;
278 for (i = 1; i <= 31; ++i) {
279 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
280 testMoment = moment(ordinalStr, 'YYYY MM Do');
281 assert.equal(testMoment.year(), 2014,
282 'lenient ordinal parsing ' + i + ' year check');
283 assert.equal(testMoment.month(), 0,
284 'lenient ordinal parsing ' + i + ' month check');
285 assert.equal(testMoment.date(), i,
286 'lenient ordinal parsing ' + i + ' date check');
287 }
288 });
289
290 test('lenient ordinal parsing of number', function (assert) {
291 var i, testMoment;
292 for (i = 1; i <= 31; ++i) {
293 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
294 assert.equal(testMoment.year(), 2014,
295 'lenient ordinal parsing of number ' + i + ' year check');
296 assert.equal(testMoment.month(), 0,
297 'lenient ordinal parsing of number ' + i + ' month check');
298 assert.equal(testMoment.date(), i,
299 'lenient ordinal parsing of number ' + i + ' date check');
300 }
301 });
302
303 test('strict ordinal parsing', function (assert) {
304 var i, ordinalStr, testMoment;
305 for (i = 1; i <= 31; ++i) {
306 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
307 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
308 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
309 }
310 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('cy');
3
4 test('parse', function (assert) {
5 var tests = 'Ionawr Ion_Chwefror Chwe_Mawrth Maw_Ebrill Ebr_Mai Mai_Mehefin Meh_Gorffennaf Gor_Awst Aws_Medi Med_Hydref Hyd_Tachwedd Tach_Rhagfyr Rhag'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Dydd Sul, Chwefror 14eg 2010, 3:25:50 pm'],
26 ['ddd, hA', 'Sul, 3PM'],
27 ['M Mo MM MMMM MMM', '2 2il 02 Chwefror Chwe'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14eg 14'],
30 ['d do dddd ddd dd', '0 0 Dydd Sul Sul Su'],
31 ['DDD DDDo DDDD', '45 45ain 045'],
32 ['w wo ww', '6 6ed 06'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[the] DDDo [day of the year]', 'the 45ain day of the year'],
39 ['LTS', '15:25:50'],
40 ['L', '14/02/2010'],
41 ['LL', '14 Chwefror 2010'],
42 ['LLL', '14 Chwefror 2010 15:25'],
43 ['LLLL', 'Dydd Sul, 14 Chwefror 2010 15:25'],
44 ['l', '14/2/2010'],
45 ['ll', '14 Chwe 2010'],
46 ['lll', '14 Chwe 2010 15:25'],
47 ['llll', 'Sul, 14 Chwe 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1af', '1af');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2il', '2il');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3ydd', '3ydd');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4ydd', '4ydd');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5ed', '5ed');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6ed', '6ed');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7ed', '7ed');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8fed', '8fed');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9fed', '9fed');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10fed', '10fed');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11eg', '11eg');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12fed', '12fed');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13eg', '13eg');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14eg', '14eg');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15fed', '15fed');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16eg', '16eg');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17eg', '17eg');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18fed', '18fed');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19eg', '19eg');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20fed', '20fed');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ain', '21ain');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ain', '22ain');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ain', '23ain');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ain', '24ain');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ain', '25ain');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ain', '26ain');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ain', '27ain');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ain', '28ain');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ain', '29ain');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ain', '30ain');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ain', '31ain');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'Ionawr Ion_Chwefror Chwe_Mawrth Maw_Ebrill Ebr_Mai Mai_Mehefin Meh_Gorffennaf Gor_Awst Aws_Medi Med_Hydref Hyd_Tachwedd Tach_Rhagfyr Rhag'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'Dydd Sul Sul Su_Dydd Llun Llun Ll_Dydd Mawrth Maw Ma_Dydd Mercher Mer Me_Dydd Iau Iau Ia_Dydd Gwener Gwe Gw_Dydd Sadwrn Sad Sa'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ychydig eiliadau', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'munud', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'munud', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 munud', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 munud', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'awr', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'awr', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 awr', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 awr', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 awr', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'diwrnod', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'diwrnod', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 diwrnod', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'diwrnod', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 diwrnod', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 diwrnod', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mis', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mis', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mis', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mis', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mis', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mis', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mis', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mis', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'blwyddyn', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 flynedd', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'blwyddyn', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 flynedd', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'mewn ychydig eiliadau', 'prefix');
141 assert.equal(moment(0).from(30000), 'ychydig eiliadau yn ôl', 'suffix');
142 });
143
144 test('fromNow', function (assert) {
145 assert.equal(moment().add({s: 30}).fromNow(), 'mewn ychydig eiliadau', 'in a few seconds');
146 assert.equal(moment().add({d: 5}).fromNow(), 'mewn 5 diwrnod', 'in 5 days');
147 });
148
149 test('same day', function (assert) {
150 var a = moment().hours(2).minutes(0).seconds(0);
151
152 assert.equal(moment(a).calendar(), 'Heddiw am 02:00', 'today at the same time');
153 assert.equal(moment(a).add({m: 25}).calendar(), 'Heddiw am 02:25', 'Now plus 25 min');
154 assert.equal(moment(a).add({h: 1}).calendar(), 'Heddiw am 03:00', 'Now plus 1 hour');
155 assert.equal(moment(a).add({d: 1}).calendar(), 'Yfory am 02:00', 'tomorrow at the same time');
156 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heddiw am 01:00', 'Now minus 1 hour');
157 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ddoe am 02:00', 'yesterday at the same time');
158 });
159
160 test('same next week', function (assert) {
161 var i, m;
162
163 for (i = 2; i < 7; i++) {
164 m = moment().add({d: i});
165 assert.equal(m.calendar(), m.format('dddd [am] LT'), 'Today + ' + i + ' days current time');
166 m.hours(0).minutes(0).seconds(0).milliseconds(0);
167 assert.equal(m.calendar(), m.format('dddd [am] LT'), 'Today + ' + i + ' days beginning of day');
168 m.hours(23).minutes(59).seconds(59).milliseconds(999);
169 assert.equal(m.calendar(), m.format('dddd [am] LT'), 'Today + ' + i + ' days end of day');
170 }
171 });
172
173 test('same last week', function (assert) {
174 var i, m;
175
176 for (i = 2; i < 7; i++) {
177 m = moment().subtract({d: i});
178 assert.equal(m.calendar(), m.format('dddd [diwethaf am] LT'), 'Today - ' + i + ' days current time');
179 m.hours(0).minutes(0).seconds(0).milliseconds(0);
180 assert.equal(m.calendar(), m.format('dddd [diwethaf am] LT'), 'Today - ' + i + ' days beginning of day');
181 m.hours(23).minutes(59).seconds(59).milliseconds(999);
182 assert.equal(m.calendar(), m.format('dddd [diwethaf am] LT'), 'Today - ' + i + ' days end of day');
183 }
184 });
185
186 test('same all else', function (assert) {
187 var weeksAgo = moment().subtract({w: 1}),
188 weeksFromNow = moment().add({w: 1});
189
190 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
191 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
192
193 weeksAgo = moment().subtract({w: 2});
194 weeksFromNow = moment().add({w: 2});
195
196 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
197 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
198 });
199
200 test('weeks year starting sunday', function (assert) {
201 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
202 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
203 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
204 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
205 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
206 });
207
208 test('weeks year starting monday', function (assert) {
209 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
210 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
211 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
212 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
213 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
214 });
215
216 test('weeks year starting tuesday', function (assert) {
217 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
218 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
219 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
220 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
221 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
222 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
223 });
224
225 test('weeks year starting wednesday', function (assert) {
226 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
227 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
228 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
229 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
230 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
231 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
232 });
233
234 test('weeks year starting thursday', function (assert) {
235 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
236 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
237 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
238 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
239 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
240 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
241 });
242
243 test('weeks year starting friday', function (assert) {
244 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
245 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
246 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
247 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
248 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
249 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
250 });
251
252 test('weeks year starting saturday', function (assert) {
253 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
254 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
255 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
256 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
257 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
258 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
259 });
260
261 test('weeks year starting sunday formatted', function (assert) {
262 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ain', 'Jan 1 2012 should be week 52');
263 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1af', 'Jan 2 2012 should be week 1');
264 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1af', 'Jan 8 2012 should be week 1');
265 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2il', 'Jan 9 2012 should be week 2');
266 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2il', 'Jan 15 2012 should be week 2');
267 });
268
269 test('lenient ordinal parsing', function (assert) {
270 var i, ordinalStr, testMoment;
271 for (i = 1; i <= 31; ++i) {
272 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
273 testMoment = moment(ordinalStr, 'YYYY MM Do');
274 assert.equal(testMoment.year(), 2014,
275 'lenient ordinal parsing ' + i + ' year check');
276 assert.equal(testMoment.month(), 0,
277 'lenient ordinal parsing ' + i + ' month check');
278 assert.equal(testMoment.date(), i,
279 'lenient ordinal parsing ' + i + ' date check');
280 }
281 });
282
283 test('lenient ordinal parsing of number', function (assert) {
284 var i, testMoment;
285 for (i = 1; i <= 31; ++i) {
286 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
287 assert.equal(testMoment.year(), 2014,
288 'lenient ordinal parsing of number ' + i + ' year check');
289 assert.equal(testMoment.month(), 0,
290 'lenient ordinal parsing of number ' + i + ' month check');
291 assert.equal(testMoment.date(), i,
292 'lenient ordinal parsing of number ' + i + ' date check');
293 }
294 });
295
296 test('strict ordinal parsing', function (assert) {
297 var i, ordinalStr, testMoment;
298 for (i = 1; i <= 31; ++i) {
299 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
300 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
301 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
302 }
303 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('da');
3
4 test('parse', function (assert) {
5 var tests = 'januar jan_februar feb_marts mar_april apr_maj maj_juni jun_juli jul_august aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd [den] Do MMMM YYYY, h:mm:ss a', 'søndag den 14. februar 2010, 3:25:50 pm'],
25 ['ddd hA', 'søn 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. søndag søn sø'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[den] DDDo [dag på året]', 'den 45. dag på året'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14. februar 2010'],
41 ['LLL', '14. februar 2010 15:25'],
42 ['LLLL', 'søndag d. 14. februar 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14. feb 2010'],
45 ['lll', '14. feb 2010 15:25'],
46 ['llll', 'søn d. 14. feb 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'januar jan_februar feb_marts mar_april apr_maj maj_juni jun_juli jul_august aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'søndag søn sø_mandag man ma_tirsdag tir ti_onsdag ons on_torsdag tor to_fredag fre fr_lørdag lør lø'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'få sekunder', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'et minut', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'et minut', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutter', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutter', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'en time', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'en time', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timer', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timer', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timer', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dag', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dag', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dage', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dag', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dage', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dage', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en måned', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en måned', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en måned', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 måneder', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 måneder', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 måneder', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en måned', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 måneder', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'et år', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'et år', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'om få sekunder', 'prefix');
140 assert.equal(moment(0).from(30000), 'få sekunder siden', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'få sekunder siden', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'om få sekunder', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dage', 'in 5 days');
150 });
151
152 test('weeks year starting sunday', function (assert) {
153 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
154 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
155 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
156 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
157 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
158 });
159
160 test('weeks year starting monday', function (assert) {
161 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
162 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
163 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
164 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
165 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
166 });
167
168 test('weeks year starting tuesday', function (assert) {
169 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
170 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
171 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
172 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
173 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
174 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
175 });
176
177 test('weeks year starting wednesday', function (assert) {
178 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
179 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
180 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
181 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
182 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
183 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
184 });
185
186 test('weeks year starting thursday', function (assert) {
187 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
188 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
189 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
190 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
191 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
192 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
193 });
194
195 test('weeks year starting friday', function (assert) {
196 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
197 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
198 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
199 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
200 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
201 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
202 });
203
204 test('weeks year starting saturday', function (assert) {
205 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
206 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
207 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
208 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
209 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
210 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
211 });
212
213 test('weeks year starting sunday formatted', function (assert) {
214 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
215 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
216 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
217 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
218 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
219 });
220
221 test('lenient ordinal parsing', function (assert) {
222 var i, ordinalStr, testMoment;
223 for (i = 1; i <= 31; ++i) {
224 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
225 testMoment = moment(ordinalStr, 'YYYY MM Do');
226 assert.equal(testMoment.year(), 2014,
227 'lenient ordinal parsing ' + i + ' year check');
228 assert.equal(testMoment.month(), 0,
229 'lenient ordinal parsing ' + i + ' month check');
230 assert.equal(testMoment.date(), i,
231 'lenient ordinal parsing ' + i + ' date check');
232 }
233 });
234
235 test('lenient ordinal parsing of number', function (assert) {
236 var i, testMoment;
237 for (i = 1; i <= 31; ++i) {
238 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
239 assert.equal(testMoment.year(), 2014,
240 'lenient ordinal parsing of number ' + i + ' year check');
241 assert.equal(testMoment.month(), 0,
242 'lenient ordinal parsing of number ' + i + ' month check');
243 assert.equal(testMoment.date(), i,
244 'lenient ordinal parsing of number ' + i + ' date check');
245 }
246 });
247
248 test('strict ordinal parsing', function (assert) {
249 var i, ordinalStr, testMoment;
250 for (i = 1; i <= 31; ++i) {
251 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
252 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
253 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
254 }
255 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('de-at');
3
4 test('parse', function (assert) {
5 var tests = 'Jänner Jän._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
6
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10
11 for (i = 0; i < 12; i++) {
12 tests[i] = tests[i].split(' ');
13 equalTest(tests[i][0], 'MMM', i);
14 equalTest(tests[i][1], 'MMM', i);
15 equalTest(tests[i][0], 'MMMM', i);
16 equalTest(tests[i][1], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21 }
22 });
23
24 test('format', function (assert) {
25 var a = [
26 ['dddd, Do MMMM YYYY, h:mm:ss a', 'Sonntag, 14. Februar 2010, 3:25:50 pm'],
27 ['ddd, hA', 'So., 3PM'],
28 ['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
29 ['YYYY YY', '2010 10'],
30 ['D Do DD', '14 14. 14'],
31 ['d do dddd ddd dd', '0 0. Sonntag So. So'],
32 ['DDD DDDo DDDD', '45 45. 045'],
33 ['w wo ww', '6 6. 06'],
34 ['h hh', '3 03'],
35 ['H HH', '15 15'],
36 ['m mm', '25 25'],
37 ['s ss', '50 50'],
38 ['a A', 'pm PM'],
39 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
40 ['LTS', '15:25:50'],
41 ['L', '14.02.2010'],
42 ['LL', '14. Februar 2010'],
43 ['LLL', '14. Februar 2010 15:25'],
44 ['LLLL', 'Sonntag, 14. Februar 2010 15:25'],
45 ['l', '14.2.2010'],
46 ['ll', '14. Febr. 2010'],
47 ['lll', '14. Febr. 2010 15:25'],
48 ['llll', 'So., 14. Febr. 2010 15:25']
49 ],
50 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
51 i;
52 for (i = 0; i < a.length; i++) {
53 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
54 }
55 });
56
57 test('format ordinal', function (assert) {
58 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
59 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
60 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
61 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
62 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
63 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
64 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
65 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
66 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
67 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
68
69 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
70 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
71 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
72 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
73 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
74 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
75 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
76 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
77 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
78 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
79
80 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
81 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
82 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
83 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
84 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
85 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
86 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
87 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
88 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
89 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
90
91 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
92 });
93
94 test('format month', function (assert) {
95 var expected = 'Jänner Jän._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
96 for (i = 0; i < expected.length; i++) {
97 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
98 }
99 });
100
101 test('format week', function (assert) {
102 var expected = 'Sonntag So. So_Montag Mo. Mo_Dienstag Di. Di_Mittwoch Mi. Mi_Donnerstag Do. Do_Freitag Fr. Fr_Samstag Sa. Sa'.split('_'), i;
103 for (i = 0; i < expected.length; i++) {
104 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
105 }
106 });
107
108 test('from', function (assert) {
109 var start = moment([2007, 1, 28]);
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ein paar Sekunden', '44 seconds = a few seconds');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eine Minute', '45 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eine Minute', '89 seconds = a minute');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 Minuten', '90 seconds = 2 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 Minuten', '44 minutes = 44 minutes');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'eine Stunde', '45 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'eine Stunde', '89 minutes = an hour');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 Stunden', '90 minutes = 2 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 Stunden', '5 hours = 5 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 Stunden', '21 hours = 21 hours');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein Tag', '22 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein Tag', '35 hours = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 Tage', '36 hours = 2 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein Tag', '1 day = a day');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 Tage', '5 days = 5 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 Tage', '25 days = 25 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein Monat', '26 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein Monat', '30 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 Monate', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 Monate', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 Monate', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein Monat', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 Monate', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ein Jahr', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 Jahre', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ein Jahr', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 Jahre', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'in ein paar Sekunden', 'prefix');
141 assert.equal(moment(0).from(30000), 'vor ein paar Sekunden', 'suffix');
142 });
143
144 test('fromNow', function (assert) {
145 assert.equal(moment().add({s: 30}).fromNow(), 'in ein paar Sekunden', 'in a few seconds');
146 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 Tagen', 'in 5 days');
147 });
148
149 test('calendar day', function (assert) {
150 var a = moment().hours(2).minutes(0).seconds(0);
151
152 assert.equal(moment(a).calendar(), 'Heute um 02:00 Uhr', 'today at the same time');
153 assert.equal(moment(a).add({m: 25}).calendar(), 'Heute um 02:25 Uhr', 'Now plus 25 min');
154 assert.equal(moment(a).add({h: 1}).calendar(), 'Heute um 03:00 Uhr', 'Now plus 1 hour');
155 assert.equal(moment(a).add({d: 1}).calendar(), 'Morgen um 02:00 Uhr', 'tomorrow at the same time');
156 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heute um 01:00 Uhr', 'Now minus 1 hour');
157 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gestern um 02:00 Uhr', 'yesterday at the same time');
158 });
159
160 test('calendar next week', function (assert) {
161 var i, m;
162 for (i = 2; i < 7; i++) {
163 m = moment().add({d: i});
164 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
165 m.hours(0).minutes(0).seconds(0).milliseconds(0);
166 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
167 m.hours(23).minutes(59).seconds(59).milliseconds(999);
168 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
169 }
170 });
171
172 test('calendar last week', function (assert) {
173 var i, m;
174 for (i = 2; i < 7; i++) {
175 m = moment().subtract({d: i});
176 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
177 m.hours(0).minutes(0).seconds(0).milliseconds(0);
178 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
179 m.hours(23).minutes(59).seconds(59).milliseconds(999);
180 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
181 }
182 });
183
184 test('calendar all else', function (assert) {
185 var weeksAgo = moment().subtract({w: 1}),
186 weeksFromNow = moment().add({w: 1});
187
188 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
189 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
190
191 weeksAgo = moment().subtract({w: 2});
192 weeksFromNow = moment().add({w: 2});
193
194 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
195 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
196 });
197
198 test('weeks year starting sunday', function (assert) {
199 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
200 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
201 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
202 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
203 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
204 });
205
206 test('weeks year starting monday', function (assert) {
207 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
208 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
209 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
210 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
211 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
212 });
213
214 test('weeks year starting tuesday', function (assert) {
215 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
216 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
217 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
218 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
219 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
220 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
221 });
222
223 test('weeks year starting wednesday', function (assert) {
224 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
225 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
226 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
227 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
228 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
229 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
230 });
231
232 test('weeks year starting thursday', function (assert) {
233 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
234 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
235 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
236 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
237 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
238 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
239 });
240
241 test('weeks year starting friday', function (assert) {
242 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
243 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
244 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
245 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
246 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
247 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
248 });
249
250 test('weeks year starting saturday', function (assert) {
251 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
252 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
253 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
254 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
255 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
256 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
257 });
258
259 test('weeks year starting sunday formatted', function (assert) {
260 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
261 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
262 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
263 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
264 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
265 });
266
267 test('lenient ordinal parsing', function (assert) {
268 var i, ordinalStr, testMoment;
269 for (i = 1; i <= 31; ++i) {
270 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
271 testMoment = moment(ordinalStr, 'YYYY MM Do');
272 assert.equal(testMoment.year(), 2014,
273 'lenient ordinal parsing ' + i + ' year check');
274 assert.equal(testMoment.month(), 0,
275 'lenient ordinal parsing ' + i + ' month check');
276 assert.equal(testMoment.date(), i,
277 'lenient ordinal parsing ' + i + ' date check');
278 }
279 });
280
281 test('lenient ordinal parsing of number', function (assert) {
282 var i, testMoment;
283 for (i = 1; i <= 31; ++i) {
284 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
285 assert.equal(testMoment.year(), 2014,
286 'lenient ordinal parsing of number ' + i + ' year check');
287 assert.equal(testMoment.month(), 0,
288 'lenient ordinal parsing of number ' + i + ' month check');
289 assert.equal(testMoment.date(), i,
290 'lenient ordinal parsing of number ' + i + ' date check');
291 }
292 });
293
294 test('strict ordinal parsing', function (assert) {
295 var i, ordinalStr, testMoment;
296 for (i = 1; i <= 31; ++i) {
297 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
298 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
299 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
300 }
301 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('de');
3
4 test('parse', function (assert) {
5 var tests = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'Sonntag, 14. Februar 2010, 3:25:50 pm'],
25 ['ddd, hA', 'So., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. Sonntag So. So'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14. Februar 2010'],
41 ['LLL', '14. Februar 2010 15:25'],
42 ['LLLL', 'Sonntag, 14. Februar 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14. Febr. 2010'],
45 ['lll', '14. Febr. 2010 15:25'],
46 ['llll', 'So., 14. Febr. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Sonntag So. So_Montag Mo. Mo_Dienstag Di. Di_Mittwoch Mi. Mi_Donnerstag Do. Do_Freitag Fr. Fr_Samstag Sa. Sa'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ein paar Sekunden', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eine Minute', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eine Minute', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 Minuten', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 Minuten', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'eine Stunde', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'eine Stunde', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 Stunden', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 Stunden', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 Stunden', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein Tag', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein Tag', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 Tage', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein Tag', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 Tage', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 Tage', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein Monat', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein Monat', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ein Monat', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 Monate', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 Monate', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 Monate', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein Monat', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 Monate', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ein Jahr', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 Jahre', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ein Jahr', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 Jahre', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'in ein paar Sekunden', 'prefix');
140 assert.equal(moment(0).from(30000), 'vor ein paar Sekunden', 'suffix');
141 });
142
143 test('fromNow', function (assert) {
144 assert.equal(moment().add({s: 30}).fromNow(), 'in ein paar Sekunden', 'in a few seconds');
145 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 Tagen', 'in 5 days');
146 });
147
148 test('calendar day', function (assert) {
149 var a = moment().hours(2).minutes(0).seconds(0);
150
151 assert.equal(moment(a).calendar(), 'Heute um 02:00 Uhr', 'today at the same time');
152 assert.equal(moment(a).add({m: 25}).calendar(), 'Heute um 02:25 Uhr', 'Now plus 25 min');
153 assert.equal(moment(a).add({h: 1}).calendar(), 'Heute um 03:00 Uhr', 'Now plus 1 hour');
154 assert.equal(moment(a).add({d: 1}).calendar(), 'Morgen um 02:00 Uhr', 'tomorrow at the same time');
155 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heute um 01:00 Uhr', 'Now minus 1 hour');
156 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gestern um 02:00 Uhr', 'yesterday at the same time');
157 });
158
159 test('calendar next week', function (assert) {
160 var i, m;
161 for (i = 2; i < 7; i++) {
162 m = moment().add({d: i});
163 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
164 m.hours(0).minutes(0).seconds(0).milliseconds(0);
165 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
166 m.hours(23).minutes(59).seconds(59).milliseconds(999);
167 assert.equal(m.calendar(), m.format('dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
168 }
169 });
170
171 test('calendar last week', function (assert) {
172 var i, m;
173 for (i = 2; i < 7; i++) {
174 m = moment().subtract({d: i});
175 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days current time');
176 m.hours(0).minutes(0).seconds(0).milliseconds(0);
177 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days beginning of day');
178 m.hours(23).minutes(59).seconds(59).milliseconds(999);
179 assert.equal(m.calendar(), m.format('[letzten] dddd [um] LT [Uhr]'), 'Today + ' + i + ' days end of day');
180 }
181 });
182
183 test('calendar all else', function (assert) {
184 var weeksAgo = moment().subtract({w: 1}),
185 weeksFromNow = moment().add({w: 1});
186
187 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
188 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
189
190 weeksAgo = moment().subtract({w: 2});
191 weeksFromNow = moment().add({w: 2});
192
193 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
194 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
195 });
196
197 test('weeks year starting sunday', function (assert) {
198 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
199 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
200 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
201 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
202 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
203 });
204
205 test('weeks year starting monday', function (assert) {
206 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
207 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
208 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
209 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
210 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
211 });
212
213 test('weeks year starting tuesday', function (assert) {
214 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
215 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
216 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
217 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
218 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
219 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
220 });
221
222 test('weeks year starting wednesday', function (assert) {
223 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
224 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
225 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
226 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
227 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
228 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
229 });
230
231 test('weeks year starting thursday', function (assert) {
232 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
233 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
234 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
235 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
236 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
237 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
238 });
239
240 test('weeks year starting friday', function (assert) {
241 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
242 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
243 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
244 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
245 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
246 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
247 });
248
249 test('weeks year starting saturday', function (assert) {
250 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
251 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
252 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
253 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
254 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
255 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
256 });
257
258 test('weeks year starting sunday formatted', function (assert) {
259 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
260 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
261 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
262 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
263 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
264 });
265
266 test('lenient ordinal parsing', function (assert) {
267 var i, ordinalStr, testMoment;
268 for (i = 1; i <= 31; ++i) {
269 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
270 testMoment = moment(ordinalStr, 'YYYY MM Do');
271 assert.equal(testMoment.year(), 2014,
272 'lenient ordinal parsing ' + i + ' year check');
273 assert.equal(testMoment.month(), 0,
274 'lenient ordinal parsing ' + i + ' month check');
275 assert.equal(testMoment.date(), i,
276 'lenient ordinal parsing ' + i + ' date check');
277 }
278 });
279
280 test('lenient ordinal parsing of number', function (assert) {
281 var i, testMoment;
282 for (i = 1; i <= 31; ++i) {
283 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
284 assert.equal(testMoment.year(), 2014,
285 'lenient ordinal parsing of number ' + i + ' year check');
286 assert.equal(testMoment.month(), 0,
287 'lenient ordinal parsing of number ' + i + ' month check');
288 assert.equal(testMoment.date(), i,
289 'lenient ordinal parsing of number ' + i + ' date check');
290 }
291 });
292
293 test('strict ordinal parsing', function (assert) {
294 var i, ordinalStr, testMoment;
295 for (i = 1; i <= 31; ++i) {
296 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
297 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
298 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
299 }
300 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('el');
3
4 test('parse', function (assert) {
5 var i,
6 tests = 'Ιανουάριος Ιαν_Φεβρουάριος Φεβ_Μάρτιος Μαρ_Απρίλιος Απρ_Μάιος Μαϊ_Ιούνιος Ιουν_Ιούλιος Ιουλ_Αύγουστος Αυγ_Σεπτέμβριος Σεπ_Οκτώβριος Οκτ_Νοέμβριος Νοε_Δεκέμβριος Δεκ'.split('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('parse meridiem', function (assert) {
26 var i,
27 b = moment(),
28 meridiemTests = [
29 // h a patterns, expected hours, isValid
30 ['10 πμ', 10, true],
31 ['10 μμ', 22, true],
32 ['10 π.μ.', 10, true],
33 ['10 μ.μ.', 22, true],
34 ['10 π', 10, true],
35 ['10 μ', 22, true],
36 ['10 ΠΜ', 10, true],
37 ['10 ΜΜ', 22, true],
38 ['10 Π.Μ.', 10, true],
39 ['10 Μ.Μ.', 22, true],
40 ['10 Π', 10, true],
41 ['10 Μ', 22, true],
42 ['10 am', 10, false],
43 ['10 pm', 10, false]
44 ];
45
46 // test that a formatted moment including meridiem string can be parsed back to the same moment
47 assert.ok(b.isSame(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'el', true), 'seconds'), b.format('h:mm:ss a') + ' should be equal to ' + moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'el', true).format('h:mm:ss a'));
48
49 // test that a formatted moment having a meridiem string can be parsed with strict flag
50 assert.ok(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'el', true).isValid(), b.format('h:mm:ss a') + ' should be parsed as valid');
51
52 for (i = 0; i < meridiemTests.length; i++) {
53 assert.equal(moment(meridiemTests[i][0], 'h a', 'el', true).hours(), meridiemTests[i][1], moment(meridiemTests[i][0], 'h a', 'el', true).hours() + ' should be ' + meridiemTests[i][1]);
54 assert.ok(moment(meridiemTests[i][0], 'h a', 'el', true).isValid() === meridiemTests[i][2], meridiemTests[i][0] + ' ----> ' + meridiemTests[i][2]);
55 }
56 });
57
58 test('format', function (assert) {
59 var a = [
60 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Κυριακή, Φεβρουάριος 14η 2010, 3:25:50 μμ'],
61 ['dddd, D MMMM YYYY, h:mm:ss a', 'Κυριακή, 14 Φεβρουαρίου 2010, 3:25:50 μμ'],
62 ['ddd, hA', 'Κυρ, 3ΜΜ'],
63 ['dddd, MMMM YYYY', 'Κυριακή, Φεβρουάριος 2010'],
64 ['M Mo MM MMMM MMM', '2 2η 02 Φεβρουάριος Φεβ'],
65 ['YYYY YY', '2010 10'],
66 ['D Do DD', '14 14η 14'],
67 ['d do dddd ddd dd', '0 0η Κυριακή Κυρ Κυ'],
68 ['DDD DDDo DDDD', '45 45η 045'],
69 ['w wo ww', '6 6η 06'],
70 ['h hh', '3 03'],
71 ['H HH', '15 15'],
72 ['m mm', '25 25'],
73 ['s ss', '50 50'],
74 ['a A', 'μμ ΜΜ'],
75 ['[the] DDDo [day of the year]', 'the 45η day of the year'],
76 ['LTS', '3:25:50 ΜΜ'],
77 ['L', '14/02/2010'],
78 ['LL', '14 Φεβρουαρίου 2010'],
79 ['LLL', '14 Φεβρουαρίου 2010 3:25 ΜΜ'],
80 ['LLLL', 'Κυριακή, 14 Φεβρουαρίου 2010 3:25 ΜΜ'],
81 ['l', '14/2/2010'],
82 ['ll', '14 Φεβ 2010'],
83 ['lll', '14 Φεβ 2010 3:25 ΜΜ'],
84 ['llll', 'Κυρ, 14 Φεβ 2010 3:25 ΜΜ']
85 ],
86 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
87 i;
88
89 for (i = 0; i < a.length; i++) {
90 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
91 }
92 });
93
94 test('format ordinal', function (assert) {
95 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1η', '1η');
96 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2η', '2η');
97 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3η', '3η');
98 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4η', '4η');
99 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5η', '5η');
100 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6η', '6η');
101 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7η', '7η');
102 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8η', '8η');
103 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9η', '9η');
104 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10η', '10η');
105
106 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11η', '11η');
107 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12η', '12η');
108 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13η', '13η');
109 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14η', '14η');
110 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15η', '15η');
111 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16η', '16η');
112 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17η', '17η');
113 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18η', '18η');
114 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19η', '19η');
115 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20η', '20η');
116
117 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21η', '21η');
118 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22η', '22η');
119 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23η', '23η');
120 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24η', '24η');
121 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25η', '25η');
122 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26η', '26η');
123 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27η', '27η');
124 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28η', '28η');
125 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29η', '29η');
126 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30η', '30η');
127
128 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31η', '31η');
129 });
130
131 test('format month', function (assert) {
132 var i,
133 expected = 'Ιανουάριος Ιαν_Φεβρουάριος Φεβ_Μάρτιος Μαρ_Απρίλιος Απρ_Μάιος Μαϊ_Ιούνιος Ιουν_Ιούλιος Ιουλ_Αύγουστος Αυγ_Σεπτέμβριος Σεπ_Οκτώβριος Οκτ_Νοέμβριος Νοε_Δεκέμβριος Δεκ'.split('_');
134
135 for (i = 0; i < expected.length; i++) {
136 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
137 }
138 });
139
140 test('format week', function (assert) {
141 var i,
142 expected = 'Κυριακή Κυρ Κυ_Δευτέρα Δευ Δε_Τρίτη Τρι Τρ_Τετάρτη Τετ Τε_Πέμπτη Πεμ Πε_Παρασκευή Παρ Πα_Σάββατο Σαβ Σα'.split('_');
143
144 for (i = 0; i < expected.length; i++) {
145 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
146 }
147 });
148
149 test('from', function (assert) {
150 var start = moment([2007, 1, 28]);
151
152 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'λίγα δευτερόλεπτα', '44 seconds = a few seconds');
153 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ένα λεπτό', '45 seconds = a minute');
154 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ένα λεπτό', '89 seconds = a minute');
155 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 λεπτά', '90 seconds = 2 minutes');
156 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 λεπτά', '44 minutes = 44 minutes');
157 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'μία ώρα', '45 minutes = an hour');
158 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'μία ώρα', '89 minutes = an hour');
159 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ώρες', '90 minutes = 2 hours');
160 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ώρες', '5 hours = 5 hours');
161 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ώρες', '21 hours = 21 hours');
162 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'μία μέρα', '22 hours = a day');
163 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'μία μέρα', '35 hours = a day');
164 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 μέρες', '36 hours = 2 days');
165 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'μία μέρα', '1 day = a day');
166 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 μέρες', '5 days = 5 days');
167 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 μέρες', '25 days = 25 days');
168 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ένας μήνας', '26 days = a month');
169 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ένας μήνας', '30 days = a month');
170 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ένας μήνας', '43 days = a month');
171 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 μήνες', '46 days = 2 months');
172 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 μήνες', '75 days = 2 months');
173 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 μήνες', '76 days = 3 months');
174 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ένας μήνας', '1 month = a month');
175 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 μήνες', '5 months = 5 months');
176 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ένας χρόνος', '345 days = a year');
177 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 χρόνια', '548 days = 2 years');
178 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ένας χρόνος', '1 year = a year');
179 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 χρόνια', '5 years = 5 years');
180 });
181
182 test('suffix', function (assert) {
183 assert.equal(moment(30000).from(0), 'σε λίγα δευτερόλεπτα', 'prefix');
184 assert.equal(moment(0).from(30000), 'λίγα δευτερόλεπτα πριν', 'suffix');
185 });
186
187 test('now from now', function (assert) {
188 assert.equal(moment().fromNow(), 'λίγα δευτερόλεπτα πριν', 'now from now should display as in the past');
189 });
190
191 test('fromNow', function (assert) {
192 assert.equal(moment().add({s: 30}).fromNow(), 'σε λίγα δευτερόλεπτα', 'in a few seconds');
193 assert.equal(moment().add({d: 5}).fromNow(), 'σε 5 μέρες', 'in 5 days');
194 });
195
196 test('calendar day', function (assert) {
197 var a = moment().hours(2).minutes(0).seconds(0);
198
199 assert.equal(moment(a).calendar(), 'Σήμερα στις 2:00 ΠΜ', 'today at the same time');
200 assert.equal(moment(a).add({m: 25}).calendar(), 'Σήμερα στις 2:25 ΠΜ', 'Now plus 25 min');
201 assert.equal(moment(a).add({h: 1}).calendar(), 'Σήμερα στις 3:00 ΠΜ', 'Now plus 1 hour');
202 assert.equal(moment(a).add({d: 1}).calendar(), 'Αύριο στις 2:00 ΠΜ', 'tomorrow at the same time');
203 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Σήμερα στη 1:00 ΠΜ', 'Now minus 1 hour');
204 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Χθες στις 2:00 ΠΜ', 'yesterday at the same time');
205 });
206
207 test('calendar next week', function (assert) {
208 var i, m;
209 for (i = 2; i < 7; i++) {
210 m = moment().add({d: i});
211 assert.equal(m.calendar(), m.format('dddd [' + (m.hours() % 12 === 1 ? 'στη' : 'στις') + '] LT'), 'Today + ' + i + ' days current time');
212 m.hours(0).minutes(0).seconds(0).milliseconds(0);
213 assert.equal(m.calendar(), m.format('dddd [στις] LT'), 'Today + ' + i + ' days beginning of day');
214 m.hours(23).minutes(59).seconds(59).milliseconds(999);
215 assert.equal(m.calendar(), m.format('dddd [στις] LT'), 'Today + ' + i + ' days end of day');
216 }
217 });
218
219 test('calendar last week', function (assert) {
220 var i, m, dayString;
221 for (i = 2; i < 7; i++) {
222 m = moment().subtract({d: i});
223 dayString = m.day() === 6 ? '[το προηγούμενο Σάββατο]' : '[την προηγούμενη] dddd';
224 assert.equal(m.calendar(), m.format(dayString + ' [' + (m.hours() % 12 === 1 ? 'στη' : 'στις') + '] LT'), 'Today - ' + i + ' days current time');
225 m.hours(1).minutes(30).seconds(0).milliseconds(0);
226 assert.equal(m.calendar(), m.format(dayString + ' [στη] LT'), 'Today - ' + i + ' days one o clock');
227 m.hours(0).minutes(0).seconds(0).milliseconds(0);
228 assert.equal(m.calendar(), m.format(dayString + ' [στις] LT'), 'Today - ' + i + ' days beginning of day');
229 m.hours(23).minutes(59).seconds(59).milliseconds(999);
230 assert.equal(m.calendar(), m.format(dayString + ' [στις] LT'), 'Today - ' + i + ' days end of day');
231 }
232 });
233
234 test('calendar all else', function (assert) {
235 var weeksAgo = moment().subtract({w: 1}),
236 weeksFromNow = moment().add({w: 1});
237
238 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
239 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
240
241 weeksAgo = moment().subtract({w: 2});
242 weeksFromNow = moment().add({w: 2});
243
244 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
245 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
246 });
247
248 test('weeks year starting sunday', function (assert) {
249 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
250 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
251 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
252 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
253 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
254 });
255
256 test('weeks year starting monday', function (assert) {
257 assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
258 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
259 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
260 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
261 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
262 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
263 });
264
265 test('weeks year starting tuesday', function (assert) {
266 assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 should be week 52');
267 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
268 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
269 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
270 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
271 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
272 });
273
274 test('weeks year starting wednesday', function (assert) {
275 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
276 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
277 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
278 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
279 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
280 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
281 });
282
283 test('weeks year starting thursday', function (assert) {
284 assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 should be week 52');
285 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
286 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
287 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
288 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
289 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
290 });
291
292 test('weeks year starting friday', function (assert) {
293 assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 should be week 52');
294 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
295 assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
296 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 1');
297 assert.equal(moment([2010, 0, 9]).week(), 1, 'Jan 9 2010 should be week 1');
298 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
299 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
300 });
301
302 test('weeks year starting saturday', function (assert) {
303 assert.equal(moment([2010, 11, 26]).week(), 51, 'Dec 26 2010 should be week 51');
304 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
305 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
306 assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
307 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
308 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
309 });
310
311 test('weeks year starting sunday format', function (assert) {
312 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52η', 'Jan 1 2012 should be week 52');
313 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1η', 'Jan 7 2012 should be week 1');
314 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1η', 'Jan 8 2012 should be week 1');
315 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2η', 'Jan 14 2012 should be week 2');
316 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2η', 'Jan 15 2012 should be week 2');
317 });
318
319 test('lenient ordinal parsing', function (assert) {
320 var i, ordinalStr, testMoment;
321 for (i = 1; i <= 31; ++i) {
322 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
323 testMoment = moment(ordinalStr, 'YYYY MM Do');
324 assert.equal(testMoment.year(), 2014,
325 'lenient ordinal parsing ' + i + ' year check');
326 assert.equal(testMoment.month(), 0,
327 'lenient ordinal parsing ' + i + ' month check');
328 assert.equal(testMoment.date(), i,
329 'lenient ordinal parsing ' + i + ' date check');
330 }
331 });
332
333 test('lenient ordinal parsing of number', function (assert) {
334 var i, testMoment;
335 for (i = 1; i <= 31; ++i) {
336 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
337 assert.equal(testMoment.year(), 2014,
338 'lenient ordinal parsing of number ' + i + ' year check');
339 assert.equal(testMoment.month(), 0,
340 'lenient ordinal parsing of number ' + i + ' month check');
341 assert.equal(testMoment.date(), i,
342 'lenient ordinal parsing of number ' + i + ' date check');
343 }
344 });
345
346 test('strict ordinal parsing', function (assert) {
347 var i, ordinalStr, testMoment;
348 for (i = 1; i <= 31; ++i) {
349 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
350 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
351 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
352 }
353 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('en-au');
3
4 test('parse', function (assert) {
5 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;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Sun, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14th 14'],
29 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
30 ['DDD DDDo DDDD', '45 45th 045'],
31 ['w wo ww', '6 6th 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
38 ['LTS', '3:25:50 PM'],
39 ['L', '14/02/2010'],
40 ['LL', '14 February 2010'],
41 ['LLL', '14 February 2010 3:25 PM'],
42 ['LLLL', 'Sunday, 14 February 2010 3:25 PM'],
43 ['l', '14/2/2010'],
44 ['ll', '14 Feb 2010'],
45 ['lll', '14 Feb 2010 3:25 PM'],
46 ['llll', 'Sun, 14 Feb 2010 3:25 PM']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
90 });
91
92 test('format month', function (assert) {
93 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;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
140 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
204 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
206 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
212 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
213 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
214 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
215 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
222 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
223 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
224 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
231 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
232 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
233 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
240 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
241 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
242 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
247 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
248 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
249 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
250 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
251 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
252 });
253
254 test('weeks year starting saturday', function (assert) {
255 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
256 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
257 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
258 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
259 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
260 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
261 });
262
263 test('weeks year starting sunday formatted', function (assert) {
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', 'Jan 8 2012 should be week 1');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
268 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
269 });
270
271 test('lenient ordinal parsing', function (assert) {
272 var i, ordinalStr, testStr;
273 for (i = 1; i <= 31; ++i) {
274 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
275 testStr = moment(ordinalStr, 'YYYY MM Do').format('YYYY MM D');
276 assert.equal(testStr, '2014 01 ' + i, 'lenient ordinal parsing ' + i);
277 }
278 });
279
280 test('lenient ordinal parsing of number', function (assert) {
281 var i, testStr;
282 for (i = 1; i <= 31; ++i) {
283 testStr = moment('2014 01 ' + i, 'YYYY MM Do').format('YYYY MM D');
284 assert.equal(testStr, '2014 01 ' + i,
285 'lenient ordinal parsing of number ' + i);
286 }
287 });
288
289 test('strict ordinal parsing', function (assert) {
290 var i, ordinalStr, testMoment;
291 for (i = 1; i <= 31; ++i) {
292 ordinalStr = moment([2014, 0, i]).format('YYYY MMM Do');
293 testMoment = moment(ordinalStr, 'YYYY MMM Do', true);
294 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
295 }
296 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('en-ca');
3
4 test('parse', function (assert) {
5 var i,
6 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('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
28 ['ddd, hA', 'Sun, 3PM'],
29 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 14th 14'],
32 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
33 ['DDD DDDo DDDD', '45 45th 045'],
34 ['w wo ww', '8 8th 08'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'pm PM'],
40 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
41 ['L', '2010-02-14'],
42 ['LTS', '3:25:50 PM'],
43 ['LL', '14 February, 2010'],
44 ['LLL', '14 February, 2010 3:25 PM'],
45 ['LLLL', 'Sunday, 14 February, 2010 3:25 PM'],
46 ['l', '2010-2-14'],
47 ['ll', '14 Feb, 2010'],
48 ['lll', '14 Feb, 2010 3:25 PM'],
49 ['llll', 'Sun, 14 Feb, 2010 3:25 PM']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format ordinal', function (assert) {
60 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
61 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
62 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
63 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
64 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
65 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
66 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
67 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
68 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
69 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
70
71 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
72 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
73 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
74 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
75 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
76 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
77 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
78 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
79 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
80 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
81
82 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
83 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
84 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
85 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
86 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
87 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
88 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
89 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
90 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
91 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
92
93 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
94 });
95
96 test('format month', function (assert) {
97 var i,
98 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('_');
99
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
102 }
103 });
104
105 test('format week', function (assert) {
106 var i,
107 expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_');
108
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
111 }
112 });
113
114 test('from', function (assert) {
115 var start = moment([2007, 1, 28]);
116 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
120 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
124 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
138 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
139 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
142 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
143 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
144 });
145
146 test('suffix', function (assert) {
147 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
148 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
149 });
150
151 test('now from now', function (assert) {
152 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
153 });
154
155 test('fromNow', function (assert) {
156 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
157 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
158 });
159
160 test('calendar day', function (assert) {
161 var a = moment().hours(2).minutes(0).seconds(0);
162
163 assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
164 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
165 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
166 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
167 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
168 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
169 });
170
171 test('calendar next week', function (assert) {
172 var i, m;
173
174 for (i = 2; i < 7; i++) {
175 m = moment().add({d: i});
176 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
177 m.hours(0).minutes(0).seconds(0).milliseconds(0);
178 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
179 m.hours(23).minutes(59).seconds(59).milliseconds(999);
180 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
181 }
182 });
183
184 test('calendar last week', function (assert) {
185 var i, m;
186
187 for (i = 2; i < 7; i++) {
188 m = moment().subtract({d: i});
189 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
190 m.hours(0).minutes(0).seconds(0).milliseconds(0);
191 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
192 m.hours(23).minutes(59).seconds(59).milliseconds(999);
193 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
194 }
195 });
196
197 test('calendar all else', function (assert) {
198 var weeksAgo = moment().subtract({w: 1}),
199 weeksFromNow = moment().add({w: 1});
200
201 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
202 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
203
204 weeksAgo = moment().subtract({w: 2});
205 weeksFromNow = moment().add({w: 2});
206
207 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
208 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
209 });
210
211 test('weeks year starting sunday', function (assert) {
212 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
213 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
214 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
215 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
216 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
217 });
218
219 test('weeks year starting monday', function (assert) {
220 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
221 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
222 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
223 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
224 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
225 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
226 });
227
228 test('weeks year starting tuesday', function (assert) {
229 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
230 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
231 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
232 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
233 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
234 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
235 });
236
237 test('weeks year starting wednesday', function (assert) {
238 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
239 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
240 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
241 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
242 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
243 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
244 });
245
246 test('weeks year starting thursday', function (assert) {
247 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
248 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
249 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
250 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
251 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
252 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
253 });
254
255 test('weeks year starting friday', function (assert) {
256 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
257 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
258 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
259 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
260 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
261 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
262 });
263
264 test('weeks year starting saturday', function (assert) {
265 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
266 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
267 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
268 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
269 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
270 });
271
272 test('weeks year starting sunday format', function (assert) {
273 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
274 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
275 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2nd', 'Jan 8 2012 should be week 2');
276 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', 'Jan 14 2012 should be week 2');
277 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
278 });
279
280 test('lenient ordinal parsing', function (assert) {
281 var i, ordinalStr, testMoment;
282 for (i = 1; i <= 31; ++i) {
283 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
284 testMoment = moment(ordinalStr, 'YYYY MM Do');
285 assert.equal(testMoment.year(), 2014,
286 'lenient ordinal parsing ' + i + ' year check');
287 assert.equal(testMoment.month(), 0,
288 'lenient ordinal parsing ' + i + ' month check');
289 assert.equal(testMoment.date(), i,
290 'lenient ordinal parsing ' + i + ' date check');
291 }
292 });
293
294 test('lenient ordinal parsing of number', function (assert) {
295 var i, testMoment;
296 for (i = 1; i <= 31; ++i) {
297 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
298 assert.equal(testMoment.year(), 2014,
299 'lenient ordinal parsing of number ' + i + ' year check');
300 assert.equal(testMoment.month(), 0,
301 'lenient ordinal parsing of number ' + i + ' month check');
302 assert.equal(testMoment.date(), i,
303 'lenient ordinal parsing of number ' + i + ' date check');
304 }
305 });
306
307 test('strict ordinal parsing', function (assert) {
308 var i, ordinalStr, testMoment;
309 for (i = 1; i <= 31; ++i) {
310 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
311 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
312 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
313 }
314 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('en-gb');
3
4 test('parse', function (assert) {
5 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;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Sun, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14th 14'],
29 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
30 ['DDD DDDo DDDD', '45 45th 045'],
31 ['w wo ww', '6 6th 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 February 2010'],
41 ['LLL', '14 February 2010 15:25'],
42 ['LLLL', 'Sunday, 14 February 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 Feb 2010'],
45 ['lll', '14 Feb 2010 15:25'],
46 ['llll', 'Sun, 14 Feb 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
90 });
91
92 test('format month', function (assert) {
93 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;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
140 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'Today at 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
204 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
206 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
212 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
213 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
214 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
215 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
222 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
223 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
224 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
231 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
232 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
233 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
240 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
241 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
242 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
247 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
248 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
249 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
250 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
251 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
252 });
253
254 test('weeks year starting saturday', function (assert) {
255 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
256 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
257 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
258 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
259 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
260 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
261 });
262
263 test('weeks year starting sunday formatted', function (assert) {
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', 'Jan 8 2012 should be week 1');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
268 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
269 });
270
271 test('lenient ordinal parsing', function (assert) {
272 var i, ordinalStr, testMoment;
273 for (i = 1; i <= 31; ++i) {
274 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
275 testMoment = moment(ordinalStr, 'YYYY MM Do');
276 assert.equal(testMoment.year(), 2014,
277 'lenient ordinal parsing ' + i + ' year check');
278 assert.equal(testMoment.month(), 0,
279 'lenient ordinal parsing ' + i + ' month check');
280 assert.equal(testMoment.date(), i,
281 'lenient ordinal parsing ' + i + ' date check');
282 }
283 });
284
285 test('lenient ordinal parsing of number', function (assert) {
286 var i, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
289 assert.equal(testMoment.year(), 2014,
290 'lenient ordinal parsing of number ' + i + ' year check');
291 assert.equal(testMoment.month(), 0,
292 'lenient ordinal parsing of number ' + i + ' month check');
293 assert.equal(testMoment.date(), i,
294 'lenient ordinal parsing of number ' + i + ' date check');
295 }
296 });
297
298 test('strict ordinal parsing', function (assert) {
299 var i, ordinalStr, testMoment;
300 for (i = 1; i <= 31; ++i) {
301 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
302 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
303 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
304 }
305 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('en');
3
4 test('parse', function (assert) {
5 var i,
6 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('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
28 ['ddd, hA', 'Sun, 3PM'],
29 ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 14th 14'],
32 ['d do dddd ddd dd', '0 0th Sunday Sun Su'],
33 ['DDD DDDo DDDD', '45 45th 045'],
34 ['w wo ww', '8 8th 08'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'pm PM'],
40 ['[the] DDDo [day of the year]', 'the 45th day of the year'],
41 ['LTS', '3:25:50 PM'],
42 ['L', '02/14/2010'],
43 ['LL', 'February 14, 2010'],
44 ['LLL', 'February 14, 2010 3:25 PM'],
45 ['LLLL', 'Sunday, February 14, 2010 3:25 PM'],
46 ['l', '2/14/2010'],
47 ['ll', 'Feb 14, 2010'],
48 ['lll', 'Feb 14, 2010 3:25 PM'],
49 ['llll', 'Sun, Feb 14, 2010 3:25 PM']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format ordinal', function (assert) {
60 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
61 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
62 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
63 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
64 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
65 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
66 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
67 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
68 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
69 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
70
71 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
72 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
73 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
74 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
75 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
76 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
77 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
78 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
79 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
80 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
81
82 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
83 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
84 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
85 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
86 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
87 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
88 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
89 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
90 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
91 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
92
93 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
94 });
95
96 test('format month', function (assert) {
97 var i,
98 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('_');
99
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
102 }
103 });
104
105 test('format week', function (assert) {
106 var i,
107 expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split('_');
108
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
111 }
112 });
113
114 test('from', function (assert) {
115 var start = moment([2007, 1, 28]);
116
117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'a few seconds', '44 seconds = a few seconds');
118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'a minute', '45 seconds = a minute');
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'a minute', '89 seconds = a minute');
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'an hour', '45 minutes = an hour');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'an hour', '89 minutes = an hour');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hours', '90 minutes = 2 hours');
125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hours', '5 hours = 5 hours');
126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hours', '21 hours = 21 hours');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'a day', '22 hours = a day');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'a day', '35 hours = a day');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 days', '36 hours = 2 days');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'a day', '1 day = a day');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 days', '5 days = 5 days');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 days', '25 days = 25 days');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'a month', '26 days = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'a month', '30 days = a month');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'a month', '43 days = a month');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 months', '46 days = 2 months');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 months', '75 days = 2 months');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 months', '76 days = 3 months');
139 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'a month', '1 month = a month');
140 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 months', '5 months = 5 months');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'a year', '345 days = a year');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 years', '548 days = 2 years');
143 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'a year', '1 year = a year');
144 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 years', '5 years = 5 years');
145 });
146
147 test('suffix', function (assert) {
148 assert.equal(moment(30000).from(0), 'in a few seconds', 'prefix');
149 assert.equal(moment(0).from(30000), 'a few seconds ago', 'suffix');
150 });
151
152 test('now from now', function (assert) {
153 assert.equal(moment().fromNow(), 'a few seconds ago', 'now from now should display as in the past');
154 });
155
156 test('fromNow', function (assert) {
157 assert.equal(moment().add({s: 30}).fromNow(), 'in a few seconds', 'in a few seconds');
158 assert.equal(moment().add({d: 5}).fromNow(), 'in 5 days', 'in 5 days');
159 });
160
161 test('calendar day', function (assert) {
162 var a = moment().hours(2).minutes(0).seconds(0);
163
164 assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
165 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
166 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
167 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
168 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
169 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
170 });
171
172 test('calendar next week', function (assert) {
173 var i, m;
174
175 for (i = 2; i < 7; i++) {
176 m = moment().add({d: i});
177 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days current time');
178 m.hours(0).minutes(0).seconds(0).milliseconds(0);
179 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days beginning of day');
180 m.hours(23).minutes(59).seconds(59).milliseconds(999);
181 assert.equal(m.calendar(), m.format('dddd [at] LT'), 'Today + ' + i + ' days end of day');
182 }
183 });
184
185 test('calendar last week', function (assert) {
186 var i, m;
187
188 for (i = 2; i < 7; i++) {
189 m = moment().subtract({d: i});
190 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days current time');
191 m.hours(0).minutes(0).seconds(0).milliseconds(0);
192 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days beginning of day');
193 m.hours(23).minutes(59).seconds(59).milliseconds(999);
194 assert.equal(m.calendar(), m.format('[Last] dddd [at] LT'), 'Today - ' + i + ' days end of day');
195 }
196 });
197
198 test('calendar all else', function (assert) {
199 var weeksAgo = moment().subtract({w: 1}),
200 weeksFromNow = moment().add({w: 1});
201
202 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
203 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
204
205 weeksAgo = moment().subtract({w: 2});
206 weeksFromNow = moment().add({w: 2});
207
208 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
209 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
210 });
211
212 test('weeks year starting sunday', function (assert) {
213 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
214 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
215 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
216 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
217 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
218 });
219
220 test('weeks year starting monday', function (assert) {
221 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
222 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
223 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
224 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
225 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
226 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
227 });
228
229 test('weeks year starting tuesday', function (assert) {
230 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
231 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
232 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
233 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
234 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
235 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
236 });
237
238 test('weeks year starting wednesday', function (assert) {
239 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
240 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
241 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
242 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
243 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
244 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
245 });
246
247 test('weeks year starting thursday', function (assert) {
248 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
249 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
250 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
251 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
252 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
253 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
254 });
255
256 test('weeks year starting friday', function (assert) {
257 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
258 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
259 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
260 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
261 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
262 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
263 });
264
265 test('weeks year starting saturday', function (assert) {
266 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
267 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
268 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
269 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
270 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
271 });
272
273 test('weeks year starting sunday format', function (assert) {
274 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
275 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
276 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2nd', 'Jan 8 2012 should be week 2');
277 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2nd', 'Jan 14 2012 should be week 2');
278 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
279 });
280
281 test('lenient ordinal parsing', function (assert) {
282 var i, ordinalStr, testMoment;
283 for (i = 1; i <= 31; ++i) {
284 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
285 testMoment = moment(ordinalStr, 'YYYY MM Do');
286 assert.equal(testMoment.year(), 2014,
287 'lenient ordinal parsing ' + i + ' year check');
288 assert.equal(testMoment.month(), 0,
289 'lenient ordinal parsing ' + i + ' month check');
290 assert.equal(testMoment.date(), i,
291 'lenient ordinal parsing ' + i + ' date check');
292 }
293 });
294
295 test('lenient ordinal parsing of number', function (assert) {
296 var i, testMoment;
297 for (i = 1; i <= 31; ++i) {
298 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
299 assert.equal(testMoment.year(), 2014,
300 'lenient ordinal parsing of number ' + i + ' year check');
301 assert.equal(testMoment.month(), 0,
302 'lenient ordinal parsing of number ' + i + ' month check');
303 assert.equal(testMoment.date(), i,
304 'lenient ordinal parsing of number ' + i + ' date check');
305 }
306 });
307
308 test('strict ordinal parsing', function (assert) {
309 var i, ordinalStr, testMoment;
310 for (i = 1; i <= 31; ++i) {
311 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
312 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
313 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
314 }
315 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('eo');
3
4 test('parse', function (assert) {
5 var tests = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Dimanĉo, februaro 14a 2010, 3:25:50 p.t.m.'],
25 ['ddd, hA', 'Dim, 3P.T.M.'],
26 ['M Mo MM MMMM MMM', '2 2a 02 februaro feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14a 14'],
29 ['d do dddd ddd dd', '0 0a Dimanĉo Dim Di'],
30 ['DDD DDDo DDDD', '45 45a 045'],
31 ['w wo ww', '7 7a 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'p.t.m. P.T.M.'],
37 ['[la] DDDo [tago] [de] [la] [jaro]', 'la 45a tago de la jaro'],
38 ['LTS', '15:25:50'],
39 ['L', '2010-02-14'],
40 ['LL', '14-an de februaro, 2010'],
41 ['LLL', '14-an de februaro, 2010 15:25'],
42 ['LLLL', 'Dimanĉo, la 14-an de februaro, 2010 15:25'],
43 ['l', '2010-2-14'],
44 ['ll', '14-an de feb, 2010'],
45 ['lll', '14-an de feb, 2010 15:25'],
46 ['llll', 'Dim, la 14-an de feb, 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3a', '3a');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4a', '4a');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5a', '5a');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6a', '6a');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7a', '7a');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8a', '8a');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9a', '9a');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10a', '10a');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11a', '11a');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12a', '12a');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13a', '13a');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14a', '14a');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15a', '15a');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16a', '16a');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17a', '17a');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18a', '18a');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19a', '19a');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20a', '20a');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23a', '23a');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24a', '24a');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25a', '25a');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26a', '26a');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27a', '27a');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28a', '28a');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29a', '29a');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30a', '30a');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Dimanĉo Dim Di_Lundo Lun Lu_Mardo Mard Ma_Merkredo Merk Me_Ĵaŭdo Ĵaŭ Ĵa_Vendredo Ven Ve_Sabato Sab Sa'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'sekundoj', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuto', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuto', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutoj', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutoj', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'horo', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'horo', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horoj', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horoj', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horoj', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'tago', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'tago', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 tagoj', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'tago', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 tagoj', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 tagoj', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'monato', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'monato', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'monato', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 monatoj', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 monatoj', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 monatoj', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'monato', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 monatoj', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'jaro', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jaroj', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'jaro', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jaroj', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'je sekundoj', 'je prefix');
140 assert.equal(moment(0).from(30000), 'antaŭ sekundoj', 'antaŭ prefix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'antaŭ sekundoj', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'je sekundoj', 'je sekundoj');
149 assert.equal(moment().add({d: 5}).fromNow(), 'je 5 tagoj', 'je 5 tagoj');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'Hodiaŭ je 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'Hodiaŭ je 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'Hodiaŭ je 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'Morgaŭ je 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hodiaŭ je 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hieraŭ je 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [je] LT'), 'Today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [je] LT'), 'Today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [je] LT'), 'Today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178
179 for (i = 2; i < 7; i++) {
180 m = moment().subtract({d: i});
181 assert.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), 'Today - ' + i + ' days current time');
182 m.hours(0).minutes(0).seconds(0).milliseconds(0);
183 assert.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), 'Today - ' + i + ' days beginning of day');
184 m.hours(23).minutes(59).seconds(59).milliseconds(999);
185 assert.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), 'Today - ' + i + ' days end of day');
186 }
187 });
188
189 test('calendar all else', function (assert) {
190 var weeksAgo = moment().subtract({w: 1}),
191 weeksFromNow = moment().add({w: 1});
192
193 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
194 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
195
196 weeksAgo = moment().subtract({w: 2});
197 weeksFromNow = moment().add({w: 2});
198
199 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
200 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
201 });
202
203 test('weeks year starting sunday', function (assert) {
204 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
205 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
206 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
207 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
208 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
209 });
210
211 test('weeks year starting monday', function (assert) {
212 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
213 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
214 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
215 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
216 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
217 });
218
219 test('weeks year starting tuesday', function (assert) {
220 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
221 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
222 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
223 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
224 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
225 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
226 });
227
228 test('weeks year starting wednesday', function (assert) {
229 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
230 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
231 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
232 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
233 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
234 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
235 });
236
237 test('weeks year starting thursday', function (assert) {
238 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
239 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
240 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
241 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
242 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
243 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
244 });
245
246 test('weeks year starting friday', function (assert) {
247 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
248 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
249 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
250 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
251 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
252 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
253 });
254
255 test('weeks year starting saturday', function (assert) {
256 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
257 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
258 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
259 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
260 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
261 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
262 });
263
264 test('weeks year starting sunday formatted', function (assert) {
265 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1a', 'Dec 26 2011 should be week 1');
266 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1a', 'Jan 1 2012 should be week 1');
267 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2a', 'Jan 2 2012 should be week 2');
268 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2a', 'Jan 8 2012 should be week 2');
269 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3a', 'Jan 9 2012 should be week 3');
270 });
271
272 test('lenient ordinal parsing', function (assert) {
273 var i, ordinalStr, testMoment;
274 for (i = 1; i <= 31; ++i) {
275 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
276 testMoment = moment(ordinalStr, 'YYYY MM Do');
277 assert.equal(testMoment.year(), 2014,
278 'lenient ordinal parsing ' + i + ' year check');
279 assert.equal(testMoment.month(), 0,
280 'lenient ordinal parsing ' + i + ' month check');
281 assert.equal(testMoment.date(), i,
282 'lenient ordinal parsing ' + i + ' date check');
283 }
284 });
285
286 test('lenient ordinal parsing of number', function (assert) {
287 var i, testMoment;
288 for (i = 1; i <= 31; ++i) {
289 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
290 assert.equal(testMoment.year(), 2014,
291 'lenient ordinal parsing of number ' + i + ' year check');
292 assert.equal(testMoment.month(), 0,
293 'lenient ordinal parsing of number ' + i + ' month check');
294 assert.equal(testMoment.date(), i,
295 'lenient ordinal parsing of number ' + i + ' date check');
296 }
297 });
298
299 test('strict ordinal parsing', function (assert) {
300 var i, ordinalStr, testMoment;
301 for (i = 1; i <= 31; ++i) {
302 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
303 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
304 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
305 }
306 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('es');
3
4 test('parse', function (assert) {
5 var tests = 'enero ene._febrero feb._marzo mar._abril abr._mayo may._junio jun._julio jul._agosto ago._septiembre sep._octubre oct._noviembre nov._diciembre dic.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Febrero 14º 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Dom., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2º 02 Febrero Feb.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14º 14'],
29 ['d do dddd ddd dd', '0 0º Domingo Dom. Do'],
30 ['DDD DDDo DDDD', '45 45º 045'],
31 ['w wo ww', '6 6º 06'],
32 ['YYYY-MMM-DD', '2010-Feb-14'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
39 ['LTS', '15:25:50'],
40 ['L', '14/02/2010'],
41 ['LL', '14 de Febrero de 2010'],
42 ['LLL', '14 de Febrero de 2010 15:25'],
43 ['LLLL', 'Domingo, 14 de Febrero de 2010 15:25'],
44 ['l', '14/2/2010'],
45 ['ll', '14 de Feb. de 2010'],
46 ['lll', '14 de Feb. de 2010 15:25'],
47 ['llll', 'Dom., 14 de Feb. de 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'Enero Ene._Febrero Feb._Marzo Mar._Abril Abr._Mayo May._Junio Jun._Julio Jul._Agosto Ago._Septiembre Sep._Octubre Oct._Noviembre Nov._Diciembre Dic.'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'Domingo Dom. Do_Lunes Lun. Lu_Martes Mar. Ma_Miércoles Mié. Mi_Jueves Jue. Ju_Viernes Vie. Vi_Sábado Sáb. Sá'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'unos segundos', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minuto', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minuto', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'una hora', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'una hora', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un día', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un día', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 días', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un día', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 días', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 días', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mes', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mes', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mes', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mes', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un año', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 años', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un año', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 años', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'en unos segundos', 'prefix');
141 assert.equal(moment(0).from(30000), 'hace unos segundos', 'suffix');
142 });
143
144 test('now from now', function (assert) {
145 assert.equal(moment().fromNow(), 'hace unos segundos', 'now from now should display as in the past');
146 });
147
148 test('fromNow', function (assert) {
149 assert.equal(moment().add({s: 30}).fromNow(), 'en unos segundos', 'en unos segundos');
150 assert.equal(moment().add({d: 5}).fromNow(), 'en 5 días', 'en 5 días');
151 });
152
153 test('calendar day', function (assert) {
154 var a = moment().hours(2).minutes(0).seconds(0);
155
156 assert.equal(moment(a).calendar(), 'hoy a las 2:00', 'today at the same time');
157 assert.equal(moment(a).add({m: 25}).calendar(), 'hoy a las 2:25', 'Now plus 25 min');
158 assert.equal(moment(a).add({h: 1}).calendar(), 'hoy a las 3:00', 'Now plus 1 hour');
159 assert.equal(moment(a).add({d: 1}).calendar(), 'mañana a las 2:00', 'tomorrow at the same time');
160 assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañana a la 1:00', 'tomorrow minus 1 hour');
161 assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoy a la 1:00', 'Now minus 1 hour');
162 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ayer a las 2:00', 'yesterday at the same time');
163 });
164
165 test('calendar next week', function (assert) {
166 var i, m;
167
168 for (i = 2; i < 7; i++) {
169 m = moment().add({d: i});
170 assert.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today + ' + i + ' days current time');
171 m.hours(0).minutes(0).seconds(0).milliseconds(0);
172 assert.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today + ' + i + ' days beginning of day');
173 m.hours(23).minutes(59).seconds(59).milliseconds(999);
174 assert.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today + ' + i + ' days end of day');
175 }
176 });
177
178 test('calendar last week', function (assert) {
179 var i, m;
180
181 for (i = 2; i < 7; i++) {
182 m = moment().subtract({d: i});
183 assert.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today - ' + i + ' days current time');
184 m.hours(0).minutes(0).seconds(0).milliseconds(0);
185 assert.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today - ' + i + ' days beginning of day');
186 m.hours(23).minutes(59).seconds(59).milliseconds(999);
187 assert.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), 'Today - ' + i + ' days end of day');
188 }
189 });
190
191 test('calendar all else', function (assert) {
192 var weeksAgo = moment().subtract({w: 1}),
193 weeksFromNow = moment().add({w: 1});
194
195 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
196 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
197
198 weeksAgo = moment().subtract({w: 2});
199 weeksFromNow = moment().add({w: 2});
200
201 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
202 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
203 });
204
205 test('weeks year starting sunday', function (assert) {
206 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
207 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
208 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
209 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
210 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
211 });
212
213 test('weeks year starting monday', function (assert) {
214 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
215 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
216 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
217 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
218 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
219 });
220
221 test('weeks year starting tuesday', function (assert) {
222 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
223 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
224 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
225 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
226 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
227 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
228 });
229
230 test('weeks year starting wednesday', function (assert) {
231 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
232 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
233 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
234 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
235 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
236 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
237 });
238
239 test('weeks year starting thursday', function (assert) {
240 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
241 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
242 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
243 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
244 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
245 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
246 });
247
248 test('weeks year starting friday', function (assert) {
249 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
250 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
251 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
252 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
253 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
254 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
255 });
256
257 test('weeks year starting saturday', function (assert) {
258 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
259 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
260 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
261 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
262 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
263 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
264 });
265
266 test('weeks year starting sunday formatted', function (assert) {
267 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
268 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
269 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', 'Jan 8 2012 should be week 1');
270 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2');
271 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
272 });
273
274 test('lenient ordinal parsing', function (assert) {
275 var i, ordinalStr, testMoment;
276 for (i = 1; i <= 31; ++i) {
277 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
278 testMoment = moment(ordinalStr, 'YYYY MM Do');
279 assert.equal(testMoment.year(), 2014,
280 'lenient ordinal parsing ' + i + ' year check');
281 assert.equal(testMoment.month(), 0,
282 'lenient ordinal parsing ' + i + ' month check');
283 assert.equal(testMoment.date(), i,
284 'lenient ordinal parsing ' + i + ' date check');
285 }
286 });
287
288 test('lenient ordinal parsing of number', function (assert) {
289 var i, testMoment;
290 for (i = 1; i <= 31; ++i) {
291 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
292 assert.equal(testMoment.year(), 2014,
293 'lenient ordinal parsing of number ' + i + ' year check');
294 assert.equal(testMoment.month(), 0,
295 'lenient ordinal parsing of number ' + i + ' month check');
296 assert.equal(testMoment.date(), i,
297 'lenient ordinal parsing of number ' + i + ' date check');
298 }
299 });
300
301 test('strict ordinal parsing', function (assert) {
302 var i, ordinalStr, testMoment;
303 for (i = 1; i <= 31; ++i) {
304 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
305 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
306 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
307 }
308 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('et');
3
4 test('parse', function (assert) {
5 var tests = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' peaks olema kuu ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, H:mm:ss', 'pühapäev, 14. veebruar 2010, 15:25:50'],
25 ['ddd, h', 'P, 3'],
26 ['M Mo MM MMMM MMM', '2 2. 02 veebruar veebr'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. pühapäev P P'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[aasta] DDDo [päev]', 'aasta 45. päev'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14. veebruar 2010'],
41 ['LLL', '14. veebruar 2010 15:25'],
42 ['LLLL', 'pühapäev, 14. veebruar 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14. veebr 2010'],
45 ['lll', '14. veebr 2010 15:25'],
46 ['llll', 'P, 14. veebr 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'pühapäev P P_esmaspäev E E_teisipäev T T_kolmapäev K K_neljapäev N N_reede R R_laupäev L L'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'paar sekundit', '44 seconds = paar sekundit');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'üks minut', '45 seconds = üks minut');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'üks minut', '89 seconds = üks minut');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutit', '90 seconds = 2 minutit');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutit', '44 minutes = 44 minutit');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'üks tund', '45 minutes = tund aega');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'üks tund', '89 minutes = üks tund');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 tundi', '90 minutes = 2 tundi');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 tundi', '5 hours = 5 tundi');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tundi', '21 hours = 21 tundi');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'üks päev', '22 hours = üks päev');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'üks päev', '35 hours = üks päev');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 päeva', '36 hours = 2 päeva');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'üks päev', '1 day = üks päev');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 päeva', '5 days = 5 päeva');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 päeva', '25 days = 25 päeva');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'üks kuu', '26 days = üks kuu');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'üks kuu', '30 days = üks kuu');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'üks kuu', '43 days = üks kuu');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 kuud', '46 days = 2 kuud');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 kuud', '75 days = 2 kuud');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 kuud', '76 days = 3 kuud');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'üks kuu', '1 month = üks kuu');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 kuud', '5 months = 5 kuud');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'üks aasta', '345 days = üks aasta');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 aastat', '548 days = 2 aastat');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'üks aasta', '1 year = üks aasta');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 aastat', '5 years = 5 aastat');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'mõne sekundi pärast', 'prefix');
140 assert.equal(moment(0).from(30000), 'mõni sekund tagasi', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'mõni sekund tagasi', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'mõne sekundi pärast', 'in a few seconds');
149 assert.equal(moment().subtract({s: 30}).fromNow(), 'mõni sekund tagasi', 'a few seconds ago');
150
151 assert.equal(moment().add({m: 1}).fromNow(), 'ühe minuti pärast', 'in a minute');
152 assert.equal(moment().subtract({m: 1}).fromNow(), 'üks minut tagasi', 'a minute ago');
153
154 assert.equal(moment().add({m: 5}).fromNow(), '5 minuti pärast', 'in 5 minutes');
155 assert.equal(moment().subtract({m: 5}).fromNow(), '5 minutit tagasi', '5 minutes ago');
156
157 assert.equal(moment().add({d: 1}).fromNow(), 'ühe päeva pärast', 'in one day');
158 assert.equal(moment().subtract({d: 1}).fromNow(), 'üks päev tagasi', 'one day ago');
159
160 assert.equal(moment().add({d: 5}).fromNow(), '5 päeva pärast', 'in 5 days');
161 assert.equal(moment().subtract({d: 5}).fromNow(), '5 päeva tagasi', '5 days ago');
162
163 assert.equal(moment().add({M: 1}).fromNow(), 'kuu aja pärast', 'in a month');
164 assert.equal(moment().subtract({M: 1}).fromNow(), 'kuu aega tagasi', 'a month ago');
165
166 assert.equal(moment().add({M: 5}).fromNow(), '5 kuu pärast', 'in 5 months');
167 assert.equal(moment().subtract({M: 5}).fromNow(), '5 kuud tagasi', '5 months ago');
168
169 assert.equal(moment().add({y: 1}).fromNow(), 'ühe aasta pärast', 'in a year');
170 assert.equal(moment().subtract({y: 1}).fromNow(), 'aasta tagasi', 'a year ago');
171
172 assert.equal(moment().add({y: 5}).fromNow(), '5 aasta pärast', 'in 5 years');
173 assert.equal(moment().subtract({y: 5}).fromNow(), '5 aastat tagasi', '5 years ago');
174 });
175
176 test('calendar day', function (assert) {
177 var a = moment().hours(2).minutes(0).seconds(0);
178
179 assert.equal(moment(a).calendar(), 'Täna, 2:00', 'today at the same time');
180 assert.equal(moment(a).add({m: 25}).calendar(), 'Täna, 2:25', 'Now plus 25 min');
181 assert.equal(moment(a).add({h: 1}).calendar(), 'Täna, 3:00', 'Now plus 1 hour');
182 assert.equal(moment(a).add({d: 1}).calendar(), 'Homme, 2:00', 'tomorrow at the same time');
183 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Täna, 1:00', 'Now minus 1 hour');
184 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Eile, 2:00', 'yesterday at the same time');
185 });
186
187 test('calendar next week', function (assert) {
188 var i, m;
189 for (i = 2; i < 7; i++) {
190 m = moment().add({d: i});
191 assert.equal(m.calendar(), m.format('[Järgmine] dddd LT'), 'Today + ' + i + ' days current time');
192 m.hours(0).minutes(0).seconds(0).milliseconds(0);
193 assert.equal(m.calendar(), m.format('[Järgmine] dddd LT'), 'Today + ' + i + ' days beginning of day');
194 m.hours(23).minutes(59).seconds(59).milliseconds(999);
195 assert.equal(m.calendar(), m.format('[Järgmine] dddd LT'), 'Today + ' + i + ' days end of day');
196 }
197 });
198
199 test('calendar last week', function (assert) {
200 var i, m;
201 for (i = 2; i < 7; i++) {
202 m = moment().subtract({d: i});
203 assert.equal(m.calendar(), m.format('[Eelmine] dddd LT'), 'Today - ' + i + ' days current time');
204 m.hours(0).minutes(0).seconds(0).milliseconds(0);
205 assert.equal(m.calendar(), m.format('[Eelmine] dddd LT'), 'Today - ' + i + ' days beginning of day');
206 m.hours(23).minutes(59).seconds(59).milliseconds(999);
207 assert.equal(m.calendar(), m.format('[Eelmine] dddd LT'), 'Today - ' + i + ' days end of day');
208 }
209 });
210
211 test('calendar all else', function (assert) {
212 var weeksAgo = moment().subtract({w: 1}),
213 weeksFromNow = moment().add({w: 1});
214
215 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 nädal tagasi');
216 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '1 nädala pärast');
217
218 weeksAgo = moment().subtract({w: 2});
219 weeksFromNow = moment().add({w: 2});
220
221 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 nädalat tagasi');
222 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 nädala pärast');
223 });
224
225 test('weeks year starting sunday', function (assert) {
226 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
227 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
228 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
229 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
230 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
231 });
232
233 test('weeks year starting monday', function (assert) {
234 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
235 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
236 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
237 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
238 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
239 });
240
241 test('weeks year starting tuesday', function (assert) {
242 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
243 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
244 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
245 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
246 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
247 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
248 });
249
250 test('weeks year starting wednesday', function (assert) {
251 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
252 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
253 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
254 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
255 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
256 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
257 });
258
259 test('weeks year starting thursday', function (assert) {
260 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
261 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
262 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
263 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
264 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
265 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
266 });
267
268 test('weeks year starting friday', function (assert) {
269 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
270 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
271 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
272 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
273 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
274 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
275 });
276
277 test('weeks year starting saturday', function (assert) {
278 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
279 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
280 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
281 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
282 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
283 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
284 });
285
286 test('weeks year starting sunday formatted', function (assert) {
287 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
288 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
289 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
290 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
291 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
292 });
293
294 test('lenient ordinal parsing', function (assert) {
295 var i, ordinalStr, testMoment;
296 for (i = 1; i <= 31; ++i) {
297 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
298 testMoment = moment(ordinalStr, 'YYYY MM Do');
299 assert.equal(testMoment.year(), 2014,
300 'lenient ordinal parsing ' + i + ' year check');
301 assert.equal(testMoment.month(), 0,
302 'lenient ordinal parsing ' + i + ' month check');
303 assert.equal(testMoment.date(), i,
304 'lenient ordinal parsing ' + i + ' date check');
305 }
306 });
307
308 test('lenient ordinal parsing of number', function (assert) {
309 var i, testMoment;
310 for (i = 1; i <= 31; ++i) {
311 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
312 assert.equal(testMoment.year(), 2014,
313 'lenient ordinal parsing of number ' + i + ' year check');
314 assert.equal(testMoment.month(), 0,
315 'lenient ordinal parsing of number ' + i + ' month check');
316 assert.equal(testMoment.date(), i,
317 'lenient ordinal parsing of number ' + i + ' date check');
318 }
319 });
320
321 test('strict ordinal parsing', function (assert) {
322 var i, ordinalStr, testMoment;
323 for (i = 1; i <= 31; ++i) {
324 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
325 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
326 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
327 }
328 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('eu');
3
4 test('parse', function (assert) {
5 var tests = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'igandea, otsaila 14. 2010, 3:25:50 pm'],
25 ['ddd, hA', 'ig., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 otsaila ots.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. igandea ig. ig'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '7 7. 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '2010-02-14'],
40 ['LL', '2010ko otsailaren 14a'],
41 ['LLL', '2010ko otsailaren 14a 15:25'],
42 ['LLLL', 'igandea, 2010ko otsailaren 14a 15:25'],
43 ['l', '2010-2-14'],
44 ['ll', '2010ko ots. 14a'],
45 ['lll', '2010ko ots. 14a 15:25'],
46 ['llll', 'ig., 2010ko ots. 14a 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'igandea ig. ig_astelehena al. al_asteartea ar. ar_asteazkena az. az_osteguna og. og_ostirala ol. ol_larunbata lr. lr'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'segundo batzuk', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minutu bat', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minutu bat', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutu', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutu', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ordu bat', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ordu bat', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ordu', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ordu', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ordu', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'egun bat', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'egun bat', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 egun', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'egun bat', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 egun', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 egun', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'hilabete bat', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'hilabete bat', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'hilabete bat', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 hilabete', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 hilabete', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 hilabete', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'hilabete bat', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 hilabete', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'urte bat', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 urte', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'urte bat', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 urte', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'segundo batzuk barru', 'prefix');
140 assert.equal(moment(0).from(30000), 'duela segundo batzuk', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'duela segundo batzuk', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'segundo batzuk barru', 'in seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), '5 egun barru', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'gaur 02:00etan', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'gaur 02:25etan', 'now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'gaur 03:00etan', 'now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'bihar 02:00etan', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'gaur 01:00etan', 'now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'atzo 02:00etan', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd LT[etan]'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd LT[etan]'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd LT[etan]'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('weeks year starting sunday', function (assert) {
202 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
203 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
204 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
205 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
206 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
207 });
208
209 test('weeks year starting monday', function (assert) {
210 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
211 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
212 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
213 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
214 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
215 });
216
217 test('weeks year starting tuesday', function (assert) {
218 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
219 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
220 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
221 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
222 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
223 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
224 });
225
226 test('weeks year starting wednesday', function (assert) {
227 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
228 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
229 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
230 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
231 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
232 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
233 });
234
235 test('weeks year starting thursday', function (assert) {
236 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
237 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
238 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
239 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
240 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
241 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
242 });
243
244 test('weeks year starting friday', function (assert) {
245 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
246 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
247 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
248 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
249 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
250 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
251 });
252
253 test('weeks year starting saturday', function (assert) {
254 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
255 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
256 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
257 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
258 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
259 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
260 });
261
262 test('weeks year starting sunday formatted', function (assert) {
263 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
268 });
269
270 test('lenient ordinal parsing', function (assert) {
271 var i, ordinalStr, testMoment;
272 for (i = 1; i <= 31; ++i) {
273 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
274 testMoment = moment(ordinalStr, 'YYYY MM Do');
275 assert.equal(testMoment.year(), 2014,
276 'lenient ordinal parsing ' + i + ' year check');
277 assert.equal(testMoment.month(), 0,
278 'lenient ordinal parsing ' + i + ' month check');
279 assert.equal(testMoment.date(), i,
280 'lenient ordinal parsing ' + i + ' date check');
281 }
282 });
283
284 test('lenient ordinal parsing of number', function (assert) {
285 var i, testMoment;
286 for (i = 1; i <= 31; ++i) {
287 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
288 assert.equal(testMoment.year(), 2014,
289 'lenient ordinal parsing of number ' + i + ' year check');
290 assert.equal(testMoment.month(), 0,
291 'lenient ordinal parsing of number ' + i + ' month check');
292 assert.equal(testMoment.date(), i,
293 'lenient ordinal parsing of number ' + i + ' date check');
294 }
295 });
296
297 test('strict ordinal parsing', function (assert) {
298 var i, ordinalStr, testMoment;
299 for (i = 1; i <= 31; ++i) {
300 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
301 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
302 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
303 }
304 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('fa');
3
4 test('parse', function (assert) {
5 var tests = 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month());
8 }
9 for (i = 0; i < 12; i++) {
10 equalTest(tests[i], 'MMM', i);
11 equalTest(tests[i], 'MMMM', i);
12 }
13 });
14
15 test('format', function (assert) {
16 var a = [
17 ['dddd, MMMM Do YYYY, h:mm:ss a', 'یک\u200cشنبه، فوریه ۱۴م ۲۰۱۰، ۳:۲۵:۵۰ بعد از ظهر'],
18 ['ddd, hA', 'یک\u200cشنبه، ۳بعد از ظهر'],
19 ['M Mo MM MMMM MMM', '۲ ۲م ۰۲ فوریه فوریه'],
20 ['YYYY YY', '۲۰۱۰ ۱۰'],
21 ['D Do DD', '۱۴ ۱۴م ۱۴'],
22 ['d do dddd ddd dd', '۰ ۰م یک\u200cشنبه یک\u200cشنبه ی'],
23 ['DDD DDDo DDDD', '۴۵ ۴۵م ۰۴۵'],
24 ['w wo ww', '۸ ۸م ۰۸'],
25 ['h hh', '۳ ۰۳'],
26 ['H HH', '۱۵ ۱۵'],
27 ['m mm', '۲۵ ۲۵'],
28 ['s ss', '۵۰ ۵۰'],
29 ['a A', 'بعد از ظهر بعد از ظهر'],
30 ['DDDo [روز سال]', '۴۵م روز سال'],
31 ['LTS', '۱۵:۲۵:۵۰'],
32 ['L', '۱۴/۰۲/۲۰۱۰'],
33 ['LL', '۱۴ فوریه ۲۰۱۰'],
34 ['LLL', '۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
35 ['LLLL', 'یک\u200cشنبه، ۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
36 ['l', '۱۴/۲/۲۰۱۰'],
37 ['ll', '۱۴ فوریه ۲۰۱۰'],
38 ['lll', '۱۴ فوریه ۲۰۱۰ ۱۵:۲۵'],
39 ['llll', 'یک\u200cشنبه، ۱۴ فوریه ۲۰۱۰ ۱۵:۲۵']
40 ],
41 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
42 i;
43 for (i = 0; i < a.length; i++) {
44 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
45 }
46 });
47
48 test('format ordinal', function (assert) {
49 assert.equal(moment([2011, 0, 1]).format('DDDo'), '۱م', '1');
50 assert.equal(moment([2011, 0, 2]).format('DDDo'), '۲م', '2');
51 assert.equal(moment([2011, 0, 3]).format('DDDo'), '۳م', '3');
52 assert.equal(moment([2011, 0, 4]).format('DDDo'), '۴م', '4');
53 assert.equal(moment([2011, 0, 5]).format('DDDo'), '۵م', '5');
54 assert.equal(moment([2011, 0, 6]).format('DDDo'), '۶م', '6');
55 assert.equal(moment([2011, 0, 7]).format('DDDo'), '۷م', '7');
56 assert.equal(moment([2011, 0, 8]).format('DDDo'), '۸م', '8');
57 assert.equal(moment([2011, 0, 9]).format('DDDo'), '۹م', '9');
58 assert.equal(moment([2011, 0, 10]).format('DDDo'), '۱۰م', '10');
59
60 assert.equal(moment([2011, 0, 11]).format('DDDo'), '۱۱م', '11');
61 assert.equal(moment([2011, 0, 12]).format('DDDo'), '۱۲م', '12');
62 assert.equal(moment([2011, 0, 13]).format('DDDo'), '۱۳م', '13');
63 assert.equal(moment([2011, 0, 14]).format('DDDo'), '۱۴م', '14');
64 assert.equal(moment([2011, 0, 15]).format('DDDo'), '۱۵م', '15');
65 assert.equal(moment([2011, 0, 16]).format('DDDo'), '۱۶م', '16');
66 assert.equal(moment([2011, 0, 17]).format('DDDo'), '۱۷م', '17');
67 assert.equal(moment([2011, 0, 18]).format('DDDo'), '۱۸م', '18');
68 assert.equal(moment([2011, 0, 19]).format('DDDo'), '۱۹م', '19');
69 assert.equal(moment([2011, 0, 20]).format('DDDo'), '۲۰م', '20');
70
71 assert.equal(moment([2011, 0, 21]).format('DDDo'), '۲۱م', '21');
72 assert.equal(moment([2011, 0, 22]).format('DDDo'), '۲۲م', '22');
73 assert.equal(moment([2011, 0, 23]).format('DDDo'), '۲۳م', '23');
74 assert.equal(moment([2011, 0, 24]).format('DDDo'), '۲۴م', '24');
75 assert.equal(moment([2011, 0, 25]).format('DDDo'), '۲۵م', '25');
76 assert.equal(moment([2011, 0, 26]).format('DDDo'), '۲۶م', '26');
77 assert.equal(moment([2011, 0, 27]).format('DDDo'), '۲۷م', '27');
78 assert.equal(moment([2011, 0, 28]).format('DDDo'), '۲۸م', '28');
79 assert.equal(moment([2011, 0, 29]).format('DDDo'), '۲۹م', '29');
80 assert.equal(moment([2011, 0, 30]).format('DDDo'), '۳۰م', '30');
81
82 assert.equal(moment([2011, 0, 31]).format('DDDo'), '۳۱م', '31');
83 });
84
85 test('format month', function (assert) {
86 var expected = 'ژانویه ژانویه_فوریه فوریه_مارس مارس_آوریل آوریل_مه مه_ژوئن ژوئن_ژوئیه ژوئیه_اوت اوت_سپتامبر سپتامبر_اکتبر اکتبر_نوامبر نوامبر_دسامبر دسامبر'.split('_'), i;
87 for (i = 0; i < expected.length; i++) {
88 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
89 }
90 });
91
92 test('format week', function (assert) {
93 var expected = 'یک\u200cشنبه یک\u200cشنبه ی_دوشنبه دوشنبه د_سه\u200cشنبه سه\u200cشنبه س_چهارشنبه چهارشنبه چ_پنج\u200cشنبه پنج\u200cشنبه پ_جمعه جمعه ج_شنبه شنبه ش'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
96 }
97 });
98
99 test('from', function (assert) {
100 var start = moment([2007, 1, 28]);
101 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'چندین ثانیه', '44 seconds = a few seconds');
102 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'یک دقیقه', '45 seconds = a minute');
103 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'یک دقیقه', '89 seconds = a minute');
104 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '۲ دقیقه', '90 seconds = 2 minutes');
105 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '۴۴ دقیقه', '44 minutes = 44 minutes');
106 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'یک ساعت', '45 minutes = an hour');
107 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'یک ساعت', '89 minutes = an hour');
108 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '۲ ساعت', '90 minutes = 2 hours');
109 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '۵ ساعت', '5 hours = 5 hours');
110 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '۲۱ ساعت', '21 hours = 21 hours');
111 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'یک روز', '22 hours = a day');
112 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'یک روز', '35 hours = a day');
113 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '۲ روز', '36 hours = 2 days');
114 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'یک روز', '1 day = a day');
115 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '۵ روز', '5 days = 5 days');
116 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '۲۵ روز', '25 days = 25 days');
117 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'یک ماه', '26 days = a month');
118 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'یک ماه', '30 days = a month');
119 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'یک ماه', '43 days = a month');
120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '۲ ماه', '46 days = 2 months');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '۲ ماه', '75 days = 2 months');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '۳ ماه', '76 days = 3 months');
123 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'یک ماه', '1 month = a month');
124 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '۵ ماه', '5 months = 5 months');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'یک سال', '345 days = a year');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '۲ سال', '548 days = 2 years');
127 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'یک سال', '1 year = a year');
128 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '۵ سال', '5 years = 5 years');
129 });
130
131 test('suffix', function (assert) {
132 assert.equal(moment(30000).from(0), 'در چندین ثانیه', 'prefix');
133 assert.equal(moment(0).from(30000), 'چندین ثانیه پیش', 'suffix');
134 });
135
136 test('now from now', function (assert) {
137 assert.equal(moment().fromNow(), 'چندین ثانیه پیش', 'now from now should display as in the past');
138 });
139
140 test('fromNow', function (assert) {
141 assert.equal(moment().add({s: 30}).fromNow(), 'در چندین ثانیه', 'in a few seconds');
142 assert.equal(moment().add({d: 5}).fromNow(), 'در ۵ روز', 'in 5 days');
143 });
144
145 test('calendar day', function (assert) {
146 var a = moment().hours(2).minutes(0).seconds(0);
147
148 assert.equal(moment(a).calendar(), 'امروز ساعت ۰۲:۰۰', 'today at the same time');
149 assert.equal(moment(a).add({m: 25}).calendar(), 'امروز ساعت ۰۲:۲۵', 'Now plus 25 min');
150 assert.equal(moment(a).add({h: 1}).calendar(), 'امروز ساعت ۰۳:۰۰', 'Now plus 1 hour');
151 assert.equal(moment(a).add({d: 1}).calendar(), 'فردا ساعت ۰۲:۰۰', 'tomorrow at the same time');
152 assert.equal(moment(a).subtract({h: 1}).calendar(), 'امروز ساعت ۰۱:۰۰', 'Now minus 1 hour');
153 assert.equal(moment(a).subtract({d: 1}).calendar(), 'دیروز ساعت ۰۲:۰۰', 'yesterday at the same time');
154 });
155
156 test('calendar next week', function (assert) {
157 var i, m;
158 for (i = 2; i < 7; i++) {
159 m = moment().add({d: i});
160 assert.equal(m.calendar(), m.format('dddd [ساعت] LT'), 'Today + ' + i + ' days current time');
161 m.hours(0).minutes(0).seconds(0).milliseconds(0);
162 assert.equal(m.calendar(), m.format('dddd [ساعت] LT'), 'Today + ' + i + ' days beginning of day');
163 m.hours(23).minutes(59).seconds(59).milliseconds(999);
164 assert.equal(m.calendar(), m.format('dddd [ساعت] LT'), 'Today + ' + i + ' days end of day');
165 }
166 });
167
168 test('calendar last week', function (assert) {
169 var i, m;
170 for (i = 2; i < 7; i++) {
171 m = moment().subtract({d: i});
172 assert.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), 'Today - ' + i + ' days current time');
173 m.hours(0).minutes(0).seconds(0).milliseconds(0);
174 assert.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), 'Today - ' + i + ' days beginning of day');
175 m.hours(23).minutes(59).seconds(59).milliseconds(999);
176 assert.equal(m.calendar(), m.format('dddd [پیش ساعت] LT'), 'Today - ' + i + ' days end of day');
177 }
178 });
179
180 test('calendar all else', function (assert) {
181 var weeksAgo = moment().subtract({w: 1}),
182 weeksFromNow = moment().add({w: 1});
183
184 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
185 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
186
187 weeksAgo = moment().subtract({w: 2});
188 weeksFromNow = moment().add({w: 2});
189
190 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
191 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
192 });
193
194 test('weeks year starting sunday', function (assert) {
195 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
196 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
197 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
198 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
199 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
200 });
201
202 test('weeks year starting monday', function (assert) {
203 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
204 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
205 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
206 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
207 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
208 });
209
210 test('weeks year starting tuesday', function (assert) {
211 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
212 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
213 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
214 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
215 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
216 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
217 });
218
219 test('weeks year starting wednesday', function (assert) {
220 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
221 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
222 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
223 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
224 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
225 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
226 });
227
228 test('weeks year starting thursday', function (assert) {
229 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
230 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
231 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
232 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
233 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
234 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
235 });
236
237 test('weeks year starting friday', function (assert) {
238 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
239 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
240 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
241 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
242 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
243 });
244
245 test('weeks year starting saturday', function (assert) {
246 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
247 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
248 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
249 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
250 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
251 });
252
253 test('weeks year starting sunday formatted', function (assert) {
254 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '۱ ۰۱ ۱م', 'Dec 31 2011 should be week 1');
255 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '۱ ۰۱ ۱م', 'Jan 6 2012 should be week 1');
256 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '۲ ۰۲ ۲م', 'Jan 7 2012 should be week 2');
257 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '۲ ۰۲ ۲م', 'Jan 13 2012 should be week 2');
258 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '۳ ۰۳ ۳م', 'Jan 14 2012 should be week 3');
259 });
260
261 test('lenient ordinal parsing', function (assert) {
262 var i, ordinalStr, testMoment;
263 for (i = 1; i <= 31; ++i) {
264 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
265 testMoment = moment(ordinalStr, 'YYYY MM Do');
266 assert.equal(testMoment.year(), 2014,
267 'lenient ordinal parsing ' + i + ' year check');
268 assert.equal(testMoment.month(), 0,
269 'lenient ordinal parsing ' + i + ' month check');
270 assert.equal(testMoment.date(), i,
271 'lenient ordinal parsing ' + i + ' date check');
272 }
273 });
274
275 test('lenient ordinal parsing of number', function (assert) {
276 var i, testMoment;
277 for (i = 1; i <= 31; ++i) {
278 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
279 assert.equal(testMoment.year(), 2014,
280 'lenient ordinal parsing of number ' + i + ' year check');
281 assert.equal(testMoment.month(), 0,
282 'lenient ordinal parsing of number ' + i + ' month check');
283 assert.equal(testMoment.date(), i,
284 'lenient ordinal parsing of number ' + i + ' date check');
285 }
286 });
287
288 test('strict ordinal parsing', function (assert) {
289 var i, ordinalStr, testMoment;
290 for (i = 1; i <= 31; ++i) {
291 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
292 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
293 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
294 }
295 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('fi');
3
4 test('parse', function (assert) {
5 var tests = 'tammikuu tammi_helmikuu helmi_maaliskuu maalis_huhtikuu huhti_toukokuu touko_kesäkuu kesä_heinäkuu heinä_elokuu elo_syyskuu syys_lokakuu loka_marraskuu marras_joulukuu joulu'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'sunnuntai, helmikuu 14. 2010, 3:25:50 pm'],
25 ['ddd, hA', 'su, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 helmikuu helmi'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. sunnuntai su su'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[vuoden] DDDo [päivä]', 'vuoden 45. päivä'],
38 ['LTS', '15.25.50'],
39 ['L', '14.02.2010'],
40 ['LL', '14. helmikuuta 2010'],
41 ['LLL', '14. helmikuuta 2010, klo 15.25'],
42 ['LLLL', 'sunnuntai, 14. helmikuuta 2010, klo 15.25'],
43 ['l', '14.2.2010'],
44 ['ll', '14. helmi 2010'],
45 ['lll', '14. helmi 2010, klo 15.25'],
46 ['llll', 'su, 14. helmi 2010, klo 15.25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1st');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2nd');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3rd');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4th');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5th');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6th');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7th');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8th');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9th');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10th');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11th');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12th');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13th');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14th');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15th');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16th');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17th');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18th');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19th');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20th');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21st');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22nd');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23rd');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24th');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25th');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26th');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27th');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28th');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29th');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30th');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31st');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'tammikuu tammi_helmikuu helmi_maaliskuu maalis_huhtikuu huhti_toukokuu touko_kesäkuu kesä_heinäkuu heinä_elokuu elo_syyskuu syys_lokakuu loka_marraskuu marras_joulukuu joulu'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'sunnuntai su su_maanantai ma ma_tiistai ti ti_keskiviikko ke ke_torstai to to_perjantai pe pe_lauantai la la'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'muutama sekunti', '44 seconds = few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuutti', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuutti', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'kaksi minuuttia', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuuttia', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'tunti', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'tunti', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'kaksi tuntia', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'viisi tuntia', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tuntia', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'päivä', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'päivä', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'kaksi päivää', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'päivä', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'viisi päivää', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 päivää', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'kuukausi', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'kuukausi', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'kuukausi', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'kaksi kuukautta', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'kaksi kuukautta', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'kolme kuukautta', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'kuukausi', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'viisi kuukautta', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'vuosi', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'kaksi vuotta', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'vuosi', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'viisi vuotta', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'muutaman sekunnin päästä', 'prefix');
140 assert.equal(moment(0).from(30000), 'muutama sekunti sitten', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'muutama sekunti sitten', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'muutaman sekunnin päästä', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'viiden päivän päästä', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'tänään klo 02.00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'tänään klo 02.25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'tänään klo 03.00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'huomenna klo 02.00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'tänään klo 01.00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'eilen klo 02.00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [klo] LT'), 'today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [klo] LT'), 'today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [klo] LT'), 'today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), 'today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), 'today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[viime] dddd[na] [klo] LT'), 'today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'yksi viikko sitten');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'yhden viikon päästä');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'kaksi viikkoa sitten');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'kaden viikon päästä');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
204 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
206 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
212 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
213 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
214 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
215 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
222 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
223 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
224 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
231 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
232 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
233 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
240 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
241 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
242 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
247 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
248 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
249 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
250 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
251 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
252 });
253
254 test('weeks year starting saturday', function (assert) {
255 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
256 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
257 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
258 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
259 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
260 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
261 });
262
263 test('weeks year starting sunday formatted', function (assert) {
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
268 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
269 });
270
271 test('lenient ordinal parsing', function (assert) {
272 var i, ordinalStr, testMoment;
273 for (i = 1; i <= 31; ++i) {
274 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
275 testMoment = moment(ordinalStr, 'YYYY MM Do');
276 assert.equal(testMoment.year(), 2014,
277 'lenient ordinal parsing ' + i + ' year check');
278 assert.equal(testMoment.month(), 0,
279 'lenient ordinal parsing ' + i + ' month check');
280 assert.equal(testMoment.date(), i,
281 'lenient ordinal parsing ' + i + ' date check');
282 }
283 });
284
285 test('lenient ordinal parsing of number', function (assert) {
286 var i, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
289 assert.equal(testMoment.year(), 2014,
290 'lenient ordinal parsing of number ' + i + ' year check');
291 assert.equal(testMoment.month(), 0,
292 'lenient ordinal parsing of number ' + i + ' month check');
293 assert.equal(testMoment.date(), i,
294 'lenient ordinal parsing of number ' + i + ' date check');
295 }
296 });
297
298 test('strict ordinal parsing', function (assert) {
299 var i, ordinalStr, testMoment;
300 for (i = 1; i <= 31; ++i) {
301 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
302 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
303 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
304 }
305 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('fo');
3
4 test('parse', function (assert) {
5 var tests = 'januar jan_februar feb_mars mar_apríl apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd [tann] Do MMMM YYYY, h:mm:ss a', 'sunnudagur tann 14. februar 2010, 3:25:50 pm'],
25 ['ddd hA', 'sun 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. sunnudagur sun su'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[tann] DDDo [dagin á árinum]', 'tann 45. dagin á árinum'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 februar 2010'],
41 ['LLL', '14 februar 2010 15:25'],
42 ['LLLL', 'sunnudagur 14. februar, 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 feb 2010'],
45 ['lll', '14 feb 2010 15:25'],
46 ['llll', 'sun 14. feb, 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'januar jan_februar feb_mars mar_apríl apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'sunnudagur sun su_mánadagur mán má_týsdagur týs tý_mikudagur mik mi_hósdagur hós hó_fríggjadagur frí fr_leygardagur ley le'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'fá sekund', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ein minutt', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ein minutt', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuttir', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuttir', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ein tími', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ein tími', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 tímar', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 tímar', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tímar', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein dagur', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein dagur', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein dagur', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein mánaði', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein mánaði', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ein mánaði', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mánaðir', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mánaðir', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mánaðir', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein mánaði', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mánaðir', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'eitt ár', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ár', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eitt ár', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ár', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'um fá sekund', 'prefix');
140 assert.equal(moment(0).from(30000), 'fá sekund síðani', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'fá sekund síðani', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'um fá sekund', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'um 5 dagar', 'in 5 days');
150 });
151
152 test('weeks year starting sunday', function (assert) {
153 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
154 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
155 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
156 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
157 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
158 });
159
160 test('weeks year starting monday', function (assert) {
161 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
162 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
163 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
164 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
165 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
166 });
167
168 test('weeks year starting tuesday', function (assert) {
169 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
170 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
171 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
172 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
173 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
174 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
175 });
176
177 test('weeks year starting wednesday', function (assert) {
178 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
179 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
180 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
181 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
182 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
183 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
184 });
185
186 test('weeks year starting thursday', function (assert) {
187 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
188 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
189 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
190 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
191 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
192 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
193 });
194
195 test('weeks year starting friday', function (assert) {
196 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
197 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
198 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
199 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
200 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
201 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
202 });
203
204 test('weeks year starting saturday', function (assert) {
205 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
206 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
207 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
208 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
209 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
210 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
211 });
212
213 test('weeks year starting sunday formatted', function (assert) {
214 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
215 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
216 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
217 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
218 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
219 });
220
221 test('lenient ordinal parsing', function (assert) {
222 var i, ordinalStr, testMoment;
223 for (i = 1; i <= 31; ++i) {
224 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
225 testMoment = moment(ordinalStr, 'YYYY MM Do');
226 assert.equal(testMoment.year(), 2014,
227 'lenient ordinal parsing ' + i + ' year check');
228 assert.equal(testMoment.month(), 0,
229 'lenient ordinal parsing ' + i + ' month check');
230 assert.equal(testMoment.date(), i,
231 'lenient ordinal parsing ' + i + ' date check');
232 }
233 });
234
235 test('lenient ordinal parsing of number', function (assert) {
236 var i, testMoment;
237 for (i = 1; i <= 31; ++i) {
238 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
239 assert.equal(testMoment.year(), 2014,
240 'lenient ordinal parsing of number ' + i + ' year check');
241 assert.equal(testMoment.month(), 0,
242 'lenient ordinal parsing of number ' + i + ' month check');
243 assert.equal(testMoment.date(), i,
244 'lenient ordinal parsing of number ' + i + ' date check');
245 }
246 });
247
248 test('strict ordinal parsing', function (assert) {
249 var i, ordinalStr, testMoment;
250 for (i = 1; i <= 31; ++i) {
251 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
252 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
253 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
254 }
255 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('fr-ca');
3
4 test('parse', function (assert) {
5 var i,
6 tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14e 2010, 3:25:50 pm'],
28 ['ddd, hA', 'dim., 3PM'],
29 ['M Mo MM MMMM MMM', '2 2e 02 février févr.'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 14e 14'],
32 ['d do dddd ddd dd', '0 0e dimanche dim. Di'],
33 ['DDD DDDo DDDD', '45 45e 045'],
34 ['w wo ww', '8 8e 08'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'pm PM'],
40 ['[the] DDDo [day of the year]', 'the 45e day of the year'],
41 ['LTS', '15:25:50'],
42 ['L', '2010-02-14'],
43 ['LL', '14 février 2010'],
44 ['LLL', '14 février 2010 15:25'],
45 ['LLLL', 'dimanche 14 février 2010 15:25'],
46 ['l', '2010-2-14'],
47 ['ll', '14 févr. 2010'],
48 ['lll', '14 févr. 2010 15:25'],
49 ['llll', 'dim. 14 févr. 2010 15:25']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format ordinal', function (assert) {
60 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
61 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2e', '2e');
62 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3e', '3e');
63 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4e', '4e');
64 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5e', '5e');
65 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6e', '6e');
66 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7e', '7e');
67 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8e', '8e');
68 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9e', '9e');
69 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10e', '10e');
70
71 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11e', '11e');
72 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12e', '12e');
73 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13e', '13e');
74 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14e', '14e');
75 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15e', '15e');
76 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16e', '16e');
77 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17e', '17e');
78 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18e', '18e');
79 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19e', '19e');
80 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20e', '20e');
81
82 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21e', '21e');
83 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22e', '22e');
84 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23e', '23e');
85 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24e', '24e');
86 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25e', '25e');
87 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26e', '26e');
88 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27e', '27e');
89 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28e', '28e');
90 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29e', '29e');
91 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30e', '30e');
92
93 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31e', '31e');
94 });
95
96 test('format month', function (assert) {
97 var i,
98 expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_');
99
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
102 }
103 });
104
105 test('format week', function (assert) {
106 var i,
107 expected = 'dimanche dim. Di_lundi lun. Lu_mardi mar. Ma_mercredi mer. Me_jeudi jeu. Je_vendredi ven. Ve_samedi sam. Sa'.split('_');
108
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
111 }
112 });
113
114 test('from', function (assert) {
115 var start = moment([2007, 1, 28]);
116
117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'quelques secondes', '44 seconds = a few seconds');
118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'une minute', '45 seconds = a minute');
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'une minute', '89 seconds = a minute');
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'une heure', '45 minutes = an hour');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'une heure', '89 minutes = an hour');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 heures', '90 minutes = 2 hours');
125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 heures', '5 hours = 5 hours');
126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 heures', '21 hours = 21 hours');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un jour', '22 hours = a day');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un jour', '35 hours = a day');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 jours', '36 hours = 2 days');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un jour', '1 day = a day');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 jours', '5 days = 5 days');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 jours', '25 days = 25 days');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mois', '26 days = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mois', '30 days = a month');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mois', '43 days = a month');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mois', '46 days = 2 months');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mois', '75 days = 2 months');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mois', '76 days = 3 months');
139 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mois', '1 month = a month');
140 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mois', '5 months = 5 months');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un an', '345 days = a year');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ans', '548 days = 2 years');
143 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un an', '1 year = a year');
144 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ans', '5 years = 5 years');
145 });
146
147 test('suffix', function (assert) {
148 assert.equal(moment(30000).from(0), 'dans quelques secondes', 'prefix');
149 assert.equal(moment(0).from(30000), 'il y a quelques secondes', 'suffix');
150 });
151
152 test('fromNow', function (assert) {
153 assert.equal(moment().add({s: 30}).fromNow(), 'dans quelques secondes', 'in a few seconds');
154 assert.equal(moment().add({d: 5}).fromNow(), 'dans 5 jours', 'in 5 days');
155 });
156
157 test('same day', function (assert) {
158 var a = moment().hours(2).minutes(0).seconds(0);
159
160 assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
161 assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
162 assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
163 assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
164 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
165 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
166 });
167
168 test('same next week', function (assert) {
169 var i, m;
170
171 for (i = 2; i < 7; i++) {
172 m = moment().add({d: i});
173 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time');
174 m.hours(0).minutes(0).seconds(0).milliseconds(0);
175 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day');
176 m.hours(23).minutes(59).seconds(59).milliseconds(999);
177 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day');
178 }
179 });
180
181 test('same last week', function (assert) {
182 var i, m;
183
184 for (i = 2; i < 7; i++) {
185 m = moment().subtract({d: i});
186 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days current time');
187 m.hours(0).minutes(0).seconds(0).milliseconds(0);
188 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days beginning of day');
189 m.hours(23).minutes(59).seconds(59).milliseconds(999);
190 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days end of day');
191 }
192 });
193
194 test('same all else', function (assert) {
195 var weeksAgo = moment().subtract({w: 1}),
196 weeksFromNow = moment().add({w: 1});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
200
201 weeksAgo = moment().subtract({w: 2});
202 weeksFromNow = moment().add({w: 2});
203
204 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
205 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
206 });
207
208 test('weeks year starting sunday', function (assert) {
209 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
210 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
211 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
212 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
213 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
214 });
215
216 test('weeks year starting monday', function (assert) {
217 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
218 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
219 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
220 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
221 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
222 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
223 });
224
225 test('weeks year starting tuesday', function (assert) {
226 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
227 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
228 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
229 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
230 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
231 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
232 });
233
234 test('weeks year starting wednesday', function (assert) {
235 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
236 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
237 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
238 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
239 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
240 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
241 });
242
243 test('weeks year starting thursday', function (assert) {
244 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
245 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
246 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
247 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
248 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
249 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
250 });
251
252 test('weeks year starting friday', function (assert) {
253 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
254 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
255 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
256 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
257 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
258 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
259 });
260
261 test('weeks year starting saturday', function (assert) {
262 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
263 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
264 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
265 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
266 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
267 });
268
269 test('weeks year starting sunday format', function (assert) {
270 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1er', 'Jan 1 2012 should be week 1');
271 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1er', 'Jan 7 2012 should be week 1');
272 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2e', 'Jan 8 2012 should be week 2');
273 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2e', 'Jan 14 2012 should be week 2');
274 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3e', 'Jan 15 2012 should be week 3');
275 });
276
277 test('lenient ordinal parsing', function (assert) {
278 var i, ordinalStr, testMoment;
279 for (i = 1; i <= 31; ++i) {
280 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
281 testMoment = moment(ordinalStr, 'YYYY MM Do');
282 assert.equal(testMoment.year(), 2014,
283 'lenient ordinal parsing ' + i + ' year check');
284 assert.equal(testMoment.month(), 0,
285 'lenient ordinal parsing ' + i + ' month check');
286 assert.equal(testMoment.date(), i,
287 'lenient ordinal parsing ' + i + ' date check');
288 }
289 });
290
291 test('lenient ordinal parsing of number', function (assert) {
292 var i, testMoment;
293 for (i = 1; i <= 31; ++i) {
294 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
295 assert.equal(testMoment.year(), 2014,
296 'lenient ordinal parsing of number ' + i + ' year check');
297 assert.equal(testMoment.month(), 0,
298 'lenient ordinal parsing of number ' + i + ' month check');
299 assert.equal(testMoment.date(), i,
300 'lenient ordinal parsing of number ' + i + ' date check');
301 }
302 });
303
304 test('strict ordinal parsing', function (assert) {
305 var i, ordinalStr, testMoment;
306 for (i = 1; i <= 31; ++i) {
307 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
308 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
309 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
310 }
311 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('fr');
3
4 test('parse', function (assert) {
5 var tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14 2010, 3:25:50 pm'],
26 ['ddd, hA', 'dim., 3PM'],
27 ['M Mo MM MMMM MMM', '2 2 02 février févr.'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14 14'],
30 ['d do dddd ddd dd', '0 0 dimanche dim. Di'],
31 ['DDD DDDo DDDD', '45 45 045'],
32 ['w wo ww', '6 6 06'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
39 ['LTS', '15:25:50'],
40 ['L', '14/02/2010'],
41 ['LL', '14 février 2010'],
42 ['LLL', '14 février 2010 15:25'],
43 ['LLLL', 'dimanche 14 février 2010 15:25'],
44 ['l', '14/2/2010'],
45 ['ll', '14 févr. 2010'],
46 ['lll', '14 févr. 2010 15:25'],
47 ['llll', 'dim. 14 févr. 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'dimanche dim. Di_lundi lun. Lu_mardi mar. Ma_mercredi mer. Me_jeudi jeu. Je_vendredi ven. Ve_samedi sam. Sa'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'quelques secondes', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'une minute', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'une minute', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutes', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutes', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'une heure', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'une heure', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 heures', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 heures', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 heures', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un jour', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un jour', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 jours', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un jour', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 jours', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 jours', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mois', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mois', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mois', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mois', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mois', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mois', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mois', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mois', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un an', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ans', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un an', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ans', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'dans quelques secondes', 'prefix');
141 assert.equal(moment(0).from(30000), 'il y a quelques secondes', 'suffix');
142 });
143
144 test('fromNow', function (assert) {
145 assert.equal(moment().add({s: 30}).fromNow(), 'dans quelques secondes', 'in a few seconds');
146 assert.equal(moment().add({d: 5}).fromNow(), 'dans 5 jours', 'in 5 days');
147 });
148
149 test('same day', function (assert) {
150 var a = moment().hours(2).minutes(0).seconds(0);
151
152 assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
153 assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
154 assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
155 assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
156 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
157 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
158 });
159
160 test('same next week', function (assert) {
161 var i, m;
162
163 for (i = 2; i < 7; i++) {
164 m = moment().add({d: i});
165 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time');
166 m.hours(0).minutes(0).seconds(0).milliseconds(0);
167 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day');
168 m.hours(23).minutes(59).seconds(59).milliseconds(999);
169 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day');
170 }
171 });
172
173 test('same last week', function (assert) {
174 var i, m;
175
176 for (i = 2; i < 7; i++) {
177 m = moment().subtract({d: i});
178 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days current time');
179 m.hours(0).minutes(0).seconds(0).milliseconds(0);
180 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days beginning of day');
181 m.hours(23).minutes(59).seconds(59).milliseconds(999);
182 assert.equal(m.calendar(), m.format('dddd [dernier à] LT'), 'Today - ' + i + ' days end of day');
183 }
184 });
185
186 test('same all else', function (assert) {
187 var weeksAgo = moment().subtract({w: 1}),
188 weeksFromNow = moment().add({w: 1});
189
190 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
191 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
192
193 weeksAgo = moment().subtract({w: 2});
194 weeksFromNow = moment().add({w: 2});
195
196 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
197 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
198 });
199
200 test('weeks year starting sunday', function (assert) {
201 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
202 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
203 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
204 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
205 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
206 });
207
208 test('weeks year starting monday', function (assert) {
209 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
210 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
211 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
212 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
213 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
214 });
215
216 test('weeks year starting tuesday', function (assert) {
217 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
218 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
219 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
220 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
221 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
222 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
223 });
224
225 test('weeks year starting wednesday', function (assert) {
226 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
227 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
228 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
229 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
230 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
231 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
232 });
233
234 test('weeks year starting thursday', function (assert) {
235 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
236 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
237 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
238 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
239 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
240 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
241 });
242
243 test('weeks year starting friday', function (assert) {
244 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
245 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
246 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
247 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
248 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
249 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
250 });
251
252 test('weeks year starting saturday', function (assert) {
253 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
254 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
255 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
256 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
257 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
258 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
259 });
260
261 test('weeks year starting sunday formatted', function (assert) {
262 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
263 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1er', 'Jan 2 2012 should be week 1');
264 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1er', 'Jan 8 2012 should be week 1');
265 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
266 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
267 });
268
269 test('lenient ordinal parsing', function (assert) {
270 var i, ordinalStr, testMoment;
271 for (i = 1; i <= 31; ++i) {
272 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
273 testMoment = moment(ordinalStr, 'YYYY MM Do');
274 assert.equal(testMoment.year(), 2014,
275 'lenient ordinal parsing ' + i + ' year check');
276 assert.equal(testMoment.month(), 0,
277 'lenient ordinal parsing ' + i + ' month check');
278 assert.equal(testMoment.date(), i,
279 'lenient ordinal parsing ' + i + ' date check');
280 }
281 });
282
283 test('lenient ordinal parsing of number', function (assert) {
284 var i, testMoment;
285 for (i = 1; i <= 31; ++i) {
286 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
287 assert.equal(testMoment.year(), 2014,
288 'lenient ordinal parsing of number ' + i + ' year check');
289 assert.equal(testMoment.month(), 0,
290 'lenient ordinal parsing of number ' + i + ' month check');
291 assert.equal(testMoment.date(), i,
292 'lenient ordinal parsing of number ' + i + ' date check');
293 }
294 });
295
296 test('strict ordinal parsing', function (assert) {
297 var i, ordinalStr, testMoment;
298 for (i = 1; i <= 31; ++i) {
299 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
300 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
301 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
302 }
303 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('fy');
3
4 test('parse', function (assert) {
5 var tests = 'jannewaris jan._febrewaris feb._maart mrt._april apr._maaie mai._juny jun._july jul._augustus aug._septimber sep._oktober okt._novimber nov._desimber des.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, HH:mm:ss', 'snein, febrewaris 14de 2010, 15:25:50'],
25 ['ddd, HH', 'si., 15'],
26 ['M Mo MM MMMM MMM', '2 2de 02 febrewaris feb.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14de 14'],
29 ['d do dddd ddd dd', '0 0de snein si. Si'],
30 ['DDD DDDo DDDD', '45 45ste 045'],
31 ['w wo ww', '6 6de 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45ste day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14-02-2010'],
40 ['LL', '14 febrewaris 2010'],
41 ['LLL', '14 febrewaris 2010 15:25'],
42 ['LLLL', 'snein 14 febrewaris 2010 15:25'],
43 ['l', '14-2-2010'],
44 ['ll', '14 feb. 2010'],
45 ['lll', '14 feb. 2010 15:25'],
46 ['llll', 'si. 14 feb. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4de', '4de');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5de', '5de');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6de', '6de');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7de', '7de');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14de', '14de');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15de', '15de');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16de', '16de');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17de', '17de');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ste', '24ste');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ste', '25ste');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ste', '26ste');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ste', '27ste');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'jannewaris jan._febrewaris feb._maart mrt._april apr._maaie mai_juny jun._july jul._augustus aug._septimber sep._oktober okt._novimber nov._desimber des.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'snein si. Si_moandei mo. Mo_tiisdei ti. Ti_woansdei wo. Wo_tongersdei to. To_freed fr. Fr_sneon so. So'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'in pear sekonden', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ien minút', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ien minút', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuten', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuten', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ien oere', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ien oere', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 oeren', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 oeren', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 oeren', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ien dei', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ien dei', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagen', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ien dei', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagen', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagen', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ien moanne', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ien moanne', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ien moanne', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 moannen', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 moannen', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 moannen', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ien moanne', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 moannen', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ien jier', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jierren', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ien jier', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jierren', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'oer in pear sekonden', 'prefix');
140 assert.equal(moment(0).from(30000), 'in pear sekonden lyn', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'in pear sekonden lyn', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'oer in pear sekonden', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'oer 5 dagen', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'hjoed om 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'hjoed om 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'hjoed om 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'moarn om 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'hjoed om 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'juster om 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[ôfrûne] dddd [om] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[ôfrûne] dddd [om] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[ôfrûne] dddd [om] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('month abbreviation', function (assert) {
202 assert.equal(moment([2012, 5, 23]).format('D-MMM-YYYY'), '23-jun-2012', 'format month abbreviation surrounded by dashes should not include a dot');
203 assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
204 });
205
206 test('weeks year starting sunday', function (assert) {
207 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
208 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
209 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
210 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
211 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
212 });
213
214 test('weeks year starting monday', function (assert) {
215 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
216 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
217 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
218 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
219 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
220 });
221
222 test('weeks year starting tuesday', function (assert) {
223 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
224 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
225 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
226 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
227 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
228 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
229 });
230
231 test('weeks year starting wednesday', function (assert) {
232 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
233 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
234 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
235 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
236 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
237 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
238 });
239
240 test('weeks year starting thursday', function (assert) {
241 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
242 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
243 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
244 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
245 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
246 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
247 });
248
249 test('weeks year starting friday', function (assert) {
250 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
251 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
252 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
253 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
254 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
255 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
256 });
257
258 test('weeks year starting saturday', function (assert) {
259 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
260 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
261 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
262 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
263 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
264 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
265 });
266
267 test('weeks year starting sunday formatted', function (assert) {
268 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
269 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
270 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1ste', 'Jan 8 2012 should be week 1');
271 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2');
272 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
273 });
274
275 test('lenient ordinal parsing', function (assert) {
276 var i, ordinalStr, testMoment;
277 for (i = 1; i <= 31; ++i) {
278 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
279 testMoment = moment(ordinalStr, 'YYYY MM Do');
280 assert.equal(testMoment.year(), 2014,
281 'lenient ordinal parsing ' + i + ' year check');
282 assert.equal(testMoment.month(), 0,
283 'lenient ordinal parsing ' + i + ' month check');
284 assert.equal(testMoment.date(), i,
285 'lenient ordinal parsing ' + i + ' date check');
286 }
287 });
288
289 test('lenient ordinal parsing of number', function (assert) {
290 var i, testMoment;
291 for (i = 1; i <= 31; ++i) {
292 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
293 assert.equal(testMoment.year(), 2014,
294 'lenient ordinal parsing of number ' + i + ' year check');
295 assert.equal(testMoment.month(), 0,
296 'lenient ordinal parsing of number ' + i + ' month check');
297 assert.equal(testMoment.date(), i,
298 'lenient ordinal parsing of number ' + i + ' date check');
299 }
300 });
301
302 test('strict ordinal parsing', function (assert) {
303 var i, ordinalStr, testMoment;
304 for (i = 1; i <= 31; ++i) {
305 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
306 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
307 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
308 }
309 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('gl');
3
4 test('parse', function (assert) {
5 var tests = 'Xaneiro Xan._Febreiro Feb._Marzo Mar._Abril Abr._Maio Mai._Xuño Xuñ._Xullo Xul._Agosto Ago._Setembro Set._Outubro Out._Novembro Nov._Decembro Dec.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Febreiro 14º 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Dom., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2º 02 Febreiro Feb.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14º 14'],
29 ['d do dddd ddd dd', '0 0º Domingo Dom. Do'],
30 ['DDD DDDo DDDD', '45 45º 045'],
31 ['w wo ww', '7 7º 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 Febreiro 2010'],
41 ['LLL', '14 Febreiro 2010 15:25'],
42 ['LLLL', 'Domingo 14 Febreiro 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 Feb. 2010'],
45 ['lll', '14 Feb. 2010 15:25'],
46 ['llll', 'Dom. 14 Feb. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'Xaneiro Xan._Febreiro Feb._Marzo Mar._Abril Abr._Maio Mai._Xuño Xuñ._Xullo Xul._Agosto Ago._Setembro Set._Outubro Out._Novembro Nov._Decembro Dec.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Domingo Dom. Do_Luns Lun. Lu_Martes Mar. Ma_Mércores Mér. Mé_Xoves Xov. Xo_Venres Ven. Ve_Sábado Sáb. Sá'.split('_'),
101 i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'uns segundos', '44 seconds = a few seconds');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minuto', '45 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minuto', '89 seconds = a minute');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'unha hora', '45 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'unha hora', '89 minutes = an hour');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un día', '22 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un día', '35 hours = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 días', '36 hours = 2 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un día', '1 day = a day');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 días', '5 days = 5 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 días', '25 days = 25 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mes', '26 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mes', '30 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mes', '43 days = a month');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mes', '1 month = a month');
133 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un ano', '345 days = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anos', '548 days = 2 years');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un ano', '1 year = a year');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anos', '5 years = 5 years');
138 });
139
140 test('suffix', function (assert) {
141 assert.equal(moment(30000).from(0), 'nuns segundos', 'prefix');
142 assert.equal(moment(0).from(30000), 'hai uns segundos', 'suffix');
143 });
144
145 test('now from now', function (assert) {
146 assert.equal(moment().fromNow(), 'hai uns segundos', 'now from now should display as in the past');
147 });
148
149 test('fromNow', function (assert) {
150 assert.equal(moment().add({s: 30}).fromNow(), 'nuns segundos', 'en unos segundos');
151 assert.equal(moment().add({d: 5}).fromNow(), 'en 5 días', 'en 5 días');
152 });
153
154 test('calendar day', function (assert) {
155 var a = moment().hours(2).minutes(0).seconds(0);
156
157 assert.equal(moment(a).calendar(), 'hoxe ás 2:00', 'today at the same time');
158 assert.equal(moment(a).add({m: 25}).calendar(), 'hoxe ás 2:25', 'Now plus 25 min');
159 assert.equal(moment(a).add({h: 1}).calendar(), 'hoxe ás 3:00', 'Now plus 1 hour');
160 assert.equal(moment(a).add({d: 1}).calendar(), 'mañá ás 2:00', 'tomorrow at the same time');
161 assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañá á 1:00', 'tomorrow minus 1 hour');
162 assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoxe á 1:00', 'Now minus 1 hour');
163 assert.equal(moment(a).subtract({d: 1}).calendar(), 'onte á 2:00', 'yesterday at the same time');
164 });
165
166 test('calendar next week', function (assert) {
167 var i, m;
168
169 for (i = 2; i < 7; i++) {
170 m = moment().add({d: i});
171 assert.equal(m.calendar(), m.format('dddd [' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today + ' + i + ' days current time');
172 m.hours(0).minutes(0).seconds(0).milliseconds(0);
173 assert.equal(m.calendar(), m.format('dddd [' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today + ' + i + ' days beginning of day');
174 m.hours(23).minutes(59).seconds(59).milliseconds(999);
175 assert.equal(m.calendar(), m.format('dddd [' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today + ' + i + ' days end of day');
176 }
177 });
178
179 test('calendar last week', function (assert) {
180 var i, m;
181 for (i = 2; i < 7; i++) {
182 m = moment().subtract({d: i});
183 assert.equal(m.calendar(), m.format('[o] dddd [pasado ' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today - ' + i + ' days current time');
184 m.hours(0).minutes(0).seconds(0).milliseconds(0);
185 assert.equal(m.calendar(), m.format('[o] dddd [pasado ' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today - ' + i + ' days beginning of day');
186 m.hours(23).minutes(59).seconds(59).milliseconds(999);
187 assert.equal(m.calendar(), m.format('[o] dddd [pasado ' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), 'Today - ' + i + ' days end of day');
188 }
189 });
190
191 test('calendar all else', function (assert) {
192 var weeksAgo = moment().subtract({w: 1}),
193 weeksFromNow = moment().add({w: 1});
194
195 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
196 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
197
198 weeksAgo = moment().subtract({w: 2});
199 weeksFromNow = moment().add({w: 2});
200
201 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
202 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
203 });
204
205 test('regression tests', function (assert) {
206 var lastWeek = moment().subtract({d: 4}).hours(1);
207 assert.equal(lastWeek.calendar(), lastWeek.format('[o] dddd [pasado a] LT'), '1 o\'clock bug');
208 });
209
210 test('weeks year starting sunday', function (assert) {
211 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
212 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
213 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
214 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
215 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
216 });
217
218 test('weeks year starting monday', function (assert) {
219 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
220 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
221 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
222 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
223 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
224 });
225
226 test('weeks year starting tuesday', function (assert) {
227 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
228 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
229 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
230 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
231 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
232 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
233 });
234
235 test('weeks year starting wednesday', function (assert) {
236 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
237 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
238 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
239 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
240 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
241 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
242 });
243
244 test('weeks year starting thursday', function (assert) {
245 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
246 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
247 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
248 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
249 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
250 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
251 });
252
253 test('weeks year starting friday', function (assert) {
254 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
255 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
256 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
257 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
258 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
259 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
260 });
261
262 test('weeks year starting saturday', function (assert) {
263 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
264 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
265 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
266 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
267 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
268 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
269 });
270
271 test('weeks year starting sunday formatted', function (assert) {
272 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1º', 'Dec 26 2011 should be week 1');
273 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
274 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2º', 'Jan 2 2012 should be week 2');
275 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2º', 'Jan 8 2012 should be week 2');
276 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3º', 'Jan 9 2012 should be week 3');
277 });
278
279 test('lenient ordinal parsing', function (assert) {
280 var i, ordinalStr, testMoment;
281 for (i = 1; i <= 31; ++i) {
282 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
283 testMoment = moment(ordinalStr, 'YYYY MM Do');
284 assert.equal(testMoment.year(), 2014,
285 'lenient ordinal parsing ' + i + ' year check');
286 assert.equal(testMoment.month(), 0,
287 'lenient ordinal parsing ' + i + ' month check');
288 assert.equal(testMoment.date(), i,
289 'lenient ordinal parsing ' + i + ' date check');
290 }
291 });
292
293 test('lenient ordinal parsing of number', function (assert) {
294 var i, testMoment;
295 for (i = 1; i <= 31; ++i) {
296 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
297 assert.equal(testMoment.year(), 2014,
298 'lenient ordinal parsing of number ' + i + ' year check');
299 assert.equal(testMoment.month(), 0,
300 'lenient ordinal parsing of number ' + i + ' month check');
301 assert.equal(testMoment.date(), i,
302 'lenient ordinal parsing of number ' + i + ' date check');
303 }
304 });
305
306 test('strict ordinal parsing', function (assert) {
307 var i, ordinalStr, testMoment;
308 for (i = 1; i <= 31; ++i) {
309 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
310 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
311 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
312 }
313 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('he');
3
4 test('parse', function (assert) {
5 var tests = 'ינואר ינו׳_פברואר פבר׳_מרץ מרץ_אפריל אפר׳_מאי מאי_יוני יוני_יולי יולי_אוגוסט אוג׳_ספטמבר ספט׳_אוקטובר אוק׳_נובמבר נוב׳_דצמבר דצמ׳'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'ראשון, פברואר 14 2010, 3:25:50 pm'],
25 ['ddd, hA', 'א׳, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2 02 פברואר פבר׳'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 ראשון א׳ א'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '8 8 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 בפברואר 2010'],
41 ['LLL', '14 בפברואר 2010 15:25'],
42 ['LLLL', 'ראשון, 14 בפברואר 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 פבר׳ 2010'],
45 ['lll', '14 פבר׳ 2010 15:25'],
46 ['llll', 'א׳, 14 פבר׳ 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format month', function (assert) {
56 var expected = 'ינואר ינו׳_פברואר פבר׳_מרץ מרץ_אפריל אפר׳_מאי מאי_יוני יוני_יולי יולי_אוגוסט אוג׳_ספטמבר ספט׳_אוקטובר אוק׳_נובמבר נוב׳_דצמבר דצמ׳'.split('_'), i;
57 for (i = 0; i < expected.length; i++) {
58 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
59 }
60 });
61
62 test('format week', function (assert) {
63 var expected = 'ראשון א׳ א|שני ב׳ ב|שלישי ג׳ ג|רביעי ד׳ ד|חמישי ה׳ ה|שישי ו׳ ו|שבת ש׳ ש'.split('|'), i;
64 for (i = 0; i < expected.length; i++) {
65 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
66 }
67 });
68
69 test('from', function (assert) {
70 var start = moment([2007, 1, 28]);
71 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'מספר שניות', '44 seconds = a few seconds');
72 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'דקה', '45 seconds = a minute');
73 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'דקה', '89 seconds = a minute');
74 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 דקות', '90 seconds = 2 minutes');
75 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 דקות', '44 minutes = 44 minutes');
76 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'שעה', '45 minutes = an hour');
77 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'שעה', '89 minutes = an hour');
78 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'שעתיים', '90 minutes = 2 hours');
79 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 שעות', '5 hours = 5 hours');
80 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 שעות', '21 hours = 21 hours');
81 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'יום', '22 hours = a day');
82 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'יום', '35 hours = a day');
83 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'יומיים', '36 hours = 2 days');
84 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'יום', '1 day = a day');
85 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ימים', '5 days = 5 days');
86 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ימים', '25 days = 25 days');
87 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'חודש', '26 days = a month');
88 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'חודש', '30 days = a month');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'חודש', '43 days = a month');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'חודשיים', '46 days = 2 months');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'חודשיים', '75 days = 2 months');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 חודשים', '76 days = 3 months');
93 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'חודש', '1 month = a month');
94 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 חודשים', '5 months = 5 months');
95 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'שנה', '345 days = a year');
96 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'שנתיים', '548 days = 2 years');
97 assert.equal(start.from(moment([2007, 1, 28]).add({d: 3699}), true), '10 שנים', '345 days = 10 years');
98 assert.equal(start.from(moment([2007, 1, 28]).add({d: 7340}), true), '20 שנה', '548 days = 20 years');
99 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'שנה', '1 year = a year');
100 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 שנים', '5 years = 5 years');
101 });
102
103 test('suffix', function (assert) {
104 assert.equal(moment(30000).from(0), 'בעוד מספר שניות', 'prefix');
105 assert.equal(moment(0).from(30000), 'לפני מספר שניות', 'suffix');
106 });
107
108 test('now from now', function (assert) {
109 assert.equal(moment().fromNow(), 'לפני מספר שניות', 'now from now should display as in the past');
110 });
111
112 test('fromNow', function (assert) {
113 assert.equal(moment().add({s: 30}).fromNow(), 'בעוד מספר שניות', 'in a few seconds');
114 assert.equal(moment().add({d: 5}).fromNow(), 'בעוד 5 ימים', 'in 5 days');
115 });
116
117 test('calendar day', function (assert) {
118 var a = moment().hours(2).minutes(0).seconds(0);
119
120 assert.equal(moment(a).calendar(), 'היום ב־02:00', 'today at the same time');
121 assert.equal(moment(a).add({m: 25}).calendar(), 'היום ב־02:25', 'Now plus 25 min');
122 assert.equal(moment(a).add({h: 1}).calendar(), 'היום ב־03:00', 'Now plus 1 hour');
123 assert.equal(moment(a).add({d: 1}).calendar(), 'מחר ב־02:00', 'tomorrow at the same time');
124 assert.equal(moment(a).subtract({h: 1}).calendar(), 'היום ב־01:00', 'Now minus 1 hour');
125 assert.equal(moment(a).subtract({d: 1}).calendar(), 'אתמול ב־02:00', 'yesterday at the same time');
126 });
127
128 test('calendar next week', function (assert) {
129 var i, m;
130 for (i = 2; i < 7; i++) {
131 m = moment().add({d: i});
132 assert.equal(m.calendar(), m.format('dddd [בשעה] LT'), 'Today + ' + i + ' days current time');
133 m.hours(0).minutes(0).seconds(0).milliseconds(0);
134 assert.equal(m.calendar(), m.format('dddd [בשעה] LT'), 'Today + ' + i + ' days beginning of day');
135 m.hours(23).minutes(59).seconds(59).milliseconds(999);
136 assert.equal(m.calendar(), m.format('dddd [בשעה] LT'), 'Today + ' + i + ' days end of day');
137 }
138 });
139
140 test('calendar last week', function (assert) {
141 var i, m;
142 for (i = 2; i < 7; i++) {
143 m = moment().subtract({d: i});
144 assert.equal(m.calendar(), m.format('[ביום] dddd [האחרון בשעה] LT'), 'Today - ' + i + ' days current time');
145 m.hours(0).minutes(0).seconds(0).milliseconds(0);
146 assert.equal(m.calendar(), m.format('[ביום] dddd [האחרון בשעה] LT'), 'Today - ' + i + ' days beginning of day');
147 m.hours(23).minutes(59).seconds(59).milliseconds(999);
148 assert.equal(m.calendar(), m.format('[ביום] dddd [האחרון בשעה] LT'), 'Today - ' + i + ' days end of day');
149 }
150 });
151
152 test('calendar all else', function (assert) {
153 var weeksAgo = moment().subtract({w: 1}),
154 weeksFromNow = moment().add({w: 1});
155
156 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
157 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
158
159 weeksAgo = moment().subtract({w: 2});
160 weeksFromNow = moment().add({w: 2});
161
162 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
163 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
164 });
165
166 test('weeks year starting sunday', function (assert) {
167 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
168 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
169 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
170 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
171 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
172 });
173
174 test('weeks year starting monday', function (assert) {
175 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
176 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
177 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
178 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
179 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
180 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
181 });
182
183 test('weeks year starting tuesday', function (assert) {
184 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
185 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
186 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
187 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
188 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
189 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
190 });
191
192 test('weeks year starting wednesday', function (assert) {
193 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
194 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
195 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
196 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
197 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
198 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
199 });
200
201 test('weeks year starting thursday', function (assert) {
202 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
203 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
204 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
205 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
206 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
207 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
208 });
209
210 test('weeks year starting friday', function (assert) {
211 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
212 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
213 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
214 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
215 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
216 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
217 });
218
219 test('weeks year starting saturday', function (assert) {
220 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
221 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
222 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
223 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
224 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
225 });
226
227 test('weeks year starting sunday format', function (assert) {
228 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
229 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
230 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
231 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
232 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
233 });
234
235 test('lenient ordinal parsing', function (assert) {
236 var i, ordinalStr, testMoment;
237 for (i = 1; i <= 31; ++i) {
238 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
239 testMoment = moment(ordinalStr, 'YYYY MM Do');
240 assert.equal(testMoment.year(), 2014,
241 'lenient ordinal parsing ' + i + ' year check');
242 assert.equal(testMoment.month(), 0,
243 'lenient ordinal parsing ' + i + ' month check');
244 assert.equal(testMoment.date(), i,
245 'lenient ordinal parsing ' + i + ' date check');
246 }
247 });
248
249 test('lenient ordinal parsing of number', function (assert) {
250 var i, testMoment;
251 for (i = 1; i <= 31; ++i) {
252 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
253 assert.equal(testMoment.year(), 2014,
254 'lenient ordinal parsing of number ' + i + ' year check');
255 assert.equal(testMoment.month(), 0,
256 'lenient ordinal parsing of number ' + i + ' month check');
257 assert.equal(testMoment.date(), i,
258 'lenient ordinal parsing of number ' + i + ' date check');
259 }
260 });
261
262 test('strict ordinal parsing', function (assert) {
263 var i, ordinalStr, testMoment;
264 for (i = 1; i <= 31; ++i) {
265 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
266 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
267 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
268 }
269 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('hi');
3
4 test('parse', function (assert) {
5 var tests = 'जनवरी जन._फ़रवरी फ़र._मार्च मार्च_अप्रैल अप्रै._मई मई_जून जून_जुलाई जुल._अगस्त अग._सितम्बर सित._अक्टूबर अक्टू._नवम्बर नव._दिसम्बर दिस.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, a h:mm:ss बजे', 'रविवार, १४ फ़रवरी २०१०, दोपहर ३:२५:५० बजे'],
25 ['ddd, a h बजे', 'रवि, दोपहर ३ बजे'],
26 ['M Mo MM MMMM MMM', '२ २ ०२ फ़रवरी फ़र.'],
27 ['YYYY YY', '२०१० १०'],
28 ['D Do DD', '१४ १४ १४'],
29 ['d do dddd ddd dd', '० ० रविवार रवि र'],
30 ['DDD DDDo DDDD', '४५ ४५ ०४५'],
31 ['w wo ww', '८ ८ ०८'],
32 ['h hh', '३ ०३'],
33 ['H HH', '१५ १५'],
34 ['m mm', '२५ २५'],
35 ['s ss', '५० ५०'],
36 ['a A', 'दोपहर दोपहर'],
37 ['LTS', 'दोपहर ३:२५:५० बजे'],
38 ['L', '१४/०२/२०१०'],
39 ['LL', '१४ फ़रवरी २०१०'],
40 ['LLL', '१४ फ़रवरी २०१०, दोपहर ३:२५ बजे'],
41 ['LLLL', 'रविवार, १४ फ़रवरी २०१०, दोपहर ३:२५ बजे'],
42 ['l', '१४/२/२०१०'],
43 ['ll', '१४ फ़र. २०१०'],
44 ['lll', '१४ फ़र. २०१०, दोपहर ३:२५ बजे'],
45 ['llll', 'रवि, १४ फ़र. २०१०, दोपहर ३:२५ बजे']
46 ],
47 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
48 i;
49 for (i = 0; i < a.length; i++) {
50 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
51 }
52 });
53
54 test('format ordinal', function (assert) {
55 assert.equal(moment([2011, 0, 1]).format('DDDo'), '१', '१');
56 assert.equal(moment([2011, 0, 2]).format('DDDo'), '२', '२');
57 assert.equal(moment([2011, 0, 3]).format('DDDo'), '३', '३');
58 assert.equal(moment([2011, 0, 4]).format('DDDo'), '४', '४');
59 assert.equal(moment([2011, 0, 5]).format('DDDo'), '५', '५');
60 assert.equal(moment([2011, 0, 6]).format('DDDo'), '६', '६');
61 assert.equal(moment([2011, 0, 7]).format('DDDo'), '७', '७');
62 assert.equal(moment([2011, 0, 8]).format('DDDo'), '८', '८');
63 assert.equal(moment([2011, 0, 9]).format('DDDo'), '९', '९');
64 assert.equal(moment([2011, 0, 10]).format('DDDo'), '१०', '१०');
65
66 assert.equal(moment([2011, 0, 11]).format('DDDo'), '११', '११');
67 assert.equal(moment([2011, 0, 12]).format('DDDo'), '१२', '१२');
68 assert.equal(moment([2011, 0, 13]).format('DDDo'), '१३', '१३');
69 assert.equal(moment([2011, 0, 14]).format('DDDo'), '१४', '१४');
70 assert.equal(moment([2011, 0, 15]).format('DDDo'), '१५', '१५');
71 assert.equal(moment([2011, 0, 16]).format('DDDo'), '१६', '१६');
72 assert.equal(moment([2011, 0, 17]).format('DDDo'), '१७', '१७');
73 assert.equal(moment([2011, 0, 18]).format('DDDo'), '१८', '१८');
74 assert.equal(moment([2011, 0, 19]).format('DDDo'), '१९', '१९');
75 assert.equal(moment([2011, 0, 20]).format('DDDo'), '२०', '२०');
76
77 assert.equal(moment([2011, 0, 21]).format('DDDo'), '२१', '२१');
78 assert.equal(moment([2011, 0, 22]).format('DDDo'), '२२', '२२');
79 assert.equal(moment([2011, 0, 23]).format('DDDo'), '२३', '२३');
80 assert.equal(moment([2011, 0, 24]).format('DDDo'), '२४', '२४');
81 assert.equal(moment([2011, 0, 25]).format('DDDo'), '२५', '२५');
82 assert.equal(moment([2011, 0, 26]).format('DDDo'), '२६', '२६');
83 assert.equal(moment([2011, 0, 27]).format('DDDo'), '२७', '२७');
84 assert.equal(moment([2011, 0, 28]).format('DDDo'), '२८', '२८');
85 assert.equal(moment([2011, 0, 29]).format('DDDo'), '२९', '२९');
86 assert.equal(moment([2011, 0, 30]).format('DDDo'), '३०', '३०');
87
88 assert.equal(moment([2011, 0, 31]).format('DDDo'), '३१', '३१');
89 });
90
91 test('format month', function (assert) {
92 var expected = 'जनवरी जन._फ़रवरी फ़र._मार्च मार्च_अप्रैल अप्रै._मई मई_जून जून_जुलाई जुल._अगस्त अग._सितम्बर सित._अक्टूबर अक्टू._नवम्बर नव._दिसम्बर दिस.'.split('_'), i;
93 for (i = 0; i < expected.length; i++) {
94 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
95 }
96 });
97
98 test('format week', function (assert) {
99 var expected = 'रविवार रवि र_सोमवार सोम सो_मंगलवार मंगल मं_बुधवार बुध बु_गुरूवार गुरू गु_शुक्रवार शुक्र शु_शनिवार शनि श'.split('_'), i;
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
102 }
103 });
104
105 test('from', function (assert) {
106 var start = moment([2007, 1, 28]);
107 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'कुछ ही क्षण', '44 seconds = a few seconds');
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'एक मिनट', '45 seconds = a minute');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'एक मिनट', '89 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '२ मिनट', '90 seconds = 2 minutes');
111 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '४४ मिनट', '44 minutes = 44 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'एक घंटा', '45 minutes = an hour');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'एक घंटा', '89 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '२ घंटे', '90 minutes = 2 hours');
115 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '५ घंटे', '5 hours = 5 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '२१ घंटे', '21 hours = 21 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'एक दिन', '22 hours = a day');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'एक दिन', '35 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '२ दिन', '36 hours = 2 days');
120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'एक दिन', '1 day = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '५ दिन', '5 days = 5 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '२५ दिन', '25 days = 25 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'एक महीने', '26 days = a month');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'एक महीने', '30 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'एक महीने', '43 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '२ महीने', '46 days = 2 months');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '२ महीने', '75 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '३ महीने', '76 days = 3 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'एक महीने', '1 month = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '५ महीने', '5 months = 5 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'एक वर्ष', '345 days = a year');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '२ वर्ष', '548 days = 2 years');
133 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'एक वर्ष', '1 year = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '५ वर्ष', '5 years = 5 years');
135 });
136
137 test('suffix', function (assert) {
138 assert.equal(moment(30000).from(0), 'कुछ ही क्षण में', 'prefix');
139 assert.equal(moment(0).from(30000), 'कुछ ही क्षण पहले', 'suffix');
140 });
141
142 test('now from now', function (assert) {
143 assert.equal(moment().fromNow(), 'कुछ ही क्षण पहले', 'now from now should display as in the past');
144 });
145
146 test('fromNow', function (assert) {
147 assert.equal(moment().add({s: 30}).fromNow(), 'कुछ ही क्षण में', 'कुछ ही क्षण में');
148 assert.equal(moment().add({d: 5}).fromNow(), '५ दिन में', '५ दिन में');
149 });
150
151 test('calendar day', function (assert) {
152 var a = moment().hours(2).minutes(0).seconds(0);
153
154 assert.equal(moment(a).calendar(), 'आज रात २:०० बजे', 'today at the same time');
155 assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात २:२५ बजे', 'Now plus 25 min');
156 assert.equal(moment(a).add({h: 3}).calendar(), 'आज सुबह ५:०० बजे', 'Now plus 3 hour');
157 assert.equal(moment(a).add({d: 1}).calendar(), 'कल रात २:०० बजे', 'tomorrow at the same time');
158 assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात १:०० बजे', 'Now minus 1 hour');
159 assert.equal(moment(a).subtract({d: 1}).calendar(), 'कल रात २:०० बजे', 'yesterday at the same time');
160 });
161
162 test('calendar next week', function (assert) {
163 var i, m;
164 for (i = 2; i < 7; i++) {
165 m = moment().add({d: i});
166 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
167 m.hours(0).minutes(0).seconds(0).milliseconds(0);
168 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
169 m.hours(23).minutes(59).seconds(59).milliseconds(999);
170 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
171 }
172 });
173
174 test('calendar last week', function (assert) {
175 var i, m;
176
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[पिछले] dddd[,] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[पिछले] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[पिछले] dddd[,] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('meridiem invariant', function (assert) {
202 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'रात', 'before dawn');
203 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'सुबह', 'morning');
204 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दोपहर', 'during day');
205 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'शाम', 'evening');
206 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'शाम', 'late evening');
207 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'रात', 'night');
208
209 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'रात', 'before dawn');
210 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'सुबह', 'morning');
211 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'दोपहर', ' during day');
212 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'शाम', 'evening');
213 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'शाम', 'late evening');
214 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात', 'night');
215 });
216
217 test('weeks year starting sunday', function (assert) {
218 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
219 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
220 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
221 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
222 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
223 });
224
225 test('weeks year starting monday', function (assert) {
226 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
227 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
228 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
229 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
230 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
231 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
232 });
233
234 test('weeks year starting tuesday', function (assert) {
235 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
236 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
237 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
238 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
239 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
240 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
241 });
242
243 test('weeks year starting wednesday', function (assert) {
244 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
245 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
246 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
247 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
248 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
249 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
250 });
251
252 test('weeks year starting thursday', function (assert) {
253 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
254 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
255 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
256 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
257 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
258 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
259 });
260
261 test('weeks year starting friday', function (assert) {
262 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
263 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
264 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
265 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
266 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
267 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
268 });
269
270 test('weeks year starting saturday', function (assert) {
271 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
272 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
273 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
274 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
275 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
276 });
277
278 test('weeks year starting sunday formatted', function (assert) {
279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
280 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '२ ०२ २', 'Jan 8 2012 should be week 2');
282 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '२ ०२ २', 'Jan 14 2012 should be week 2');
283 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
284 });
285
286 test('lenient ordinal parsing', function (assert) {
287 var i, ordinalStr, testMoment;
288 for (i = 1; i <= 31; ++i) {
289 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
290 testMoment = moment(ordinalStr, 'YYYY MM Do');
291 assert.equal(testMoment.year(), 2014,
292 'lenient ordinal parsing ' + i + ' year check');
293 assert.equal(testMoment.month(), 0,
294 'lenient ordinal parsing ' + i + ' month check');
295 assert.equal(testMoment.date(), i,
296 'lenient ordinal parsing ' + i + ' date check');
297 }
298 });
299
300 test('lenient ordinal parsing of number', function (assert) {
301 var i, testMoment;
302 for (i = 1; i <= 31; ++i) {
303 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
304 assert.equal(testMoment.year(), 2014,
305 'lenient ordinal parsing of number ' + i + ' year check');
306 assert.equal(testMoment.month(), 0,
307 'lenient ordinal parsing of number ' + i + ' month check');
308 assert.equal(testMoment.date(), i,
309 'lenient ordinal parsing of number ' + i + ' date check');
310 }
311 });
312
313 test('meridiem', function (assert) {
314 var h, m, t1, t2;
315 for (h = 0; h < 24; ++h) {
316 for (m = 0; m < 60; m += 15) {
317 t1 = moment.utc([2000, 0, 1, h, m]);
318 t2 = moment(t1.format('A h:mm'), 'A h:mm');
319 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
320 'meridiem at ' + t1.format('HH:mm'));
321 }
322 }
323 });
324
325 test('strict ordinal parsing', function (assert) {
326 var i, ordinalStr, testMoment;
327 for (i = 1; i <= 31; ++i) {
328 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
329 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
330 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
331 }
332 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('hr');
3
4 test('parse', function (assert) {
5 var tests = 'siječanj sij._veljača velj._ožujak ožu._travanj tra._svibanj svi._lipanj lip._srpanj srp._kolovoz kol._rujan ruj._listopad lis._studeni stu._prosinac pro.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedjelja, 14. veljača 2010, 3:25:50 pm'],
25 ['ddd, hA', 'ned., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 veljača velj.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. nedjelja ned. ne'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '7 7. 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14. 02. 2010'],
40 ['LL', '14. veljača 2010'],
41 ['LLL', '14. veljača 2010 15:25'],
42 ['LLLL', 'nedjelja, 14. veljača 2010 15:25'],
43 ['l', '14. 2. 2010'],
44 ['ll', '14. velj. 2010'],
45 ['lll', '14. velj. 2010 15:25'],
46 ['llll', 'ned., 14. velj. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'siječanj sij._veljača velj._ožujak ožu._travanj tra._svibanj svi._lipanj lip._srpanj srp._kolovoz kol._rujan ruj._listopad lis._studeni stu._prosinac pro.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'nedjelja ned. ne_ponedjeljak pon. po_utorak uto. ut_srijeda sri. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'par sekundi', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedna minuta', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedna minuta', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mjesec', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mjesec', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mjesec', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mjeseca', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mjeseca', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mjeseca', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mjesec', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mjeseci', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'za par sekundi', 'prefix');
140 assert.equal(moment(0).from(30000), 'prije par sekundi', 'prefix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'prije par sekundi', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'za par sekundi', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165
166 function makeFormat(d) {
167 switch (d.day()) {
168 case 0:
169 return '[u] [nedjelju] [u] LT';
170 case 3:
171 return '[u] [srijedu] [u] LT';
172 case 6:
173 return '[u] [subotu] [u] LT';
174 case 1:
175 case 2:
176 case 4:
177 case 5:
178 return '[u] dddd [u] LT';
179 }
180 }
181
182 for (i = 2; i < 7; i++) {
183 m = moment().add({d: i});
184 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
185 m.hours(0).minutes(0).seconds(0).milliseconds(0);
186 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
187 m.hours(23).minutes(59).seconds(59).milliseconds(999);
188 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
189 }
190 });
191
192 test('calendar last week', function (assert) {
193 var i, m;
194
195 function makeFormat(d) {
196 switch (d.day()) {
197 case 0:
198 case 3:
199 return '[prošlu] dddd [u] LT';
200 case 6:
201 return '[prošle] [subote] [u] LT';
202 case 1:
203 case 2:
204 case 4:
205 case 5:
206 return '[prošli] dddd [u] LT';
207 }
208 }
209
210 for (i = 2; i < 7; i++) {
211 m = moment().subtract({d: i});
212 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
213 m.hours(0).minutes(0).seconds(0).milliseconds(0);
214 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
215 m.hours(23).minutes(59).seconds(59).milliseconds(999);
216 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
217 }
218 });
219
220 test('calendar all else', function (assert) {
221 var weeksAgo = moment().subtract({w: 1}),
222 weeksFromNow = moment().add({w: 1});
223
224 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
225 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
226
227 weeksAgo = moment().subtract({w: 2});
228 weeksFromNow = moment().add({w: 2});
229
230 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
231 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
232 });
233
234 test('weeks year starting sunday', function (assert) {
235 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
236 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
237 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
238 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
239 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
240 });
241
242 test('weeks year starting monday', function (assert) {
243 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
244 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
245 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
246 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
247 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
248 });
249
250 test('weeks year starting tuesday', function (assert) {
251 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
252 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
253 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
254 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
255 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
256 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
257 });
258
259 test('weeks year starting wednesday', function (assert) {
260 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
261 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
262 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
263 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
264 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
265 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
266 });
267
268 test('weeks year starting thursday', function (assert) {
269 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
270 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
271 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
272 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
273 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
274 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
275 });
276
277 test('weeks year starting friday', function (assert) {
278 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
279 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
280 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
281 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
282 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
283 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
284 });
285
286 test('weeks year starting saturday', function (assert) {
287 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
288 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
289 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
290 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
291 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
292 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
293 });
294
295 test('weeks year starting sunday formatted', function (assert) {
296 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
297 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
298 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
299 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
300 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
301 });
302
303 test('lenient ordinal parsing', function (assert) {
304 var i, ordinalStr, testMoment;
305 for (i = 1; i <= 31; ++i) {
306 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
307 testMoment = moment(ordinalStr, 'YYYY MM Do');
308 assert.equal(testMoment.year(), 2014,
309 'lenient ordinal parsing ' + i + ' year check');
310 assert.equal(testMoment.month(), 0,
311 'lenient ordinal parsing ' + i + ' month check');
312 assert.equal(testMoment.date(), i,
313 'lenient ordinal parsing ' + i + ' date check');
314 }
315 });
316
317 test('lenient ordinal parsing of number', function (assert) {
318 var i, testMoment;
319 for (i = 1; i <= 31; ++i) {
320 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
321 assert.equal(testMoment.year(), 2014,
322 'lenient ordinal parsing of number ' + i + ' year check');
323 assert.equal(testMoment.month(), 0,
324 'lenient ordinal parsing of number ' + i + ' month check');
325 assert.equal(testMoment.date(), i,
326 'lenient ordinal parsing of number ' + i + ' date check');
327 }
328 });
329
330 test('strict ordinal parsing', function (assert) {
331 var i, ordinalStr, testMoment;
332 for (i = 1; i <= 31; ++i) {
333 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
334 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
335 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
336 }
337 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('hu');
3
4 test('parse', function (assert) {
5 var tests = 'január jan_február feb_március márc_április ápr_május máj_június jún_július júl_augusztus aug_szeptember szept_október okt_november nov_december dec'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, MMMM Do YYYY, HH:mm:ss', 'vasárnap, február 14. 2010, 15:25:50'],
26 ['ddd, HH', 'vas, 15'],
27 ['M Mo MM MMMM MMM', '2 2. 02 február feb'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14. 14'],
30 ['d do dddd ddd dd', '0 0. vasárnap vas v'],
31 ['DDD DDDo DDDD', '45 45. 045'],
32 ['w wo ww', '7 7. 07'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['[az év] DDDo [napja]', 'az év 45. napja'],
37 ['LTS', '15:25:50'],
38 ['L', '2010.02.14.'],
39 ['LL', '2010. február 14.'],
40 ['LLL', '2010. február 14. 15:25'],
41 ['LLLL', '2010. február 14., vasárnap 15:25'],
42 ['l', '2010.2.14.'],
43 ['ll', '2010. feb 14.'],
44 ['lll', '2010. feb 14. 15:25'],
45 ['llll', '2010. feb 14., vas 15:25']
46 ],
47 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
48 i;
49 for (i = 0; i < a.length; i++) {
50 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
51 }
52 });
53
54 test('meridiem', function (assert) {
55 assert.equal(moment([2011, 2, 23, 0, 0]).format('a'), 'de', 'am');
56 assert.equal(moment([2011, 2, 23, 11, 59]).format('a'), 'de', 'am');
57 assert.equal(moment([2011, 2, 23, 12, 0]).format('a'), 'du', 'pm');
58 assert.equal(moment([2011, 2, 23, 23, 59]).format('a'), 'du', 'pm');
59
60 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), 'DE', 'AM');
61 assert.equal(moment([2011, 2, 23, 11, 59]).format('A'), 'DE', 'AM');
62 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), 'DU', 'PM');
63 assert.equal(moment([2011, 2, 23, 23, 59]).format('A'), 'DU', 'PM');
64 });
65
66 test('format ordinal', function (assert) {
67 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
68 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
69 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
70 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
71 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
72 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
73 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
74 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
75 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
76 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
77
78 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
79 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
80 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
81 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
82 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
83 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
84 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
85 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
86 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
87 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
88
89 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
90 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
91 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
92 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
93 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
94 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
95 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
96 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
97 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
98 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
99
100 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
101 });
102
103 test('format month', function (assert) {
104 var expected = 'január jan_február feb_március márc_április ápr_május máj_június jún_július júl_augusztus aug_szeptember szept_október okt_november nov_december dec'.split('_'),
105 i;
106 for (i = 0; i < expected.length; i++) {
107 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
108 }
109 });
110
111 test('format week', function (assert) {
112 var expected = 'vasárnap vas_hétfő hét_kedd kedd_szerda sze_csütörtök csüt_péntek pén_szombat szo'.split('_'),
113 i;
114 for (i = 0; i < expected.length; i++) {
115 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
116 }
117 });
118
119 test('from', function (assert) {
120 var start = moment([2007, 1, 28]);
121 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'néhány másodperc', '44 másodperc = néhány másodperc');
122 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'egy perc', '45 másodperc = egy perc');
123 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'egy perc', '89 másodperc = egy perc');
124 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 perc', '90 másodperc = 2 perc');
125 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 perc', '44 perc = 44 perc');
126 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'egy óra', '45 perc = egy óra');
127 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'egy óra', '89 perc = egy óra');
128 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 óra', '90 perc = 2 óra');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 óra', '5 óra = 5 óra');
130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 óra', '21 óra = 21 óra');
131 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'egy nap', '22 óra = egy nap');
132 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'egy nap', '35 óra = egy nap');
133 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 nap', '36 óra = 2 nap');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'egy nap', '1 nap = egy nap');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 nap', '5 nap = 5 nap');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 nap', '25 nap = 25 nap');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'egy hónap', '26 nap = egy hónap');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'egy hónap', '30 nap = egy hónap');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'egy hónap', '45 nap = egy hónap');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 hónap', '46 nap = 2 hónap');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 hónap', '75 nap = 2 hónap');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 hónap', '76 nap = 3 hónap');
143 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'egy hónap', '1 hónap = egy hónap');
144 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 hónap', '5 hónap = 5 hónap');
145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'egy év', '345 nap = egy év');
146 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 év', '548 nap = 2 év');
147 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'egy év', '1 év = egy év');
148 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 év', '5 év = 5 év');
149 });
150
151 test('suffix', function (assert) {
152 assert.equal(moment(30000).from(0), 'néhány másodperc múlva', 'prefix');
153 assert.equal(moment(0).from(30000), 'néhány másodperce', 'suffix');
154 });
155
156 test('now from now', function (assert) {
157 assert.equal(moment().fromNow(), 'néhány másodperce', 'now from now should display as in the past');
158 });
159
160 test('fromNow', function (assert) {
161 assert.equal(moment().add({s: 30}).fromNow(), 'néhány másodperc múlva', 'néhány másodperc múlva');
162 assert.equal(moment().add({d: 5}).fromNow(), '5 nap múlva', '5 nap múlva');
163 });
164
165 test('calendar day', function (assert) {
166 var a = moment().hours(2).minutes(0).seconds(0);
167
168 assert.equal(moment(a).calendar(), 'ma 2:00-kor', 'today at the same time');
169 assert.equal(moment(a).add({m: 25}).calendar(), 'ma 2:25-kor', 'Now plus 25 min');
170 assert.equal(moment(a).add({h: 1}).calendar(), 'ma 3:00-kor', 'Now plus 1 hour');
171 assert.equal(moment(a).add({d: 1}).calendar(), 'holnap 2:00-kor', 'tomorrow at the same time');
172 assert.equal(moment(a).subtract({h: 1}).calendar(), 'ma 1:00-kor', 'Now minus 1 hour');
173 assert.equal(moment(a).subtract({d: 1}).calendar(), 'tegnap 2:00-kor', 'yesterday at the same time');
174 });
175
176 test('calendar next week', function (assert) {
177 var i, m, days = 'vasárnap_hétfőn_kedden_szerdán_csütörtökön_pénteken_szombaton'.split('_');
178 for (i = 2; i < 7; i++) {
179 m = moment().add({d: i});
180 assert.equal(m.calendar(), m.format('[' + days[m.day()] + '] LT[-kor]'), 'today + ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[' + days[m.day()] + '] LT[-kor]'), 'today + ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[' + days[m.day()] + '] LT[-kor]'), 'today + ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar last week', function (assert) {
189 var i, m, days = 'vasárnap_hétfőn_kedden_szerdán_csütörtökön_pénteken_szombaton'.split('_');
190
191 for (i = 2; i < 7; i++) {
192 m = moment().subtract({d: i});
193 assert.equal(m.calendar(), m.format('[múlt ' + days[m.day()] + '] LT[-kor]'), 'today - ' + i + ' days current time');
194 m.hours(0).minutes(0).seconds(0).milliseconds(0);
195 assert.equal(m.calendar(), m.format('[múlt ' + days[m.day()] + '] LT[-kor]'), 'today - ' + i + ' days beginning of day');
196 m.hours(23).minutes(59).seconds(59).milliseconds(999);
197 assert.equal(m.calendar(), m.format('[múlt ' + days[m.day()] + '] LT[-kor]'), 'today - ' + i + ' days end of day');
198 }
199 });
200
201 test('calendar all else', function (assert) {
202 var weeksAgo = moment().subtract({w: 1}),
203 weeksFromNow = moment().add({w: 1});
204
205 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'egy héte');
206 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'egy hét múlva');
207
208 weeksAgo = moment().subtract({w: 2});
209 weeksFromNow = moment().add({w: 2});
210
211 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 hete');
212 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 hét múlva');
213 });
214
215 test('weeks year starting sunday', function (assert) {
216 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
217 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
218 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
219 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
220 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
221 });
222
223 test('weeks year starting monday', function (assert) {
224 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
225 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
226 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
227 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
228 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
229 });
230
231 test('weeks year starting tuesday', function (assert) {
232 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
233 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
234 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
235 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
236 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
237 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
238 });
239
240 test('weeks year starting wednesday', function (assert) {
241 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
242 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
243 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
244 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
245 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
246 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
247 });
248
249 test('weeks year starting thursday', function (assert) {
250 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
251 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
252 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
253 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
254 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
255 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
256 });
257
258 test('weeks year starting friday', function (assert) {
259 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
260 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
261 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
262 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
263 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
264 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
265 });
266
267 test('weeks year starting saturday', function (assert) {
268 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
269 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
270 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
271 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
272 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
273 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
274 });
275
276 test('weeks year starting sunday formatted', function (assert) {
277 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
278 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
279 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
280 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
281 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
282 });
283
284 test('lenient ordinal parsing', function (assert) {
285 var i, ordinalStr, testMoment;
286 for (i = 1; i <= 31; ++i) {
287 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
288 testMoment = moment(ordinalStr, 'YYYY MM Do');
289 assert.equal(testMoment.year(), 2014,
290 'lenient ordinal parsing ' + i + ' year check');
291 assert.equal(testMoment.month(), 0,
292 'lenient ordinal parsing ' + i + ' month check');
293 assert.equal(testMoment.date(), i,
294 'lenient ordinal parsing ' + i + ' date check');
295 }
296 });
297
298 test('lenient ordinal parsing of number', function (assert) {
299 var i, testMoment;
300 for (i = 1; i <= 31; ++i) {
301 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
302 assert.equal(testMoment.year(), 2014,
303 'lenient ordinal parsing of number ' + i + ' year check');
304 assert.equal(testMoment.month(), 0,
305 'lenient ordinal parsing of number ' + i + ' month check');
306 assert.equal(testMoment.date(), i,
307 'lenient ordinal parsing of number ' + i + ' date check');
308 }
309 });
310
311 test('strict ordinal parsing', function (assert) {
312 var i, ordinalStr, testMoment;
313 for (i = 1; i <= 31; ++i) {
314 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
315 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
316 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
317 }
318 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('hy-am');
3
4 test('parse', function (assert) {
5 var tests = 'հունվար հնվ_փետրվար փտր_մարտ մրտ_ապրիլ ապր_մայիս մյս_հունիս հնս_հուլիս հլս_օգոստոս օգս_սեպտեմբեր սպտ_հոկտեմբեր հկտ_նոյեմբեր նմբ_դեկտեմբեր դկտ'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('parse exceptional case', function (assert) {
23 assert.equal(moment('11 մայիսի 1989', ['DD MMMM YYYY']).format('DD-MM-YYYY'), '11-05-1989');
24 });
25
26 test('format', function (assert) {
27 var a = [
28 ['dddd, Do MMMM YYYY, HH:mm:ss', 'կիրակի, 14 փետրվարի 2010, 15:25:50'],
29 ['ddd, h A', 'կրկ, 3 ցերեկվա'],
30 ['M Mo MM MMMM MMM', '2 2 02 փետրվար փտր'],
31 ['YYYY YY', '2010 10'],
32 ['D Do DD', '14 14 14'],
33 ['d do dddd ddd dd', '0 0 կիրակի կրկ կրկ'],
34 ['DDD DDDo DDDD', '45 45-րդ 045'],
35 ['w wo ww', '7 7-րդ 07'],
36 ['h hh', '3 03'],
37 ['H HH', '15 15'],
38 ['m mm', '25 25'],
39 ['s ss', '50 50'],
40 ['a A', 'ցերեկվա ցերեկվա'],
41 ['[տարվա] DDDo [օրը]', 'տարվա 45-րդ օրը'],
42 ['LTS', '15:25:50'],
43 ['L', '14.02.2010'],
44 ['LL', '14 փետրվարի 2010 թ.'],
45 ['LLL', '14 փետրվարի 2010 թ., 15:25'],
46 ['LLLL', 'կիրակի, 14 փետրվարի 2010 թ., 15:25'],
47 ['l', '14.2.2010'],
48 ['ll', '14 փտր 2010 թ.'],
49 ['lll', '14 փտր 2010 թ., 15:25'],
50 ['llll', 'կրկ, 14 փտր 2010 թ., 15:25']
51 ],
52 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
53 i;
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format meridiem', function (assert) {
60 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'գիշերվա', 'night');
61 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'գիշերվա', 'night');
62 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'առավոտվա', 'morning');
63 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'առավոտվա', 'morning');
64 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'ցերեկվա', 'afternoon');
65 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'ցերեկվա', 'afternoon');
66 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'երեկոյան', 'evening');
67 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'երեկոյան', 'evening');
68 });
69
70 test('format ordinal', function (assert) {
71 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ին', '1-ին');
72 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-րդ', '2-րդ');
73 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-րդ', '3-րդ');
74 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-րդ', '4-րդ');
75 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-րդ', '5-րդ');
76 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-րդ', '6-րդ');
77 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-րդ', '7-րդ');
78 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-րդ', '8-րդ');
79 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-րդ', '9-րդ');
80 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-րդ', '10-րդ');
81
82 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-րդ', '11-րդ');
83 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-րդ', '12-րդ');
84 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-րդ', '13-րդ');
85 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-րդ', '14-րդ');
86 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-րդ', '15-րդ');
87 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-րդ', '16-րդ');
88 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-րդ', '17-րդ');
89 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-րդ', '18-րդ');
90 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-րդ', '19-րդ');
91 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-րդ', '20-րդ');
92
93 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-րդ', '21-րդ');
94 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-րդ', '22-րդ');
95 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-րդ', '23-րդ');
96 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-րդ', '24-րդ');
97 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-րդ', '25-րդ');
98 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-րդ', '26-րդ');
99 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-րդ', '27-րդ');
100 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-րդ', '28-րդ');
101 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-րդ', '29-րդ');
102 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-րդ', '30-րդ');
103
104 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-րդ', '31-րդ');
105 });
106
107 test('format month', function (assert) {
108 var expected = 'հունվար հնվ_փետրվար փտր_մարտ մրտ_ապրիլ ապր_մայիս մյս_հունիս հնս_հուլիս հլս_օգոստոս օգս_սեպտեմբեր սպտ_հոկտեմբեր հկտ_նոյեմբեր նմբ_դեկտեմբեր դկտ'.split('_'), i;
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
111 }
112 });
113
114 test('format month case', function (assert) {
115 var months = {
116 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
117 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
118 }, i;
119 for (i = 0; i < 12; i++) {
120 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
121 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
122 }
123 });
124
125 test('format month short case', function (assert) {
126 var monthsShort = {
127 'nominative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'),
128 'accusative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_')
129 }, i;
130 for (i = 0; i < 12; i++) {
131 assert.equal(moment([2011, i, 1]).format('D MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
132 assert.equal(moment([2011, i, 1]).format('MMM'), monthsShort.nominative[i], '1 ' + monthsShort.nominative[i]);
133 }
134 });
135
136 test('format month case with escaped symbols', function (assert) {
137 var months = {
138 'nominative': 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_'),
139 'accusative': 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_')
140 }, i;
141 for (i = 0; i < 12; i++) {
142 assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
143 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMMM[</b>]'), '<i>1</i> <b>' + months.accusative[i] + '</b>', '1 <b>' + months.accusative[i] + '</b>');
144 assert.equal(moment([2013, i, 1]).format('D[-ին օրը] MMMM'), '1-ին օրը ' + months.accusative[i], '1-ին օրը ' + months.accusative[i]);
145 assert.equal(moment([2013, i, 1]).format('D, MMMM'), '1, ' + months.nominative[i], '1, ' + months.nominative[i]);
146 }
147 });
148
149 test('format month short case with escaped symbols', function (assert) {
150 var monthsShort = {
151 'nominative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'),
152 'accusative': 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_')
153 }, i;
154 for (i = 0; i < 12; i++) {
155 assert.equal(moment([2013, i, 1]).format('D[] MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
156 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMM[</b>]'), '<i>1</i> <b>' + monthsShort.accusative[i] + '</b>', '1 <b>' + monthsShort.accusative[i] + '</b>');
157 assert.equal(moment([2013, i, 1]).format('D[-ին օրը] MMM'), '1-ին օրը ' + monthsShort.accusative[i], '1-ին օրը ' + monthsShort.accusative[i]);
158 assert.equal(moment([2013, i, 1]).format('D, MMM'), '1, ' + monthsShort.nominative[i], '1, ' + monthsShort.nominative[i]);
159 }
160 });
161
162 test('format week', function (assert) {
163 var expected = 'կիրակի կրկ կրկ_երկուշաբթի երկ երկ_երեքշաբթի երք երք_չորեքշաբթի չրք չրք_հինգշաբթի հնգ հնգ_ուրբաթ ուրբ ուրբ_շաբաթ շբթ շբթ'.split('_'), i;
164 for (i = 0; i < expected.length; i++) {
165 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
166 }
167 });
168
169 test('from', function (assert) {
170 var start = moment([2007, 1, 28]);
171 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'մի քանի վայրկյան', '44 seconds = seconds');
172 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'րոպե', '45 seconds = a minute');
173 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'րոպե', '89 seconds = a minute');
174 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 րոպե', '90 seconds = 2 minutes');
175 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 րոպե', '44 minutes = 44 minutes');
176 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ժամ', '45 minutes = an hour');
177 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ժամ', '89 minutes = an hour');
178 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ժամ', '90 minutes = 2 hours');
179 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ժամ', '5 hours = 5 hours');
180 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ժամ', '21 hours = 21 hours');
181 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'օր', '22 hours = a day');
182 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'օր', '35 hours = a day');
183 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 օր', '36 hours = 2 days');
184 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'օր', '1 day = a day');
185 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 օր', '5 days = 5 days');
186 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 օր', '11 days = 11 days');
187 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 օր', '21 days = 21 days');
188 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 օր', '25 days = 25 days');
189 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ամիս', '26 days = a month');
190 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ամիս', '30 days = a month');
191 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ամիս', '43 days = a month');
192 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ամիս', '46 days = 2 months');
193 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ամիս', '75 days = 2 months');
194 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ամիս', '76 days = 3 months');
195 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ամիս', '1 month = a month');
196 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ամիս', '5 months = 5 months');
197 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'տարի', '345 days = a year');
198 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 տարի', '548 days = 2 years');
199 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'տարի', '1 year = a year');
200 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 տարի', '5 years = 5 years');
201 });
202
203 test('suffix', function (assert) {
204 assert.equal(moment(30000).from(0), 'մի քանի վայրկյան հետո', 'prefix');
205 assert.equal(moment(0).from(30000), 'մի քանի վայրկյան առաջ', 'suffix');
206 });
207
208 test('fromNow', function (assert) {
209 assert.equal(moment().add({s: 30}).fromNow(), 'մի քանի վայրկյան հետո', 'in seconds');
210 assert.equal(moment().add({d: 5}).fromNow(), '5 օր հետո', 'in 5 days');
211 });
212
213 test('calendar day', function (assert) {
214 var a = moment().hours(2).minutes(0).seconds(0);
215
216 assert.equal(moment(a).calendar(), 'այսօր 02:00', 'today at the same time');
217 assert.equal(moment(a).add({m: 25}).calendar(), 'այսօր 02:25', 'Now plus 25 min');
218 assert.equal(moment(a).add({h: 1}).calendar(), 'այսօր 03:00', 'Now plus 1 hour');
219 assert.equal(moment(a).add({d: 1}).calendar(), 'վաղը 02:00', 'tomorrow at the same time');
220 assert.equal(moment(a).subtract({h: 1}).calendar(), 'այսօր 01:00', 'Now minus 1 hour');
221 assert.equal(moment(a).subtract({d: 1}).calendar(), 'երեկ 02:00', 'yesterday at the same time');
222 });
223
224 test('calendar next week', function (assert) {
225 var i, m;
226 function makeFormat(d) {
227 return 'dddd [օրը ժամը] LT';
228 }
229
230 for (i = 2; i < 7; i++) {
231 m = moment().add({d: i});
232 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
233 m.hours(0).minutes(0).seconds(0).milliseconds(0);
234 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
235 m.hours(23).minutes(59).seconds(59).milliseconds(999);
236 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
237 }
238 });
239
240 test('calendar last week', function (assert) {
241 var i, m;
242
243 function makeFormat(d) {
244 return '[անցած] dddd [օրը ժամը] LT';
245 }
246
247 for (i = 2; i < 7; i++) {
248 m = moment().subtract({d: i});
249 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
250 m.hours(0).minutes(0).seconds(0).milliseconds(0);
251 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
252 m.hours(23).minutes(59).seconds(59).milliseconds(999);
253 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
254 }
255 });
256
257 test('calendar all else', function (assert) {
258 var weeksAgo = moment().subtract({w: 1}),
259 weeksFromNow = moment().add({w: 1});
260
261 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
262 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
263
264 weeksAgo = moment().subtract({w: 2});
265 weeksFromNow = moment().add({w: 2});
266
267 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
268 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
269 });
270
271 test('weeks year starting sunday', function (assert) {
272 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
273 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
274 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
275 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
276 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
277 });
278
279 test('weeks year starting monday', function (assert) {
280 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
281 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
282 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
283 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
284 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
285 });
286
287 test('weeks year starting tuesday', function (assert) {
288 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
289 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
290 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
291 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
292 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
293 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
294 });
295
296 test('weeks year starting wednesday', function (assert) {
297 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
298 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
299 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
300 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
301 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
302 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
303 });
304
305 test('weeks year starting thursday', function (assert) {
306 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
307 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
308 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
309 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
310 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
311 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
312 });
313
314 test('weeks year starting friday', function (assert) {
315 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
316 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
317 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
318 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
319 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
320 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
321 });
322
323 test('weeks year starting saturday', function (assert) {
324 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
325 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
326 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
327 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
328 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
329 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
330 });
331
332 test('weeks year starting sunday formatted', function (assert) {
333 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ին', 'Dec 26 2011 should be week 1');
334 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ին', 'Jan 1 2012 should be week 1');
335 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-րդ', 'Jan 2 2012 should be week 2');
336 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-րդ', 'Jan 8 2012 should be week 2');
337 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-րդ', 'Jan 9 2012 should be week 3');
338 });
339
340 test('lenient ordinal parsing', function (assert) {
341 var i, ordinalStr, testMoment;
342 for (i = 1; i <= 31; ++i) {
343 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
344 testMoment = moment(ordinalStr, 'YYYY MM Do');
345 assert.equal(testMoment.year(), 2014,
346 'lenient ordinal parsing ' + i + ' year check');
347 assert.equal(testMoment.month(), 0,
348 'lenient ordinal parsing ' + i + ' month check');
349 assert.equal(testMoment.date(), i,
350 'lenient ordinal parsing ' + i + ' date check');
351 }
352 });
353
354 test('lenient ordinal parsing of number', function (assert) {
355 var i, testMoment;
356 for (i = 1; i <= 31; ++i) {
357 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
358 assert.equal(testMoment.year(), 2014,
359 'lenient ordinal parsing of number ' + i + ' year check');
360 assert.equal(testMoment.month(), 0,
361 'lenient ordinal parsing of number ' + i + ' month check');
362 assert.equal(testMoment.date(), i,
363 'lenient ordinal parsing of number ' + i + ' date check');
364 }
365 });
366
367 test('strict ordinal parsing', function (assert) {
368 var i, ordinalStr, testMoment;
369 for (i = 1; i <= 31; ++i) {
370 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
371 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
372 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
373 }
374 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('id');
3
4 test('parse', function (assert) {
5 var tests = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Minggu, Februari 14 2010, 3:25:50 sore'],
25 ['ddd, hA', 'Min, 3sore'],
26 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 Minggu Min Mg'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '7 7 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'sore sore'],
37 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
38 ['LTS', '15.25.50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 Februari 2010'],
41 ['LLL', '14 Februari 2010 pukul 15.25'],
42 ['LLLL', 'Minggu, 14 Februari 2010 pukul 15.25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 Feb 2010'],
45 ['lll', '14 Feb 2010 pukul 15.25'],
46 ['llll', 'Min, 14 Feb 2010 pukul 15.25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format month', function (assert) {
56 var expected = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_November Nov_Desember Des'.split('_'), i;
57 for (i = 0; i < expected.length; i++) {
58 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
59 }
60 });
61
62 test('format week', function (assert) {
63 var expected = 'Minggu Min Mg_Senin Sen Sn_Selasa Sel Sl_Rabu Rab Rb_Kamis Kam Km_Jumat Jum Jm_Sabtu Sab Sb'.split('_'), i;
64 for (i = 0; i < expected.length; i++) {
65 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
66 }
67 });
68
69 test('from', function (assert) {
70 var start = moment([2007, 1, 28]);
71 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'beberapa detik', '44 seconds = a few seconds');
72 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'semenit', '45 seconds = a minute');
73 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'semenit', '89 seconds = a minute');
74 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 menit', '90 seconds = 2 minutes');
75 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 menit', '44 minutes = 44 minutes');
76 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'sejam', '45 minutes = an hour');
77 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'sejam', '89 minutes = an hour');
78 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minutes = 2 hours');
79 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 hours = 5 hours');
80 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 hours = 21 hours');
81 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sehari', '22 hours = a day');
82 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sehari', '35 hours = a day');
83 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 hari', '36 hours = 2 days');
84 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sehari', '1 day = a day');
85 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 hari', '5 days = 5 days');
86 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 hari', '25 days = 25 days');
87 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sebulan', '26 days = a month');
88 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sebulan', '30 days = a month');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sebulan', '43 days = a month');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 bulan', '46 days = 2 months');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 bulan', '75 days = 2 months');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 bulan', '76 days = 3 months');
93 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sebulan', '1 month = a month');
94 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 bulan', '5 months = 5 months');
95 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setahun', '345 days = a year');
96 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 tahun', '548 days = 2 years');
97 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setahun', '1 year = a year');
98 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 tahun', '5 years = 5 years');
99 });
100
101 test('suffix', function (assert) {
102 assert.equal(moment(30000).from(0), 'dalam beberapa detik', 'prefix');
103 assert.equal(moment(0).from(30000), 'beberapa detik yang lalu', 'suffix');
104 });
105
106 test('now from now', function (assert) {
107 assert.equal(moment().fromNow(), 'beberapa detik yang lalu', 'now from now should display as in the past');
108 });
109
110 test('fromNow', function (assert) {
111 assert.equal(moment().add({s: 30}).fromNow(), 'dalam beberapa detik', 'in a few seconds');
112 assert.equal(moment().add({d: 5}).fromNow(), 'dalam 5 hari', 'in 5 days');
113 });
114
115 test('calendar day', function (assert) {
116 var a = moment().hours(2).minutes(0).seconds(0);
117
118 assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'today at the same time');
119 assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Now plus 25 min');
120 assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Now plus 1 hour');
121 assert.equal(moment(a).add({d: 1}).calendar(), 'Besok pukul 02.00', 'tomorrow at the same time');
122 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Now minus 1 hour');
123 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kemarin pukul 02.00', 'yesterday at the same time');
124 });
125
126 test('calendar next week', function (assert) {
127 var i, m;
128 for (i = 2; i < 7; i++) {
129 m = moment().add({d: i});
130 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days current time');
131 m.hours(0).minutes(0).seconds(0).milliseconds(0);
132 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days beginning of day');
133 m.hours(23).minutes(59).seconds(59).milliseconds(999);
134 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days end of day');
135 }
136 });
137
138 test('calendar last week', function (assert) {
139 var i, m;
140 for (i = 2; i < 7; i++) {
141 m = moment().subtract({d: i});
142 assert.equal(m.calendar(), m.format('dddd [lalu pukul] LT'), 'Today - ' + i + ' days current time');
143 m.hours(0).minutes(0).seconds(0).milliseconds(0);
144 assert.equal(m.calendar(), m.format('dddd [lalu pukul] LT'), 'Today - ' + i + ' days beginning of day');
145 m.hours(23).minutes(59).seconds(59).milliseconds(999);
146 assert.equal(m.calendar(), m.format('dddd [lalu pukul] LT'), 'Today - ' + i + ' days end of day');
147 }
148 });
149
150 test('calendar all else', function (assert) {
151 var weeksAgo = moment().subtract({w: 1}),
152 weeksFromNow = moment().add({w: 1});
153
154 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
155 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
156
157 weeksAgo = moment().subtract({w: 2});
158 weeksFromNow = moment().add({w: 2});
159
160 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
161 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
162 });
163
164 test('weeks year starting sunday', function (assert) {
165 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
166 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
167 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
168 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
169 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
170 });
171
172 test('weeks year starting monday', function (assert) {
173 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
174 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
175 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
176 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
177 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
178 });
179
180 test('weeks year starting tuesday', function (assert) {
181 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
182 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
183 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
184 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
185 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
186 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
187 });
188
189 test('weeks year starting wednesday', function (assert) {
190 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
191 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
192 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
193 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
194 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
195 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
196 });
197
198 test('weeks year starting thursday', function (assert) {
199 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
200 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
201 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
202 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
203 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
204 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
205 });
206
207 test('weeks year starting friday', function (assert) {
208 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
209 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
210 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
211 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
212 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
213 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
214 });
215
216 test('weeks year starting saturday', function (assert) {
217 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
218 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
219 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
220 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
221 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
222 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
223 });
224
225 test('weeks year starting sunday formatted', function (assert) {
226 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
227 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
228 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 2');
229 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
230 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
231 });
232
233 test('lenient ordinal parsing', function (assert) {
234 var i, ordinalStr, testMoment;
235 for (i = 1; i <= 31; ++i) {
236 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
237 testMoment = moment(ordinalStr, 'YYYY MM Do');
238 assert.equal(testMoment.year(), 2014,
239 'lenient ordinal parsing ' + i + ' year check');
240 assert.equal(testMoment.month(), 0,
241 'lenient ordinal parsing ' + i + ' month check');
242 assert.equal(testMoment.date(), i,
243 'lenient ordinal parsing ' + i + ' date check');
244 }
245 });
246
247 test('lenient ordinal parsing of number', function (assert) {
248 var i, testMoment;
249 for (i = 1; i <= 31; ++i) {
250 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
251 assert.equal(testMoment.year(), 2014,
252 'lenient ordinal parsing of number ' + i + ' year check');
253 assert.equal(testMoment.month(), 0,
254 'lenient ordinal parsing of number ' + i + ' month check');
255 assert.equal(testMoment.date(), i,
256 'lenient ordinal parsing of number ' + i + ' date check');
257 }
258 });
259
260 test('meridiem invariant', function (assert) {
261 var h, m, t1, t2;
262 for (h = 0; h < 24; ++h) {
263 for (m = 0; m < 60; m += 15) {
264 t1 = moment.utc([2000, 0, 1, h, m]);
265 t2 = moment(t1.format('A h:mm'), 'A h:mm');
266 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
267 'meridiem at ' + t1.format('HH:mm'));
268 }
269 }
270 });
271
272 test('strict ordinal parsing', function (assert) {
273 var i, ordinalStr, testMoment;
274 for (i = 1; i <= 31; ++i) {
275 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
276 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
277 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
278 }
279 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('is');
3
4 test('parse', function (assert) {
5 var tests = 'janúar jan_febrúar feb_mars mar_apríl apr_maí maí_júní jún_júlí júl_ágúst ágú_september sep_október okt_nóvember nóv_desember des'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'sunnudagur, 14. febrúar 2010, 3:25:50 pm'],
25 ['ddd, hA', 'sun, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 febrúar feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. sunnudagur sun Su'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14. febrúar 2010'],
41 ['LLL', '14. febrúar 2010 kl. 15:25'],
42 ['LLLL', 'sunnudagur, 14. febrúar 2010 kl. 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14. feb 2010'],
45 ['lll', '14. feb 2010 kl. 15:25'],
46 ['llll', 'sun, 14. feb 2010 kl. 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'janúar jan_febrúar feb_mars mar_apríl apr_maí maí_júní jún_júlí júl_ágúst ágú_september sep_október okt_nóvember nóv_desember des'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'sunnudagur sun Su_mánudagur mán Má_þriðjudagur þri Þr_miðvikudagur mið Mi_fimmtudagur fim Fi_föstudagur fös Fö_laugardagur lau La'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nokkrar sekúndur', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'mínúta', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'mínúta', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 mínútur', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 mínútur', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 21}), true), '21 mínúta', '21 minutes = 21 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'klukkustund', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'klukkustund', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 klukkustundir', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 klukkustundir', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 klukkustund', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dagur', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dagur', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dagur', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 dagar', '11 days = 11 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 dagur', '21 days = 21 days');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mánuður', '26 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mánuður', '30 days = a month');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mánuður', '43 days = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mánuðir', '46 days = 2 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mánuðir', '75 days = 2 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mánuðir', '76 days = 3 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mánuður', '1 month = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mánuðir', '5 months = 5 months');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ár', '345 days = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ár', '548 days = 2 years');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ár', '1 year = a year');
138 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ár', '5 years = 5 years');
139 assert.equal(start.from(moment([2007, 1, 28]).add({y: 21}), true), '21 ár', '21 years = 21 years');
140 });
141
142 test('suffix', function (assert) {
143 assert.equal(moment(30000).from(0), 'eftir nokkrar sekúndur', 'prefix');
144 assert.equal(moment(0).from(30000), 'fyrir nokkrum sekúndum síðan', 'suffix');
145 assert.equal(moment().subtract({m: 1}).fromNow(), 'fyrir mínútu síðan', 'a minute ago');
146 });
147
148 test('now from now', function (assert) {
149 assert.equal(moment().fromNow(), 'fyrir nokkrum sekúndum síðan', 'now from now should display as in the past');
150 });
151
152 test('fromNow', function (assert) {
153 assert.equal(moment().add({s: 30}).fromNow(), 'eftir nokkrar sekúndur', 'in a few seconds');
154 assert.equal(moment().add({m: 1}).fromNow(), 'eftir mínútu', 'in a minute');
155 assert.equal(moment().add({d: 5}).fromNow(), 'eftir 5 daga', 'in 5 days');
156 });
157
158 test('calendar day', function (assert) {
159 var a = moment().hours(2).minutes(0).seconds(0);
160
161 assert.equal(moment(a).calendar(), 'í dag kl. 2:00', 'today at the same time');
162 assert.equal(moment(a).add({m: 25}).calendar(), 'í dag kl. 2:25', 'Now plus 25 min');
163 assert.equal(moment(a).add({h: 1}).calendar(), 'í dag kl. 3:00', 'Now plus 1 hour');
164 assert.equal(moment(a).add({d: 1}).calendar(), 'á morgun kl. 2:00', 'tomorrow at the same time');
165 assert.equal(moment(a).subtract({h: 1}).calendar(), 'í dag kl. 1:00', 'Now minus 1 hour');
166 assert.equal(moment(a).subtract({d: 1}).calendar(), 'í gær kl. 2:00', 'yesterday at the same time');
167 });
168
169 test('calendar next week', function (assert) {
170 var i, m;
171 for (i = 2; i < 7; i++) {
172 m = moment().add({d: i});
173 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days current time');
174 m.hours(0).minutes(0).seconds(0).milliseconds(0);
175 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days beginning of day');
176 m.hours(23).minutes(59).seconds(59).milliseconds(999);
177 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days end of day');
178 }
179 });
180
181 test('calendar last week', function (assert) {
182 var i, m;
183
184 for (i = 2; i < 7; i++) {
185 m = moment().subtract({d: i});
186 assert.equal(m.calendar(), m.format('[síðasta] dddd [kl.] LT'), 'Today - ' + i + ' days current time');
187 m.hours(0).minutes(0).seconds(0).milliseconds(0);
188 assert.equal(m.calendar(), m.format('[síðasta] dddd [kl.] LT'), 'Today - ' + i + ' days beginning of day');
189 m.hours(23).minutes(59).seconds(59).milliseconds(999);
190 assert.equal(m.calendar(), m.format('[síðasta] dddd [kl.] LT'), 'Today - ' + i + ' days end of day');
191 }
192 });
193
194 test('calendar all else', function (assert) {
195 var weeksAgo = moment().subtract({w: 1}),
196 weeksFromNow = moment().add({w: 1});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
200
201 weeksAgo = moment().subtract({w: 2});
202 weeksFromNow = moment().add({w: 2});
203
204 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
205 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
206 });
207
208 test('weeks year starting sunday', function (assert) {
209 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
210 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
211 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
212 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
213 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
214 });
215
216 test('weeks year starting monday', function (assert) {
217 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
218 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
219 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
220 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
221 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
222 });
223
224 test('weeks year starting tuesday', function (assert) {
225 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
226 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
227 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
228 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
229 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
230 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
231 });
232
233 test('weeks year starting wednesday', function (assert) {
234 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
235 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
236 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
237 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
238 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
239 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
240 });
241
242 test('weeks year starting thursday', function (assert) {
243 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
244 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
245 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
246 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
247 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
248 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
249 });
250
251 test('weeks year starting friday', function (assert) {
252 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
253 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
254 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
255 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
256 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
257 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
258 });
259
260 test('weeks year starting saturday', function (assert) {
261 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
262 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
263 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
264 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
265 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
266 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
267 });
268
269 test('weeks year starting sunday formatted', function (assert) {
270 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
271 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
272 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
273 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
274 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
275 });
276
277 test('lenient ordinal parsing', function (assert) {
278 var i, ordinalStr, testMoment;
279 for (i = 1; i <= 31; ++i) {
280 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
281 testMoment = moment(ordinalStr, 'YYYY MM Do');
282 assert.equal(testMoment.year(), 2014,
283 'lenient ordinal parsing ' + i + ' year check');
284 assert.equal(testMoment.month(), 0,
285 'lenient ordinal parsing ' + i + ' month check');
286 assert.equal(testMoment.date(), i,
287 'lenient ordinal parsing ' + i + ' date check');
288 }
289 });
290
291 test('lenient ordinal parsing of number', function (assert) {
292 var i, testMoment;
293 for (i = 1; i <= 31; ++i) {
294 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
295 assert.equal(testMoment.year(), 2014,
296 'lenient ordinal parsing of number ' + i + ' year check');
297 assert.equal(testMoment.month(), 0,
298 'lenient ordinal parsing of number ' + i + ' month check');
299 assert.equal(testMoment.date(), i,
300 'lenient ordinal parsing of number ' + i + ' date check');
301 }
302 });
303
304 test('strict ordinal parsing', function (assert) {
305 var i, ordinalStr, testMoment;
306 for (i = 1; i <= 31; ++i) {
307 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
308 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
309 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
310 }
311 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('it');
3
4 test('parse', function (assert) {
5 var tests = 'gennaio gen_febbraio feb_marzo mar_aprile apr_maggio mag_giugno giu_luglio lug_agosto ago_settembre set_ottobre ott_novembre nov_dicembre dic'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domenica, febbraio 14º 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Dom, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2º 02 febbraio feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14º 14'],
29 ['d do dddd ddd dd', '0 0º Domenica Dom D'],
30 ['DDD DDDo DDDD', '45 45º 045'],
31 ['w wo ww', '6 6º 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 febbraio 2010'],
41 ['LLL', '14 febbraio 2010 15:25'],
42 ['LLLL', 'Domenica, 14 febbraio 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 feb 2010'],
45 ['lll', '14 feb 2010 15:25'],
46 ['llll', 'Dom, 14 feb 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'gennaio gen_febbraio feb_marzo mar_aprile apr_maggio mag_giugno giu_luglio lug_agosto ago_settembre set_ottobre ott_novembre nov_dicembre dic'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Domenica Dom D_Lunedì Lun L_Martedì Mar Ma_Mercoledì Mer Me_Giovedì Gio G_Venerdì Ven V_Sabato Sab S'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'alcuni secondi', '44 seconds = seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minuto', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minuto', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuti', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuti', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'un\'ora', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'un\'ora', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ore', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ore', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ore', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'un giorno', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'un giorno', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 giorni', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'un giorno', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 giorni', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 giorni', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'un mese', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'un mese', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'un mese', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesi', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesi', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesi', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'un mese', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesi', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un anno', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anni', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un anno', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anni', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'in alcuni secondi', 'prefix');
140 assert.equal(moment(0).from(30000), 'alcuni secondi fa', 'suffix');
141 });
142
143 test('fromNow', function (assert) {
144 assert.equal(moment().add({s: 30}).fromNow(), 'in alcuni secondi', 'in seconds');
145 assert.equal(moment().add({d: 5}).fromNow(), 'tra 5 giorni', 'in 5 days');
146 });
147
148 test('calendar day', function (assert) {
149 var a = moment().hours(2).minutes(0).seconds(0);
150
151 assert.equal(moment(a).calendar(), 'Oggi alle 02:00', 'today at the same time');
152 assert.equal(moment(a).add({m: 25}).calendar(), 'Oggi alle 02:25', 'Now plus 25 min');
153 assert.equal(moment(a).add({h: 1}).calendar(), 'Oggi alle 03:00', 'Now plus 1 hour');
154 assert.equal(moment(a).add({d: 1}).calendar(), 'Domani alle 02:00', 'tomorrow at the same time');
155 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Oggi alle 01:00', 'Now minus 1 hour');
156 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ieri alle 02:00', 'yesterday at the same time');
157 });
158
159 test('calendar next week', function (assert) {
160 var i, m;
161 for (i = 2; i < 7; i++) {
162 m = moment().add({d: i});
163 assert.equal(m.calendar(), m.format('dddd [alle] LT'), 'Today + ' + i + ' days current time');
164 m.hours(0).minutes(0).seconds(0).milliseconds(0);
165 assert.equal(m.calendar(), m.format('dddd [alle] LT'), 'Today + ' + i + ' days beginning of day');
166 m.hours(23).minutes(59).seconds(59).milliseconds(999);
167 assert.equal(m.calendar(), m.format('dddd [alle] LT'), 'Today + ' + i + ' days end of day');
168 }
169 });
170
171 test('calendar last week', function (assert) {
172 var i, m, weekday, datestring;
173 for (i = 2; i < 7; i++) {
174 m = moment().subtract({d: i});
175 // Different date string
176 weekday = parseInt(m.format('d'), 10);
177 datestring = (weekday === 0) ? '[la scorsa] dddd [alle] LT' : '[lo scorso] dddd [alle] LT';
178 assert.equal(m.calendar(), m.format(datestring), 'Today - ' + i + ' days current time');
179 m.hours(0).minutes(0).seconds(0).milliseconds(0);
180 assert.equal(m.calendar(), m.format(datestring), 'Today - ' + i + ' days beginning of day');
181 m.hours(23).minutes(59).seconds(59).milliseconds(999);
182 assert.equal(m.calendar(), m.format(datestring), 'Today - ' + i + ' days end of day');
183 }
184 });
185
186 test('calendar all else', function (assert) {
187 var weeksAgo = moment().subtract({w: 1}),
188 weeksFromNow = moment().add({w: 1});
189
190 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
191 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
192
193 weeksAgo = moment().subtract({w: 2});
194 weeksFromNow = moment().add({w: 2});
195
196 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
197 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
198 });
199
200 test('weeks year starting sunday', function (assert) {
201 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
202 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
203 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
204 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
205 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
206 });
207
208 test('weeks year starting monday', function (assert) {
209 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
210 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
211 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
212 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
213 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
214 });
215
216 test('weeks year starting tuesday', function (assert) {
217 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
218 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
219 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
220 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
221 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
222 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
223 });
224
225 test('weeks year starting wednesday', function (assert) {
226 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
227 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
228 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
229 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
230 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
231 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
232 });
233
234 test('weeks year starting thursday', function (assert) {
235 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
236 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
237 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
238 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
239 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
240 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
241 });
242
243 test('weeks year starting friday', function (assert) {
244 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
245 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
246 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
247 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
248 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
249 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
250 });
251
252 test('weeks year starting saturday', function (assert) {
253 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
254 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
255 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
256 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
257 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
258 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
259 });
260
261 test('weeks year starting sunday formatted', function (assert) {
262 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
263 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
264 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', 'Jan 8 2012 should be week 1');
265 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2');
266 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
267 });
268
269 test('lenient ordinal parsing', function (assert) {
270 var i, ordinalStr, testMoment;
271 for (i = 1; i <= 31; ++i) {
272 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
273 testMoment = moment(ordinalStr, 'YYYY MM Do');
274 assert.equal(testMoment.year(), 2014,
275 'lenient ordinal parsing ' + i + ' year check');
276 assert.equal(testMoment.month(), 0,
277 'lenient ordinal parsing ' + i + ' month check');
278 assert.equal(testMoment.date(), i,
279 'lenient ordinal parsing ' + i + ' date check');
280 }
281 });
282
283 test('lenient ordinal parsing of number', function (assert) {
284 var i, testMoment;
285 for (i = 1; i <= 31; ++i) {
286 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
287 assert.equal(testMoment.year(), 2014,
288 'lenient ordinal parsing of number ' + i + ' year check');
289 assert.equal(testMoment.month(), 0,
290 'lenient ordinal parsing of number ' + i + ' month check');
291 assert.equal(testMoment.date(), i,
292 'lenient ordinal parsing of number ' + i + ' date check');
293 }
294 });
295
296 test('strict ordinal parsing', function (assert) {
297 var i, ordinalStr, testMoment;
298 for (i = 1; i <= 31; ++i) {
299 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
300 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
301 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
302 }
303 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ja');
3
4 test('parse', function (assert) {
5 var tests = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14 2010, 午後 3:25:50'],
25 ['ddd, Ah', '日, 午後3'],
26 ['M Mo MM MMMM MMM', '2 2 02 2月 2月'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 日曜日 日 日'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '8 8 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', '午後 午後'],
37 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
38 ['LTS', '午後3時25分50秒'],
39 ['L', '2010/02/14'],
40 ['LL', '2010年2月14日'],
41 ['LLL', '2010年2月14日午後3時25分'],
42 ['LLLL', '2010年2月14日午後3時25分 日曜日'],
43 ['l', '2010/2/14'],
44 ['ll', '2010年2月14日'],
45 ['lll', '2010年2月14日午後3時25分'],
46 ['llll', '2010年2月14日午後3時25分 日']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format month', function (assert) {
56 var expected = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split('_'), i;
57 for (i = 0; i < expected.length; i++) {
58 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
59 }
60 });
61
62 test('format week', function (assert) {
63 var expected = '日曜日 日 日_月曜日 月 月_火曜日 火 火_水曜日 水 水_木曜日 木 木_金曜日 金 金_土曜日 土 土'.split('_'), i;
64 for (i = 0; i < expected.length; i++) {
65 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
66 }
67 });
68
69 test('from', function (assert) {
70 var start = moment([2007, 1, 28]);
71 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '数秒', '44 seconds = a few seconds');
72 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1分', '45 seconds = a minute');
73 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1分', '89 seconds = a minute');
74 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2分', '90 seconds = 2 minutes');
75 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44分', '44 minutes = 44 minutes');
76 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1時間', '45 minutes = an hour');
77 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1時間', '89 minutes = an hour');
78 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2時間', '90 minutes = 2 hours');
79 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5時間', '5 hours = 5 hours');
80 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21時間', '21 hours = 21 hours');
81 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1日', '22 hours = a day');
82 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1日', '35 hours = a day');
83 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2日', '36 hours = 2 days');
84 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1日', '1 day = a day');
85 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5日', '5 days = 5 days');
86 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25日', '25 days = 25 days');
87 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1ヶ月', '26 days = a month');
88 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1ヶ月', '30 days = a month');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1ヶ月', '43 days = a month');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2ヶ月', '46 days = 2 months');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2ヶ月', '75 days = 2 months');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3ヶ月', '76 days = 3 months');
93 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1ヶ月', '1 month = a month');
94 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5ヶ月', '5 months = 5 months');
95 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1年', '345 days = a year');
96 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2年', '548 days = 2 years');
97 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1年', '1 year = a year');
98 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5年', '5 years = 5 years');
99 });
100
101 test('suffix', function (assert) {
102 assert.equal(moment(30000).from(0), '数秒後', 'prefix');
103 assert.equal(moment(0).from(30000), '数秒前', 'suffix');
104 });
105
106 test('now from now', function (assert) {
107 assert.equal(moment().fromNow(), '数秒前', 'now from now should display as in the past');
108 });
109
110 test('fromNow', function (assert) {
111 assert.equal(moment().add({s: 30}).fromNow(), '数秒後', 'in a few seconds');
112 assert.equal(moment().add({d: 5}).fromNow(), '5日後', 'in 5 days');
113 });
114
115 test('calendar day', function (assert) {
116 var a = moment().hours(2).minutes(0).seconds(0);
117
118 assert.equal(moment(a).calendar(), '今日 午前2時0分', 'today at the same time');
119 assert.equal(moment(a).add({m: 25}).calendar(), '今日 午前2時25分', 'Now plus 25 min');
120 assert.equal(moment(a).add({h: 1}).calendar(), '今日 午前3時0分', 'Now plus 1 hour');
121 assert.equal(moment(a).add({d: 1}).calendar(), '明日 午前2時0分', 'tomorrow at the same time');
122 assert.equal(moment(a).subtract({h: 1}).calendar(), '今日 午前1時0分', 'Now minus 1 hour');
123 assert.equal(moment(a).subtract({d: 1}).calendar(), '昨日 午前2時0分', 'yesterday at the same time');
124 });
125
126 test('calendar next week', function (assert) {
127 var i, m;
128 for (i = 2; i < 7; i++) {
129 m = moment().add({d: i});
130 assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days current time');
131 m.hours(0).minutes(0).seconds(0).milliseconds(0);
132 assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days beginning of day');
133 m.hours(23).minutes(59).seconds(59).milliseconds(999);
134 assert.equal(m.calendar(), m.format('[来週]dddd LT'), 'Today + ' + i + ' days end of day');
135 }
136 });
137
138 test('calendar last week', function (assert) {
139 var i, m;
140 for (i = 2; i < 7; i++) {
141 m = moment().subtract({d: i});
142 assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days current time');
143 m.hours(0).minutes(0).seconds(0).milliseconds(0);
144 assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days beginning of day');
145 m.hours(23).minutes(59).seconds(59).milliseconds(999);
146 assert.equal(m.calendar(), m.format('[前週]dddd LT'), 'Today - ' + i + ' days end of day');
147 }
148 });
149
150 test('calendar all else', function (assert) {
151 var weeksAgo = moment().subtract({w: 1}),
152 weeksFromNow = moment().add({w: 1});
153
154 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
155 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
156
157 weeksAgo = moment().subtract({w: 2});
158 weeksFromNow = moment().add({w: 2});
159
160 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
161 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
162 });
163
164 test('weeks year starting sunday', function (assert) {
165 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
166 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
167 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
168 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
169 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
170 });
171
172 test('weeks year starting monday', function (assert) {
173 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
174 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
175 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
176 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
177 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
178 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
179 });
180
181 test('weeks year starting tuesday', function (assert) {
182 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
183 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
184 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
185 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
186 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
187 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
188 });
189
190 test('weeks year starting wednesday', function (assert) {
191 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
192 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
193 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
194 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
195 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
196 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
197 });
198
199 test('weeks year starting thursday', function (assert) {
200 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
201 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
202 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
203 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
204 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
205 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
206 });
207
208 test('weeks year starting friday', function (assert) {
209 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
210 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
211 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
212 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
213 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
214 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
215 });
216
217 test('weeks year starting saturday', function (assert) {
218 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
219 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
220 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
221 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
222 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
223 });
224
225 test('weeks year starting sunday format', function (assert) {
226 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
227 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
228 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
229 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
230 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
231 });
232
233 test('lenient ordinal parsing', function (assert) {
234 var i, ordinalStr, testMoment;
235 for (i = 1; i <= 31; ++i) {
236 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
237 testMoment = moment(ordinalStr, 'YYYY MM Do');
238 assert.equal(testMoment.year(), 2014,
239 'lenient ordinal parsing ' + i + ' year check');
240 assert.equal(testMoment.month(), 0,
241 'lenient ordinal parsing ' + i + ' month check');
242 assert.equal(testMoment.date(), i,
243 'lenient ordinal parsing ' + i + ' date check');
244 }
245 });
246
247 test('lenient ordinal parsing of number', function (assert) {
248 var i, testMoment;
249 for (i = 1; i <= 31; ++i) {
250 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
251 assert.equal(testMoment.year(), 2014,
252 'lenient ordinal parsing of number ' + i + ' year check');
253 assert.equal(testMoment.month(), 0,
254 'lenient ordinal parsing of number ' + i + ' month check');
255 assert.equal(testMoment.date(), i,
256 'lenient ordinal parsing of number ' + i + ' date check');
257 }
258 });
259
260 test('strict ordinal parsing', function (assert) {
261 var i, ordinalStr, testMoment;
262 for (i = 1; i <= 31; ++i) {
263 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
264 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
265 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
266 }
267 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('jv');
3
4
5 test('parse', function (assert) {
6 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;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Minggu, Februari 14 2010, 3:25:50 sonten'],
26 ['ddd, hA', 'Min, 3sonten'],
27 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14 14'],
30 ['d do dddd ddd dd', '0 0 Minggu Min Mg'],
31 ['DDD DDDo DDDD', '45 45 045'],
32 ['w wo ww', '7 7 07'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'sonten sonten'],
38 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
39 ['LTS', '15.25.50'],
40 ['L', '14/02/2010'],
41 ['LL', '14 Februari 2010'],
42 ['LLL', '14 Februari 2010 pukul 15.25'],
43 ['LLLL', 'Minggu, 14 Februari 2010 pukul 15.25'],
44 ['l', '14/2/2010'],
45 ['ll', '14 Feb 2010'],
46 ['lll', '14 Feb 2010 pukul 15.25'],
47 ['llll', 'Min, 14 Feb 2010 pukul 15.25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format month', function (assert) {
57 var expected = '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;
58 for (i = 0; i < expected.length; i++) {
59 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
60 }
61 });
62
63 test('format week', function (assert) {
64 var expected = 'Minggu Min Mg_Senen Sen Sn_Seloso Sel Sl_Rebu Reb Rb_Kemis Kem Km_Jemuwah Jem Jm_Septu Sep Sp'.split('_'), i;
65 for (i = 0; i < expected.length; i++) {
66 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
67 }
68 });
69
70 test('from', function (assert) {
71 var start = moment([2007, 1, 28]);
72 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'sawetawis detik', '44 seconds = a few seconds');
73 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'setunggal menit', '45 seconds = a minute');
74 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'setunggal menit', '89 seconds = a minute');
75 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 menit', '90 seconds = 2 minutes');
76 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 menit', '44 minutes = 44 minutes');
77 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'setunggal jam', '45 minutes = an hour');
78 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'setunggal jam', '89 minutes = an hour');
79 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minutes = 2 hours');
80 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 hours = 5 hours');
81 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 hours = 21 hours');
82 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sedinten', '22 hours = a day');
83 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sedinten', '35 hours = a day');
84 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dinten', '36 hours = 2 days');
85 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sedinten', '1 day = a day');
86 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dinten', '5 days = 5 days');
87 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dinten', '25 days = 25 days');
88 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sewulan', '26 days = a month');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sewulan', '30 days = a month');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sewulan', '43 days = a month');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 wulan', '46 days = 2 months');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 wulan', '75 days = 2 months');
93 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 wulan', '76 days = 3 months');
94 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sewulan', '1 month = a month');
95 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 wulan', '5 months = 5 months');
96 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setaun', '345 days = a year');
97 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 taun', '548 days = 2 years');
98 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setaun', '1 year = a year');
99 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 taun', '5 years = 5 years');
100 });
101
102 test('suffix', function (assert) {
103 assert.equal(moment(30000).from(0), 'wonten ing sawetawis detik', 'prefix');
104 assert.equal(moment(0).from(30000), 'sawetawis detik ingkang kepengker', 'suffix');
105 });
106
107 test('now from now', function (assert) {
108 assert.equal(moment().fromNow(), 'sawetawis detik ingkang kepengker', 'now from now should display as in the past');
109 });
110
111 test('fromNow', function (assert) {
112 assert.equal(moment().add({s: 30}).fromNow(), 'wonten ing sawetawis detik', 'in a few seconds');
113 assert.equal(moment().add({d: 5}).fromNow(), 'wonten ing 5 dinten', 'in 5 days');
114 });
115
116 test('calendar day', function (assert) {
117 var a = moment().hours(2).minutes(0).seconds(0);
118
119 assert.equal(moment(a).calendar(), 'Dinten puniko pukul 02.00', 'today at the same time');
120 assert.equal(moment(a).add({m: 25}).calendar(), 'Dinten puniko pukul 02.25', 'Now plus 25 min');
121 assert.equal(moment(a).add({h: 1}).calendar(), 'Dinten puniko pukul 03.00', 'Now plus 1 hour');
122 assert.equal(moment(a).add({d: 1}).calendar(), 'Mbenjang pukul 02.00', 'tomorrow at the same time');
123 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dinten puniko pukul 01.00', 'Now minus 1 hour');
124 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kala wingi pukul 02.00', 'yesterday at the same time');
125 });
126
127 test('calendar next week', function (assert) {
128 var i, m;
129 for (i = 2; i < 7; i++) {
130 m = moment().add({d: i});
131 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days current time');
132 m.hours(0).minutes(0).seconds(0).milliseconds(0);
133 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days beginning of day');
134 m.hours(23).minutes(59).seconds(59).milliseconds(999);
135 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Today + ' + i + ' days end of day');
136 }
137 });
138
139 test('calendar last week', function (assert) {
140 var i, m;
141 for (i = 2; i < 7; i++) {
142 m = moment().subtract({d: i});
143 assert.equal(m.calendar(), m.format('dddd [kepengker pukul] LT'), 'Today - ' + i + ' days current time');
144 m.hours(0).minutes(0).seconds(0).milliseconds(0);
145 assert.equal(m.calendar(), m.format('dddd [kepengker pukul] LT'), 'Today - ' + i + ' days beginning of day');
146 m.hours(23).minutes(59).seconds(59).milliseconds(999);
147 assert.equal(m.calendar(), m.format('dddd [kepengker pukul] LT'), 'Today - ' + i + ' days end of day');
148 }
149 });
150
151 test('calendar all else', function (assert) {
152 var weeksAgo = moment().subtract({w: 1}),
153 weeksFromNow = moment().add({w: 1});
154
155 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
156 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
157
158 weeksAgo = moment().subtract({w: 2});
159 weeksFromNow = moment().add({w: 2});
160
161 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
162 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
163 });
164
165 // Monday is the first day of the week.
166 // The week that contains Jan 1st is the first week of the year.
167
168 test('weeks year starting sunday', function (assert) {
169 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
170 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
171 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
172 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
173 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
174 });
175
176 test('weeks year starting monday', function (assert) {
177 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
178 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
179 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
180 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
181 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
182 });
183
184 test('weeks year starting tuesday', function (assert) {
185 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
186 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
187 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
188 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
189 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
190 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
191 });
192
193 test('weeks year starting wednesday', function (assert) {
194 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
195 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
196 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
197 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
198 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
199 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
200 });
201
202 test('weeks year starting thursday', function (assert) {
203 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
204 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
205 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
206 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
207 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
208 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
209 });
210
211 test('weeks year starting friday', function (assert) {
212 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
213 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
214 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
215 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
216 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
217 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
218 });
219
220 test('weeks year starting saturday', function (assert) {
221 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
222 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
223 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
224 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
225 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
226 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
227 });
228
229 test('weeks year starting sunday formatted', function (assert) {
230 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
231 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
232 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 2');
233 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
234 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
235 });
236
237 test('lenient ordinal parsing', function (assert) {
238 var i, ordinalStr, testMoment;
239 for (i = 1; i <= 31; ++i) {
240 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
241 testMoment = moment(ordinalStr, 'YYYY MM Do');
242 assert.equal(testMoment.year(), 2014,
243 'lenient ordinal parsing ' + i + ' year check');
244 assert.equal(testMoment.month(), 0,
245 'lenient ordinal parsing ' + i + ' month check');
246 assert.equal(testMoment.date(), i,
247 'lenient ordinal parsing ' + i + ' date check');
248 }
249 });
250
251 test('lenient ordinal parsing of number', function (assert) {
252 var i, testMoment;
253 for (i = 1; i <= 31; ++i) {
254 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
255 assert.equal(testMoment.year(), 2014,
256 'lenient ordinal parsing of number ' + i + ' year check');
257 assert.equal(testMoment.month(), 0,
258 'lenient ordinal parsing of number ' + i + ' month check');
259 assert.equal(testMoment.date(), i,
260 'lenient ordinal parsing of number ' + i + ' date check');
261 }
262 });
263
264 test('meridiem invariant', function (assert) {
265 var h, m, t1, t2;
266 for (h = 0; h < 24; ++h) {
267 for (m = 0; m < 60; m += 15) {
268 t1 = moment.utc([2000, 0, 1, h, m]);
269 t2 = moment(t1.format('A h:mm'), 'A h:mm');
270 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
271 'meridiem at ' + t1.format('HH:mm'));
272 }
273 }
274 });
275
276 test('strict ordinal parsing', function (assert) {
277 var i, ordinalStr, testMoment;
278 for (i = 1; i <= 31; ++i) {
279 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
280 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
281 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
282 }
283 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ka');
3
4 test('parse', function (assert) {
5 var i,
6 tests = 'იანვარი იან_თებერვალი თებ_მარტი მარ_აპრილი აპრ_მაისი მაი_ივნისი ივნ_ივლისი ივლ_აგვისტო აგვ_სექტემბერი სექ_ოქტომბერი ოქტ_ნოემბერი ნოე_დეკემბერი დეკ'.split('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' უნდა იყოს თვე ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, h:mm:ss a', 'კვირა, თებერვალი მე-14 2010, 3:25:50 pm'],
28 ['ddd, hA', 'კვი, 3PM'],
29 ['M Mo MM MMMM MMM', '2 მე-2 02 თებერვალი თებ'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 მე-14 14'],
32 ['d do dddd ddd dd', '0 0 კვირა კვი კვ'],
33 ['DDD DDDo DDDD', '45 45-ე 045'],
34 ['w wo ww', '7 მე-7 07'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'pm PM'],
40 ['წლის DDDo დღე', 'წლის 45-ე დღე'],
41 ['LTS', '3:25:50 PM'],
42 ['L', '14/02/2010'],
43 ['LL', '14 თებერვალი 2010'],
44 ['LLL', '14 თებერვალი 2010 3:25 PM'],
45 ['LLLL', 'კვირა, 14 თებერვალი 2010 3:25 PM'],
46 ['l', '14/2/2010'],
47 ['ll', '14 თებ 2010'],
48 ['lll', '14 თებ 2010 3:25 PM'],
49 ['llll', 'კვი, 14 თებ 2010 3:25 PM']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format ordinal', function (assert) {
60 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ლი', '1-ლი');
61 assert.equal(moment([2011, 0, 2]).format('DDDo'), 'მე-2', 'მე-2');
62 assert.equal(moment([2011, 0, 3]).format('DDDo'), 'მე-3', 'მე-3');
63 assert.equal(moment([2011, 0, 4]).format('DDDo'), 'მე-4', 'მე-4');
64 assert.equal(moment([2011, 0, 5]).format('DDDo'), 'მე-5', 'მე-5');
65 assert.equal(moment([2011, 0, 6]).format('DDDo'), 'მე-6', 'მე-6');
66 assert.equal(moment([2011, 0, 7]).format('DDDo'), 'მე-7', 'მე-7');
67 assert.equal(moment([2011, 0, 8]).format('DDDo'), 'მე-8', 'მე-8');
68 assert.equal(moment([2011, 0, 9]).format('DDDo'), 'მე-9', 'მე-9');
69 assert.equal(moment([2011, 0, 10]).format('DDDo'), 'მე-10', 'მე-10');
70
71 assert.equal(moment([2011, 0, 11]).format('DDDo'), 'მე-11', 'მე-11');
72 assert.equal(moment([2011, 0, 12]).format('DDDo'), 'მე-12', 'მე-12');
73 assert.equal(moment([2011, 0, 13]).format('DDDo'), 'მე-13', 'მე-13');
74 assert.equal(moment([2011, 0, 14]).format('DDDo'), 'მე-14', 'მე-14');
75 assert.equal(moment([2011, 0, 15]).format('DDDo'), 'მე-15', 'მე-15');
76 assert.equal(moment([2011, 0, 16]).format('DDDo'), 'მე-16', 'მე-16');
77 assert.equal(moment([2011, 0, 17]).format('DDDo'), 'მე-17', 'მე-17');
78 assert.equal(moment([2011, 0, 18]).format('DDDo'), 'მე-18', 'მე-18');
79 assert.equal(moment([2011, 0, 19]).format('DDDo'), 'მე-19', 'მე-19');
80 assert.equal(moment([2011, 0, 20]).format('DDDo'), 'მე-20', 'მე-20');
81
82 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ე', '21-ე');
83 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-ე', '22-ე');
84 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-ე', '23-ე');
85 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ე', '24-ე');
86 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ე', '25-ე');
87 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ე', '26-ე');
88 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ე', '27-ე');
89 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ე', '28-ე');
90 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ე', '29-ე');
91 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ე', '30-ე');
92
93 assert.equal(moment('2011 40', 'YYYY DDD').format('DDDo'), 'მე-40', 'მე-40');
94 assert.equal(moment('2011 50', 'YYYY DDD').format('DDDo'), '50-ე', '50-ე');
95 assert.equal(moment('2011 60', 'YYYY DDD').format('DDDo'), 'მე-60', 'მე-60');
96 assert.equal(moment('2011 100', 'YYYY DDD').format('DDDo'), 'მე-100', 'მე-100');
97 assert.equal(moment('2011 101', 'YYYY DDD').format('DDDo'), '101-ე', '101-ე');
98 });
99
100 test('format month', function (assert) {
101 var i,
102 expected = 'იანვარი იან_თებერვალი თებ_მარტი მარ_აპრილი აპრ_მაისი მაი_ივნისი ივნ_ივლისი ივლ_აგვისტო აგვ_სექტემბერი სექ_ოქტომბერი ოქტ_ნოემბერი ნოე_დეკემბერი დეკ'.split('_');
103
104 for (i = 0; i < expected.length; i++) {
105 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
106 }
107 });
108
109 test('format week', function (assert) {
110 var i,
111 expected = 'კვირა კვი კვ_ორშაბათი ორშ ორ_სამშაბათი სამ სა_ოთხშაბათი ოთხ ოთ_ხუთშაბათი ხუთ ხუ_პარასკევი პარ პა_შაბათი შაბ შა'.split('_');
112
113 for (i = 0; i < expected.length; i++) {
114 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
115 }
116 });
117
118 test('from', function (assert) {
119 var start = moment([2007, 1, 28]);
120
121 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'რამდენიმე წამი', '44 წამი = რამდენიმე წამი');
122 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'წუთი', '45 წამი = წუთი');
123 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'წუთი', '89 წამი = წუთი');
124 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 წუთი', '90 წამი = 2 წუთი');
125 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 წუთი', '44 წამი = 44 წუთი');
126 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'საათი', '45 წამი = საათი');
127 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'საათი', '89 წამი = საათი');
128 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 საათი', '90 წამი = 2 საათი');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 საათი', '5 საათი = 5 საათი');
130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 საათი', '21 საათი = 21 საათი');
131 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'დღე', '22 საათი = დღე');
132 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'დღე', '35 საათი = დღე');
133 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 დღე', '36 საათი = 2 დღე');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'დღე', '1 დღე = დღე');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 დღე', '5 დღე = 5 დღე');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 დღე', '25 დღე = 25 დღე');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'თვე', '26 დღე = თვე');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'თვე', '30 დღე = თვე');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'თვე', '45 დღე = თვე');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 თვე', '46 დღე = 2 თვე');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 თვე', '75 დღე = 2 თვე');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 თვე', '76 დღე = 3 თვე');
143 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'თვე', '1 თვე = თვე');
144 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 თვე', '5 თვე = 5 თვე');
145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'წელი', '345 დღე = წელი');
146 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 წელი', '548 დღე = 2 წელი');
147 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'წელი', '1 წელი = წელი');
148 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 წელი', '5 წელი = 5 წელი');
149 });
150
151 test('suffix', function (assert) {
152 assert.equal(moment(30000).from(0), 'რამდენიმე წამში', 'ში სუფიქსი');
153 assert.equal(moment(0).from(30000), 'რამდენიმე წამის წინ', 'წინ სუფიქსი');
154 });
155
156 test('now from now', function (assert) {
157 assert.equal(moment().fromNow(), 'რამდენიმე წამის წინ', 'უნდა აჩვენოს როგორც წარსული');
158 });
159
160 test('fromNow', function (assert) {
161 assert.equal(moment().add({s: 30}).fromNow(), 'რამდენიმე წამში', 'რამდენიმე წამში');
162 assert.equal(moment().add({d: 5}).fromNow(), '5 დღეში', '5 დღეში');
163 });
164
165 test('calendar day', function (assert) {
166 var a = moment().hours(2).minutes(0).seconds(0);
167
168 assert.equal(moment(a).calendar(), 'დღეს 2:00 AM-ზე', 'დღეს ამავე დროს');
169 assert.equal(moment(a).add({m: 25}).calendar(), 'დღეს 2:25 AM-ზე', 'ახლანდელ დროს დამატებული 25 წუთი');
170 assert.equal(moment(a).add({h: 1}).calendar(), 'დღეს 3:00 AM-ზე', 'ახლანდელ დროს დამატებული 1 საათი');
171 assert.equal(moment(a).add({d: 1}).calendar(), 'ხვალ 2:00 AM-ზე', 'ხვალ ამავე დროს');
172 assert.equal(moment(a).subtract({h: 1}).calendar(), 'დღეს 1:00 AM-ზე', 'ახლანდელ დროს გამოკლებული 1 საათი');
173 assert.equal(moment(a).subtract({d: 1}).calendar(), 'გუშინ 2:00 AM-ზე', 'გუშინ ამავე დროს');
174 });
175
176 test('calendar next week', function (assert) {
177 var i, m;
178 for (i = 2; i < 7; i++) {
179 m = moment().add({d: i});
180 assert.equal(m.calendar(), m.format('[შემდეგ] dddd LT[-ზე]'), 'დღეს + ' + i + ' დღე ახლანდელ დროს');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[შემდეგ] dddd LT[-ზე]'), 'დღეს + ' + i + ' დღე დღის დასაწყისში');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[შემდეგ] dddd LT[-ზე]'), 'დღეს + ' + i + ' დღე დღის დასასრულს');
185 }
186 });
187
188 test('calendar last week', function (assert) {
189 var i, m;
190 for (i = 2; i < 7; i++) {
191 m = moment().subtract({d: i});
192 assert.equal(m.calendar(), m.format('[წინა] dddd LT[-ზე]'), 'დღეს - ' + i + ' დღე ახლანდელ დროს');
193 m.hours(0).minutes(0).seconds(0).milliseconds(0);
194 assert.equal(m.calendar(), m.format('[წინა] dddd LT[-ზე]'), 'დღეს - ' + i + ' დღე დღის დასაწყისში');
195 m.hours(23).minutes(59).seconds(59).milliseconds(999);
196 assert.equal(m.calendar(), m.format('[წინა] dddd LT[-ზე]'), 'დღეს - ' + i + ' დღე დღის დასასრულს');
197 }
198 });
199
200 test('calendar all else', function (assert) {
201 var weeksAgo = moment().subtract({w: 1}),
202 weeksFromNow = moment().add({w: 1});
203
204 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 კვირის წინ');
205 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '1 კვირაში');
206
207 weeksAgo = moment().subtract({w: 2});
208 weeksFromNow = moment().add({w: 2});
209
210 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 კვირის წინ');
211 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 კვირაში');
212 });
213
214 test('weeks year starting sunday', function (assert) {
215 assert.equal(moment([2011, 11, 26]).week(), 1, 'დეკ 26 2011 უნდა იყოს კვირა 1');
216 assert.equal(moment([2012, 0, 1]).week(), 1, 'იან 1 2012 უნდა იყოს კვირა 1');
217 assert.equal(moment([2012, 0, 2]).week(), 2, 'იან 2 2012 უნდა იყოს კვირა 2');
218 assert.equal(moment([2012, 0, 8]).week(), 2, 'იან 8 2012 უნდა იყოს კვირა 2');
219 assert.equal(moment([2012, 0, 9]).week(), 3, 'იან 9 2012 უნდა იყოს კვირა 3');
220 });
221
222 test('weeks year starting monday', function (assert) {
223 assert.equal(moment([2007, 0, 1]).week(), 1, 'იან 1 2007 უნდა იყოს კვირა 1');
224 assert.equal(moment([2007, 0, 7]).week(), 1, 'იან 7 2007 უნდა იყოს კვირა 1');
225 assert.equal(moment([2007, 0, 8]).week(), 2, 'იან 8 2007 უნდა იყოს კვირა 2');
226 assert.equal(moment([2007, 0, 14]).week(), 2, 'იან 14 2007 უნდა იყოს კვირა 2');
227 assert.equal(moment([2007, 0, 15]).week(), 3, 'იან 15 2007 უნდა იყოს კვირა 3');
228 });
229
230 test('weeks year starting tuesday', function (assert) {
231 assert.equal(moment([2007, 11, 31]).week(), 1, 'დეკ 31 2007 უნდა იყოს კვირა 1');
232 assert.equal(moment([2008, 0, 1]).week(), 1, 'იან 1 2008 უნდა იყოს კვირა 1');
233 assert.equal(moment([2008, 0, 6]).week(), 1, 'იან 6 2008 უნდა იყოს კვირა 1');
234 assert.equal(moment([2008, 0, 7]).week(), 2, 'იან 7 2008 უნდა იყოს კვირა 2');
235 assert.equal(moment([2008, 0, 13]).week(), 2, 'იან 13 2008 უნდა იყოს კვირა 2');
236 assert.equal(moment([2008, 0, 14]).week(), 3, 'იან 14 2008 უნდა იყოს კვირა 3');
237 });
238
239 test('weeks year starting wednesday', function (assert) {
240 assert.equal(moment([2002, 11, 30]).week(), 1, 'დეკ 30 2002 უნდა იყოს კვირა 1');
241 assert.equal(moment([2003, 0, 1]).week(), 1, 'იან 1 2003 უნდა იყოს კვირა 1');
242 assert.equal(moment([2003, 0, 5]).week(), 1, 'იან 5 2003 უნდა იყოს კვირა 1');
243 assert.equal(moment([2003, 0, 6]).week(), 2, 'იან 6 2003 უნდა იყოს კვირა 2');
244 assert.equal(moment([2003, 0, 12]).week(), 2, 'იან 12 2003 უნდა იყოს კვირა 2');
245 assert.equal(moment([2003, 0, 13]).week(), 3, 'იან 13 2003 უნდა იყოს კვირა 3');
246 });
247
248 test('weeks year starting thursday', function (assert) {
249 assert.equal(moment([2008, 11, 29]).week(), 1, 'დეკ 29 2008 უნდა იყოს კვირა 1');
250 assert.equal(moment([2009, 0, 1]).week(), 1, 'იან 1 2009 უნდა იყოს კვირა 1');
251 assert.equal(moment([2009, 0, 4]).week(), 1, 'იან 4 2009 უნდა იყოს კვირა 1');
252 assert.equal(moment([2009, 0, 5]).week(), 2, 'იან 5 2009 უნდა იყოს კვირა 2');
253 assert.equal(moment([2009, 0, 11]).week(), 2, 'იან 11 2009 უნდა იყოს კვირა 2');
254 assert.equal(moment([2009, 0, 12]).week(), 3, 'იან 12 2009 უნდა იყოს კვირა 3');
255 });
256
257 test('weeks year starting friday', function (assert) {
258 assert.equal(moment([2009, 11, 28]).week(), 1, 'დეკ 28 2009 უნდა იყოს კვირა 1');
259 assert.equal(moment([2010, 0, 1]).week(), 1, 'იან 1 2010 უნდა იყოს კვირა 1');
260 assert.equal(moment([2010, 0, 3]).week(), 1, 'იან 3 2010 უნდა იყოს კვირა 1');
261 assert.equal(moment([2010, 0, 4]).week(), 2, 'იან 4 2010 უნდა იყოს კვირა 2');
262 assert.equal(moment([2010, 0, 10]).week(), 2, 'იან 10 2010 უნდა იყოს კვირა 2');
263 assert.equal(moment([2010, 0, 11]).week(), 3, 'იან 11 2010 უნდა იყოს კვირა 3');
264 });
265
266 test('weeks year starting saturday', function (assert) {
267 assert.equal(moment([2010, 11, 27]).week(), 1, 'დეკ 27 2010 უნდა იყოს კვირა 1');
268 assert.equal(moment([2011, 0, 1]).week(), 1, 'იან 1 2011 უნდა იყოს კვირა 1');
269 assert.equal(moment([2011, 0, 2]).week(), 1, 'იან 2 2011 უნდა იყოს კვირა 1');
270 assert.equal(moment([2011, 0, 3]).week(), 2, 'იან 3 2011 უნდა იყოს კვირა 2');
271 assert.equal(moment([2011, 0, 9]).week(), 2, 'იან 9 2011 უნდა იყოს კვირა 2');
272 assert.equal(moment([2011, 0, 10]).week(), 3, 'იან 10 2011 უნდა იყოს კვირა 3');
273 });
274
275 test('weeks year starting sunday formatted', function (assert) {
276 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ლი', 'დეკ 26 2011 უნდა იყოს კვირა 1');
277 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ლი', 'იან 1 2012 უნდა იყოს კვირა 1');
278 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 მე-2', 'იან 2 2012 უნდა იყოს კვირა 2');
279 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 მე-2', 'იან 8 2012 უნდა იყოს კვირა 2');
280 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 მე-3', 'იან 9 2012 უნდა იყოს კვირა 3');
281 });
282
283 test('lenient ordinal parsing', function (assert) {
284 var i, ordinalStr, testMoment;
285 for (i = 1; i <= 31; ++i) {
286 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
287 testMoment = moment(ordinalStr, 'YYYY MM Do');
288 assert.equal(testMoment.year(), 2014,
289 'lenient ordinal parsing ' + i + ' year check');
290 assert.equal(testMoment.month(), 0,
291 'lenient ordinal parsing ' + i + ' month check');
292 assert.equal(testMoment.date(), i,
293 'lenient ordinal parsing ' + i + ' date check');
294 }
295 });
296
297 test('lenient ordinal parsing of number', function (assert) {
298 var i, testMoment;
299 for (i = 1; i <= 31; ++i) {
300 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
301 assert.equal(testMoment.year(), 2014,
302 'lenient ordinal parsing of number ' + i + ' year check');
303 assert.equal(testMoment.month(), 0,
304 'lenient ordinal parsing of number ' + i + ' month check');
305 assert.equal(testMoment.date(), i,
306 'lenient ordinal parsing of number ' + i + ' date check');
307 }
308 });
309
310 test('strict ordinal parsing', function (assert) {
311 var i, ordinalStr, testMoment;
312 for (i = 1; i <= 31; ++i) {
313 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
314 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
315 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
316 }
317 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('km');
3
4 test('parse', function (assert) {
5 var tests = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
6 i;
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11 for (i = 0; i < 12; i++) {
12 tests[i] = tests[i].split(' ');
13 equalTest(tests[i][0], 'MMM', i);
14 equalTest(tests[i][1], 'MMM', i);
15 equalTest(tests[i][0], 'MMMM', i);
16 equalTest(tests[i][1], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21 }
22 });
23
24 test('format', function (assert) {
25 var a = [
26 ['dddd, MMMM Do YYYY, h:mm:ss a', 'អាទិត្យ, កុម្ភៈ 14 2010, 3:25:50 pm'],
27 ['ddd, hA', 'អាទិត្យ, 3PM'],
28 ['M Mo MM MMMM MMM', '2 2 02 កុម្ភៈ កុម្ភៈ'],
29 ['YYYY YY', '2010 10'],
30 ['D Do DD', '14 14 14'],
31 ['d do dddd ddd dd', '0 0 អាទិត្យ អាទិត្យ អាទិត្យ'],
32 ['DDD DDDo DDDD', '45 45 045'],
33 ['w wo ww', '6 6 06'],
34 ['h hh', '3 03'],
35 ['H HH', '15 15'],
36 ['m mm', '25 25'],
37 ['s ss', '50 50'],
38 ['a A', 'pm PM'],
39 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
40 ['LTS', '15:25:50'],
41 ['L', '14/02/2010'],
42 ['LL', '14 កុម្ភៈ 2010'],
43 ['LLL', '14 កុម្ភៈ 2010 15:25'],
44 ['LLLL', 'អាទិត្យ, 14 កុម្ភៈ 2010 15:25'],
45 ['l', '14/2/2010'],
46 ['ll', '14 កុម្ភៈ 2010'],
47 ['lll', '14 កុម្ភៈ 2010 15:25'],
48 ['llll', 'អាទិត្យ, 14 កុម្ភៈ 2010 15:25']
49 ],
50 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
51 i;
52 for (i = 0; i < a.length; i++) {
53 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
54 }
55 });
56
57 test('format ordinal', function (assert) {
58 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1st');
59 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2nd');
60 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3rd');
61 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4th');
62 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5th');
63 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6th');
64 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7th');
65 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8th');
66 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9th');
67 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10th');
68
69 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11th');
70 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12th');
71 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13th');
72 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14th');
73 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15th');
74 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16th');
75 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17th');
76 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18th');
77 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19th');
78 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20th');
79
80 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21st');
81 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22nd');
82 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23rd');
83 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24th');
84 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25th');
85 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26th');
86 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27th');
87 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28th');
88 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29th');
89 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30th');
90
91 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31st');
92 });
93
94 test('format month', function (assert) {
95 var expected = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
96 i;
97 for (i = 0; i < expected.length; i++) {
98 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
99 }
100 });
101
102 test('format week', function (assert) {
103 var expected = 'អាទិត្យ អាទិត្យ អាទិត្យ_ច័ន្ទ ច័ន្ទ ច័ន្ទ_អង្គារ អង្គារ អង្គារ_ពុធ ពុធ ពុធ_ព្រហស្បតិ៍ ព្រហស្បតិ៍ ព្រហស្បតិ៍_សុក្រ សុក្រ សុក្រ_សៅរ៍ សៅរ៍ សៅរ៍'.split('_'),
104 i;
105 for (i = 0; i < expected.length; i++) {
106 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
107 }
108 });
109
110 test('from', function (assert) {
111 var start = moment([2007, 1, 28]);
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ប៉ុន្មានវិនាទី', '44 seconds = ប៉ុន្មានវិនាទី');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'មួយនាទី', '45 seconds = មួយនាទី');
114 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'មួយនាទី', '89 seconds = មួយនាទី');
115 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 នាទី', '90 seconds = 2 នាទី');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 នាទី', '44 minutes = 44 នាទី');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'មួយម៉ោង', '45 minutes = មួយម៉ោង');
118 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'មួយម៉ោង', '89 minutes = មួយម៉ោង');
119 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ម៉ោង', '90 minutes = 2 ម៉ោង');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ម៉ោង', '5 hours = 5 ម៉ោង');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ម៉ោង', '21 hours = 21 ម៉ោង');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'មួយថ្ងៃ', '22 hours = មួយថ្ងៃ');
123 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'មួយថ្ងៃ', '35 hours = មួយថ្ងៃ');
124 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ថ្ងៃ', '36 hours = 2 ថ្ងៃ');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'មួយថ្ងៃ', '1 day = មួយថ្ងៃ');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ថ្ងៃ', '5 days = 5 ថ្ងៃ');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ថ្ងៃ', '25 days = 25 ថ្ងៃ');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'មួយខែ', '26 days = មួយខែ');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'មួយខែ', '30 days = មួយខែ');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'មួយខែ', '43 days = មួយខែ');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ខែ', '46 days = 2 ខែ');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ខែ', '75 days = 2 ខែ');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ខែ', '76 days = 3 ខែ');
134 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'មួយខែ', '1 month = មួយខែ');
135 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ខែ', '5 months = 5 ខែ');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'មួយឆ្នាំ', '345 days = មួយឆ្នាំ');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ឆ្នាំ', '548 days = 2 ឆ្នាំ');
138 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'មួយឆ្នាំ', '1 year = មួយឆ្នាំ');
139 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ឆ្នាំ', '5 years = 5 ឆ្នាំ');
140 });
141
142 test('suffix', function (assert) {
143 assert.equal(moment(30000).from(0), 'ប៉ុន្មានវិនាទីទៀត', 'prefix');
144 assert.equal(moment(0).from(30000), 'ប៉ុន្មានវិនាទីមុន', 'suffix');
145 });
146
147 test('now from now', function (assert) {
148 assert.equal(moment().fromNow(), 'ប៉ុន្មានវិនាទីមុន', 'now from now should display as in the past');
149 });
150
151 test('fromNow', function (assert) {
152 assert.equal(moment().add({
153 s: 30
154 }).fromNow(), 'ប៉ុន្មានវិនាទីទៀត', 'in a few seconds');
155 assert.equal(moment().add({
156 d: 5
157 }).fromNow(), '5 ថ្ងៃទៀត', 'in 5 days');
158 });
159
160 test('calendar day', function (assert) {
161 var a = moment().hours(2).minutes(0).seconds(0);
162
163 assert.equal(moment(a).calendar(), 'ថ្ងៃនៈ ម៉ោង 02:00', 'today at the same time');
164 assert.equal(moment(a).add({
165 m: 25
166 }).calendar(), 'ថ្ងៃនៈ ម៉ោង 02:25', 'Now plus 25 min');
167 assert.equal(moment(a).add({
168 h: 1
169 }).calendar(), 'ថ្ងៃនៈ ម៉ោង 03:00', 'Now plus 1 hour');
170 assert.equal(moment(a).add({
171 d: 1
172 }).calendar(), 'ស្អែក ម៉ោង 02:00', 'tomorrow at the same time');
173 assert.equal(moment(a).subtract({
174 h: 1
175 }).calendar(), 'ថ្ងៃនៈ ម៉ោង 01:00', 'Now minus 1 hour');
176 assert.equal(moment(a).subtract({
177 d: 1
178 }).calendar(), 'ម្សិលមិញ ម៉ោង 02:00', 'yesterday at the same time');
179 });
180
181 test('calendar next week', function (assert) {
182 var i, m;
183 for (i = 2; i < 7; i++) {
184 m = moment().add({
185 d: i
186 });
187 assert.equal(m.calendar(), m.format('dddd [ម៉ោង] LT'), 'Today + ' + i + ' days current time');
188 m.hours(0).minutes(0).seconds(0).milliseconds(0);
189 assert.equal(m.calendar(), m.format('dddd [ម៉ោង] LT'), 'Today + ' + i + ' days beginning of day');
190 m.hours(23).minutes(59).seconds(59).milliseconds(999);
191 assert.equal(m.calendar(), m.format('dddd [ម៉ោង] LT'), 'Today + ' + i + ' days end of day');
192 }
193 });
194
195 test('calendar last week', function (assert) {
196 var i, m;
197
198 for (i = 2; i < 7; i++) {
199 m = moment().subtract({
200 d: i
201 });
202 assert.equal(m.calendar(), m.format('dddd [សប្តាហ៍មុន] [ម៉ោង] LT'), 'Today - ' + i + ' days current time');
203 m.hours(0).minutes(0).seconds(0).milliseconds(0);
204 assert.equal(m.calendar(), m.format('dddd [សប្តាហ៍មុន] [ម៉ោង] LT'), 'Today - ' + i + ' days beginning of day');
205 m.hours(23).minutes(59).seconds(59).milliseconds(999);
206 assert.equal(m.calendar(), m.format('dddd [សប្តាហ៍មុន] [ម៉ោង] LT'), 'Today - ' + i + ' days end of day');
207 }
208 });
209
210 test('calendar all else', function (assert) {
211 var weeksAgo = moment().subtract({
212 w: 1
213 }),
214 weeksFromNow = moment().add({
215 w: 1
216 });
217
218 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
219 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
220
221 weeksAgo = moment().subtract({
222 w: 2
223 });
224 weeksFromNow = moment().add({
225 w: 2
226 });
227
228 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
229 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
230 });
231
232 test('weeks year starting sunday', function (assert) {
233 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
234 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
235 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
236 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
237 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
238 });
239
240 test('weeks year starting monday', function (assert) {
241 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
242 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
243 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
244 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
245 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
246 });
247
248 test('weeks year starting tuesday', function (assert) {
249 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
250 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
251 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
252 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
253 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
254 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
255 });
256
257 test('weeks year starting wednesday', function (assert) {
258 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
259 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
260 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
261 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
262 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
263 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
264 });
265
266 test('weeks year starting thursday', function (assert) {
267 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
268 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
269 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
270 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
271 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
272 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
273 });
274
275 test('weeks year starting friday', function (assert) {
276 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
277 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
278 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
279 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
280 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
281 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
282 });
283
284 test('weeks year starting saturday', function (assert) {
285 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
286 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
287 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
288 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
289 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
290 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
291 });
292
293 test('weeks year starting sunday formatted', function (assert) {
294 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
295 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
296 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
297 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
298 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
299 });
300
301 test('lenient ordinal parsing', function (assert) {
302 var i, ordinalStr, testMoment;
303 for (i = 1; i <= 31; ++i) {
304 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
305 testMoment = moment(ordinalStr, 'YYYY MM Do');
306 assert.equal(testMoment.year(), 2014,
307 'lenient ordinal parsing ' + i + ' year check');
308 assert.equal(testMoment.month(), 0,
309 'lenient ordinal parsing ' + i + ' month check');
310 assert.equal(testMoment.date(), i,
311 'lenient ordinal parsing ' + i + ' date check');
312 }
313 });
314
315 test('lenient ordinal parsing of number', function (assert) {
316 var i, testMoment;
317 for (i = 1; i <= 31; ++i) {
318 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
319 assert.equal(testMoment.year(), 2014,
320 'lenient ordinal parsing of number ' + i + ' year check');
321 assert.equal(testMoment.month(), 0,
322 'lenient ordinal parsing of number ' + i + ' month check');
323 assert.equal(testMoment.date(), i,
324 'lenient ordinal parsing of number ' + i + ' date check');
325 }
326 });
327
328 test('strict ordinal parsing', function (assert) {
329 var i, ordinalStr, testMoment;
330 for (i = 1; i <= 31; ++i) {
331 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
332 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
333 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
334 }
335 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ko');
3
4 test('parse', function (assert) {
5 var tests = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('parse meridiem', function (assert) {
23 var elements = [{
24 expression : '1981년 9월 8일 오후 2시 30분',
25 inputFormat : 'YYYY[년] M[월] D[일] A h[시] m[분]',
26 outputFormat : 'A',
27 expected : '오후'
28 }, {
29 expression : '1981년 9월 8일 오전 2시 30분',
30 inputFormat : 'YYYY[년] M[월] D[일] A h[시] m[분]',
31 outputFormat : 'A h시',
32 expected : '오전 2시'
33 }, {
34 expression : '14시 30분',
35 inputFormat : 'H[시] m[분]',
36 outputFormat : 'A',
37 expected : '오후'
38 }, {
39 expression : '오후 4시',
40 inputFormat : 'A h[시]',
41 outputFormat : 'H',
42 expected : '16'
43 }], i, l, it, actual;
44
45
46 for (i = 0, l = elements.length; i < l; ++i) {
47 it = elements[i];
48 actual = moment(it.expression, it.inputFormat).format(it.outputFormat);
49
50 assert.equal(
51 actual,
52 it.expected,
53 '\'' + it.outputFormat + '\' of \'' + it.expression + '\' must be \'' + it.expected + '\' but was \'' + actual + '\'.'
54 );
55 }
56 });
57
58 test('format', function (assert) {
59 var a = [
60 ['YYYY년 MMMM Do dddd a h:mm:ss', '2010년 2월 14일 일요일 오후 3:25:50'],
61 ['ddd A h', '일 오후 3'],
62 ['M Mo MM MMMM MMM', '2 2일 02 2월 2월'],
63 ['YYYY YY', '2010 10'],
64 ['D Do DD', '14 14일 14'],
65 ['d do dddd ddd dd', '0 0일 일요일 일 일'],
66 ['DDD DDDo DDDD', '45 45일 045'],
67 ['w wo ww', '8 8일 08'],
68 ['h hh', '3 03'],
69 ['H HH', '15 15'],
70 ['m mm', '25 25'],
71 ['s ss', '50 50'],
72 ['a A', '오후 오후'],
73 ['일년 중 DDDo째 되는 날', '일년 중 45일째 되는 날'],
74 ['LTS', '오후 3시 25분 50초'],
75 ['L', '2010.02.14'],
76 ['LL', '2010년 2월 14일'],
77 ['LLL', '2010년 2월 14일 오후 3시 25분'],
78 ['LLLL', '2010년 2월 14일 일요일 오후 3시 25분'],
79 ['l', '2010.2.14'],
80 ['ll', '2010년 2월 14일'],
81 ['lll', '2010년 2월 14일 오후 3시 25분'],
82 ['llll', '2010년 2월 14일 일 오후 3시 25분']
83 ],
84 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
85 i;
86 for (i = 0; i < a.length; i++) {
87 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
88 }
89 });
90
91 test('format ordinal', function (assert) {
92 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1일', '1일');
93 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2일', '2일');
94 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3일', '3일');
95 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4일', '4일');
96 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5일', '5일');
97 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6일', '6일');
98 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7일', '7일');
99 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8일', '8일');
100 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9일', '9일');
101 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10일', '10일');
102
103 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11일', '11일');
104 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12일', '12일');
105 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13일', '13일');
106 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14일', '14일');
107 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15일', '15일');
108 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16일', '16일');
109 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17일', '17일');
110 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18일', '18일');
111 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19일', '19일');
112 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20일', '20일');
113
114 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21일', '21일');
115 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22일', '22일');
116 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23일', '23일');
117 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24일', '24일');
118 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25일', '25일');
119 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26일', '26일');
120 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27일', '27일');
121 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28일', '28일');
122 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29일', '29일');
123 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30일', '30일');
124
125 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31일', '31일');
126 });
127
128 test('format month', function (assert) {
129 var expected = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split('_'), i;
130 for (i = 0; i < expected.length; i++) {
131 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
132 }
133 });
134
135 test('format week', function (assert) {
136 var expected = '일요일 일 일_월요일 월 월_화요일 화 화_수요일 수 수_목요일 목 목_금요일 금 금_토요일 토 토'.split('_'), i;
137 for (i = 0; i < expected.length; i++) {
138 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
139 }
140 });
141
142 test('from', function (assert) {
143 var start = moment([2007, 1, 28]);
144 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '몇초', '44초 = 몇초');
145 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '일분', '45초 = 일분');
146 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '일분', '89초 = 일분');
147 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2분', '90초 = 2분');
148 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44분', '44분 = 44분');
149 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '한시간', '45분 = 한시간');
150 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '한시간', '89분 = 한시간');
151 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2시간', '90분 = 2시간');
152 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5시간', '5시간 = 5시간');
153 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21시간', '21시간 = 21시간');
154 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '하루', '22시간 = 하루');
155 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '하루', '35시간 = 하루');
156 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2일', '36시간 = 2일');
157 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '하루', '하루 = 하루');
158 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5일', '5일 = 5일');
159 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25일', '25일 = 25일');
160 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '한달', '26일 = 한달');
161 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '한달', '30일 = 한달');
162 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '한달', '45일 = 한달');
163 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2달', '46일 = 2달');
164 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2달', '75일 = 2달');
165 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3달', '76일 = 3달');
166 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '한달', '1달 = 한달');
167 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5달', '5달 = 5달');
168 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '일년', '345일 = 일년');
169 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2년', '548일 = 2년');
170 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '일년', '일년 = 일년');
171 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5년', '5년 = 5년');
172 });
173
174 test('suffix', function (assert) {
175 assert.equal(moment(30000).from(0), '몇초 후', 'prefix');
176 assert.equal(moment(0).from(30000), '몇초 전', 'suffix');
177 });
178
179 test('now from now', function (assert) {
180 assert.equal(moment().fromNow(), '몇초 전', 'now from now should display as in the past');
181 });
182
183 test('fromNow', function (assert) {
184 assert.equal(moment().add({s: 30}).fromNow(), '몇초 후', 'in a few seconds');
185 assert.equal(moment().add({d: 5}).fromNow(), '5일 후', 'in 5 days');
186 });
187
188 test('calendar day', function (assert) {
189 var a = moment().hours(2).minutes(0).seconds(0);
190
191 assert.equal(moment(a).calendar(), '오늘 오전 2시 0분', 'today at the same time');
192 assert.equal(moment(a).add({m: 25}).calendar(), '오늘 오전 2시 25분', 'Now plus 25 min');
193 assert.equal(moment(a).add({h: 1}).calendar(), '오늘 오전 3시 0분', 'Now plus 1 hour');
194 assert.equal(moment(a).add({d: 1}).calendar(), '내일 오전 2시 0분', 'tomorrow at the same time');
195 assert.equal(moment(a).subtract({h: 1}).calendar(), '오늘 오전 1시 0분', 'Now minus 1 hour');
196 assert.equal(moment(a).subtract({d: 1}).calendar(), '어제 오전 2시 0분', 'yesterday at the same time');
197 });
198
199 test('calendar next week', function (assert) {
200 var i, m;
201 for (i = 2; i < 7; i++) {
202 m = moment().add({d: i});
203 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days current time');
204 m.hours(0).minutes(0).seconds(0).milliseconds(0);
205 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days beginning of day');
206 m.hours(23).minutes(59).seconds(59).milliseconds(999);
207 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days end of day');
208 }
209 });
210
211 test('calendar last week', function (assert) {
212 var i, m;
213 for (i = 2; i < 7; i++) {
214 m = moment().subtract({d: i});
215 assert.equal(m.calendar(), m.format('지난주 dddd LT'), 'Today - ' + i + ' days current time');
216 m.hours(0).minutes(0).seconds(0).milliseconds(0);
217 assert.equal(m.calendar(), m.format('지난주 dddd LT'), 'Today - ' + i + ' days beginning of day');
218 m.hours(23).minutes(59).seconds(59).milliseconds(999);
219 assert.equal(m.calendar(), m.format('지난주 dddd LT'), 'Today - ' + i + ' days end of day');
220 }
221 });
222
223 test('calendar all else', function (assert) {
224 var weeksAgo = moment().subtract({w: 1}),
225 weeksFromNow = moment().add({w: 1});
226
227 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
228 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
229
230 weeksAgo = moment().subtract({w: 2});
231 weeksFromNow = moment().add({w: 2});
232
233 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
234 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
235 });
236
237 test('weeks year starting sunday', function (assert) {
238 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
239 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
240 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
241 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
242 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
243 });
244
245 test('weeks year starting monday', function (assert) {
246 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
247 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
248 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
249 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
250 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
251 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
252 });
253
254 test('weeks year starting tuesday', function (assert) {
255 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
256 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
257 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
258 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
259 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
260 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
261 });
262
263 test('weeks year starting wednesday', function (assert) {
264 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
265 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
266 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
267 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
268 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
269 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
270 });
271
272 test('weeks year starting thursday', function (assert) {
273 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
274 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
275 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
276 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
277 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
278 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
279 });
280
281 test('weeks year starting friday', function (assert) {
282 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
283 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
284 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
285 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
286 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
287 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
288 });
289
290 test('weeks year starting saturday', function (assert) {
291 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
292 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
293 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
294 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
295 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
296 });
297
298 test('weeks year starting sunday format', function (assert) {
299 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1일', 'Jan 1 2012 should be week 1');
300 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1일', 'Jan 7 2012 should be week 1');
301 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2일', 'Jan 8 2012 should be week 2');
302 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2일', 'Jan 14 2012 should be week 2');
303 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3일', 'Jan 15 2012 should be week 3');
304 });
305
306 test('lenient ordinal parsing', function (assert) {
307 var i, ordinalStr, testMoment;
308 for (i = 1; i <= 31; ++i) {
309 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
310 testMoment = moment(ordinalStr, 'YYYY MM Do');
311 assert.equal(testMoment.year(), 2014,
312 'lenient ordinal parsing ' + i + ' year check');
313 assert.equal(testMoment.month(), 0,
314 'lenient ordinal parsing ' + i + ' month check');
315 assert.equal(testMoment.date(), i,
316 'lenient ordinal parsing ' + i + ' date check');
317 }
318 });
319
320 test('lenient ordinal parsing of number', function (assert) {
321 var i, testMoment;
322 for (i = 1; i <= 31; ++i) {
323 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
324 assert.equal(testMoment.year(), 2014,
325 'lenient ordinal parsing of number ' + i + ' year check');
326 assert.equal(testMoment.month(), 0,
327 'lenient ordinal parsing of number ' + i + ' month check');
328 assert.equal(testMoment.date(), i,
329 'lenient ordinal parsing of number ' + i + ' date check');
330 }
331 });
332
333 test('strict ordinal parsing', function (assert) {
334 var i, ordinalStr, testMoment;
335 for (i = 1; i <= 31; ++i) {
336 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
337 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
338 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
339 }
340 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('lb');
3
4 test('parse', function (assert) {
5 var tests = 'Januar Jan._Februar Febr._Mäerz Mrz._Abrëll Abr._Mee Mee_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
6
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10
11 for (i = 0; i < 12; i++) {
12 tests[i] = tests[i].split(' ');
13 equalTest(tests[i][0], 'MMM', i);
14 equalTest(tests[i][1], 'MMM', i);
15 equalTest(tests[i][0], 'MMMM', i);
16 equalTest(tests[i][1], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21 }
22 });
23
24 test('format', function (assert) {
25 var a = [
26 ['dddd, Do MMMM YYYY, HH:mm:ss', 'Sonndeg, 14. Februar 2010, 15:25:50'],
27 ['ddd, HH:mm', 'So., 15:25'],
28 ['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
29 ['YYYY YY', '2010 10'],
30 ['D Do DD', '14 14. 14'],
31 ['d do dddd ddd dd', '0 0. Sonndeg So. So'],
32 ['DDD DDDo DDDD', '45 45. 045'],
33 ['w wo ww', '6 6. 06'],
34 ['h hh', '3 03'],
35 ['H HH', '15 15'],
36 ['m mm', '25 25'],
37 ['s ss', '50 50'],
38 ['a A', 'pm PM'],
39 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
40 ['LTS', '15:25:50 Auer'],
41 ['L', '14.02.2010'],
42 ['LL', '14. Februar 2010'],
43 ['LLL', '14. Februar 2010 15:25 Auer'],
44 ['LLLL', 'Sonndeg, 14. Februar 2010 15:25 Auer'],
45 ['l', '14.2.2010'],
46 ['ll', '14. Febr. 2010'],
47 ['lll', '14. Febr. 2010 15:25 Auer'],
48 ['llll', 'So., 14. Febr. 2010 15:25 Auer']
49 ],
50 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
51 i;
52 for (i = 0; i < a.length; i++) {
53 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
54 }
55 });
56
57 test('format month', function (assert) {
58 var expected = 'Januar Jan._Februar Febr._Mäerz Mrz._Abrëll Abr._Mee Mee_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split('_'), i;
59 for (i = 0; i < expected.length; i++) {
60 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
61 }
62 });
63
64 test('format week', function (assert) {
65 var expected = 'Sonndeg So. So_Méindeg Mé. Mé_Dënschdeg Dë. Dë_Mëttwoch Më. Më_Donneschdeg Do. Do_Freideg Fr. Fr_Samschdeg Sa. Sa'.split('_'), i;
66 for (i = 0; i < expected.length; i++) {
67 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
68 }
69 });
70
71 test('from', function (assert) {
72 var start = moment([2007, 1, 28]);
73 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'e puer Sekonnen', '44 seconds = a few seconds');
74 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eng Minutt', '45 seconds = a minute');
75 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eng Minutt', '89 seconds = a minute');
76 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 Minutten', '90 seconds = 2 minutes');
77 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 Minutten', '44 minutes = 44 minutes');
78 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'eng Stonn', '45 minutes = an hour');
79 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'eng Stonn', '89 minutes = an hour');
80 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 Stonnen', '90 minutes = 2 hours');
81 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 Stonnen', '5 hours = 5 hours');
82 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 Stonnen', '21 hours = 21 hours');
83 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'een Dag', '22 hours = a day');
84 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'een Dag', '35 hours = a day');
85 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 Deeg', '36 hours = 2 days');
86 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'een Dag', '1 day = a day');
87 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 Deeg', '5 days = 5 days');
88 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 Deeg', '25 days = 25 days');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ee Mount', '26 days = a month');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ee Mount', '30 days = a month');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ee Mount', '43 days = a month');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 Méint', '46 days = 2 months');
93 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 Méint', '75 days = 2 months');
94 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 Méint', '76 days = 3 months');
95 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ee Mount', '1 month = a month');
96 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 Méint', '5 months = 5 months');
97 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ee Joer', '345 days = a year');
98 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 Joer', '548 days = 2 years');
99 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ee Joer', '1 year = a year');
100 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 Joer', '5 years = 5 years');
101 });
102
103 test('suffix', function (assert) {
104 assert.equal(moment(30000).from(0), 'an e puer Sekonnen', 'prefix');
105 assert.equal(moment(0).from(30000), 'virun e puer Sekonnen', 'suffix');
106 });
107
108 test('fromNow', function (assert) {
109 assert.equal(moment().add({s: 30}).fromNow(), 'an e puer Sekonnen', 'in a few seconds');
110 assert.equal(moment().add({d: 1}).fromNow(), 'an engem Dag', 'in one day');
111 assert.equal(moment().add({d: 2}).fromNow(), 'an 2 Deeg', 'in 2 days');
112 assert.equal(moment().add({d: 3}).fromNow(), 'an 3 Deeg', 'in 3 days');
113 assert.equal(moment().add({d: 4}).fromNow(), 'a 4 Deeg', 'in 4 days');
114 assert.equal(moment().add({d: 5}).fromNow(), 'a 5 Deeg', 'in 5 days');
115 assert.equal(moment().add({d: 6}).fromNow(), 'a 6 Deeg', 'in 6 days');
116 assert.equal(moment().add({d: 7}).fromNow(), 'a 7 Deeg', 'in 7 days');
117 assert.equal(moment().add({d: 8}).fromNow(), 'an 8 Deeg', 'in 8 days');
118 assert.equal(moment().add({d: 9}).fromNow(), 'an 9 Deeg', 'in 9 days');
119 assert.equal(moment().add({d: 10}).fromNow(), 'an 10 Deeg', 'in 10 days');
120 assert.equal(moment().add({y: 100}).fromNow(), 'an 100 Joer', 'in 100 years');
121 assert.equal(moment().add({y: 400}).fromNow(), 'a 400 Joer', 'in 400 years');
122 });
123
124 test('calendar last week', function (assert) {
125 var i, m, weekday, datestring;
126 for (i = 2; i < 7; i++) {
127 m = moment().subtract({d: i});
128
129 // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday)
130 weekday = parseInt(m.format('d'), 10);
131 datestring = (weekday === 2 || weekday === 4 ? '[Leschten] dddd [um] LT' : '[Leschte] dddd [um] LT');
132
133 assert.equal(m.calendar(), m.format(datestring), 'Today + ' + i + ' days current time');
134 m.hours(0).minutes(0).seconds(0).milliseconds(0);
135 assert.equal(m.calendar(), m.format(datestring), 'Today + ' + i + ' days beginning of day');
136 m.hours(23).minutes(59).seconds(59).milliseconds(999);
137 assert.equal(m.calendar(), m.format(datestring), 'Today + ' + i + ' days end of day');
138 }
139 });
140
141 test('lenient ordinal parsing', function (assert) {
142 var i, ordinalStr, testMoment;
143 for (i = 1; i <= 31; ++i) {
144 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
145 testMoment = moment(ordinalStr, 'YYYY MM Do');
146 assert.equal(testMoment.year(), 2014,
147 'lenient ordinal parsing ' + i + ' year check');
148 assert.equal(testMoment.month(), 0,
149 'lenient ordinal parsing ' + i + ' month check');
150 assert.equal(testMoment.date(), i,
151 'lenient ordinal parsing ' + i + ' date check');
152 }
153 });
154
155 test('lenient ordinal parsing of number', function (assert) {
156 var i, testMoment;
157 for (i = 1; i <= 31; ++i) {
158 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
159 assert.equal(testMoment.year(), 2014,
160 'lenient ordinal parsing of number ' + i + ' year check');
161 assert.equal(testMoment.month(), 0,
162 'lenient ordinal parsing of number ' + i + ' month check');
163 assert.equal(testMoment.date(), i,
164 'lenient ordinal parsing of number ' + i + ' date check');
165 }
166 });
167
168 test('strict ordinal parsing', function (assert) {
169 var i, ordinalStr, testMoment;
170 for (i = 1; i <= 31; ++i) {
171 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
172 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
173 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
174 }
175 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('lt');
3
4 test('parse', function (assert) {
5 var tests = 'sausis sau_vasaris vas_kovas kov_balandis bal_gegužė geg_birželis bir_liepa lie_rugpjūtis rgp_rugsėjis rgs_spalis spa_lapkritis lap_gruodis grd'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'sekmadienis, 14-oji vasario 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Sek, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2-oji 02 vasaris vas'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14-oji 14'],
29 ['d do dddd ddd dd', '0 0-oji sekmadienis Sek S'],
30 ['DDD DDDo DDDD', '45 45-oji 045'],
31 ['w wo ww', '6 6-oji 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['DDDo [metų diena]', '45-oji metų diena'],
38 ['LTS', '15:25:50'],
39 ['L', '2010-02-14'],
40 ['LL', '2010 m. vasaris 14 d.'],
41 ['LLL', '2010 m. vasaris 14 d., 15:25 val.'],
42 ['LLLL', '2010 m. vasaris 14 d., sekmadienis, 15:25 val.'],
43 ['l', '2010-02-14'],
44 ['ll', '2010 m. vasaris 14 d.'],
45 ['lll', '2010 m. vasaris 14 d., 15:25 val.'],
46 ['llll', '2010 m. vasaris 14 d., Sek, 15:25 val.']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-oji', '1-oji');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-oji', '2-oji');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-oji', '3-oji');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-oji', '4-oji');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-oji', '5-oji');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-oji', '6-oji');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-oji', '7-oji');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-oji', '8-oji');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-oji', '9-oji');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-oji', '10-oji');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-oji', '11-oji');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-oji', '12-oji');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-oji', '13-oji');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-oji', '14-oji');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-oji', '15-oji');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-oji', '16-oji');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-oji', '17-oji');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-oji', '18-oji');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-oji', '19-oji');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-oji', '20-oji');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-oji', '21-oji');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-oji', '22-oji');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-oji', '23-oji');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-oji', '24-oji');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-oji', '25-oji');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-oji', '26-oji');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-oji', '27-oji');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-oji', '28-oji');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-oji', '29-oji');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-oji', '30-oji');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-oji', '31-oji');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'sausis sau_vasaris vas_kovas kov_balandis bal_gegužė geg_birželis bir_liepa lie_rugpjūtis rgp_rugsėjis rgs_spalis spa_lapkritis lap_gruodis grd'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 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;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('format week on US calendar', function (assert) {
107 // Tests, whether the weekday names are correct, even if the week does not start on Monday
108 moment.locale('lt', {week: {dow: 0, doy: 6}});
109 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;
110 for (i = 0; i < expected.length; i++) {
111 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
112 }
113 moment.locale('lt', {week: {dow: 1, doy: 4}});
114 });
115
116 test('from', function (assert) {
117 var start = moment([2007, 1, 28]);
118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'kelios sekundės', '44 seconds = seconds');
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minutė', '45 seconds = a minute');
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minutė', '89 seconds = a minute');
121 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutės', '90 seconds = 2 minutes');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 10}), true), '10 minučių', '10 minutes = 10 minutes');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 11}), true), '11 minučių', '11 minutes = 11 minutes');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 19}), true), '19 minučių', '19 minutes = 19 minutes');
125 assert.equal(start.from(moment([2007, 1, 28]).add({m: 20}), true), '20 minučių', '20 minutes = 20 minutes');
126 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutės', '44 minutes = 44 minutes');
127 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'valanda', '45 minutes = an hour');
128 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'valanda', '89 minutes = an hour');
129 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 valandos', '90 minutes = 2 hours');
130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 valandos', '5 hours = 5 hours');
131 assert.equal(start.from(moment([2007, 1, 28]).add({h: 10}), true), '10 valandų', '10 hours = 10 hours');
132 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 valandos', '21 hours = 21 hours');
133 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'diena', '22 hours = a day');
134 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'diena', '35 hours = a day');
135 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dienos', '36 hours = 2 days');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'diena', '1 day = a day');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dienos', '5 days = 5 days');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 10}), true), '10 dienų', '10 days = 10 days');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dienos', '25 days = 25 days');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mėnuo', '26 days = a month');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mėnuo', '30 days = a month');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mėnuo', '43 days = a month');
143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mėnesiai', '46 days = 2 months');
144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mėnesiai', '75 days = 2 months');
145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mėnesiai', '76 days = 3 months');
146 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mėnuo', '1 month = a month');
147 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mėnesiai', '5 months = 5 months');
148 assert.equal(start.from(moment([2007, 1, 28]).add({M: 10}), true), '10 mėnesių', '10 months = 10 months');
149 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'metai', '345 days = a year');
150 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 metai', '548 days = 2 years');
151 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'metai', '1 year = a year');
152 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 metai', '5 years = 5 years');
153 });
154
155 test('suffix', function (assert) {
156 assert.equal(moment(30000).from(0), 'po kelių sekundžių', 'prefix');
157 assert.equal(moment(0).from(30000), 'prieš kelias sekundes', 'suffix');
158 });
159
160 test('now from now', function (assert) {
161 assert.equal(moment().fromNow(), 'prieš kelias sekundes', 'now from now should display as in the past');
162 });
163
164 test('fromNow', function (assert) {
165 assert.equal(moment().add({s: 30}).fromNow(), 'po kelių sekundžių', 'in seconds');
166 assert.equal(moment().add({d: 5}).fromNow(), 'po 5 dienų', 'in 5 days');
167 });
168
169 test('calendar day', function (assert) {
170 var a = moment().hours(2).minutes(0).seconds(0);
171
172 assert.equal(moment(a).calendar(), 'Šiandien 02:00', 'today at the same time');
173 assert.equal(moment(a).add({m: 25}).calendar(), 'Šiandien 02:25', 'Now plus 25 min');
174 assert.equal(moment(a).add({h: 1}).calendar(), 'Šiandien 03:00', 'Now plus 1 hour');
175 assert.equal(moment(a).add({d: 1}).calendar(), 'Rytoj 02:00', 'tomorrow at the same time');
176 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šiandien 01:00', 'Now minus 1 hour');
177 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar 02:00', 'yesterday at the same time');
178 });
179
180 test('calendar next week', function (assert) {
181 var i, m;
182 for (i = 2; i < 7; i++) {
183 m = moment().add({d: i});
184 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days current time');
185 m.hours(0).minutes(0).seconds(0).milliseconds(0);
186 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days beginning of day');
187 m.hours(23).minutes(59).seconds(59).milliseconds(999);
188 assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days end of day');
189 }
190 });
191
192 test('calendar last week', function (assert) {
193 var i, m;
194 for (i = 2; i < 7; i++) {
195 m = moment().subtract({d: i});
196 assert.equal(m.calendar(), m.format('[Praėjusį] dddd LT'), 'Today - ' + i + ' days current time');
197 m.hours(0).minutes(0).seconds(0).milliseconds(0);
198 assert.equal(m.calendar(), m.format('[Praėjusį] dddd LT'), 'Today - ' + i + ' days beginning of day');
199 m.hours(23).minutes(59).seconds(59).milliseconds(999);
200 assert.equal(m.calendar(), m.format('[Praėjusį] dddd LT'), 'Today - ' + i + ' days end of day');
201 }
202 });
203
204 test('calendar all else', function (assert) {
205 var weeksAgo = moment().subtract({w: 1}),
206 weeksFromNow = moment().add({w: 1});
207
208 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
209 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
210
211 weeksAgo = moment().subtract({w: 2});
212 weeksFromNow = moment().add({w: 2});
213
214 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
215 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
216 });
217
218 test('weeks year starting sunday', function (assert) {
219 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
220 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
221 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
222 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
223 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
224 });
225
226 test('weeks year starting monday', function (assert) {
227 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
228 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
229 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
230 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
231 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
232 });
233
234 test('weeks year starting tuesday', function (assert) {
235 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
236 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
237 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
238 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
239 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
240 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
241 });
242
243 test('weeks year starting wednesday', function (assert) {
244 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
245 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
246 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
247 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
248 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
249 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
250 });
251
252 test('weeks year starting thursday', function (assert) {
253 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
254 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
255 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
256 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
257 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
258 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
259 });
260
261 test('weeks year starting friday', function (assert) {
262 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
263 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
264 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
265 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
266 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
267 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
268 });
269
270 test('weeks year starting saturday', function (assert) {
271 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
272 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
273 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
274 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
275 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
276 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
277 });
278
279 test('weeks year starting sunday formatted', function (assert) {
280 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52-oji', 'Jan 1 2012 should be week 52');
281 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1-oji', 'Jan 2 2012 should be week 1');
282 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1-oji', 'Jan 8 2012 should be week 1');
283 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2-oji', 'Jan 9 2012 should be week 2');
284 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2-oji', 'Jan 15 2012 should be week 2');
285 });
286
287 test('lenient ordinal parsing', function (assert) {
288 var i, ordinalStr, testMoment;
289 for (i = 1; i <= 31; ++i) {
290 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
291 testMoment = moment(ordinalStr, 'YYYY MM Do');
292 assert.equal(testMoment.year(), 2014,
293 'lenient ordinal parsing ' + i + ' year check');
294 assert.equal(testMoment.month(), 0,
295 'lenient ordinal parsing ' + i + ' month check');
296 assert.equal(testMoment.date(), i,
297 'lenient ordinal parsing ' + i + ' date check');
298 }
299 });
300
301 test('lenient ordinal parsing of number', function (assert) {
302 var i, testMoment;
303 for (i = 1; i <= 31; ++i) {
304 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
305 assert.equal(testMoment.year(), 2014,
306 'lenient ordinal parsing of number ' + i + ' year check');
307 assert.equal(testMoment.month(), 0,
308 'lenient ordinal parsing of number ' + i + ' month check');
309 assert.equal(testMoment.date(), i,
310 'lenient ordinal parsing of number ' + i + ' date check');
311 }
312 });
313
314 test('strict ordinal parsing', function (assert) {
315 var i, ordinalStr, testMoment;
316 for (i = 1; i <= 31; ++i) {
317 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
318 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
319 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
320 }
321 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('lv');
3
4 test('parse', function (assert) {
5 var tests = 'janvāris jan_februāris feb_marts mar_aprīlis apr_maijs mai_jūnijs jūn_jūlijs jūl_augusts aug_septembris sep_oktobris okt_novembris nov_decembris dec'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'svētdiena, 14. februāris 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Sv, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 februāris feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. svētdiena Sv Sv'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010.'],
40 ['LL', '2010. gada 14. februāris'],
41 ['LLL', '2010. gada 14. februāris, 15:25'],
42 ['LLLL', '2010. gada 14. februāris, svētdiena, 15:25'],
43 ['l', '14.2.2010.'],
44 ['ll', '2010. gada 14. feb'],
45 ['lll', '2010. gada 14. feb, 15:25'],
46 ['llll', '2010. gada 14. feb, Sv, 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'janvāris jan_februāris feb_marts mar_aprīlis apr_maijs mai_jūnijs jūn_jūlijs jūl_augusts aug_septembris sep_oktobris okt_novembris nov_decembris dec'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'svētdiena Sv Sv_pirmdiena P P_otrdiena O O_trešdiena T T_ceturtdiena C C_piektdiena Pk Pk_sestdiena S S'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 // Includes testing the cases of withoutSuffix = true and false.
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'dažas sekundes', '44 seconds = seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), false), 'pirms dažām sekundēm', '44 seconds with suffix = seconds ago');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minūte', '45 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), false), 'pirms minūtes', '45 seconds with suffix = a minute ago');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minūte', '89 seconds = a minute');
114 assert.equal(start.from(moment([2007, 1, 28]).add({s: -89}), false), 'pēc minūtes', '89 seconds with suffix/prefix = in a minute');
115 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minūtes', '90 seconds = 2 minutes');
116 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), false), 'pirms 2 minūtēm', '90 seconds with suffix = 2 minutes ago');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minūtes', '44 minutes = 44 minutes');
118 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), false), 'pirms 44 minūtēm', '44 minutes with suffix = 44 minutes ago');
119 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'stunda', '45 minutes = an hour');
120 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), false), 'pirms stundas', '45 minutes with suffix = an hour ago');
121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'stunda', '89 minutes = an hour');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 stundas', '90 minutes = 2 hours');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: -90}), false), 'pēc 2 stundām', '90 minutes with suffix = in 2 hours');
124 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 stundas', '5 hours = 5 hours');
125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), false), 'pirms 5 stundām', '5 hours with suffix = 5 hours ago');
126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 stunda', '21 hours = 21 hours');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), false), 'pirms 21 stundas', '21 hours with suffix = 21 hours ago');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'diena', '22 hours = a day');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), false), 'pirms dienas', '22 hours with suffix = a day ago');
130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'diena', '35 hours = a day');
131 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dienas', '36 hours = 2 days');
132 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), false), 'pirms 2 dienām', '36 hours with suffix = 2 days ago');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'diena', '1 day = a day');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dienas', '5 days = 5 days');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), false), 'pirms 5 dienām', '5 days with suffix = 5 days ago');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dienas', '25 days = 25 days');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), false), 'pirms 25 dienām', '25 days with suffix = 25 days ago');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mēnesis', '26 days = a month');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), false), 'pirms mēneša', '26 days with suffix = a month ago');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mēnesis', '30 days = a month');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mēnesis', '43 days = a month');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mēneši', '46 days = 2 months');
143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), false), 'pirms 2 mēnešiem', '46 days with suffix = 2 months ago');
144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mēneši', '75 days = 2 months');
145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mēneši', '76 days = 3 months');
146 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), false), 'pirms 3 mēnešiem', '76 days with suffix = 3 months ago');
147 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mēnesis', '1 month = a month');
148 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mēneši', '5 months = 5 months');
149 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), false), 'pirms 5 mēnešiem', '5 months with suffix = 5 months ago');
150 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'gads', '345 days = a year');
151 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), false), 'pirms gada', '345 days with suffix = a year ago');
152 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 gadi', '548 days = 2 years');
153 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), false), 'pirms 2 gadiem', '548 days with suffix = 2 years ago');
154 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'gads', '1 year = a year');
155 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 gadi', '5 years = 5 years');
156 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), false), 'pirms 5 gadiem', '5 years with suffix = 5 years ago');
157 });
158
159 test('suffix', function (assert) {
160 assert.equal(moment(30000).from(0), 'pēc dažām sekundēm', 'prefix');
161 assert.equal(moment(0).from(30000), 'pirms dažām sekundēm', 'suffix');
162 });
163
164 test('now from now', function (assert) {
165 assert.equal(moment().fromNow(), 'pirms dažām sekundēm', 'now from now should display as in the past');
166 });
167
168 test('fromNow', function (assert) {
169 assert.equal(moment().add({s: 30}).fromNow(), 'pēc dažām sekundēm', 'in seconds');
170 assert.equal(moment().add({d: 5}).fromNow(), 'pēc 5 dienām', 'in 5 days');
171 });
172
173 test('calendar day', function (assert) {
174 var a = moment().hours(2).minutes(0).seconds(0);
175
176 assert.equal(moment(a).calendar(), 'Šodien pulksten 02:00', 'today at the same time');
177 assert.equal(moment(a).add({m: 25}).calendar(), 'Šodien pulksten 02:25', 'Now plus 25 min');
178 assert.equal(moment(a).add({h: 1}).calendar(), 'Šodien pulksten 03:00', 'Now plus 1 hour');
179 assert.equal(moment(a).add({d: 1}).calendar(), 'Rīt pulksten 02:00', 'tomorrow at the same time');
180 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šodien pulksten 01:00', 'Now minus 1 hour');
181 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar pulksten 02:00', 'yesterday at the same time');
182 });
183
184 test('calendar next week', function (assert) {
185 var i, m;
186 for (i = 2; i < 7; i++) {
187 m = moment().add({d: i});
188 assert.equal(m.calendar(), m.format('dddd [pulksten] LT'), 'Today + ' + i + ' days current time');
189 m.hours(0).minutes(0).seconds(0).milliseconds(0);
190 assert.equal(m.calendar(), m.format('dddd [pulksten] LT'), 'Today + ' + i + ' days beginning of day');
191 m.hours(23).minutes(59).seconds(59).milliseconds(999);
192 assert.equal(m.calendar(), m.format('dddd [pulksten] LT'), 'Today + ' + i + ' days end of day');
193 }
194 });
195
196 test('calendar last week', function (assert) {
197 var i, m;
198 for (i = 2; i < 7; i++) {
199 m = moment().subtract({d: i});
200 assert.equal(m.calendar(), m.format('[Pagājušā] dddd [pulksten] LT'), 'Today - ' + i + ' days current time');
201 m.hours(0).minutes(0).seconds(0).milliseconds(0);
202 assert.equal(m.calendar(), m.format('[Pagājušā] dddd [pulksten] LT'), 'Today - ' + i + ' days beginning of day');
203 m.hours(23).minutes(59).seconds(59).milliseconds(999);
204 assert.equal(m.calendar(), m.format('[Pagājušā] dddd [pulksten] LT'), 'Today - ' + i + ' days end of day');
205 }
206 });
207
208 test('calendar all else', function (assert) {
209 var weeksAgo = moment().subtract({w: 1}),
210 weeksFromNow = moment().add({w: 1});
211
212 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
213 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
214
215 weeksAgo = moment().subtract({w: 2});
216 weeksFromNow = moment().add({w: 2});
217
218 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
219 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
220 });
221
222 test('weeks year starting sunday', function (assert) {
223 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
224 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
225 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
226 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
227 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
228 });
229
230 test('weeks year starting monday', function (assert) {
231 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
232 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
233 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
234 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
235 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
236 });
237
238 test('weeks year starting tuesday', function (assert) {
239 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
240 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
241 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
242 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
243 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
244 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
245 });
246
247 test('weeks year starting wednesday', function (assert) {
248 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
249 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
250 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
251 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
252 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
253 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
254 });
255
256 test('weeks year starting thursday', function (assert) {
257 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
258 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
259 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
260 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
261 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
262 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
263 });
264
265 test('weeks year starting friday', function (assert) {
266 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
267 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
268 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
269 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
270 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
271 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
272 });
273
274 test('weeks year starting saturday', function (assert) {
275 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
276 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
277 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
278 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
279 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
280 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
281 });
282
283 test('weeks year starting sunday formatted', function (assert) {
284 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
285 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
286 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
287 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
288 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
289 });
290
291 test('lenient ordinal parsing', function (assert) {
292 var i, ordinalStr, testMoment;
293 for (i = 1; i <= 31; ++i) {
294 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
295 testMoment = moment(ordinalStr, 'YYYY MM Do');
296 assert.equal(testMoment.year(), 2014,
297 'lenient ordinal parsing ' + i + ' year check');
298 assert.equal(testMoment.month(), 0,
299 'lenient ordinal parsing ' + i + ' month check');
300 assert.equal(testMoment.date(), i,
301 'lenient ordinal parsing ' + i + ' date check');
302 }
303 });
304
305 test('lenient ordinal parsing of number', function (assert) {
306 var i, testMoment;
307 for (i = 1; i <= 31; ++i) {
308 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
309 assert.equal(testMoment.year(), 2014,
310 'lenient ordinal parsing of number ' + i + ' year check');
311 assert.equal(testMoment.month(), 0,
312 'lenient ordinal parsing of number ' + i + ' month check');
313 assert.equal(testMoment.date(), i,
314 'lenient ordinal parsing of number ' + i + ' date check');
315 }
316 });
317
318 test('strict ordinal parsing', function (assert) {
319 var i, ordinalStr, testMoment;
320 for (i = 1; i <= 31; ++i) {
321 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
322 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
323 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
324 }
325 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('me');
3
4 test('parse', function (assert) {
5 var tests = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedjelja, 14. februar 2010, 3:25:50 pm'],
26 ['ddd, hA', 'ned., 3PM'],
27 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14. 14'],
30 ['d do dddd ddd dd', '0 0. nedjelja ned. ne'],
31 ['DDD DDDo DDDD', '45 45. 045'],
32 ['w wo ww', '7 7. 07'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
39 ['LTS', '15:25:50'],
40 ['L', '14. 02. 2010'],
41 ['LL', '14. februar 2010'],
42 ['LLL', '14. februar 2010 15:25'],
43 ['LLLL', 'nedjelja, 14. februar 2010 15:25'],
44 ['l', '14. 2. 2010'],
45 ['ll', '14. feb. 2010'],
46 ['lll', '14. feb. 2010 15:25'],
47 ['llll', 'ned., 14. feb. 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
95 i;
96 for (i = 0; i < expected.length; i++) {
97 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
98 }
99 });
100
101 test('format week', function (assert) {
102 var expected = 'nedjelja ned. ne_ponedjeljak pon. po_utorak uto. ut_srijeda sri. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'),
103 i;
104 for (i = 0; i < expected.length; i++) {
105 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
106 }
107 });
108
109 test('from', function (assert) {
110 var start = moment([2007, 1, 28]);
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nekoliko sekundi', '44 seconds = a few seconds');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedan minut', '45 seconds = a minute');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedan minut', '89 seconds = a minute');
114 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuta', '90 seconds = 2 minutes');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
118 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mjesec', '26 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mjesec', '30 days = a month');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mjesec', '43 days = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mjeseca', '46 days = 2 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mjeseca', '75 days = 2 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mjeseca', '76 days = 3 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mjesec', '1 month = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mjeseci', '5 months = 5 months');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
138 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
139 });
140
141 test('suffix', function (assert) {
142 assert.equal(moment(30000).from(0), 'za nekoliko sekundi', 'prefix');
143 assert.equal(moment(0).from(30000), 'prije nekoliko sekundi', 'prefix');
144 });
145
146 test('now from now', function (assert) {
147 assert.equal(moment().fromNow(), 'prije nekoliko sekundi', 'now from now should display as in the past');
148 });
149
150 test('fromNow', function (assert) {
151 assert.equal(moment().add({s: 30}).fromNow(), 'za nekoliko sekundi', 'in a few seconds');
152 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
153 });
154
155 test('calendar day', function (assert) {
156 var a = moment().hours(2).minutes(0).seconds(0);
157
158 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
159 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
160 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
161 assert.equal(moment(a).add({d: 1}).calendar(), 'sjutra u 2:00', 'tomorrow at the same time');
162 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
163 assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
164 });
165
166 test('calendar next week', function (assert) {
167 var i, m;
168
169 function makeFormat(d) {
170 switch (d.day()) {
171 case 0:
172 return '[u] [nedjelju] [u] LT';
173 case 3:
174 return '[u] [srijedu] [u] LT';
175 case 6:
176 return '[u] [subotu] [u] LT';
177 case 1:
178 case 2:
179 case 4:
180 case 5:
181 return '[u] dddd [u] LT';
182 }
183 }
184
185 for (i = 2; i < 7; i++) {
186 m = moment().add({d: i});
187 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
188 m.hours(0).minutes(0).seconds(0).milliseconds(0);
189 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
190 m.hours(23).minutes(59).seconds(59).milliseconds(999);
191 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
192 }
193 });
194
195 test('calendar last week', function (assert) {
196 var i, m;
197
198 function makeFormat(d) {
199 var lastWeekDay = [
200 '[prošle] [nedjelje] [u] LT',
201 '[prošlog] [ponedjeljka] [u] LT',
202 '[prošlog] [utorka] [u] LT',
203 '[prošle] [srijede] [u] LT',
204 '[prošlog] [četvrtka] [u] LT',
205 '[prošlog] [petka] [u] LT',
206 '[prošle] [subote] [u] LT'
207 ];
208
209 return lastWeekDay[d.day()];
210 }
211
212 for (i = 2; i < 7; i++) {
213 m = moment().subtract({d: i});
214 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
215 m.hours(0).minutes(0).seconds(0).milliseconds(0);
216 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
217 m.hours(23).minutes(59).seconds(59).milliseconds(999);
218 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
219 }
220 });
221
222 test('calendar all else', function (assert) {
223 var weeksAgo = moment().subtract({w: 1}),
224 weeksFromNow = moment().add({w: 1});
225
226 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
227 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
228
229 weeksAgo = moment().subtract({w: 2});
230 weeksFromNow = moment().add({w: 2});
231
232 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
233 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
234 });
235
236 // Monday is the first day of the week.
237 // The week that contains Jan 1st is the first week of the year.
238
239 test('weeks year starting sunday', function (assert) {
240 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
241 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
242 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
243 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
244 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
245 });
246
247 test('weeks year starting monday', function (assert) {
248 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
249 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
250 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
251 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
252 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
253 });
254
255 test('weeks year starting tuesday', function (assert) {
256 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
257 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
258 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
259 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
260 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
261 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
262 });
263
264 test('weeks year starting wednesday', function (assert) {
265 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
266 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
267 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
268 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
269 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
270 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
271 });
272
273 test('weeks year starting thursday', function (assert) {
274 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
275 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
276 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
277 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
278 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
279 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
280 });
281
282 test('weeks year starting friday', function (assert) {
283 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
284 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
285 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
286 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
287 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
288 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
289 });
290
291 test('weeks year starting saturday', function (assert) {
292 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
293 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
294 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
295 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
296 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
297 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
298 });
299
300 test('weeks year starting sunday formatted', function (assert) {
301 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
302 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
303 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
304 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
305 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
306 });
307
308 test('lenient ordinal parsing', function (assert) {
309 var i, ordinalStr, testMoment;
310 for (i = 1; i <= 31; ++i) {
311 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
312 testMoment = moment(ordinalStr, 'YYYY MM Do');
313 assert.equal(testMoment.year(), 2014,
314 'lenient ordinal parsing ' + i + ' year check');
315 assert.equal(testMoment.month(), 0,
316 'lenient ordinal parsing ' + i + ' month check');
317 assert.equal(testMoment.date(), i,
318 'lenient ordinal parsing ' + i + ' date check');
319 }
320 });
321
322 test('lenient ordinal parsing of number', function (assert) {
323 var i, testMoment;
324 for (i = 1; i <= 31; ++i) {
325 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
326 assert.equal(testMoment.year(), 2014,
327 'lenient ordinal parsing of number ' + i + ' year check');
328 assert.equal(testMoment.month(), 0,
329 'lenient ordinal parsing of number ' + i + ' month check');
330 assert.equal(testMoment.date(), i,
331 'lenient ordinal parsing of number ' + i + ' date check');
332 }
333 });
334
335 test('strict ordinal parsing', function (assert) {
336 var i, ordinalStr, testMoment;
337 for (i = 1; i <= 31; ++i) {
338 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
339 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
340 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
341 }
342 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('mk');
3
4 test('parse', function (assert) {
5 var tests = 'јануари јан_февруари фев_март мар_април апр_мај мај_јуни јун_јули јул_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, H:mm:ss', 'недела, февруари 14-ти 2010, 15:25:50'],
25 ['ddd, hA', 'нед, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2-ри 02 февруари фев'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14-ти 14'],
29 ['d do dddd ddd dd', '0 0-ев недела нед нe'],
30 ['DDD DDDo DDDD', '45 45-ти 045'],
31 ['w wo ww', '7 7-ми 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45-ти day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14 февруари 2010'],
41 ['LLL', '14 февруари 2010 15:25'],
42 ['LLLL', 'недела, 14 февруари 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14 фев 2010'],
45 ['lll', '14 фев 2010 15:25'],
46 ['llll', 'нед, 14 фев 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-ви', '1-ви');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-ри', '2-ри');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-ти', '3-ти');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-ти', '4-ти');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-ти', '5-ти');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-ти', '6-ти');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-ми', '7-ми');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-ми', '8-ми');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-ти', '9-ти');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-ти', '10-ти');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-ти', '11-ти');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-ти', '12-ти');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-ти', '13-ти');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-ти', '14-ти');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-ти', '15-ти');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-ти', '16-ти');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-ти', '17-ти');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-ти', '18-ти');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-ти', '19-ти');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-ти', '20-ти');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-ви', '21-ви');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-ри', '22-ри');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-ти', '23-ти');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-ти', '24-ти');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-ти', '25-ти');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-ти', '26-ти');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-ми', '27-ми');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-ми', '28-ми');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-ти', '29-ти');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-ти', '30-ти');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-ви', '31-ви');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'јануари јан_февруари фев_март мар_април апр_мај мај_јуни јун_јули јул_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'недела нед нe_понеделник пон пo_вторник вто вт_среда сре ср_четврток чет че_петок пет пе_сабота саб сa'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'неколку секунди', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'минута', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'минута', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минути', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минути', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'час', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'час', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 часа', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 часа', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 часа', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ден', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ден', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дена', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ден', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дена', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дена', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месец', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месец', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месец', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месеци', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месеци', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месеци', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месец', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месеци', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'година', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 години', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'година', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 години', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'после неколку секунди', 'prefix');
140 assert.equal(moment(0).from(30000), 'пред неколку секунди', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'пред неколку секунди', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'после неколку секунди', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'после 5 дена', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'Денес во 2:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'Денес во 2:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'Денес во 3:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'Утре во 2:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Денес во 1:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера во 2:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [во] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [во] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [во] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177
178 function makeFormat(d) {
179 switch (d.day()) {
180 case 0:
181 case 3:
182 case 6:
183 return '[Во изминатата] dddd [во] LT';
184 case 1:
185 case 2:
186 case 4:
187 case 5:
188 return '[Во изминатиот] dddd [во] LT';
189 }
190 }
191
192 for (i = 2; i < 7; i++) {
193 m = moment().subtract({d: i});
194 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
195 m.hours(0).minutes(0).seconds(0).milliseconds(0);
196 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
197 m.hours(23).minutes(59).seconds(59).milliseconds(999);
198 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
199 }
200 });
201
202 test('calendar all else', function (assert) {
203 var weeksAgo = moment().subtract({w: 1}),
204 weeksFromNow = moment().add({w: 1});
205
206 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
207 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
208
209 weeksAgo = moment().subtract({w: 2});
210 weeksFromNow = moment().add({w: 2});
211
212 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
213 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
214 });
215
216 test('weeks year starting sunday', function (assert) {
217 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
218 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
219 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
220 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
221 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
222 });
223
224 test('weeks year starting monday', function (assert) {
225 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
226 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
227 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
228 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
229 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
230 });
231
232 test('weeks year starting tuesday', function (assert) {
233 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
234 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
235 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
236 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
237 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
238 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
239 });
240
241 test('weeks year starting wednesday', function (assert) {
242 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
243 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
244 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
245 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
246 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
247 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
248 });
249
250 test('weeks year starting thursday', function (assert) {
251 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
252 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
253 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
254 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
255 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
256 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
257 });
258
259 test('weeks year starting friday', function (assert) {
260 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
261 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
262 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
263 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
264 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
265 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
266 });
267
268 test('weeks year starting saturday', function (assert) {
269 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
270 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
271 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
272 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
273 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
274 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
275 });
276
277 test('weeks year starting sunday formatted', function (assert) {
278 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
280 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-ри', 'Jan 2 2012 should be week 2');
281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-ри', 'Jan 8 2012 should be week 2');
282 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
283 });
284
285 test('lenient ordinal parsing', function (assert) {
286 var i, ordinalStr, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
289 testMoment = moment(ordinalStr, 'YYYY MM Do');
290 assert.equal(testMoment.year(), 2014,
291 'lenient ordinal parsing ' + i + ' year check');
292 assert.equal(testMoment.month(), 0,
293 'lenient ordinal parsing ' + i + ' month check');
294 assert.equal(testMoment.date(), i,
295 'lenient ordinal parsing ' + i + ' date check');
296 }
297 });
298
299 test('lenient ordinal parsing of number', function (assert) {
300 var i, testMoment;
301 for (i = 1; i <= 31; ++i) {
302 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
303 assert.equal(testMoment.year(), 2014,
304 'lenient ordinal parsing of number ' + i + ' year check');
305 assert.equal(testMoment.month(), 0,
306 'lenient ordinal parsing of number ' + i + ' month check');
307 assert.equal(testMoment.date(), i,
308 'lenient ordinal parsing of number ' + i + ' date check');
309 }
310 });
311
312 test('strict ordinal parsing', function (assert) {
313 var i, ordinalStr, testMoment;
314 for (i = 1; i <= 31; ++i) {
315 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
316 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
317 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
318 }
319 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ml');
3
4 test('parse', function (assert) {
5 var tests = 'ജനുവരി ജനു._ഫെബ്രുവരി ഫെബ്രു._മാർച്ച് മാർ._ഏപ്രിൽ ഏപ്രി._മേയ് മേയ്_ജൂൺ ജൂൺ_ജൂലൈ ജൂലൈ._ഓഗസ്റ്റ് ഓഗ._സെപ്റ്റംബർ സെപ്റ്റ._ഒക്ടോബർ ഒക്ടോ._നവംബർ നവം._ഡിസംബർ ഡിസം.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, a h:mm:ss -നു', 'ഞായറാഴ്ച, 14 ഫെബ്രുവരി 2010, ഉച്ച കഴിഞ്ഞ് 3:25:50 -നു'],
25 ['ddd, a h -നു', 'ഞായർ, ഉച്ച കഴിഞ്ഞ് 3 -നു'],
26 ['M Mo MM MMMM MMM', '2 2 02 ഫെബ്രുവരി ഫെബ്രു.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 ഞായറാഴ്ച ഞായർ ഞാ'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '8 8 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'ഉച്ച കഴിഞ്ഞ് ഉച്ച കഴിഞ്ഞ്'],
37 ['LTS', 'ഉച്ച കഴിഞ്ഞ് 3:25:50 -നു'],
38 ['L', '14/02/2010'],
39 ['LL', '14 ഫെബ്രുവരി 2010'],
40 ['LLL', '14 ഫെബ്രുവരി 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു'],
41 ['LLLL', 'ഞായറാഴ്ച, 14 ഫെബ്രുവരി 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു'],
42 ['l', '14/2/2010'],
43 ['ll', '14 ഫെബ്രു. 2010'],
44 ['lll', '14 ഫെബ്രു. 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു'],
45 ['llll', 'ഞായർ, 14 ഫെബ്രു. 2010, ഉച്ച കഴിഞ്ഞ് 3:25 -നു']
46 ],
47 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
48 i;
49 for (i = 0; i < a.length; i++) {
50 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
51 }
52 });
53
54 test('format ordinal', function (assert) {
55 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
56 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
57 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
58 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
59 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
60 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
61 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
62 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
63 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
64 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
65
66 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
67 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
68 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
69 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
70 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
71 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
72 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
73 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
74 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
75 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
76
77 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
78 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
79 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
80 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
81 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
82 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
83 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
84 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
85 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
86 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
87
88 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
89 });
90
91 test('format month', function (assert) {
92 var expected = 'ജനുവരി ജനു._ഫെബ്രുവരി ഫെബ്രു._മാർച്ച് മാർ._ഏപ്രിൽ ഏപ്രി._മേയ് മേയ്_ജൂൺ ജൂൺ_ജൂലൈ ജൂലൈ._ഓഗസ്റ്റ് ഓഗ._സെപ്റ്റംബർ സെപ്റ്റ._ഒക്ടോബർ ഒക്ടോ._നവംബർ നവം._ഡിസംബർ ഡിസം.'.split('_'), i;
93 for (i = 0; i < expected.length; i++) {
94 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
95 }
96 });
97
98 test('format week', function (assert) {
99 var expected = 'ഞായറാഴ്ച ഞായർ ഞാ_തിങ്കളാഴ്ച തിങ്കൾ തി_ചൊവ്വാഴ്ച ചൊവ്വ ചൊ_ബുധനാഴ്ച ബുധൻ ബു_വ്യാഴാഴ്ച വ്യാഴം വ്യാ_വെള്ളിയാഴ്ച വെള്ളി വെ_ശനിയാഴ്ച ശനി ശ'.split('_'), i;
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
102 }
103 });
104
105 test('from', function (assert) {
106 var start = moment([2007, 1, 28]);
107 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'അൽപ നിമിഷങ്ങൾ', '44 seconds = a few seconds');
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ഒരു മിനിറ്റ്', '45 seconds = a minute');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ഒരു മിനിറ്റ്', '89 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 മിനിറ്റ്', '90 seconds = 2 minutes');
111 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 മിനിറ്റ്', '44 minutes = 44 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ഒരു മണിക്കൂർ', '45 minutes = an hour');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ഒരു മണിക്കൂർ', '89 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 മണിക്കൂർ', '90 minutes = 2 hours');
115 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 മണിക്കൂർ', '5 hours = 5 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 മണിക്കൂർ', '21 hours = 21 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ഒരു ദിവസം', '22 hours = a day');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ഒരു ദിവസം', '35 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ദിവസം', '36 hours = 2 days');
120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ഒരു ദിവസം', '1 day = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ദിവസം', '5 days = 5 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ദിവസം', '25 days = 25 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ഒരു മാസം', '26 days = a month');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ഒരു മാസം', '30 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ഒരു മാസം', '43 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 മാസം', '46 days = 2 months');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 മാസം', '75 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 മാസം', '76 days = 3 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ഒരു മാസം', '1 month = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 മാസം', '5 months = 5 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ഒരു വർഷം', '345 days = a year');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 വർഷം', '548 days = 2 years');
133 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ഒരു വർഷം', '1 year = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 വർഷം', '5 years = 5 years');
135 });
136
137 test('suffix', function (assert) {
138 assert.equal(moment(30000).from(0), 'അൽപ നിമിഷങ്ങൾ കഴിഞ്ഞ്', 'prefix');
139 assert.equal(moment(0).from(30000), 'അൽപ നിമിഷങ്ങൾ മുൻപ്', 'suffix');
140 });
141
142 test('now from now', function (assert) {
143 assert.equal(moment().fromNow(), 'അൽപ നിമിഷങ്ങൾ മുൻപ്', 'now from now should display as in the past');
144 });
145
146 test('fromNow', function (assert) {
147 assert.equal(moment().add({s: 30}).fromNow(), 'അൽപ നിമിഷങ്ങൾ കഴിഞ്ഞ്', 'അൽപ നിമിഷങ്ങൾ കഴിഞ്ഞ്');
148 assert.equal(moment().add({d: 5}).fromNow(), '5 ദിവസം കഴിഞ്ഞ്', '5 ദിവസം കഴിഞ്ഞ്');
149 });
150
151 test('calendar day', function (assert) {
152 var a = moment().hours(2).minutes(0).seconds(0);
153
154 assert.equal(moment(a).calendar(), 'ഇന്ന് രാത്രി 2:00 -നു', 'today at the same time');
155 assert.equal(moment(a).add({m: 25}).calendar(), 'ഇന്ന് രാത്രി 2:25 -നു', 'Now plus 25 min');
156 assert.equal(moment(a).add({h: 3}).calendar(), 'ഇന്ന് രാവിലെ 5:00 -നു', 'Now plus 3 hour');
157 assert.equal(moment(a).add({d: 1}).calendar(), 'നാളെ രാത്രി 2:00 -നു', 'tomorrow at the same time');
158 assert.equal(moment(a).subtract({h: 1}).calendar(), 'ഇന്ന് രാത്രി 1:00 -നു', 'Now minus 1 hour');
159 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ഇന്നലെ രാത്രി 2:00 -നു', 'yesterday at the same time');
160 });
161
162 test('calendar next week', function (assert) {
163 var i, m;
164 for (i = 2; i < 7; i++) {
165 m = moment().add({d: i});
166 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
167 m.hours(0).minutes(0).seconds(0).milliseconds(0);
168 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
169 m.hours(23).minutes(59).seconds(59).milliseconds(999);
170 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
171 }
172 });
173
174 test('calendar last week', function (assert) {
175 var i, m;
176
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[കഴിഞ്ഞ] dddd[,] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[കഴിഞ്ഞ] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[കഴിഞ്ഞ] dddd[,] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('meridiem', function (assert) {
202 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'രാത്രി', 'before dawn');
203 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'രാവിലെ', 'morning');
204 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'ഉച്ച കഴിഞ്ഞ്', 'during day');
205 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'വൈകുന്നേരം', 'evening');
206 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'വൈകുന്നേരം', 'late evening');
207 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'രാത്രി', 'night');
208
209 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'രാത്രി', 'before dawn');
210 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'രാവിലെ', 'morning');
211 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'ഉച്ച കഴിഞ്ഞ്', ' during day');
212 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'വൈകുന്നേരം', 'evening');
213 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'വൈകുന്നേരം', 'late evening');
214 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'രാത്രി', 'night');
215 });
216
217 test('weeks year starting sunday', function (assert) {
218 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
219 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
220 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
221 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
222 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
223 });
224
225 test('weeks year starting monday', function (assert) {
226 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
227 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
228 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
229 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
230 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
231 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
232 });
233
234 test('weeks year starting tuesday', function (assert) {
235 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
236 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
237 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
238 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
239 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
240 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
241 });
242
243 test('weeks year starting wednesday', function (assert) {
244 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
245 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
246 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
247 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
248 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
249 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
250 });
251
252 test('weeks year starting thursday', function (assert) {
253 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
254 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
255 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
256 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
257 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
258 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
259 });
260
261 test('weeks year starting friday', function (assert) {
262 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
263 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
264 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
265 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
266 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
267 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
268 });
269
270 test('weeks year starting saturday', function (assert) {
271 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
272 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
273 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
274 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
275 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
276 });
277
278 test('weeks year starting sunday formatted', function (assert) {
279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
280 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
282 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
283 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
284 });
285
286 test('lenient ordinal parsing', function (assert) {
287 var i, ordinalStr, testMoment;
288 for (i = 1; i <= 31; ++i) {
289 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
290 testMoment = moment(ordinalStr, 'YYYY MM Do');
291 assert.equal(testMoment.year(), 2014,
292 'lenient ordinal parsing ' + i + ' year check');
293 assert.equal(testMoment.month(), 0,
294 'lenient ordinal parsing ' + i + ' month check');
295 assert.equal(testMoment.date(), i,
296 'lenient ordinal parsing ' + i + ' date check');
297 }
298 });
299
300 test('lenient ordinal parsing of number', function (assert) {
301 var i, testMoment;
302 for (i = 1; i <= 31; ++i) {
303 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
304 assert.equal(testMoment.year(), 2014,
305 'lenient ordinal parsing of number ' + i + ' year check');
306 assert.equal(testMoment.month(), 0,
307 'lenient ordinal parsing of number ' + i + ' month check');
308 assert.equal(testMoment.date(), i,
309 'lenient ordinal parsing of number ' + i + ' date check');
310 }
311 });
312
313 test('strict ordinal parsing', function (assert) {
314 var i, ordinalStr, testMoment;
315 for (i = 1; i <= 31; ++i) {
316 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
317 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
318 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
319 }
320 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('mr');
3
4 test('parse', function (assert) {
5 var tests = 'जानेवारी जाने._फेब्रुवारी फेब्रु._मार्च मार्च._एप्रिल एप्रि._मे मे._जून जून._जुलै जुलै._ऑगस्ट ऑग._सप्टेंबर सप्टें._ऑक्टोबर ऑक्टो._नोव्हेंबर नोव्हें._डिसेंबर डिसें.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, a h:mm:ss वाजता', 'रविवार, १४ फेब्रुवारी २०१०, दुपारी ३:२५:५० वाजता'],
25 ['ddd, a h वाजता', 'रवि, दुपारी ३ वाजता'],
26 ['M Mo MM MMMM MMM', '२ २ ०२ फेब्रुवारी फेब्रु.'],
27 ['YYYY YY', '२०१० १०'],
28 ['D Do DD', '१४ १४ १४'],
29 ['d do dddd ddd dd', '० ० रविवार रवि र'],
30 ['DDD DDDo DDDD', '४५ ४५ ०४५'],
31 ['w wo ww', '८ ८ ०८'],
32 ['h hh', '३ ०३'],
33 ['H HH', '१५ १५'],
34 ['m mm', '२५ २५'],
35 ['s ss', '५० ५०'],
36 ['a A', 'दुपारी दुपारी'],
37 ['LTS', 'दुपारी ३:२५:५० वाजता'],
38 ['L', '१४/०२/२०१०'],
39 ['LL', '१४ फेब्रुवारी २०१०'],
40 ['LLL', '१४ फेब्रुवारी २०१०, दुपारी ३:२५ वाजता'],
41 ['LLLL', 'रविवार, १४ फेब्रुवारी २०१०, दुपारी ३:२५ वाजता'],
42 ['l', '१४/२/२०१०'],
43 ['ll', '१४ फेब्रु. २०१०'],
44 ['lll', '१४ फेब्रु. २०१०, दुपारी ३:२५ वाजता'],
45 ['llll', 'रवि, १४ फेब्रु. २०१०, दुपारी ३:२५ वाजता']
46 ],
47 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
48 i;
49 for (i = 0; i < a.length; i++) {
50 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
51 }
52 });
53
54 test('format ordinal', function (assert) {
55 assert.equal(moment([2011, 0, 1]).format('DDDo'), '१', '१');
56 assert.equal(moment([2011, 0, 2]).format('DDDo'), '२', '२');
57 assert.equal(moment([2011, 0, 3]).format('DDDo'), '३', '३');
58 assert.equal(moment([2011, 0, 4]).format('DDDo'), '४', '४');
59 assert.equal(moment([2011, 0, 5]).format('DDDo'), '५', '५');
60 assert.equal(moment([2011, 0, 6]).format('DDDo'), '६', '६');
61 assert.equal(moment([2011, 0, 7]).format('DDDo'), '७', '७');
62 assert.equal(moment([2011, 0, 8]).format('DDDo'), '८', '८');
63 assert.equal(moment([2011, 0, 9]).format('DDDo'), '९', '९');
64 assert.equal(moment([2011, 0, 10]).format('DDDo'), '१०', '१०');
65
66 assert.equal(moment([2011, 0, 11]).format('DDDo'), '११', '११');
67 assert.equal(moment([2011, 0, 12]).format('DDDo'), '१२', '१२');
68 assert.equal(moment([2011, 0, 13]).format('DDDo'), '१३', '१३');
69 assert.equal(moment([2011, 0, 14]).format('DDDo'), '१४', '१४');
70 assert.equal(moment([2011, 0, 15]).format('DDDo'), '१५', '१५');
71 assert.equal(moment([2011, 0, 16]).format('DDDo'), '१६', '१६');
72 assert.equal(moment([2011, 0, 17]).format('DDDo'), '१७', '१७');
73 assert.equal(moment([2011, 0, 18]).format('DDDo'), '१८', '१८');
74 assert.equal(moment([2011, 0, 19]).format('DDDo'), '१९', '१९');
75 assert.equal(moment([2011, 0, 20]).format('DDDo'), '२०', '२०');
76
77 assert.equal(moment([2011, 0, 21]).format('DDDo'), '२१', '२१');
78 assert.equal(moment([2011, 0, 22]).format('DDDo'), '२२', '२२');
79 assert.equal(moment([2011, 0, 23]).format('DDDo'), '२३', '२३');
80 assert.equal(moment([2011, 0, 24]).format('DDDo'), '२४', '२४');
81 assert.equal(moment([2011, 0, 25]).format('DDDo'), '२५', '२५');
82 assert.equal(moment([2011, 0, 26]).format('DDDo'), '२६', '२६');
83 assert.equal(moment([2011, 0, 27]).format('DDDo'), '२७', '२७');
84 assert.equal(moment([2011, 0, 28]).format('DDDo'), '२८', '२८');
85 assert.equal(moment([2011, 0, 29]).format('DDDo'), '२९', '२९');
86 assert.equal(moment([2011, 0, 30]).format('DDDo'), '३०', '३०');
87
88 assert.equal(moment([2011, 0, 31]).format('DDDo'), '३१', '३१');
89 });
90
91 test('format month', function (assert) {
92 var expected = 'जानेवारी जाने._फेब्रुवारी फेब्रु._मार्च मार्च._एप्रिल एप्रि._मे मे._जून जून._जुलै जुलै._ऑगस्ट ऑग._सप्टेंबर सप्टें._ऑक्टोबर ऑक्टो._नोव्हेंबर नोव्हें._डिसेंबर डिसें.'.split('_'), i;
93 for (i = 0; i < expected.length; i++) {
94 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
95 }
96 });
97
98 test('format week', function (assert) {
99 var expected = 'रविवार रवि र_सोमवार सोम सो_मंगळवार मंगळ मं_बुधवार बुध बु_गुरूवार गुरू गु_शुक्रवार शुक्र शु_शनिवार शनि श'.split('_'), i;
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
102 }
103 });
104
105 test('from', function (assert) {
106 var start = moment([2007, 1, 28]);
107 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'सेकंद', '44 seconds = a few seconds');
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'एक मिनिट', '45 seconds = a minute');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'एक मिनिट', '89 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '२ मिनिटे', '90 seconds = 2 minutes');
111 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '४४ मिनिटे', '44 minutes = 44 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'एक तास', '45 minutes = an hour');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'एक तास', '89 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '२ तास', '90 minutes = 2 hours');
115 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '५ तास', '5 hours = 5 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '२१ तास', '21 hours = 21 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'एक दिवस', '22 hours = a day');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'एक दिवस', '35 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '२ दिवस', '36 hours = 2 days');
120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'एक दिवस', '1 day = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '५ दिवस', '5 days = 5 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '२५ दिवस', '25 days = 25 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'एक महिना', '26 days = a month');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'एक महिना', '30 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'एक महिना', '43 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '२ महिने', '46 days = 2 months');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '२ महिने', '75 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '३ महिने', '76 days = 3 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'एक महिना', '1 month = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '५ महिने', '5 months = 5 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'एक वर्ष', '345 days = a year');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '२ वर्षे', '548 days = 2 years');
133 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'एक वर्ष', '1 year = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '५ वर्षे', '5 years = 5 years');
135 });
136
137 test('suffix', function (assert) {
138 assert.equal(moment(30000).from(0), 'सेकंद नंतर', 'prefix');
139 assert.equal(moment(0).from(30000), 'सेकंद पूर्वी', 'suffix');
140 });
141
142 test('now from now', function (assert) {
143 assert.equal(moment().fromNow(), 'सेकंद पूर्वी', 'now from now should display as in the past');
144 });
145
146 test('fromNow', function (assert) {
147 assert.equal(moment().add({s: 30}).fromNow(), 'सेकंद नंतर', 'सेकंद नंतर');
148 assert.equal(moment().add({d: 5}).fromNow(), '५ दिवस नंतर', '५ दिवस नंतर');
149 });
150
151 test('calendar day', function (assert) {
152 var a = moment().hours(2).minutes(0).seconds(0);
153
154 assert.equal(moment(a).calendar(), 'आज रात्री २:०० वाजता', 'today at the same time');
155 assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात्री २:२५ वाजता', 'Now plus 25 min');
156 assert.equal(moment(a).add({h: 3}).calendar(), 'आज सकाळी ५:०० वाजता', 'Now plus 3 hour');
157 assert.equal(moment(a).add({d: 1}).calendar(), 'उद्या रात्री २:०० वाजता', 'tomorrow at the same time');
158 assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात्री १:०० वाजता', 'Now minus 1 hour');
159 assert.equal(moment(a).subtract({d: 1}).calendar(), 'काल रात्री २:०० वाजता', 'yesterday at the same time');
160 });
161
162 test('calendar next week', function (assert) {
163 var i, m;
164 for (i = 2; i < 7; i++) {
165 m = moment().add({d: i});
166 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
167 m.hours(0).minutes(0).seconds(0).milliseconds(0);
168 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
169 m.hours(23).minutes(59).seconds(59).milliseconds(999);
170 assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
171 }
172 });
173
174 test('calendar last week', function (assert) {
175 var i, m;
176
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[मागील] dddd[,] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[मागील] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[मागील] dddd[,] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('meridiem', function (assert) {
202 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'रात्री', 'before dawn');
203 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'सकाळी', 'morning');
204 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दुपारी', 'during day');
205 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'सायंकाळी', 'evening');
206 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'सायंकाळी', 'late evening');
207 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'रात्री', 'night');
208
209 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'रात्री', 'before dawn');
210 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'सकाळी', 'morning');
211 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'दुपारी', ' during day');
212 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'सायंकाळी', 'evening');
213 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'सायंकाळी', 'late evening');
214 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात्री', 'night');
215 });
216
217 test('weeks year starting sunday', function (assert) {
218 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
219 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
220 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
221 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
222 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
223 });
224
225 test('weeks year starting monday', function (assert) {
226 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
227 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
228 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
229 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
230 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
231 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
232 });
233
234 test('weeks year starting tuesday', function (assert) {
235 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
236 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
237 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
238 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
239 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
240 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
241 });
242
243 test('weeks year starting wednesday', function (assert) {
244 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
245 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
246 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
247 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
248 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
249 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
250 });
251
252 test('weeks year starting thursday', function (assert) {
253 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
254 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
255 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
256 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
257 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
258 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
259 });
260
261 test('weeks year starting friday', function (assert) {
262 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
263 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
264 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
265 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
266 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
267 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
268 });
269
270 test('weeks year starting saturday', function (assert) {
271 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
272 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
273 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
274 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
275 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
276 });
277
278 test('weeks year starting sunday formatted', function (assert) {
279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
280 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '२ ०२ २', 'Jan 8 2012 should be week 2');
282 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '२ ०२ २', 'Jan 14 2012 should be week 2');
283 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
284 });
285
286 test('lenient ordinal parsing', function (assert) {
287 var i, ordinalStr, testMoment;
288 for (i = 1; i <= 31; ++i) {
289 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
290 testMoment = moment(ordinalStr, 'YYYY MM Do');
291 assert.equal(testMoment.year(), 2014,
292 'lenient ordinal parsing ' + i + ' year check');
293 assert.equal(testMoment.month(), 0,
294 'lenient ordinal parsing ' + i + ' month check');
295 assert.equal(testMoment.date(), i,
296 'lenient ordinal parsing ' + i + ' date check');
297 }
298 });
299
300 test('lenient ordinal parsing of number', function (assert) {
301 var i, testMoment;
302 for (i = 1; i <= 31; ++i) {
303 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
304 assert.equal(testMoment.year(), 2014,
305 'lenient ordinal parsing of number ' + i + ' year check');
306 assert.equal(testMoment.month(), 0,
307 'lenient ordinal parsing of number ' + i + ' month check');
308 assert.equal(testMoment.date(), i,
309 'lenient ordinal parsing of number ' + i + ' date check');
310 }
311 });
312
313 test('meridiem invariant', function (assert) {
314 var h, m, t1, t2;
315 for (h = 0; h < 24; ++h) {
316 for (m = 0; m < 60; m += 15) {
317 t1 = moment.utc([2000, 0, 1, h, m]);
318 t2 = moment(t1.format('A h:mm'), 'A h:mm');
319 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
320 'meridiem at ' + t1.format('HH:mm'));
321 }
322 }
323 });
324
325 test('strict ordinal parsing', function (assert) {
326 var i, ordinalStr, testMoment;
327 for (i = 1; i <= 31; ++i) {
328 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
329 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
330 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
331 }
332 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ms-my');
3
4 test('parse', function (assert) {
5 var i,
6 tests = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' sepatutnya bulan ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Ahad, Februari 14 2010, 3:25:50 petang'],
28 ['ddd, hA', 'Ahd, 3petang'],
29 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 14 14'],
32 ['d do dddd ddd dd', '0 0 Ahad Ahd Ah'],
33 ['DDD DDDo DDDD', '45 45 045'],
34 ['w wo ww', '7 7 07'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'petang petang'],
40 ['[hari] [ke] DDDo [tahun] ini', 'hari ke 45 tahun ini'],
41 ['LTS', '15.25.50'],
42 ['L', '14/02/2010'],
43 ['LL', '14 Februari 2010'],
44 ['LLL', '14 Februari 2010 pukul 15.25'],
45 ['LLLL', 'Ahad, 14 Februari 2010 pukul 15.25'],
46 ['l', '14/2/2010'],
47 ['ll', '14 Feb 2010'],
48 ['lll', '14 Feb 2010 pukul 15.25'],
49 ['llll', 'Ahd, 14 Feb 2010 pukul 15.25']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format ordinal', function (assert) {
60 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
61 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
62 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
63 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
64 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
65 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
66 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
67 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
68 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
69 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
70
71 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
72 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
73 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
74 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
75 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
76 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
77 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
78 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
79 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
80 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
81
82 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
83 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
84 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
85 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
86 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
87 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
88 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
89 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
90 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
91 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
92
93 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
94 });
95
96 test('format month', function (assert) {
97 var i,
98 expected = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
99
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
102 }
103 });
104
105 test('format week', function (assert) {
106 var i,
107 expected = 'Ahad Ahd Ah_Isnin Isn Is_Selasa Sel Sl_Rabu Rab Rb_Khamis Kha Km_Jumaat Jum Jm_Sabtu Sab Sb'.split('_');
108
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
111 }
112 });
113
114 test('from', function (assert) {
115 var start = moment([2007, 1, 28]);
116
117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'beberapa saat', '44 saat = beberapa saat');
118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'seminit', '45 saat = seminit');
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'seminit', '89 saat = seminit');
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minit', '90 saat = 2 minit');
121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minit', '44 minit = 44 minit');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'sejam', '45 minit = sejam');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'sejam', '89 minit = sejam');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minit = 2 jam');
125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 jam = 5 jam');
126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 jam = 21 jam');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sehari', '22 jam = sehari');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sehari', '35 jam = sehari');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 hari', '36 jam = 2 hari');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sehari', '1 hari = sehari');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 hari', '5 hari = 5 hari');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 hari', '25 hari = 25 hari');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sebulan', '26 hari = sebulan');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sebulan', '30 hari = sebulan');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sebulan', '45 hari = sebulan');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 bulan', '46 hari = 2 bulan');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 bulan', '75 hari = 2 bulan');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 bulan', '76 hari = 3 bulan');
139 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sebulan', '1 bulan = sebulan');
140 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 bulan', '5 bulan = 5 bulan');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setahun', '345 hari = setahun');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 tahun', '548 hari = 2 tahun');
143 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setahun', '1 tahun = setahun');
144 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 tahun', '5 tahun = 5 tahun');
145 });
146
147 test('suffix', function (assert) {
148 assert.equal(moment(30000).from(0), 'dalam beberapa saat', 'prefix');
149 assert.equal(moment(0).from(30000), 'beberapa saat yang lepas', 'suffix');
150 });
151
152 test('now from now', function (assert) {
153 assert.equal(moment().fromNow(), 'beberapa saat yang lepas', 'waktu sekarang dari sekarang sepatutnya menunjukkan sebagai telah lepas');
154 });
155
156 test('fromNow', function (assert) {
157 assert.equal(moment().add({s: 30}).fromNow(), 'dalam beberapa saat', 'dalam beberapa saat');
158 assert.equal(moment().add({d: 5}).fromNow(), 'dalam 5 hari', 'dalam 5 hari');
159 });
160
161 test('calendar day', function (assert) {
162 var a = moment().hours(2).minutes(0).seconds(0);
163
164 assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
165 assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
166 assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
167 assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
168 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
169 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
170 });
171
172 test('calendar next week', function (assert) {
173 var i, m;
174 for (i = 2; i < 7; i++) {
175 m = moment().add({d: i});
176 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari waktu sekarang');
177 m.hours(0).minutes(0).seconds(0).milliseconds(0);
178 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari permulaan hari');
179 m.hours(23).minutes(59).seconds(59).milliseconds(999);
180 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari tamat hari');
181 }
182 });
183
184 test('calendar last week', function (assert) {
185 var i, m;
186 for (i = 2; i < 7; i++) {
187 m = moment().subtract({d: i});
188 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari waktu sekarang');
189 m.hours(0).minutes(0).seconds(0).milliseconds(0);
190 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari permulaan hari');
191 m.hours(23).minutes(59).seconds(59).milliseconds(999);
192 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari tamat hari');
193 }
194 });
195
196 test('calendar all else', function (assert) {
197 var weeksAgo = moment().subtract({w: 1}),
198 weeksFromNow = moment().add({w: 1});
199
200 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 minggu lepas');
201 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 1 minggu');
202
203 weeksAgo = moment().subtract({w: 2});
204 weeksFromNow = moment().add({w: 2});
205
206 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 minggu lepas');
207 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
208 });
209
210 test('weeks year starting sunday', function (assert) {
211 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
212 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
213 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
214 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
215 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
216 });
217
218 test('weeks year starting monday', function (assert) {
219 assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
220 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
221 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
222 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
223 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
224 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
225 });
226
227 test('weeks year starting tuesday', function (assert) {
228 assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
229 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
230 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
231 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
232 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
233 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
234 });
235
236 test('weeks year starting wednesday', function (assert) {
237 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
238 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
239 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
240 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
241 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
242 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
243 });
244
245 test('weeks year starting thursday', function (assert) {
246 assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
247 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
248 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
249 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
250 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
251 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
252 });
253
254 test('weeks year starting friday', function (assert) {
255 assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
256 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
257 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
258 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
259 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
260 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
261 });
262
263 test('weeks year starting saturday', function (assert) {
264 assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
265 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
266 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
267 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
268 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
269 });
270
271 test('weeks year starting sunday format', function (assert) {
272 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
273 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
274 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 sepatutnya minggu 2');
275 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 sepatutnya minggu 3');
276 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
277 });
278
279 test('lenient ordinal parsing', function (assert) {
280 var i, ordinalStr, testMoment;
281 for (i = 1; i <= 31; ++i) {
282 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
283 testMoment = moment(ordinalStr, 'YYYY MM Do');
284 assert.equal(testMoment.year(), 2014,
285 'lenient ordinal parsing ' + i + ' year check');
286 assert.equal(testMoment.month(), 0,
287 'lenient ordinal parsing ' + i + ' month check');
288 assert.equal(testMoment.date(), i,
289 'lenient ordinal parsing ' + i + ' date check');
290 }
291 });
292
293 test('meridiem invariant', function (assert) {
294 var h, m, t1, t2;
295 for (h = 0; h < 24; ++h) {
296 for (m = 0; m < 60; m += 15) {
297 t1 = moment.utc([2000, 0, 1, h, m]);
298 t2 = moment(t1.format('A h:mm'), 'A h:mm');
299 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
300 'meridiem at ' + t1.format('HH:mm'));
301 }
302 }
303 });
304
305 test('lenient ordinal parsing of number', function (assert) {
306 var i, testMoment;
307 for (i = 1; i <= 31; ++i) {
308 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
309 assert.equal(testMoment.year(), 2014,
310 'lenient ordinal parsing of number ' + i + ' year check');
311 assert.equal(testMoment.month(), 0,
312 'lenient ordinal parsing of number ' + i + ' month check');
313 assert.equal(testMoment.date(), i,
314 'lenient ordinal parsing of number ' + i + ' date check');
315 }
316 });
317
318 test('strict ordinal parsing', function (assert) {
319 var i, ordinalStr, testMoment;
320 for (i = 1; i <= 31; ++i) {
321 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
322 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
323 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
324 }
325 });
0 import {localeModule, test} from '../qunit';
1 import {moment} from '../../moment';
2 localeModule('ms');
3
4 test('parse', function (assert) {
5 var i,
6 tests = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' sepatutnya bulan ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Ahad, Februari 14 2010, 3:25:50 petang'],
28 ['ddd, hA', 'Ahd, 3petang'],
29 ['M Mo MM MMMM MMM', '2 2 02 Februari Feb'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 14 14'],
32 ['d do dddd ddd dd', '0 0 Ahad Ahd Ah'],
33 ['DDD DDDo DDDD', '45 45 045'],
34 ['w wo ww', '7 7 07'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'petang petang'],
40 ['[hari] [ke] DDDo [tahun] ini', 'hari ke 45 tahun ini'],
41 ['LTS', '15.25.50'],
42 ['L', '14/02/2010'],
43 ['LL', '14 Februari 2010'],
44 ['LLL', '14 Februari 2010 pukul 15.25'],
45 ['LLLL', 'Ahad, 14 Februari 2010 pukul 15.25'],
46 ['l', '14/2/2010'],
47 ['ll', '14 Feb 2010'],
48 ['lll', '14 Feb 2010 pukul 15.25'],
49 ['llll', 'Ahd, 14 Feb 2010 pukul 15.25']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format ordinal', function (assert) {
60 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
61 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
62 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
63 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
64 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
65 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
66 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
67 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
68 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
69 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
70
71 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
72 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
73 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
74 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
75 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
76 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
77 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
78 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
79 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
80 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
81
82 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
83 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
84 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
85 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
86 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
87 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
88 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
89 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
90 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
91 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
92
93 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
94 });
95
96 test('format month', function (assert) {
97 var i,
98 expected = 'Januari Jan_Februari Feb_Mac Mac_April Apr_Mei Mei_Jun Jun_Julai Jul_Ogos Ogs_September Sep_Oktober Okt_November Nov_Disember Dis'.split('_');
99
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
102 }
103 });
104
105 test('format week', function (assert) {
106 var i,
107 expected = 'Ahad Ahd Ah_Isnin Isn Is_Selasa Sel Sl_Rabu Rab Rb_Khamis Kha Km_Jumaat Jum Jm_Sabtu Sab Sb'.split('_');
108
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
111 }
112 });
113
114 test('from', function (assert) {
115 var start = moment([2007, 1, 28]);
116
117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'beberapa saat', '44 saat = beberapa saat');
118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'seminit', '45 saat = seminit');
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'seminit', '89 saat = seminit');
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minit', '90 saat = 2 minit');
121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minit', '44 minit = 44 minit');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'sejam', '45 minit = sejam');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'sejam', '89 minit = sejam');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 jam', '90 minit = 2 jam');
125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 jam', '5 jam = 5 jam');
126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 jam', '21 jam = 21 jam');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'sehari', '22 jam = sehari');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'sehari', '35 jam = sehari');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 hari', '36 jam = 2 hari');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'sehari', '1 hari = sehari');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 hari', '5 hari = 5 hari');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 hari', '25 hari = 25 hari');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'sebulan', '26 hari = sebulan');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'sebulan', '30 hari = sebulan');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'sebulan', '45 hari = sebulan');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 bulan', '46 hari = 2 bulan');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 bulan', '75 hari = 2 bulan');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 bulan', '76 hari = 3 bulan');
139 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'sebulan', '1 bulan = sebulan');
140 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 bulan', '5 bulan = 5 bulan');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'setahun', '345 hari = setahun');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 tahun', '548 hari = 2 tahun');
143 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'setahun', '1 tahun = setahun');
144 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 tahun', '5 tahun = 5 tahun');
145 });
146
147 test('suffix', function (assert) {
148 assert.equal(moment(30000).from(0), 'dalam beberapa saat', 'prefix');
149 assert.equal(moment(0).from(30000), 'beberapa saat yang lepas', 'suffix');
150 });
151
152 test('now from now', function (assert) {
153 assert.equal(moment().fromNow(), 'beberapa saat yang lepas', 'waktu sekarang dari sekarang sepatutnya menunjukkan sebagai telah lepas');
154 });
155
156 test('fromNow', function (assert) {
157 assert.equal(moment().add({s: 30}).fromNow(), 'dalam beberapa saat', 'dalam beberapa saat');
158 assert.equal(moment().add({d: 5}).fromNow(), 'dalam 5 hari', 'dalam 5 hari');
159 });
160
161 test('calendar day', function (assert) {
162 var a = moment().hours(2).minutes(0).seconds(0);
163
164 assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
165 assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
166 assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
167 assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
168 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
169 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
170 });
171
172 test('calendar next week', function (assert) {
173 var i, m;
174 for (i = 2; i < 7; i++) {
175 m = moment().add({d: i});
176 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari waktu sekarang');
177 m.hours(0).minutes(0).seconds(0).milliseconds(0);
178 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari permulaan hari');
179 m.hours(23).minutes(59).seconds(59).milliseconds(999);
180 assert.equal(m.calendar(), m.format('dddd [pukul] LT'), 'Hari ini + ' + i + ' hari tamat hari');
181 }
182 });
183
184 test('calendar last week', function (assert) {
185 var i, m;
186 for (i = 2; i < 7; i++) {
187 m = moment().subtract({d: i});
188 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari waktu sekarang');
189 m.hours(0).minutes(0).seconds(0).milliseconds(0);
190 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari permulaan hari');
191 m.hours(23).minutes(59).seconds(59).milliseconds(999);
192 assert.equal(m.calendar(), m.format('dddd [lepas] [pukul] LT'), 'Hari ini - ' + i + ' hari tamat hari');
193 }
194 });
195
196 test('calendar all else', function (assert) {
197 var weeksAgo = moment().subtract({w: 1}),
198 weeksFromNow = moment().add({w: 1});
199
200 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 minggu lepas');
201 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 1 minggu');
202
203 weeksAgo = moment().subtract({w: 2});
204 weeksFromNow = moment().add({w: 2});
205
206 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 minggu lepas');
207 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
208 });
209
210 test('weeks year starting sunday', function (assert) {
211 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
212 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
213 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
214 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
215 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
216 });
217
218 test('weeks year starting monday', function (assert) {
219 assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
220 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
221 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
222 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
223 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
224 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
225 });
226
227 test('weeks year starting tuesday', function (assert) {
228 assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
229 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
230 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
231 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
232 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
233 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
234 });
235
236 test('weeks year starting wednesday', function (assert) {
237 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
238 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
239 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
240 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
241 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
242 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
243 });
244
245 test('weeks year starting thursday', function (assert) {
246 assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
247 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
248 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
249 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
250 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
251 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
252 });
253
254 test('weeks year starting friday', function (assert) {
255 assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
256 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
257 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
258 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
259 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
260 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
261 });
262
263 test('weeks year starting saturday', function (assert) {
264 assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
265 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
266 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
267 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
268 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
269 });
270
271 test('weeks year starting sunday format', function (assert) {
272 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
273 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
274 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 sepatutnya minggu 2');
275 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 sepatutnya minggu 3');
276 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
277 });
278
279 test('lenient ordinal parsing', function (assert) {
280 var i, ordinalStr, testMoment;
281 for (i = 1; i <= 31; ++i) {
282 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
283 testMoment = moment(ordinalStr, 'YYYY MM Do');
284 assert.equal(testMoment.year(), 2014,
285 'lenient ordinal parsing ' + i + ' year check');
286 assert.equal(testMoment.month(), 0,
287 'lenient ordinal parsing ' + i + ' month check');
288 assert.equal(testMoment.date(), i,
289 'lenient ordinal parsing ' + i + ' date check');
290 }
291 });
292
293 test('meridiem invariant', function (assert) {
294 var h, m, t1, t2;
295 for (h = 0; h < 24; ++h) {
296 for (m = 0; m < 60; m += 15) {
297 t1 = moment.utc([2000, 0, 1, h, m]);
298 t2 = moment(t1.format('A h:mm'), 'A h:mm');
299 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
300 'meridiem at ' + t1.format('HH:mm'));
301 }
302 }
303 });
304
305 test('lenient ordinal parsing of number', function (assert) {
306 var i, testMoment;
307 for (i = 1; i <= 31; ++i) {
308 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
309 assert.equal(testMoment.year(), 2014,
310 'lenient ordinal parsing of number ' + i + ' year check');
311 assert.equal(testMoment.month(), 0,
312 'lenient ordinal parsing of number ' + i + ' month check');
313 assert.equal(testMoment.date(), i,
314 'lenient ordinal parsing of number ' + i + ' date check');
315 }
316 });
317
318 test('strict ordinal parsing', function (assert) {
319 var i, ordinalStr, testMoment;
320 for (i = 1; i <= 31; ++i) {
321 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
322 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
323 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
324 }
325 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('my');
3
4 test('parse', function (assert) {
5 var tests = 'ဇန်နဝါရီ ဇန်_ဖေဖော်ဝါရီ ဖေ_မတ် မတ်_ဧပြီ ပြီ_မေ မေ_ဇွန် ဇွန်_ဇူလိုင် လိုင်_သြဂုတ် သြ_စက်တင်ဘာ စက်_အောက်တိုဘာ အောက်_နိုဝင်ဘာ နို_ဒီဇင်ဘာ ဒီ'.split('_'),
6 i;
7
8 function equalTest (input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11 for (i = 0; i < 12; i++) {
12 tests[i] = tests[i].split(' ');
13 equalTest(tests[i][0], 'MMM', i);
14 equalTest(tests[i][1], 'MMM', i);
15 equalTest(tests[i][0], 'MMMM', i);
16 equalTest(tests[i][1], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21 }
22 });
23
24 test('format', function (assert) {
25 var a = [
26 ['dddd, MMMM Do YYYY, h:mm:ss a', 'တနင်္ဂနွေ, ဖေဖော်ဝါရီ ၁၄ ၂၀၁၀, ၃:၂၅:၅၀ pm'],
27 ['ddd, hA', 'နွေ, ၃PM'],
28 ['M Mo MM MMMM MMM', '၂ ၂ ၀၂ ဖေဖော်ဝါရီ ဖေ'],
29 ['YYYY YY', '၂၀၁၀ ၁၀'],
30 ['D Do DD', '၁၄ ၁၄ ၁၄'],
31 ['d do dddd ddd dd', '၀ ၀ တနင်္ဂနွေ နွေ နွေ'],
32 ['DDD DDDo DDDD', '၄၅ ၄၅ ၀၄၅'],
33 ['w wo ww', '၆ ၆ ၀၆'],
34 ['h hh', '၃ ၀၃'],
35 ['H HH', '၁၅ ၁၅'],
36 ['m mm', '၂၅ ၂၅'],
37 ['s ss', '၅၀ ၅၀'],
38 ['a A', 'pm PM'],
39 ['[နှစ်၏] DDDo [ရက်မြောက်]', 'နှစ်၏ ၄၅ ရက်မြောက်'],
40 ['LTS', '၁၅:၂၅:၅၀'],
41 ['L', '၁၄/၀၂/၂၀၁၀'],
42 ['LL', '၁၄ ဖေဖော်ဝါရီ ၂၀၁၀'],
43 ['LLL', '၁၄ ဖေဖော်ဝါရီ ၂၀၁၀ ၁၅:၂၅'],
44 ['LLLL', 'တနင်္ဂနွေ ၁၄ ဖေဖော်ဝါရီ ၂၀၁၀ ၁၅:၂၅'],
45 ['l', '၁၄/၂/၂၀၁၀'],
46 ['ll', '၁၄ ဖေ ၂၀၁၀'],
47 ['lll', '၁၄ ဖေ ၂၀၁၀ ၁၅:၂၅'],
48 ['llll', 'နွေ ၁၄ ဖေ ၂၀၁၀ ၁၅:၂၅']
49 ],
50 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
51 i;
52 for (i = 0; i < a.length; i++) {
53 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
54 }
55 });
56
57 test('format ordinal', function (assert) {
58 assert.equal(moment([2011, 0, 1]).format('DDDo'), '၁', '၁');
59 assert.equal(moment([2011, 0, 2]).format('DDDo'), '၂', '၂');
60 assert.equal(moment([2011, 0, 3]).format('DDDo'), '၃', '၃');
61 assert.equal(moment([2011, 0, 4]).format('DDDo'), '၄', '၄');
62 assert.equal(moment([2011, 0, 5]).format('DDDo'), '၅', '၅');
63 assert.equal(moment([2011, 0, 6]).format('DDDo'), '၆', '၆');
64 assert.equal(moment([2011, 0, 7]).format('DDDo'), '၇', '၇');
65 assert.equal(moment([2011, 0, 8]).format('DDDo'), '၈', '၈');
66 assert.equal(moment([2011, 0, 9]).format('DDDo'), '၉', '၉');
67 assert.equal(moment([2011, 0, 10]).format('DDDo'), '၁၀', '၁၀');
68
69 assert.equal(moment([2011, 0, 11]).format('DDDo'), '၁၁', '၁၁');
70 assert.equal(moment([2011, 0, 12]).format('DDDo'), '၁၂', '၁၂');
71 assert.equal(moment([2011, 0, 13]).format('DDDo'), '၁၃', '၁၃');
72 assert.equal(moment([2011, 0, 14]).format('DDDo'), '၁၄', '၁၄');
73 assert.equal(moment([2011, 0, 15]).format('DDDo'), '၁၅', '၁၅');
74 assert.equal(moment([2011, 0, 16]).format('DDDo'), '၁၆', '၁၆');
75 assert.equal(moment([2011, 0, 17]).format('DDDo'), '၁၇', '၁၇');
76 assert.equal(moment([2011, 0, 18]).format('DDDo'), '၁၈', '၁၈');
77 assert.equal(moment([2011, 0, 19]).format('DDDo'), '၁၉', '၁၉');
78 assert.equal(moment([2011, 0, 20]).format('DDDo'), '၂၀', '၂၀');
79
80 assert.equal(moment([2011, 0, 21]).format('DDDo'), '၂၁', '၂၁');
81 assert.equal(moment([2011, 0, 22]).format('DDDo'), '၂၂', '၂၂');
82 assert.equal(moment([2011, 0, 23]).format('DDDo'), '၂၃', '၂၃');
83 assert.equal(moment([2011, 0, 24]).format('DDDo'), '၂၄', '၂၄');
84 assert.equal(moment([2011, 0, 25]).format('DDDo'), '၂၅', '၂၅');
85 assert.equal(moment([2011, 0, 26]).format('DDDo'), '၂၆', '၂၆');
86 assert.equal(moment([2011, 0, 27]).format('DDDo'), '၂၇', '၂၇');
87 assert.equal(moment([2011, 0, 28]).format('DDDo'), '၂၈', '၂၈');
88 assert.equal(moment([2011, 0, 29]).format('DDDo'), '၂၉', '၂၉');
89 assert.equal(moment([2011, 0, 30]).format('DDDo'), '၃၀', '၃၀');
90
91 assert.equal(moment([2011, 0, 31]).format('DDDo'), '၃၁', '၃၁');
92 });
93
94 test('format month', function (assert) {
95 var expected = 'ဇန်နဝါရီ ဇန်_ဖေဖော်ဝါရီ ဖေ_မတ် မတ်_ဧပြီ ပြီ_မေ မေ_ဇွန် ဇွန်_ဇူလိုင် လိုင်_သြဂုတ် သြ_စက်တင်ဘာ စက်_အောက်တိုဘာ အောက်_နိုဝင်ဘာ နို_ဒီဇင်ဘာ ဒီ'.split('_'),
96 i;
97 for (i = 0; i < expected.length; i++) {
98 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
99 }
100 });
101
102 test('format week', function (assert) {
103 var expected = 'တနင်္ဂနွေ နွေ နွေ_တနင်္လာ လာ လာ_အင်္ဂါ ဂါ ဂါ_ဗုဒ္ဓဟူး ဟူး ဟူး_ကြာသပတေး ကြာ ကြာ_သောကြာ သော သော_စနေ နေ နေ'.split('_'),
104 i;
105
106 for (i = 0; i < expected.length; i++) {
107 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
108 }
109 });
110
111 test('from', function (assert) {
112 var start = moment([2007, 1, 28]);
113 assert.equal(start.from(moment([2007, 1, 28]).add({
114 s: 44
115 }), true), 'စက္ကန်.အနည်းငယ်', '၄၄ စက္ကန်. = စက္ကန်.အနည်းငယ်');
116 assert.equal(start.from(moment([2007, 1, 28]).add({
117 s: 45
118 }), true), 'တစ်မိနစ်', '၄၅ စက္ကန်. = တစ်မိနစ်');
119 assert.equal(start.from(moment([2007, 1, 28]).add({
120 s: 89
121 }), true), 'တစ်မိနစ်', '၈၉ စက္ကန်. = တစ်မိနစ်');
122 assert.equal(start.from(moment([2007, 1, 28]).add({
123 s: 90
124 }), true), '၂ မိနစ်', '၉၀ စက္ကန်. = ၂ မိနစ်');
125 assert.equal(start.from(moment([2007, 1, 28]).add({
126 m: 44
127 }), true), '၄၄ မိနစ်', '၄၄ မိနစ် = ၄၄ မိနစ်');
128 assert.equal(start.from(moment([2007, 1, 28]).add({
129 m: 45
130 }), true), 'တစ်နာရီ', '၄၅ မိနစ် = ၁ နာရီ');
131 assert.equal(start.from(moment([2007, 1, 28]).add({
132 m: 89
133 }), true), 'တစ်နာရီ', '၈၉ မိနစ် = တစ်နာရီ');
134 assert.equal(start.from(moment([2007, 1, 28]).add({
135 m: 90
136 }), true), '၂ နာရီ', 'မိနစ် ၉၀= ၂ နာရီ');
137 assert.equal(start.from(moment([2007, 1, 28]).add({
138 h: 5
139 }), true), '၅ နာရီ', '၅ နာရီ= ၅ နာရီ');
140 assert.equal(start.from(moment([2007, 1, 28]).add({
141 h: 21
142 }), true), '၂၁ နာရီ', '၂၁ နာရီ =၂၁ နာရီ');
143 assert.equal(start.from(moment([2007, 1, 28]).add({
144 h: 22
145 }), true), 'တစ်ရက်', '၂၂ နာရီ =တစ်ရက်');
146 assert.equal(start.from(moment([2007, 1, 28]).add({
147 h: 35
148 }), true), 'တစ်ရက်', '၃၅ နာရီ =တစ်ရက်');
149 assert.equal(start.from(moment([2007, 1, 28]).add({
150 h: 36
151 }), true), '၂ ရက်', '၃၆ နာရီ = ၂ ရက်');
152 assert.equal(start.from(moment([2007, 1, 28]).add({
153 d: 1
154 }), true), 'တစ်ရက်', '၁ ရက်= တစ်ရက်');
155 assert.equal(start.from(moment([2007, 1, 28]).add({
156 d: 5
157 }), true), '၅ ရက်', '၅ ရက် = ၅ ရက်');
158 assert.equal(start.from(moment([2007, 1, 28]).add({
159 d: 25
160 }), true), '၂၅ ရက်', '၂၅ ရက်= ၂၅ ရက်');
161 assert.equal(start.from(moment([2007, 1, 28]).add({
162 d: 26
163 }), true), 'တစ်လ', '၂၆ ရက် = တစ်လ');
164 assert.equal(start.from(moment([2007, 1, 28]).add({
165 d: 30
166 }), true), 'တစ်လ', 'ရက် ၃၀ = တစ်လ');
167 assert.equal(start.from(moment([2007, 1, 28]).add({
168 d: 43
169 }), true), 'တစ်လ', '၄၃ ရက် = တစ်လ');
170 assert.equal(start.from(moment([2007, 1, 28]).add({
171 d: 46
172 }), true), '၂ လ', '၄၆ ရက် = ၂ လ');
173 assert.equal(start.from(moment([2007, 1, 28]).add({
174 d: 74
175 }), true), '၂ လ', '၇၅ ရက်= ၂ လ');
176 assert.equal(start.from(moment([2007, 1, 28]).add({
177 d: 76
178 }), true), '၃ လ', '၇၆ ရက် = ၃ လ');
179 assert.equal(start.from(moment([2007, 1, 28]).add({
180 M: 1
181 }), true), 'တစ်လ', '၁ လ = တစ်လ');
182 assert.equal(start.from(moment([2007, 1, 28]).add({
183 M: 5
184 }), true), '၅ လ', '၅ လ = ၅ လ');
185 assert.equal(start.from(moment([2007, 1, 28]).add({
186 d: 345
187 }), true), 'တစ်နှစ်', '၃၄၅ ရက် = တစ်နှစ်');
188 assert.equal(start.from(moment([2007, 1, 28]).add({
189 d: 548
190 }), true), '၂ နှစ်', '၅၄၈ ရက် = ၂ နှစ်');
191 assert.equal(start.from(moment([2007, 1, 28]).add({
192 y: 1
193 }), true), 'တစ်နှစ်', '၁ နှစ် = တစ်နှစ်');
194 assert.equal(start.from(moment([2007, 1, 28]).add({
195 y: 5
196 }), true), '၅ နှစ်', '၅ နှစ် = ၅ နှစ်');
197 });
198
199 test('suffix', function (assert) {
200 assert.equal(moment(30000).from(0), 'လာမည့် စက္ကန်.အနည်းငယ် မှာ', 'prefix');
201 assert.equal(moment(0).from(30000), 'လွန်ခဲ့သော စက္ကန်.အနည်းငယ် က', 'suffix');
202 });
203
204 test('now from now', function (assert) {
205 assert.equal(moment().fromNow(), 'လွန်ခဲ့သော စက္ကန်.အနည်းငယ် က', 'ယခုမှစပြီး အတိတ်တွင်ဖော်ပြသလိုဖော်ပြမည်');
206 });
207
208 test('fromNow', function (assert) {
209 assert.equal(moment().add({
210 s: 30
211 }).fromNow(), 'လာမည့် စက္ကန်.အနည်းငယ် မှာ', 'လာမည့် စက္ကန်.အနည်းငယ် မှာ');
212 assert.equal(moment().add({
213 d: 5
214 }).fromNow(), 'လာမည့် ၅ ရက် မှာ', 'လာမည့် ၅ ရက် မှာ');
215 });
216
217 test('calendar day', function (assert) {
218 var a = moment().hours(2).minutes(0).seconds(0);
219
220 assert.equal(moment(a).calendar(), 'ယနေ. ၀၂:၀၀ မှာ', 'ယနေ. ဒီအချိန်');
221 assert.equal(moment(a).add({
222 m: 25
223 }).calendar(), 'ယနေ. ၀၂:၂၅ မှာ', 'ယခုမှ ၂၅ မိနစ်ပေါင်းထည့်');
224 assert.equal(moment(a).add({
225 h: 1
226 }).calendar(), 'ယနေ. ၀၃:၀၀ မှာ', 'ယခုမှ ၁ နာရီပေါင်းထည့်');
227 assert.equal(moment(a).add({
228 d: 1
229 }).calendar(), 'မနက်ဖြန် ၀၂:၀၀ မှာ', 'မနက်ဖြန် ဒီအချိန်');
230 assert.equal(moment(a).subtract({
231 h: 1
232 }).calendar(), 'ယနေ. ၀၁:၀၀ မှာ', 'ယခုမှ ၁ နာရီနှုတ်');
233 assert.equal(moment(a).subtract({
234 d: 1
235 }).calendar(), 'မနေ.က ၀၂:၀၀ မှာ', 'မနေ.က ဒီအချိန်');
236 });
237
238 test('calendar next week', function (assert) {
239 var i, m;
240 for (i = 2; i < 7; i++) {
241 m = moment().add({
242 d: i
243 });
244 assert.equal(m.calendar(), m.format('dddd LT [မှာ]'), 'Today + ' + i + ' days current time');
245 m.hours(0).minutes(0).seconds(0).milliseconds(0);
246 assert.equal(m.calendar(), m.format('dddd LT [မှာ]'), 'Today + ' + i + ' days beginning of day');
247 m.hours(23).minutes(59).seconds(59).milliseconds(999);
248 assert.equal(m.calendar(), m.format('dddd LT [မှာ]'), 'Today + ' + i + ' days end of day');
249 }
250 });
251
252 test('calendar last week', function (assert) {
253 var i, m;
254
255 for (i = 2; i < 7; i++) {
256 m = moment().subtract({
257 d: i
258 });
259 assert.equal(m.calendar(), m.format('[ပြီးခဲ့သော] dddd LT [မှာ]'), 'Today - ' + i + ' days current time');
260 m.hours(0).minutes(0).seconds(0).milliseconds(0);
261 assert.equal(m.calendar(), m.format('[ပြီးခဲ့သော] dddd LT [မှာ]'), 'Today - ' + i + ' days beginning of day');
262 m.hours(23).minutes(59).seconds(59).milliseconds(999);
263 assert.equal(m.calendar(), m.format('[ပြီးခဲ့သော] dddd LT [မှာ]'), 'Today - ' + i + ' days end of day');
264 }
265 });
266
267 test('calendar all else', function (assert) {
268 var weeksAgo = moment().subtract({
269 w: 1
270 }),
271 weeksFromNow = moment().add({
272 w: 1
273 });
274
275 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'လွန်ခဲ့သော ၁ ပတ်က');
276 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '၁ ပတ်အတွင်း');
277
278 weeksAgo = moment().subtract({
279 w: 2
280 });
281 weeksFromNow = moment().add({
282 w: 2
283 });
284
285 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '၂ ပတ် အရင်က');
286 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '၂ ပတ် အတွင်း');
287 });
288
289 test('weeks year starting sunday', function (assert) {
290 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
291 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
292 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
293 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
294 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
295 });
296
297 test('weeks year starting monday', function (assert) {
298 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
299 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
300 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
301 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
302 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
303 });
304
305 test('weeks year starting tuesday', function (assert) {
306 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
307 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
308 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
309 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
310 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
311 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
312 });
313
314 test('weeks year starting wednesday', function (assert) {
315 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
316 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
317 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
318 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
319 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
320 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
321 });
322
323 test('weeks year starting thursday', function (assert) {
324 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
325 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
326 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
327 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
328 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
329 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
330 });
331
332 test('weeks year starting friday', function (assert) {
333 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
334 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
335 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
336 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
337 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
338 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
339 });
340
341 test('weeks year starting saturday', function (assert) {
342 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
343 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
344 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
345 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
346 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
347 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
348 });
349
350 test('weeks year starting sunday formatted', function (assert) {
351 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '၅၂ ၅၂ ၅၂', 'Jan 1 2012 should be week 52');
352 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '၁ ၀၁ ၁', 'Jan 2 2012 should be week 1');
353 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '၁ ၀၁ ၁', 'Jan 8 2012 should be week 1');
354 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 9 2012 should be week 2');
355 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 15 2012 should be week 2');
356 });
357
358 test('lenient ordinal parsing', function (assert) {
359 var i, ordinalStr, testMoment;
360 for (i = 1; i <= 31; ++i) {
361 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
362 testMoment = moment(ordinalStr, 'YYYY MM Do');
363 assert.equal(testMoment.year(), 2014,
364 'lenient ordinal parsing ' + i + ' year check');
365 assert.equal(testMoment.month(), 0,
366 'lenient ordinal parsing ' + i + ' month check');
367 assert.equal(testMoment.date(), i,
368 'lenient ordinal parsing ' + i + ' date check');
369 }
370 });
371
372 test('lenient ordinal parsing of number', function (assert) {
373 var i, testMoment;
374 for (i = 1; i <= 31; ++i) {
375 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
376 assert.equal(testMoment.year(), 2014,
377 'lenient ordinal parsing of number ' + i + ' year check');
378 assert.equal(testMoment.month(), 0,
379 'lenient ordinal parsing of number ' + i + ' month check');
380 assert.equal(testMoment.date(), i,
381 'lenient ordinal parsing of number ' + i + ' date check');
382 }
383 });
384
385 test('strict ordinal parsing', function (assert) {
386 var i, ordinalStr, testMoment;
387 for (i = 1; i <= 31; ++i) {
388 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
389 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
390 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
391 }
392 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('nb');
3
4 test('parse', function (assert) {
5 var tests = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, MMMM Do YYYY, h:mm:ss a', 'søndag, februar 14. 2010, 3:25:50 pm'],
26 ['ddd, hA', 'søn, 3PM'],
27 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14. 14'],
30 ['d do dddd ddd dd', '0 0. søndag søn sø'],
31 ['DDD DDDo DDDD', '45 45. 045'],
32 ['w wo ww', '6 6. 06'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[den] DDDo [dagen i året]', 'den 45. dagen i året'],
39 ['LTS', '15.25.50'],
40 ['L', '14.02.2010'],
41 ['LL', '14. februar 2010'],
42 ['LLL', '14. februar 2010 kl. 15.25'],
43 ['LLLL', 'søndag 14. februar 2010 kl. 15.25'],
44 ['l', '14.2.2010'],
45 ['ll', '14. feb 2010'],
46 ['lll', '14. feb 2010 kl. 15.25'],
47 ['llll', 'søn 14. feb 2010 kl. 15.25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'søndag søn sø_mandag man ma_tirsdag tirs ti_onsdag ons on_torsdag tors to_fredag fre fr_lørdag lør lø'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'noen sekunder', '44 sekunder = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ett minutt', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ett minutt', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutter', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutter', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'en time', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'en time', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timer', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timer', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timer', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dag', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dag', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dager', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dag', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dager', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dager', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en måned', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en måned', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en måned', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 måneder', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 måneder', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 måneder', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en måned', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 måneder', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ett år', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ett år', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'om noen sekunder', 'prefix');
141 assert.equal(moment(0).from(30000), 'for noen sekunder siden', 'suffix');
142 });
143
144 test('now from now', function (assert) {
145 assert.equal(moment().fromNow(), 'for noen sekunder siden', 'now from now should display as in the past');
146 });
147
148 test('fromNow', function (assert) {
149 assert.equal(moment().add({s: 30}).fromNow(), 'om noen sekunder', 'in a few seconds');
150 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dager', 'in 5 days');
151 });
152
153 test('calendar day', function (assert) {
154 var a = moment().hours(2).minutes(0).seconds(0);
155
156 assert.equal(moment(a).calendar(), 'i dag kl. 2.00', 'today at the same time');
157 assert.equal(moment(a).add({m: 25}).calendar(), 'i dag kl. 2.25', 'Now plus 25 min');
158 assert.equal(moment(a).add({h: 1}).calendar(), 'i dag kl. 3.00', 'Now plus 1 hour');
159 assert.equal(moment(a).add({d: 1}).calendar(), 'i morgen kl. 2.00', 'tomorrow at the same time');
160 assert.equal(moment(a).subtract({h: 1}).calendar(), 'i dag kl. 1.00', 'Now minus 1 hour');
161 assert.equal(moment(a).subtract({d: 1}).calendar(), 'i går kl. 2.00', 'yesterday at the same time');
162 });
163
164 test('calendar next week', function (assert) {
165 var i, m;
166 for (i = 2; i < 7; i++) {
167 m = moment().add({d: i});
168 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days current time');
169 m.hours(0).minutes(0).seconds(0).milliseconds(0);
170 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days beginning of day');
171 m.hours(23).minutes(59).seconds(59).milliseconds(999);
172 assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days end of day');
173 }
174 });
175
176 test('calendar last week', function (assert) {
177 var i, m;
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[forrige] dddd [kl.] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[forrige] dddd [kl.] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[forrige] dddd [kl.] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
204 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
206 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
212 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
213 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
214 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
215 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
222 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
223 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
224 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
231 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
232 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
233 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
240 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
241 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
242 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
247 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
248 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
249 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
250 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
251 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
252 });
253
254 test('weeks year starting saturday', function (assert) {
255 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
256 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
257 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
258 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
259 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
260 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
261 });
262
263 test('weeks year starting sunday formatted', function (assert) {
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
268 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
269 });
270
271 test('lenient ordinal parsing', function (assert) {
272 var i, ordinalStr, testMoment;
273 for (i = 1; i <= 31; ++i) {
274 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
275 testMoment = moment(ordinalStr, 'YYYY MM Do');
276 assert.equal(testMoment.year(), 2014,
277 'lenient ordinal parsing ' + i + ' year check');
278 assert.equal(testMoment.month(), 0,
279 'lenient ordinal parsing ' + i + ' month check');
280 assert.equal(testMoment.date(), i,
281 'lenient ordinal parsing ' + i + ' date check');
282 }
283 });
284
285 test('lenient ordinal parsing of number', function (assert) {
286 var i, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
289 assert.equal(testMoment.year(), 2014,
290 'lenient ordinal parsing of number ' + i + ' year check');
291 assert.equal(testMoment.month(), 0,
292 'lenient ordinal parsing of number ' + i + ' month check');
293 assert.equal(testMoment.date(), i,
294 'lenient ordinal parsing of number ' + i + ' date check');
295 }
296 });
297
298 test('strict ordinal parsing', function (assert) {
299 var i, ordinalStr, testMoment;
300 for (i = 1; i <= 31; ++i) {
301 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
302 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
303 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
304 }
305 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ne');
3
4 test('parse', function (assert) {
5 var tests = 'जनवरी जन._फेब्रुवरी फेब्रु._मार्च मार्च_अप्रिल अप्रि._मई मई_जुन जुन_जुलाई जुलाई._अगष्ट अग._सेप्टेम्बर सेप्ट._अक्टोबर अक्टो._नोभेम्बर नोभे._डिसेम्बर डिसे.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, aको h:mm:ss बजे', 'आइतबार, १४ फेब्रुवरी २०१०, बेलुकाको ३:२५:५० बजे'],
25 ['ddd, aको h बजे', 'आइत., बेलुकाको ३ बजे'],
26 ['M Mo MM MMMM MMM', '२ २ ०२ फेब्रुवरी फेब्रु.'],
27 ['YYYY YY', '२०१० १०'],
28 ['D Do DD', '१४ १४ १४'],
29 ['d do dddd ddd dd', '० ० आइतबार आइत. आइ.'],
30 ['DDD DDDo DDDD', '४५ ४५ ०४५'],
31 ['w wo ww', '७ ७ ०७'],
32 ['h hh', '३ ०३'],
33 ['H HH', '१५ १५'],
34 ['m mm', '२५ २५'],
35 ['s ss', '५० ५०'],
36 ['a A', 'बेलुका बेलुका'],
37 ['LTS', 'बेलुकाको ३:२५:५० बजे'],
38 ['L', '१४/०२/२०१०'],
39 ['LL', '१४ फेब्रुवरी २०१०'],
40 ['LLL', '१४ फेब्रुवरी २०१०, बेलुकाको ३:२५ बजे'],
41 ['LLLL', 'आइतबार, १४ फेब्रुवरी २०१०, बेलुकाको ३:२५ बजे'],
42 ['l', '१४/२/२०१०'],
43 ['ll', '१४ फेब्रु. २०१०'],
44 ['lll', '१४ फेब्रु. २०१०, बेलुकाको ३:२५ बजे'],
45 ['llll', 'आइत., १४ फेब्रु. २०१०, बेलुकाको ३:२५ बजे']
46 ],
47 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
48 i;
49 for (i = 0; i < a.length; i++) {
50 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
51 }
52 });
53
54 test('format ordinal', function (assert) {
55 assert.equal(moment([2011, 0, 1]).format('DDDo'), '१', '१');
56 assert.equal(moment([2011, 0, 2]).format('DDDo'), '२', '२');
57 assert.equal(moment([2011, 0, 3]).format('DDDo'), '३', '३');
58 assert.equal(moment([2011, 0, 4]).format('DDDo'), '४', '४');
59 assert.equal(moment([2011, 0, 5]).format('DDDo'), '५', '५');
60 assert.equal(moment([2011, 0, 6]).format('DDDo'), '६', '६');
61 assert.equal(moment([2011, 0, 7]).format('DDDo'), '७', '७');
62 assert.equal(moment([2011, 0, 8]).format('DDDo'), '८', '८');
63 assert.equal(moment([2011, 0, 9]).format('DDDo'), '९', '९');
64 assert.equal(moment([2011, 0, 10]).format('DDDo'), '१०', '१०');
65
66 assert.equal(moment([2011, 0, 11]).format('DDDo'), '११', '११');
67 assert.equal(moment([2011, 0, 12]).format('DDDo'), '१२', '१२');
68 assert.equal(moment([2011, 0, 13]).format('DDDo'), '१३', '१३');
69 assert.equal(moment([2011, 0, 14]).format('DDDo'), '१४', '१४');
70 assert.equal(moment([2011, 0, 15]).format('DDDo'), '१५', '१५');
71 assert.equal(moment([2011, 0, 16]).format('DDDo'), '१६', '१६');
72 assert.equal(moment([2011, 0, 17]).format('DDDo'), '१७', '१७');
73 assert.equal(moment([2011, 0, 18]).format('DDDo'), '१८', '१८');
74 assert.equal(moment([2011, 0, 19]).format('DDDo'), '१९', '१९');
75 assert.equal(moment([2011, 0, 20]).format('DDDo'), '२०', '२०');
76
77 assert.equal(moment([2011, 0, 21]).format('DDDo'), '२१', '२१');
78 assert.equal(moment([2011, 0, 22]).format('DDDo'), '२२', '२२');
79 assert.equal(moment([2011, 0, 23]).format('DDDo'), '२३', '२३');
80 assert.equal(moment([2011, 0, 24]).format('DDDo'), '२४', '२४');
81 assert.equal(moment([2011, 0, 25]).format('DDDo'), '२५', '२५');
82 assert.equal(moment([2011, 0, 26]).format('DDDo'), '२६', '२६');
83 assert.equal(moment([2011, 0, 27]).format('DDDo'), '२७', '२७');
84 assert.equal(moment([2011, 0, 28]).format('DDDo'), '२८', '२८');
85 assert.equal(moment([2011, 0, 29]).format('DDDo'), '२९', '२९');
86 assert.equal(moment([2011, 0, 30]).format('DDDo'), '३०', '३०');
87
88 assert.equal(moment([2011, 0, 31]).format('DDDo'), '३१', '३१');
89 });
90
91 test('format month', function (assert) {
92 var expected = 'जनवरी जन._फेब्रुवरी फेब्रु._मार्च मार्च_अप्रिल अप्रि._मई मई_जुन जुन_जुलाई जुलाई._अगष्ट अग._सेप्टेम्बर सेप्ट._अक्टोबर अक्टो._नोभेम्बर नोभे._डिसेम्बर डिसे.'.split('_'), i;
93 for (i = 0; i < expected.length; i++) {
94 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
95 }
96 });
97
98 test('format week', function (assert) {
99 var expected = 'आइतबार आइत. आइ._सोमबार सोम. सो._मङ्गलबार मङ्गल. मङ्_बुधबार बुध. बु._बिहिबार बिहि. बि._शुक्रबार शुक्र. शु._शनिबार शनि. श.'.split('_'), i;
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
102 }
103 });
104
105 test('from', function (assert) {
106 var start = moment([2007, 1, 28]);
107 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'केही समय', '44 seconds = a few seconds');
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'एक मिनेट', '45 seconds = a minute');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'एक मिनेट', '89 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '२ मिनेट', '90 seconds = 2 minutes');
111 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '४४ मिनेट', '44 minutes = 44 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'एक घण्टा', '45 minutes = an hour');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'एक घण्टा', '89 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '२ घण्टा', '90 minutes = 2 hours');
115 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '५ घण्टा', '5 hours = 5 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '२१ घण्टा', '21 hours = 21 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'एक दिन', '22 hours = a day');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'एक दिन', '35 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '२ दिन', '36 hours = 2 days');
120 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'एक दिन', '1 day = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '५ दिन', '5 days = 5 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '२५ दिन', '25 days = 25 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'एक महिना', '26 days = a month');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'एक महिना', '30 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'एक महिना', '43 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '२ महिना', '46 days = 2 months');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '२ महिना', '75 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '३ महिना', '76 days = 3 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'एक महिना', '1 month = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '५ महिना', '5 months = 5 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'एक बर्ष', '345 days = a year');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '२ बर्ष', '548 days = 2 years');
133 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'एक बर्ष', '1 year = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '५ बर्ष', '5 years = 5 years');
135 });
136
137 test('suffix', function (assert) {
138 assert.equal(moment(30000).from(0), 'केही समयमा', 'prefix');
139 assert.equal(moment(0).from(30000), 'केही समय अगाडी', 'suffix');
140 });
141
142 test('now from now', function (assert) {
143 assert.equal(moment().fromNow(), 'केही समय अगाडी', 'now from now should display as in the past');
144 });
145
146 test('fromNow', function (assert) {
147 assert.equal(moment().add({s: 30}).fromNow(), 'केही समयमा', 'केही समयमा');
148 assert.equal(moment().add({d: 5}).fromNow(), '५ दिनमा', '५ दिनमा');
149 });
150
151 test('calendar day', function (assert) {
152 var a = moment().hours(2).minutes(0).seconds(0);
153
154 assert.equal(moment(a).calendar(), 'आज रातीको २:०० बजे', 'today at the same time');
155 assert.equal(moment(a).add({m: 25}).calendar(), 'आज रातीको २:२५ बजे', 'Now plus 25 min');
156 assert.equal(moment(a).add({h: 1}).calendar(), 'आज बिहानको ३:०० बजे', 'Now plus 1 hour');
157 assert.equal(moment(a).add({d: 1}).calendar(), 'भोली रातीको २:०० बजे', 'tomorrow at the same time');
158 assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रातीको १:०० बजे', 'Now minus 1 hour');
159 assert.equal(moment(a).subtract({d: 1}).calendar(), 'हिजो रातीको २:०० बजे', 'yesterday at the same time');
160 });
161
162 test('calendar next week', function (assert) {
163 var i, m;
164 for (i = 2; i < 7; i++) {
165 m = moment().add({d: i});
166 assert.equal(m.calendar(), m.format('[आउँदो] dddd[,] LT'), 'Today + ' + i + ' days current time');
167 m.hours(0).minutes(0).seconds(0).milliseconds(0);
168 assert.equal(m.calendar(), m.format('[आउँदो] dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
169 m.hours(23).minutes(59).seconds(59).milliseconds(999);
170 assert.equal(m.calendar(), m.format('[आउँदो] dddd[,] LT'), 'Today + ' + i + ' days end of day');
171 }
172 });
173
174 test('calendar last week', function (assert) {
175 var i, m;
176 for (i = 2; i < 7; i++) {
177 m = moment().subtract({d: i});
178 assert.equal(m.calendar(), m.format('[गएको] dddd[,] LT'), 'Today - ' + i + ' days current time');
179 m.hours(0).minutes(0).seconds(0).milliseconds(0);
180 assert.equal(m.calendar(), m.format('[गएको] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
181 m.hours(23).minutes(59).seconds(59).milliseconds(999);
182 assert.equal(m.calendar(), m.format('[गएको] dddd[,] LT'), 'Today - ' + i + ' days end of day');
183 }
184 });
185
186 test('calendar all else', function (assert) {
187 var weeksAgo = moment().subtract({w: 1}),
188 weeksFromNow = moment().add({w: 1});
189
190 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
191 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
192
193 weeksAgo = moment().subtract({w: 2});
194 weeksFromNow = moment().add({w: 2});
195
196 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
197 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
198 });
199
200 test('meridiem', function (assert) {
201 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'राती', 'before dawn');
202 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'बिहान', 'morning');
203 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दिउँसो', 'during day');
204 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'बेलुका', 'evening');
205 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'साँझ', 'late evening');
206 assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'राती', 'night');
207
208 assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'राती', 'before dawn');
209 assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'बिहान', 'morning');
210 assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'दिउँसो', 'during day');
211 assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'बेलुका', 'evening');
212 assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'साँझ', 'late evening');
213 assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'राती', 'night');
214 });
215
216 test('weeks year starting sunday', function (assert) {
217 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
218 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
219 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
220 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
221 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
222 });
223
224 test('weeks year starting monday', function (assert) {
225 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
226 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
227 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
228 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
229 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
230 });
231
232 test('weeks year starting tuesday', function (assert) {
233 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
234 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
235 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
236 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
237 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
238 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
239 });
240
241 test('weeks year starting wednesday', function (assert) {
242 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
243 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
244 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
245 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
246 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
247 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
248 });
249
250 test('weeks year starting thursday', function (assert) {
251 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
252 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
253 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
254 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
255 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
256 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
257 });
258
259 test('weeks year starting friday', function (assert) {
260 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
261 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
262 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
263 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
264 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
265 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
266 });
267
268 test('weeks year starting saturday', function (assert) {
269 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
270 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
271 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
272 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
273 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
274 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
275 });
276
277 test('weeks year starting sunday formatted', function (assert) {
278 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '१ ०१ १', 'Dec 26 2011 should be week 1');
279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
280 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '२ ०२ २', 'Jan 2 2012 should be week 2');
281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '२ ०२ २', 'Jan 8 2012 should be week 2');
282 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '३ ०३ ३', 'Jan 9 2012 should be week 3');
283 });
284
285 test('lenient ordinal parsing', function (assert) {
286 var i, ordinalStr, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
289 testMoment = moment(ordinalStr, 'YYYY MM Do');
290 assert.equal(testMoment.year(), 2014,
291 'lenient ordinal parsing ' + i + ' year check');
292 assert.equal(testMoment.month(), 0,
293 'lenient ordinal parsing ' + i + ' month check');
294 assert.equal(testMoment.date(), i,
295 'lenient ordinal parsing ' + i + ' date check');
296 }
297 });
298
299 test('lenient ordinal parsing of number', function (assert) {
300 var i, testMoment;
301 for (i = 1; i <= 31; ++i) {
302 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
303 assert.equal(testMoment.year(), 2014,
304 'lenient ordinal parsing of number ' + i + ' year check');
305 assert.equal(testMoment.month(), 0,
306 'lenient ordinal parsing of number ' + i + ' month check');
307 assert.equal(testMoment.date(), i,
308 'lenient ordinal parsing of number ' + i + ' date check');
309 }
310 });
311
312 test('meridiem invariant', function (assert) {
313 var h, m, t1, t2;
314 for (h = 0; h < 24; ++h) {
315 for (m = 0; m < 60; m += 15) {
316 t1 = moment.utc([2000, 0, 1, h, m]);
317 t2 = moment(t1.format('A h:mm'), 'A h:mm');
318 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
319 'meridiem at ' + t1.format('HH:mm'));
320 }
321 }
322 });
323
324 test('strict ordinal parsing', function (assert) {
325 var i, ordinalStr, testMoment;
326 for (i = 1; i <= 31; ++i) {
327 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
328 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
329 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
330 }
331 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('nl');
3
4 test('parse', function (assert) {
5 var tests = 'januari jan._februari feb._maart mrt._april apr._mei mei._juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, HH:mm:ss', 'zondag, februari 14de 2010, 15:25:50'],
25 ['ddd, HH', 'zo., 15'],
26 ['M Mo MM MMMM MMM', '2 2de 02 februari feb.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14de 14'],
29 ['d do dddd ddd dd', '0 0de zondag zo. Zo'],
30 ['DDD DDDo DDDD', '45 45ste 045'],
31 ['w wo ww', '6 6de 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45ste day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14-02-2010'],
40 ['LL', '14 februari 2010'],
41 ['LLL', '14 februari 2010 15:25'],
42 ['LLLL', 'zondag 14 februari 2010 15:25'],
43 ['l', '14-2-2010'],
44 ['ll', '14 feb. 2010'],
45 ['lll', '14 feb. 2010 15:25'],
46 ['llll', 'zo. 14 feb. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4de', '4de');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5de', '5de');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6de', '6de');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7de', '7de');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14de', '14de');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15de', '15de');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16de', '16de');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17de', '17de');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24ste', '24ste');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25ste', '25ste');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26ste', '26ste');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27ste', '27ste');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'januari jan._februari feb._maart mrt._april apr._mei mei_juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'zondag zo. Zo_maandag ma. Ma_dinsdag di. Di_woensdag wo. Wo_donderdag do. Do_vrijdag vr. Vr_zaterdag za. Za'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'een paar seconden', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'één minuut', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'één minuut', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuten', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuten', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'één uur', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'één uur', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 uur', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 uur', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 uur', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'één dag', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'één dag', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagen', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'één dag', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagen', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagen', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'één maand', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'één maand', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'één maand', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 maanden', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 maanden', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 maanden', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'één maand', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 maanden', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'één jaar', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 jaar', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'één jaar', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 jaar', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'over een paar seconden', 'prefix');
140 assert.equal(moment(0).from(30000), 'een paar seconden geleden', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'een paar seconden geleden', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'over een paar seconden', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'over 5 dagen', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'vandaag om 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'vandaag om 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'vandaag om 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'morgen om 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'vandaag om 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'gisteren om 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [om] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[afgelopen] dddd [om] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[afgelopen] dddd [om] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[afgelopen] dddd [om] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('month abbreviation', function (assert) {
202 assert.equal(moment([2012, 5, 23]).format('D-MMM-YYYY'), '23-jun-2012', 'format month abbreviation surrounded by dashes should not include a dot');
203 assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
204 });
205
206 test('weeks year starting sunday', function (assert) {
207 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
208 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
209 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
210 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
211 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
212 });
213
214 test('weeks year starting monday', function (assert) {
215 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
216 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
217 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
218 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
219 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
220 });
221
222 test('weeks year starting tuesday', function (assert) {
223 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
224 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
225 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
226 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
227 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
228 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
229 });
230
231 test('weeks year starting wednesday', function (assert) {
232 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
233 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
234 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
235 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
236 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
237 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
238 });
239
240 test('weeks year starting thursday', function (assert) {
241 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
242 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
243 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
244 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
245 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
246 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
247 });
248
249 test('weeks year starting friday', function (assert) {
250 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
251 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
252 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
253 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
254 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
255 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
256 });
257
258 test('weeks year starting saturday', function (assert) {
259 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
260 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
261 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
262 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
263 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
264 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
265 });
266
267 test('weeks year starting sunday formatted', function (assert) {
268 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
269 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
270 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1ste', 'Jan 8 2012 should be week 1');
271 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2de', 'Jan 9 2012 should be week 2');
272 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
273 });
274
275 test('lenient ordinal parsing', function (assert) {
276 var i, ordinalStr, testMoment;
277 for (i = 1; i <= 31; ++i) {
278 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
279 testMoment = moment(ordinalStr, 'YYYY MM Do');
280 assert.equal(testMoment.year(), 2014,
281 'lenient ordinal parsing ' + i + ' year check');
282 assert.equal(testMoment.month(), 0,
283 'lenient ordinal parsing ' + i + ' month check');
284 assert.equal(testMoment.date(), i,
285 'lenient ordinal parsing ' + i + ' date check');
286 }
287 });
288
289 test('lenient ordinal parsing of number', function (assert) {
290 var i, testMoment;
291 for (i = 1; i <= 31; ++i) {
292 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
293 assert.equal(testMoment.year(), 2014,
294 'lenient ordinal parsing of number ' + i + ' year check');
295 assert.equal(testMoment.month(), 0,
296 'lenient ordinal parsing of number ' + i + ' month check');
297 assert.equal(testMoment.date(), i,
298 'lenient ordinal parsing of number ' + i + ' date check');
299 }
300 });
301
302 test('strict ordinal parsing', function (assert) {
303 var i, ordinalStr, testMoment;
304 for (i = 1; i <= 31; ++i) {
305 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
306 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
307 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
308 }
309 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('nn');
3
4 test('parse', function (assert) {
5 var tests = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'sundag, februar 14. 2010, 3:25:50 pm'],
25 ['ddd, hA', 'sun, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 februar feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. sundag sun su'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14 februar 2010'],
41 ['LLL', '14 februar 2010 15:25'],
42 ['LLLL', 'sundag 14 februar 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14 feb 2010'],
45 ['lll', '14 feb 2010 15:25'],
46 ['llll', 'sun 14 feb 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'sundag sun su_måndag mån må_tysdag tys ty_onsdag ons on_torsdag tor to_fredag fre fr_laurdag lau lø'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nokre sekund', '44 sekunder = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'eit minutt', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'eit minutt', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutt', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutt', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ein time', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ein time', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timar', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timar', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timar', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ein dag', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ein dag', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ein dag', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ein månad', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ein månad', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ein månad', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 månader', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 månader', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 månader', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ein månad', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 månader', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'eit år', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eit år', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'om nokre sekund', 'prefix');
140 assert.equal(moment(0).from(30000), 'for nokre sekund sidan', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'for nokre sekund sidan', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'om nokre sekund', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dagar', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'I dag klokka 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'I dag klokka 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'I dag klokka 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'I morgon klokka 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag klokka 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går klokka 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [klokka] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [klokka] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [klokka] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[Føregåande] dddd [klokka] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[Føregåande] dddd [klokka] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[Føregåande] dddd [klokka] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('weeks year starting sunday', function (assert) {
202 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
203 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
204 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
205 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
206 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
207 });
208
209 test('weeks year starting monday', function (assert) {
210 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
211 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
212 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
213 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
214 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
215 });
216
217 test('weeks year starting tuesday', function (assert) {
218 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
219 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
220 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
221 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
222 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
223 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
224 });
225
226 test('weeks year starting wednesday', function (assert) {
227 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
228 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
229 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
230 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
231 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
232 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
233 });
234
235 test('weeks year starting thursday', function (assert) {
236 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
237 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
238 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
239 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
240 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
241 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
242 });
243
244 test('weeks year starting friday', function (assert) {
245 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
246 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
247 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
248 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
249 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
250 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
251 });
252
253 test('weeks year starting saturday', function (assert) {
254 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
255 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
256 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
257 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
258 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
259 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
260 });
261
262 test('weeks year starting sunday formatted', function (assert) {
263 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
264 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
265 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
266 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
267 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
268 });
269
270 test('lenient ordinal parsing', function (assert) {
271 var i, ordinalStr, testMoment;
272 for (i = 1; i <= 31; ++i) {
273 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
274 testMoment = moment(ordinalStr, 'YYYY MM Do');
275 assert.equal(testMoment.year(), 2014,
276 'lenient ordinal parsing ' + i + ' year check');
277 assert.equal(testMoment.month(), 0,
278 'lenient ordinal parsing ' + i + ' month check');
279 assert.equal(testMoment.date(), i,
280 'lenient ordinal parsing ' + i + ' date check');
281 }
282 });
283
284 test('lenient ordinal parsing of number', function (assert) {
285 var i, testMoment;
286 for (i = 1; i <= 31; ++i) {
287 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
288 assert.equal(testMoment.year(), 2014,
289 'lenient ordinal parsing of number ' + i + ' year check');
290 assert.equal(testMoment.month(), 0,
291 'lenient ordinal parsing of number ' + i + ' month check');
292 assert.equal(testMoment.date(), i,
293 'lenient ordinal parsing of number ' + i + ' date check');
294 }
295 });
296
297 test('strict ordinal parsing', function (assert) {
298 var i, ordinalStr, testMoment;
299 for (i = 1; i <= 31; ++i) {
300 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
301 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
302 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
303 }
304 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('pl');
3
4 test('parse', function (assert) {
5 var tests = 'styczeń stycznia sty_luty lutego lut_marzec marca mar_kwiecień kwietnia kwi_maj maja maj_czerwiec czerwca cze_lipiec lipca lip_sierpień sierpnia sie_wrzesień września wrz_październik października paź_listopad listopada lis_grudzień grudnia gru'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][2], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][2], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][2].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 equalTest(tests[i][2].toLocaleUpperCase(), 'MMMM', i);
23 }
24 });
25
26 test('parse strict', function (assert) {
27 var tests = 'styczeń stycznia sty_luty lutego lut_marzec marca mar_kwiecień kwietnia kwi_maj maja maj_czerwiec czerwca cze_lipiec lipca lip_sierpień sierpnia sie_wrzesień września wrz_październik października paź_listopad listopada lis_grudzień grudnia gru'.split('_'), i;
28 function equalTest(input, mmm, i) {
29 assert.equal(moment(input, mmm, true).month(), i, input + ' should be month ' + (i + 1));
30 }
31 for (i = 0; i < 12; i++) {
32 tests[i] = tests[i].split(' ');
33 equalTest(tests[i][0], 'MMMM', i);
34 equalTest(tests[i][1], 'MMMM', i);
35 equalTest(tests[i][2], 'MMM', i);
36 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
37 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
38 equalTest(tests[i][2].toLocaleLowerCase(), 'MMM', i);
39 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
40 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
41 equalTest(tests[i][2].toLocaleUpperCase(), 'MMM', i);
42 }
43 });
44
45 test('format', function (assert) {
46 var a = [
47 ['dddd, MMMM Do YYYY, h:mm:ss a', 'niedziela, luty 14. 2010, 3:25:50 pm'],
48 ['ddd, hA', 'nie, 3PM'],
49 ['M Mo MM MMMM MMM', '2 2. 02 luty lut'],
50 ['YYYY YY', '2010 10'],
51 ['D Do DD', '14 14. 14'],
52 ['d do dddd ddd dd', '0 0. niedziela nie N'],
53 ['DDD DDDo DDDD', '45 45. 045'],
54 ['w wo ww', '6 6. 06'],
55 ['h hh', '3 03'],
56 ['H HH', '15 15'],
57 ['m mm', '25 25'],
58 ['s ss', '50 50'],
59 ['a A', 'pm PM'],
60 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
61 ['LTS', '15:25:50'],
62 ['L', '14.02.2010'],
63 ['LL', '14 lutego 2010'],
64 ['LLL', '14 lutego 2010 15:25'],
65 ['LLLL', 'niedziela, 14 lutego 2010 15:25'],
66 ['l', '14.2.2010'],
67 ['ll', '14 lut 2010'],
68 ['lll', '14 lut 2010 15:25'],
69 ['llll', 'nie, 14 lut 2010 15:25']
70 ],
71 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
72 i;
73 for (i = 0; i < a.length; i++) {
74 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
75 }
76 });
77
78 test('format ordinal', function (assert) {
79 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
80 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
81 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
82 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
83 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
84 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
85 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
86 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
87 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
88 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
89
90 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
91 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
92 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
93 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
94 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
95 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
96 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
97 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
98 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
99 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
100
101 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
102 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
103 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
104 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
105 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
106 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
107 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
108 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
109 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
110 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
111
112 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
113 });
114
115 test('format month', function (assert) {
116 var expected = 'styczeń sty_luty lut_marzec mar_kwiecień kwi_maj maj_czerwiec cze_lipiec lip_sierpień sie_wrzesień wrz_październik paź_listopad lis_grudzień gru'.split('_'), i;
117 for (i = 0; i < expected.length; i++) {
118 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
119 }
120 });
121
122 test('format week', function (assert) {
123 var expected = 'niedziela nie N_poniedziałek pon Pn_wtorek wt Wt_środa śr Śr_czwartek czw Cz_piątek pt Pt_sobota sb So'.split('_'), i;
124 for (i = 0; i < expected.length; i++) {
125 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
126 }
127 });
128
129 test('from', function (assert) {
130 var start = moment([2007, 1, 28]);
131 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'kilka sekund', '44 seconds = a few seconds');
132 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuta', '45 seconds = a minute');
133 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuta', '89 seconds = a minute');
134 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuty', '90 seconds = 2 minutes');
135 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuty', '44 minutes = 44 minutes');
136 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'godzina', '45 minutes = an hour');
137 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'godzina', '89 minutes = an hour');
138 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 godziny', '90 minutes = 2 hours');
139 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 godzin', '5 hours = 5 hours');
140 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 godzin', '21 hours = 21 hours');
141 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1 dzień', '22 hours = a day');
142 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1 dzień', '35 hours = a day');
143 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dni', '36 hours = 2 days');
144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1 dzień', '1 day = a day');
145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dni', '5 days = 5 days');
146 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dni', '25 days = 25 days');
147 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'miesiąc', '26 days = a month');
148 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'miesiąc', '30 days = a month');
149 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'miesiąc', '43 days = a month');
150 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 miesiące', '46 days = 2 months');
151 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 miesiące', '75 days = 2 months');
152 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 miesiące', '76 days = 3 months');
153 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'miesiąc', '1 month = a month');
154 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 miesięcy', '5 months = 5 months');
155 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'rok', '345 days = a year');
156 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 lata', '548 days = 2 years');
157 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'rok', '1 year = a year');
158 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 lat', '5 years = 5 years');
159 assert.equal(start.from(moment([2007, 1, 28]).add({y: 112}), true), '112 lat', '112 years = 112 years');
160 assert.equal(start.from(moment([2007, 1, 28]).add({y: 122}), true), '122 lata', '122 years = 122 years');
161 assert.equal(start.from(moment([2007, 1, 28]).add({y: 213}), true), '213 lat', '213 years = 213 years');
162 assert.equal(start.from(moment([2007, 1, 28]).add({y: 223}), true), '223 lata', '223 years = 223 years');
163 });
164
165 test('suffix', function (assert) {
166 assert.equal(moment(30000).from(0), 'za kilka sekund', 'prefix');
167 assert.equal(moment(0).from(30000), 'kilka sekund temu', 'suffix');
168 });
169
170 test('now from now', function (assert) {
171 assert.equal(moment().fromNow(), 'kilka sekund temu', 'now from now should display as in the past');
172 });
173
174 test('fromNow', function (assert) {
175 assert.equal(moment().add({s: 30}).fromNow(), 'za kilka sekund', 'in a few seconds');
176 assert.equal(moment().add({h: 1}).fromNow(), 'za godzinę', 'in an hour');
177 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dni', 'in 5 days');
178 });
179
180 test('calendar day', function (assert) {
181 var a = moment().hours(2).minutes(0).seconds(0);
182
183 assert.equal(moment(a).calendar(), 'Dziś o 02:00', 'today at the same time');
184 assert.equal(moment(a).add({m: 25}).calendar(), 'Dziś o 02:25', 'Now plus 25 min');
185 assert.equal(moment(a).add({h: 1}).calendar(), 'Dziś o 03:00', 'Now plus 1 hour');
186 assert.equal(moment(a).add({d: 1}).calendar(), 'Jutro o 02:00', 'tomorrow at the same time');
187 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dziś o 01:00', 'Now minus 1 hour');
188 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Wczoraj o 02:00', 'yesterday at the same time');
189 });
190
191 test('calendar next week', function (assert) {
192 var i, m;
193 for (i = 2; i < 7; i++) {
194 m = moment().add({d: i});
195 assert.equal(m.calendar(), m.format('[W] dddd [o] LT'), 'Today + ' + i + ' days current time');
196 m.hours(0).minutes(0).seconds(0).milliseconds(0);
197 assert.equal(m.calendar(), m.format('[W] dddd [o] LT'), 'Today + ' + i + ' days beginning of day');
198 m.hours(23).minutes(59).seconds(59).milliseconds(999);
199 assert.equal(m.calendar(), m.format('[W] dddd [o] LT'), 'Today + ' + i + ' days end of day');
200 }
201 });
202
203 test('calendar last week', function (assert) {
204 var i, m;
205
206 function makeFormat(d) {
207 switch (d.day()) {
208 case 0:
209 return '[W zeszłą niedzielę o] LT';
210 case 3:
211 return '[W zeszłą środę o] LT';
212 case 6:
213 return '[W zeszłą sobotę o] LT';
214 default:
215 return '[W zeszły] dddd [o] LT';
216 }
217 }
218
219 for (i = 2; i < 7; i++) {
220 m = moment().subtract({d: i});
221 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
222
223 m.hours(0).minutes(0).seconds(0).milliseconds(0);
224 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
225
226 m.hours(23).minutes(59).seconds(59).milliseconds(999);
227 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
228 }
229 });
230
231 test('calendar all else', function (assert) {
232 var weeksAgo = moment().subtract({w: 1}),
233 weeksFromNow = moment().add({w: 1});
234
235 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
236 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
237
238 weeksAgo = moment().subtract({w: 2});
239 weeksFromNow = moment().add({w: 2});
240
241 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
242 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
243 });
244
245 test('weeks year starting sunday', function (assert) {
246 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
247 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
248 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
249 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
250 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
251 });
252
253 test('weeks year starting monday', function (assert) {
254 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
255 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
256 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
257 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
258 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
259 });
260
261 test('weeks year starting tuesday', function (assert) {
262 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
263 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
264 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
265 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
266 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
267 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
268 });
269
270 test('weeks year starting wednesday', function (assert) {
271 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
272 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
273 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
274 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
275 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
276 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
277 });
278
279 test('weeks year starting thursday', function (assert) {
280 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
281 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
282 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
283 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
284 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
285 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
286 });
287
288 test('weeks year starting friday', function (assert) {
289 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
290 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
291 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
292 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
293 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
294 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
295 });
296
297 test('weeks year starting saturday', function (assert) {
298 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
299 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
300 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
301 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
302 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
303 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
304 });
305
306 test('weeks year starting sunday formatted', function (assert) {
307 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
308 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
309 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
310 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
311 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
312 });
313
314 test('lenient ordinal parsing', function (assert) {
315 var i, ordinalStr, testMoment;
316 for (i = 1; i <= 31; ++i) {
317 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
318 testMoment = moment(ordinalStr, 'YYYY MM Do');
319 assert.equal(testMoment.year(), 2014,
320 'lenient ordinal parsing ' + i + ' year check');
321 assert.equal(testMoment.month(), 0,
322 'lenient ordinal parsing ' + i + ' month check');
323 assert.equal(testMoment.date(), i,
324 'lenient ordinal parsing ' + i + ' date check');
325 }
326 });
327
328 test('lenient ordinal parsing of number', function (assert) {
329 var i, testMoment;
330 for (i = 1; i <= 31; ++i) {
331 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
332 assert.equal(testMoment.year(), 2014,
333 'lenient ordinal parsing of number ' + i + ' year check');
334 assert.equal(testMoment.month(), 0,
335 'lenient ordinal parsing of number ' + i + ' month check');
336 assert.equal(testMoment.date(), i,
337 'lenient ordinal parsing of number ' + i + ' date check');
338 }
339 });
340
341 test('strict ordinal parsing', function (assert) {
342 var i, ordinalStr, testMoment;
343 for (i = 1; i <= 31; ++i) {
344 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
345 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
346 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
347 }
348 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('pt-br');
3
4 test('parse', function (assert) {
5 var tests = 'janeiro jan_fevereiro fev_março mar_abril abr_maio mai_junho jun_julho jul_agosto ago_setembro set_outubro out_novembro nov_dezembro dez'.split('_'), i;
6
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10
11 for (i = 0; i < 12; i++) {
12 tests[i] = tests[i].split(' ');
13 equalTest(tests[i][0], 'MMM', i);
14 equalTest(tests[i][1], 'MMM', i);
15 equalTest(tests[i][0], 'MMMM', i);
16 equalTest(tests[i][1], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21 }
22 });
23
24 test('format', function (assert) {
25 var a = [
26 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
27 ['ddd, hA', 'Dom, 3PM'],
28 ['M Mo MM MMMM MMM', '2 2º 02 Fevereiro Fev'],
29 ['YYYY YY', '2010 10'],
30 ['D Do DD', '14 14º 14'],
31 ['d do dddd ddd', '0 0º Domingo Dom'],
32 ['DDD DDDo DDDD', '45 45º 045'],
33 ['w wo ww', '8 8º 08'],
34 ['h hh', '3 03'],
35 ['H HH', '15 15'],
36 ['m mm', '25 25'],
37 ['s ss', '50 50'],
38 ['a A', 'pm PM'],
39 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
40 ['LTS', '15:25:50'],
41 ['L', '14/02/2010'],
42 ['LL', '14 de Fevereiro de 2010'],
43 ['LLL', '14 de Fevereiro de 2010 às 15:25'],
44 ['LLLL', 'Domingo, 14 de Fevereiro de 2010 às 15:25'],
45 ['l', '14/2/2010'],
46 ['ll', '14 de Fev de 2010'],
47 ['lll', '14 de Fev de 2010 às 15:25'],
48 ['llll', 'Dom, 14 de Fev de 2010 às 15:25']
49 ],
50 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
51 i;
52 for (i = 0; i < a.length; i++) {
53 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
54 }
55 });
56
57 test('format ordinal', function (assert) {
58 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
59 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
60 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
61 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
62 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
63 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
64 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
65 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
66 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
67 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
68
69 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
70 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
71 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
72 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
73 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
74 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
75 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
76 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
77 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
78 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
79
80 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
81 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
82 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
83 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
84 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
85 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
86 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
87 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
88 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
89 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
90
91 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
92 });
93
94 test('format month', function (assert) {
95 var expected = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split('_'), i;
96 for (i = 0; i < expected.length; i++) {
97 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
98 }
99 });
100
101 test('format week', function (assert) {
102 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;
103 for (i = 0; i < expected.length; i++) {
104 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
105 }
106 });
107
108 test('from', function (assert) {
109 var start = moment([2007, 1, 28]);
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'poucos segundos', '44 seconds = seconds');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'um minuto', '45 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'um minuto', '89 seconds = a minute');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'uma hora', '45 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'uma hora', '89 minutes = an hour');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'um dia', '22 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'um dia', '35 hours = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dias', '36 hours = 2 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'um dia', '1 day = a day');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dias', '5 days = 5 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dias', '25 days = 25 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'um mês', '26 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'um mês', '30 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'um mês', '43 days = a month');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'um mês', '1 month = a month');
133 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'um ano', '345 days = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anos', '548 days = 2 years');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'um ano', '1 year = a year');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anos', '5 years = 5 years');
138 });
139
140 test('suffix', function (assert) {
141 assert.equal(moment(30000).from(0), 'em poucos segundos', 'prefix');
142 assert.equal(moment(0).from(30000), 'poucos segundos atrás', 'suffix');
143 });
144
145 test('fromNow', function (assert) {
146 assert.equal(moment().add({s: 30}).fromNow(), 'em poucos segundos', 'in seconds');
147 assert.equal(moment().add({d: 5}).fromNow(), 'em 5 dias', 'in 5 days');
148 });
149
150 test('calendar day', function (assert) {
151 var a = moment().hours(2).minutes(0).seconds(0);
152
153 assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
154 assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
155 assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
156 assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
157 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
158 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
159 });
160
161 test('calendar next week', function (assert) {
162 var i, m;
163 for (i = 2; i < 7; i++) {
164 m = moment().add({d: i});
165 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days current time');
166 m.hours(0).minutes(0).seconds(0).milliseconds(0);
167 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days beginning of day');
168 m.hours(23).minutes(59).seconds(59).milliseconds(999);
169 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days end of day');
170 }
171 });
172
173 test('calendar last week', function (assert) {
174 var i, m;
175 for (i = 2; i < 7; i++) {
176 m = moment().subtract({d: i});
177 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days current time');
178 m.hours(0).minutes(0).seconds(0).milliseconds(0);
179 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days beginning of day');
180 m.hours(23).minutes(59).seconds(59).milliseconds(999);
181 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days end of day');
182 }
183 });
184
185 test('calendar all else', function (assert) {
186 var weeksAgo = moment().subtract({w: 1}),
187 weeksFromNow = moment().add({w: 1});
188
189 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
190 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
191
192 weeksAgo = moment().subtract({w: 2});
193 weeksFromNow = moment().add({w: 2});
194
195 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
196 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
197 });
198
199 test('weeks year starting sunday', function (assert) {
200 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
201 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
202 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
203 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
204 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
205 });
206
207 test('weeks year starting monday', function (assert) {
208 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
209 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
210 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
211 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
212 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
213 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
214 });
215
216 test('weeks year starting tuesday', function (assert) {
217 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
218 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
219 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
220 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
221 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
222 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
223 });
224
225 test('weeks year starting wednesday', function (assert) {
226 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
227 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
228 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
229 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
230 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
231 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
232 });
233
234 test('weeks year starting thursday', function (assert) {
235 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
236 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
237 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
238 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
239 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
240 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
241 });
242
243 test('weeks year starting friday', function (assert) {
244 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
245 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
246 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
247 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
248 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
249 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
250 });
251
252 test('weeks year starting saturday', function (assert) {
253 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
254 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
255 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
256 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
257 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
258 });
259
260 test('weeks year starting sunday format', function (assert) {
261 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
262 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1º', 'Jan 7 2012 should be week 1');
263 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2º', 'Jan 8 2012 should be week 2');
264 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2º', 'Jan 14 2012 should be week 2');
265 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3º', 'Jan 15 2012 should be week 3');
266 });
267
268 test('lenient ordinal parsing', function (assert) {
269 var i, ordinalStr, testMoment;
270 for (i = 1; i <= 31; ++i) {
271 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
272 testMoment = moment(ordinalStr, 'YYYY MM Do');
273 assert.equal(testMoment.year(), 2014,
274 'lenient ordinal parsing ' + i + ' year check');
275 assert.equal(testMoment.month(), 0,
276 'lenient ordinal parsing ' + i + ' month check');
277 assert.equal(testMoment.date(), i,
278 'lenient ordinal parsing ' + i + ' date check');
279 }
280 });
281
282 test('lenient ordinal parsing of number', function (assert) {
283 var i, testMoment;
284 for (i = 1; i <= 31; ++i) {
285 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
286 assert.equal(testMoment.year(), 2014,
287 'lenient ordinal parsing of number ' + i + ' year check');
288 assert.equal(testMoment.month(), 0,
289 'lenient ordinal parsing of number ' + i + ' month check');
290 assert.equal(testMoment.date(), i,
291 'lenient ordinal parsing of number ' + i + ' date check');
292 }
293 });
294
295 test('strict ordinal parsing', function (assert) {
296 var i, ordinalStr, testMoment;
297 for (i = 1; i <= 31; ++i) {
298 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
299 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
300 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
301 }
302 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('pt');
3
4 test('parse', function (assert) {
5 var tests = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Dom, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2º 02 Fevereiro Fev'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14º 14'],
29 ['d do dddd ddd', '0 0º Domingo Dom'],
30 ['DDD DDDo DDDD', '45 45º 045'],
31 ['w wo ww', '6 6º 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45º day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 de Fevereiro de 2010'],
41 ['LLL', '14 de Fevereiro de 2010 15:25'],
42 ['LLLL', 'Domingo, 14 de Fevereiro de 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 de Fev de 2010'],
45 ['lll', '14 de Fev de 2010 15:25'],
46 ['llll', 'Dom, 14 de Fev de 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Domingo Dom Dom_Segunda-Feira Seg 2ª_Terça-Feira Ter 3ª_Quarta-Feira Qua 4ª_Quinta-Feira Qui 5ª_Sexta-Feira Sex 6ª_Sábado Sáb Sáb'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'segundos', '44 seconds = seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'um minuto', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'um minuto', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minutos', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minutos', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'uma hora', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'uma hora', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 horas', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 horas', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 horas', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'um dia', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'um dia', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dias', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'um dia', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dias', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dias', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'um mês', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'um mês', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'um mês', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meses', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meses', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meses', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'um mês', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meses', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'um ano', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 anos', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'um ano', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 anos', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'em segundos', 'prefix');
140 assert.equal(moment(0).from(30000), 'há segundos', 'suffix');
141 });
142
143 test('fromNow', function (assert) {
144 assert.equal(moment().add({s: 30}).fromNow(), 'em segundos', 'in seconds');
145 assert.equal(moment().add({d: 5}).fromNow(), 'em 5 dias', 'in 5 days');
146 });
147
148 test('calendar day', function (assert) {
149 var a = moment().hours(2).minutes(0).seconds(0);
150
151 assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
152 assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
153 assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
154 assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
155 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
156 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
157 });
158
159 test('calendar next week', function (assert) {
160 var i, m;
161 for (i = 2; i < 7; i++) {
162 m = moment().add({d: i});
163 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days current time');
164 m.hours(0).minutes(0).seconds(0).milliseconds(0);
165 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days beginning of day');
166 m.hours(23).minutes(59).seconds(59).milliseconds(999);
167 assert.equal(m.calendar(), m.format('dddd [às] LT'), 'Today + ' + i + ' days end of day');
168 }
169 });
170
171 test('calendar last week', function (assert) {
172 var i, m;
173 for (i = 2; i < 7; i++) {
174 m = moment().subtract({d: i});
175 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days current time');
176 m.hours(0).minutes(0).seconds(0).milliseconds(0);
177 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days beginning of day');
178 m.hours(23).minutes(59).seconds(59).milliseconds(999);
179 assert.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), 'Today - ' + i + ' days end of day');
180 }
181 });
182
183 test('calendar all else', function (assert) {
184 var weeksAgo = moment().subtract({w: 1}),
185 weeksFromNow = moment().add({w: 1});
186
187 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
188 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
189
190 weeksAgo = moment().subtract({w: 2});
191 weeksFromNow = moment().add({w: 2});
192
193 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
194 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
195 });
196
197 test('weeks year starting sunday', function (assert) {
198 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
199 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
200 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
201 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
202 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
203 });
204
205 test('weeks year starting monday', function (assert) {
206 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
207 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
208 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
209 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
210 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
211 });
212
213 test('weeks year starting tuesday', function (assert) {
214 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
215 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
216 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
217 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
218 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
219 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
220 });
221
222 test('weeks year starting wednesday', function (assert) {
223 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
224 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
225 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
226 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
227 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
228 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
229 });
230
231 test('weeks year starting thursday', function (assert) {
232 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
233 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
234 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
235 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
236 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
237 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
238 });
239
240 test('weeks year starting friday', function (assert) {
241 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
242 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
243 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
244 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
245 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
246 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
247 });
248
249 test('weeks year starting saturday', function (assert) {
250 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
251 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
252 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
253 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
254 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
255 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
256 });
257
258 test('weeks year starting sunday formatted', function (assert) {
259 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
260 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
261 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1º', 'Jan 8 2012 should be week 1');
262 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2º', 'Jan 9 2012 should be week 2');
263 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
264 });
265
266 test('lenient ordinal parsing', function (assert) {
267 var i, ordinalStr, testMoment;
268 for (i = 1; i <= 31; ++i) {
269 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
270 testMoment = moment(ordinalStr, 'YYYY MM Do');
271 assert.equal(testMoment.year(), 2014,
272 'lenient ordinal parsing ' + i + ' year check');
273 assert.equal(testMoment.month(), 0,
274 'lenient ordinal parsing ' + i + ' month check');
275 assert.equal(testMoment.date(), i,
276 'lenient ordinal parsing ' + i + ' date check');
277 }
278 });
279
280 test('lenient ordinal parsing of number', function (assert) {
281 var i, testMoment;
282 for (i = 1; i <= 31; ++i) {
283 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
284 assert.equal(testMoment.year(), 2014,
285 'lenient ordinal parsing of number ' + i + ' year check');
286 assert.equal(testMoment.month(), 0,
287 'lenient ordinal parsing of number ' + i + ' month check');
288 assert.equal(testMoment.date(), i,
289 'lenient ordinal parsing of number ' + i + ' date check');
290 }
291 });
292
293 test('strict ordinal parsing', function (assert) {
294 var i, ordinalStr, testMoment;
295 for (i = 1; i <= 31; ++i) {
296 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
297 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
298 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
299 }
300 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ro');
3
4 test('parse', function (assert) {
5 var tests = 'ianuarie ian._februarie febr._martie mart._aprilie apr._mai mai_iunie iun._iulie iul._august aug._septembrie sept._octombrie oct._noiembrie nov._decembrie dec.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss A', 'duminică, februarie 14 2010, 3:25:50 PM'],
25 ['ddd, hA', 'Dum, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2 02 februarie febr.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 duminică Dum Du'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '7 7 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[a] DDDo[a zi a anului]', 'a 45a zi a anului'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14 februarie 2010'],
41 ['LLL', '14 februarie 2010 15:25'],
42 ['LLLL', 'duminică, 14 februarie 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14 febr. 2010'],
45 ['lll', '14 febr. 2010 15:25'],
46 ['llll', 'Dum, 14 febr. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'ianuarie ian._februarie febr._martie mart._aprilie apr._mai mai_iunie iun._iulie iul._august aug._septembrie sept._octombrie oct._noiembrie nov._decembrie dec.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'duminică Dum Du_luni Lun Lu_marți Mar Ma_miercuri Mie Mi_joi Joi Jo_vineri Vin Vi_sâmbătă Sâm Sâ'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'câteva secunde', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'un minut', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'un minut', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 de minute', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'o oră', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'o oră', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ore', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ore', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 de ore', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'o zi', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'o zi', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 zile', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'o zi', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 zile', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 de zile', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'o lună', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'o lună', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'o lună', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 luni', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 luni', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 luni', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'o lună', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 luni', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'un an', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ani', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'un an', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ani', '5 years = 5 years');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 19}), true), '19 ani', '19 years = 19 years');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 20}), true), '20 de ani', '20 years = 20 years');
138 assert.equal(start.from(moment([2007, 1, 28]).add({y: 100}), true), '100 de ani', '100 years = 100 years');
139 assert.equal(start.from(moment([2007, 1, 28]).add({y: 101}), true), '101 ani', '101 years = 101 years');
140 assert.equal(start.from(moment([2007, 1, 28]).add({y: 119}), true), '119 ani', '119 years = 119 years');
141 assert.equal(start.from(moment([2007, 1, 28]).add({y: 120}), true), '120 de ani', '120 years = 120 years');
142 assert.equal(start.from(moment([2007, 1, 28]).add({y: 219}), true), '219 ani', '219 years = 219 years');
143 assert.equal(start.from(moment([2007, 1, 28]).add({y: 220}), true), '220 de ani', '220 years = 220 years');
144 });
145
146 test('suffix', function (assert) {
147 assert.equal(moment(30000).from(0), 'peste câteva secunde', 'prefix');
148 assert.equal(moment(0).from(30000), 'câteva secunde în urmă', 'suffix');
149 });
150
151 test('now from now', function (assert) {
152 assert.equal(moment().fromNow(), 'câteva secunde în urmă', 'now from now should display as in the past');
153 });
154
155 test('fromNow', function (assert) {
156 assert.equal(moment().add({s: 30}).fromNow(), 'peste câteva secunde', 'in a few seconds');
157 assert.equal(moment().add({d: 5}).fromNow(), 'peste 5 zile', 'in 5 days');
158 });
159
160 test('calendar day', function (assert) {
161 var a = moment().hours(2).minutes(0).seconds(0);
162
163 assert.equal(moment(a).calendar(), 'azi la 2:00', 'today at the same time');
164 assert.equal(moment(a).add({m: 25}).calendar(), 'azi la 2:25', 'Now plus 25 min');
165 assert.equal(moment(a).add({h: 1}).calendar(), 'azi la 3:00', 'Now plus 1 hour');
166 assert.equal(moment(a).add({d: 1}).calendar(), 'mâine la 2:00', 'tomorrow at the same time');
167 assert.equal(moment(a).subtract({h: 1}).calendar(), 'azi la 1:00', 'Now minus 1 hour');
168 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieri la 2:00', 'yesterday at the same time');
169 });
170
171 test('calendar next week', function (assert) {
172 var i, m;
173 for (i = 2; i < 7; i++) {
174 m = moment().add({d: i});
175 assert.equal(m.calendar(), m.format('dddd [la] LT'), 'Today + ' + i + ' days current time');
176 m.hours(0).minutes(0).seconds(0).milliseconds(0);
177 assert.equal(m.calendar(), m.format('dddd [la] LT'), 'Today + ' + i + ' days beginning of day');
178 m.hours(23).minutes(59).seconds(59).milliseconds(999);
179 assert.equal(m.calendar(), m.format('dddd [la] LT'), 'Today + ' + i + ' days end of day');
180 }
181 });
182
183 test('calendar last week', function (assert) {
184 var i, m;
185 for (i = 2; i < 7; i++) {
186 m = moment().subtract({d: i});
187 assert.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), 'Today - ' + i + ' days current time');
188 m.hours(0).minutes(0).seconds(0).milliseconds(0);
189 assert.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), 'Today - ' + i + ' days beginning of day');
190 m.hours(23).minutes(59).seconds(59).milliseconds(999);
191 assert.equal(m.calendar(), m.format('[fosta] dddd [la] LT'), 'Today - ' + i + ' days end of day');
192 }
193 });
194
195 test('calendar all else', function (assert) {
196 var weeksAgo = moment().subtract({w: 1}),
197 weeksFromNow = moment().add({w: 1});
198
199 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
200 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
201
202 weeksAgo = moment().subtract({w: 2});
203 weeksFromNow = moment().add({w: 2});
204
205 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
206 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
207 });
208
209 test('weeks year starting sunday', function (assert) {
210 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
211 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
212 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
213 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
214 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
215 });
216
217 test('weeks year starting monday', function (assert) {
218 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
219 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
220 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
221 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
222 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
223 });
224
225 test('weeks year starting tuesday', function (assert) {
226 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
227 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
228 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
229 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
230 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
231 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
232 });
233
234 test('weeks year starting wednesday', function (assert) {
235 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
236 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
237 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
238 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
239 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
240 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
241 });
242
243 test('weeks year starting thursday', function (assert) {
244 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
245 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
246 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
247 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
248 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
249 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
250 });
251
252 test('weeks year starting friday', function (assert) {
253 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
254 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
255 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
256 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
257 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
258 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
259 });
260
261 test('weeks year starting saturday', function (assert) {
262 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
263 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
264 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
265 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
266 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
267 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
268 });
269
270 test('weeks year starting sunday formatted', function (assert) {
271 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
272 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
273 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 2');
274 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
275 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
276 });
277
278 test('lenient ordinal parsing', function (assert) {
279 var i, ordinalStr, testMoment;
280 for (i = 1; i <= 31; ++i) {
281 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
282 testMoment = moment(ordinalStr, 'YYYY MM Do');
283 assert.equal(testMoment.year(), 2014,
284 'lenient ordinal parsing ' + i + ' year check');
285 assert.equal(testMoment.month(), 0,
286 'lenient ordinal parsing ' + i + ' month check');
287 assert.equal(testMoment.date(), i,
288 'lenient ordinal parsing ' + i + ' date check');
289 }
290 });
291
292 test('lenient ordinal parsing of number', function (assert) {
293 var i, testMoment;
294 for (i = 1; i <= 31; ++i) {
295 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
296 assert.equal(testMoment.year(), 2014,
297 'lenient ordinal parsing of number ' + i + ' year check');
298 assert.equal(testMoment.month(), 0,
299 'lenient ordinal parsing of number ' + i + ' month check');
300 assert.equal(testMoment.date(), i,
301 'lenient ordinal parsing of number ' + i + ' date check');
302 }
303 });
304
305 test('strict ordinal parsing', function (assert) {
306 var i, ordinalStr, testMoment;
307 for (i = 1; i <= 31; ++i) {
308 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
309 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
310 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
311 }
312 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ru');
3
4 test('parse', function (assert) {
5 var tests = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('parse exceptional case', function (assert) {
23 assert.equal(moment('11 мая 1989', ['DD MMMM YYYY']).format('DD-MM-YYYY'), '11-05-1989');
24 });
25
26 test('format', function (assert) {
27 var a = [
28 ['dddd, Do MMMM YYYY, HH:mm:ss', 'воскресенье, 14-го февраля 2010, 15:25:50'],
29 ['ddd, h A', 'вс, 3 дня'],
30 ['M Mo MM MMMM MMM', '2 2-й 02 февраль фев'],
31 ['YYYY YY', '2010 10'],
32 ['D Do DD', '14 14-го 14'],
33 ['d do dddd ddd dd', '0 0-й воскресенье вс вс'],
34 ['DDD DDDo DDDD', '45 45-й 045'],
35 ['w wo ww', '7 7-я 07'],
36 ['h hh', '3 03'],
37 ['H HH', '15 15'],
38 ['m mm', '25 25'],
39 ['s ss', '50 50'],
40 ['a A', 'дня дня'],
41 ['DDDo [день года]', '45-й день года'],
42 ['LTS', '15:25:50'],
43 ['L', '14.02.2010'],
44 ['LL', '14 февраля 2010 г.'],
45 ['LLL', '14 февраля 2010 г., 15:25'],
46 ['LLLL', 'воскресенье, 14 февраля 2010 г., 15:25'],
47 ['l', '14.2.2010'],
48 ['ll', '14 фев 2010 г.'],
49 ['lll', '14 фев 2010 г., 15:25'],
50 ['llll', 'вс, 14 фев 2010 г., 15:25']
51 ],
52 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
53 i;
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format meridiem', function (assert) {
60 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'ночи', 'night');
61 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'ночи', 'night');
62 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'утра', 'morning');
63 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'утра', 'morning');
64 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'дня', 'afternoon');
65 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'дня', 'afternoon');
66 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'вечера', 'evening');
67 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'вечера', 'evening');
68 });
69
70 test('format ordinal', function (assert) {
71 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-й', '1-й');
72 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-й', '2-й');
73 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-й', '3-й');
74 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-й', '4-й');
75 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-й', '5-й');
76 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-й', '6-й');
77 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-й', '7-й');
78 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-й', '8-й');
79 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-й', '9-й');
80 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-й', '10-й');
81
82 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-й', '11-й');
83 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-й', '12-й');
84 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-й', '13-й');
85 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-й', '14-й');
86 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-й', '15-й');
87 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-й', '16-й');
88 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-й', '17-й');
89 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-й', '18-й');
90 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-й', '19-й');
91 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-й', '20-й');
92
93 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-й', '21-й');
94 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-й', '22-й');
95 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-й', '23-й');
96 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-й', '24-й');
97 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-й', '25-й');
98 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-й', '26-й');
99 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-й', '27-й');
100 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-й', '28-й');
101 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-й', '29-й');
102 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-й', '30-й');
103
104 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-й', '31-й');
105 });
106
107 test('format month', function (assert) {
108 var expected = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
111 }
112 });
113
114 test('format month case', function (assert) {
115 var months = {
116 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
117 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
118 }, i;
119 for (i = 0; i < 12; i++) {
120 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
121 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
122 }
123 });
124
125 test('format month short case', function (assert) {
126 var monthsShort = {
127 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
128 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
129 }, i;
130 for (i = 0; i < 12; i++) {
131 assert.equal(moment([2011, i, 1]).format('D MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
132 assert.equal(moment([2011, i, 1]).format('MMM'), monthsShort.nominative[i], '1 ' + monthsShort.nominative[i]);
133 }
134 });
135
136 test('format month case with escaped symbols', function (assert) {
137 var months = {
138 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
139 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
140 }, i;
141 for (i = 0; i < 12; i++) {
142 assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
143 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMMM[</b>]'), '<i>1</i> <b>' + months.accusative[i] + '</b>', '1 <b>' + months.accusative[i] + '</b>');
144 assert.equal(moment([2013, i, 1]).format('D[-й день] MMMM'), '1-й день ' + months.accusative[i], '1-й день ' + months.accusative[i]);
145 assert.equal(moment([2013, i, 1]).format('D, MMMM'), '1, ' + months.nominative[i], '1, ' + months.nominative[i]);
146 }
147 });
148
149 test('format month short case with escaped symbols', function (assert) {
150 var monthsShort = {
151 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
152 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
153 }, i;
154 for (i = 0; i < 12; i++) {
155 assert.equal(moment([2013, i, 1]).format('D[] MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
156 assert.equal(moment([2013, i, 1]).format('[<i>]D[</i>] [<b>]MMM[</b>]'), '<i>1</i> <b>' + monthsShort.accusative[i] + '</b>', '1 <b>' + monthsShort.accusative[i] + '</b>');
157 assert.equal(moment([2013, i, 1]).format('D[-й день] MMM'), '1-й день ' + monthsShort.accusative[i], '1-й день ' + monthsShort.accusative[i]);
158 assert.equal(moment([2013, i, 1]).format('D, MMM'), '1, ' + monthsShort.nominative[i], '1, ' + monthsShort.nominative[i]);
159 }
160 });
161
162 test('format week', function (assert) {
163 var expected = 'воскресенье вс вс_понедельник пн пн_вторник вт вт_среда ср ср_четверг чт чт_пятница пт пт_суббота сб сб'.split('_'), i;
164 for (i = 0; i < expected.length; i++) {
165 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
166 }
167 });
168
169 test('from', function (assert) {
170 var start = moment([2007, 1, 28]);
171 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'несколько секунд', '44 seconds = seconds');
172 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'минута', '45 seconds = a minute');
173 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'минута', '89 seconds = a minute');
174 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минуты', '90 seconds = 2 minutes');
175 assert.equal(start.from(moment([2007, 1, 28]).add({m: 31}), true), '31 минута', '31 minutes = 31 minutes');
176 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минуты', '44 minutes = 44 minutes');
177 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'час', '45 minutes = an hour');
178 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'час', '89 minutes = an hour');
179 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 часа', '90 minutes = 2 hours');
180 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 часов', '5 hours = 5 hours');
181 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 час', '21 hours = 21 hours');
182 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'день', '22 hours = a day');
183 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'день', '35 hours = a day');
184 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дня', '36 hours = 2 days');
185 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'день', '1 day = a day');
186 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дней', '5 days = 5 days');
187 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 дней', '11 days = 11 days');
188 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 день', '21 days = 21 days');
189 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дней', '25 days = 25 days');
190 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месяц', '26 days = a month');
191 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месяц', '30 days = a month');
192 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месяц', '43 days = a month');
193 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месяца', '46 days = 2 months');
194 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месяца', '75 days = 2 months');
195 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месяца', '76 days = 3 months');
196 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месяц', '1 month = a month');
197 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месяцев', '5 months = 5 months');
198 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'год', '345 days = a year');
199 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 года', '548 days = 2 years');
200 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'год', '1 year = a year');
201 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 лет', '5 years = 5 years');
202 });
203
204 test('suffix', function (assert) {
205 assert.equal(moment(30000).from(0), 'через несколько секунд', 'prefix');
206 assert.equal(moment(0).from(30000), 'несколько секунд назад', 'suffix');
207 });
208
209 test('fromNow', function (assert) {
210 assert.equal(moment().add({s: 30}).fromNow(), 'через несколько секунд', 'in seconds');
211 assert.equal(moment().add({d: 5}).fromNow(), 'через 5 дней', 'in 5 days');
212 assert.equal(moment().add({m: 31}).fromNow(), 'через 31 минуту', 'in 31 minutes = in 31 minutes');
213 assert.equal(moment().subtract({m: 31}).fromNow(), '31 минуту назад', '31 minutes ago = 31 minutes ago');
214 });
215
216 test('calendar day', function (assert) {
217 var a = moment().hours(2).minutes(0).seconds(0);
218
219 assert.equal(moment(a).calendar(), 'Сегодня в 02:00', 'today at the same time');
220 assert.equal(moment(a).add({m: 25}).calendar(), 'Сегодня в 02:25', 'Now plus 25 min');
221 assert.equal(moment(a).add({h: 1}).calendar(), 'Сегодня в 03:00', 'Now plus 1 hour');
222 assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра в 02:00', 'tomorrow at the same time');
223 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сегодня в 01:00', 'Now minus 1 hour');
224 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 02:00', 'yesterday at the same time');
225 });
226
227 test('calendar next week', function (assert) {
228 var i, m;
229 function makeFormat(d) {
230 return d.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
231 }
232
233 for (i = 2; i < 7; i++) {
234 m = moment().add({d: i});
235 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
236 m.hours(0).minutes(0).seconds(0).milliseconds(0);
237 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
238 m.hours(23).minutes(59).seconds(59).milliseconds(999);
239 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
240 }
241 });
242
243 test('calendar last week', function (assert) {
244 var i, m, now;
245
246 function makeFormatLast(d) {
247 switch (d.day()) {
248 case 0:
249 return '[В прошлое] dddd [в] LT';
250 case 1:
251 case 2:
252 case 4:
253 return '[В прошлый] dddd [в] LT';
254 case 3:
255 case 5:
256 case 6:
257 return '[В прошлую] dddd [в] LT';
258 }
259 }
260
261 function makeFormatThis(d) {
262 switch (d.day()) {
263 case 2:
264 return '[Во] dddd [в] LT';
265 case 0:
266 case 1:
267 case 3:
268 case 4:
269 case 5:
270 case 6:
271 return '[В] dddd [в] LT';
272 }
273 }
274
275 now = moment().startOf('week');
276 for (i = 2; i < 7; i++) {
277 m = moment(now).subtract({d: i});
278 assert.equal(m.calendar(now), m.format(makeFormatLast(m)), 'Today - ' + i + ' days current time');
279 m.hours(0).minutes(0).seconds(0).milliseconds(0);
280 assert.equal(m.calendar(now), m.format(makeFormatLast(m)), 'Today - ' + i + ' days beginning of day');
281 m.hours(23).minutes(59).seconds(59).milliseconds(999);
282 assert.equal(m.calendar(now), m.format(makeFormatLast(m)), 'Today - ' + i + ' days end of day');
283 }
284
285 now = moment().endOf('week');
286 for (i = 2; i < 7; i++) {
287 m = moment(now).subtract({d: i});
288 assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today - ' + i + ' days current time');
289 m.hours(0).minutes(0).seconds(0).milliseconds(0);
290 assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today - ' + i + ' days beginning of day');
291 m.hours(23).minutes(59).seconds(59).milliseconds(999);
292 assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today - ' + i + ' days end of day');
293 }
294 });
295
296 test('calendar all else', function (assert) {
297 var weeksAgo = moment().subtract({w: 1}),
298 weeksFromNow = moment().add({w: 1});
299
300 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
301 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
302
303 weeksAgo = moment().subtract({w: 2});
304 weeksFromNow = moment().add({w: 2});
305
306 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
307 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
308 });
309
310 test('weeks year starting sunday', function (assert) {
311 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
312 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
313 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
314 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
315 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
316 });
317
318 test('weeks year starting monday', function (assert) {
319 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
320 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
321 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
322 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
323 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
324 });
325
326 test('weeks year starting tuesday', function (assert) {
327 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
328 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
329 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
330 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
331 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
332 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
333 });
334
335 test('weeks year starting wednesday', function (assert) {
336 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
337 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
338 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
339 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
340 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
341 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
342 });
343
344 test('weeks year starting thursday', function (assert) {
345 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
346 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
347 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
348 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
349 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
350 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
351 });
352
353 test('weeks year starting friday', function (assert) {
354 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
355 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
356 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
357 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
358 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
359 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
360 });
361
362 test('weeks year starting saturday', function (assert) {
363 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
364 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
365 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
366 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
367 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
368 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
369 });
370
371 test('weeks year starting sunday formatted', function (assert) {
372 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-я', 'Dec 26 2011 should be week 1');
373 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-я', 'Jan 1 2012 should be week 1');
374 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-я', 'Jan 2 2012 should be week 2');
375 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-я', 'Jan 8 2012 should be week 2');
376 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-я', 'Jan 9 2012 should be week 3');
377 });
378
379 test('lenient ordinal parsing', function (assert) {
380 var i, ordinalStr, testMoment;
381 for (i = 1; i <= 31; ++i) {
382 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
383 testMoment = moment(ordinalStr, 'YYYY MM Do');
384 assert.equal(testMoment.year(), 2014,
385 'lenient ordinal parsing ' + i + ' year check');
386 assert.equal(testMoment.month(), 0,
387 'lenient ordinal parsing ' + i + ' month check');
388 assert.equal(testMoment.date(), i,
389 'lenient ordinal parsing ' + i + ' date check');
390 }
391 });
392
393 test('lenient ordinal parsing of number', function (assert) {
394 var i, testMoment;
395 for (i = 1; i <= 31; ++i) {
396 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
397 assert.equal(testMoment.year(), 2014,
398 'lenient ordinal parsing of number ' + i + ' year check');
399 assert.equal(testMoment.month(), 0,
400 'lenient ordinal parsing of number ' + i + ' month check');
401 assert.equal(testMoment.date(), i,
402 'lenient ordinal parsing of number ' + i + ' date check');
403 }
404 });
405
406 test('strict ordinal parsing', function (assert) {
407 var i, ordinalStr, testMoment;
408 for (i = 1; i <= 31; ++i) {
409 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
410 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
411 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
412 }
413 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('si');
3
4 /*jshint -W100*/
5 test('parse', function (assert) {
6 var tests = 'ජනවාරි ජන_පෙබරවාරි පෙබ_මාර්තු මාර්_අප්‍රේල් අප්_මැයි මැයි_ජූනි ජූනි_ජූලි ජූලි_අගෝස්තු අගෝ_සැප්තැම්බර් සැප්_ඔක්තෝබර් ඔක්_නොවැම්බර් නොවැ_දෙසැම්බර් දෙසැ'.split('_'), i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['YYYY MMMM Do dddd, a h:mm:ss', '2010 පෙබරවාරි 14 වැනි ඉරිදා, ප.ව. 3:25:50'],
26 ['YYYY MMMM Do dddd, a h:mm:ss', '2010 පෙබරවාරි 14 වැනි ඉරිදා, ප.ව. 3:25:50'],
27 ['ddd, A h', 'ඉරි, පස් වරු 3'],
28 ['M Mo MM MMMM MMM', '2 2 වැනි 02 පෙබරවාරි පෙබ'],
29 ['YYYY YY', '2010 10'],
30 ['D Do DD', '14 14 වැනි 14'],
31 ['d do dddd ddd dd', '0 0 වැනි ඉරිදා ඉරි ඉ'],
32 ['DDD DDDo DDDD', '45 45 වැනි 045'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'ප.ව. පස් වරු'],
38 ['[වසරේ] DDDo [දිනය]', 'වසරේ 45 වැනි දිනය'],
39 ['LTS', 'ප.ව. 3:25:50'],
40 ['LT', 'ප.ව. 3:25'],
41 ['L', '2010/02/14'],
42 ['LL', '2010 පෙබරවාරි 14'],
43 ['LLL', '2010 පෙබරවාරි 14, ප.ව. 3:25'],
44 ['LLLL', '2010 පෙබරවාරි 14 වැනි ඉරිදා, ප.ව. 3:25:50'],
45 ['l', '2010/2/14'],
46 ['ll', '2010 පෙබ 14'],
47 ['lll', '2010 පෙබ 14, ප.ව. 3:25'],
48 ['llll', '2010 පෙබ 14 වැනි ඉරි, ප.ව. 3:25:50']
49 ],
50 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
51 i;
52 for (i = 0; i < a.length; i++) {
53 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
54 }
55 });
56
57 test('format ordinal', function (assert) {
58 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1 වැනි', '1 වැනි');
59 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2 වැනි', '2 වැනි');
60 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3 වැනි', '3 වැනි');
61 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4 වැනි', '4 වැනි');
62 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5 වැනි', '5 වැනි');
63 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6 වැනි', '6 වැනි');
64 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7 වැනි', '7 වැනි');
65 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8 වැනි', '8 වැනි');
66 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9 වැනි', '9 වැනි');
67 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10 වැනි', '10 වැනි');
68
69 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11 වැනි', '11 වැනි');
70 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12 වැනි', '12 වැනි');
71 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13 වැනි', '13 වැනි');
72 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14 වැනි', '14 වැනි');
73 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15 වැනි', '15 වැනි');
74 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16 වැනි', '16 වැනි');
75 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17 වැනි', '17 වැනි');
76 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18 වැනි', '18 වැනි');
77 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19 වැනි', '19 වැනි');
78 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20 වැනි', '20 වැනි');
79
80 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21 වැනි', '21 වැනි');
81 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22 වැනි', '22 වැනි');
82 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23 වැනි', '23 වැනි');
83 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24 වැනි', '24 වැනි');
84 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25 වැනි', '25 වැනි');
85 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26 වැනි', '26 වැනි');
86 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27 වැනි', '27 වැනි');
87 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28 වැනි', '28 වැනි');
88 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29 වැනි', '29 වැනි');
89 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30 වැනි', '30 වැනි');
90
91 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31 වැනි', '31 වැනි');
92 });
93
94 test('format month', function (assert) {
95 var expected = 'ජනවාරි ජන_පෙබරවාරි පෙබ_මාර්තු මාර්_අප්‍රේල් අප්_මැයි මැයි_ජූනි ජූනි_ජූලි ජූලි_අගෝස්තු අගෝ_සැප්තැම්බර් සැප්_ඔක්තෝබර් ඔක්_නොවැම්බර් නොවැ_දෙසැම්බර් දෙසැ'.split('_'), i;
96 for (i = 0; i < expected.length; i++) {
97 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
98 }
99 });
100
101 test('format week', function (assert) {
102 var expected = 'ඉරිදා ඉරි ඉ_සඳුදා සඳු ස_අඟහරුවාදා අඟ අ_බදාදා බදා බ_බ්‍රහස්පතින්දා බ්‍රහ බ්‍ර_සිකුරාදා සිකු සි_සෙනසුරාදා සෙන සෙ'.split('_'), i;
103 for (i = 0; i < expected.length; i++) {
104 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
105 }
106 });
107
108 test('from', function (assert) {
109 var start = moment([2007, 1, 28]);
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'තත්පර කිහිපය', '44 seconds = a few seconds');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'මිනිත්තුව', '45 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'මිනිත්තුව', '89 seconds = a minute');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'මිනිත්තු 2', '90 seconds = 2 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), 'මිනිත්තු 44', '44 minutes = 44 minutes');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'පැය', '45 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'පැය', '89 minutes = an hour');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'පැය 2', '90 minutes = 2 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'පැය 5', '5 hours = 5 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), 'පැය 21', '21 hours = 21 hours');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'දිනය', '22 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'දිනය', '35 hours = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'දින 2', '36 hours = 2 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'දිනය', '1 day = a day');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'දින 5', '5 days = 5 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), 'දින 25', '25 days = 25 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'මාසය', '26 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'මාසය', '30 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'මාසය', '43 days = a month');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'මාස 2', '46 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'මාස 2', '75 days = 2 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'මාස 3', '76 days = 3 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'මාසය', '1 month = a month');
133 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'මාස 5', '5 months = 5 months');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'වසර', '345 days = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'වසර 2', '548 days = 2 years');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'වසර', '1 year = a year');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'වසර 5', '5 years = 5 years');
138 });
139
140 test('suffix', function (assert) {
141 assert.equal(moment(30000).from(0), 'තත්පර කිහිපයකින්', 'prefix');
142 assert.equal(moment(0).from(30000), 'තත්පර කිහිපයකට පෙර', 'suffix');
143 });
144
145 test('now from now', function (assert) {
146 assert.equal(moment().fromNow(), 'තත්පර කිහිපයකට පෙර', 'now from now should display as in the past');
147 });
148
149 test('fromNow', function (assert) {
150 assert.equal(moment().add({s: 30}).fromNow(), 'තත්පර කිහිපයකින්', 'in a few seconds');
151 assert.equal(moment().add({d: 5}).fromNow(), 'දින 5කින්', 'in 5 days');
152 });
153
154 test('calendar day', function (assert) {
155 var a = moment().hours(2).minutes(0).seconds(0);
156
157 assert.equal(moment(a).calendar(), 'අද පෙ.ව. 2:00ට', 'today at the same time');
158 assert.equal(moment(a).add({m: 25}).calendar(), 'අද පෙ.ව. 2:25ට', 'Now plus 25 min');
159 assert.equal(moment(a).add({h: 1}).calendar(), 'අද පෙ.ව. 3:00ට', 'Now plus 1 hour');
160 assert.equal(moment(a).add({d: 1}).calendar(), 'හෙට පෙ.ව. 2:00ට', 'tomorrow at the same time');
161 assert.equal(moment(a).subtract({h: 1}).calendar(), 'අද පෙ.ව. 1:00ට', 'Now minus 1 hour');
162 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ඊයේ පෙ.ව. 2:00ට', 'yesterday at the same time');
163 });
164
165 test('calendar next week', function (assert) {
166 var i, m;
167 for (i = 2; i < 7; i++) {
168 m = moment().add({d: i});
169 assert.equal(m.calendar(), m.format('dddd LT[ට]'), 'Today + ' + i + ' days current time');
170 m.hours(0).minutes(0).seconds(0).milliseconds(0);
171 assert.equal(m.calendar(), m.format('dddd LT[ට]'), 'Today + ' + i + ' days beginning of day');
172 m.hours(23).minutes(59).seconds(59).milliseconds(999);
173 assert.equal(m.calendar(), m.format('dddd LT[ට]'), 'Today + ' + i + ' days end of day');
174 }
175 });
176
177 test('calendar last week', function (assert) {
178 var i, m;
179
180 for (i = 2; i < 7; i++) {
181 m = moment().subtract({d: i});
182 assert.equal(m.calendar(), m.format('[පසුගිය] dddd LT[ට]'), 'Today - ' + i + ' days current time');
183 m.hours(0).minutes(0).seconds(0).milliseconds(0);
184 assert.equal(m.calendar(), m.format('[පසුගිය] dddd LT[ට]'), 'Today - ' + i + ' days beginning of day');
185 m.hours(23).minutes(59).seconds(59).milliseconds(999);
186 assert.equal(m.calendar(), m.format('[පසුගිය] dddd LT[ට]'), 'Today - ' + i + ' days end of day');
187 }
188 });
189
190 test('calendar all else', function (assert) {
191 var weeksAgo = moment().subtract({w: 1}),
192 weeksFromNow = moment().add({w: 1});
193
194 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
195 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
196
197 weeksAgo = moment().subtract({w: 2});
198 weeksFromNow = moment().add({w: 2});
199
200 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
201 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
202 });
203
204 test('lenient ordinal parsing', function (assert) {
205 var i, ordinalStr, testMoment;
206 for (i = 1; i <= 31; ++i) {
207 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
208 testMoment = moment(ordinalStr, 'YYYY MM Do');
209 assert.equal(testMoment.year(), 2014,
210 'lenient ordinal parsing ' + i + ' year check');
211 assert.equal(testMoment.month(), 0,
212 'lenient ordinal parsing ' + i + ' month check');
213 assert.equal(testMoment.date(), i,
214 'lenient ordinal parsing ' + i + ' date check');
215 }
216 });
217
218 test('lenient ordinal parsing of number', function (assert) {
219 var i, testMoment;
220 for (i = 1; i <= 31; ++i) {
221 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
222 assert.equal(testMoment.year(), 2014,
223 'lenient ordinal parsing of number ' + i + ' year check');
224 assert.equal(testMoment.month(), 0,
225 'lenient ordinal parsing of number ' + i + ' month check');
226 assert.equal(testMoment.date(), i,
227 'lenient ordinal parsing of number ' + i + ' date check');
228 }
229 });
230
231 test('strict ordinal parsing', function (assert) {
232 var i, ordinalStr, testMoment;
233 for (i = 1; i <= 31; ++i) {
234 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
235 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
236 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
237 }
238 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('sk');
3
4 test('parse', function (assert) {
5 var tests = 'január jan._február feb._marec mar._apríl apr._máj máj_jún jún._júl júl._august aug._september sep._október okt._november nov._december dec.'.split('_'), i;
6 function equalTest(input, mmm, monthIndex) {
7 assert.equal(moment(input, mmm).month(), monthIndex, input + ' should be month ' + (monthIndex + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss', 'nedeľa, február 14. 2010, 3:25:50'],
25 ['ddd, h', 'ne, 3'],
26 ['M Mo MM MMMM MMM', '2 2. 02 február feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. nedeľa ne ne'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['DDDo [deň v roku]', '45. deň v roku'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14. február 2010'],
41 ['LLL', '14. február 2010 15:25'],
42 ['LLLL', 'nedeľa 14. február 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14. feb 2010'],
45 ['lll', '14. feb 2010 15:25'],
46 ['llll', 'ne 14. feb 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'január jan_február feb_marec mar_apríl apr_máj máj_jún jún_júl júl_august aug_september sep_október okt_november nov_december dec'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'nedeľa ne ne_pondelok po po_utorok ut ut_streda st st_štvrtok št št_piatok pi pi_sobota so so'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'pár sekúnd', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minúta', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minúta', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minúty', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minút', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'hodina', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'hodina', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 hodiny', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 hodín', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 hodín', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'deň', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'deň', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dni', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'deň', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dní', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dní', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mesiac', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mesiac', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mesiac', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesiace', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesiace', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesiace', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mesiac', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesiacov', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'rok', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 roky', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'rok', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 rokov', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'za pár sekúnd', 'prefix');
140 assert.equal(moment(0).from(30000), 'pred pár sekundami', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'pred pár sekundami', 'now from now should display as in the past');
145 });
146
147 test('fromNow (future)', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'za pár sekúnd', 'in a few seconds');
149 assert.equal(moment().add({m: 1}).fromNow(), 'za minútu', 'in a minute');
150 assert.equal(moment().add({m: 3}).fromNow(), 'za 3 minúty', 'in 3 minutes');
151 assert.equal(moment().add({m: 10}).fromNow(), 'za 10 minút', 'in 10 minutes');
152 assert.equal(moment().add({h: 1}).fromNow(), 'za hodinu', 'in an hour');
153 assert.equal(moment().add({h: 3}).fromNow(), 'za 3 hodiny', 'in 3 hours');
154 assert.equal(moment().add({h: 10}).fromNow(), 'za 10 hodín', 'in 10 hours');
155 assert.equal(moment().add({d: 1}).fromNow(), 'za deň', 'in a day');
156 assert.equal(moment().add({d: 3}).fromNow(), 'za 3 dni', 'in 3 days');
157 assert.equal(moment().add({d: 10}).fromNow(), 'za 10 dní', 'in 10 days');
158 assert.equal(moment().add({M: 1}).fromNow(), 'za mesiac', 'in a month');
159 assert.equal(moment().add({M: 3}).fromNow(), 'za 3 mesiace', 'in 3 months');
160 assert.equal(moment().add({M: 10}).fromNow(), 'za 10 mesiacov', 'in 10 months');
161 assert.equal(moment().add({y: 1}).fromNow(), 'za rok', 'in a year');
162 assert.equal(moment().add({y: 3}).fromNow(), 'za 3 roky', 'in 3 years');
163 assert.equal(moment().add({y: 10}).fromNow(), 'za 10 rokov', 'in 10 years');
164 });
165
166 test('fromNow (past)', function (assert) {
167 assert.equal(moment().subtract({s: 30}).fromNow(), 'pred pár sekundami', 'a few seconds ago');
168 assert.equal(moment().subtract({m: 1}).fromNow(), 'pred minútou', 'a minute ago');
169 assert.equal(moment().subtract({m: 3}).fromNow(), 'pred 3 minútami', '3 minutes ago');
170 assert.equal(moment().subtract({m: 10}).fromNow(), 'pred 10 minútami', '10 minutes ago');
171 assert.equal(moment().subtract({h: 1}).fromNow(), 'pred hodinou', 'an hour ago');
172 assert.equal(moment().subtract({h: 3}).fromNow(), 'pred 3 hodinami', '3 hours ago');
173 assert.equal(moment().subtract({h: 10}).fromNow(), 'pred 10 hodinami', '10 hours ago');
174 assert.equal(moment().subtract({d: 1}).fromNow(), 'pred dňom', 'a day ago');
175 assert.equal(moment().subtract({d: 3}).fromNow(), 'pred 3 dňami', '3 days ago');
176 assert.equal(moment().subtract({d: 10}).fromNow(), 'pred 10 dňami', '10 days ago');
177 assert.equal(moment().subtract({M: 1}).fromNow(), 'pred mesiacom', 'a month ago');
178 assert.equal(moment().subtract({M: 3}).fromNow(), 'pred 3 mesiacmi', '3 months ago');
179 assert.equal(moment().subtract({M: 10}).fromNow(), 'pred 10 mesiacmi', '10 months ago');
180 assert.equal(moment().subtract({y: 1}).fromNow(), 'pred rokom', 'a year ago');
181 assert.equal(moment().subtract({y: 3}).fromNow(), 'pred 3 rokmi', '3 years ago');
182 assert.equal(moment().subtract({y: 10}).fromNow(), 'pred 10 rokmi', '10 years ago');
183 });
184
185 test('calendar day', function (assert) {
186 var a = moment().hours(2).minutes(0).seconds(0);
187
188 assert.equal(moment(a).calendar(), 'dnes o 2:00', 'today at the same time');
189 assert.equal(moment(a).add({m: 25}).calendar(), 'dnes o 2:25', 'Now plus 25 min');
190 assert.equal(moment(a).add({h: 1}).calendar(), 'dnes o 3:00', 'Now plus 1 hour');
191 assert.equal(moment(a).add({d: 1}).calendar(), 'zajtra o 2:00', 'tomorrow at the same time');
192 assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes o 1:00', 'Now minus 1 hour');
193 assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera o 2:00', 'yesterday at the same time');
194 });
195
196 test('calendar next week', function (assert) {
197 var i, m, nextDay;
198 for (i = 2; i < 7; i++) {
199 m = moment().add({d: i});
200 nextDay = '';
201 switch (m.day()) {
202 case 0:
203 nextDay = 'v nedeľu';
204 break;
205 case 1:
206 nextDay = 'v pondelok';
207 break;
208 case 2:
209 nextDay = 'v utorok';
210 break;
211 case 3:
212 nextDay = 'v stredu';
213 break;
214 case 4:
215 nextDay = 'vo štvrtok';
216 break;
217 case 5:
218 nextDay = 'v piatok';
219 break;
220 case 6:
221 nextDay = 'v sobotu';
222 break;
223 }
224 assert.equal(m.calendar(), m.format('[' + nextDay + '] [o] LT'), 'Today + ' + i + ' days current time');
225 m.hours(0).minutes(0).seconds(0).milliseconds(0);
226 assert.equal(m.calendar(), m.format('[' + nextDay + '] [o] LT'), 'Today + ' + i + ' days beginning of day');
227 m.hours(23).minutes(59).seconds(59).milliseconds(999);
228 assert.equal(m.calendar(), m.format('[' + nextDay + '] [o] LT'), 'Today + ' + i + ' days end of day');
229 }
230 });
231
232 test('calendar last week', function (assert) {
233 var i, m, lastDay;
234 for (i = 2; i < 7; i++) {
235 m = moment().subtract({d: i});
236 lastDay = '';
237 switch (m.day()) {
238 case 0:
239 lastDay = 'minulú nedeľu';
240 break;
241 case 1:
242 lastDay = 'minulý pondelok';
243 break;
244 case 2:
245 lastDay = 'minulý utorok';
246 break;
247 case 3:
248 lastDay = 'minulú stredu';
249 break;
250 case 4:
251 lastDay = 'minulý štvrtok';
252 break;
253 case 5:
254 lastDay = 'minulý piatok';
255 break;
256 case 6:
257 lastDay = 'minulú sobotu';
258 break;
259 }
260 assert.equal(m.calendar(), m.format('[' + lastDay + '] [o] LT'), 'Today - ' + i + ' days current time');
261 m.hours(0).minutes(0).seconds(0).milliseconds(0);
262 assert.equal(m.calendar(), m.format('[' + lastDay + '] [o] LT'), 'Today - ' + i + ' days beginning of day');
263 m.hours(23).minutes(59).seconds(59).milliseconds(999);
264 assert.equal(m.calendar(), m.format('[' + lastDay + '] [o] LT'), 'Today - ' + i + ' days end of day');
265 }
266 });
267
268 test('calendar all else', function (assert) {
269 var weeksAgo = moment().subtract({w: 1}),
270 weeksFromNow = moment().add({w: 1});
271
272 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
273 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
274
275 weeksAgo = moment().subtract({w: 2});
276 weeksFromNow = moment().add({w: 2});
277
278 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
279 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
280 });
281
282 test('humanize duration', function (assert) {
283 assert.equal(moment.duration(1, 'minutes').humanize(), 'minúta', 'a minute (future)');
284 assert.equal(moment.duration(1, 'minutes').humanize(true), 'za minútu', 'in a minute');
285 assert.equal(moment.duration(-1, 'minutes').humanize(), 'minúta', 'a minute (past)');
286 assert.equal(moment.duration(-1, 'minutes').humanize(true), 'pred minútou', 'a minute ago');
287 });
288
289 test('weeks year starting sunday', function (assert) {
290 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
291 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
292 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
293 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
294 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
295 });
296
297 test('weeks year starting monday', function (assert) {
298 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
299 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
300 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
301 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
302 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
303 });
304
305 test('weeks year starting tuesday', function (assert) {
306 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
307 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
308 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
309 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
310 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
311 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
312 });
313
314 test('weeks year starting wednesday', function (assert) {
315 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
316 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
317 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
318 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
319 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
320 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
321 });
322
323 test('weeks year starting thursday', function (assert) {
324 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
325 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
326 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
327 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
328 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
329 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
330 });
331
332 test('weeks year starting friday', function (assert) {
333 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
334 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
335 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
336 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
337 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
338 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
339 });
340
341 test('weeks year starting saturday', function (assert) {
342 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
343 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
344 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
345 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
346 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
347 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
348 });
349
350 test('weeks year starting sunday formatted', function (assert) {
351 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
352 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
353 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
354 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
355 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
356 });
357
358 test('lenient ordinal parsing', function (assert) {
359 var i, ordinalStr, testMoment;
360 for (i = 1; i <= 31; ++i) {
361 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
362 testMoment = moment(ordinalStr, 'YYYY MM Do');
363 assert.equal(testMoment.year(), 2014,
364 'lenient ordinal parsing ' + i + ' year check');
365 assert.equal(testMoment.month(), 0,
366 'lenient ordinal parsing ' + i + ' month check');
367 assert.equal(testMoment.date(), i,
368 'lenient ordinal parsing ' + i + ' date check');
369 }
370 });
371
372 test('lenient ordinal parsing of number', function (assert) {
373 var i, testMoment;
374 for (i = 1; i <= 31; ++i) {
375 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
376 assert.equal(testMoment.year(), 2014,
377 'lenient ordinal parsing of number ' + i + ' year check');
378 assert.equal(testMoment.month(), 0,
379 'lenient ordinal parsing of number ' + i + ' month check');
380 assert.equal(testMoment.date(), i,
381 'lenient ordinal parsing of number ' + i + ' date check');
382 }
383 });
384
385 test('strict ordinal parsing', function (assert) {
386 var i, ordinalStr, testMoment;
387 for (i = 1; i <= 31; ++i) {
388 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
389 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
390 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
391 }
392 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('sl');
3
4 test('parse', function (assert) {
5 var tests = 'januar jan._februar feb._marec mar._april apr._maj maj_junij jun._julij jul._avgust avg._september sep._oktober okt._november nov._december dec.'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedelja, 14. februar 2010, 3:25:50 pm'],
25 ['ddd, hA', 'ned., 3PM'],
26 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. nedelja ned. ne'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '7 7. 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14. 02. 2010'],
40 ['LL', '14. februar 2010'],
41 ['LLL', '14. februar 2010 15:25'],
42 ['LLLL', 'nedelja, 14. februar 2010 15:25'],
43 ['l', '14. 2. 2010'],
44 ['ll', '14. feb. 2010'],
45 ['lll', '14. feb. 2010 15:25'],
46 ['llll', 'ned., 14. feb. 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'januar jan._februar feb._marec mar._april apr._maj maj._junij jun._julij jul._avgust avg._september sep._oktober okt._november nov._december dec.'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'nedelja ned. ne_ponedeljek pon. po_torek tor. to_sreda sre. sr_četrtek čet. če_petek pet. pe_sobota sob. so'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nekaj sekund', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ena minuta', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ena minuta', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuti', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minut', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ena ura', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ena ura', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 uri', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ur', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ur', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dan', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dan', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dni', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dan', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dni', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dni', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en mesec', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en mesec', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en mesec', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meseca', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meseca', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesece', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en mesec', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesecev', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'eno leto', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 leti', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eno leto', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 let', '5 years = 5 years');
136
137 assert.equal(start.from(moment([2007, 1, 28]).add({m: 1}), true), 'ena minuta', 'a minute');
138 assert.equal(start.from(moment([2007, 1, 28]).add({m: 2}), true), '2 minuti', '2 minutes');
139 assert.equal(start.from(moment([2007, 1, 28]).add({m: 3}), true), '3 minute', '3 minutes');
140 assert.equal(start.from(moment([2007, 1, 28]).add({m: 4}), true), '4 minute', '4 minutes');
141 assert.equal(start.from(moment([2007, 1, 28]).add({m: 5}), true), '5 minut', '5 minutes');
142
143 assert.equal(start.from(moment([2007, 1, 28]).add({h: 1}), true), 'ena ura', 'an hour');
144 assert.equal(start.from(moment([2007, 1, 28]).add({h: 2}), true), '2 uri', '2 hours');
145 assert.equal(start.from(moment([2007, 1, 28]).add({h: 3}), true), '3 ure', '3 hours');
146 assert.equal(start.from(moment([2007, 1, 28]).add({h: 4}), true), '4 ure', '4 hours');
147 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ur', '5 hours');
148
149 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dan', 'a day');
150 assert.equal(start.from(moment([2007, 1, 28]).add({d: 2}), true), '2 dni', '2 days');
151 assert.equal(start.from(moment([2007, 1, 28]).add({d: 3}), true), '3 dni', '3 days');
152 assert.equal(start.from(moment([2007, 1, 28]).add({d: 4}), true), '4 dni', '4 days');
153 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dni', '5 days');
154
155 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en mesec', 'a month');
156 assert.equal(start.from(moment([2007, 1, 28]).add({M: 2}), true), '2 meseca', '2 months');
157 assert.equal(start.from(moment([2007, 1, 28]).add({M: 3}), true), '3 mesece', '3 months');
158 assert.equal(start.from(moment([2007, 1, 28]).add({M: 4}), true), '4 mesece', '4 months');
159 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesecev', '5 months');
160
161 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'eno leto', 'a year');
162 assert.equal(start.from(moment([2007, 1, 28]).add({y: 2}), true), '2 leti', '2 years');
163 assert.equal(start.from(moment([2007, 1, 28]).add({y: 3}), true), '3 leta', '3 years');
164 assert.equal(start.from(moment([2007, 1, 28]).add({y: 4}), true), '4 leta', '4 years');
165 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 let', '5 years');
166 });
167
168 test('suffix', function (assert) {
169 assert.equal(moment(30000).from(0), 'čez nekaj sekund', 'prefix');
170 assert.equal(moment(0).from(30000), 'pred nekaj sekundami', 'suffix');
171 });
172
173 test('now from now', function (assert) {
174 assert.equal(moment().fromNow(), 'pred nekaj sekundami', 'now from now should display as in the past');
175 });
176
177 test('fromNow (future)', function (assert) {
178 assert.equal(moment().add({s: 30}).fromNow(), 'čez nekaj sekund', 'in a few seconds');
179 assert.equal(moment().add({m: 1}).fromNow(), 'čez eno minuto', 'in a minute');
180 assert.equal(moment().add({m: 2}).fromNow(), 'čez 2 minuti', 'in 2 minutes');
181 assert.equal(moment().add({m: 3}).fromNow(), 'čez 3 minute', 'in 3 minutes');
182 assert.equal(moment().add({m: 4}).fromNow(), 'čez 4 minute', 'in 4 minutes');
183 assert.equal(moment().add({m: 5}).fromNow(), 'čez 5 minut', 'in 5 minutes');
184
185 assert.equal(moment().add({h: 1}).fromNow(), 'čez eno uro', 'in an hour');
186 assert.equal(moment().add({h: 2}).fromNow(), 'čez 2 uri', 'in 2 hours');
187 assert.equal(moment().add({h: 3}).fromNow(), 'čez 3 ure', 'in 3 hours');
188 assert.equal(moment().add({h: 4}).fromNow(), 'čez 4 ure', 'in 4 hours');
189 assert.equal(moment().add({h: 5}).fromNow(), 'čez 5 ur', 'in 5 hours');
190
191 assert.equal(moment().add({d: 1}).fromNow(), 'čez en dan', 'in a day');
192 assert.equal(moment().add({d: 2}).fromNow(), 'čez 2 dni', 'in 2 days');
193 assert.equal(moment().add({d: 3}).fromNow(), 'čez 3 dni', 'in 3 days');
194 assert.equal(moment().add({d: 4}).fromNow(), 'čez 4 dni', 'in 4 days');
195 assert.equal(moment().add({d: 5}).fromNow(), 'čez 5 dni', 'in 5 days');
196
197 assert.equal(moment().add({M: 1}).fromNow(), 'čez en mesec', 'in a month');
198 assert.equal(moment().add({M: 2}).fromNow(), 'čez 2 meseca', 'in 2 months');
199 assert.equal(moment().add({M: 3}).fromNow(), 'čez 3 mesece', 'in 3 months');
200 assert.equal(moment().add({M: 4}).fromNow(), 'čez 4 mesece', 'in 4 months');
201 assert.equal(moment().add({M: 5}).fromNow(), 'čez 5 mesecev', 'in 5 months');
202
203 assert.equal(moment().add({y: 1}).fromNow(), 'čez eno leto', 'in a year');
204 assert.equal(moment().add({y: 2}).fromNow(), 'čez 2 leti', 'in 2 years');
205 assert.equal(moment().add({y: 3}).fromNow(), 'čez 3 leta', 'in 3 years');
206 assert.equal(moment().add({y: 4}).fromNow(), 'čez 4 leta', 'in 4 years');
207 assert.equal(moment().add({y: 5}).fromNow(), 'čez 5 let', 'in 5 years');
208
209 assert.equal(moment().subtract({s: 30}).fromNow(), 'pred nekaj sekundami', 'a few seconds ago');
210
211 assert.equal(moment().subtract({m: 1}).fromNow(), 'pred eno minuto', 'a minute ago');
212 assert.equal(moment().subtract({m: 2}).fromNow(), 'pred 2 minutama', '2 minutes ago');
213 assert.equal(moment().subtract({m: 3}).fromNow(), 'pred 3 minutami', '3 minutes ago');
214 assert.equal(moment().subtract({m: 4}).fromNow(), 'pred 4 minutami', '4 minutes ago');
215 assert.equal(moment().subtract({m: 5}).fromNow(), 'pred 5 minutami', '5 minutes ago');
216
217 assert.equal(moment().subtract({h: 1}).fromNow(), 'pred eno uro', 'an hour ago');
218 assert.equal(moment().subtract({h: 2}).fromNow(), 'pred 2 urama', '2 hours ago');
219 assert.equal(moment().subtract({h: 3}).fromNow(), 'pred 3 urami', '3 hours ago');
220 assert.equal(moment().subtract({h: 4}).fromNow(), 'pred 4 urami', '4 hours ago');
221 assert.equal(moment().subtract({h: 5}).fromNow(), 'pred 5 urami', '5 hours ago');
222
223 assert.equal(moment().subtract({d: 1}).fromNow(), 'pred enim dnem', 'a day ago');
224 assert.equal(moment().subtract({d: 2}).fromNow(), 'pred 2 dnevoma', '2 days ago');
225 assert.equal(moment().subtract({d: 3}).fromNow(), 'pred 3 dnevi', '3 days ago');
226 assert.equal(moment().subtract({d: 4}).fromNow(), 'pred 4 dnevi', '4 days ago');
227 assert.equal(moment().subtract({d: 5}).fromNow(), 'pred 5 dnevi', '5 days ago');
228
229 assert.equal(moment().subtract({M: 1}).fromNow(), 'pred enim mesecem', 'a month ago');
230 assert.equal(moment().subtract({M: 2}).fromNow(), 'pred 2 mesecema', '2 months ago');
231 assert.equal(moment().subtract({M: 3}).fromNow(), 'pred 3 meseci', '3 months ago');
232 assert.equal(moment().subtract({M: 4}).fromNow(), 'pred 4 meseci', '4 months ago');
233 assert.equal(moment().subtract({M: 5}).fromNow(), 'pred 5 meseci', '5 months ago');
234
235 assert.equal(moment().subtract({y: 1}).fromNow(), 'pred enim letom', 'a year ago');
236 assert.equal(moment().subtract({y: 2}).fromNow(), 'pred 2 letoma', '2 years ago');
237 assert.equal(moment().subtract({y: 3}).fromNow(), 'pred 3 leti', '3 years ago');
238 assert.equal(moment().subtract({y: 4}).fromNow(), 'pred 4 leti', '4 years ago');
239 assert.equal(moment().subtract({y: 5}).fromNow(), 'pred 5 leti', '5 years ago');
240 });
241
242 test('calendar day', function (assert) {
243 var a = moment().hours(2).minutes(0).seconds(0);
244
245 assert.equal(moment(a).calendar(), 'danes ob 2:00', 'today at the same time');
246 assert.equal(moment(a).add({m: 25}).calendar(), 'danes ob 2:25', 'Now plus 25 min');
247 assert.equal(moment(a).add({h: 1}).calendar(), 'danes ob 3:00', 'Now plus 1 hour');
248 assert.equal(moment(a).add({d: 1}).calendar(), 'jutri ob 2:00', 'tomorrow at the same time');
249 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danes ob 1:00', 'Now minus 1 hour');
250 assert.equal(moment(a).subtract({d: 1}).calendar(), 'včeraj ob 2:00', 'yesterday at the same time');
251 });
252
253 test('calendar next week', function (assert) {
254 var i, m;
255
256 function makeFormat(d) {
257 switch (d.day()) {
258 case 0:
259 return '[v] [nedeljo] [ob] LT';
260 case 3:
261 return '[v] [sredo] [ob] LT';
262 case 6:
263 return '[v] [soboto] [ob] LT';
264 case 1:
265 case 2:
266 case 4:
267 case 5:
268 return '[v] dddd [ob] LT';
269 }
270 }
271
272 for (i = 2; i < 7; i++) {
273 m = moment().add({d: i});
274 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
275 m.hours(0).minutes(0).seconds(0).milliseconds(0);
276 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
277 m.hours(23).minutes(59).seconds(59).milliseconds(999);
278 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
279 }
280 });
281
282 test('calendar last week', function (assert) {
283 var i, m;
284
285 function makeFormat(d) {
286 switch (d.day()) {
287 case 0:
288 return '[prejšnjo] [nedeljo] [ob] LT';
289 case 3:
290 return '[prejšnjo] [sredo] [ob] LT';
291 case 6:
292 return '[prejšnjo] [soboto] [ob] LT';
293 case 1:
294 case 2:
295 case 4:
296 case 5:
297 return '[prejšnji] dddd [ob] LT';
298 }
299 }
300
301 for (i = 2; i < 7; i++) {
302 m = moment().subtract({d: i});
303 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
304 m.hours(0).minutes(0).seconds(0).milliseconds(0);
305 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
306 m.hours(23).minutes(59).seconds(59).milliseconds(999);
307 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
308 }
309 });
310
311 test('calendar all else', function (assert) {
312 var weeksAgo = moment().subtract({w: 1}),
313 weeksFromNow = moment().add({w: 1});
314
315 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
316 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
317
318 weeksAgo = moment().subtract({w: 2});
319 weeksFromNow = moment().add({w: 2});
320
321 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
322 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
323 });
324
325 test('weeks year starting sunday', function (assert) {
326 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
327 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
328 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
329 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
330 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
331 });
332
333 test('weeks year starting monday', function (assert) {
334 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
335 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
336 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
337 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
338 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
339 });
340
341 test('weeks year starting tuesday', function (assert) {
342 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
343 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
344 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
345 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
346 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
347 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
348 });
349
350 test('weeks year starting wednesday', function (assert) {
351 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
352 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
353 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
354 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
355 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
356 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
357 });
358
359 test('weeks year starting thursday', function (assert) {
360 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
361 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
362 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
363 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
364 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
365 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
366 });
367
368 test('weeks year starting friday', function (assert) {
369 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
370 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
371 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
372 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
373 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
374 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
375 });
376
377 test('weeks year starting saturday', function (assert) {
378 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
379 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
380 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
381 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
382 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
383 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
384 });
385
386 test('weeks year starting sunday formatted', function (assert) {
387 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
388 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
389 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
390 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
391 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
392 });
393
394 test('lenient ordinal parsing', function (assert) {
395 var i, ordinalStr, testMoment;
396 for (i = 1; i <= 31; ++i) {
397 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
398 testMoment = moment(ordinalStr, 'YYYY MM Do');
399 assert.equal(testMoment.year(), 2014,
400 'lenient ordinal parsing ' + i + ' year check');
401 assert.equal(testMoment.month(), 0,
402 'lenient ordinal parsing ' + i + ' month check');
403 assert.equal(testMoment.date(), i,
404 'lenient ordinal parsing ' + i + ' date check');
405 }
406 });
407
408 test('lenient ordinal parsing of number', function (assert) {
409 var i, testMoment;
410 for (i = 1; i <= 31; ++i) {
411 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
412 assert.equal(testMoment.year(), 2014,
413 'lenient ordinal parsing of number ' + i + ' year check');
414 assert.equal(testMoment.month(), 0,
415 'lenient ordinal parsing of number ' + i + ' month check');
416 assert.equal(testMoment.date(), i,
417 'lenient ordinal parsing of number ' + i + ' date check');
418 }
419 });
420
421 test('strict ordinal parsing', function (assert) {
422 var i, ordinalStr, testMoment;
423 for (i = 1; i <= 31; ++i) {
424 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
425 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
426 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
427 }
428 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('sq');
3
4 test('parse', function (assert) {
5 var i,
6 tests = 'Janar Jan_Shkurt Shk_Mars Mar_Prill Pri_Maj Maj_Qershor Qer_Korrik Kor_Gusht Gus_Shtator Sht_Tetor Tet_Nëntor Nën_Dhjetor Dhj'.split('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(' ');
14 equalTest(tests[i][0], 'MMM', i);
15 equalTest(tests[i][1], 'MMM', i);
16 equalTest(tests[i][0], 'MMMM', i);
17 equalTest(tests[i][1], 'MMMM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, HH:mm:ss', 'E Diel, Shkurt 14. 2010, 15:25:50'],
28 ['ddd, HH', 'Die, 15'],
29 ['M Mo MM MMMM MMM', '2 2. 02 Shkurt Shk'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 14. 14'],
32 ['d do dddd ddd dd', '0 0. E Diel Die D'],
33 ['DDD DDDo DDDD', '45 45. 045'],
34 ['w wo ww', '6 6. 06'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'MD MD'],
40 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
41 ['LTS', '15:25:50'],
42 ['L', '14/02/2010'],
43 ['LL', '14 Shkurt 2010'],
44 ['LLL', '14 Shkurt 2010 15:25'],
45 ['LLLL', 'E Diel, 14 Shkurt 2010 15:25'],
46 ['l', '14/2/2010'],
47 ['ll', '14 Shk 2010'],
48 ['lll', '14 Shk 2010 15:25'],
49 ['llll', 'Die, 14 Shk 2010 15:25']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('meridiem', function (assert) {
60 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), 'PD', 'before dawn');
61 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), 'MD', 'noon');
62 });
63
64 test('format ordinal', function (assert) {
65 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
66 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
67 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
68 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
69 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
70 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
71 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
72 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
73 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
74 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
75
76 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
77 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
78 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
79 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
80 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
81 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
82 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
83 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
84 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
85 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
86
87 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
88 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
89 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
90 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
91 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
92 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
93 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
94 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
95 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
96 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
97
98 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
99 });
100
101 test('format month', function (assert) {
102 var i,
103 expected = 'Janar Jan_Shkurt Shk_Mars Mar_Prill Pri_Maj Maj_Qershor Qer_Korrik Kor_Gusht Gus_Shtator Sht_Tetor Tet_Nëntor Nën_Dhjetor Dhj'.split('_');
104
105 for (i = 0; i < expected.length; i++) {
106 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
107 }
108 });
109
110 test('format week', function (assert) {
111 var i,
112 expected = 'E Diel Die D_E Hënë Hën H_E Martë Mar Ma_E Mërkurë Mër Më_E Enjte Enj E_E Premte Pre P_E Shtunë Sht Sh'.split('_');
113
114 for (i = 0; i < expected.length; i++) {
115 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
116 }
117 });
118
119 test('from', function (assert) {
120 var start = moment([2007, 1, 28]);
121
122 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'disa sekonda', '44 seconds = a few seconds');
123 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'një minutë', '45 seconds = a minute');
124 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'një minutë', '89 seconds = a minute');
125 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuta', '90 seconds = 2 minutes');
126 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
127 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'një orë', '45 minutes = an hour');
128 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'një orë', '89 minutes = an hour');
129 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 orë', '90 minutes = 2 hours');
130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 orë', '5 hours = 5 hours');
131 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 orë', '21 hours = 21 hours');
132 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'një ditë', '22 hours = a day');
133 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'një ditë', '35 hours = a day');
134 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ditë', '36 hours = 2 days');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'një ditë', '1 day = a day');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ditë', '5 days = 5 days');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ditë', '25 days = 25 days');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'një muaj', '26 days = a month');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'një muaj', '30 days = a month');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'një muaj', '43 days = a month');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 muaj', '46 days = 2 months');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 muaj', '75 days = 2 months');
143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 muaj', '76 days = 3 months');
144 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'një muaj', '1 month = a month');
145 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 muaj', '5 months = 5 months');
146 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'një vit', '345 days = a year');
147 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 vite', '548 days = 2 years');
148 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'një vit', '1 year = a year');
149 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 vite', '5 years = 5 years');
150 });
151
152 test('suffix', function (assert) {
153 assert.equal(moment(30000).from(0), 'në disa sekonda', 'prefix');
154 assert.equal(moment(0).from(30000), 'disa sekonda më parë', 'suffix');
155 });
156
157 test('now from now', function (assert) {
158 assert.equal(moment().fromNow(), 'disa sekonda më parë', 'now from now should display as in the past');
159 });
160
161 test('fromNow', function (assert) {
162 assert.equal(moment().add({s: 30}).fromNow(), 'në disa sekonda', 'in a few seconds');
163 assert.equal(moment().add({d: 5}).fromNow(), 'në 5 ditë', 'in 5 days');
164 });
165
166 test('calendar day', function (assert) {
167 var a = moment().hours(2).minutes(0).seconds(0);
168
169 assert.equal(moment(a).calendar(), 'Sot në 02:00', 'today at the same time');
170 assert.equal(moment(a).add({m: 25}).calendar(), 'Sot në 02:25', 'Now plus 25 min');
171 assert.equal(moment(a).add({h: 1}).calendar(), 'Sot në 03:00', 'Now plus 1 hour');
172 assert.equal(moment(a).add({d: 1}).calendar(), 'Nesër në 02:00', 'tomorrow at the same time');
173 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Sot në 01:00', 'Now minus 1 hour');
174 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dje në 02:00', 'yesterday at the same time');
175 });
176
177 test('calendar next week', function (assert) {
178 var i, m;
179
180 for (i = 2; i < 7; i++) {
181 m = moment().add({d: i});
182 assert.equal(m.calendar(), m.format('dddd [në] LT'), 'Today + ' + i + ' days current time');
183 m.hours(0).minutes(0).seconds(0).milliseconds(0);
184 assert.equal(m.calendar(), m.format('dddd [në] LT'), 'Today + ' + i + ' days beginning of day');
185 m.hours(23).minutes(59).seconds(59).milliseconds(999);
186 assert.equal(m.calendar(), m.format('dddd [në] LT'), 'Today + ' + i + ' days end of day');
187 }
188 });
189
190 test('calendar last week', function (assert) {
191 var i, m;
192
193 for (i = 2; i < 7; i++) {
194 m = moment().subtract({d: i});
195 assert.equal(m.calendar(), m.format('dddd [e kaluar në] LT'), 'Today - ' + i + ' days current time');
196 m.hours(0).minutes(0).seconds(0).milliseconds(0);
197 assert.equal(m.calendar(), m.format('dddd [e kaluar në] LT'), 'Today - ' + i + ' days beginning of day');
198 m.hours(23).minutes(59).seconds(59).milliseconds(999);
199 assert.equal(m.calendar(), m.format('dddd [e kaluar në] LT'), 'Today - ' + i + ' days end of day');
200 }
201 });
202
203 test('calendar all else', function (assert) {
204 var weeksAgo = moment().subtract({w: 1}),
205 weeksFromNow = moment().add({w: 1});
206
207 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
208 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
209
210 weeksAgo = moment().subtract({w: 2});
211 weeksFromNow = moment().add({w: 2});
212
213 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
214 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
215 });
216
217 test('weeks year starting sunday', function (assert) {
218 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
219 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
220 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
221 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
222 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
223 });
224
225 test('weeks year starting monday', function (assert) {
226 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
227 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
228 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
229 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
230 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
231 });
232
233 test('weeks year starting tuesday', function (assert) {
234 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
235 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
236 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
237 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
238 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
239 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
240 });
241
242 test('weeks year starting wednesday', function (assert) {
243 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
244 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
245 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
246 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
247 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
248 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
249 });
250
251 test('weeks year starting thursday', function (assert) {
252 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
253 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
254 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
255 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
256 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
257 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
258 });
259
260 test('weeks year starting friday', function (assert) {
261 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
262 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
263 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
264 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
265 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
266 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
267 });
268
269 test('weeks year starting saturday', function (assert) {
270 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
271 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
272 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
273 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
274 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
275 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
276 });
277
278 test('weeks year starting sunday formatted', function (assert) {
279 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
280 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
281 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
282 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
283 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
284 });
285
286 test('lenient ordinal parsing', function (assert) {
287 var i, ordinalStr, testMoment;
288 for (i = 1; i <= 31; ++i) {
289 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
290 testMoment = moment(ordinalStr, 'YYYY MM Do');
291 assert.equal(testMoment.year(), 2014,
292 'lenient ordinal parsing ' + i + ' year check');
293 assert.equal(testMoment.month(), 0,
294 'lenient ordinal parsing ' + i + ' month check');
295 assert.equal(testMoment.date(), i,
296 'lenient ordinal parsing ' + i + ' date check');
297 }
298 });
299
300 test('lenient ordinal parsing of number', function (assert) {
301 var i, testMoment;
302 for (i = 1; i <= 31; ++i) {
303 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
304 assert.equal(testMoment.year(), 2014,
305 'lenient ordinal parsing of number ' + i + ' year check');
306 assert.equal(testMoment.month(), 0,
307 'lenient ordinal parsing of number ' + i + ' month check');
308 assert.equal(testMoment.date(), i,
309 'lenient ordinal parsing of number ' + i + ' date check');
310 }
311 });
312
313 test('strict ordinal parsing', function (assert) {
314 var i, ordinalStr, testMoment;
315 for (i = 1; i <= 31; ++i) {
316 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
317 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
318 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
319 }
320 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('sr-cyrl');
3
4 test('parse', function (assert) {
5 var tests = 'јануар јан._фебруар феб._март мар._април апр._мај мај_јун јун_јул јул_август авг._септембар сеп._октобар окт._новембар нов._децембар дец.'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, Do MMMM YYYY, h:mm:ss a', 'недеља, 14. фебруар 2010, 3:25:50 pm'],
26 ['ddd, hA', 'нед., 3PM'],
27 ['M Mo MM MMMM MMM', '2 2. 02 фебруар феб.'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14. 14'],
30 ['d do dddd ddd dd', '0 0. недеља нед. не'],
31 ['DDD DDDo DDDD', '45 45. 045'],
32 ['w wo ww', '7 7. 07'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
39 ['LTS', '15:25:50'],
40 ['L', '14. 02. 2010'],
41 ['LL', '14. фебруар 2010'],
42 ['LLL', '14. фебруар 2010 15:25'],
43 ['LLLL', 'недеља, 14. фебруар 2010 15:25'],
44 ['l', '14. 2. 2010'],
45 ['ll', '14. феб. 2010'],
46 ['lll', '14. феб. 2010 15:25'],
47 ['llll', 'нед., 14. феб. 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'јануар јан._фебруар феб._март мар._април апр._мај мај_јун јун_јул јул_август авг._септембар сеп._октобар окт._новембар нов._децембар дец.'.split('_'),
95 i;
96 for (i = 0; i < expected.length; i++) {
97 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
98 }
99 });
100
101 test('format week', function (assert) {
102 var expected = 'недеља нед. не_понедељак пон. по_уторак уто. ут_среда сре. ср_четвртак чет. че_петак пет. пе_субота суб. су'.split('_'),
103 i;
104 for (i = 0; i < expected.length; i++) {
105 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
106 }
107 });
108
109 test('from', function (assert) {
110 var start = moment([2007, 1, 28]);
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'неколико секунди', '44 seconds = a few seconds');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'један минут', '45 seconds = a minute');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'један минут', '89 seconds = a minute');
114 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 минуте', '90 seconds = 2 minutes');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 минута', '44 minutes = 44 minutes');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'један сат', '45 minutes = an hour');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'један сат', '89 minutes = an hour');
118 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 сата', '90 minutes = 2 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 сати', '5 hours = 5 hours');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 сати', '21 hours = 21 hours');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'дан', '22 hours = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'дан', '35 hours = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дана', '36 hours = 2 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'дан', '1 day = a day');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 дана', '5 days = 5 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 дана', '25 days = 25 days');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'месец', '26 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'месец', '30 days = a month');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'месец', '43 days = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 месеца', '46 days = 2 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 месеца', '75 days = 2 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 месеца', '76 days = 3 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'месец', '1 month = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 месеци', '5 months = 5 months');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'годину', '345 days = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 године', '548 days = 2 years');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'годину', '1 year = a year');
138 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 година', '5 years = 5 years');
139 });
140
141 test('suffix', function (assert) {
142 assert.equal(moment(30000).from(0), 'за неколико секунди', 'prefix');
143 assert.equal(moment(0).from(30000), 'пре неколико секунди', 'prefix');
144 });
145
146 test('now from now', function (assert) {
147 assert.equal(moment().fromNow(), 'пре неколико секунди', 'now from now should display as in the past');
148 });
149
150 test('fromNow', function (assert) {
151 assert.equal(moment().add({s: 30}).fromNow(), 'за неколико секунди', 'in a few seconds');
152 assert.equal(moment().add({d: 5}).fromNow(), 'за 5 дана', 'in 5 days');
153 });
154
155 test('calendar day', function (assert) {
156 var a = moment().hours(2).minutes(0).seconds(0);
157
158 assert.equal(moment(a).calendar(), 'данас у 2:00', 'today at the same time');
159 assert.equal(moment(a).add({m: 25}).calendar(), 'данас у 2:25', 'Now plus 25 min');
160 assert.equal(moment(a).add({h: 1}).calendar(), 'данас у 3:00', 'Now plus 1 hour');
161 assert.equal(moment(a).add({d: 1}).calendar(), 'сутра у 2:00', 'tomorrow at the same time');
162 assert.equal(moment(a).subtract({h: 1}).calendar(), 'данас у 1:00', 'Now minus 1 hour');
163 assert.equal(moment(a).subtract({d: 1}).calendar(), 'јуче у 2:00', 'yesterday at the same time');
164 });
165
166 test('calendar next week', function (assert) {
167 var i, m;
168
169 function makeFormat(d) {
170 switch (d.day()) {
171 case 0:
172 return '[у] [недељу] [у] LT';
173 case 3:
174 return '[у] [среду] [у] LT';
175 case 6:
176 return '[у] [суботу] [у] LT';
177 case 1:
178 case 2:
179 case 4:
180 case 5:
181 return '[у] dddd [у] LT';
182 }
183 }
184
185 for (i = 2; i < 7; i++) {
186 m = moment().add({d: i});
187 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
188 m.hours(0).minutes(0).seconds(0).milliseconds(0);
189 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
190 m.hours(23).minutes(59).seconds(59).milliseconds(999);
191 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
192 }
193 });
194
195 test('calendar last week', function (assert) {
196 var i, m;
197
198 function makeFormat(d) {
199 var lastWeekDay = [
200 '[прошле] [недеље] [у] LT',
201 '[прошлог] [понедељка] [у] LT',
202 '[прошлог] [уторка] [у] LT',
203 '[прошле] [среде] [у] LT',
204 '[прошлог] [четвртка] [у] LT',
205 '[прошлог] [петка] [у] LT',
206 '[прошле] [суботе] [у] LT'
207 ];
208
209 return lastWeekDay[d.day()];
210 }
211
212 for (i = 2; i < 7; i++) {
213 m = moment().subtract({d: i});
214 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
215 m.hours(0).minutes(0).seconds(0).milliseconds(0);
216 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
217 m.hours(23).minutes(59).seconds(59).milliseconds(999);
218 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
219 }
220 });
221
222 test('calendar all else', function (assert) {
223 var weeksAgo = moment().subtract({w: 1}),
224 weeksFromNow = moment().add({w: 1});
225
226 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
227 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
228
229 weeksAgo = moment().subtract({w: 2});
230 weeksFromNow = moment().add({w: 2});
231
232 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
233 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
234 });
235
236 test('weeks year starting sunday', function (assert) {
237 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
238 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
239 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
240 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
241 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
242 });
243
244 test('weeks year starting monday', function (assert) {
245 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
246 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
247 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
248 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
249 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
250 });
251
252 test('weeks year starting tuesday', function (assert) {
253 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
254 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
255 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
256 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
257 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
258 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
259 });
260
261 test('weeks year starting wednesday', function (assert) {
262 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
263 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
264 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
265 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
266 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
267 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
268 });
269
270 test('weeks year starting thursday', function (assert) {
271 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
272 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
273 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
274 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
275 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
276 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
277 });
278
279 test('weeks year starting friday', function (assert) {
280 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
281 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
282 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
283 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
284 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
285 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
286 });
287
288 test('weeks year starting saturday', function (assert) {
289 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
290 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
291 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
292 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
293 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
294 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
295 });
296
297 test('weeks year starting sunday formatted', function (assert) {
298 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
299 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
300 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
301 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
302 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
303 });
304
305 test('lenient ordinal parsing', function (assert) {
306 var i, ordinalStr, testMoment;
307 for (i = 1; i <= 31; ++i) {
308 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
309 testMoment = moment(ordinalStr, 'YYYY MM Do');
310 assert.equal(testMoment.year(), 2014,
311 'lenient ordinal parsing ' + i + ' year check');
312 assert.equal(testMoment.month(), 0,
313 'lenient ordinal parsing ' + i + ' month check');
314 assert.equal(testMoment.date(), i,
315 'lenient ordinal parsing ' + i + ' date check');
316 }
317 });
318
319 test('lenient ordinal parsing of number', function (assert) {
320 var i, testMoment;
321 for (i = 1; i <= 31; ++i) {
322 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
323 assert.equal(testMoment.year(), 2014,
324 'lenient ordinal parsing of number ' + i + ' year check');
325 assert.equal(testMoment.month(), 0,
326 'lenient ordinal parsing of number ' + i + ' month check');
327 assert.equal(testMoment.date(), i,
328 'lenient ordinal parsing of number ' + i + ' date check');
329 }
330 });
331
332 test('strict ordinal parsing', function (assert) {
333 var i, ordinalStr, testMoment;
334 for (i = 1; i <= 31; ++i) {
335 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
336 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
337 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
338 }
339 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('sr');
3
4 test('parse', function (assert) {
5 var tests = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedelja, 14. februar 2010, 3:25:50 pm'],
26 ['ddd, hA', 'ned., 3PM'],
27 ['M Mo MM MMMM MMM', '2 2. 02 februar feb.'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14. 14'],
30 ['d do dddd ddd dd', '0 0. nedelja ned. ne'],
31 ['DDD DDDo DDDD', '45 45. 045'],
32 ['w wo ww', '7 7. 07'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
39 ['LTS', '15:25:50'],
40 ['L', '14. 02. 2010'],
41 ['LL', '14. februar 2010'],
42 ['LLL', '14. februar 2010 15:25'],
43 ['LLLL', 'nedelja, 14. februar 2010 15:25'],
44 ['l', '14. 2. 2010'],
45 ['ll', '14. feb. 2010'],
46 ['lll', '14. feb. 2010 15:25'],
47 ['llll', 'ned., 14. feb. 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'januar jan._februar feb._mart mar._april apr._maj maj_jun jun_jul jul_avgust avg._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'),
95 i;
96 for (i = 0; i < expected.length; i++) {
97 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
98 }
99 });
100
101 test('format week', function (assert) {
102 var expected = 'nedelja ned. ne_ponedeljak pon. po_utorak uto. ut_sreda sre. sr_četvrtak čet. če_petak pet. pe_subota sub. su'.split('_'),
103 i;
104 for (i = 0; i < expected.length; i++) {
105 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
106 }
107 });
108
109 test('from', function (assert) {
110 var start = moment([2007, 1, 28]);
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'nekoliko sekundi', '44 seconds = a few seconds');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'jedan minut', '45 seconds = a minute');
113 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'jedan minut', '89 seconds = a minute');
114 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minute', '90 seconds = 2 minutes');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuta', '44 minutes = 44 minutes');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'jedan sat', '45 minutes = an hour');
117 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'jedan sat', '89 minutes = an hour');
118 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 sata', '90 minutes = 2 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 sati', '5 hours = 5 hours');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 sati', '21 hours = 21 hours');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'dan', '22 hours = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'dan', '35 hours = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dana', '36 hours = 2 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'dan', '1 day = a day');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dana', '5 days = 5 days');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dana', '25 days = 25 days');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'mesec', '26 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'mesec', '30 days = a month');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'mesec', '43 days = a month');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 meseca', '46 days = 2 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 meseca', '75 days = 2 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 meseca', '76 days = 3 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'mesec', '1 month = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 meseci', '5 months = 5 months');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'godinu', '345 days = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 godine', '548 days = 2 years');
137 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'godinu', '1 year = a year');
138 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 godina', '5 years = 5 years');
139 });
140
141 test('suffix', function (assert) {
142 assert.equal(moment(30000).from(0), 'za nekoliko sekundi', 'prefix');
143 assert.equal(moment(0).from(30000), 'pre nekoliko sekundi', 'prefix');
144 });
145
146 test('now from now', function (assert) {
147 assert.equal(moment().fromNow(), 'pre nekoliko sekundi', 'now from now should display as in the past');
148 });
149
150 test('fromNow', function (assert) {
151 assert.equal(moment().add({s: 30}).fromNow(), 'za nekoliko sekundi', 'in a few seconds');
152 assert.equal(moment().add({d: 5}).fromNow(), 'za 5 dana', 'in 5 days');
153 });
154
155 test('calendar day', function (assert) {
156 var a = moment().hours(2).minutes(0).seconds(0);
157
158 assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
159 assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
160 assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
161 assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
162 assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
163 assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
164 });
165
166 test('calendar next week', function (assert) {
167 var i, m;
168
169 function makeFormat(d) {
170 switch (d.day()) {
171 case 0:
172 return '[u] [nedelju] [u] LT';
173 case 3:
174 return '[u] [sredu] [u] LT';
175 case 6:
176 return '[u] [subotu] [u] LT';
177 case 1:
178 case 2:
179 case 4:
180 case 5:
181 return '[u] dddd [u] LT';
182 }
183 }
184
185 for (i = 2; i < 7; i++) {
186 m = moment().add({d: i});
187 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
188 m.hours(0).minutes(0).seconds(0).milliseconds(0);
189 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
190 m.hours(23).minutes(59).seconds(59).milliseconds(999);
191 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
192 }
193 });
194
195 test('calendar last week', function (assert) {
196 var i, m;
197
198 function makeFormat(d) {
199 var lastWeekDay = [
200 '[prošle] [nedelje] [u] LT',
201 '[prošlog] [ponedeljka] [u] LT',
202 '[prošlog] [utorka] [u] LT',
203 '[prošle] [srede] [u] LT',
204 '[prošlog] [četvrtka] [u] LT',
205 '[prošlog] [petka] [u] LT',
206 '[prošle] [subote] [u] LT'
207 ];
208
209 return lastWeekDay[d.day()];
210 }
211
212 for (i = 2; i < 7; i++) {
213 m = moment().subtract({d: i});
214 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
215 m.hours(0).minutes(0).seconds(0).milliseconds(0);
216 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
217 m.hours(23).minutes(59).seconds(59).milliseconds(999);
218 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
219 }
220 });
221
222 test('calendar all else', function (assert) {
223 var weeksAgo = moment().subtract({w: 1}),
224 weeksFromNow = moment().add({w: 1});
225
226 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
227 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
228
229 weeksAgo = moment().subtract({w: 2});
230 weeksFromNow = moment().add({w: 2});
231
232 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
233 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
234 });
235
236 test('weeks year starting sunday', function (assert) {
237 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
238 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
239 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
240 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
241 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
242 });
243
244 test('weeks year starting monday', function (assert) {
245 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
246 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
247 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
248 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
249 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
250 });
251
252 test('weeks year starting tuesday', function (assert) {
253 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
254 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
255 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
256 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
257 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
258 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
259 });
260
261 test('weeks year starting wednesday', function (assert) {
262 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
263 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
264 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
265 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
266 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
267 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
268 });
269
270 test('weeks year starting thursday', function (assert) {
271 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
272 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
273 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
274 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
275 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
276 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
277 });
278
279 test('weeks year starting friday', function (assert) {
280 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
281 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
282 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
283 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
284 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
285 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
286 });
287
288 test('weeks year starting saturday', function (assert) {
289 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
290 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
291 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
292 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
293 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
294 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
295 });
296
297 test('weeks year starting sunday formatted', function (assert) {
298 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
299 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
300 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2.', 'Jan 2 2012 should be week 2');
301 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2.', 'Jan 8 2012 should be week 2');
302 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
303 });
304
305 test('lenient ordinal parsing', function (assert) {
306 var i, ordinalStr, testMoment;
307 for (i = 1; i <= 31; ++i) {
308 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
309 testMoment = moment(ordinalStr, 'YYYY MM Do');
310 assert.equal(testMoment.year(), 2014,
311 'lenient ordinal parsing ' + i + ' year check');
312 assert.equal(testMoment.month(), 0,
313 'lenient ordinal parsing ' + i + ' month check');
314 assert.equal(testMoment.date(), i,
315 'lenient ordinal parsing ' + i + ' date check');
316 }
317 });
318
319 test('lenient ordinal parsing of number', function (assert) {
320 var i, testMoment;
321 for (i = 1; i <= 31; ++i) {
322 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
323 assert.equal(testMoment.year(), 2014,
324 'lenient ordinal parsing of number ' + i + ' year check');
325 assert.equal(testMoment.month(), 0,
326 'lenient ordinal parsing of number ' + i + ' month check');
327 assert.equal(testMoment.date(), i,
328 'lenient ordinal parsing of number ' + i + ' date check');
329 }
330 });
331
332 test('strict ordinal parsing', function (assert) {
333 var i, ordinalStr, testMoment;
334 for (i = 1; i <= 31; ++i) {
335 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
336 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
337 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
338 }
339 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('sv');
3
4 test('parse', function (assert) {
5 var tests = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'söndag, februari 14e 2010, 3:25:50 pm'],
25 ['ddd, hA', 'sön, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2a 02 februari feb'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14e 14'],
29 ['d do dddd ddd dd', '0 0e söndag sön sö'],
30 ['DDD DDDo DDDD', '45 45e 045'],
31 ['w wo ww', '6 6e 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45e day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '2010-02-14'],
40 ['LL', '14 februari 2010'],
41 ['LLL', '14 februari 2010 15:25'],
42 ['LLLL', 'söndag 14 februari 2010 15:25'],
43 ['l', '2010-2-14'],
44 ['ll', '14 feb 2010'],
45 ['lll', '14 feb 2010 15:25'],
46 ['llll', 'sön 14 feb 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3e', '3e');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4e', '4e');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5e', '5e');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6e', '6e');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7e', '7e');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8e', '8e');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9e', '9e');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10e', '10e');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11e', '11e');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12e', '12e');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13e', '13e');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14e', '14e');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15e', '15e');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16e', '16e');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17e', '17e');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18e', '18e');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19e', '19e');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20e', '20e');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23e', '23e');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24e', '24e');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25e', '25e');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26e', '26e');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27e', '27e');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28e', '28e');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29e', '29e');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30e', '30e');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'söndag sön sö_måndag mån må_tisdag tis ti_onsdag ons on_torsdag tor to_fredag fre fr_lördag lör lö'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'några sekunder', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'en minut', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'en minut', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuter', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuter', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'en timme', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'en timme', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 timmar', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 timmar', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 timmar', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'en dag', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'en dag', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 dagar', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'en dag', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 dagar', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 dagar', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'en månad', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'en månad', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'en månad', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 månader', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 månader', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 månader', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'en månad', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 månader', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ett år', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 år', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ett år', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 år', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'om några sekunder', 'prefix');
140 assert.equal(moment(0).from(30000), 'för några sekunder sedan', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'för några sekunder sedan', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'om några sekunder', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dagar', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'Idag 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'Idag 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'Idag 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'Imorgon 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Idag 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Igår 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('[På] dddd LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('[På] dddd LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('[På] dddd LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('[I] dddd[s] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('[I] dddd[s] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('[I] dddd[s] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('weeks year starting sunday', function (assert) {
202 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
203 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
204 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
205 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
206 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
207 });
208
209 test('weeks year starting monday', function (assert) {
210 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
211 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
212 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
213 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
214 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
215 });
216
217 test('weeks year starting tuesday', function (assert) {
218 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
219 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
220 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
221 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
222 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
223 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
224 });
225
226 test('weeks year starting wednesday', function (assert) {
227 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
228 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
229 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
230 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
231 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
232 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
233 });
234
235 test('weeks year starting thursday', function (assert) {
236 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
237 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
238 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
239 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
240 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
241 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
242 });
243
244 test('weeks year starting friday', function (assert) {
245 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
246 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
247 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
248 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
249 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
250 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
251 });
252
253 test('weeks year starting saturday', function (assert) {
254 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
255 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
256 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
257 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
258 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
259 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
260 });
261
262 test('weeks year starting sunday formatted', function (assert) {
263 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
264 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
265 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1a', 'Jan 8 2012 should be week 1');
266 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2a', 'Jan 9 2012 should be week 2');
267 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
268 });
269
270 test('lenient ordinal parsing', function (assert) {
271 var i, ordinalStr, testMoment;
272 for (i = 1; i <= 31; ++i) {
273 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
274 testMoment = moment(ordinalStr, 'YYYY MM Do');
275 assert.equal(testMoment.year(), 2014,
276 'lenient ordinal parsing ' + i + ' year check');
277 assert.equal(testMoment.month(), 0,
278 'lenient ordinal parsing ' + i + ' month check');
279 assert.equal(testMoment.date(), i,
280 'lenient ordinal parsing ' + i + ' date check');
281 }
282 });
283
284 test('lenient ordinal parsing of number', function (assert) {
285 var i, testMoment;
286 for (i = 1; i <= 31; ++i) {
287 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
288 assert.equal(testMoment.year(), 2014,
289 'lenient ordinal parsing of number ' + i + ' year check');
290 assert.equal(testMoment.month(), 0,
291 'lenient ordinal parsing of number ' + i + ' month check');
292 assert.equal(testMoment.date(), i,
293 'lenient ordinal parsing of number ' + i + ' date check');
294 }
295 });
296
297 test('strict ordinal parsing', function (assert) {
298 var i, ordinalStr, testMoment;
299 for (i = 1; i <= 31; ++i) {
300 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
301 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
302 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
303 }
304 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('ta');
3
4 test('parse', function (assert) {
5 var tests = 'ஜனவரி ஜனவரி_பிப்ரவரி பிப்ரவரி_மார்ச் மார்ச்_ஏப்ரல் ஏப்ரல்_மே மே_ஜூன் ஜூன்_ஜூலை ஜூலை_ஆகஸ்ட் ஆகஸ்ட்_செப்டெம்பர் செப்டெம்பர்_அக்டோபர் அக்டோபர்_நவம்பர் நவம்பர்_டிசம்பர் டிசம்பர்'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'ஞாயிற்றுக்கிழமை, பிப்ரவரி 14வது 2010, 3:25:50 எற்பாடு'],
25 ['ddd, hA', 'ஞாயிறு, 3 எற்பாடு'],
26 ['M Mo MM MMMM MMM', '2 2வது 02 பிப்ரவரி பிப்ரவரி'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14வது 14'],
29 ['d do dddd ddd dd', '0 0வது ஞாயிற்றுக்கிழமை ஞாயிறு ஞா'],
30 ['DDD DDDo DDDD', '45 45வது 045'],
31 ['w wo ww', '8 8வது 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', ' எற்பாடு எற்பாடு'],
37 ['[ஆண்டின்] DDDo [நாள்]', 'ஆண்டின் 45வது நாள்'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 பிப்ரவரி 2010'],
41 ['LLL', '14 பிப்ரவரி 2010, 15:25'],
42 ['LLLL', 'ஞாயிற்றுக்கிழமை, 14 பிப்ரவரி 2010, 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 பிப்ரவரி 2010'],
45 ['lll', '14 பிப்ரவரி 2010, 15:25'],
46 ['llll', 'ஞாயிறு, 14 பிப்ரவரி 2010, 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1வது', '1வது');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2வது', '2வது');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3வது', '3வது');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4வது', '4வது');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5வது', '5வது');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6வது', '6வது');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7வது', '7வது');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8வது', '8வது');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9வது', '9வது');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10வது', '10வது');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11வது', '11வது');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12வது', '12வது');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13வது', '13வது');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14வது', '14வது');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15வது', '15வது');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16வது', '16வது');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17வது', '17வது');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18வது', '18வது');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19வது', '19வது');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20வது', '20வது');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21வது', '21வது');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22வது', '22வது');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23வது', '23வது');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24வது', '24வது');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25வது', '25வது');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26வது', '26வது');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27வது', '27வது');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28வது', '28வது');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29வது', '29வது');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30வது', '30வது');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31வது', '31வது');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'ஜனவரி ஜனவரி_பிப்ரவரி பிப்ரவரி_மார்ச் மார்ச்_ஏப்ரல் ஏப்ரல்_மே மே_ஜூன் ஜூன்_ஜூலை ஜூலை_ஆகஸ்ட் ஆகஸ்ட்_செப்டெம்பர் செப்டெம்பர்_அக்டோபர் அக்டோபர்_நவம்பர் நவம்பர்_டிசம்பர் டிசம்பர்'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'ஞாயிற்றுக்கிழமை ஞாயிறு ஞா_திங்கட்கிழமை திங்கள் தி_செவ்வாய்கிழமை செவ்வாய் செ_புதன்கிழமை புதன் பு_வியாழக்கிழமை வியாழன் வி_வெள்ளிக்கிழமை வெள்ளி வெ_சனிக்கிழமை சனி ச'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ஒரு சில விநாடிகள்', '44 விநாடிகள் = ஒரு சில விநாடிகள்');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ஒரு நிமிடம்', '45 விநாடிகள் = ஒரு நிமிடம்');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ஒரு நிமிடம்', '89 விநாடிகள் = ஒரு நிமிடம்');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 நிமிடங்கள்', '90 விநாடிகள் = 2 நிமிடங்கள்');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 நிமிடங்கள்', '44 நிமிடங்கள் = 44 நிமிடங்கள்');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ஒரு மணி நேரம்', '45 நிமிடங்கள் = ஒரு மணி நேரம்');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ஒரு மணி நேரம்', '89 நிமிடங்கள் = ஒரு மணி நேரம்');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 மணி நேரம்', '90 நிமிடங்கள் = 2 மணி நேரம்');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 மணி நேரம்', '5 மணி நேரம் = 5 மணி நேரம்');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 மணி நேரம்', '21 மணி நேரம் = 21 மணி நேரம்');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ஒரு நாள்', '22 மணி நேரம் = ஒரு நாள்');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ஒரு நாள்', '35 மணி நேரம் = ஒரு நாள்');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 நாட்கள்', '36 மணி நேரம் = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ஒரு நாள்', '1 நாள் = ஒரு நாள்');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 நாட்கள்', '5 நாட்கள் = 5 நாட்கள்');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 நாட்கள்', '25 நாட்கள் = 25 நாட்கள்');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ஒரு மாதம்', '26 நாட்கள் = ஒரு மாதம்');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ஒரு மாதம்', '30 நாட்கள் = ஒரு மாதம்');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ஒரு மாதம்', '45 நாட்கள் = ஒரு மாதம்');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 மாதங்கள்', '46 நாட்கள் = 2 மாதங்கள்');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 மாதங்கள்', '75 நாட்கள் = 2 மாதங்கள்');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 மாதங்கள்', '76 நாட்கள் = 3 மாதங்கள்');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ஒரு மாதம்', '1 மாதம் = ஒரு மாதம்');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 மாதங்கள்', '5 மாதங்கள் = 5 மாதங்கள்');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ஒரு வருடம்', '345 நாட்கள் = ஒரு வருடம்');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ஆண்டுகள்', '548 நாட்கள் = 2 ஆண்டுகள்');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ஒரு வருடம்', '1 வருடம் = ஒரு வருடம்');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ஆண்டுகள்', '5 ஆண்டுகள் = 5 ஆண்டுகள்');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'ஒரு சில விநாடிகள் இல்', 'prefix');
140 assert.equal(moment(0).from(30000), 'ஒரு சில விநாடிகள் முன்', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'ஒரு சில விநாடிகள் முன்', 'இப்போது இருந்து கடந்த காலத்தில் காட்ட வேண்டும்');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'ஒரு சில விநாடிகள் இல்', 'ஒரு சில விநாடிகள் இல்');
149 assert.equal(moment().add({d: 5}).fromNow(), '5 நாட்கள் இல்', '5 நாட்கள் இல்');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'இன்று 02:00', 'இன்று 02:00');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'இன்று 02:25', 'இன்று 02:25');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'இன்று 03:00', 'இன்று 03:00');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'நாளை 02:00', 'நாளை 02:00');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'இன்று 01:00', 'இன்று 01:00');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'நேற்று 02:00', 'நேற்று 02:00');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd, LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd, LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd, LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[கடந்த வாரம்] dddd, LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[கடந்த வாரம்] dddd, LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[கடந்த வாரம்] dddd, LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
204 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
206 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
212 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
213 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
214 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
215 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
216 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
217 });
218
219 test('weeks year starting tuesday', function (assert) {
220 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
221 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
222 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
223 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
224 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
225 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
226 });
227
228 test('weeks year starting wednesday', function (assert) {
229 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
230 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
231 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
232 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
233 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
234 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
235 });
236
237 test('weeks year starting thursday', function (assert) {
238 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
239 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
240 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
241 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
242 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
243 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
244 });
245
246 test('weeks year starting friday', function (assert) {
247 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
248 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
249 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
250 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
251 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
252 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
253 });
254
255 test('weeks year starting saturday', function (assert) {
256 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
257 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
258 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
259 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
260 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
261 });
262
263 test('meridiem', function (assert) {
264 assert.equal(moment([2011, 2, 23, 0, 30]).format('a'), ' யாமம்', '(after) midnight');
265 assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), ' வைகறை', 'before dawn');
266 assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), ' காலை', 'morning');
267 assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), ' எற்பாடு', 'during day');
268 assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), ' எற்பாடு', 'evening');
269 assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), ' மாலை', 'late evening');
270 assert.equal(moment([2011, 2, 23, 23, 30]).format('a'), ' யாமம்', '(before) midnight');
271 });
272
273 test('lenient ordinal parsing', function (assert) {
274 var i, ordinalStr, testMoment;
275 for (i = 1; i <= 31; ++i) {
276 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
277 testMoment = moment(ordinalStr, 'YYYY MM Do');
278 assert.equal(testMoment.year(), 2014,
279 'lenient ordinal parsing ' + i + ' year check');
280 assert.equal(testMoment.month(), 0,
281 'lenient ordinal parsing ' + i + ' month check');
282 assert.equal(testMoment.date(), i,
283 'lenient ordinal parsing ' + i + ' date check');
284 }
285 });
286
287 test('lenient ordinal parsing of number', function (assert) {
288 var i, testMoment;
289 for (i = 1; i <= 31; ++i) {
290 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
291 assert.equal(testMoment.year(), 2014,
292 'lenient ordinal parsing of number ' + i + ' year check');
293 assert.equal(testMoment.month(), 0,
294 'lenient ordinal parsing of number ' + i + ' month check');
295 assert.equal(testMoment.date(), i,
296 'lenient ordinal parsing of number ' + i + ' date check');
297 }
298 });
299
300 test('meridiem invariant', function (assert) {
301 var h, m, t1, t2;
302 for (h = 0; h < 24; ++h) {
303 for (m = 0; m < 60; m += 15) {
304 t1 = moment.utc([2000, 0, 1, h, m]);
305 t2 = moment(t1.format('A h:mm'), 'A h:mm');
306 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
307 'meridiem at ' + t1.format('HH:mm'));
308 }
309 }
310 });
311
312 test('strict ordinal parsing', function (assert) {
313 var i, ordinalStr, testMoment;
314 for (i = 1; i <= 31; ++i) {
315 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
316 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
317 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
318 }
319 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('th');
3
4 test('parse', function (assert) {
5 var tests = 'มกราคม มกรา_กุมภาพันธ์ กุมภา_มีนาคม มีนา_เมษายน เมษา_พฤษภาคม พฤษภา_มิถุนายน มิถุนา_กรกฎาคม กรกฎา_สิงหาคม สิงหา_กันยายน กันยา_ตุลาคม ตุลา_พฤศจิกายน พฤศจิกา_ธันวาคม ธันวา'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, h:mm:ss a', 'อาทิตย์, 14 กุมภาพันธ์ 2010, 3:25:50 หลังเที่ยง'],
25 ['ddd, h A', 'อาทิตย์, 3 หลังเที่ยง'],
26 ['M Mo MM MMMM MMM', '2 2 02 กุมภาพันธ์ กุมภา'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 อาทิตย์ อาทิตย์ อา.'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '8 8 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'หลังเที่ยง หลังเที่ยง'],
37 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
38 ['LTS', '15 นาฬิกา 25 นาที 50 วินาที'],
39 ['L', '2010/02/14'],
40 ['LL', '14 กุมภาพันธ์ 2010'],
41 ['LLL', '14 กุมภาพันธ์ 2010 เวลา 15 นาฬิกา 25 นาที'],
42 ['LLLL', 'วันอาทิตย์ที่ 14 กุมภาพันธ์ 2010 เวลา 15 นาฬิกา 25 นาที'],
43 ['l', '2010/2/14'],
44 ['ll', '14 กุมภา 2010'],
45 ['lll', '14 กุมภา 2010 เวลา 15 นาฬิกา 25 นาที'],
46 ['llll', 'วันอาทิตย์ที่ 14 กุมภา 2010 เวลา 15 นาฬิกา 25 นาที']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format month', function (assert) {
56 var expected = 'มกราคม มกรา_กุมภาพันธ์ กุมภา_มีนาคม มีนา_เมษายน เมษา_พฤษภาคม พฤษภา_มิถุนายน มิถุนา_กรกฎาคม กรกฎา_สิงหาคม สิงหา_กันยายน กันยา_ตุลาคม ตุลา_พฤศจิกายน พฤศจิกา_ธันวาคม ธันวา'.split('_'), i;
57 for (i = 0; i < expected.length; i++) {
58 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
59 }
60 });
61
62 test('format week', function (assert) {
63 var expected = 'อาทิตย์ อาทิตย์ อา._จันทร์ จันทร์ จ._อังคาร อังคาร อ._พุธ พุธ พ._พฤหัสบดี พฤหัส พฤ._ศุกร์ ศุกร์ ศ._เสาร์ เสาร์ ส.'.split('_'), i;
64 for (i = 0; i < expected.length; i++) {
65 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
66 }
67 });
68
69 test('from', function (assert) {
70 var start = moment([2007, 1, 28]);
71 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ไม่กี่วินาที', '44 seconds = a few seconds');
72 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1 นาที', '45 seconds = a minute');
73 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1 นาที', '89 seconds = a minute');
74 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 นาที', '90 seconds = 2 minutes');
75 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 นาที', '44 minutes = 44 minutes');
76 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1 ชั่วโมง', '45 minutes = an hour');
77 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1 ชั่วโมง', '89 minutes = an hour');
78 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ชั่วโมง', '90 minutes = 2 hours');
79 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ชั่วโมง', '5 hours = 5 hours');
80 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ชั่วโมง', '21 hours = 21 hours');
81 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1 วัน', '22 hours = a day');
82 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1 วัน', '35 hours = a day');
83 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 วัน', '36 hours = 2 days');
84 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1 วัน', '1 day = a day');
85 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 วัน', '5 days = 5 days');
86 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 วัน', '25 days = 25 days');
87 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1 เดือน', '26 days = a month');
88 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1 เดือน', '30 days = a month');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1 เดือน', '43 days = a month');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 เดือน', '46 days = 2 months');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 เดือน', '75 days = 2 months');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 เดือน', '76 days = 3 months');
93 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1 เดือน', '1 month = a month');
94 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 เดือน', '5 months = 5 months');
95 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1 ปี', '345 days = a year');
96 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ปี', '548 days = 2 years');
97 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1 ปี', '1 year = a year');
98 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ปี', '5 years = 5 years');
99 });
100
101 test('suffix', function (assert) {
102 assert.equal(moment(30000).from(0), 'อีก ไม่กี่วินาที', 'prefix');
103 assert.equal(moment(0).from(30000), 'ไม่กี่วินาทีที่แล้ว', 'suffix');
104 });
105
106 test('now from now', function (assert) {
107 assert.equal(moment().fromNow(), 'ไม่กี่วินาทีที่แล้ว', 'now from now should display as in the past');
108 });
109
110 test('fromNow', function (assert) {
111 assert.equal(moment().add({s: 30}).fromNow(), 'อีก ไม่กี่วินาที', 'in a few seconds');
112 assert.equal(moment().add({d: 5}).fromNow(), 'อีก 5 วัน', 'in 5 days');
113 });
114
115 test('calendar day', function (assert) {
116 var a = moment().hours(2).minutes(0).seconds(0);
117
118 assert.equal(moment(a).calendar(), 'วันนี้ เวลา 2 นาฬิกา 0 นาที', 'today at the same time');
119 assert.equal(moment(a).add({m: 25}).calendar(), 'วันนี้ เวลา 2 นาฬิกา 25 นาที', 'Now plus 25 min');
120 assert.equal(moment(a).add({h: 1}).calendar(), 'วันนี้ เวลา 3 นาฬิกา 0 นาที', 'Now plus 1 hour');
121 assert.equal(moment(a).add({d: 1}).calendar(), 'พรุ่งนี้ เวลา 2 นาฬิกา 0 นาที', 'tomorrow at the same time');
122 assert.equal(moment(a).subtract({h: 1}).calendar(), 'วันนี้ เวลา 1 นาฬิกา 0 นาที', 'Now minus 1 hour');
123 assert.equal(moment(a).subtract({d: 1}).calendar(), 'เมื่อวานนี้ เวลา 2 นาฬิกา 0 นาที', 'yesterday at the same time');
124 });
125
126 test('calendar next week', function (assert) {
127 var i, m;
128 for (i = 2; i < 7; i++) {
129 m = moment().add({d: i});
130 assert.equal(m.calendar(), m.format('dddd[หน้า เวลา] LT'), 'Today + ' + i + ' days current time');
131 m.hours(0).minutes(0).seconds(0).milliseconds(0);
132 assert.equal(m.calendar(), m.format('dddd[หน้า เวลา] LT'), 'Today + ' + i + ' days beginning of day');
133 m.hours(23).minutes(59).seconds(59).milliseconds(999);
134 assert.equal(m.calendar(), m.format('dddd[หน้า เวลา] LT'), 'Today + ' + i + ' days end of day');
135 }
136 });
137
138 test('calendar last week', function (assert) {
139 var i, m;
140 for (i = 2; i < 7; i++) {
141 m = moment().subtract({d: i});
142 assert.equal(m.calendar(), m.format('[วัน]dddd[ที่แล้ว เวลา] LT'), 'Today - ' + i + ' days current time');
143 m.hours(0).minutes(0).seconds(0).milliseconds(0);
144 assert.equal(m.calendar(), m.format('[วัน]dddd[ที่แล้ว เวลา] LT'), 'Today - ' + i + ' days beginning of day');
145 m.hours(23).minutes(59).seconds(59).milliseconds(999);
146 assert.equal(m.calendar(), m.format('[วัน]dddd[ที่แล้ว เวลา] LT'), 'Today - ' + i + ' days end of day');
147 }
148 });
149
150 test('calendar all else', function (assert) {
151 var weeksAgo = moment().subtract({w: 1}),
152 weeksFromNow = moment().add({w: 1});
153
154 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
155 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
156
157 weeksAgo = moment().subtract({w: 2});
158 weeksFromNow = moment().add({w: 2});
159
160 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
161 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
162 });
163
164 test('weeks year starting sunday', function (assert) {
165 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
166 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
167 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
168 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
169 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
170 });
171
172 test('weeks year starting monday', function (assert) {
173 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
174 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
175 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
176 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
177 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
178 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
179 });
180
181 test('weeks year starting tuesday', function (assert) {
182 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
183 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
184 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
185 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
186 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
187 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
188 });
189
190 test('weeks year starting wednesday', function (assert) {
191 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
192 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
193 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
194 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
195 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
196 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
197 });
198
199 test('weeks year starting thursday', function (assert) {
200 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
201 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
202 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
203 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
204 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
205 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
206 });
207
208 test('weeks year starting friday', function (assert) {
209 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
210 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
211 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
212 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
213 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
214 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
215 });
216
217 test('weeks year starting saturday', function (assert) {
218 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
219 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
220 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
221 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
222 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
223 });
224
225 test('weeks year starting sunday format', function (assert) {
226 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
227 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
228 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
229 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2', 'Jan 14 2012 should be week 2');
230 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
231 });
232
233 test('lenient ordinal parsing', function (assert) {
234 var i, ordinalStr, testMoment;
235 for (i = 1; i <= 31; ++i) {
236 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
237 testMoment = moment(ordinalStr, 'YYYY MM Do');
238 assert.equal(testMoment.year(), 2014,
239 'lenient ordinal parsing ' + i + ' year check');
240 assert.equal(testMoment.month(), 0,
241 'lenient ordinal parsing ' + i + ' month check');
242 assert.equal(testMoment.date(), i,
243 'lenient ordinal parsing ' + i + ' date check');
244 }
245 });
246
247 test('lenient ordinal parsing of number', function (assert) {
248 var i, testMoment;
249 for (i = 1; i <= 31; ++i) {
250 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
251 assert.equal(testMoment.year(), 2014,
252 'lenient ordinal parsing of number ' + i + ' year check');
253 assert.equal(testMoment.month(), 0,
254 'lenient ordinal parsing of number ' + i + ' month check');
255 assert.equal(testMoment.date(), i,
256 'lenient ordinal parsing of number ' + i + ' date check');
257 }
258 });
259
260 test('strict ordinal parsing', function (assert) {
261 var i, ordinalStr, testMoment;
262 for (i = 1; i <= 31; ++i) {
263 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
264 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
265 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
266 }
267 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('tl-ph');
3
4 test('parse', function (assert) {
5 var tests = 'Enero Ene_Pebrero Peb_Marso Mar_Abril Abr_Mayo May_Hunyo Hun_Hulyo Hul_Agosto Ago_Setyembre Set_Oktubre Okt_Nobyembre Nob_Disyembre Dis'.split('_'),
6 i;
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10 for (i = 0; i < 12; i++) {
11 tests[i] = tests[i].split(' ');
12 equalTest(tests[i][0], 'MMM', i);
13 equalTest(tests[i][1], 'MMM', i);
14 equalTest(tests[i][0], 'MMMM', i);
15 equalTest(tests[i][1], 'MMMM', i);
16 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
19 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
20 }
21 });
22
23 test('format', function (assert) {
24 var a = [
25 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Linggo, Pebrero 14 2010, 3:25:50 pm'],
26 ['ddd, hA', 'Lin, 3PM'],
27 ['M Mo MM MMMM MMM', '2 2 02 Pebrero Peb'],
28 ['YYYY YY', '2010 10'],
29 ['D Do DD', '14 14 14'],
30 ['d do dddd ddd dd', '0 0 Linggo Lin Li'],
31 ['DDD DDDo DDDD', '45 45 045'],
32 ['w wo ww', '6 6 06'],
33 ['h hh', '3 03'],
34 ['H HH', '15 15'],
35 ['m mm', '25 25'],
36 ['s ss', '50 50'],
37 ['a A', 'pm PM'],
38 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
39 ['LTS', '15:25:50'],
40 ['L', '02/14/2010'],
41 ['LL', 'Pebrero 14, 2010'],
42 ['LLL', 'Pebrero 14, 2010 15:25'],
43 ['LLLL', 'Linggo, Pebrero 14, 2010 15:25'],
44 ['l', '2/14/2010'],
45 ['ll', 'Peb 14, 2010'],
46 ['lll', 'Peb 14, 2010 15:25'],
47 ['llll', 'Lin, Peb 14, 2010 15:25']
48 ],
49 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
50 i;
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format ordinal', function (assert) {
57 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
58 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
59 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
60 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
61 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
62 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
63 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
64 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
65 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
66 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
67
68 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
69 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
70 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
71 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
72 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
73 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
74 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
75 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
76 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
77 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
78
79 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
80 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
81 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
82 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
83 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
84 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
85 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
86 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
87 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
88 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
89
90 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
91 });
92
93 test('format month', function (assert) {
94 var expected = 'Enero Ene_Pebrero Peb_Marso Mar_Abril Abr_Mayo May_Hunyo Hun_Hulyo Hul_Agosto Ago_Setyembre Set_Oktubre Okt_Nobyembre Nob_Disyembre Dis'.split('_'), i;
95 for (i = 0; i < expected.length; i++) {
96 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
97 }
98 });
99
100 test('format week', function (assert) {
101 var expected = 'Linggo Lin Li_Lunes Lun Lu_Martes Mar Ma_Miyerkules Miy Mi_Huwebes Huw Hu_Biyernes Biy Bi_Sabado Sab Sab'.split('_'), i;
102 for (i = 0; i < expected.length; i++) {
103 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
104 }
105 });
106
107 test('from', function (assert) {
108 var start = moment([2007, 1, 28]);
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ilang segundo', '44 seconds = a few seconds');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'isang minuto', '45 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'isang minuto', '89 seconds = a minute');
112 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuto', '90 seconds = 2 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuto', '44 minutes = 44 minutes');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'isang oras', '45 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'isang oras', '89 minutes = an hour');
116 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 oras', '90 minutes = 2 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 oras', '5 hours = 5 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 oras', '21 hours = 21 hours');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'isang araw', '22 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'isang araw', '35 hours = a day');
121 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 araw', '36 hours = 2 days');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'isang araw', '1 day = a day');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 araw', '5 days = 5 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 araw', '25 days = 25 days');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'isang buwan', '26 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'isang buwan', '30 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'isang buwan', '43 days = a month');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 buwan', '46 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 buwan', '75 days = 2 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 buwan', '76 days = 3 months');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'isang buwan', '1 month = a month');
132 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 buwan', '5 months = 5 months');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'isang taon', '345 days = a year');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 taon', '548 days = 2 years');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'isang taon', '1 year = a year');
136 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 taon', '5 years = 5 years');
137 });
138
139 test('suffix', function (assert) {
140 assert.equal(moment(30000).from(0), 'sa loob ng ilang segundo', 'prefix');
141 assert.equal(moment(0).from(30000), 'ilang segundo ang nakalipas', 'suffix');
142 });
143
144 test('fromNow', function (assert) {
145 assert.equal(moment().add({s: 30}).fromNow(), 'sa loob ng ilang segundo', 'in a few seconds');
146 assert.equal(moment().add({d: 5}).fromNow(), 'sa loob ng 5 araw', 'in 5 days');
147 });
148
149 test('same day', function (assert) {
150 var a = moment().hours(2).minutes(0).seconds(0);
151
152 assert.equal(moment(a).calendar(), 'Ngayon sa 02:00', 'today at the same time');
153 assert.equal(moment(a).add({m: 25}).calendar(), 'Ngayon sa 02:25', 'Now plus 25 min');
154 assert.equal(moment(a).add({h: 1}).calendar(), 'Ngayon sa 03:00', 'Now plus 1 hour');
155 assert.equal(moment(a).add({d: 1}).calendar(), 'Bukas sa 02:00', 'tomorrow at the same time');
156 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ngayon sa 01:00', 'Now minus 1 hour');
157 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kahapon sa 02:00', 'yesterday at the same time');
158 });
159
160 test('same next week', function (assert) {
161 var i, m;
162
163 for (i = 2; i < 7; i++) {
164 m = moment().add({d: i});
165 assert.equal(m.calendar(), m.format('dddd [sa] LT'), 'Today + ' + i + ' days current time');
166 m.hours(0).minutes(0).seconds(0).milliseconds(0);
167 assert.equal(m.calendar(), m.format('dddd [sa] LT'), 'Today + ' + i + ' days beginning of day');
168 m.hours(23).minutes(59).seconds(59).milliseconds(999);
169 assert.equal(m.calendar(), m.format('dddd [sa] LT'), 'Today + ' + i + ' days end of day');
170 }
171 });
172
173 test('same last week', function (assert) {
174 var i, m;
175
176 for (i = 2; i < 7; i++) {
177 m = moment().subtract({d: i});
178 assert.equal(m.calendar(), m.format('dddd [huling linggo] LT'), 'Today - ' + i + ' days current time');
179 m.hours(0).minutes(0).seconds(0).milliseconds(0);
180 assert.equal(m.calendar(), m.format('dddd [huling linggo] LT'), 'Today - ' + i + ' days beginning of day');
181 m.hours(23).minutes(59).seconds(59).milliseconds(999);
182 assert.equal(m.calendar(), m.format('dddd [huling linggo] LT'), 'Today - ' + i + ' days end of day');
183 }
184 });
185
186 test('same all else', function (assert) {
187 var weeksAgo = moment().subtract({w: 1}),
188 weeksFromNow = moment().add({w: 1});
189
190 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
191 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
192
193 weeksAgo = moment().subtract({w: 2});
194 weeksFromNow = moment().add({w: 2});
195
196 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
197 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
198 });
199
200 test('weeks year starting sunday', function (assert) {
201 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
202 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
203 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
204 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
205 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
206 });
207
208 test('weeks year starting monday', function (assert) {
209 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
210 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
211 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
212 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
213 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
214 });
215
216 test('weeks year starting tuesday', function (assert) {
217 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
218 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
219 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
220 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
221 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
222 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
223 });
224
225 test('weeks year starting wednesday', function (assert) {
226 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
227 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
228 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
229 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
230 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
231 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
232 });
233
234 test('weeks year starting thursday', function (assert) {
235 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
236 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
237 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
238 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
239 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
240 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
241 });
242
243 test('weeks year starting friday', function (assert) {
244 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
245 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
246 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
247 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
248 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
249 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
250 });
251
252 test('weeks year starting saturday', function (assert) {
253 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
254 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
255 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
256 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
257 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
258 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
259 });
260
261 test('weeks year starting sunday formatted', function (assert) {
262 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
263 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
264 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
265 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
266 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
267 });
268
269 test('lenient ordinal parsing', function (assert) {
270 var i, ordinalStr, testMoment;
271 for (i = 1; i <= 31; ++i) {
272 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
273 testMoment = moment(ordinalStr, 'YYYY MM Do');
274 assert.equal(testMoment.year(), 2014,
275 'lenient ordinal parsing ' + i + ' year check');
276 assert.equal(testMoment.month(), 0,
277 'lenient ordinal parsing ' + i + ' month check');
278 assert.equal(testMoment.date(), i,
279 'lenient ordinal parsing ' + i + ' date check');
280 }
281 });
282
283 test('lenient ordinal parsing of number', function (assert) {
284 var i, testMoment;
285 for (i = 1; i <= 31; ++i) {
286 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
287 assert.equal(testMoment.year(), 2014,
288 'lenient ordinal parsing of number ' + i + ' year check');
289 assert.equal(testMoment.month(), 0,
290 'lenient ordinal parsing of number ' + i + ' month check');
291 assert.equal(testMoment.date(), i,
292 'lenient ordinal parsing of number ' + i + ' date check');
293 }
294 });
295
296 test('strict ordinal parsing', function (assert) {
297 var i, ordinalStr, testMoment;
298 for (i = 1; i <= 31; ++i) {
299 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
300 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
301 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
302 }
303 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('tr');
3
4 test('parse', function (assert) {
5 var tests = 'Ocak Oca_Şubat Şub_Mart Mar_Nisan Nis_Mayıs May_Haziran Haz_Temmuz Tem_Ağustos Ağu_Eylül Eyl_Ekim Eki_Kasım Kas_Aralık Ara'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'Pazar, Şubat 14\'üncü 2010, 3:25:50 pm'],
25 ['ddd, hA', 'Paz, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2\'nci 02 Şubat Şub'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14\'üncü 14'],
29 ['d do dddd ddd dd', '0 0\'ıncı Pazar Paz Pz'],
30 ['DDD DDDo DDDD', '45 45\'inci 045'],
31 ['w wo ww', '7 7\'nci 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[yılın] DDDo [günü]', 'yılın 45\'inci günü'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14 Şubat 2010'],
41 ['LLL', '14 Şubat 2010 15:25'],
42 ['LLLL', 'Pazar, 14 Şubat 2010 15:25'],
43 ['l', '14.2.2010'],
44 ['ll', '14 Şub 2010'],
45 ['lll', '14 Şub 2010 15:25'],
46 ['llll', 'Paz, 14 Şub 2010 15:25']
47 ],
48 DDDo = [
49 [359, '360\'ıncı'],
50 [199, '200\'üncü'],
51 [149, '150\'nci']
52 ],
53 dt = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
54 DDDoDt,
55 i;
56
57 for (i = 0; i < a.length; i++) {
58 assert.equal(dt.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
59 }
60 for (i = 0; i < DDDo.length; i++) {
61 DDDoDt = moment([2010]);
62 assert.equal(DDDoDt.add(DDDo[i][0], 'days').format('DDDo'), DDDo[i][1], DDDo[i][0] + ' ---> ' + DDDo[i][1]);
63 }
64 });
65
66 test('format ordinal', function (assert) {
67 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1\'inci', '1st');
68 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2\'nci', '2nd');
69 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3\'üncü', '3rd');
70 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4\'üncü', '4th');
71 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5\'inci', '5th');
72 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6\'ncı', '6th');
73 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7\'nci', '7th');
74 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8\'inci', '8th');
75 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9\'uncu', '9th');
76 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10\'uncu', '10th');
77
78 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11\'inci', '11th');
79 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12\'nci', '12th');
80 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13\'üncü', '13th');
81 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14\'üncü', '14th');
82 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15\'inci', '15th');
83 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16\'ncı', '16th');
84 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17\'nci', '17th');
85 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18\'inci', '18th');
86 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19\'uncu', '19th');
87 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20\'nci', '20th');
88
89 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21\'inci', '21th');
90 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22\'nci', '22th');
91 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23\'üncü', '23th');
92 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24\'üncü', '24th');
93 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25\'inci', '25th');
94 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26\'ncı', '26th');
95 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27\'nci', '27th');
96 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28\'inci', '28th');
97 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29\'uncu', '29th');
98 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30\'uncu', '30th');
99
100 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31\'inci', '31st');
101 });
102
103 test('format month', function (assert) {
104 var expected = 'Ocak Oca_Şubat Şub_Mart Mar_Nisan Nis_Mayıs May_Haziran Haz_Temmuz Tem_Ağustos Ağu_Eylül Eyl_Ekim Eki_Kasım Kas_Aralık Ara'.split('_'), i;
105 for (i = 0; i < expected.length; i++) {
106 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
107 }
108 });
109
110 test('format week', function (assert) {
111 var expected = 'Pazar Paz Pz_Pazartesi Pts Pt_Salı Sal Sa_Çarşamba Çar Ça_Perşembe Per Pe_Cuma Cum Cu_Cumartesi Cts Ct'.split('_'), i;
112 for (i = 0; i < expected.length; i++) {
113 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
114 }
115 });
116
117 test('from', function (assert) {
118 var start = moment([2007, 1, 28]);
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'birkaç saniye', '44 seconds = a few seconds');
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'bir dakika', '45 seconds = a minute');
121 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'bir dakika', '89 seconds = a minute');
122 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 dakika', '90 seconds = 2 minutes');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 dakika', '44 minutes = 44 minutes');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'bir saat', '45 minutes = an hour');
125 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'bir saat', '89 minutes = an hour');
126 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 saat', '90 minutes = 2 hours');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 saat', '5 hours = 5 hours');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 saat', '21 hours = 21 hours');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'bir gün', '22 hours = a day');
130 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'bir gün', '35 hours = a day');
131 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 gün', '36 hours = 2 days');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'bir gün', '1 day = a day');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 gün', '5 days = 5 days');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 gün', '25 days = 25 days');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'bir ay', '26 days = a month');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'bir ay', '30 days = a month');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'bir ay', '43 days = a month');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ay', '46 days = 2 months');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ay', '75 days = 2 months');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ay', '76 days = 3 months');
141 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'bir ay', '1 month = a month');
142 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ay', '5 months = 5 months');
143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'bir yıl', '345 days = a year');
144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 yıl', '548 days = 2 years');
145 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'bir yıl', '1 year = a year');
146 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 yıl', '5 years = 5 years');
147 });
148
149 test('suffix', function (assert) {
150 assert.equal(moment(30000).from(0), 'birkaç saniye sonra', 'prefix');
151 assert.equal(moment(0).from(30000), 'birkaç saniye önce', 'suffix');
152 });
153
154 test('now from now', function (assert) {
155 assert.equal(moment().fromNow(), 'birkaç saniye önce', 'now from now should display as in the past');
156 });
157
158 test('fromNow', function (assert) {
159 assert.equal(moment().add({s: 30}).fromNow(), 'birkaç saniye sonra', 'in a few seconds');
160 assert.equal(moment().add({d: 5}).fromNow(), '5 gün sonra', 'in 5 days');
161 });
162
163 test('calendar day', function (assert) {
164 var a = moment().hours(2).minutes(0).seconds(0);
165
166 assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
167 assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
168 assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
169 assert.equal(moment(a).add({d: 1}).calendar(), 'yarın saat 02:00', 'tomorrow at the same time');
170 assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
171 assert.equal(moment(a).subtract({d: 1}).calendar(), 'dün 02:00', 'yesterday at the same time');
172 });
173
174 test('calendar next week', function (assert) {
175 var i, m;
176 for (i = 2; i < 7; i++) {
177 m = moment().add({d: i});
178 assert.equal(m.calendar(), m.format('[haftaya] dddd [saat] LT'), 'Today + ' + i + ' days current time');
179 m.hours(0).minutes(0).seconds(0).milliseconds(0);
180 assert.equal(m.calendar(), m.format('[haftaya] dddd [saat] LT'), 'Today + ' + i + ' days beginning of day');
181 m.hours(23).minutes(59).seconds(59).milliseconds(999);
182 assert.equal(m.calendar(), m.format('[haftaya] dddd [saat] LT'), 'Today + ' + i + ' days end of day');
183 }
184 });
185
186 test('calendar last week', function (assert) {
187 var i, m;
188 for (i = 2; i < 7; i++) {
189 m = moment().subtract({d: i});
190 assert.equal(m.calendar(), m.format('[geçen hafta] dddd [saat] LT'), 'Today - ' + i + ' days current time');
191 m.hours(0).minutes(0).seconds(0).milliseconds(0);
192 assert.equal(m.calendar(), m.format('[geçen hafta] dddd [saat] LT'), 'Today - ' + i + ' days beginning of day');
193 m.hours(23).minutes(59).seconds(59).milliseconds(999);
194 assert.equal(m.calendar(), m.format('[geçen hafta] dddd [saat] LT'), 'Today - ' + i + ' days end of day');
195 }
196 });
197
198 test('calendar all else', function (assert) {
199 var weeksAgo = moment().subtract({w: 1}),
200 weeksFromNow = moment().add({w: 1});
201
202 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
203 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
204
205 weeksAgo = moment().subtract({w: 2});
206 weeksFromNow = moment().add({w: 2});
207
208 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
209 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
210 });
211
212 test('weeks year starting sunday', function (assert) {
213 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
214 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
215 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
216 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
217 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
218 });
219
220 test('weeks year starting monday', function (assert) {
221 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
222 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
223 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
224 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
225 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
226 });
227
228 test('weeks year starting tuesday', function (assert) {
229 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
230 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
231 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
232 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
233 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
234 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
235 });
236
237 test('weeks year starting wednesday', function (assert) {
238 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
239 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
240 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
241 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
242 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
243 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
244 });
245
246 test('weeks year starting thursday', function (assert) {
247 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
248 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
249 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
250 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
251 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
252 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
253 });
254
255 test('weeks year starting friday', function (assert) {
256 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
257 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
258 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
259 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
260 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
261 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
262 });
263
264 test('weeks year starting saturday', function (assert) {
265 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
266 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
267 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
268 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
269 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
270 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
271 });
272
273 test('weeks year starting sunday formatted', function (assert) {
274 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1\'inci', 'Dec 26 2011 should be week 1');
275 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1\'inci', 'Jan 1 2012 should be week 1');
276 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2\'nci', 'Jan 2 2012 should be week 2');
277 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2\'nci', 'Jan 8 2012 should be week 2');
278 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3\'üncü', 'Jan 9 2012 should be week 3');
279 });
280
281 test('lenient ordinal parsing', function (assert) {
282 var i, ordinalStr, testMoment;
283 for (i = 1; i <= 31; ++i) {
284 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
285 testMoment = moment(ordinalStr, 'YYYY MM Do');
286 assert.equal(testMoment.year(), 2014,
287 'lenient ordinal parsing ' + i + ' year check');
288 assert.equal(testMoment.month(), 0,
289 'lenient ordinal parsing ' + i + ' month check');
290 assert.equal(testMoment.date(), i,
291 'lenient ordinal parsing ' + i + ' date check');
292 }
293 });
294
295 test('lenient ordinal parsing of number', function (assert) {
296 var i, testMoment;
297 for (i = 1; i <= 31; ++i) {
298 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
299 assert.equal(testMoment.year(), 2014,
300 'lenient ordinal parsing of number ' + i + ' year check');
301 assert.equal(testMoment.month(), 0,
302 'lenient ordinal parsing of number ' + i + ' month check');
303 assert.equal(testMoment.date(), i,
304 'lenient ordinal parsing of number ' + i + ' date check');
305 }
306 });
307
308 test('strict ordinal parsing', function (assert) {
309 var i, ordinalStr, testMoment;
310 for (i = 1; i <= 31; ++i) {
311 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
312 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
313 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
314 }
315 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('tzl');
3
4 test('parse', function (assert) {
5 var tests = 'Januar Jan_Fevraglh Fev_Març Mar_Avrïu Avr_Mai Mai_Gün Gün_Julia Jul_Guscht Gus_Setemvar Set_Listopäts Lis_Noemvar Noe_Zecemvar Zec'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h.mm.ss a', 'Súladi, Fevraglh 14. 2010, 3.25.50 d\'o'],
25 ['ddd, hA', 'Súl, 3D\'O'],
26 ['M Mo MM MMMM MMM', '2 2. 02 Fevraglh Fev'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14. 14'],
29 ['d do dddd ddd dd', '0 0. Súladi Súl Sú'],
30 ['DDD DDDo DDDD', '45 45. 045'],
31 ['w wo ww', '6 6. 06'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'd\'o D\'O'],
37 ['[the] DDDo [day of the year]', 'the 45. day of the year'],
38 ['LTS', '15.25.50'],
39 ['L', '14.02.2010'],
40 ['LL', '14. Fevraglh dallas 2010'],
41 ['LLL', '14. Fevraglh dallas 2010 15.25'],
42 ['LLLL', 'Súladi, li 14. Fevraglh dallas 2010 15.25'],
43 ['l', '14.2.2010'],
44 ['ll', '14. Fev dallas 2010'],
45 ['lll', '14. Fev dallas 2010 15.25'],
46 ['llll', 'Súl, li 14. Fev dallas 2010 15.25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4.', '4.');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5.', '5.');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6.', '6.');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7.', '7.');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14.', '14.');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15.', '15.');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16.', '16.');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17.', '17.');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24.', '24.');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25.', '25.');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26.', '26.');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27.', '27.');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'Januar Jan_Fevraglh Fev_Març Mar_Avrïu Avr_Mai Mai_Gün Gün_Julia Jul_Guscht Gus_Setemvar Set_Listopäts Lis_Noemvar Noe_Zecemvar Zec'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Súladi Súl Sú_Lúneçi Lún Lú_Maitzi Mai Ma_Márcuri Már Má_Xhúadi Xhú Xh_Viénerçi Vié Vi_Sáturi Sát Sá'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'viensas secunds', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '\'n míut', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '\'n míut', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 míuts', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 míuts', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '\'n þora', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '\'n þora', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 þoras', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 þoras', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 þoras', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '\'n ziua', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '\'n ziua', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ziuas', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '\'n ziua', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ziuas', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ziuas', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '\'n mes', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '\'n mes', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '\'n mes', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 mesen', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 mesen', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 mesen', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '\'n mes', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 mesen', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '\'n ar', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ars', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '\'n ar', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ars', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'osprei viensas secunds', 'prefix');
140 assert.equal(moment(0).from(30000), 'ja\'iensas secunds', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'ja\'iensas secunds', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'osprei viensas secunds', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'osprei 5 ziuas', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'oxhi à 02.00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'oxhi à 02.25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'oxhi à 03.00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'demà à 02.00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'oxhi à 01.00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieiri à 02.00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [à] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[sür el] dddd [lasteu à] LT'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[sür el] dddd [lasteu à] LT'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[sür el] dddd [lasteu à] LT'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 // Monday is the first day of the week.
203 // The week that contains Jan 4th is the first week of the year.
204
205 test('weeks year starting sunday', function (assert) {
206 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
207 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
208 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
209 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
210 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
211 });
212
213 test('weeks year starting monday', function (assert) {
214 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
215 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
216 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
217 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
218 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
219 });
220
221 test('weeks year starting tuesday', function (assert) {
222 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
223 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
224 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
225 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
226 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
227 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
228 });
229
230 test('weeks year starting wednesday', function (assert) {
231 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
232 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
233 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
234 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
235 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
236 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
237 });
238
239 test('weeks year starting thursday', function (assert) {
240 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
241 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
242 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
243 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
244 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
245 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
246 });
247
248 test('weeks year starting friday', function (assert) {
249 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
250 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
251 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
252 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
253 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
254 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
255 });
256
257 test('weeks year starting saturday', function (assert) {
258 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
259 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
260 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
261 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
262 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
263 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
264 });
265
266 test('weeks year starting sunday formatted', function (assert) {
267 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
268 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
269 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
270 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
271 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
272 });
273
274 test('lenient ordinal parsing', function (assert) {
275 var i, ordinalStr, testMoment;
276 for (i = 1; i <= 31; ++i) {
277 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
278 testMoment = moment(ordinalStr, 'YYYY MM Do');
279 assert.equal(testMoment.year(), 2014,
280 'lenient ordinal parsing ' + i + ' year check');
281 assert.equal(testMoment.month(), 0,
282 'lenient ordinal parsing ' + i + ' month check');
283 assert.equal(testMoment.date(), i,
284 'lenient ordinal parsing ' + i + ' date check');
285 }
286 });
287
288 test('lenient ordinal parsing of number', function (assert) {
289 var i, testMoment;
290 for (i = 1; i <= 31; ++i) {
291 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
292 assert.equal(testMoment.year(), 2014,
293 'lenient ordinal parsing of number ' + i + ' year check');
294 assert.equal(testMoment.month(), 0,
295 'lenient ordinal parsing of number ' + i + ' month check');
296 assert.equal(testMoment.date(), i,
297 'lenient ordinal parsing of number ' + i + ' date check');
298 }
299 });
300
301 test('strict ordinal parsing', function (assert) {
302 var i, ordinalStr, testMoment;
303 for (i = 1; i <= 31; ++i) {
304 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
305 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
306 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
307 }
308 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('tzm-latn');
3
4 test('parse', function (assert) {
5 var tests = 'innayr innayr_brˤayrˤ brˤayrˤ_marˤsˤ marˤsˤ_ibrir ibrir_mayyw mayyw_ywnyw ywnyw_ywlywz ywlywz_ɣwšt ɣwšt_šwtanbir šwtanbir_ktˤwbrˤ ktˤwbrˤ_nwwanbir nwwanbir_dwjnbir dwjnbir'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'asamas, brˤayrˤ 14 2010, 3:25:50 pm'],
25 ['ddd, hA', 'asamas, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2 02 brˤayrˤ brˤayrˤ'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 asamas asamas asamas'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '8 8 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 brˤayrˤ 2010'],
41 ['LLL', '14 brˤayrˤ 2010 15:25'],
42 ['LLLL', 'asamas 14 brˤayrˤ 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 brˤayrˤ 2010'],
45 ['lll', '14 brˤayrˤ 2010 15:25'],
46 ['llll', 'asamas 14 brˤayrˤ 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'innayr innayr_brˤayrˤ brˤayrˤ_marˤsˤ marˤsˤ_ibrir ibrir_mayyw mayyw_ywnyw ywnyw_ywlywz ywlywz_ɣwšt ɣwšt_šwtanbir šwtanbir_ktˤwbrˤ ktˤwbrˤ_nwwanbir nwwanbir_dwjnbir dwjnbir'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'asamas asamas asamas_aynas aynas aynas_asinas asinas asinas_akras akras akras_akwas akwas akwas_asimwas asimwas asimwas_asiḍyas asiḍyas asiḍyas'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'imik', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'minuḍ', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'minuḍ', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 minuḍ', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 minuḍ', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'saɛa', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'saɛa', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 tassaɛin', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 tassaɛin', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 tassaɛin', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ass', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ass', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ossan', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ass', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ossan', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ossan', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ayowr', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ayowr', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ayowr', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 iyyirn', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 iyyirn', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 iyyirn', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ayowr', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 iyyirn', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'asgas', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 isgasn', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'asgas', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 isgasn', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'dadkh s yan imik', 'prefix');
140 assert.equal(moment(0).from(30000), 'yan imik', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'yan imik', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'dadkh s yan imik', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'dadkh s yan 5 ossan', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'asdkh g 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'asdkh g 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'asdkh g 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'aska g 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'asdkh g 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'assant g 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('dddd [g] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('weeks year starting sunday', function (assert) {
202 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
203 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
204 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
205 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
206 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
207 });
208
209 test('weeks year starting monday', function (assert) {
210 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
211 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
212 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
213 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
214 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
215 });
216
217 test('weeks year starting tuesday', function (assert) {
218 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
219 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
220 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
221 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
222 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
223 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
224 });
225
226 test('weeks year starting wednesday', function (assert) {
227 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
228 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
229 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
230 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
231 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
232 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
233 });
234
235 test('weeks year starting thursday', function (assert) {
236 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
237 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
238 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
239 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
240 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
241 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
242 });
243
244 test('weeks year starting friday', function (assert) {
245 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
246 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
247 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
248 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
249 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
250 });
251
252 test('weeks year starting saturday', function (assert) {
253 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
254 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
255 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
256 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
257 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
258 });
259
260 test('weeks year starting sunday formatted', function (assert) {
261 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
262 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
263 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 should be week 2');
264 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2');
265 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
266 });
267
268 test('lenient ordinal parsing', function (assert) {
269 var i, ordinalStr, testMoment;
270 for (i = 1; i <= 31; ++i) {
271 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
272 testMoment = moment(ordinalStr, 'YYYY MM Do');
273 assert.equal(testMoment.year(), 2014,
274 'lenient ordinal parsing ' + i + ' year check');
275 assert.equal(testMoment.month(), 0,
276 'lenient ordinal parsing ' + i + ' month check');
277 assert.equal(testMoment.date(), i,
278 'lenient ordinal parsing ' + i + ' date check');
279 }
280 });
281
282 test('lenient ordinal parsing of number', function (assert) {
283 var i, testMoment;
284 for (i = 1; i <= 31; ++i) {
285 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
286 assert.equal(testMoment.year(), 2014,
287 'lenient ordinal parsing of number ' + i + ' year check');
288 assert.equal(testMoment.month(), 0,
289 'lenient ordinal parsing of number ' + i + ' month check');
290 assert.equal(testMoment.date(), i,
291 'lenient ordinal parsing of number ' + i + ' date check');
292 }
293 });
294
295 test('strict ordinal parsing', function (assert) {
296 var i, ordinalStr, testMoment;
297 for (i = 1; i <= 31; ++i) {
298 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
299 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
300 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
301 }
302 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('tzm');
3
4 test('parse', function (assert) {
5 var tests = 'ⵉⵏⵏⴰⵢⵔ ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, h:mm:ss a', 'ⴰⵙⴰⵎⴰⵙ, ⴱⵕⴰⵢⵕ 14 2010, 3:25:50 pm'],
25 ['ddd, hA', 'ⴰⵙⴰⵎⴰⵙ, 3PM'],
26 ['M Mo MM MMMM MMM', '2 2 02 ⴱⵕⴰⵢⵕ ⴱⵕⴰⵢⵕ'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '8 8 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[the] DDDo [day of the year]', 'the 45 day of the year'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 ⴱⵕⴰⵢⵕ 2010'],
41 ['LLL', '14 ⴱⵕⴰⵢⵕ 2010 15:25'],
42 ['LLLL', 'ⴰⵙⴰⵎⴰⵙ 14 ⴱⵕⴰⵢⵕ 2010 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 ⴱⵕⴰⵢⵕ 2010'],
45 ['lll', '14 ⴱⵕⴰⵢⵕ 2010 15:25'],
46 ['llll', 'ⴰⵙⴰⵎⴰⵙ 14 ⴱⵕⴰⵢⵕ 2010 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'ⵉⵏⵏⴰⵢⵔ ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ ⴷⵓⵊⵏⴱⵉⵔ'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ ⴰⵢⵏⴰⵙ ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ ⴰⵙⵉⵏⴰⵙ ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ ⴰⴽⵔⴰⵙ ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ ⴰⴽⵡⴰⵙ ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ ⴰⵙⵉⵎⵡⴰⵙ ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ ⴰⵙⵉⴹⵢⴰⵙ ⴰⵙⵉⴹⵢⴰⵙ'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ⵉⵎⵉⴽ', '44 seconds = a few seconds');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ⵎⵉⵏⵓⴺ', '45 seconds = a minute');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ⵎⵉⵏⵓⴺ', '89 seconds = a minute');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 ⵎⵉⵏⵓⴺ', '90 seconds = 2 minutes');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 ⵎⵉⵏⵓⴺ', '44 minutes = 44 minutes');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ⵙⴰⵄⴰ', '45 minutes = an hour');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ⵙⴰⵄⴰ', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 ⵜⴰⵙⵙⴰⵄⵉⵏ', '90 minutes = 2 hours');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 ⵜⴰⵙⵙⴰⵄⵉⵏ', '5 hours = 5 hours');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 ⵜⴰⵙⵙⴰⵄⵉⵏ', '21 hours = 21 hours');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ⴰⵙⵙ', '22 hours = a day');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ⴰⵙⵙ', '35 hours = a day');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 oⵙⵙⴰⵏ', '36 hours = 2 days');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ⴰⵙⵙ', '1 day = a day');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 oⵙⵙⴰⵏ', '5 days = 5 days');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 oⵙⵙⴰⵏ', '25 days = 25 days');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ⴰⵢoⵓⵔ', '26 days = a month');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ⴰⵢoⵓⵔ', '30 days = a month');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ⴰⵢoⵓⵔ', '43 days = a month');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ⵉⵢⵢⵉⵔⵏ', '46 days = 2 months');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ⵉⵢⵢⵉⵔⵏ', '75 days = 2 months');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ⵉⵢⵢⵉⵔⵏ', '76 days = 3 months');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ⴰⵢoⵓⵔ', '1 month = a month');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ⵉⵢⵢⵉⵔⵏ', '5 months = 5 months');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ⴰⵙⴳⴰⵙ', '345 days = a year');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ⵉⵙⴳⴰⵙⵏ', '548 days = 2 years');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ⴰⵙⴳⴰⵙ', '1 year = a year');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ⵉⵙⴳⴰⵙⵏ', '5 years = 5 years');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ ⵉⵎⵉⴽ', 'prefix');
140 assert.equal(moment(0).from(30000), 'ⵢⴰⵏ ⵉⵎⵉⴽ', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'ⵢⴰⵏ ⵉⵎⵉⴽ', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ ⵉⵎⵉⴽ', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ 5 oⵙⵙⴰⵏ', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:00', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:25', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 03:00', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'ⴰⵙⴽⴰ ⴴ 02:00', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 01:00', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'ⴰⵚⴰⵏⵜ ⴴ 02:00', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177 for (i = 2; i < 7; i++) {
178 m = moment().subtract({d: i});
179 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today - ' + i + ' days current time');
180 m.hours(0).minutes(0).seconds(0).milliseconds(0);
181 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today - ' + i + ' days beginning of day');
182 m.hours(23).minutes(59).seconds(59).milliseconds(999);
183 assert.equal(m.calendar(), m.format('dddd [ⴴ] LT'), 'Today - ' + i + ' days end of day');
184 }
185 });
186
187 test('calendar all else', function (assert) {
188 var weeksAgo = moment().subtract({w: 1}),
189 weeksFromNow = moment().add({w: 1});
190
191 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
192 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
193
194 weeksAgo = moment().subtract({w: 2});
195 weeksFromNow = moment().add({w: 2});
196
197 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
198 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
199 });
200
201 test('weeks year starting sunday', function (assert) {
202 assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
203 assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
204 assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
205 assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
206 assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
207 });
208
209 test('weeks year starting monday', function (assert) {
210 assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
211 assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
212 assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
213 assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
214 assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
215 });
216
217 test('weeks year starting tuesday', function (assert) {
218 assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
219 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
220 assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
221 assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
222 assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
223 assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
224 });
225
226 test('weeks year starting wednesday', function (assert) {
227 assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
228 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
229 assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
230 assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
231 assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
232 assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
233 });
234
235 test('weeks year starting thursday', function (assert) {
236 assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
237 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
238 assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
239 assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
240 assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
241 assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
242 });
243
244 test('weeks year starting friday', function (assert) {
245 assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
246 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
247 assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
248 assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
249 assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
250 });
251
252 test('weeks year starting saturday', function (assert) {
253 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
254 assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
255 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
256 assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
257 assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
258 });
259
260 test('weeks year starting sunday formatted', function (assert) {
261 assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
262 assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
263 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 should be week 2');
264 assert.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', 'Jan 13 2012 should be week 2');
265 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
266 });
267
268 test('lenient ordinal parsing', function (assert) {
269 var i, ordinalStr, testMoment;
270 for (i = 1; i <= 31; ++i) {
271 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
272 testMoment = moment(ordinalStr, 'YYYY MM Do');
273 assert.equal(testMoment.year(), 2014,
274 'lenient ordinal parsing ' + i + ' year check');
275 assert.equal(testMoment.month(), 0,
276 'lenient ordinal parsing ' + i + ' month check');
277 assert.equal(testMoment.date(), i,
278 'lenient ordinal parsing ' + i + ' date check');
279 }
280 });
281
282 test('lenient ordinal parsing of number', function (assert) {
283 var i, testMoment;
284 for (i = 1; i <= 31; ++i) {
285 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
286 assert.equal(testMoment.year(), 2014,
287 'lenient ordinal parsing of number ' + i + ' year check');
288 assert.equal(testMoment.month(), 0,
289 'lenient ordinal parsing of number ' + i + ' month check');
290 assert.equal(testMoment.date(), i,
291 'lenient ordinal parsing of number ' + i + ' date check');
292 }
293 });
294
295 test('strict ordinal parsing', function (assert) {
296 var i, ordinalStr, testMoment;
297 for (i = 1; i <= 31; ++i) {
298 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
299 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
300 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
301 }
302 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('uk');
3
4 test('parse', function (assert) {
5 var tests = 'січень січ_лютий лют_березень бер_квітень квіт_травень трав_червень черв_липень лип_серпень серп_вересень вер_жовтень жовт_листопад лист_грудень груд'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do MMMM YYYY, HH:mm:ss', 'неділя, 14-го лютого 2010, 15:25:50'],
25 ['ddd, h A', 'нд, 3 дня'],
26 ['M Mo MM MMMM MMM', '2 2-й 02 лютий лют'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14-го 14'],
29 ['d do dddd ddd dd', '0 0-й неділя нд нд'],
30 ['DDD DDDo DDDD', '45 45-й 045'],
31 ['w wo ww', '7 7-й 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'дня дня'],
37 ['DDDo [день року]', '45-й день року'],
38 ['LTS', '15:25:50'],
39 ['L', '14.02.2010'],
40 ['LL', '14 лютого 2010 р.'],
41 ['LLL', '14 лютого 2010 р., 15:25'],
42 ['LLLL', 'неділя, 14 лютого 2010 р., 15:25']
43 ],
44 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
45 i;
46 for (i = 0; i < a.length; i++) {
47 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
48 }
49 });
50
51 test('format meridiem', function (assert) {
52 assert.equal(moment([2012, 11, 28, 0, 0]).format('A'), 'ночі', 'night');
53 assert.equal(moment([2012, 11, 28, 3, 59]).format('A'), 'ночі', 'night');
54 assert.equal(moment([2012, 11, 28, 4, 0]).format('A'), 'ранку', 'morning');
55 assert.equal(moment([2012, 11, 28, 11, 59]).format('A'), 'ранку', 'morning');
56 assert.equal(moment([2012, 11, 28, 12, 0]).format('A'), 'дня', 'afternoon');
57 assert.equal(moment([2012, 11, 28, 16, 59]).format('A'), 'дня', 'afternoon');
58 assert.equal(moment([2012, 11, 28, 17, 0]).format('A'), 'вечора', 'evening');
59 assert.equal(moment([2012, 11, 28, 23, 59]).format('A'), 'вечора', 'evening');
60 });
61
62 test('format ordinal', function (assert) {
63 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-й', '1-й');
64 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-й', '2-й');
65 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-й', '3-й');
66 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-й', '4-й');
67 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-й', '5-й');
68 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-й', '6-й');
69 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-й', '7-й');
70 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-й', '8-й');
71 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-й', '9-й');
72 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-й', '10-й');
73
74 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-й', '11-й');
75 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-й', '12-й');
76 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-й', '13-й');
77 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-й', '14-й');
78 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-й', '15-й');
79 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-й', '16-й');
80 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-й', '17-й');
81 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-й', '18-й');
82 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-й', '19-й');
83 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-й', '20-й');
84
85 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-й', '21-й');
86 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-й', '22-й');
87 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-й', '23-й');
88 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-й', '24-й');
89 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-й', '25-й');
90 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-й', '26-й');
91 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-й', '27-й');
92 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-й', '28-й');
93 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-й', '29-й');
94 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-й', '30-й');
95
96 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-й', '31-й');
97 });
98
99 test('format month', function (assert) {
100 var expected = 'січень січ_лютий лют_березень бер_квітень квіт_травень трав_червень черв_липень лип_серпень серп_вересень вер_жовтень жовт_листопад лист_грудень груд'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
103 }
104 });
105
106 test('format month case', function (assert) {
107 var months = {
108 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
109 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
110 }, i;
111 for (i = 0; i < 12; i++) {
112 assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
113 assert.equal(moment([2011, i, 1]).format('MMMM'), months.nominative[i], '1 ' + months.nominative[i]);
114 }
115 });
116
117 test('format week', function (assert) {
118 var expected = 'неділя нд нд_понеділок пн пн_вівторок вт вт_середа ср ср_четвер чт чт_п’ятниця пт пт_субота сб сб'.split('_'), i;
119 for (i = 0; i < expected.length; i++) {
120 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
121 }
122 });
123
124 test('from', function (assert) {
125 var start = moment([2007, 1, 28]);
126 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'декілька секунд', '44 seconds = seconds');
127 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'хвилина', '45 seconds = a minute');
128 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'хвилина', '89 seconds = a minute');
129 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 хвилини', '90 seconds = 2 minutes');
130 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 хвилини', '44 minutes = 44 minutes');
131 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'годину', '45 minutes = an hour');
132 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'годину', '89 minutes = an hour');
133 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 години', '90 minutes = 2 hours');
134 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 годин', '5 hours = 5 hours');
135 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 година', '21 hours = 21 hours');
136 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'день', '22 hours = a day');
137 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'день', '35 hours = a day');
138 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 дні', '36 hours = 2 days');
139 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'день', '1 day = a day');
140 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 днів', '5 days = 5 days');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 11}), true), '11 днів', '11 days = 11 days');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 21}), true), '21 день', '21 days = 21 days');
143 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 днів', '25 days = 25 days');
144 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'місяць', '26 days = a month');
145 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'місяць', '30 days = a month');
146 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'місяць', '43 days = a month');
147 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 місяці', '46 days = 2 months');
148 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 місяці', '75 days = 2 months');
149 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 місяці', '76 days = 3 months');
150 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'місяць', '1 month = a month');
151 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 місяців', '5 months = 5 months');
152 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'рік', '345 days = a year');
153 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 роки', '548 days = 2 years');
154 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'рік', '1 year = a year');
155 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 років', '5 years = 5 years');
156 });
157
158 test('suffix', function (assert) {
159 assert.equal(moment(30000).from(0), 'за декілька секунд', 'prefix');
160 assert.equal(moment(0).from(30000), 'декілька секунд тому', 'suffix');
161 });
162
163 test('fromNow', function (assert) {
164 assert.equal(moment().add({s: 30}).fromNow(), 'за декілька секунд', 'in seconds');
165 assert.equal(moment().add({d: 5}).fromNow(), 'за 5 днів', 'in 5 days');
166 });
167
168 test('calendar day', function (assert) {
169 var a = moment().hours(2).minutes(0).seconds(0);
170
171 assert.equal(moment(a).calendar(), 'Сьогодні о 02:00', 'today at the same time');
172 assert.equal(moment(a).add({m: 25}).calendar(), 'Сьогодні о 02:25', 'Now plus 25 min');
173 assert.equal(moment(a).add({h: 1}).calendar(), 'Сьогодні о 03:00', 'Now plus 1 hour');
174 assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра о 02:00', 'tomorrow at the same time');
175 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сьогодні о 01:00', 'Now minus 1 hour');
176 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчора о 02:00', 'yesterday at the same time');
177 // A special case for Ukrainian since 11 hours have different preposition
178 assert.equal(moment(a).add({h: 9}).calendar(), 'Сьогодні об 11:00', 'same day at 11 o\'clock');
179 });
180
181 test('calendar next week', function (assert) {
182 var i, m;
183 for (i = 2; i < 7; i++) {
184 m = moment().add({d: i});
185 assert.equal(m.calendar(), m.format('[У] dddd [о' + (m.hours() === 11 ? 'б' : '') + '] LT'), 'Today + ' + i + ' days current time');
186 m.hours(0).minutes(0).seconds(0).milliseconds(0);
187 assert.equal(m.calendar(), m.format('[У] dddd [о] LT'), 'Today + ' + i + ' days beginning of day');
188 m.hours(23).minutes(59).seconds(59).milliseconds(999);
189 assert.equal(m.calendar(), m.format('[У] dddd [о] LT'), 'Today + ' + i + ' days end of day');
190 }
191 });
192
193 test('calendar last week', function (assert) {
194 var i, m;
195
196 function makeFormat(d) {
197 switch (d.day()) {
198 case 0:
199 case 3:
200 case 5:
201 case 6:
202 return '[Минулої] dddd [о' + (d.hours() === 11 ? 'б' : '') + '] LT';
203 case 1:
204 case 2:
205 case 4:
206 return '[Минулого] dddd [о' + (d.hours() === 11 ? 'б' : '') + '] LT';
207 }
208 }
209
210 for (i = 2; i < 7; i++) {
211 m = moment().subtract({d: i});
212 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days current time');
213 m.hours(0).minutes(0).seconds(0).milliseconds(0);
214 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days beginning of day');
215 m.hours(23).minutes(59).seconds(59).milliseconds(999);
216 assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today - ' + i + ' days end of day');
217 }
218 });
219
220 test('calendar all else', function (assert) {
221 var weeksAgo = moment().subtract({w: 1}),
222 weeksFromNow = moment().add({w: 1});
223
224 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
225 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
226
227 weeksAgo = moment().subtract({w: 2});
228 weeksFromNow = moment().add({w: 2});
229
230 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
231 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
232 });
233
234 test('weeks year starting sunday', function (assert) {
235 assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
236 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
237 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
238 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
239 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
240 });
241
242 test('weeks year starting monday', function (assert) {
243 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
244 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
245 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
246 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
247 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
248 });
249
250 test('weeks year starting tuesday', function (assert) {
251 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
252 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
253 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
254 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
255 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
256 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
257 });
258
259 test('weeks year starting wednesday', function (assert) {
260 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
261 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
262 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
263 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
264 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
265 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
266 });
267
268 test('weeks year starting thursday', function (assert) {
269 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
270 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
271 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
272 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
273 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
274 assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
275 });
276
277 test('weeks year starting friday', function (assert) {
278 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
279 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
280 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
281 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
282 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
283 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
284 });
285
286 test('weeks year starting saturday', function (assert) {
287 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
288 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
289 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
290 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
291 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
292 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
293 });
294
295 test('weeks year starting sunday formatted', function (assert) {
296 assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-й', 'Dec 26 2011 should be week 1');
297 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-й', 'Jan 1 2012 should be week 1');
298 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-й', 'Jan 2 2012 should be week 2');
299 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-й', 'Jan 8 2012 should be week 2');
300 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-й', 'Jan 9 2012 should be week 3');
301 });
302
303 test('lenient ordinal parsing', function (assert) {
304 var i, ordinalStr, testMoment;
305 for (i = 1; i <= 31; ++i) {
306 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
307 testMoment = moment(ordinalStr, 'YYYY MM Do');
308 assert.equal(testMoment.year(), 2014,
309 'lenient ordinal parsing ' + i + ' year check');
310 assert.equal(testMoment.month(), 0,
311 'lenient ordinal parsing ' + i + ' month check');
312 assert.equal(testMoment.date(), i,
313 'lenient ordinal parsing ' + i + ' date check');
314 }
315 });
316
317 test('lenient ordinal parsing of number', function (assert) {
318 var i, testMoment;
319 for (i = 1; i <= 31; ++i) {
320 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
321 assert.equal(testMoment.year(), 2014,
322 'lenient ordinal parsing of number ' + i + ' year check');
323 assert.equal(testMoment.month(), 0,
324 'lenient ordinal parsing of number ' + i + ' month check');
325 assert.equal(testMoment.date(), i,
326 'lenient ordinal parsing of number ' + i + ' date check');
327 }
328 });
329
330 test('strict ordinal parsing', function (assert) {
331 var i, ordinalStr, testMoment;
332 for (i = 1; i <= 31; ++i) {
333 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
334 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
335 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
336 }
337 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('uz');
3
4 test('parse', function (assert) {
5 var tests = 'январь янв_февраль фев_март мар_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, Do-MMMM YYYY, h:mm:ss', 'Якшанба, 14-февраль 2010, 3:25:50'],
25 ['ddd, h:mm', 'Якш, 3:25'],
26 ['M Mo MM MMMM MMM', '2 2 02 февраль фев'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14 14'],
29 ['d do dddd ddd dd', '0 0 Якшанба Якш Як'],
30 ['DDD DDDo DDDD', '45 45 045'],
31 ['w wo ww', '7 7 07'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', 'pm PM'],
37 ['[йилнинг] DDDo-[куни]', 'йилнинг 45-куни'],
38 ['LTS', '15:25:50'],
39 ['L', '14/02/2010'],
40 ['LL', '14 февраль 2010'],
41 ['LLL', '14 февраль 2010 15:25'],
42 ['LLLL', '14 февраль 2010, Якшанба 15:25'],
43 ['l', '14/2/2010'],
44 ['ll', '14 фев 2010'],
45 ['lll', '14 фев 2010 15:25'],
46 ['llll', '14 фев 2010, Якш 15:25']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50 for (i = 0; i < a.length; i++) {
51 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
52 }
53 });
54
55 test('format ordinal', function (assert) {
56 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
57 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
58 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
59 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
60 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
61 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
62 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
63 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
64 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
65 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
66
67 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
68 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
69 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
70 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
71 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
72 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
73 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
74 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
75 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
76 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
77
78 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
79 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
80 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
81 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
82 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
83 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
84 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
85 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
86 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
87 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
88
89 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
90 });
91
92 test('format month', function (assert) {
93 var expected = 'январь янв_февраль фев_март мар_апрель апр_май май_июнь июн_июль июл_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
94 for (i = 0; i < expected.length; i++) {
95 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
96 }
97 });
98
99 test('format week', function (assert) {
100 var expected = 'Якшанба Якш Як_Душанба Душ Ду_Сешанба Сеш Се_Чоршанба Чор Чо_Пайшанба Пай Па_Жума Жум Жу_Шанба Шан Ша'.split('_'), i;
101 for (i = 0; i < expected.length; i++) {
102 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
103 }
104 });
105
106 test('from', function (assert) {
107 var start = moment([2007, 1, 28]);
108 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'фурсат', '44 секунд = фурсат');
109 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'бир дакика', '45 секунд = бир дакика');
110 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'бир дакика', '89 секунд = бир дакика');
111 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 дакика', '90 секунд = 2 дакика');
112 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 дакика', '44 дакика = 44 дакика');
113 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'бир соат', '45 минут = бир соат');
114 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'бир соат', '89 minutes = an hour');
115 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 соат', '90 минут = 2 соат');
116 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 соат', '5 соат = 5 соат');
117 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 соат', '21 соат = 21 соат');
118 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'бир кун', '22 соат = бир кун');
119 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'бир кун', '35 соат = бир кун');
120 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 кун', '36 соат = 2 кун');
121 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'бир кун', '1 кун = 1 кун');
122 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 кун', '5 кун = 5 кун');
123 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 кун', '25 кун = 25 кун');
124 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'бир ой', '26 кун = бир ой');
125 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'бир ой', '30 кун = бир ой');
126 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'бир ой', '45 кун = бир ой');
127 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ой', '46 кун = 2 ой');
128 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ой', '75 кун = 2 ой');
129 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ой', '76 кун = 3 ой');
130 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'бир ой', 'бир ой = бир ой');
131 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ой', '5 ой = 5 ой');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'бир йил', '345 кун = бир йил');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 йил', '548 кун = 2 йил');
134 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'бир йил', '1 йил = бир йил');
135 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 йил', '5 йил = 5 йил');
136 });
137
138 test('suffix', function (assert) {
139 assert.equal(moment(30000).from(0), 'Якин фурсат ичида', 'prefix');
140 assert.equal(moment(0).from(30000), 'Бир неча фурсат олдин', 'suffix');
141 });
142
143 test('now from now', function (assert) {
144 assert.equal(moment().fromNow(), 'Бир неча фурсат олдин', 'now from now should display as in the past');
145 });
146
147 test('fromNow', function (assert) {
148 assert.equal(moment().add({s: 30}).fromNow(), 'Якин фурсат ичида', 'in a few seconds');
149 assert.equal(moment().add({d: 5}).fromNow(), 'Якин 5 кун ичида', 'in 5 days');
150 });
151
152 test('calendar day', function (assert) {
153 var a = moment().hours(2).minutes(0).seconds(0);
154
155 assert.equal(moment(a).calendar(), 'Бугун соат 02:00 да', 'today at the same time');
156 assert.equal(moment(a).add({m: 25}).calendar(), 'Бугун соат 02:25 да', 'Now plus 25 min');
157 assert.equal(moment(a).add({h: 1}).calendar(), 'Бугун соат 03:00 да', 'Now plus 1 hour');
158 assert.equal(moment(a).add({d: 1}).calendar(), 'Эртага 02:00 да', 'tomorrow at the same time');
159 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бугун соат 01:00 да', 'Now minus 1 hour');
160 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеча соат 02:00 да', 'yesterday at the same time');
161 });
162
163 test('calendar next week', function (assert) {
164 var i, m;
165 for (i = 2; i < 7; i++) {
166 m = moment().add({d: i});
167 assert.equal(m.calendar(), m.format('dddd [куни соат] LT [да]'), 'Today + ' + i + ' days current time');
168 m.hours(0).minutes(0).seconds(0).milliseconds(0);
169 assert.equal(m.calendar(), m.format('dddd [куни соат] LT [да]'), 'Today + ' + i + ' days beginning of day');
170 m.hours(23).minutes(59).seconds(59).milliseconds(999);
171 assert.equal(m.calendar(), m.format('dddd [куни соат] LT [да]'), 'Today + ' + i + ' days end of day');
172 }
173 });
174
175 test('calendar last week', function (assert) {
176 var i, m;
177
178 for (i = 2; i < 7; i++) {
179 m = moment().subtract({d: i});
180 assert.equal(m.calendar(), m.format('[Утган] dddd [куни соат] LT [да]'), 'Today - ' + i + ' days current time');
181 m.hours(0).minutes(0).seconds(0).milliseconds(0);
182 assert.equal(m.calendar(), m.format('[Утган] dddd [куни соат] LT [да]'), 'Today - ' + i + ' days beginning of day');
183 m.hours(23).minutes(59).seconds(59).milliseconds(999);
184 assert.equal(m.calendar(), m.format('[Утган] dddd [куни соат] LT [да]'), 'Today - ' + i + ' days end of day');
185 }
186 });
187
188 test('calendar all else', function (assert) {
189 var weeksAgo = moment().subtract({w: 1}),
190 weeksFromNow = moment().add({w: 1});
191
192 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
193 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
194
195 weeksAgo = moment().subtract({w: 2});
196 weeksFromNow = moment().add({w: 2});
197
198 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
199 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
200 });
201
202 test('weeks year starting sunday', function (assert) {
203 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 52');
204 assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 1');
205 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 1');
206 assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 2');
207 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 2');
208 });
209
210 test('weeks year starting monday', function (assert) {
211 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
212 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
213 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
214 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
215 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
216 });
217
218 test('weeks year starting tuesday', function (assert) {
219 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
220 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
221 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
222 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
223 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
224 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
225 });
226
227 test('weeks year starting wednesday', function (assert) {
228 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
229 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
230 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
231 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
232 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
233 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
234 });
235
236 test('weeks year starting thursday', function (assert) {
237 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
238 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
239 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
240 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
241 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
242 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
243 });
244
245 test('weeks year starting friday', function (assert) {
246 assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 53');
247 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 53');
248 assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 53');
249 assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 1');
250 assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 1');
251 assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 2');
252 });
253
254 test('weeks year starting saturday', function (assert) {
255 assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 52');
256 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 52');
257 assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 52');
258 assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 1');
259 assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 1');
260 assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 2');
261 });
262
263 test('weeks year starting sunday formatted', function (assert) {
264 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 52');
265 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 1');
266 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 1');
267 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 2');
268 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 2');
269 });
270
271 test('lenient ordinal parsing', function (assert) {
272 var i, ordinalStr, testMoment;
273 for (i = 1; i <= 31; ++i) {
274 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
275 testMoment = moment(ordinalStr, 'YYYY MM Do');
276 assert.equal(testMoment.year(), 2014,
277 'lenient ordinal parsing ' + i + ' year check');
278 assert.equal(testMoment.month(), 0,
279 'lenient ordinal parsing ' + i + ' month check');
280 assert.equal(testMoment.date(), i,
281 'lenient ordinal parsing ' + i + ' date check');
282 }
283 });
284
285 test('lenient ordinal parsing of number', function (assert) {
286 var i, testMoment;
287 for (i = 1; i <= 31; ++i) {
288 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
289 assert.equal(testMoment.year(), 2014,
290 'lenient ordinal parsing of number ' + i + ' year check');
291 assert.equal(testMoment.month(), 0,
292 'lenient ordinal parsing of number ' + i + ' month check');
293 assert.equal(testMoment.date(), i,
294 'lenient ordinal parsing of number ' + i + ' date check');
295 }
296 });
297
298 test('strict ordinal parsing', function (assert) {
299 var i, ordinalStr, testMoment;
300 for (i = 1; i <= 31; ++i) {
301 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
302 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
303 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
304 }
305 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('vi');
3
4 test('parse', function (assert) {
5 var i,
6 tests = 'tháng 1,Th01_tháng 2,Th02_tháng 3,Th03_tháng 4,Th04_tháng 5,Th05_tháng 6,Th06_tháng 7,Th07_tháng 8,Th08_tháng 9,Th09_tháng 10,Th10_tháng 11,Th11_tháng 12,Th12'.split('_');
7
8 function equalTest(input, mmm, i) {
9 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + i);
10 }
11
12 for (i = 0; i < 12; i++) {
13 tests[i] = tests[i].split(',');
14 equalTest(tests[i][0], '[tháng] M', i);
15 equalTest(tests[i][1], '[Th]M', i);
16 equalTest(tests[i][0], '[tháng] MM', i);
17 equalTest(tests[i][1], '[Th]MM', i);
18 equalTest(tests[i][0].toLocaleLowerCase(), '[THÁNG] M', i);
19 equalTest(tests[i][1].toLocaleLowerCase(), '[TH]M', i);
20 equalTest(tests[i][0].toLocaleUpperCase(), '[THÁNG] MM', i);
21 equalTest(tests[i][1].toLocaleUpperCase(), '[TH]MM', i);
22 }
23 });
24
25 test('format', function (assert) {
26 var a = [
27 ['dddd, MMMM Do YYYY, h:mm:ss a', 'chủ nhật, tháng 2 14 2010, 3:25:50 pm'],
28 ['ddd, hA', 'CN, 3PM'],
29 ['M Mo MM MMMM MMM', '2 2 02 tháng 2 Th02'],
30 ['YYYY YY', '2010 10'],
31 ['D Do DD', '14 14 14'],
32 ['d do dddd ddd dd', '0 0 chủ nhật CN CN'],
33 ['DDD DDDo DDDD', '45 45 045'],
34 ['w wo ww', '6 6 06'],
35 ['h hh', '3 03'],
36 ['H HH', '15 15'],
37 ['m mm', '25 25'],
38 ['s ss', '50 50'],
39 ['a A', 'pm PM'],
40 ['[ngày thứ] DDDo [của năm]', 'ngày thứ 45 của năm'],
41 ['LTS', '15:25:50'],
42 ['L', '14/02/2010'],
43 ['LL', '14 tháng 2 năm 2010'],
44 ['LLL', '14 tháng 2 năm 2010 15:25'],
45 ['LLLL', 'chủ nhật, 14 tháng 2 năm 2010 15:25'],
46 ['l', '14/2/2010'],
47 ['ll', '14 Th02 2010'],
48 ['lll', '14 Th02 2010 15:25'],
49 ['llll', 'CN, 14 Th02 2010 15:25']
50 ],
51 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
52 i;
53
54 for (i = 0; i < a.length; i++) {
55 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
56 }
57 });
58
59 test('format ordinal', function (assert) {
60 assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
61 assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
62 assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
63 assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
64 assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
65 assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
66 assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
67 assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
68 assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
69 assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
70
71 assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
72 assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
73 assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
74 assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
75 assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
76 assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
77 assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
78 assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
79 assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
80 assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
81
82 assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
83 assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
84 assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
85 assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
86 assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
87 assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
88 assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
89 assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
90 assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
91 assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
92
93 assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
94 });
95
96 test('format month', function (assert) {
97 var i,
98 expected = 'tháng 1,Th01_tháng 2,Th02_tháng 3,Th03_tháng 4,Th04_tháng 5,Th05_tháng 6,Th06_tháng 7,Th07_tháng 8,Th08_tháng 9,Th09_tháng 10,Th10_tháng 11,Th11_tháng 12,Th12'.split('_');
99
100 for (i = 0; i < expected.length; i++) {
101 assert.equal(moment([2011, i, 1]).format('MMMM,MMM'), expected[i], expected[i]);
102 }
103 });
104
105 test('format week', function (assert) {
106 var i,
107 expected = 'chủ nhật CN CN_thứ hai T2 T2_thứ ba T3 T3_thứ tư T4 T4_thứ năm T5 T5_thứ sáu T6 T6_thứ bảy T7 T7'.split('_');
108
109 for (i = 0; i < expected.length; i++) {
110 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
111 }
112 });
113
114 test('from', function (assert) {
115 var start = moment([2007, 1, 28]);
116
117 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'vài giây', '44 seconds = a few seconds');
118 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'một phút', '45 seconds = a minute');
119 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'một phút', '89 seconds = a minute');
120 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 phút', '90 seconds = 2 minutes');
121 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 phút', '44 minutes = 44 minutes');
122 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'một giờ', '45 minutes = an hour');
123 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'một giờ', '89 minutes = an hour');
124 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 giờ', '90 minutes = 2 hours');
125 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 giờ', '5 hours = 5 hours');
126 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 giờ', '21 hours = 21 hours');
127 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'một ngày', '22 hours = a day');
128 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'một ngày', '35 hours = a day');
129 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 ngày', '36 hours = 2 days');
130 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'một ngày', '1 day = a day');
131 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 ngày', '5 days = 5 days');
132 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 ngày', '25 days = 25 days');
133 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'một tháng', '26 days = a month');
134 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'một tháng', '30 days = a month');
135 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'một tháng', '43 days = a month');
136 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 tháng', '46 days = 2 months');
137 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 tháng', '75 days = 2 months');
138 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 tháng', '76 days = 3 months');
139 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'một tháng', '1 month = a month');
140 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 tháng', '5 months = 5 months');
141 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'một năm', '345 days = a year');
142 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 năm', '548 days = 2 years');
143 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'một năm', '1 year = a year');
144 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 năm', '5 years = 5 years');
145 });
146
147 test('suffix', function (assert) {
148 assert.equal(moment(30000).from(0), 'vài giây tới', 'prefix');
149 assert.equal(moment(0).from(30000), 'vài giây trước', 'suffix');
150 });
151
152 test('now from now', function (assert) {
153 assert.equal(moment().fromNow(), 'vài giây trước', 'now from now should display as in the past');
154 });
155
156 test('fromNow', function (assert) {
157 assert.equal(moment().add({s: 30}).fromNow(), 'vài giây tới', 'in a few seconds');
158 assert.equal(moment().add({d: 5}).fromNow(), '5 ngày tới', 'in 5 days');
159 });
160
161 test('calendar day', function (assert) {
162 var a = moment().hours(2).minutes(0).seconds(0);
163
164 assert.equal(moment(a).calendar(), 'Hôm nay lúc 02:00', 'today at the same time');
165 assert.equal(moment(a).add({m: 25}).calendar(), 'Hôm nay lúc 02:25', 'Now plus 25 min');
166 assert.equal(moment(a).add({h: 1}).calendar(), 'Hôm nay lúc 03:00', 'Now plus 1 hour');
167 assert.equal(moment(a).add({d: 1}).calendar(), 'Ngày mai lúc 02:00', 'tomorrow at the same time');
168 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hôm nay lúc 01:00', 'Now minus 1 hour');
169 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hôm qua lúc 02:00', 'yesterday at the same time');
170 });
171
172 test('calendar next week', function (assert) {
173 var i, m;
174
175 for (i = 2; i < 7; i++) {
176 m = moment().add({d: i});
177 assert.equal(m.calendar(), m.format('dddd [tuần tới lúc] LT'), 'Today + ' + i + ' days current time');
178 m.hours(0).minutes(0).seconds(0).milliseconds(0);
179 assert.equal(m.calendar(), m.format('dddd [tuần tới lúc] LT'), 'Today + ' + i + ' days beginning of day');
180 m.hours(23).minutes(59).seconds(59).milliseconds(999);
181 assert.equal(m.calendar(), m.format('dddd [tuần tới lúc] LT'), 'Today + ' + i + ' days end of day');
182 }
183 });
184
185 test('calendar last week', function (assert) {
186 var i, m;
187
188 for (i = 2; i < 7; i++) {
189 m = moment().subtract({d: i});
190 assert.equal(m.calendar(), m.format('dddd [tuần rồi lúc] LT'), 'Today - ' + i + ' days current time');
191 m.hours(0).minutes(0).seconds(0).milliseconds(0);
192 assert.equal(m.calendar(), m.format('dddd [tuần rồi lúc] LT'), 'Today - ' + i + ' days beginning of day');
193 m.hours(23).minutes(59).seconds(59).milliseconds(999);
194 assert.equal(m.calendar(), m.format('dddd [tuần rồi lúc] LT'), 'Today - ' + i + ' days end of day');
195 }
196 });
197
198 test('calendar all else', function (assert) {
199 var weeksAgo = moment().subtract({w: 1}),
200 weeksFromNow = moment().add({w: 1});
201
202 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
203 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
204
205 weeksAgo = moment().subtract({w: 2});
206 weeksFromNow = moment().add({w: 2});
207
208 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
209 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
210 });
211
212 test('weeks year starting sunday', function (assert) {
213 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
214 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
215 assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
216 assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
217 assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
218 });
219
220 test('weeks year starting monday', function (assert) {
221 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
222 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
223 assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
224 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
225 assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
226 });
227
228 test('weeks year starting tuesday', function (assert) {
229 assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
230 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
231 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
232 assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
233 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
234 assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
235 });
236
237 test('weeks year starting wednesday', function (assert) {
238 assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
239 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
240 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
241 assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
242 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
243 assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
244 });
245
246 test('weeks year starting thursday', function (assert) {
247 assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
248 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
249 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
250 assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
251 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
252 assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
253 });
254
255 test('weeks year starting friday', function (assert) {
256 assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
257 assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
258 assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
259 assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
260 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
261 assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
262 });
263
264 test('weeks year starting saturday', function (assert) {
265 assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
266 assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
267 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
268 assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
269 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
270 assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
271 });
272
273 test('weeks year starting sunday formatted', function (assert) {
274 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
275 assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
276 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
277 assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
278 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
279 });
280
281 test('lenient ordinal parsing', function (assert) {
282 var i, ordinalStr, testMoment;
283 for (i = 1; i <= 31; ++i) {
284 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
285 testMoment = moment(ordinalStr, 'YYYY MM Do');
286 assert.equal(testMoment.year(), 2014,
287 'lenient ordinal parsing ' + i + ' year check');
288 assert.equal(testMoment.month(), 0,
289 'lenient ordinal parsing ' + i + ' month check');
290 assert.equal(testMoment.date(), i,
291 'lenient ordinal parsing ' + i + ' date check');
292 }
293 });
294
295 test('lenient ordinal parsing of number', function (assert) {
296 var i, testMoment;
297 for (i = 1; i <= 31; ++i) {
298 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
299 assert.equal(testMoment.year(), 2014,
300 'lenient ordinal parsing of number ' + i + ' year check');
301 assert.equal(testMoment.month(), 0,
302 'lenient ordinal parsing of number ' + i + ' month check');
303 assert.equal(testMoment.date(), i,
304 'lenient ordinal parsing of number ' + i + ' date check');
305 }
306 });
307
308 test('strict ordinal parsing', function (assert) {
309 var i, ordinalStr, testMoment;
310 for (i = 1; i <= 31; ++i) {
311 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
312 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
313 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
314 }
315 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('zh-cn');
3
4 test('parse', function (assert) {
5 var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
6
7 function equalTest(input, mmm, i) {
8 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
9 }
10
11 for (i = 0; i < 12; i++) {
12 tests[i] = tests[i].split(' ');
13 equalTest(tests[i][0], 'MMM', i);
14 equalTest(tests[i][1], 'MMM', i);
15 equalTest(tests[i][0], 'MMMM', i);
16 equalTest(tests[i][1], 'MMMM', i);
17 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
19 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
20 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
21 }
22 });
23
24 test('format', function (assert) {
25 var a = [
26 ['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14日 2010, 下午 3:25:50'],
27 ['ddd, Ah', '周日, 下午3'],
28 ['M Mo MM MMMM MMM', '2 2月 02 二月 2月'],
29 ['YYYY YY', '2010 10'],
30 ['D Do DD', '14 14日 14'],
31 ['d do dddd ddd dd', '0 0日 星期日 周日 日'],
32 ['DDD DDDo DDDD', '45 45日 045'],
33 ['w wo ww', '6 6周 06'],
34 ['h hh', '3 03'],
35 ['H HH', '15 15'],
36 ['m mm', '25 25'],
37 ['s ss', '50 50'],
38 ['a A', '下午 下午'],
39 ['[这年的第] DDDo', '这年的第 45日'],
40 ['LTS', '下午3点25分50秒'],
41 ['L', '2010-02-14'],
42 ['LL', '2010年2月14日'],
43 ['LLL', '2010年2月14日下午3点25分'],
44 ['LLLL', '2010年2月14日星期日下午3点25分'],
45 ['l', '2010-02-14'],
46 ['ll', '2010年2月14日'],
47 ['lll', '2010年2月14日下午3点25分'],
48 ['llll', '2010年2月14日星期日下午3点25分']
49 ],
50 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
51 i;
52
53 for (i = 0; i < a.length; i++) {
54 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
55 }
56 });
57
58 test('format month', function (assert) {
59 var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
60
61 for (i = 0; i < expected.length; i++) {
62 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
63 }
64 });
65
66 test('format week', function (assert) {
67 var expected = '星期日 周日 日_星期一 周一 一_星期二 周二 二_星期三 周三 三_星期四 周四 四_星期五 周五 五_星期六 周六 六'.split('_'), i;
68
69 for (i = 0; i < expected.length; i++) {
70 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
71 }
72 });
73
74 test('from', function (assert) {
75 var start = moment([2007, 1, 28]);
76 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '几秒', '44 seconds = a few seconds');
77 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1 分钟', '45 seconds = a minute');
78 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1 分钟', '89 seconds = a minute');
79 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 分钟', '90 seconds = 2 minutes');
80 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 分钟', '44 minutes = 44 minutes');
81 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1 小时', '45 minutes = an hour');
82 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1 小时', '89 minutes = an hour');
83 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 小时', '90 minutes = 2 hours');
84 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 小时', '5 hours = 5 hours');
85 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 小时', '21 hours = 21 hours');
86 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1 天', '22 hours = a day');
87 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1 天', '35 hours = a day');
88 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 天', '36 hours = 2 days');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1 天', '1 day = a day');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 天', '5 days = 5 days');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 天', '25 days = 25 days');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1 个月', '26 days = a month');
93 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1 个月', '30 days = a month');
94 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1 个月', '43 days = a month');
95 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 个月', '46 days = 2 months');
96 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 个月', '75 days = 2 months');
97 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 个月', '76 days = 3 months');
98 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1 个月', '1 month = a month');
99 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 个月', '5 months = 5 months');
100 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1 年', '345 days = a year');
101 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 年', '548 days = 2 years');
102 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1 年', '1 year = a year');
103 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 年', '5 years = 5 years');
104 });
105
106 test('suffix', function (assert) {
107 assert.equal(moment(30000).from(0), '几秒内', 'prefix');
108 assert.equal(moment(0).from(30000), '几秒前', 'suffix');
109 });
110
111 test('now from now', function (assert) {
112 assert.equal(moment().fromNow(), '几秒前', 'now from now should display as in the past');
113 });
114
115 test('fromNow', function (assert) {
116 assert.equal(moment().add({s: 30}).fromNow(), '几秒内', 'in a few seconds');
117 assert.equal(moment().add({d: 5}).fromNow(), '5 天内', 'in 5 days');
118 });
119
120 test('calendar day', function (assert) {
121 var a = moment().hours(2).minutes(0).seconds(0);
122
123 assert.equal(moment(a).calendar(), '今天凌晨2点整', 'today at the same time');
124 assert.equal(moment(a).add({m: 25}).calendar(), '今天凌晨2点25分', 'Now plus 25 min');
125 assert.equal(moment(a).add({h: 1}).calendar(), '今天凌晨3点整', 'Now plus 1 hour');
126 assert.equal(moment(a).add({d: 1}).calendar(), '明天凌晨2点整', 'tomorrow at the same time');
127 assert.equal(moment(a).subtract({h: 1}).calendar(), '今天凌晨1点整', 'Now minus 1 hour');
128 assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天凌晨2点整', 'yesterday at the same time');
129 });
130
131 test('calendar current week', function (assert) {
132 var i, m,
133 today = moment().startOf('day');
134
135 for (i = 0; i < 7; i++) {
136 m = moment().startOf('week').add({d: i});
137 if (Math.abs(m.diff(today, 'days')) <= 1) {
138 continue; // skip today, yesterday, tomorrow
139 }
140 assert.equal(m.calendar(), m.format('[本]ddd凌晨12点整'), 'Monday + ' + i + ' days current time');
141 }
142 });
143
144 test('calendar next week', function (assert) {
145 var i, m,
146 today = moment().startOf('day');
147
148 for (i = 7; i < 14; i++) {
149 m = moment().startOf('week').add({d: i});
150 if (Math.abs(m.diff(today, 'days')) >= 7) {
151 continue;
152 }
153 if (Math.abs(m.diff(today, 'days')) <= 1) {
154 continue; // skip today, yesterday, tomorrow
155 }
156 assert.equal(m.calendar(), m.format('[下]ddd凌晨12点整'), 'Today + ' + i + ' days beginning of day');
157 }
158 assert.equal(42, 42, 'at least one assert');
159 });
160
161 test('calendar last week', function (assert) {
162 var i, m,
163 today = moment().startOf('day');
164
165 for (i = 1; i < 8; i++) {
166 m = moment().startOf('week').subtract({d: i});
167 if ((Math.abs(m.diff(today, 'days')) >= 7) || (Math.abs(m.diff(today, 'days')) <= 1)) {
168 continue;
169 }
170 assert.equal(m.calendar(), m.format('[上]ddd凌晨12点整'), 'Monday - ' + i + ' days next week');
171 }
172 assert.equal(42, 42, 'at least one assert');
173 });
174
175 test('calendar all else', function (assert) {
176 var weeksAgo = moment().subtract({w: 1}),
177 weeksFromNow = moment().add({w: 1});
178
179 assert.equal(weeksAgo.calendar(), weeksAgo.format('LL'), '1 week ago');
180 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('LL'), 'in 1 week');
181
182 weeksAgo = moment().subtract({w: 2});
183 weeksFromNow = moment().add({w: 2});
184
185 assert.equal(weeksAgo.calendar(), weeksAgo.format('LL'), '2 weeks ago');
186 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('LL'), 'in 2 weeks');
187 });
188
189 test('meridiem', function (assert) {
190 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), '凌晨', 'before dawn');
191 assert.equal(moment([2011, 2, 23, 6, 0]).format('A'), '早上', 'morning');
192 assert.equal(moment([2011, 2, 23, 9, 0]).format('A'), '上午', 'before noon');
193 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), '中午', 'noon');
194 assert.equal(moment([2011, 2, 23, 13, 0]).format('A'), '下午', 'afternoon');
195 assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
196 });
197
198 test('weeks year starting sunday', function (assert) {
199 assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
200 assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 52');
201 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
202 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
203 });
204
205 test('weeks year starting monday', function (assert) {
206 assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
207 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
208 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
209 assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
210 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
211 assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
212 });
213
214 test('weeks year starting tuesday', function (assert) {
215 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
216 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
217 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
218 assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
219 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
220 assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
221 });
222
223 test('weeks year starting wednesday', function (assert) {
224 assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
225 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
226 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
227 assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
228 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
229 assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
230 });
231
232 test('weeks year starting thursday', function (assert) {
233 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
234 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
235 assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
236 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
237 assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
238 });
239
240 test('weeks year starting friday', function (assert) {
241 assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
242 assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
243 });
244
245 test('weeks year starting saturday', function (assert) {
246 assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
247 assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
248 assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
249 });
250
251 test('weeks year starting sunday format', function (assert) {
252 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52周', 'Jan 1 2012 应该是第52周');
253 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1周', 'Jan 7 2012 应该是第 1周');
254 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2周', 'Jan 14 2012 应该是第 2周');
255 });
256
257 test('lenient ordinal parsing', function (assert) {
258 var i, ordinalStr, testMoment;
259 for (i = 1; i <= 31; ++i) {
260 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
261 testMoment = moment(ordinalStr, 'YYYY MM Do');
262 assert.equal(testMoment.year(), 2014,
263 'lenient ordinal parsing ' + i + ' year check');
264 assert.equal(testMoment.month(), 0,
265 'lenient ordinal parsing ' + i + ' month check');
266 assert.equal(testMoment.date(), i,
267 'lenient ordinal parsing ' + i + ' date check');
268 }
269 });
270
271 test('lenient ordinal parsing of number', function (assert) {
272 var i, testMoment;
273 for (i = 1; i <= 31; ++i) {
274 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
275 assert.equal(testMoment.year(), 2014,
276 'lenient ordinal parsing of number ' + i + ' year check');
277 assert.equal(testMoment.month(), 0,
278 'lenient ordinal parsing of number ' + i + ' month check');
279 assert.equal(testMoment.date(), i,
280 'lenient ordinal parsing of number ' + i + ' date check');
281 }
282 });
283
284 test('meridiem invariant', function (assert) {
285 var h, m, t1, t2;
286 for (h = 0; h < 24; ++h) {
287 for (m = 0; m < 60; m += 15) {
288 t1 = moment.utc([2000, 0, 1, h, m]);
289 t2 = moment(t1.format('A h:mm'), 'A h:mm');
290 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
291 'meridiem at ' + t1.format('HH:mm'));
292 }
293 }
294 });
295
296 test('strict ordinal parsing', function (assert) {
297 var i, ordinalStr, testMoment;
298 for (i = 1; i <= 31; ++i) {
299 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
300 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
301 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
302 }
303 });
0 import {localeModule, test} from '../qunit';
1 import moment from '../../moment';
2 localeModule('zh-tw');
3
4 test('parse', function (assert) {
5 var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
6 function equalTest(input, mmm, i) {
7 assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
8 }
9 for (i = 0; i < 12; i++) {
10 tests[i] = tests[i].split(' ');
11 equalTest(tests[i][0], 'MMM', i);
12 equalTest(tests[i][1], 'MMM', i);
13 equalTest(tests[i][0], 'MMMM', i);
14 equalTest(tests[i][1], 'MMMM', i);
15 equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
16 equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
17 equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
18 equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
19 }
20 });
21
22 test('format', function (assert) {
23 var a = [
24 ['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14日 2010, 下午 3:25:50'],
25 ['ddd, Ah', '週日, 下午3'],
26 ['M Mo MM MMMM MMM', '2 2月 02 二月 2月'],
27 ['YYYY YY', '2010 10'],
28 ['D Do DD', '14 14日 14'],
29 ['d do dddd ddd dd', '0 0日 星期日 週日 日'],
30 ['DDD DDDo DDDD', '45 45日 045'],
31 ['w wo ww', '8 8週 08'],
32 ['h hh', '3 03'],
33 ['H HH', '15 15'],
34 ['m mm', '25 25'],
35 ['s ss', '50 50'],
36 ['a A', '下午 下午'],
37 ['[這年的第] DDDo', '這年的第 45日'],
38 ['LTS', '下午3點25分50秒'],
39 ['L', '2010年2月14日'],
40 ['LL', '2010年2月14日'],
41 ['LLL', '2010年2月14日下午3點25分'],
42 ['LLLL', '2010年2月14日星期日下午3點25分'],
43 ['l', '2010年2月14日'],
44 ['ll', '2010年2月14日'],
45 ['lll', '2010年2月14日下午3點25分'],
46 ['llll', '2010年2月14日星期日下午3點25分']
47 ],
48 b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
49 i;
50
51 for (i = 0; i < a.length; i++) {
52 assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
53 }
54 });
55
56 test('format month', function (assert) {
57 var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split('_'), i;
58
59 for (i = 0; i < expected.length; i++) {
60 assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
61 }
62 });
63
64 test('format week', function (assert) {
65 var expected = '星期日 週日 日_星期一 週一 一_星期二 週二 二_星期三 週三 三_星期四 週四 四_星期五 週五 五_星期六 週六 六'.split('_'), i;
66
67 for (i = 0; i < expected.length; i++) {
68 assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
69 }
70 });
71
72 test('from', function (assert) {
73 var start = moment([2007, 1, 28]);
74 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '幾秒', '44 seconds = a few seconds');
75 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '一分鐘', '45 seconds = a minute');
76 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '一分鐘', '89 seconds = a minute');
77 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2分鐘', '90 seconds = 2 minutes');
78 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44分鐘', '44 minutes = 44 minutes');
79 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '一小時', '45 minutes = an hour');
80 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '一小時', '89 minutes = an hour');
81 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2小時', '90 minutes = 2 hours');
82 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5小時', '5 hours = 5 hours');
83 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21小時', '21 hours = 21 hours');
84 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '一天', '22 hours = a day');
85 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '一天', '35 hours = a day');
86 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2天', '36 hours = 2 days');
87 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '一天', '1 day = a day');
88 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5天', '5 days = 5 days');
89 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25天', '25 days = 25 days');
90 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '一個月', '26 days = a month');
91 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '一個月', '30 days = a month');
92 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '一個月', '43 days = a month');
93 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2個月', '46 days = 2 months');
94 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2個月', '75 days = 2 months');
95 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3個月', '76 days = 3 months');
96 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '一個月', '1 month = a month');
97 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5個月', '5 months = 5 months');
98 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '一年', '345 days = a year');
99 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2年', '548 days = 2 years');
100 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '一年', '1 year = a year');
101 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5年', '5 years = 5 years');
102 });
103
104 test('suffix', function (assert) {
105 assert.equal(moment(30000).from(0), '幾秒內', 'prefix');
106 assert.equal(moment(0).from(30000), '幾秒前', 'suffix');
107 });
108
109 test('now from now', function (assert) {
110 assert.equal(moment().fromNow(), '幾秒前', 'now from now should display as in the past');
111 });
112
113 test('fromNow', function (assert) {
114 assert.equal(moment().add({s: 30}).fromNow(), '幾秒內', 'in a few seconds');
115 assert.equal(moment().add({d: 5}).fromNow(), '5天內', 'in 5 days');
116 });
117
118 test('calendar day', function (assert) {
119 var a = moment().hours(2).minutes(0).seconds(0);
120
121 assert.equal(moment(a).calendar(), '今天早上2點00分', 'today at the same time');
122 assert.equal(moment(a).add({m: 25}).calendar(), '今天早上2點25分', 'Now plus 25 min');
123 assert.equal(moment(a).add({h: 1}).calendar(), '今天早上3點00分', 'Now plus 1 hour');
124 assert.equal(moment(a).add({d: 1}).calendar(), '明天早上2點00分', 'tomorrow at the same time');
125 assert.equal(moment(a).subtract({h: 1}).calendar(), '今天早上1點00分', 'Now minus 1 hour');
126 assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天早上2點00分', 'yesterday at the same time');
127 });
128
129 test('calendar next week', function (assert) {
130 var i, m;
131 for (i = 2; i < 7; i++) {
132 m = moment().add({d: i});
133 assert.equal(m.calendar(), m.format('[下]ddddLT'), 'Today + ' + i + ' days current time');
134 m.hours(0).minutes(0).seconds(0).milliseconds(0);
135 assert.equal(m.calendar(), m.format('[下]ddddLT'), 'Today + ' + i + ' days beginning of day');
136 m.hours(23).minutes(59).seconds(59).milliseconds(999);
137 assert.equal(m.calendar(), m.format('[下]ddddLT'), 'Today + ' + i + ' days end of day');
138 }
139 });
140
141 test('calendar last week', function (assert) {
142 var i, m;
143 for (i = 2; i < 7; i++) {
144 m = moment().subtract({d: i});
145 assert.equal(m.calendar(), m.format('[上]ddddLT'), 'Today - ' + i + ' days current time');
146 m.hours(0).minutes(0).seconds(0).milliseconds(0);
147 assert.equal(m.calendar(), m.format('[上]ddddLT'), 'Today - ' + i + ' days beginning of day');
148 m.hours(23).minutes(59).seconds(59).milliseconds(999);
149 assert.equal(m.calendar(), m.format('[上]ddddLT'), 'Today - ' + i + ' days end of day');
150 }
151 });
152
153 test('calendar all else', function (assert) {
154 var weeksAgo = moment().subtract({w: 1}),
155 weeksFromNow = moment().add({w: 1});
156
157 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
158 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
159
160 weeksAgo = moment().subtract({w: 2});
161 weeksFromNow = moment().add({w: 2});
162
163 assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
164 assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
165 });
166
167 test('meridiem', function (assert) {
168 assert.equal(moment([2011, 2, 23, 0, 0]).format('a'), '早上', 'morning');
169 assert.equal(moment([2011, 2, 23, 9, 0]).format('a'), '上午', 'before noon');
170 assert.equal(moment([2011, 2, 23, 12, 0]).format('a'), '中午', 'noon');
171 assert.equal(moment([2011, 2, 23, 13, 0]).format('a'), '下午', 'after noon');
172 assert.equal(moment([2011, 2, 23, 18, 0]).format('a'), '晚上', 'night');
173
174 assert.equal(moment([2011, 2, 23, 0, 0]).format('A'), '早上', 'morning');
175 assert.equal(moment([2011, 2, 23, 9, 0]).format('A'), '上午', 'before noon');
176 assert.equal(moment([2011, 2, 23, 12, 0]).format('A'), '中午', 'noon');
177 assert.equal(moment([2011, 2, 23, 13, 0]).format('A'), '下午', 'afternoon');
178 assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
179 });
180
181 test('weeks year starting sunday', function (assert) {
182 assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
183 assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
184 assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
185 assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
186 assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
187 });
188
189 test('weeks year starting monday', function (assert) {
190 assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
191 assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
192 assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
193 assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
194 assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
195 assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
196 });
197
198 test('weeks year starting tuesday', function (assert) {
199 assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
200 assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
201 assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
202 assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
203 assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
204 assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
205 });
206
207 test('weeks year starting wednesday', function (assert) {
208 assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
209 assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
210 assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
211 assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
212 assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
213 assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
214 });
215
216 test('weeks year starting thursday', function (assert) {
217 assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
218 assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
219 assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
220 assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
221 assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
222 assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
223 });
224
225 test('weeks year starting friday', function (assert) {
226 assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
227 assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
228 assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
229 assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
230 assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
231 assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
232 });
233
234 test('weeks year starting saturday', function (assert) {
235 assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
236 assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
237 assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
238 assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
239 assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
240 });
241
242 test('weeks year starting sunday format', function (assert) {
243 assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1週', 'Jan 1 2012 應該是第 1週');
244 assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1週', 'Jan 7 2012 應該是第 1週');
245 assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2週', 'Jan 8 2012 應該是第 2週');
246 assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2週', 'Jan 14 2012 應該是第 2週');
247 assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3週', 'Jan 15 2012 應該是第 3週');
248 });
249
250 test('lenient ordinal parsing', function (assert) {
251 var i, ordinalStr, testMoment;
252 for (i = 1; i <= 31; ++i) {
253 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
254 testMoment = moment(ordinalStr, 'YYYY MM Do');
255 assert.equal(testMoment.year(), 2014,
256 'lenient ordinal parsing ' + i + ' year check');
257 assert.equal(testMoment.month(), 0,
258 'lenient ordinal parsing ' + i + ' month check');
259 assert.equal(testMoment.date(), i,
260 'lenient ordinal parsing ' + i + ' date check');
261 }
262 });
263
264 test('lenient ordinal parsing of number', function (assert) {
265 var i, testMoment;
266 for (i = 1; i <= 31; ++i) {
267 testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
268 assert.equal(testMoment.year(), 2014,
269 'lenient ordinal parsing of number ' + i + ' year check');
270 assert.equal(testMoment.month(), 0,
271 'lenient ordinal parsing of number ' + i + ' month check');
272 assert.equal(testMoment.date(), i,
273 'lenient ordinal parsing of number ' + i + ' date check');
274 }
275 });
276
277 test('meridiem invariant', function (assert) {
278 var h, m, t1, t2;
279 for (h = 0; h < 24; ++h) {
280 for (m = 0; m < 60; m += 15) {
281 t1 = moment.utc([2000, 0, 1, h, m]);
282 t2 = moment(t1.format('A h:mm'), 'A h:mm');
283 assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
284 'meridiem at ' + t1.format('HH:mm'));
285 }
286 }
287 });
288
289 test('strict ordinal parsing', function (assert) {
290 var i, ordinalStr, testMoment;
291 for (i = 1; i <= 31; ++i) {
292 ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
293 testMoment = moment(ordinalStr, 'YYYY MM Do', true);
294 assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
295 }
296 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('add and subtract');
4
5 test('add short reverse args', function (assert) {
6 var a = moment(), b, c, d;
7 a.year(2011);
8 a.month(9);
9 a.date(12);
10 a.hours(6);
11 a.minutes(7);
12 a.seconds(8);
13 a.milliseconds(500);
14
15 assert.equal(a.add({ms: 50}).milliseconds(), 550, 'Add milliseconds');
16 assert.equal(a.add({s: 1}).seconds(), 9, 'Add seconds');
17 assert.equal(a.add({m: 1}).minutes(), 8, 'Add minutes');
18 assert.equal(a.add({h: 1}).hours(), 7, 'Add hours');
19 assert.equal(a.add({d: 1}).date(), 13, 'Add date');
20 assert.equal(a.add({w: 1}).date(), 20, 'Add week');
21 assert.equal(a.add({M: 1}).month(), 10, 'Add month');
22 assert.equal(a.add({y: 1}).year(), 2012, 'Add year');
23 assert.equal(a.add({Q: 1}).month(), 1, 'Add quarter');
24
25 b = moment([2010, 0, 31]).add({M: 1});
26 c = moment([2010, 1, 28]).subtract({M: 1});
27 d = moment([2010, 1, 28]).subtract({Q: 1});
28
29 assert.equal(b.month(), 1, 'add month, jan 31st to feb 28th');
30 assert.equal(b.date(), 28, 'add month, jan 31st to feb 28th');
31 assert.equal(c.month(), 0, 'subtract month, feb 28th to jan 28th');
32 assert.equal(c.date(), 28, 'subtract month, feb 28th to jan 28th');
33 assert.equal(d.month(), 10, 'subtract quarter, feb 28th 2010 to nov 28th 2009');
34 assert.equal(d.date(), 28, 'subtract quarter, feb 28th 2010 to nov 28th 2009');
35 assert.equal(d.year(), 2009, 'subtract quarter, feb 28th 2010 to nov 28th 2009');
36 });
37
38 test('add long reverse args', function (assert) {
39 var a = moment();
40 a.year(2011);
41 a.month(9);
42 a.date(12);
43 a.hours(6);
44 a.minutes(7);
45 a.seconds(8);
46 a.milliseconds(500);
47
48 assert.equal(a.add({milliseconds: 50}).milliseconds(), 550, 'Add milliseconds');
49 assert.equal(a.add({seconds: 1}).seconds(), 9, 'Add seconds');
50 assert.equal(a.add({minutes: 1}).minutes(), 8, 'Add minutes');
51 assert.equal(a.add({hours: 1}).hours(), 7, 'Add hours');
52 assert.equal(a.add({days: 1}).date(), 13, 'Add date');
53 assert.equal(a.add({weeks: 1}).date(), 20, 'Add week');
54 assert.equal(a.add({months: 1}).month(), 10, 'Add month');
55 assert.equal(a.add({years: 1}).year(), 2012, 'Add year');
56 assert.equal(a.add({quarters: 1}).month(), 1, 'Add quarter');
57 });
58
59 test('add long singular reverse args', function (assert) {
60 var a = moment();
61 a.year(2011);
62 a.month(9);
63 a.date(12);
64 a.hours(6);
65 a.minutes(7);
66 a.seconds(8);
67 a.milliseconds(500);
68
69 assert.equal(a.add({millisecond: 50}).milliseconds(), 550, 'Add milliseconds');
70 assert.equal(a.add({second: 1}).seconds(), 9, 'Add seconds');
71 assert.equal(a.add({minute: 1}).minutes(), 8, 'Add minutes');
72 assert.equal(a.add({hour: 1}).hours(), 7, 'Add hours');
73 assert.equal(a.add({day: 1}).date(), 13, 'Add date');
74 assert.equal(a.add({week: 1}).date(), 20, 'Add week');
75 assert.equal(a.add({month: 1}).month(), 10, 'Add month');
76 assert.equal(a.add({year: 1}).year(), 2012, 'Add year');
77 assert.equal(a.add({quarter: 1}).month(), 1, 'Add quarter');
78 });
79
80 test('add string long reverse args', function (assert) {
81 var a = moment(), b;
82 a.year(2011);
83 a.month(9);
84 a.date(12);
85 a.hours(6);
86 a.minutes(7);
87 a.seconds(8);
88 a.milliseconds(500);
89
90 b = a.clone();
91
92 assert.equal(a.add('millisecond', 50).milliseconds(), 550, 'Add milliseconds');
93 assert.equal(a.add('second', 1).seconds(), 9, 'Add seconds');
94 assert.equal(a.add('minute', 1).minutes(), 8, 'Add minutes');
95 assert.equal(a.add('hour', 1).hours(), 7, 'Add hours');
96 assert.equal(a.add('day', 1).date(), 13, 'Add date');
97 assert.equal(a.add('week', 1).date(), 20, 'Add week');
98 assert.equal(a.add('month', 1).month(), 10, 'Add month');
99 assert.equal(a.add('year', 1).year(), 2012, 'Add year');
100 assert.equal(b.add('day', '01').date(), 13, 'Add date');
101 assert.equal(a.add('quarter', 1).month(), 1, 'Add quarter');
102 });
103
104 test('add string long singular reverse args', function (assert) {
105 var a = moment(), b;
106 a.year(2011);
107 a.month(9);
108 a.date(12);
109 a.hours(6);
110 a.minutes(7);
111 a.seconds(8);
112 a.milliseconds(500);
113
114 b = a.clone();
115
116 assert.equal(a.add('milliseconds', 50).milliseconds(), 550, 'Add milliseconds');
117 assert.equal(a.add('seconds', 1).seconds(), 9, 'Add seconds');
118 assert.equal(a.add('minutes', 1).minutes(), 8, 'Add minutes');
119 assert.equal(a.add('hours', 1).hours(), 7, 'Add hours');
120 assert.equal(a.add('days', 1).date(), 13, 'Add date');
121 assert.equal(a.add('weeks', 1).date(), 20, 'Add week');
122 assert.equal(a.add('months', 1).month(), 10, 'Add month');
123 assert.equal(a.add('years', 1).year(), 2012, 'Add year');
124 assert.equal(b.add('days', '01').date(), 13, 'Add date');
125 assert.equal(a.add('quarters', 1).month(), 1, 'Add quarter');
126 });
127
128 test('add string short reverse args', function (assert) {
129 var a = moment();
130 a.year(2011);
131 a.month(9);
132 a.date(12);
133 a.hours(6);
134 a.minutes(7);
135 a.seconds(8);
136 a.milliseconds(500);
137
138 assert.equal(a.add('ms', 50).milliseconds(), 550, 'Add milliseconds');
139 assert.equal(a.add('s', 1).seconds(), 9, 'Add seconds');
140 assert.equal(a.add('m', 1).minutes(), 8, 'Add minutes');
141 assert.equal(a.add('h', 1).hours(), 7, 'Add hours');
142 assert.equal(a.add('d', 1).date(), 13, 'Add date');
143 assert.equal(a.add('w', 1).date(), 20, 'Add week');
144 assert.equal(a.add('M', 1).month(), 10, 'Add month');
145 assert.equal(a.add('y', 1).year(), 2012, 'Add year');
146 assert.equal(a.add('Q', 1).month(), 1, 'Add quarter');
147 });
148
149 test('add string long', function (assert) {
150 var a = moment();
151 a.year(2011);
152 a.month(9);
153 a.date(12);
154 a.hours(6);
155 a.minutes(7);
156 a.seconds(8);
157 a.milliseconds(500);
158
159 assert.equal(a.add(50, 'millisecond').milliseconds(), 550, 'Add milliseconds');
160 assert.equal(a.add(1, 'second').seconds(), 9, 'Add seconds');
161 assert.equal(a.add(1, 'minute').minutes(), 8, 'Add minutes');
162 assert.equal(a.add(1, 'hour').hours(), 7, 'Add hours');
163 assert.equal(a.add(1, 'day').date(), 13, 'Add date');
164 assert.equal(a.add(1, 'week').date(), 20, 'Add week');
165 assert.equal(a.add(1, 'month').month(), 10, 'Add month');
166 assert.equal(a.add(1, 'year').year(), 2012, 'Add year');
167 assert.equal(a.add(1, 'quarter').month(), 1, 'Add quarter');
168 });
169
170 test('add string long singular', function (assert) {
171 var a = moment();
172 a.year(2011);
173 a.month(9);
174 a.date(12);
175 a.hours(6);
176 a.minutes(7);
177 a.seconds(8);
178 a.milliseconds(500);
179
180 assert.equal(a.add(50, 'milliseconds').milliseconds(), 550, 'Add milliseconds');
181 assert.equal(a.add(1, 'seconds').seconds(), 9, 'Add seconds');
182 assert.equal(a.add(1, 'minutes').minutes(), 8, 'Add minutes');
183 assert.equal(a.add(1, 'hours').hours(), 7, 'Add hours');
184 assert.equal(a.add(1, 'days').date(), 13, 'Add date');
185 assert.equal(a.add(1, 'weeks').date(), 20, 'Add week');
186 assert.equal(a.add(1, 'months').month(), 10, 'Add month');
187 assert.equal(a.add(1, 'years').year(), 2012, 'Add year');
188 assert.equal(a.add(1, 'quarters').month(), 1, 'Add quarter');
189 });
190
191 test('add string short', function (assert) {
192 var a = moment();
193 a.year(2011);
194 a.month(9);
195 a.date(12);
196 a.hours(6);
197 a.minutes(7);
198 a.seconds(8);
199 a.milliseconds(500);
200
201 assert.equal(a.add(50, 'ms').milliseconds(), 550, 'Add milliseconds');
202 assert.equal(a.add(1, 's').seconds(), 9, 'Add seconds');
203 assert.equal(a.add(1, 'm').minutes(), 8, 'Add minutes');
204 assert.equal(a.add(1, 'h').hours(), 7, 'Add hours');
205 assert.equal(a.add(1, 'd').date(), 13, 'Add date');
206 assert.equal(a.add(1, 'w').date(), 20, 'Add week');
207 assert.equal(a.add(1, 'M').month(), 10, 'Add month');
208 assert.equal(a.add(1, 'y').year(), 2012, 'Add year');
209 assert.equal(a.add(1, 'Q').month(), 1, 'Add quarter');
210 });
211
212 test('add strings string short args', function (assert) {
213 var a = moment();
214 a.year(2011);
215 a.month(9);
216 a.date(12);
217 a.hours(6);
218 a.minutes(7);
219 a.seconds(8);
220 a.milliseconds(500);
221
222 assert.equal(a.add('ms', '50').milliseconds(), 550, 'Add milliseconds');
223 assert.equal(a.add('s', '1').seconds(), 9, 'Add seconds');
224 assert.equal(a.add('m', '1').minutes(), 8, 'Add minutes');
225 assert.equal(a.add('h', '1').hours(), 7, 'Add hours');
226 assert.equal(a.add('d', '1').date(), 13, 'Add date');
227 assert.equal(a.add('w', '1').date(), 20, 'Add week');
228 assert.equal(a.add('M', '1').month(), 10, 'Add month');
229 assert.equal(a.add('y', '1').year(), 2012, 'Add year');
230 assert.equal(a.add('Q', '1').month(), 1, 'Add quarter');
231 });
232
233 test('subtract strings string short args', function (assert) {
234 var a = moment();
235 a.year(2011);
236 a.month(9);
237 a.date(12);
238 a.hours(6);
239 a.minutes(7);
240 a.seconds(8);
241 a.milliseconds(500);
242
243 assert.equal(a.subtract('ms', '50').milliseconds(), 450, 'Subtract milliseconds');
244 assert.equal(a.subtract('s', '1').seconds(), 7, 'Subtract seconds');
245 assert.equal(a.subtract('m', '1').minutes(), 6, 'Subtract minutes');
246 assert.equal(a.subtract('h', '1').hours(), 5, 'Subtract hours');
247 assert.equal(a.subtract('d', '1').date(), 11, 'Subtract date');
248 assert.equal(a.subtract('w', '1').date(), 4, 'Subtract week');
249 assert.equal(a.subtract('M', '1').month(), 8, 'Subtract month');
250 assert.equal(a.subtract('y', '1').year(), 2010, 'Subtract year');
251 assert.equal(a.subtract('Q', '1').month(), 5, 'Subtract quarter');
252 });
253
254 test('add strings string short', function (assert) {
255 var a = moment();
256 a.year(2011);
257 a.month(9);
258 a.date(12);
259 a.hours(6);
260 a.minutes(7);
261 a.seconds(8);
262 a.milliseconds(500);
263
264 assert.equal(a.add('50', 'ms').milliseconds(), 550, 'Add milliseconds');
265 assert.equal(a.add('1', 's').seconds(), 9, 'Add seconds');
266 assert.equal(a.add('1', 'm').minutes(), 8, 'Add minutes');
267 assert.equal(a.add('1', 'h').hours(), 7, 'Add hours');
268 assert.equal(a.add('1', 'd').date(), 13, 'Add date');
269 assert.equal(a.add('1', 'w').date(), 20, 'Add week');
270 assert.equal(a.add('1', 'M').month(), 10, 'Add month');
271 assert.equal(a.add('1', 'y').year(), 2012, 'Add year');
272 assert.equal(a.add('1', 'Q').month(), 1, 'Add quarter');
273 });
274
275 test('subtract strings string short', function (assert) {
276 var a = moment();
277 a.year(2011);
278 a.month(9);
279 a.date(12);
280 a.hours(6);
281 a.minutes(7);
282 a.seconds(8);
283 a.milliseconds(500);
284
285 assert.equal(a.subtract('50', 'ms').milliseconds(), 450, 'Subtract milliseconds');
286 assert.equal(a.subtract('1', 's').seconds(), 7, 'Subtract seconds');
287 assert.equal(a.subtract('1', 'm').minutes(), 6, 'Subtract minutes');
288 assert.equal(a.subtract('1', 'h').hours(), 5, 'Subtract hours');
289 assert.equal(a.subtract('1', 'd').date(), 11, 'Subtract date');
290 assert.equal(a.subtract('1', 'w').date(), 4, 'Subtract week');
291 assert.equal(a.subtract('1', 'M').month(), 8, 'Subtract month');
292 assert.equal(a.subtract('1', 'y').year(), 2010, 'Subtract year');
293 assert.equal(a.subtract('1', 'Q').month(), 5, 'Subtract quarter');
294 });
295
296 test('add across DST', function (assert) {
297 // Detect Safari bug and bail. Hours on 13th March 2011 are shifted
298 // with 1 ahead.
299 if (new Date(2011, 2, 13, 5, 0, 0).getHours() !== 5) {
300 assert.expect(0);
301 return;
302 }
303
304 var a = moment(new Date(2011, 2, 12, 5, 0, 0)),
305 b = moment(new Date(2011, 2, 12, 5, 0, 0)),
306 c = moment(new Date(2011, 2, 12, 5, 0, 0)),
307 d = moment(new Date(2011, 2, 12, 5, 0, 0)),
308 e = moment(new Date(2011, 2, 12, 5, 0, 0));
309 a.add(1, 'days');
310 b.add(24, 'hours');
311 c.add(1, 'months');
312 e.add(1, 'quarter');
313
314 assert.equal(a.hours(), 5, 'adding days over DST difference should result in the same hour');
315 if (b.isDST() && !d.isDST()) {
316 assert.equal(b.hours(), 6, 'adding hours over DST difference should result in a different hour');
317 } else if (!b.isDST() && d.isDST()) {
318 assert.equal(b.hours(), 4, 'adding hours over DST difference should result in a different hour');
319 } else {
320 assert.equal(b.hours(), 5, 'adding hours over DST difference should result in a same hour if the timezone does not have daylight savings time');
321 }
322 assert.equal(c.hours(), 5, 'adding months over DST difference should result in the same hour');
323 assert.equal(e.hours(), 5, 'adding quarters over DST difference should result in the same hour');
324 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('create');
4
5 test('array', function (assert) {
6 assert.ok(moment([2010]).toDate() instanceof Date, '[2010]');
7 assert.ok(moment([2010, 1]).toDate() instanceof Date, '[2010, 1]');
8 assert.ok(moment([2010, 1, 12]).toDate() instanceof Date, '[2010, 1, 12]');
9 assert.ok(moment([2010, 1, 12, 1]).toDate() instanceof Date, '[2010, 1, 12, 1]');
10 assert.ok(moment([2010, 1, 12, 1, 1]).toDate() instanceof Date, '[2010, 1, 12, 1, 1]');
11 assert.ok(moment([2010, 1, 12, 1, 1, 1]).toDate() instanceof Date, '[2010, 1, 12, 1, 1, 1]');
12 assert.ok(moment([2010, 1, 12, 1, 1, 1, 1]).toDate() instanceof Date, '[2010, 1, 12, 1, 1, 1, 1]');
13 assert.equal(+moment(new Date(2010, 1, 14, 15, 25, 50, 125)), +moment([2010, 1, 14, 15, 25, 50, 125]), 'constructing with array === constructing with new Date()');
14 });
15
16 test('array copying', function (assert) {
17 var importantArray = [2009, 11];
18 moment(importantArray);
19 assert.deepEqual(importantArray, [2009, 11], 'initializer should not mutate the original array');
20 });
21
22 test('object', function (assert) {
23 var fmt = 'YYYY-MM-DD HH:mm:ss.SSS',
24 tests = [
25 [{year: 2010}, '2010-01-01 00:00:00.000'],
26 [{year: 2010, month: 1}, '2010-02-01 00:00:00.000'],
27 [{year: 2010, month: 1, day: 12}, '2010-02-12 00:00:00.000'],
28 [{year: 2010, month: 1, date: 12}, '2010-02-12 00:00:00.000'],
29 [{year: 2010, month: 1, day: 12, hours: 1}, '2010-02-12 01:00:00.000'],
30 [{year: 2010, month: 1, date: 12, hours: 1}, '2010-02-12 01:00:00.000'],
31 [{year: 2010, month: 1, day: 12, hours: 1, minutes: 1}, '2010-02-12 01:01:00.000'],
32 [{year: 2010, month: 1, date: 12, hours: 1, minutes: 1}, '2010-02-12 01:01:00.000'],
33 [{year: 2010, month: 1, day: 12, hours: 1, minutes: 1, seconds: 1}, '2010-02-12 01:01:01.000'],
34 [{year: 2010, month: 1, day: 12, hours: 1, minutes: 1, seconds: 1, milliseconds: 1}, '2010-02-12 01:01:01.001'],
35 [{years: 2010, months: 1, days: 14, hours: 15, minutes: 25, seconds: 50, milliseconds: 125}, '2010-02-14 15:25:50.125'],
36 [{year: 2010, month: 1, day: 14, hour: 15, minute: 25, second: 50, millisecond: 125}, '2010-02-14 15:25:50.125'],
37 [{y: 2010, M: 1, d: 14, h: 15, m: 25, s: 50, ms: 125}, '2010-02-14 15:25:50.125']
38 ], i;
39 for (i = 0; i < tests.length; ++i) {
40 assert.equal(moment(tests[i][0]).format(fmt), tests[i][1]);
41 }
42 });
43
44 test('multi format array copying', function (assert) {
45 var importantArray = ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY'];
46 moment('1999-02-13', importantArray);
47 assert.deepEqual(importantArray, ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY'], 'initializer should not mutate the original array');
48 });
49
50 test('number', function (assert) {
51 assert.ok(moment(1000).toDate() instanceof Date, '1000');
52 assert.equal(moment(1000).valueOf(), 1000, 'asserting valueOf');
53 assert.equal(moment.utc(1000).valueOf(), 1000, 'asserting valueOf');
54 });
55
56 test('unix', function (assert) {
57 assert.equal(moment.unix(1).valueOf(), 1000, '1 unix timestamp == 1000 Date.valueOf');
58 assert.equal(moment(1000).unix(), 1, '1000 Date.valueOf == 1 unix timestamp');
59 assert.equal(moment.unix(1000).valueOf(), 1000000, '1000 unix timestamp == 1000000 Date.valueOf');
60 assert.equal(moment(1500).unix(), 1, '1500 Date.valueOf == 1 unix timestamp');
61 assert.equal(moment(1900).unix(), 1, '1900 Date.valueOf == 1 unix timestamp');
62 assert.equal(moment(2100).unix(), 2, '2100 Date.valueOf == 2 unix timestamp');
63 assert.equal(moment(1333129333524).unix(), 1333129333, '1333129333524 Date.valueOf == 1333129333 unix timestamp');
64 assert.equal(moment(1333129333524000).unix(), 1333129333524, '1333129333524000 Date.valueOf == 1333129333524 unix timestamp');
65 });
66
67 test('date', function (assert) {
68 assert.ok(moment(new Date()).toDate() instanceof Date, 'new Date()');
69 });
70
71 test('date mutation', function (assert) {
72 var a = new Date();
73 assert.ok(moment(a).toDate() !== a, 'the date moment uses should not be the date passed in');
74 });
75
76 test('moment', function (assert) {
77 assert.ok(moment(moment()).toDate() instanceof Date, 'moment(moment())');
78 assert.ok(moment(moment(moment())).toDate() instanceof Date, 'moment(moment(moment()))');
79 });
80
81 test('cloning moment should only copy own properties', function (assert) {
82 assert.ok(!moment().clone().hasOwnProperty('month'), 'Should not clone prototype methods');
83 });
84
85 test('cloning moment works with weird clones', function (assert) {
86 var extend = function (a, b) {
87 var i;
88 for (i in b) {
89 a[i] = b[i];
90 }
91 return a;
92 },
93 now = moment(),
94 nowu = moment.utc();
95
96 assert.equal(+extend({}, now).clone(), +now, 'cloning extend-ed now is now');
97 assert.equal(+extend({}, nowu).clone(), +nowu, 'cloning extend-ed utc now is utc now');
98 });
99
100 test('cloning respects moment.momentProperties', function (assert) {
101 var m = moment();
102
103 assert.equal(m.clone()._special, undefined, 'cloning ignores extra properties');
104 m._special = 'bacon';
105 moment.momentProperties.push('_special');
106 assert.equal(m.clone()._special, 'bacon', 'cloning respects momentProperties');
107 moment.momentProperties.pop();
108 });
109
110 test('undefined', function (assert) {
111 assert.ok(moment().toDate() instanceof Date, 'undefined');
112 });
113
114 test('iso with bad input', function (assert) {
115 assert.ok(!moment('a', moment.ISO_8601).isValid(), 'iso parsing with invalid string');
116 assert.ok(!moment('a', moment.ISO_8601, true).isValid(), 'iso parsing with invalid string, strict');
117 });
118
119 test('iso format 24hrs', function (assert) {
120 assert.equal(moment('2014-01-01T24:00:00.000').format('YYYY-MM-DD[T]HH:mm:ss.SSS'),
121 '2014-01-02T00:00:00.000', 'iso format with 24:00 localtime');
122 assert.equal(moment.utc('2014-01-01T24:00:00.000').format('YYYY-MM-DD[T]HH:mm:ss.SSS'),
123 '2014-01-02T00:00:00.000', 'iso format with 24:00 utc');
124 });
125
126 test('string without format - json', function (assert) {
127 assert.equal(moment('Date(1325132654000)').valueOf(), 1325132654000, 'Date(1325132654000)');
128 assert.equal(moment('Date(-1325132654000)').valueOf(), -1325132654000, 'Date(-1325132654000)');
129 assert.equal(moment('/Date(1325132654000)/').valueOf(), 1325132654000, '/Date(1325132654000)/');
130 assert.equal(moment('/Date(1325132654000+0700)/').valueOf(), 1325132654000, '/Date(1325132654000+0700)/');
131 assert.equal(moment('/Date(1325132654000-0700)/').valueOf(), 1325132654000, '/Date(1325132654000-0700)/');
132 });
133
134 test('string with format dropped am/pm bug', function (assert) {
135 moment.locale('en');
136
137 assert.equal(moment('05/1/2012 12:25:00', 'MM/DD/YYYY h:m:s a').format('MM/DD/YYYY'), '05/01/2012', 'should not break if am/pm is left off from the parsing tokens');
138 assert.equal(moment('05/1/2012 12:25:00 am', 'MM/DD/YYYY h:m:s a').format('MM/DD/YYYY'), '05/01/2012', 'should not break if am/pm is left off from the parsing tokens');
139 assert.equal(moment('05/1/2012 12:25:00 pm', 'MM/DD/YYYY h:m:s a').format('MM/DD/YYYY'), '05/01/2012', 'should not break if am/pm is left off from the parsing tokens');
140
141 assert.ok(moment('05/1/2012 12:25:00', 'MM/DD/YYYY h:m:s a').isValid());
142 assert.ok(moment('05/1/2012 12:25:00 am', 'MM/DD/YYYY h:m:s a').isValid());
143 assert.ok(moment('05/1/2012 12:25:00 pm', 'MM/DD/YYYY h:m:s a').isValid());
144 });
145
146 test('empty string with formats', function (assert) {
147 assert.equal(moment('', 'MM').format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
148 assert.equal(moment(' ', 'MM').format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
149 assert.equal(moment(' ', 'DD').format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
150 assert.equal(moment(' ', ['MM', 'DD']).format('YYYY-MM-DD HH:mm:ss'), 'Invalid date');
151
152 assert.ok(!moment('', 'MM').isValid());
153 assert.ok(!moment(' ', 'MM').isValid());
154 assert.ok(!moment(' ', 'DD').isValid());
155 assert.ok(!moment(' ', ['MM', 'DD']).isValid());
156 });
157
158 test('defaulting to current date', function (assert) {
159 var now = moment();
160 assert.equal(moment('12:13:14', 'hh:mm:ss').format('YYYY-MM-DD hh:mm:ss'),
161 now.clone().hour(12).minute(13).second(14).format('YYYY-MM-DD hh:mm:ss'),
162 'given only time default to current date');
163 assert.equal(moment('05', 'DD').format('YYYY-MM-DD'),
164 now.clone().date(5).format('YYYY-MM-DD'),
165 'given day of month default to current month, year');
166 assert.equal(moment('05', 'MM').format('YYYY-MM-DD'),
167 now.clone().month(4).date(1).format('YYYY-MM-DD'),
168 'given month default to current year');
169 assert.equal(moment('1996', 'YYYY').format('YYYY-MM-DD'),
170 now.clone().year(1996).month(0).date(1).format('YYYY-MM-DD'),
171 'given year do not default');
172 });
173
174 test('matching am/pm', function (assert) {
175 assert.equal(moment('2012-09-03T03:00PM', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for PM');
176 assert.equal(moment('2012-09-03T03:00P.M.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for P.M.');
177 assert.equal(moment('2012-09-03T03:00P', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for P');
178 assert.equal(moment('2012-09-03T03:00pm', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for pm');
179 assert.equal(moment('2012-09-03T03:00p.m.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for p.m.');
180 assert.equal(moment('2012-09-03T03:00p', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00PM', 'am/pm should parse correctly for p');
181
182 assert.equal(moment('2012-09-03T03:00AM', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for AM');
183 assert.equal(moment('2012-09-03T03:00A.M.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for A.M.');
184 assert.equal(moment('2012-09-03T03:00A', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for A');
185 assert.equal(moment('2012-09-03T03:00am', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for am');
186 assert.equal(moment('2012-09-03T03:00a.m.', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for a.m.');
187 assert.equal(moment('2012-09-03T03:00a', 'YYYY-MM-DDThh:mmA').format('YYYY-MM-DDThh:mmA'), '2012-09-03T03:00AM', 'am/pm should parse correctly for a');
188
189 assert.equal(moment('5:00p.m.March 4 2012', 'h:mmAMMMM D YYYY').format('YYYY-MM-DDThh:mmA'), '2012-03-04T05:00PM', 'am/pm should parse correctly before month names');
190 });
191
192 test('string with format', function (assert) {
193 moment.locale('en');
194 var a = [
195 ['YYYY-Q', '2014-4'],
196 ['MM-DD-YYYY', '12-02-1999'],
197 ['DD-MM-YYYY', '12-02-1999'],
198 ['DD/MM/YYYY', '12/02/1999'],
199 ['DD_MM_YYYY', '12_02_1999'],
200 ['DD:MM:YYYY', '12:02:1999'],
201 ['D-M-YY', '2-2-99'],
202 ['YY', '99'],
203 ['DDD-YYYY', '300-1999'],
204 ['DD-MM-YYYY h:m:s', '12-02-1999 2:45:10'],
205 ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 am'],
206 ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 pm'],
207 ['h:mm a', '12:00 pm'],
208 ['h:mm a', '12:30 pm'],
209 ['h:mm a', '12:00 am'],
210 ['h:mm a', '12:30 am'],
211 ['HH:mm', '12:00'],
212 ['YYYY-MM-DDTHH:mm:ss', '2011-11-11T11:11:11'],
213 ['MM-DD-YYYY [M]', '12-02-1999 M'],
214 ['ddd MMM DD HH:mm:ss YYYY', 'Tue Apr 07 22:52:51 2009'],
215 ['HH:mm:ss', '12:00:00'],
216 ['HH:mm:ss', '12:30:00'],
217 ['HH:mm:ss', '00:00:00'],
218 ['HH:mm:ss S', '00:30:00 1'],
219 ['HH:mm:ss SS', '00:30:00 12'],
220 ['HH:mm:ss SSS', '00:30:00 123'],
221 ['HH:mm:ss S', '00:30:00 7'],
222 ['HH:mm:ss SS', '00:30:00 78'],
223 ['HH:mm:ss SSS', '00:30:00 789'],
224 ['X', '1234567890'],
225 ['x', '1234567890123'],
226 ['LT', '12:30 AM'],
227 ['LTS', '12:30:29 AM'],
228 ['L', '09/02/1999'],
229 ['l', '9/2/1999'],
230 ['LL', 'September 2, 1999'],
231 ['ll', 'Sep 2, 1999'],
232 ['LLL', 'September 2, 1999 12:30 AM'],
233 ['lll', 'Sep 2, 1999 12:30 AM'],
234 ['LLLL', 'Thursday, September 2, 1999 12:30 AM'],
235 ['llll', 'Thu, Sep 2, 1999 12:30 AM']
236 ],
237 m,
238 i;
239
240 for (i = 0; i < a.length; i++) {
241 m = moment(a[i][1], a[i][0]);
242 assert.ok(m.isValid());
243 assert.equal(m.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
244 }
245 });
246
247 test('2 digit year with YYYY format', function (assert) {
248 assert.equal(moment('9/2/99', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/1999', 'D/M/YYYY ---> 9/2/99');
249 assert.equal(moment('9/2/1999', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/1999', 'D/M/YYYY ---> 9/2/1999');
250 assert.equal(moment('9/2/68', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/2068', 'D/M/YYYY ---> 9/2/68');
251 assert.equal(moment('9/2/69', 'D/M/YYYY').format('DD/MM/YYYY'), '09/02/1969', 'D/M/YYYY ---> 9/2/69');
252 });
253
254 test('unix timestamp format', function (assert) {
255 var formats = ['X', 'X.S', 'X.SS', 'X.SSS'], i, format;
256
257 for (i = 0; i < formats.length; i++) {
258 format = formats[i];
259 assert.equal(moment('1234567890', format).valueOf(), 1234567890 * 1000, format + ' matches timestamp without milliseconds');
260 assert.equal(moment('1234567890.1', format).valueOf(), 1234567890 * 1000 + 100, format + ' matches timestamp with deciseconds');
261 assert.equal(moment('1234567890.12', format).valueOf(), 1234567890 * 1000 + 120, format + ' matches timestamp with centiseconds');
262 assert.equal(moment('1234567890.123', format).valueOf(), 1234567890 * 1000 + 123, format + ' matches timestamp with milliseconds');
263 }
264 });
265
266 test('unix offset milliseconds', function (assert) {
267 assert.equal(moment('1234567890123', 'x').valueOf(), 1234567890123, 'x matches unix offset in milliseconds');
268 });
269
270 test('milliseconds format', function (assert) {
271 assert.equal(moment('1', 'S').get('ms'), 100, 'deciseconds');
272 // assert.equal(moment('10', 'S', true).isValid(), false, 'deciseconds with two digits');
273 // assert.equal(moment('1', 'SS', true).isValid(), false, 'centiseconds with one digits');
274 assert.equal(moment('12', 'SS').get('ms'), 120, 'centiseconds');
275 // assert.equal(moment('123', 'SS', true).isValid(), false, 'centiseconds with three digits');
276 assert.equal(moment('123', 'SSS').get('ms'), 123, 'milliseconds');
277 assert.equal(moment('1234', 'SSSS').get('ms'), 123, 'milliseconds with SSSS');
278 assert.equal(moment('123456789101112', 'SSSS').get('ms'), 123, 'milliseconds with SSSS');
279 });
280
281 test('string with format no separators', function (assert) {
282 moment.locale('en');
283 var a = [
284 ['MMDDYYYY', '12021999'],
285 ['DDMMYYYY', '12021999'],
286 ['YYYYMMDD', '19991202'],
287 ['DDMMMYYYY', '10Sep2001']
288 ], i;
289
290 for (i = 0; i < a.length; i++) {
291 assert.equal(moment(a[i][1], a[i][0]).format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
292 }
293 });
294
295 test('string with format (timezone)', function (assert) {
296 assert.equal(moment('5 -0700', 'H ZZ').toDate().getUTCHours(), 12, 'parse hours \'5 -0700\' ---> \'H ZZ\'');
297 assert.equal(moment('5 -07:00', 'H Z').toDate().getUTCHours(), 12, 'parse hours \'5 -07:00\' ---> \'H Z\'');
298 assert.equal(moment('5 -0730', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours \'5 -0730\' ---> \'H ZZ\'');
299 assert.equal(moment('5 -07:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours \'5 -07:0\' ---> \'H Z\'');
300 assert.equal(moment('5 +0100', 'H ZZ').toDate().getUTCHours(), 4, 'parse hours \'5 +0100\' ---> \'H ZZ\'');
301 assert.equal(moment('5 +01:00', 'H Z').toDate().getUTCHours(), 4, 'parse hours \'5 +01:00\' ---> \'H Z\'');
302 assert.equal(moment('5 +0130', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours \'5 +0130\' ---> \'H ZZ\'');
303 assert.equal(moment('5 +01:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours \'5 +01:30\' ---> \'H Z\'');
304 });
305
306 test('string with format (timezone offset)', function (assert) {
307 var a, b, c, d, e, f;
308 a = new Date(Date.UTC(2011, 0, 1, 1));
309 b = moment('2011 1 1 0 -01:00', 'YYYY MM DD HH Z');
310 assert.equal(a.getHours(), b.hours(), 'date created with utc == parsed string with timezone offset');
311 assert.equal(+a, +b, 'date created with utc == parsed string with timezone offset');
312 c = moment('2011 2 1 10 -05:00', 'YYYY MM DD HH Z');
313 d = moment('2011 2 1 8 -07:00', 'YYYY MM DD HH Z');
314 assert.equal(c.hours(), d.hours(), '10 am central time == 8 am pacific time');
315 e = moment.utc('Fri, 20 Jul 2012 17:15:00', 'ddd, DD MMM YYYY HH:mm:ss');
316 f = moment.utc('Fri, 20 Jul 2012 10:15:00 -0700', 'ddd, DD MMM YYYY HH:mm:ss ZZ');
317 assert.equal(e.hours(), f.hours(), 'parse timezone offset in utc');
318 });
319
320 test('string with timezone around start of year', function (assert) {
321 assert.equal(moment('2000-01-01T00:00:00.000+01:00').toISOString(), '1999-12-31T23:00:00.000Z', '+1:00 around 2000');
322 assert.equal(moment('2000-01-01T00:00:00.000-01:00').toISOString(), '2000-01-01T01:00:00.000Z', '-1:00 around 2000');
323 assert.equal(moment('1970-01-01T00:00:00.000+01:00').toISOString(), '1969-12-31T23:00:00.000Z', '+1:00 around 1970');
324 assert.equal(moment('1970-01-01T00:00:00.000-01:00').toISOString(), '1970-01-01T01:00:00.000Z', '-1:00 around 1970');
325 assert.equal(moment('1200-01-01T00:00:00.000+01:00').toISOString(), '1199-12-31T23:00:00.000Z', '+1:00 around 1200');
326 assert.equal(moment('1200-01-01T00:00:00.000-01:00').toISOString(), '1200-01-01T01:00:00.000Z', '-1:00 around 1200');
327 });
328
329 test('string with array of formats', function (assert) {
330 assert.equal(moment('11-02-1999', ['MM-DD-YYYY', 'DD-MM-YYYY']).format('MM DD YYYY'), '11 02 1999', 'switching month and day');
331 assert.equal(moment('02-11-1999', ['MM/DD/YYYY', 'YYYY MM DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 11 1999', 'year last');
332 assert.equal(moment('1999-02-11', ['MM/DD/YYYY', 'YYYY MM DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 11 1999', 'year first');
333
334 assert.equal(moment('02-11-1999', ['MM/DD/YYYY', 'YYYY MM DD']).format('MM DD YYYY'), '02 11 1999', 'year last');
335 assert.equal(moment('1999-02-11', ['MM/DD/YYYY', 'YYYY MM DD']).format('MM DD YYYY'), '02 11 1999', 'year first');
336 assert.equal(moment('02-11-1999', ['YYYY MM DD', 'MM/DD/YYYY']).format('MM DD YYYY'), '02 11 1999', 'year last');
337 assert.equal(moment('1999-02-11', ['YYYY MM DD', 'MM/DD/YYYY']).format('MM DD YYYY'), '02 11 1999', 'year first');
338
339 assert.equal(moment('13-11-1999', ['MM/DD/YYYY', 'DD/MM/YYYY']).format('MM DD YYYY'), '11 13 1999', 'second must be month');
340 assert.equal(moment('11-13-1999', ['MM/DD/YYYY', 'DD/MM/YYYY']).format('MM DD YYYY'), '11 13 1999', 'first must be month');
341 assert.equal(moment('01-02-2000', ['MM/DD/YYYY', 'DD/MM/YYYY']).format('MM DD YYYY'), '01 02 2000', 'either can be a month, month first format');
342 assert.equal(moment('02-01-2000', ['DD/MM/YYYY', 'MM/DD/YYYY']).format('MM DD YYYY'), '01 02 2000', 'either can be a month, day first format');
343
344 assert.equal(moment('11-02-10', ['MM/DD/YY', 'YY MM DD', 'DD-MM-YY']).format('MM DD YYYY'), '02 11 2010', 'all unparsed substrings have influence on format penalty');
345 assert.equal(moment('11-02-10', ['MM-DD-YY HH:mm', 'YY MM DD']).format('MM DD YYYY'), '02 10 2011', 'prefer formats without extra tokens');
346 assert.equal(moment('11-02-10 junk', ['MM-DD-YY', 'YY.MM.DD junk']).format('MM DD YYYY'), '02 10 2011', 'prefer formats that dont result in extra characters');
347 assert.equal(moment('11-22-10', ['YY-MM-DD', 'YY-DD-MM']).format('MM DD YYYY'), '10 22 2011', 'prefer valid results');
348
349 assert.equal(moment('gibberish', ['YY-MM-DD', 'YY-DD-MM']).format('MM DD YYYY'), 'Invalid date', 'doest throw for invalid strings');
350 assert.equal(moment('gibberish', []).format('MM DD YYYY'), 'Invalid date', 'doest throw for an empty array');
351
352 //https://github.com/moment/moment/issues/1143
353 assert.equal(moment(
354 'System Administrator and Database Assistant (7/1/2011), System Administrator and Database Assistant (7/1/2011), Database Coordinator (7/1/2011), Vice President (7/1/2011), System Administrator and Database Assistant (5/31/2012), Database Coordinator (7/1/2012), System Administrator and Database Assistant (7/1/2013)',
355 ['MM/DD/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD', 'YYYY-MM-DDTHH:mm:ssZ'])
356 .format('YYYY-MM-DD'), '2011-07-01', 'Works for long strings');
357
358 assert.equal(moment('11-02-10', ['MM.DD.YY', 'DD-MM-YY']).format('MM DD YYYY'), '02 11 2010', 'escape RegExp special characters on comparing');
359
360 assert.equal(moment('13-10-98', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YY', 'use two digit year');
361 assert.equal(moment('13-10-1998', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YYYY', 'use four digit year');
362
363 assert.equal(moment('01', ['MM', 'DD'])._f, 'MM', 'Should use first valid format');
364 });
365
366 test('string with array of formats + ISO', function (assert) {
367 assert.equal(moment('1994', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).year(), 1994, 'iso: assert parse YYYY');
368 assert.equal(moment('17:15', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).hour(), 17, 'iso: assert parse HH:mm (1)');
369 assert.equal(moment('17:15', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).minutes(), 15, 'iso: assert parse HH:mm (2)');
370 assert.equal(moment('06', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).month(), 6 - 1, 'iso: assert parse MM');
371 assert.equal(moment('2012-06-01', [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']).parsingFlags().iso, true, 'iso: assert parse iso');
372 assert.equal(moment('2014-05-05', [moment.ISO_8601, 'YYYY-MM-DD']).parsingFlags().iso, true, 'iso: edge case array precedence iso');
373 assert.equal(moment('2014-05-05', ['YYYY-MM-DD', moment.ISO_8601]).parsingFlags().iso, false, 'iso: edge case array precedence not iso');
374 });
375
376 test('string with format - years', function (assert) {
377 assert.equal(moment('67', 'YY').format('YYYY'), '2067', '67 > 2067');
378 assert.equal(moment('68', 'YY').format('YYYY'), '2068', '68 > 2068');
379 assert.equal(moment('69', 'YY').format('YYYY'), '1969', '69 > 1969');
380 assert.equal(moment('70', 'YY').format('YYYY'), '1970', '70 > 1970');
381 });
382
383 test('implicit cloning', function (assert) {
384 var momentA = moment([2011, 10, 10]),
385 momentB = moment(momentA);
386 momentA.month(5);
387 assert.equal(momentB.month(), 10, 'Calling moment() on a moment will create a clone');
388 assert.equal(momentA.month(), 5, 'Calling moment() on a moment will create a clone');
389 });
390
391 test('explicit cloning', function (assert) {
392 var momentA = moment([2011, 10, 10]),
393 momentB = momentA.clone();
394 momentA.month(5);
395 assert.equal(momentB.month(), 10, 'Calling moment() on a moment will create a clone');
396 assert.equal(momentA.month(), 5, 'Calling moment() on a moment will create a clone');
397 });
398
399 test('cloning carrying over utc mode', function (assert) {
400 assert.equal(moment().local().clone()._isUTC, false, 'An explicit cloned local moment should have _isUTC == false');
401 assert.equal(moment().utc().clone()._isUTC, true, 'An cloned utc moment should have _isUTC == true');
402 assert.equal(moment().clone()._isUTC, false, 'An explicit cloned local moment should have _isUTC == false');
403 assert.equal(moment.utc().clone()._isUTC, true, 'An explicit cloned utc moment should have _isUTC == true');
404 assert.equal(moment(moment().local())._isUTC, false, 'An implicit cloned local moment should have _isUTC == false');
405 assert.equal(moment(moment().utc())._isUTC, true, 'An implicit cloned utc moment should have _isUTC == true');
406 assert.equal(moment(moment())._isUTC, false, 'An implicit cloned local moment should have _isUTC == false');
407 assert.equal(moment(moment.utc())._isUTC, true, 'An implicit cloned utc moment should have _isUTC == true');
408 });
409
410 test('parsing iso', function (assert) {
411 var offset = moment([2011, 9, 8]).utcOffset(),
412 pad = function (input) {
413 if (input < 10) {
414 return '0' + input;
415 }
416 return '' + input;
417 },
418 hourOffset = (offset > 0 ? Math.floor(offset / 60) : Math.ceil(offset / 60)),
419 minOffset = offset - (hourOffset * 60),
420 tz = (offset >= 0) ?
421 '+' + pad(hourOffset) + ':' + pad(minOffset) :
422 '-' + pad(-hourOffset) + ':' + pad(-minOffset),
423 tz2 = tz.replace(':', ''),
424 tz3 = tz2.slice(0, 3),
425 formats = [
426 ['2011-10-08', '2011-10-08T00:00:00.000' + tz],
427 ['2011-10-08T18', '2011-10-08T18:00:00.000' + tz],
428 ['2011-10-08T18:04', '2011-10-08T18:04:00.000' + tz],
429 ['2011-10-08T18:04:20', '2011-10-08T18:04:20.000' + tz],
430 ['2011-10-08T18:04' + tz, '2011-10-08T18:04:00.000' + tz],
431 ['2011-10-08T18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
432 ['2011-10-08T18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
433 ['2011-10-08T18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
434 ['2011-10-08T18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
435 ['2011-10-08T18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
436 ['2011-10-08T18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
437 ['2011-10-08T18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
438 ['2011-10-08T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
439 ['2011-10-08 18', '2011-10-08T18:00:00.000' + tz],
440 ['2011-10-08 18:04', '2011-10-08T18:04:00.000' + tz],
441 ['2011-10-08 18:04:20', '2011-10-08T18:04:20.000' + tz],
442 ['2011-10-08 18:04' + tz, '2011-10-08T18:04:00.000' + tz],
443 ['2011-10-08 18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
444 ['2011-10-08 18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
445 ['2011-10-08 18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
446 ['2011-10-08 18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
447 ['2011-10-08 18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
448 ['2011-10-08 18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
449 ['2011-10-08 18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
450 ['2011-10-08 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
451 ['2011-W40', '2011-10-03T00:00:00.000' + tz],
452 ['2011-W40-6', '2011-10-08T00:00:00.000' + tz],
453 ['2011-W40-6T18', '2011-10-08T18:00:00.000' + tz],
454 ['2011-W40-6T18:04', '2011-10-08T18:04:00.000' + tz],
455 ['2011-W40-6T18:04:20', '2011-10-08T18:04:20.000' + tz],
456 ['2011-W40-6T18:04' + tz, '2011-10-08T18:04:00.000' + tz],
457 ['2011-W40-6T18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
458 ['2011-W40-6T18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
459 ['2011-W40-6T18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
460 ['2011-W40-6T18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
461 ['2011-W40-6T18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
462 ['2011-W40-6T18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
463 ['2011-W40-6T18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
464 ['2011-W40-6T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
465 ['2011-W40-6 18', '2011-10-08T18:00:00.000' + tz],
466 ['2011-W40-6 18:04', '2011-10-08T18:04:00.000' + tz],
467 ['2011-W40-6 18:04:20', '2011-10-08T18:04:20.000' + tz],
468 ['2011-W40-6 18:04' + tz, '2011-10-08T18:04:00.000' + tz],
469 ['2011-W40-6 18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
470 ['2011-W40-6 18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
471 ['2011-W40-6 18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
472 ['2011-W40-6 18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
473 ['2011-W40-6 18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
474 ['2011-W40-6 18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
475 ['2011-W40-6 18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
476 ['2011-W40-6 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
477 ['2011-281', '2011-10-08T00:00:00.000' + tz],
478 ['2011-281T18', '2011-10-08T18:00:00.000' + tz],
479 ['2011-281T18:04', '2011-10-08T18:04:00.000' + tz],
480 ['2011-281T18:04:20', '2011-10-08T18:04:20.000' + tz],
481 ['2011-281T18:04' + tz, '2011-10-08T18:04:00.000' + tz],
482 ['2011-281T18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
483 ['2011-281T18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
484 ['2011-281T18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
485 ['2011-281T18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
486 ['2011-281T18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
487 ['2011-281T18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
488 ['2011-281T18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
489 ['2011-281T18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz],
490 ['2011-281 18', '2011-10-08T18:00:00.000' + tz],
491 ['2011-281 18:04', '2011-10-08T18:04:00.000' + tz],
492 ['2011-281 18:04:20', '2011-10-08T18:04:20.000' + tz],
493 ['2011-281 18:04' + tz, '2011-10-08T18:04:00.000' + tz],
494 ['2011-281 18:04:20' + tz, '2011-10-08T18:04:20.000' + tz],
495 ['2011-281 18:04' + tz2, '2011-10-08T18:04:00.000' + tz],
496 ['2011-281 18:04:20' + tz2, '2011-10-08T18:04:20.000' + tz],
497 ['2011-281 18:04' + tz3, '2011-10-08T18:04:00.000' + tz],
498 ['2011-281 18:04:20' + tz3, '2011-10-08T18:04:20.000' + tz],
499 ['2011-281 18:04:20.1' + tz2, '2011-10-08T18:04:20.100' + tz],
500 ['2011-281 18:04:20.11' + tz2, '2011-10-08T18:04:20.110' + tz],
501 ['2011-281 18:04:20.111' + tz2, '2011-10-08T18:04:20.111' + tz]
502 ], i;
503 for (i = 0; i < formats.length; i++) {
504 assert.equal(moment(formats[i][0]).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), formats[i][1], 'moment should be able to parse ISO ' + formats[i][0]);
505 }
506 });
507
508 test('parsing iso week year/week/weekday', function (assert) {
509 assert.equal(moment.utc('2007-W01').format(), '2007-01-01T00:00:00+00:00', '2008 week 1 (1st Jan Mon)');
510 assert.equal(moment.utc('2008-W01').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
511 assert.equal(moment.utc('2003-W01').format(), '2002-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Wed)');
512 assert.equal(moment.utc('2009-W01').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
513 assert.equal(moment.utc('2010-W01').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
514 assert.equal(moment.utc('2011-W01').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
515 assert.equal(moment.utc('2012-W01').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
516 });
517
518 test('parsing week year/week/weekday (dow 1, doy 4)', function (assert) {
519 moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
520
521 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
522 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
523 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
524 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
525 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
526 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
527 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
528
529 moment.defineLocale('dow:1,doy:4', null);
530 });
531
532 test('parsing week year/week/weekday (dow 1, doy 7)', function (assert) {
533 moment.locale('dow:1,doy:7', {week: {dow: 1, doy: 7}});
534
535 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
536 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
537 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
538 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
539 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-28T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
540 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-27T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
541 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-26T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
542 moment.defineLocale('dow:1,doy:7', null);
543 });
544
545 test('parsing week year/week/weekday (dow 0, doy 6)', function (assert) {
546 moment.locale('dow:0,doy:6', {week: {dow: 0, doy: 6}});
547
548 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-31T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
549 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
550 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-29T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
551 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-28T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
552 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-27T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
553 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-26T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
554 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-01T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
555 moment.defineLocale('dow:0,doy:6', null);
556 });
557
558 test('parsing week year/week/weekday (dow 6, doy 12)', function (assert) {
559 moment.locale('dow:6,doy:12', {week: {dow: 6, doy: 12}});
560
561 assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-30T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
562 assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-29T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
563 assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-28T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
564 assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-27T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
565 assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-26T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
566 assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-01T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
567 assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-31T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
568 });
569
570 test('parsing ISO with Z', function (assert) {
571 var i, mom, formats = [
572 ['2011-10-08T18:04', '2011-10-08T18:04:00.000'],
573 ['2011-10-08T18:04:20', '2011-10-08T18:04:20.000'],
574 ['2011-10-08T18:04:20.1', '2011-10-08T18:04:20.100'],
575 ['2011-10-08T18:04:20.11', '2011-10-08T18:04:20.110'],
576 ['2011-10-08T18:04:20.111', '2011-10-08T18:04:20.111'],
577 ['2011-W40-6T18', '2011-10-08T18:00:00.000'],
578 ['2011-W40-6T18:04', '2011-10-08T18:04:00.000'],
579 ['2011-W40-6T18:04:20', '2011-10-08T18:04:20.000'],
580 ['2011-W40-6T18:04:20.1', '2011-10-08T18:04:20.100'],
581 ['2011-W40-6T18:04:20.11', '2011-10-08T18:04:20.110'],
582 ['2011-W40-6T18:04:20.111', '2011-10-08T18:04:20.111'],
583 ['2011-281T18', '2011-10-08T18:00:00.000'],
584 ['2011-281T18:04', '2011-10-08T18:04:00.000'],
585 ['2011-281T18:04:20', '2011-10-08T18:04:20.000'],
586 ['2011-281T18:04:20', '2011-10-08T18:04:20.000'],
587 ['2011-281T18:04:20.1', '2011-10-08T18:04:20.100'],
588 ['2011-281T18:04:20.11', '2011-10-08T18:04:20.110'],
589 ['2011-281T18:04:20.111', '2011-10-08T18:04:20.111']
590 ];
591
592 for (i = 0; i < formats.length; i++) {
593 mom = moment(formats[i][0] + 'Z').utc();
594 assert.equal(mom.format('YYYY-MM-DDTHH:mm:ss.SSS'), formats[i][1], 'moment should be able to parse ISO in UTC ' + formats[i][0] + 'Z');
595
596 mom = moment(formats[i][0] + ' Z').utc();
597 assert.equal(mom.format('YYYY-MM-DDTHH:mm:ss.SSS'), formats[i][1], 'moment should be able to parse ISO in UTC ' + formats[i][0] + ' Z');
598 }
599 });
600
601 test('parsing iso with T', function (assert) {
602 assert.equal(moment('2011-10-08T18')._f, 'YYYY-MM-DDTHH', 'should include \'T\' in the format');
603 assert.equal(moment('2011-10-08T18:20')._f, 'YYYY-MM-DDTHH:mm', 'should include \'T\' in the format');
604 assert.equal(moment('2011-10-08T18:20:13')._f, 'YYYY-MM-DDTHH:mm:ss', 'should include \'T\' in the format');
605 assert.equal(moment('2011-10-08T18:20:13.321')._f, 'YYYY-MM-DDTHH:mm:ss.SSSS', 'should include \'T\' in the format');
606
607 assert.equal(moment('2011-10-08 18')._f, 'YYYY-MM-DD HH', 'should not include \'T\' in the format');
608 assert.equal(moment('2011-10-08 18:20')._f, 'YYYY-MM-DD HH:mm', 'should not include \'T\' in the format');
609 assert.equal(moment('2011-10-08 18:20:13')._f, 'YYYY-MM-DD HH:mm:ss', 'should not include \'T\' in the format');
610 assert.equal(moment('2011-10-08 18:20:13.321')._f, 'YYYY-MM-DD HH:mm:ss.SSSS', 'should not include \'T\' in the format');
611 });
612
613 test('parsing iso Z timezone', function (assert) {
614 var i,
615 formats = [
616 ['2011-10-08T18:04Z', '2011-10-08T18:04:00.000+00:00'],
617 ['2011-10-08T18:04:20Z', '2011-10-08T18:04:20.000+00:00'],
618 ['2011-10-08T18:04:20.111Z', '2011-10-08T18:04:20.111+00:00']
619 ];
620 for (i = 0; i < formats.length; i++) {
621 assert.equal(moment.utc(formats[i][0]).format('YYYY-MM-DDTHH:mm:ss.SSSZ'), formats[i][1], 'moment should be able to parse ISO ' + formats[i][0]);
622 }
623 });
624
625 test('parsing iso Z timezone into local', function (assert) {
626 var m = moment('2011-10-08T18:04:20.111Z');
627
628 assert.equal(m.utc().format('YYYY-MM-DDTHH:mm:ss.SSS'), '2011-10-08T18:04:20.111', 'moment should be able to parse ISO 2011-10-08T18:04:20.111Z');
629 });
630
631 test('parsing iso with more subsecond precision digits', function (assert) {
632 assert.equal(moment.utc('2013-07-31T22:00:00.0000000Z').format(), '2013-07-31T22:00:00+00:00', 'more than 3 subsecond digits');
633 });
634
635 test('null or empty', function (assert) {
636 assert.equal(moment('').isValid(), false, 'moment(\'\') is not valid');
637 assert.equal(moment(null).isValid(), false, 'moment(null) is not valid');
638 assert.equal(moment(null, 'YYYY-MM-DD').isValid(), false, 'moment(\'\', \'format\') is not valid');
639 assert.equal(moment('', 'YYYY-MM-DD').isValid(), false, 'moment(\'\', \'format\') is not valid');
640 assert.equal(moment.utc('').isValid(), false, 'moment.utc(\'\') is not valid');
641 assert.equal(moment.utc(null).isValid(), false, 'moment.utc(null) is not valid');
642 assert.equal(moment.utc(null, 'YYYY-MM-DD').isValid(), false, 'moment.utc(null) is not valid');
643 assert.equal(moment.utc('', 'YYYY-MM-DD').isValid(), false, 'moment.utc(\'\', \'YYYY-MM-DD\') is not valid');
644 });
645
646 test('first century', function (assert) {
647 assert.equal(moment([0, 0, 1]).format('YYYY-MM-DD'), '0000-01-01', 'Year AD 0');
648 assert.equal(moment([99, 0, 1]).format('YYYY-MM-DD'), '0099-01-01', 'Year AD 99');
649 assert.equal(moment([999, 0, 1]).format('YYYY-MM-DD'), '0999-01-01', 'Year AD 999');
650 assert.equal(moment('0 1 1', 'YYYY MM DD').format('YYYY-MM-DD'), '0000-01-01', 'Year AD 0');
651 assert.equal(moment('999 1 1', 'YYYY MM DD').format('YYYY-MM-DD'), '0999-01-01', 'Year AD 999');
652 assert.equal(moment('0 1 1', 'YYYYY MM DD').format('YYYYY-MM-DD'), '00000-01-01', 'Year AD 0');
653 assert.equal(moment('99 1 1', 'YYYYY MM DD').format('YYYYY-MM-DD'), '00099-01-01', 'Year AD 99');
654 assert.equal(moment('999 1 1', 'YYYYY MM DD').format('YYYYY-MM-DD'), '00999-01-01', 'Year AD 999');
655 });
656
657 test('six digit years', function (assert) {
658 assert.equal(moment([-270000, 0, 1]).format('YYYYY-MM-DD'), '-270000-01-01', 'format BC 270,001');
659 assert.equal(moment([270000, 0, 1]).format('YYYYY-MM-DD'), '270000-01-01', 'format AD 270,000');
660 assert.equal(moment('-270000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), -270000, 'parse BC 270,001');
661 assert.equal(moment('270000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), 270000, 'parse AD 270,000');
662 assert.equal(moment('+270000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), 270000, 'parse AD +270,000');
663 assert.equal(moment.utc('-270000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), -270000, 'parse utc BC 270,001');
664 assert.equal(moment.utc('270000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), 270000, 'parse utc AD 270,000');
665 assert.equal(moment.utc('+270000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), 270000, 'parse utc AD +270,000');
666 });
667
668 test('negative four digit years', function (assert) {
669 assert.equal(moment('-1000-01-01', 'YYYYY-MM-DD').toDate().getFullYear(), -1000, 'parse BC 1,001');
670 assert.equal(moment.utc('-1000-01-01', 'YYYYY-MM-DD').toDate().getUTCFullYear(), -1000, 'parse utc BC 1,001');
671 });
672
673 test('strict parsing', function (assert) {
674 assert.equal(moment('2014-', 'YYYY-Q', true).isValid(), false, 'fail missing quarter');
675
676 assert.equal(moment('2012-05', 'YYYY-MM', true).format('YYYY-MM'), '2012-05', 'parse correct string');
677 assert.equal(moment(' 2012-05', 'YYYY-MM', true).isValid(), false, 'fail on extra whitespace');
678 assert.equal(moment('foo 2012-05', '[foo] YYYY-MM', true).format('YYYY-MM'), '2012-05', 'handle fixed text');
679 assert.equal(moment('2012 05', 'YYYY-MM', true).isValid(), false, 'fail on different separator');
680 assert.equal(moment('2012 05', 'YYYY MM DD', true).isValid(), false, 'fail on too many tokens');
681
682 assert.equal(moment('05 30 2010', ['DD MM YYYY', 'MM DD YYYY'], true).format('MM DD YYYY'), '05 30 2010', 'array with bad date');
683 assert.equal(moment('05 30 2010', ['', 'MM DD YYYY'], true).format('MM DD YYYY'), '05 30 2010', 'array with invalid format');
684 assert.equal(moment('05 30 2010', [' DD MM YYYY', 'MM DD YYYY'], true).format('MM DD YYYY'), '05 30 2010', 'array with non-matching format');
685
686 assert.equal(moment('2010.*...', 'YYYY.*', true).isValid(), false, 'invalid format with regex chars');
687 assert.equal(moment('2010.*', 'YYYY.*', true).year(), 2010, 'valid format with regex chars');
688 assert.equal(moment('.*2010.*', '.*YYYY.*', true).year(), 2010, 'valid format with regex chars on both sides');
689
690 //strict tokens
691 assert.equal(moment('-5-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid negative year');
692 assert.equal(moment('2-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid one-digit year');
693 assert.equal(moment('20-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid two-digit year');
694 assert.equal(moment('201-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid three-digit year');
695 assert.equal(moment('2010-05-25', 'YYYY-MM-DD', true).isValid(), true, 'valid four-digit year');
696 assert.equal(moment('22010-05-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid five-digit year');
697
698 assert.equal(moment('12-05-25', 'YY-MM-DD', true).isValid(), true, 'valid two-digit year');
699 assert.equal(moment('2012-05-25', 'YY-MM-DD', true).isValid(), false, 'invalid four-digit year');
700
701 assert.equal(moment('-5-05-25', 'Y-MM-DD', true).isValid(), true, 'valid negative year');
702 assert.equal(moment('2-05-25', 'Y-MM-DD', true).isValid(), true, 'valid one-digit year');
703 assert.equal(moment('20-05-25', 'Y-MM-DD', true).isValid(), true, 'valid two-digit year');
704 assert.equal(moment('201-05-25', 'Y-MM-DD', true).isValid(), true, 'valid three-digit year');
705
706 assert.equal(moment('2012-5-25', 'YYYY-M-DD', true).isValid(), true, 'valid one-digit month');
707 assert.equal(moment('2012-5-25', 'YYYY-MM-DD', true).isValid(), false, 'invalid one-digit month');
708 assert.equal(moment('2012-05-25', 'YYYY-M-DD', true).isValid(), true, 'valid one-digit month');
709 assert.equal(moment('2012-05-25', 'YYYY-MM-DD', true).isValid(), true, 'valid one-digit month');
710
711 assert.equal(moment('2012-05-2', 'YYYY-MM-D', true).isValid(), true, 'valid one-digit day');
712 assert.equal(moment('2012-05-2', 'YYYY-MM-DD', true).isValid(), false, 'invalid one-digit day');
713 assert.equal(moment('2012-05-02', 'YYYY-MM-D', true).isValid(), true, 'valid two-digit day');
714 assert.equal(moment('2012-05-02', 'YYYY-MM-DD', true).isValid(), true, 'valid two-digit day');
715
716 assert.equal(moment('+002012-05-25', 'YYYYY-MM-DD', true).isValid(), true, 'valid six-digit year');
717 assert.equal(moment('+2012-05-25', 'YYYYY-MM-DD', true).isValid(), false, 'invalid four-digit year');
718
719 //thse are kinda pointless, but they should work as expected
720 assert.equal(moment('1', 'S', true).isValid(), true, 'valid one-digit milisecond');
721 assert.equal(moment('12', 'S', true).isValid(), false, 'invalid two-digit milisecond');
722 assert.equal(moment('123', 'S', true).isValid(), false, 'invalid three-digit milisecond');
723
724 assert.equal(moment('1', 'SS', true).isValid(), false, 'invalid one-digit milisecond');
725 assert.equal(moment('12', 'SS', true).isValid(), true, 'valid two-digit milisecond');
726 assert.equal(moment('123', 'SS', true).isValid(), false, 'invalid three-digit milisecond');
727
728 assert.equal(moment('1', 'SSS', true).isValid(), false, 'invalid one-digit milisecond');
729 assert.equal(moment('12', 'SSS', true).isValid(), false, 'invalid two-digit milisecond');
730 assert.equal(moment('123', 'SSS', true).isValid(), true, 'valid three-digit milisecond');
731
732 // strict parsing respects month length
733 assert.ok(moment('1 January 2000', 'D MMMM YYYY', true).isValid(), 'capital long-month + MMMM');
734 assert.ok(!moment('1 January 2000', 'D MMM YYYY', true).isValid(), 'capital long-month + MMM');
735 assert.ok(!moment('1 Jan 2000', 'D MMMM YYYY', true).isValid(), 'capital short-month + MMMM');
736 assert.ok(moment('1 Jan 2000', 'D MMM YYYY', true).isValid(), 'capital short-month + MMM');
737 assert.ok(moment('1 january 2000', 'D MMMM YYYY', true).isValid(), 'lower long-month + MMMM');
738 assert.ok(!moment('1 january 2000', 'D MMM YYYY', true).isValid(), 'lower long-month + MMM');
739 assert.ok(!moment('1 jan 2000', 'D MMMM YYYY', true).isValid(), 'lower short-month + MMMM');
740 assert.ok(moment('1 jan 2000', 'D MMM YYYY', true).isValid(), 'lower short-month + MMM');
741 });
742
743 test('parsing into a locale', function (assert) {
744 moment.defineLocale('parselocale', {
745 months : 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_'),
746 monthsShort : 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_')
747 });
748
749 moment.locale('en');
750
751 assert.equal(moment('2012 seven', 'YYYY MMM', 'parselocale').month(), 6, 'should be able to parse in a specific locale');
752
753 moment.locale('parselocale');
754
755 assert.equal(moment('2012 july', 'YYYY MMM', 'en').month(), 6, 'should be able to parse in a specific locale');
756
757 moment.defineLocale('parselocale', null);
758 });
759
760 function getVerifier(test) {
761 return function (input, format, expected, description, asymetrical) {
762 var m = moment(input, format);
763 test.equal(m.format('YYYY MM DD'), expected, 'compare: ' + description);
764
765 //test round trip
766 if (!asymetrical) {
767 test.equal(m.format(format), input, 'round trip: ' + description);
768 }
769 };
770 }
771
772 test('parsing week and weekday information', function (assert) {
773 var ver = getVerifier(assert);
774
775 // year
776 ver('12', 'gg', '2012 01 01', 'week-year two digits');
777 ver('2012', 'gggg', '2012 01 01', 'week-year four digits');
778
779 ver('99', 'gg', '1998 12 27', 'week-year two digits previous year');
780 ver('1999', 'gggg', '1998 12 27', 'week-year four digits previous year');
781
782 ver('99', 'GG', '1999 01 04', 'iso week-year two digits');
783 ver('1999', 'GGGG', '1999 01 04', 'iso week-year four digits');
784
785 ver('13', 'GG', '2012 12 31', 'iso week-year two digits previous year');
786 ver('2013', 'GGGG', '2012 12 31', 'iso week-year four digits previous year');
787
788 // year + week
789 ver('1999 37', 'gggg w', '1999 09 05', 'week');
790 ver('1999 37', 'gggg ww', '1999 09 05', 'week double');
791 ver('1999 37', 'GGGG W', '1999 09 13', 'iso week');
792 ver('1999 37', 'GGGG WW', '1999 09 13', 'iso week double');
793
794 ver('1999 37 4', 'GGGG WW E', '1999 09 16', 'iso day');
795 ver('1999 37 04', 'GGGG WW E', '1999 09 16', 'iso day wide', true);
796
797 ver('1999 37 4', 'gggg ww e', '1999 09 09', 'day');
798 ver('1999 37 04', 'gggg ww e', '1999 09 09', 'day wide', true);
799
800 // year + week + day
801 ver('1999 37 4', 'gggg ww d', '1999 09 09', 'd');
802 ver('1999 37 Th', 'gggg ww dd', '1999 09 09', 'dd');
803 ver('1999 37 Thu', 'gggg ww ddd', '1999 09 09', 'ddd');
804 ver('1999 37 Thursday', 'gggg ww dddd', '1999 09 09', 'dddd');
805
806 // lower-order only
807 assert.equal(moment('22', 'ww').week(), 22, 'week sets the week by itself');
808 assert.equal(moment('22', 'ww').weekYear(), moment().weekYear(), 'week keeps this year');
809 assert.equal(moment('2012 22', 'YYYY ww').weekYear(), 2012, 'week keeps parsed year');
810
811 assert.equal(moment('22', 'WW').isoWeek(), 22, 'iso week sets the week by itself');
812 assert.equal(moment('2012 22', 'YYYY WW').weekYear(), 2012, 'iso week keeps parsed year');
813 assert.equal(moment('22', 'WW').isoWeekYear(), moment().isoWeekYear(), 'iso week keeps this year');
814
815 // order
816 ver('6 2013 2', 'e gggg w', '2013 01 12', 'order doesn\'t matter');
817 ver('6 2013 2', 'E GGGG W', '2013 01 12', 'iso order doesn\'t matter');
818
819 //can parse other stuff too
820 assert.equal(moment('1999-W37-4 3:30', 'GGGG-[W]WW-E HH:mm').format('YYYY MM DD HH:mm'), '1999 09 16 03:30', 'parsing weeks and hours');
821
822 // In safari, all years before 1300 are shifted back with one day.
823 // http://stackoverflow.com/questions/20768975/safari-subtracts-1-day-from-dates-before-1300
824 if (new Date('1300-01-01').getUTCFullYear() === 1300) {
825 // Years less than 100
826 ver('0098-06', 'GGGG-WW', '0098 02 03', 'small years work', true);
827 }
828 });
829
830 test('parsing localized weekdays', function (assert) {
831 var ver = getVerifier(assert);
832 try {
833 moment.locale('dow:1,doy:4', {
834 weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
835 weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
836 weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
837 week: {dow: 1, doy: 4}
838 });
839 ver('1999 37 4', 'GGGG WW E', '1999 09 16', 'iso ignores locale');
840 ver('1999 37 7', 'GGGG WW E', '1999 09 19', 'iso ignores locale');
841
842 ver('1999 37 0', 'gggg ww e', '1999 09 13', 'localized e uses local doy and dow: 0 = monday');
843 ver('1999 37 4', 'gggg ww e', '1999 09 17', 'localized e uses local doy and dow: 4 = friday');
844
845 ver('1999 37 1', 'gggg ww d', '1999 09 13', 'localized d uses 0-indexed days: 1 = monday');
846 ver('1999 37 Lu', 'gggg ww dd', '1999 09 13', 'localized d uses 0-indexed days: Mo');
847 ver('1999 37 lun.', 'gggg ww ddd', '1999 09 13', 'localized d uses 0-indexed days: Mon');
848 ver('1999 37 lundi', 'gggg ww dddd', '1999 09 13', 'localized d uses 0-indexed days: Monday');
849 ver('1999 37 4', 'gggg ww d', '1999 09 16', 'localized d uses 0-indexed days: 4');
850
851 //sunday goes at the end of the week
852 ver('1999 37 0', 'gggg ww d', '1999 09 19', 'localized d uses 0-indexed days: 0 = sund');
853 ver('1999 37 Di', 'gggg ww dd', '1999 09 19', 'localized d uses 0-indexed days: 0 = sund');
854 }
855 finally {
856 moment.locale('en');
857 }
858 });
859
860 test('parsing with customized two-digit year', function (assert) {
861 var original = moment.parseTwoDigitYear;
862 try {
863 assert.equal(moment('68', 'YY').year(), 2068);
864 assert.equal(moment('69', 'YY').year(), 1969);
865 moment.parseTwoDigitYear = function (input) {
866 return +input + (+input > 30 ? 1900 : 2000);
867 };
868 assert.equal(moment('68', 'YY').year(), 1968);
869 assert.equal(moment('67', 'YY').year(), 1967);
870 assert.equal(moment('31', 'YY').year(), 1931);
871 assert.equal(moment('30', 'YY').year(), 2030);
872 }
873 finally {
874 moment.parseTwoDigitYear = original;
875 }
876 });
877
878 test('array with strings', function (assert) {
879 assert.equal(moment(['2014', '7', '31']).isValid(), true, 'string array + isValid');
880 });
881
882 test('utc with array of formats', function (assert) {
883 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');
884 });
885
886 test('parsing invalid string weekdays', function (assert) {
887 assert.equal(false, moment('a', 'dd').isValid(),
888 'dd with invalid weekday, non-strict');
889 assert.equal(false, moment('a', 'dd', true).isValid(),
890 'dd with invalid weekday, strict');
891 assert.equal(false, moment('a', 'ddd').isValid(),
892 'ddd with invalid weekday, non-strict');
893 assert.equal(false, moment('a', 'ddd', true).isValid(),
894 'ddd with invalid weekday, strict');
895 assert.equal(false, moment('a', 'dddd').isValid(),
896 'dddd with invalid weekday, non-strict');
897 assert.equal(false, moment('a', 'dddd', true).isValid(),
898 'dddd with invalid weekday, strict');
899 });
900
901 test('milliseconds', function (assert) {
902 assert.equal(moment('1', 'S').millisecond(), 100);
903 assert.equal(moment('12', 'SS').millisecond(), 120);
904 assert.equal(moment('123', 'SSS').millisecond(), 123);
905 assert.equal(moment('1234', 'SSSS').millisecond(), 123);
906 assert.equal(moment('12345', 'SSSSS').millisecond(), 123);
907 assert.equal(moment('123456', 'SSSSSS').millisecond(), 123);
908 assert.equal(moment('1234567', 'SSSSSSS').millisecond(), 123);
909 assert.equal(moment('12345678', 'SSSSSSSS').millisecond(), 123);
910 assert.equal(moment('123456789', 'SSSSSSSSS').millisecond(), 123);
911 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2 import each from '../helpers/each';
3
4 module('days in month');
5
6 test('days in month', function (assert) {
7 each([31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], function (days, i) {
8 var firstDay = moment([2012, i]),
9 lastDay = moment([2012, i, days]);
10 assert.equal(firstDay.daysInMonth(), days, firstDay.format('L') + ' should have ' + days + ' days.');
11 assert.equal(lastDay.daysInMonth(), days, lastDay.format('L') + ' should have ' + days + ' days.');
12 });
13 });
14
15 test('days in month leap years', function (assert) {
16 assert.equal(moment([2010, 1]).daysInMonth(), 28, 'Feb 2010 should have 28 days');
17 assert.equal(moment([2100, 1]).daysInMonth(), 28, 'Feb 2100 should have 28 days');
18 assert.equal(moment([2008, 1]).daysInMonth(), 29, 'Feb 2008 should have 29 days');
19 assert.equal(moment([2000, 1]).daysInMonth(), 29, 'Feb 2000 should have 29 days');
20 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 function equal(assert, a, b, message) {
4 assert.ok(Math.abs(a - b) < 0.00000001, '(' + a + ' === ' + b + ') ' + message);
5 }
6
7 function dstForYear(year) {
8 var start = moment([year]),
9 end = moment([year + 1]),
10 current = start.clone(),
11 last;
12
13 while (current < end) {
14 last = current.clone();
15 current.add(24, 'hour');
16 if (last.utcOffset() !== current.utcOffset()) {
17 end = current.clone();
18 current = last.clone();
19 break;
20 }
21 }
22
23 while (current < end) {
24 last = current.clone();
25 current.add(1, 'hour');
26 if (last.utcOffset() !== current.utcOffset()) {
27 return {
28 moment : last,
29 diff : -(current.utcOffset() - last.utcOffset()) / 60
30 };
31 }
32 }
33 }
34
35 module('diff');
36
37 test('diff', function (assert) {
38 assert.equal(moment(1000).diff(0), 1000, '1 second - 0 = 1000');
39 assert.equal(moment(1000).diff(500), 500, '1 second - 0.5 seconds = 500');
40 assert.equal(moment(0).diff(1000), -1000, '0 - 1 second = -1000');
41 assert.equal(moment(new Date(1000)).diff(1000), 0, '1 second - 1 second = 0');
42 var oneHourDate = new Date(),
43 nowDate = new Date(+oneHourDate);
44 oneHourDate.setHours(oneHourDate.getHours() + 1);
45 assert.equal(moment(oneHourDate).diff(nowDate), 60 * 60 * 1000, '1 hour from now = 3600000');
46 });
47
48 test('diff key after', function (assert) {
49 assert.equal(moment([2010]).diff([2011], 'years'), -1, 'year diff');
50 assert.equal(moment([2010]).diff([2010, 2], 'months'), -2, 'month diff');
51 assert.equal(moment([2010]).diff([2010, 0, 7], 'weeks'), 0, 'week diff');
52 assert.equal(moment([2010]).diff([2010, 0, 8], 'weeks'), -1, 'week diff');
53 assert.equal(moment([2010]).diff([2010, 0, 21], 'weeks'), -2, 'week diff');
54 assert.equal(moment([2010]).diff([2010, 0, 22], 'weeks'), -3, 'week diff');
55 assert.equal(moment([2010]).diff([2010, 0, 4], 'days'), -3, 'day diff');
56 assert.equal(moment([2010]).diff([2010, 0, 1, 4], 'hours'), -4, 'hour diff');
57 assert.equal(moment([2010]).diff([2010, 0, 1, 0, 5], 'minutes'), -5, 'minute diff');
58 assert.equal(moment([2010]).diff([2010, 0, 1, 0, 0, 6], 'seconds'), -6, 'second diff');
59 });
60
61 test('diff key before', function (assert) {
62 assert.equal(moment([2011]).diff([2010], 'years'), 1, 'year diff');
63 assert.equal(moment([2010, 2]).diff([2010], 'months'), 2, 'month diff');
64 assert.equal(moment([2010, 0, 4]).diff([2010], 'days'), 3, 'day diff');
65 assert.equal(moment([2010, 0, 7]).diff([2010], 'weeks'), 0, 'week diff');
66 assert.equal(moment([2010, 0, 8]).diff([2010], 'weeks'), 1, 'week diff');
67 assert.equal(moment([2010, 0, 21]).diff([2010], 'weeks'), 2, 'week diff');
68 assert.equal(moment([2010, 0, 22]).diff([2010], 'weeks'), 3, 'week diff');
69 assert.equal(moment([2010, 0, 1, 4]).diff([2010], 'hours'), 4, 'hour diff');
70 assert.equal(moment([2010, 0, 1, 0, 5]).diff([2010], 'minutes'), 5, 'minute diff');
71 assert.equal(moment([2010, 0, 1, 0, 0, 6]).diff([2010], 'seconds'), 6, 'second diff');
72 });
73
74 test('diff key before singular', function (assert) {
75 assert.equal(moment([2011]).diff([2010], 'year'), 1, 'year diff singular');
76 assert.equal(moment([2010, 2]).diff([2010], 'month'), 2, 'month diff singular');
77 assert.equal(moment([2010, 0, 4]).diff([2010], 'day'), 3, 'day diff singular');
78 assert.equal(moment([2010, 0, 7]).diff([2010], 'week'), 0, 'week diff singular');
79 assert.equal(moment([2010, 0, 8]).diff([2010], 'week'), 1, 'week diff singular');
80 assert.equal(moment([2010, 0, 21]).diff([2010], 'week'), 2, 'week diff singular');
81 assert.equal(moment([2010, 0, 22]).diff([2010], 'week'), 3, 'week diff singular');
82 assert.equal(moment([2010, 0, 1, 4]).diff([2010], 'hour'), 4, 'hour diff singular');
83 assert.equal(moment([2010, 0, 1, 0, 5]).diff([2010], 'minute'), 5, 'minute diff singular');
84 assert.equal(moment([2010, 0, 1, 0, 0, 6]).diff([2010], 'second'), 6, 'second diff singular');
85 });
86
87 test('diff key before abbreviated', function (assert) {
88 assert.equal(moment([2011]).diff([2010], 'y'), 1, 'year diff abbreviated');
89 assert.equal(moment([2010, 2]).diff([2010], 'M'), 2, 'month diff abbreviated');
90 assert.equal(moment([2010, 0, 4]).diff([2010], 'd'), 3, 'day diff abbreviated');
91 assert.equal(moment([2010, 0, 7]).diff([2010], 'w'), 0, 'week diff abbreviated');
92 assert.equal(moment([2010, 0, 8]).diff([2010], 'w'), 1, 'week diff abbreviated');
93 assert.equal(moment([2010, 0, 21]).diff([2010], 'w'), 2, 'week diff abbreviated');
94 assert.equal(moment([2010, 0, 22]).diff([2010], 'w'), 3, 'week diff abbreviated');
95 assert.equal(moment([2010, 0, 1, 4]).diff([2010], 'h'), 4, 'hour diff abbreviated');
96 assert.equal(moment([2010, 0, 1, 0, 5]).diff([2010], 'm'), 5, 'minute diff abbreviated');
97 assert.equal(moment([2010, 0, 1, 0, 0, 6]).diff([2010], 's'), 6, 'second diff abbreviated');
98 });
99
100 test('diff month', function (assert) {
101 assert.equal(moment([2011, 0, 31]).diff([2011, 2, 1], 'months'), -1, 'month diff');
102 });
103
104 test('diff across DST', function (assert) {
105 var dst = dstForYear(2012), a, b, daysInMonth;
106 if (!dst) {
107 assert.equal(42, 42, 'at least one assertion');
108 return;
109 }
110
111 a = dst.moment;
112 b = a.clone().utc().add(12, 'hours').local();
113 daysInMonth = (a.daysInMonth() + b.daysInMonth()) / 2;
114 assert.equal(b.diff(a, 'milliseconds', true), 12 * 60 * 60 * 1000,
115 'ms diff across DST');
116 assert.equal(b.diff(a, 'seconds', true), 12 * 60 * 60,
117 'second diff across DST');
118 assert.equal(b.diff(a, 'minutes', true), 12 * 60,
119 'minute diff across DST');
120 assert.equal(b.diff(a, 'hours', true), 12,
121 'hour diff across DST');
122 assert.equal(b.diff(a, 'days', true), (12 - dst.diff) / 24,
123 'day diff across DST');
124 equal(assert, b.diff(a, 'weeks', true), (12 - dst.diff) / 24 / 7,
125 'week diff across DST');
126 assert.ok(0.95 / (2 * 31) < b.diff(a, 'months', true),
127 'month diff across DST, lower bound');
128 assert.ok(b.diff(a, 'month', true) < 1.05 / (2 * 28),
129 'month diff across DST, upper bound');
130 assert.ok(0.95 / (2 * 31 * 12) < b.diff(a, 'years', true),
131 'year diff across DST, lower bound');
132 assert.ok(b.diff(a, 'year', true) < 1.05 / (2 * 28 * 12),
133 'year diff across DST, upper bound');
134
135 a = dst.moment;
136 b = a.clone().utc().add(12 + dst.diff, 'hours').local();
137 daysInMonth = (a.daysInMonth() + b.daysInMonth()) / 2;
138
139 assert.equal(b.diff(a, 'milliseconds', true),
140 (12 + dst.diff) * 60 * 60 * 1000,
141 'ms diff across DST');
142 assert.equal(b.diff(a, 'seconds', true), (12 + dst.diff) * 60 * 60,
143 'second diff across DST');
144 assert.equal(b.diff(a, 'minutes', true), (12 + dst.diff) * 60,
145 'minute diff across DST');
146 assert.equal(b.diff(a, 'hours', true), (12 + dst.diff),
147 'hour diff across DST');
148 assert.equal(b.diff(a, 'days', true), 12 / 24, 'day diff across DST');
149 equal(assert, b.diff(a, 'weeks', true), 12 / 24 / 7,
150 'week diff across DST');
151 assert.ok(0.95 / (2 * 31) < b.diff(a, 'months', true),
152 'month diff across DST, lower bound');
153 assert.ok(b.diff(a, 'month', true) < 1.05 / (2 * 28),
154 'month diff across DST, upper bound');
155 assert.ok(0.95 / (2 * 31 * 12) < b.diff(a, 'years', true),
156 'year diff across DST, lower bound');
157 assert.ok(b.diff(a, 'year', true) < 1.05 / (2 * 28 * 12),
158 'year diff across DST, upper bound');
159 });
160
161 test('diff overflow', function (assert) {
162 assert.equal(moment([2011]).diff([2010], 'months'), 12, 'month diff');
163 assert.equal(moment([2010, 0, 2]).diff([2010], 'hours'), 24, 'hour diff');
164 assert.equal(moment([2010, 0, 1, 2]).diff([2010], 'minutes'), 120, 'minute diff');
165 assert.equal(moment([2010, 0, 1, 0, 4]).diff([2010], 'seconds'), 240, 'second diff');
166 });
167
168 test('diff between utc and local', function (assert) {
169 if (moment([2012]).utcOffset() === moment([2011]).utcOffset()) {
170 // Russia's utc offset on 1st of Jan 2012 vs 2011 is different
171 assert.equal(moment([2012]).utc().diff([2011], 'years'), 1, 'year diff');
172 }
173 assert.equal(moment([2010, 2, 2]).utc().diff([2010, 0, 2], 'months'), 2, 'month diff');
174 assert.equal(moment([2010, 0, 4]).utc().diff([2010], 'days'), 3, 'day diff');
175 assert.equal(moment([2010, 0, 22]).utc().diff([2010], 'weeks'), 3, 'week diff');
176 assert.equal(moment([2010, 0, 1, 4]).utc().diff([2010], 'hours'), 4, 'hour diff');
177 assert.equal(moment([2010, 0, 1, 0, 5]).utc().diff([2010], 'minutes'), 5, 'minute diff');
178 assert.equal(moment([2010, 0, 1, 0, 0, 6]).utc().diff([2010], 'seconds'), 6, 'second diff');
179 });
180
181 test('diff floored', function (assert) {
182 assert.equal(moment([2010, 0, 1, 23]).diff([2010], 'day'), 0, '23 hours = 0 days');
183 assert.equal(moment([2010, 0, 1, 23, 59]).diff([2010], 'day'), 0, '23:59 hours = 0 days');
184 assert.equal(moment([2010, 0, 1, 24]).diff([2010], 'day'), 1, '24 hours = 1 day');
185 assert.equal(moment([2010, 0, 2]).diff([2011, 0, 1], 'year'), 0, 'year rounded down');
186 assert.equal(moment([2011, 0, 1]).diff([2010, 0, 2], 'year'), 0, 'year rounded down');
187 assert.equal(moment([2010, 0, 2]).diff([2011, 0, 2], 'year'), -1, 'year rounded down');
188 assert.equal(moment([2011, 0, 2]).diff([2010, 0, 2], 'year'), 1, 'year rounded down');
189 });
190
191 test('year diffs include dates', function (assert) {
192 assert.ok(moment([2012, 1, 19]).diff(moment([2002, 1, 20]), 'years', true) < 10, 'year diff should include date of month');
193 });
194
195 test('month diffs', function (assert) {
196 // due to floating point math errors, these tests just need to be accurate within 0.00000001
197 assert.equal(moment([2012, 0, 1]).diff([2012, 1, 1], 'months', true), -1, 'Jan 1 to Feb 1 should be 1 month');
198 equal(assert, moment([2012, 0, 1]).diff([2012, 0, 1, 12], 'months', true), -0.5 / 31, 'Jan 1 to Jan 1 noon should be 0.5 / 31 months');
199 assert.equal(moment([2012, 0, 15]).diff([2012, 1, 15], 'months', true), -1, 'Jan 15 to Feb 15 should be 1 month');
200 assert.equal(moment([2012, 0, 28]).diff([2012, 1, 28], 'months', true), -1, 'Jan 28 to Feb 28 should be 1 month');
201 assert.ok(moment([2012, 0, 31]).diff([2012, 1, 29], 'months', true), -1, 'Jan 31 to Feb 29 should be 1 month');
202 assert.ok(-1 > moment([2012, 0, 31]).diff([2012, 2, 1], 'months', true), 'Jan 31 to Mar 1 should be more than 1 month');
203 assert.ok(-30 / 28 < moment([2012, 0, 31]).diff([2012, 2, 1], 'months', true), 'Jan 31 to Mar 1 should be less than 1 month and 1 day');
204 equal(assert, moment([2012, 0, 1]).diff([2012, 0, 31], 'months', true), -(30 / 31), 'Jan 1 to Jan 31 should be 30 / 31 months');
205 assert.ok(0 < moment('2014-02-01').diff(moment('2014-01-31'), 'months', true), 'jan-31 to feb-1 diff is positive');
206 });
207
208 test('exact month diffs', function (assert) {
209 // generate all pairs of months and compute month diff, with fixed day
210 // of month = 15.
211
212 var m1, m2;
213 for (m1 = 0; m1 < 12; ++m1) {
214 for (m2 = m1; m2 < 12; ++m2) {
215 assert.equal(moment([2013, m2, 15]).diff(moment([2013, m1, 15]), 'months', true), m2 - m1,
216 'month diff from 2013-' + m1 + '-15 to 2013-' + m2 + '-15');
217 }
218 }
219 });
220
221 test('year diffs', function (assert) {
222 // due to floating point math errors, these tests just need to be accurate within 0.00000001
223 equal(assert, moment([2012, 0, 1]).diff([2013, 0, 1], 'years', true), -1, 'Jan 1 2012 to Jan 1 2013 should be 1 year');
224 equal(assert, moment([2012, 1, 28]).diff([2013, 1, 28], 'years', true), -1, 'Feb 28 2012 to Feb 28 2013 should be 1 year');
225 equal(assert, moment([2012, 2, 1]).diff([2013, 2, 1], 'years', true), -1, 'Mar 1 2012 to Mar 1 2013 should be 1 year');
226 equal(assert, moment([2012, 11, 1]).diff([2013, 11, 1], 'years', true), -1, 'Dec 1 2012 to Dec 1 2013 should be 1 year');
227 equal(assert, moment([2012, 11, 31]).diff([2013, 11, 31], 'years', true), -1, 'Dec 31 2012 to Dec 31 2013 should be 1 year');
228 equal(assert, moment([2012, 0, 1]).diff([2013, 6, 1], 'years', true), -1.5, 'Jan 1 2012 to Jul 1 2013 should be 1.5 years');
229 equal(assert, moment([2012, 0, 31]).diff([2013, 6, 31], 'years', true), -1.5, 'Jan 31 2012 to Jul 31 2013 should be 1.5 years');
230 equal(assert, moment([2012, 0, 1]).diff([2013, 0, 1, 12], 'years', true), -1 - (0.5 / 31) / 12, 'Jan 1 2012 to Jan 1 2013 noon should be 1+(0.5 / 31) / 12 years');
231 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');
232 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');
233 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('duration');
4
5 test('object instantiation', function (assert) {
6 var d = moment.duration({
7 years: 2,
8 months: 3,
9 weeks: 2,
10 days: 1,
11 hours: 8,
12 minutes: 9,
13 seconds: 20,
14 milliseconds: 12
15 });
16
17 assert.equal(d.years(), 2, 'years');
18 assert.equal(d.months(), 3, 'months');
19 assert.equal(d.weeks(), 2, 'weeks');
20 assert.equal(d.days(), 15, 'days'); // two weeks + 1 day
21 assert.equal(d.hours(), 8, 'hours');
22 assert.equal(d.minutes(), 9, 'minutes');
23 assert.equal(d.seconds(), 20, 'seconds');
24 assert.equal(d.milliseconds(), 12, 'milliseconds');
25 });
26
27 test('object instantiation with strings', function (assert) {
28 var d = moment.duration({
29 years: '2',
30 months: '3',
31 weeks: '2',
32 days: '1',
33 hours: '8',
34 minutes: '9',
35 seconds: '20',
36 milliseconds: '12'
37 });
38
39 assert.equal(d.years(), 2, 'years');
40 assert.equal(d.months(), 3, 'months');
41 assert.equal(d.weeks(), 2, 'weeks');
42 assert.equal(d.days(), 15, 'days'); // two weeks + 1 day
43 assert.equal(d.hours(), 8, 'hours');
44 assert.equal(d.minutes(), 9, 'minutes');
45 assert.equal(d.seconds(), 20, 'seconds');
46 assert.equal(d.milliseconds(), 12, 'milliseconds');
47 });
48
49 test('milliseconds instantiation', function (assert) {
50 assert.equal(moment.duration(72).milliseconds(), 72, 'milliseconds');
51 });
52
53 test('undefined instantiation', function (assert) {
54 assert.equal(moment.duration(undefined).milliseconds(), 0, 'milliseconds');
55 });
56
57 test('null instantiation', function (assert) {
58 assert.equal(moment.duration(null).milliseconds(), 0, 'milliseconds');
59 });
60
61 test('instantiation by type', function (assert) {
62 assert.equal(moment.duration(1, 'years').years(), 1, 'years');
63 assert.equal(moment.duration(1, 'y').years(), 1, 'y');
64 assert.equal(moment.duration(2, 'months').months(), 2, 'months');
65 assert.equal(moment.duration(2, 'M').months(), 2, 'M');
66 assert.equal(moment.duration(3, 'weeks').weeks(), 3, 'weeks');
67 assert.equal(moment.duration(3, 'w').weeks(), 3, 'weeks');
68 assert.equal(moment.duration(4, 'days').days(), 4, 'days');
69 assert.equal(moment.duration(4, 'd').days(), 4, 'd');
70 assert.equal(moment.duration(5, 'hours').hours(), 5, 'hours');
71 assert.equal(moment.duration(5, 'h').hours(), 5, 'h');
72 assert.equal(moment.duration(6, 'minutes').minutes(), 6, 'minutes');
73 assert.equal(moment.duration(6, 'm').minutes(), 6, 'm');
74 assert.equal(moment.duration(7, 'seconds').seconds(), 7, 'seconds');
75 assert.equal(moment.duration(7, 's').seconds(), 7, 's');
76 assert.equal(moment.duration(8, 'milliseconds').milliseconds(), 8, 'milliseconds');
77 assert.equal(moment.duration(8, 'ms').milliseconds(), 8, 'ms');
78 });
79
80 test('shortcuts', function (assert) {
81 assert.equal(moment.duration({y: 1}).years(), 1, 'years = y');
82 assert.equal(moment.duration({M: 2}).months(), 2, 'months = M');
83 assert.equal(moment.duration({w: 3}).weeks(), 3, 'weeks = w');
84 assert.equal(moment.duration({d: 4}).days(), 4, 'days = d');
85 assert.equal(moment.duration({h: 5}).hours(), 5, 'hours = h');
86 assert.equal(moment.duration({m: 6}).minutes(), 6, 'minutes = m');
87 assert.equal(moment.duration({s: 7}).seconds(), 7, 'seconds = s');
88 assert.equal(moment.duration({ms: 8}).milliseconds(), 8, 'milliseconds = ms');
89 });
90
91 test('generic getter', function (assert) {
92 assert.equal(moment.duration(1, 'years').get('years'), 1, 'years');
93 assert.equal(moment.duration(1, 'years').get('year'), 1, 'years = year');
94 assert.equal(moment.duration(1, 'years').get('y'), 1, 'years = y');
95 assert.equal(moment.duration(2, 'months').get('months'), 2, 'months');
96 assert.equal(moment.duration(2, 'months').get('month'), 2, 'months = month');
97 assert.equal(moment.duration(2, 'months').get('M'), 2, 'months = M');
98 assert.equal(moment.duration(3, 'weeks').get('weeks'), 3, 'weeks');
99 assert.equal(moment.duration(3, 'weeks').get('week'), 3, 'weeks = week');
100 assert.equal(moment.duration(3, 'weeks').get('w'), 3, 'weeks = w');
101 assert.equal(moment.duration(4, 'days').get('days'), 4, 'days');
102 assert.equal(moment.duration(4, 'days').get('day'), 4, 'days = day');
103 assert.equal(moment.duration(4, 'days').get('d'), 4, 'days = d');
104 assert.equal(moment.duration(5, 'hours').get('hours'), 5, 'hours');
105 assert.equal(moment.duration(5, 'hours').get('hour'), 5, 'hours = hour');
106 assert.equal(moment.duration(5, 'hours').get('h'), 5, 'hours = h');
107 assert.equal(moment.duration(6, 'minutes').get('minutes'), 6, 'minutes');
108 assert.equal(moment.duration(6, 'minutes').get('minute'), 6, 'minutes = minute');
109 assert.equal(moment.duration(6, 'minutes').get('m'), 6, 'minutes = m');
110 assert.equal(moment.duration(7, 'seconds').get('seconds'), 7, 'seconds');
111 assert.equal(moment.duration(7, 'seconds').get('second'), 7, 'seconds = second');
112 assert.equal(moment.duration(7, 'seconds').get('s'), 7, 'seconds = s');
113 assert.equal(moment.duration(8, 'milliseconds').get('milliseconds'), 8, 'milliseconds');
114 assert.equal(moment.duration(8, 'milliseconds').get('millisecond'), 8, 'milliseconds = millisecond');
115 assert.equal(moment.duration(8, 'milliseconds').get('ms'), 8, 'milliseconds = ms');
116 });
117
118 test('instantiation from another duration', function (assert) {
119 var simple = moment.duration(1234),
120 lengthy = moment.duration(60 * 60 * 24 * 360 * 1e3),
121 complicated = moment.duration({
122 years: 2,
123 months: 3,
124 weeks: 4,
125 days: 1,
126 hours: 8,
127 minutes: 9,
128 seconds: 20,
129 milliseconds: 12
130 }),
131 modified = moment.duration(1, 'day').add(moment.duration(1, 'day'));
132
133 assert.deepEqual(moment.duration(simple), simple, 'simple clones are equal');
134 assert.deepEqual(moment.duration(lengthy), lengthy, 'lengthy clones are equal');
135 assert.deepEqual(moment.duration(complicated), complicated, 'complicated clones are equal');
136 assert.deepEqual(moment.duration(modified), modified, 'cloning modified duration works');
137 });
138
139 test('instantiation from 24-hour time zero', function (assert) {
140 assert.equal(moment.duration('00:00').years(), 0, '0 years');
141 assert.equal(moment.duration('00:00').days(), 0, '0 days');
142 assert.equal(moment.duration('00:00').hours(), 0, '0 hours');
143 assert.equal(moment.duration('00:00').minutes(), 0, '0 minutes');
144 assert.equal(moment.duration('00:00').seconds(), 0, '0 seconds');
145 assert.equal(moment.duration('00:00').milliseconds(), 0, '0 milliseconds');
146 });
147
148 test('instantiation from 24-hour time <24 hours', function (assert) {
149 assert.equal(moment.duration('06:45').years(), 0, '0 years');
150 assert.equal(moment.duration('06:45').days(), 0, '0 days');
151 assert.equal(moment.duration('06:45').hours(), 6, '6 hours');
152 assert.equal(moment.duration('06:45').minutes(), 45, '45 minutes');
153 assert.equal(moment.duration('06:45').seconds(), 0, '0 seconds');
154 assert.equal(moment.duration('06:45').milliseconds(), 0, '0 milliseconds');
155 });
156
157 test('instantiation from 24-hour time >24 hours', function (assert) {
158 assert.equal(moment.duration('26:45').years(), 0, '0 years');
159 assert.equal(moment.duration('26:45').days(), 1, '0 days');
160 assert.equal(moment.duration('26:45').hours(), 2, '2 hours');
161 assert.equal(moment.duration('26:45').minutes(), 45, '45 minutes');
162 assert.equal(moment.duration('26:45').seconds(), 0, '0 seconds');
163 assert.equal(moment.duration('26:45').milliseconds(), 0, '0 milliseconds');
164 });
165
166 test('instatiation from serialized C# TimeSpan zero', function (assert) {
167 assert.equal(moment.duration('00:00:00').years(), 0, '0 years');
168 assert.equal(moment.duration('00:00:00').days(), 0, '0 days');
169 assert.equal(moment.duration('00:00:00').hours(), 0, '0 hours');
170 assert.equal(moment.duration('00:00:00').minutes(), 0, '0 minutes');
171 assert.equal(moment.duration('00:00:00').seconds(), 0, '0 seconds');
172 assert.equal(moment.duration('00:00:00').milliseconds(), 0, '0 milliseconds');
173 });
174
175 test('instatiation from serialized C# TimeSpan with days', function (assert) {
176 assert.equal(moment.duration('1.02:03:04.9999999').years(), 0, '0 years');
177 assert.equal(moment.duration('1.02:03:04.9999999').days(), 1, '1 day');
178 assert.equal(moment.duration('1.02:03:04.9999999').hours(), 2, '2 hours');
179 assert.equal(moment.duration('1.02:03:04.9999999').minutes(), 3, '3 minutes');
180 assert.equal(moment.duration('1.02:03:04.9999999').seconds(), 4, '4 seconds');
181 assert.equal(moment.duration('1.02:03:04.9999999').milliseconds(), 999, '999 milliseconds');
182 });
183
184 test('instatiation from serialized C# TimeSpan without days', function (assert) {
185 assert.equal(moment.duration('01:02:03.9999999').years(), 0, '0 years');
186 assert.equal(moment.duration('01:02:03.9999999').days(), 0, '0 days');
187 assert.equal(moment.duration('01:02:03.9999999').hours(), 1, '1 hour');
188 assert.equal(moment.duration('01:02:03.9999999').minutes(), 2, '2 minutes');
189 assert.equal(moment.duration('01:02:03.9999999').seconds(), 3, '3 seconds');
190 assert.equal(moment.duration('01:02:03.9999999').milliseconds(), 999, '999 milliseconds');
191
192 assert.equal(moment.duration('23:59:59.9999999').days(), 0, '0 days');
193 assert.equal(moment.duration('23:59:59.9999999').hours(), 23, '23 hours');
194
195 assert.equal(moment.duration('500:59:59.9999999').days(), 20, '500 hours overflows to 20 days');
196 assert.equal(moment.duration('500:59:59.9999999').hours(), 20, '500 hours overflows to 20 hours');
197 });
198
199 test('instatiation from serialized C# TimeSpan without days or milliseconds', function (assert) {
200 assert.equal(moment.duration('01:02:03').years(), 0, '0 years');
201 assert.equal(moment.duration('01:02:03').days(), 0, '0 days');
202 assert.equal(moment.duration('01:02:03').hours(), 1, '1 hour');
203 assert.equal(moment.duration('01:02:03').minutes(), 2, '2 minutes');
204 assert.equal(moment.duration('01:02:03').seconds(), 3, '3 seconds');
205 assert.equal(moment.duration('01:02:03').milliseconds(), 0, '0 milliseconds');
206 });
207
208 test('instatiation from serialized C# TimeSpan without milliseconds', function (assert) {
209 assert.equal(moment.duration('1.02:03:04').years(), 0, '0 years');
210 assert.equal(moment.duration('1.02:03:04').days(), 1, '1 day');
211 assert.equal(moment.duration('1.02:03:04').hours(), 2, '2 hours');
212 assert.equal(moment.duration('1.02:03:04').minutes(), 3, '3 minutes');
213 assert.equal(moment.duration('1.02:03:04').seconds(), 4, '4 seconds');
214 assert.equal(moment.duration('1.02:03:04').milliseconds(), 0, '0 milliseconds');
215 });
216
217 test('instatiation from serialized C# TimeSpan maxValue', function (assert) {
218 var d = moment.duration('10675199.02:48:05.4775807');
219
220 assert.equal(d.years(), 29227, '29227 years');
221 assert.equal(d.months(), 8, '8 months');
222 assert.equal(d.days(), 12, '12 day'); // if you have to change this value -- just do it
223
224 assert.equal(d.hours(), 2, '2 hours');
225 assert.equal(d.minutes(), 48, '48 minutes');
226 assert.equal(d.seconds(), 5, '5 seconds');
227 assert.equal(d.milliseconds(), 477, '477 milliseconds');
228 });
229
230 test('instatiation from serialized C# TimeSpan minValue', function (assert) {
231 var d = moment.duration('-10675199.02:48:05.4775808');
232
233 assert.equal(d.years(), -29227, '29653 years');
234 assert.equal(d.months(), -8, '8 day');
235 assert.equal(d.days(), -12, '12 day'); // if you have to change this value -- just do it
236
237 assert.equal(d.hours(), -2, '2 hours');
238 assert.equal(d.minutes(), -48, '48 minutes');
239 assert.equal(d.seconds(), -5, '5 seconds');
240 assert.equal(d.milliseconds(), -477, '477 milliseconds');
241 });
242
243 test('instantiation from ISO 8601 duration', function (assert) {
244 assert.equal(moment.duration('P1Y2M3DT4H5M6S').asSeconds(), moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).asSeconds(), 'all fields');
245 assert.equal(moment.duration('P1M').asSeconds(), moment.duration({M: 1}).asSeconds(), 'single month field');
246 assert.equal(moment.duration('PT1M').asSeconds(), moment.duration({m: 1}).asSeconds(), 'single minute field');
247 assert.equal(moment.duration('P1MT2H').asSeconds(), moment.duration({M: 1, h: 2}).asSeconds(), 'random fields missing');
248 assert.equal(moment.duration('-P60D').asSeconds(), moment.duration({d: -60}).asSeconds(), 'negative days');
249 assert.equal(moment.duration('PT0.5S').asSeconds(), moment.duration({s: 0.5}).asSeconds(), 'fractional seconds');
250 assert.equal(moment.duration('PT0,5S').asSeconds(), moment.duration({s: 0.5}).asSeconds(), 'fractional seconds (comma)');
251 });
252
253 test('serialization to ISO 8601 duration strings', function (assert) {
254 assert.equal(moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).toISOString(), 'P1Y2M3DT4H5M6S', 'all fields');
255 assert.equal(moment.duration({M: -1}).toISOString(), '-P1M', 'one month ago');
256 assert.equal(moment.duration({m: -1}).toISOString(), '-PT1M', 'one minute ago');
257 assert.equal(moment.duration({s: -0.5}).toISOString(), '-PT0.5S', 'one half second ago');
258 assert.equal(moment.duration({y: -0.5, M: 1}).toISOString(), '-P5M', 'a month after half a year ago');
259 assert.equal(moment.duration({}).toISOString(), 'P0D', 'zero duration');
260 assert.equal(moment.duration({M: 16, d:40, s: 86465}).toISOString(), 'P1Y4M40DT24H1M5S', 'all fields');
261 });
262
263 test('toString acts as toISOString', function (assert) {
264 assert.equal(moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).toString(), 'P1Y2M3DT4H5M6S', 'all fields');
265 assert.equal(moment.duration({M: -1}).toString(), '-P1M', 'one month ago');
266 assert.equal(moment.duration({m: -1}).toString(), '-PT1M', 'one minute ago');
267 assert.equal(moment.duration({s: -0.5}).toString(), '-PT0.5S', 'one half second ago');
268 assert.equal(moment.duration({y: -0.5, M: 1}).toString(), '-P5M', 'a month after half a year ago');
269 assert.equal(moment.duration({}).toString(), 'P0D', 'zero duration');
270 assert.equal(moment.duration({M: 16, d:40, s: 86465}).toString(), 'P1Y4M40DT24H1M5S', 'all fields');
271 });
272
273 test('toIsoString deprecation', function (assert) {
274 assert.equal(moment.duration({}).toIsoString(), moment.duration({}).toISOString(), 'toIsoString delegates to toISOString');
275 });
276
277 test('`isodate` (python) test cases', function (assert) {
278 assert.equal(moment.duration('P18Y9M4DT11H9M8S').asSeconds(), moment.duration({y: 18, M: 9, d: 4, h: 11, m: 9, s: 8}).asSeconds(), 'python isodate 1');
279 assert.equal(moment.duration('P2W').asSeconds(), moment.duration({w: 2}).asSeconds(), 'python isodate 2');
280 assert.equal(moment.duration('P3Y6M4DT12H30M5S').asSeconds(), moment.duration({y: 3, M: 6, d: 4, h: 12, m: 30, s: 5}).asSeconds(), 'python isodate 3');
281 assert.equal(moment.duration('P23DT23H').asSeconds(), moment.duration({d: 23, h: 23}).asSeconds(), 'python isodate 4');
282 assert.equal(moment.duration('P4Y').asSeconds(), moment.duration({y: 4}).asSeconds(), 'python isodate 5');
283 assert.equal(moment.duration('P1M').asSeconds(), moment.duration({M: 1}).asSeconds(), 'python isodate 6');
284 assert.equal(moment.duration('PT1M').asSeconds(), moment.duration({m: 1}).asSeconds(), 'python isodate 7');
285 assert.equal(moment.duration('P0.5Y').asSeconds(), moment.duration({y: 0.5}).asSeconds(), 'python isodate 8');
286 assert.equal(moment.duration('PT36H').asSeconds(), moment.duration({h: 36}).asSeconds(), 'python isodate 9');
287 assert.equal(moment.duration('P1DT12H').asSeconds(), moment.duration({d: 1, h: 12}).asSeconds(), 'python isodate 10');
288 assert.equal(moment.duration('-P2W').asSeconds(), moment.duration({w: -2}).asSeconds(), 'python isodate 11');
289 assert.equal(moment.duration('-P2.2W').asSeconds(), moment.duration({w: -2.2}).asSeconds(), 'python isodate 12');
290 assert.equal(moment.duration('P1DT2H3M4S').asSeconds(), moment.duration({d: 1, h: 2, m: 3, s: 4}).asSeconds(), 'python isodate 13');
291 assert.equal(moment.duration('P1DT2H3M').asSeconds(), moment.duration({d: 1, h: 2, m: 3}).asSeconds(), 'python isodate 14');
292 assert.equal(moment.duration('P1DT2H').asSeconds(), moment.duration({d: 1, h: 2}).asSeconds(), 'python isodate 15');
293 assert.equal(moment.duration('PT2H').asSeconds(), moment.duration({h: 2}).asSeconds(), 'python isodate 16');
294 assert.equal(moment.duration('PT2.3H').asSeconds(), moment.duration({h: 2.3}).asSeconds(), 'python isodate 17');
295 assert.equal(moment.duration('PT2H3M4S').asSeconds(), moment.duration({h: 2, m: 3, s: 4}).asSeconds(), 'python isodate 18');
296 assert.equal(moment.duration('PT3M4S').asSeconds(), moment.duration({m: 3, s: 4}).asSeconds(), 'python isodate 19');
297 assert.equal(moment.duration('PT22S').asSeconds(), moment.duration({s: 22}).asSeconds(), 'python isodate 20');
298 assert.equal(moment.duration('PT22.22S').asSeconds(), moment.duration({s: 22.22}).asSeconds(), 'python isodate 21');
299 assert.equal(moment.duration('-P2Y').asSeconds(), moment.duration({y: -2}).asSeconds(), 'python isodate 22');
300 assert.equal(moment.duration('-P3Y6M4DT12H30M5S').asSeconds(), moment.duration({y: -3, M: -6, d: -4, h: -12, m: -30, s: -5}).asSeconds(), 'python isodate 23');
301 assert.equal(moment.duration('-P1DT2H3M4S').asSeconds(), moment.duration({d: -1, h: -2, m: -3, s: -4}).asSeconds(), 'python isodate 24');
302 });
303
304 test('ISO 8601 misuse cases', function (assert) {
305 assert.equal(moment.duration('P').asSeconds(), 0, 'lonely P');
306 assert.equal(moment.duration('PT').asSeconds(), 0, 'just P and T');
307 assert.equal(moment.duration('P1H').asSeconds(), 0, 'missing T');
308 assert.equal(moment.duration('P1D1Y').asSeconds(), 0, 'out of order');
309 assert.equal(moment.duration('PT.5S').asSeconds(), 0.5, 'accept no leading zero for decimal');
310 assert.equal(moment.duration('PT1,S').asSeconds(), 1, 'accept trailing decimal separator');
311 assert.equal(moment.duration('PT1M0,,5S').asSeconds(), 60, 'extra decimal separators are ignored as 0');
312 assert.equal(moment.duration('P-1DS').asSeconds(), 0, 'wrong position of negative');
313 });
314
315 test('humanize', function (assert) {
316 moment.locale('en');
317 assert.equal(moment.duration({seconds: 44}).humanize(), 'a few seconds', '44 seconds = a few seconds');
318 assert.equal(moment.duration({seconds: 45}).humanize(), 'a minute', '45 seconds = a minute');
319 assert.equal(moment.duration({seconds: 89}).humanize(), 'a minute', '89 seconds = a minute');
320 assert.equal(moment.duration({seconds: 90}).humanize(), '2 minutes', '90 seconds = 2 minutes');
321 assert.equal(moment.duration({minutes: 44}).humanize(), '44 minutes', '44 minutes = 44 minutes');
322 assert.equal(moment.duration({minutes: 45}).humanize(), 'an hour', '45 minutes = an hour');
323 assert.equal(moment.duration({minutes: 89}).humanize(), 'an hour', '89 minutes = an hour');
324 assert.equal(moment.duration({minutes: 90}).humanize(), '2 hours', '90 minutes = 2 hours');
325 assert.equal(moment.duration({hours: 5}).humanize(), '5 hours', '5 hours = 5 hours');
326 assert.equal(moment.duration({hours: 21}).humanize(), '21 hours', '21 hours = 21 hours');
327 assert.equal(moment.duration({hours: 22}).humanize(), 'a day', '22 hours = a day');
328 assert.equal(moment.duration({hours: 35}).humanize(), 'a day', '35 hours = a day');
329 assert.equal(moment.duration({hours: 36}).humanize(), '2 days', '36 hours = 2 days');
330 assert.equal(moment.duration({days: 1}).humanize(), 'a day', '1 day = a day');
331 assert.equal(moment.duration({days: 5}).humanize(), '5 days', '5 days = 5 days');
332 assert.equal(moment.duration({weeks: 1}).humanize(), '7 days', '1 week = 7 days');
333 assert.equal(moment.duration({days: 25}).humanize(), '25 days', '25 days = 25 days');
334 assert.equal(moment.duration({days: 26}).humanize(), 'a month', '26 days = a month');
335 assert.equal(moment.duration({days: 30}).humanize(), 'a month', '30 days = a month');
336 assert.equal(moment.duration({days: 45}).humanize(), 'a month', '45 days = a month');
337 assert.equal(moment.duration({days: 46}).humanize(), '2 months', '46 days = 2 months');
338 assert.equal(moment.duration({days: 74}).humanize(), '2 months', '74 days = 2 months');
339 assert.equal(moment.duration({days: 77}).humanize(), '3 months', '77 days = 3 months');
340 assert.equal(moment.duration({months: 1}).humanize(), 'a month', '1 month = a month');
341 assert.equal(moment.duration({months: 5}).humanize(), '5 months', '5 months = 5 months');
342 assert.equal(moment.duration({days: 344}).humanize(), 'a year', '344 days = a year');
343 assert.equal(moment.duration({days: 345}).humanize(), 'a year', '345 days = a year');
344 assert.equal(moment.duration({days: 547}).humanize(), 'a year', '547 days = a year');
345 assert.equal(moment.duration({days: 548}).humanize(), '2 years', '548 days = 2 years');
346 assert.equal(moment.duration({years: 1}).humanize(), 'a year', '1 year = a year');
347 assert.equal(moment.duration({years: 5}).humanize(), '5 years', '5 years = 5 years');
348 assert.equal(moment.duration(7200000).humanize(), '2 hours', '7200000 = 2 minutes');
349 });
350
351 test('humanize duration with suffix', function (assert) {
352 moment.locale('en');
353 assert.equal(moment.duration({seconds: 44}).humanize(true), 'in a few seconds', '44 seconds = a few seconds');
354 assert.equal(moment.duration({seconds: -44}).humanize(true), 'a few seconds ago', '44 seconds = a few seconds');
355 });
356
357 test('bubble value up', function (assert) {
358 assert.equal(moment.duration({milliseconds: 61001}).milliseconds(), 1, '61001 milliseconds has 1 millisecond left over');
359 assert.equal(moment.duration({milliseconds: 61001}).seconds(), 1, '61001 milliseconds has 1 second left over');
360 assert.equal(moment.duration({milliseconds: 61001}).minutes(), 1, '61001 milliseconds has 1 minute left over');
361
362 assert.equal(moment.duration({minutes: 350}).minutes(), 50, '350 minutes has 50 minutes left over');
363 assert.equal(moment.duration({minutes: 350}).hours(), 5, '350 minutes has 5 hours left over');
364 });
365
366 test('clipping', function (assert) {
367 assert.equal(moment.duration({months: 11}).months(), 11, '11 months is 11 months');
368 assert.equal(moment.duration({months: 11}).years(), 0, '11 months makes no year');
369 assert.equal(moment.duration({months: 12}).months(), 0, '12 months is 0 months left over');
370 assert.equal(moment.duration({months: 12}).years(), 1, '12 months makes 1 year');
371 assert.equal(moment.duration({months: 13}).months(), 1, '13 months is 1 month left over');
372 assert.equal(moment.duration({months: 13}).years(), 1, '13 months makes 1 year');
373
374 assert.equal(moment.duration({days: 30}).days(), 30, '30 days is 30 days');
375 assert.equal(moment.duration({days: 30}).months(), 0, '30 days makes no month');
376 assert.equal(moment.duration({days: 31}).days(), 0, '31 days is 0 days left over');
377 assert.equal(moment.duration({days: 31}).months(), 1, '31 days is a month');
378 assert.equal(moment.duration({days: 32}).days(), 1, '32 days is 1 day left over');
379 assert.equal(moment.duration({days: 32}).months(), 1, '32 days is a month');
380
381 assert.equal(moment.duration({hours: 23}).hours(), 23, '23 hours is 23 hours');
382 assert.equal(moment.duration({hours: 23}).days(), 0, '23 hours makes no day');
383 assert.equal(moment.duration({hours: 24}).hours(), 0, '24 hours is 0 hours left over');
384 assert.equal(moment.duration({hours: 24}).days(), 1, '24 hours makes 1 day');
385 assert.equal(moment.duration({hours: 25}).hours(), 1, '25 hours is 1 hour left over');
386 assert.equal(moment.duration({hours: 25}).days(), 1, '25 hours makes 1 day');
387 });
388
389 test('bubbling consistency', function (assert) {
390 var days = 0, months = 0, newDays, newMonths, totalDays, d;
391 for (totalDays = 1; totalDays <= 500; ++totalDays) {
392 d = moment.duration(totalDays, 'days');
393 newDays = d.days();
394 newMonths = d.months() + d.years() * 12;
395 assert.ok(
396 (months === newMonths && days + 1 === newDays) ||
397 (months + 1 === newMonths && newDays === 0),
398 'consistent total days ' + totalDays +
399 ' was ' + months + ' ' + days +
400 ' now ' + newMonths + ' ' + newDays);
401 days = newDays;
402 months = newMonths;
403 }
404 });
405
406 test('effective equivalency', function (assert) {
407 assert.deepEqual(moment.duration({seconds: 1})._data, moment.duration({milliseconds: 1000})._data, '1 second is the same as 1000 milliseconds');
408 assert.deepEqual(moment.duration({seconds: 60})._data, moment.duration({minutes: 1})._data, '1 minute is the same as 60 seconds');
409 assert.deepEqual(moment.duration({minutes: 60})._data, moment.duration({hours: 1})._data, '1 hour is the same as 60 minutes');
410 assert.deepEqual(moment.duration({hours: 24})._data, moment.duration({days: 1})._data, '1 day is the same as 24 hours');
411 assert.deepEqual(moment.duration({days: 7})._data, moment.duration({weeks: 1})._data, '1 week is the same as 7 days');
412 assert.deepEqual(moment.duration({days: 31})._data, moment.duration({months: 1})._data, '1 month is the same as 30 days');
413 assert.deepEqual(moment.duration({months: 12})._data, moment.duration({years: 1})._data, '1 years is the same as 12 months');
414 });
415
416 test('asGetters', function (assert) {
417 // 400 years have exactly 146097 days
418
419 // years
420 assert.equal(moment.duration(1, 'year').asYears(), 1, '1 year as years');
421 assert.equal(moment.duration(1, 'year').asMonths(), 12, '1 year as months');
422 assert.equal(moment.duration(400, 'year').asMonths(), 4800, '400 years as months');
423 assert.equal(moment.duration(1, 'year').asWeeks().toFixed(3), 52.143, '1 year as weeks');
424 assert.equal(moment.duration(1, 'year').asDays(), 365, '1 year as days');
425 assert.equal(moment.duration(2, 'year').asDays(), 730, '2 years as days');
426 assert.equal(moment.duration(3, 'year').asDays(), 1096, '3 years as days');
427 assert.equal(moment.duration(4, 'year').asDays(), 1461, '4 years as days');
428 assert.equal(moment.duration(400, 'year').asDays(), 146097, '400 years as days');
429 assert.equal(moment.duration(1, 'year').asHours(), 8760, '1 year as hours');
430 assert.equal(moment.duration(1, 'year').asMinutes(), 525600, '1 year as minutes');
431 assert.equal(moment.duration(1, 'year').asSeconds(), 31536000, '1 year as seconds');
432 assert.equal(moment.duration(1, 'year').asMilliseconds(), 31536000000, '1 year as milliseconds');
433
434 // months
435 assert.equal(moment.duration(1, 'month').asYears().toFixed(4), 0.0833, '1 month as years');
436 assert.equal(moment.duration(1, 'month').asMonths(), 1, '1 month as months');
437 assert.equal(moment.duration(1, 'month').asWeeks().toFixed(3), 4.286, '1 month as weeks');
438 assert.equal(moment.duration(1, 'month').asDays(), 30, '1 month as days');
439 assert.equal(moment.duration(2, 'month').asDays(), 61, '2 months as days');
440 assert.equal(moment.duration(3, 'month').asDays(), 91, '3 months as days');
441 assert.equal(moment.duration(4, 'month').asDays(), 122, '4 months as days');
442 assert.equal(moment.duration(5, 'month').asDays(), 152, '5 months as days');
443 assert.equal(moment.duration(6, 'month').asDays(), 183, '6 months as days');
444 assert.equal(moment.duration(7, 'month').asDays(), 213, '7 months as days');
445 assert.equal(moment.duration(8, 'month').asDays(), 243, '8 months as days');
446 assert.equal(moment.duration(9, 'month').asDays(), 274, '9 months as days');
447 assert.equal(moment.duration(10, 'month').asDays(), 304, '10 months as days');
448 assert.equal(moment.duration(11, 'month').asDays(), 335, '11 months as days');
449 assert.equal(moment.duration(12, 'month').asDays(), 365, '12 months as days');
450 assert.equal(moment.duration(24, 'month').asDays(), 730, '24 months as days');
451 assert.equal(moment.duration(36, 'month').asDays(), 1096, '36 months as days');
452 assert.equal(moment.duration(48, 'month').asDays(), 1461, '48 months as days');
453 assert.equal(moment.duration(4800, 'month').asDays(), 146097, '4800 months as days');
454 assert.equal(moment.duration(1, 'month').asHours(), 720, '1 month as hours');
455 assert.equal(moment.duration(1, 'month').asMinutes(), 43200, '1 month as minutes');
456 assert.equal(moment.duration(1, 'month').asSeconds(), 2592000, '1 month as seconds');
457 assert.equal(moment.duration(1, 'month').asMilliseconds(), 2592000000, '1 month as milliseconds');
458
459 // weeks
460 assert.equal(moment.duration(1, 'week').asYears().toFixed(4), 0.0192, '1 week as years');
461 assert.equal(moment.duration(1, 'week').asMonths().toFixed(3), 0.230, '1 week as months');
462 assert.equal(moment.duration(1, 'week').asWeeks(), 1, '1 week as weeks');
463 assert.equal(moment.duration(1, 'week').asDays(), 7, '1 week as days');
464 assert.equal(moment.duration(1, 'week').asHours(), 168, '1 week as hours');
465 assert.equal(moment.duration(1, 'week').asMinutes(), 10080, '1 week as minutes');
466 assert.equal(moment.duration(1, 'week').asSeconds(), 604800, '1 week as seconds');
467 assert.equal(moment.duration(1, 'week').asMilliseconds(), 604800000, '1 week as milliseconds');
468
469 // days
470 assert.equal(moment.duration(1, 'day').asYears().toFixed(4), 0.0027, '1 day as years');
471 assert.equal(moment.duration(1, 'day').asMonths().toFixed(3), 0.033, '1 day as months');
472 assert.equal(moment.duration(1, 'day').asWeeks().toFixed(3), 0.143, '1 day as weeks');
473 assert.equal(moment.duration(1, 'day').asDays(), 1, '1 day as days');
474 assert.equal(moment.duration(1, 'day').asHours(), 24, '1 day as hours');
475 assert.equal(moment.duration(1, 'day').asMinutes(), 1440, '1 day as minutes');
476 assert.equal(moment.duration(1, 'day').asSeconds(), 86400, '1 day as seconds');
477 assert.equal(moment.duration(1, 'day').asMilliseconds(), 86400000, '1 day as milliseconds');
478
479 // hours
480 assert.equal(moment.duration(1, 'hour').asYears().toFixed(6), 0.000114, '1 hour as years');
481 assert.equal(moment.duration(1, 'hour').asMonths().toFixed(5), 0.00137, '1 hour as months');
482 assert.equal(moment.duration(1, 'hour').asWeeks().toFixed(5), 0.00595, '1 hour as weeks');
483 assert.equal(moment.duration(1, 'hour').asDays().toFixed(4), 0.0417, '1 hour as days');
484 assert.equal(moment.duration(1, 'hour').asHours(), 1, '1 hour as hours');
485 assert.equal(moment.duration(1, 'hour').asMinutes(), 60, '1 hour as minutes');
486 assert.equal(moment.duration(1, 'hour').asSeconds(), 3600, '1 hour as seconds');
487 assert.equal(moment.duration(1, 'hour').asMilliseconds(), 3600000, '1 hour as milliseconds');
488
489 // minutes
490 assert.equal(moment.duration(1, 'minute').asYears().toFixed(8), 0.00000190, '1 minute as years');
491 assert.equal(moment.duration(1, 'minute').asMonths().toFixed(7), 0.0000228, '1 minute as months');
492 assert.equal(moment.duration(1, 'minute').asWeeks().toFixed(7), 0.0000992, '1 minute as weeks');
493 assert.equal(moment.duration(1, 'minute').asDays().toFixed(6), 0.000694, '1 minute as days');
494 assert.equal(moment.duration(1, 'minute').asHours().toFixed(4), 0.0167, '1 minute as hours');
495 assert.equal(moment.duration(1, 'minute').asMinutes(), 1, '1 minute as minutes');
496 assert.equal(moment.duration(1, 'minute').asSeconds(), 60, '1 minute as seconds');
497 assert.equal(moment.duration(1, 'minute').asMilliseconds(), 60000, '1 minute as milliseconds');
498
499 // seconds
500 assert.equal(moment.duration(1, 'second').asYears().toFixed(10), 0.0000000317, '1 second as years');
501 assert.equal(moment.duration(1, 'second').asMonths().toFixed(9), 0.000000380, '1 second as months');
502 assert.equal(moment.duration(1, 'second').asWeeks().toFixed(8), 0.00000165, '1 second as weeks');
503 assert.equal(moment.duration(1, 'second').asDays().toFixed(7), 0.0000116, '1 second as days');
504 assert.equal(moment.duration(1, 'second').asHours().toFixed(6), 0.000278, '1 second as hours');
505 assert.equal(moment.duration(1, 'second').asMinutes().toFixed(4), 0.0167, '1 second as minutes');
506 assert.equal(moment.duration(1, 'second').asSeconds(), 1, '1 second as seconds');
507 assert.equal(moment.duration(1, 'second').asMilliseconds(), 1000, '1 second as milliseconds');
508
509 // milliseconds
510 assert.equal(moment.duration(1, 'millisecond').asYears().toFixed(13), 0.0000000000317, '1 millisecond as years');
511 assert.equal(moment.duration(1, 'millisecond').asMonths().toFixed(12), 0.000000000380, '1 millisecond as months');
512 assert.equal(moment.duration(1, 'millisecond').asWeeks().toFixed(11), 0.00000000165, '1 millisecond as weeks');
513 assert.equal(moment.duration(1, 'millisecond').asDays().toFixed(10), 0.0000000116, '1 millisecond as days');
514 assert.equal(moment.duration(1, 'millisecond').asHours().toFixed(9), 0.000000278, '1 millisecond as hours');
515 assert.equal(moment.duration(1, 'millisecond').asMinutes().toFixed(7), 0.0000167, '1 millisecond as minutes');
516 assert.equal(moment.duration(1, 'millisecond').asSeconds(), 0.001, '1 millisecond as seconds');
517 assert.equal(moment.duration(1, 'millisecond').asMilliseconds(), 1, '1 millisecond as milliseconds');
518 });
519
520 test('as getters for small units', function (assert) {
521 var dS = moment.duration(1, 'milliseconds'),
522 ds = moment.duration(3, 'seconds'),
523 dm = moment.duration(13, 'minutes');
524
525 // Tests for issue #1867.
526 // Floating point errors for small duration units were introduced in version 2.8.0.
527 assert.equal(dS.as('milliseconds'), 1, 'as("milliseconds")');
528 assert.equal(dS.asMilliseconds(), 1, 'asMilliseconds()');
529 assert.equal(ds.as('seconds'), 3, 'as("seconds")');
530 assert.equal(ds.asSeconds(), 3, 'asSeconds()');
531 assert.equal(dm.as('minutes'), 13, 'as("minutes")');
532 assert.equal(dm.asMinutes(), 13, 'asMinutes()');
533 });
534
535 test('isDuration', function (assert) {
536 assert.ok(moment.isDuration(moment.duration(12345678)), 'correctly says true');
537 assert.ok(!moment.isDuration(moment()), 'moment object is not a duration');
538 assert.ok(!moment.isDuration({milliseconds: 1}), 'plain object is not a duration');
539 });
540
541 test('add', function (assert) {
542 var d = moment.duration({months: 4, weeks: 3, days: 2});
543 // for some reason, d._data._months does not get updated; use d._months instead.
544 assert.equal(d.add(1, 'month')._months, 5, 'Add months');
545 assert.equal(d.add(5, 'days')._days, 28, 'Add days');
546 assert.equal(d.add(10000)._milliseconds, 10000, 'Add milliseconds');
547 assert.equal(d.add({h: 23, m: 59})._milliseconds, 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 10000, 'Add hour:minute');
548 });
549
550 test('add and bubble', function (assert) {
551 var d;
552
553 assert.equal(moment.duration(1, 'second').add(1000, 'milliseconds').seconds(), 2, 'Adding milliseconds should bubble up to seconds');
554 assert.equal(moment.duration(1, 'minute').add(60, 'second').minutes(), 2, 'Adding seconds should bubble up to minutes');
555 assert.equal(moment.duration(1, 'hour').add(60, 'minutes').hours(), 2, 'Adding minutes should bubble up to hours');
556 assert.equal(moment.duration(1, 'day').add(24, 'hours').days(), 2, 'Adding hours should bubble up to days');
557
558 d = moment.duration(-1, 'day').add(1, 'hour');
559 assert.equal(d.hours(), -23, '-1 day + 1 hour == -23 hour (component)');
560 assert.equal(d.asHours(), -23, '-1 day + 1 hour == -23 hours');
561
562 d = moment.duration(-1, 'year').add(1, 'day');
563 assert.equal(d.days(), -30, '- 1 year + 1 day == -30 days (component)');
564 assert.equal(d.months(), -11, '- 1 year + 1 day == -11 months (component)');
565 assert.equal(d.years(), 0, '- 1 year + 1 day == 0 years (component)');
566 assert.equal(d.asDays(), -364, '- 1 year + 1 day == -364 days');
567
568 d = moment.duration(-1, 'year').add(1, 'hour');
569 assert.equal(d.hours(), -23, '- 1 year + 1 hour == -23 hours (component)');
570 assert.equal(d.days(), -30, '- 1 year + 1 hour == -30 days (component)');
571 assert.equal(d.months(), -11, '- 1 year + 1 hour == -11 months (component)');
572 assert.equal(d.years(), 0, '- 1 year + 1 hour == 0 years (component)');
573 });
574
575 test('subtract and bubble', function (assert) {
576 var d;
577
578 assert.equal(moment.duration(2, 'second').subtract(1000, 'milliseconds').seconds(), 1, 'Subtracting milliseconds should bubble up to seconds');
579 assert.equal(moment.duration(2, 'minute').subtract(60, 'second').minutes(), 1, 'Subtracting seconds should bubble up to minutes');
580 assert.equal(moment.duration(2, 'hour').subtract(60, 'minutes').hours(), 1, 'Subtracting minutes should bubble up to hours');
581 assert.equal(moment.duration(2, 'day').subtract(24, 'hours').days(), 1, 'Subtracting hours should bubble up to days');
582
583 d = moment.duration(1, 'day').subtract(1, 'hour');
584 assert.equal(d.hours(), 23, '1 day - 1 hour == 23 hour (component)');
585 assert.equal(d.asHours(), 23, '1 day - 1 hour == 23 hours');
586
587 d = moment.duration(1, 'year').subtract(1, 'day');
588 assert.equal(d.days(), 30, '1 year - 1 day == 30 days (component)');
589 assert.equal(d.months(), 11, '1 year - 1 day == 11 months (component)');
590 assert.equal(d.years(), 0, '1 year - 1 day == 0 years (component)');
591 assert.equal(d.asDays(), 364, '1 year - 1 day == 364 days');
592
593 d = moment.duration(1, 'year').subtract(1, 'hour');
594 assert.equal(d.hours(), 23, '1 year - 1 hour == 23 hours (component)');
595 assert.equal(d.days(), 30, '1 year - 1 hour == 30 days (component)');
596 assert.equal(d.months(), 11, '1 year - 1 hour == 11 months (component)');
597 assert.equal(d.years(), 0, '1 year - 1 hour == 0 years (component)');
598 });
599
600 test('subtract', function (assert) {
601 var d = moment.duration({months: 2, weeks: 2, days: 0, hours: 5});
602 // for some reason, d._data._months does not get updated; use d._months instead.
603 assert.equal(d.subtract(1, 'months')._months, 1, 'Subtract months');
604 assert.equal(d.subtract(14, 'days')._days, 0, 'Subtract days');
605 assert.equal(d.subtract(10000)._milliseconds, 5 * 60 * 60 * 1000 - 10000, 'Subtract milliseconds');
606 assert.equal(d.subtract({h: 1, m: 59})._milliseconds, 3 * 60 * 60 * 1000 + 1 * 60 * 1000 - 10000, 'Subtract hour:minute');
607 });
608
609 test('JSON.stringify duration', function (assert) {
610 var d = moment.duration(1024, 'h');
611
612 assert.equal(JSON.stringify(d), '"' + d.toISOString() + '"', 'JSON.stringify on duration should return ISO string');
613 });
614
615 test('duration plugins', function (assert) {
616 var durationObject = moment.duration();
617 moment.duration.fn.foo = function (arg) {
618 assert.equal(this, durationObject);
619 assert.equal(arg, 5);
620 };
621 durationObject.foo(5);
622 });
623
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('duration from moments');
4
5 test('pure year diff', function (assert) {
6 var m1 = moment('2012-01-01T00:00:00.000Z'),
7 m2 = moment('2013-01-01T00:00:00.000Z');
8
9 assert.equal(moment.duration({from: m1, to: m2}).as('years'), 1, 'year moment difference');
10 assert.equal(moment.duration({from: m2, to: m1}).as('years'), -1, 'negative year moment difference');
11 });
12
13 test('month and day diff', function (assert) {
14 var m1 = moment('2012-01-15T00:00:00.000Z'),
15 m2 = moment('2012-02-17T00:00:00.000Z'),
16 d = moment.duration({from: m1, to: m2});
17
18 assert.equal(d.get('days'), 2);
19 assert.equal(d.get('months'), 1);
20 });
21
22 test('day diff, separate months', function (assert) {
23 var m1 = moment('2012-01-15T00:00:00.000Z'),
24 m2 = moment('2012-02-13T00:00:00.000Z'),
25 d = moment.duration({from: m1, to: m2});
26
27 assert.equal(d.as('days'), 29);
28 });
29
30 test('hour diff', function (assert) {
31 var m1 = moment('2012-01-15T17:00:00.000Z'),
32 m2 = moment('2012-01-16T03:00:00.000Z'),
33 d = moment.duration({from: m1, to: m2});
34
35 assert.equal(d.as('hours'), 10);
36 });
37
38 test('minute diff', function (assert) {
39 var m1 = moment('2012-01-15T17:45:00.000Z'),
40 m2 = moment('2012-01-16T03:15:00.000Z'),
41 d = moment.duration({from: m1, to: m2});
42
43 assert.equal(d.as('hours'), 9.5);
44 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('format');
4
5 test('format YY', function (assert) {
6 var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
7 assert.equal(b.format('YY'), '09', 'YY ---> 09');
8 });
9
10 test('format escape brackets', function (assert) {
11 moment.locale('en');
12
13 var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
14 assert.equal(b.format('[day]'), 'day', 'Single bracket');
15 assert.equal(b.format('[day] YY [YY]'), 'day 09 YY', 'Double bracket');
16 assert.equal(b.format('[YY'), '[09', 'Un-ended bracket');
17 assert.equal(b.format('[[YY]]'), '[YY]', 'Double nested brackets');
18 assert.equal(b.format('[[]'), '[', 'Escape open bracket');
19 assert.equal(b.format('[Last]'), 'Last', 'localized tokens');
20 assert.equal(b.format('[L] L'), 'L 02/14/2009', 'localized tokens with escaped localized tokens');
21 assert.equal(b.format('[L LL LLL LLLL aLa]'), 'L LL LLL LLLL aLa', 'localized tokens with escaped localized tokens');
22 assert.equal(b.format('[LLL] LLL'), 'LLL February 14, 2009 3:25 PM', 'localized tokens with escaped localized tokens (recursion)');
23 assert.equal(b.format('YYYY[\n]DD[\n]'), '2009\n14\n', 'Newlines');
24 });
25
26 test('handle negative years', function (assert) {
27 moment.locale('en');
28 assert.equal(moment.utc().year(-1).format('YY'), '-01', 'YY with negative year');
29 assert.equal(moment.utc().year(-1).format('YYYY'), '-0001', 'YYYY with negative year');
30 assert.equal(moment.utc().year(-12).format('YY'), '-12', 'YY with negative year');
31 assert.equal(moment.utc().year(-12).format('YYYY'), '-0012', 'YYYY with negative year');
32 assert.equal(moment.utc().year(-123).format('YY'), '-23', 'YY with negative year');
33 assert.equal(moment.utc().year(-123).format('YYYY'), '-0123', 'YYYY with negative year');
34 assert.equal(moment.utc().year(-1234).format('YY'), '-34', 'YY with negative year');
35 assert.equal(moment.utc().year(-1234).format('YYYY'), '-1234', 'YYYY with negative year');
36 assert.equal(moment.utc().year(-12345).format('YY'), '-45', 'YY with negative year');
37 assert.equal(moment.utc().year(-12345).format('YYYY'), '-12345', 'YYYY with negative year');
38 });
39
40 test('format milliseconds', function (assert) {
41 var b = moment(new Date(2009, 1, 14, 15, 25, 50, 123));
42 assert.equal(b.format('S'), '1', 'Deciseconds');
43 assert.equal(b.format('SS'), '12', 'Centiseconds');
44 assert.equal(b.format('SSS'), '123', 'Milliseconds');
45 b.milliseconds(789);
46 assert.equal(b.format('S'), '7', 'Deciseconds');
47 assert.equal(b.format('SS'), '78', 'Centiseconds');
48 assert.equal(b.format('SSS'), '789', 'Milliseconds');
49 });
50
51 test('format timezone', function (assert) {
52 var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
53 assert.ok(b.format('Z').match(/^[\+\-]\d\d:\d\d$/), b.format('Z') + ' should be something like \'+07:30\'');
54 assert.ok(b.format('ZZ').match(/^[\+\-]\d{4}$/), b.format('ZZ') + ' should be something like \'+0700\'');
55 });
56
57 test('format multiple with utc offset', function (assert) {
58 var b = moment('2012-10-08 -1200', ['YYYY-MM-DD HH:mm ZZ', 'YYYY-MM-DD ZZ', 'YYYY-MM-DD']);
59 assert.equal(b.format('YYYY-MM'), '2012-10', 'Parsing multiple formats should not crash with different sized formats');
60 });
61
62 test('isDST', function (assert) {
63 var janOffset = new Date(2011, 0, 1).getTimezoneOffset(),
64 julOffset = new Date(2011, 6, 1).getTimezoneOffset(),
65 janIsDst = janOffset < julOffset,
66 julIsDst = julOffset < janOffset,
67 jan1 = moment([2011]),
68 jul1 = moment([2011, 6]);
69
70 if (janIsDst && julIsDst) {
71 assert.ok(0, 'January and July cannot both be in DST');
72 assert.ok(0, 'January and July cannot both be in DST');
73 } else if (janIsDst) {
74 assert.ok(jan1.isDST(), 'January 1 is DST');
75 assert.ok(!jul1.isDST(), 'July 1 is not DST');
76 } else if (julIsDst) {
77 assert.ok(!jan1.isDST(), 'January 1 is not DST');
78 assert.ok(jul1.isDST(), 'July 1 is DST');
79 } else {
80 assert.ok(!jan1.isDST(), 'January 1 is not DST');
81 assert.ok(!jul1.isDST(), 'July 1 is not DST');
82 }
83 });
84
85 test('unix timestamp', function (assert) {
86 var m = moment('1234567890.123', 'X');
87 assert.equal(m.format('X'), '1234567890', 'unix timestamp without milliseconds');
88 assert.equal(m.format('X.S'), '1234567890.1', 'unix timestamp with deciseconds');
89 assert.equal(m.format('X.SS'), '1234567890.12', 'unix timestamp with centiseconds');
90 assert.equal(m.format('X.SSS'), '1234567890.123', 'unix timestamp with milliseconds');
91
92 m = moment(1234567890.123, 'X');
93 assert.equal(m.format('X'), '1234567890', 'unix timestamp as integer');
94 });
95
96 test('unix offset milliseconds', function (assert) {
97 var m = moment('1234567890123', 'x');
98 assert.equal(m.format('x'), '1234567890123', 'unix offset in milliseconds');
99
100 m = moment(1234567890123, 'x');
101 assert.equal(m.format('x'), '1234567890123', 'unix offset in milliseconds as integer');
102 });
103
104 test('utcOffset sanity checks', function (assert) {
105 assert.equal(moment().utcOffset() % 15, 0,
106 'utc offset should be a multiple of 15 (was ' + moment().utcOffset() + ')');
107
108 assert.equal(moment().utcOffset(), -(new Date()).getTimezoneOffset(),
109 'utcOffset should return the opposite of getTimezoneOffset');
110 });
111
112 test('default format', function (assert) {
113 var isoRegex = /\d{4}.\d\d.\d\dT\d\d.\d\d.\d\d[\+\-]\d\d:\d\d/;
114 assert.ok(isoRegex.exec(moment().format()), 'default format (' + moment().format() + ') should match ISO');
115 });
116
117 test('toJSON', function (assert) {
118 var supportsJson = typeof JSON !== 'undefined' && JSON.stringify && JSON.stringify.call,
119 date = moment('2012-10-09T21:30:40.678+0100');
120
121 assert.equal(date.toJSON(), '2012-10-09T20:30:40.678Z', 'should output ISO8601 on moment.fn.toJSON');
122
123 if (supportsJson) {
124 assert.equal(JSON.stringify({
125 date : date
126 }), '{"date":"2012-10-09T20:30:40.678Z"}', 'should output ISO8601 on JSON.stringify');
127 }
128 });
129
130 test('toISOString', function (assert) {
131 var date = moment.utc('2012-10-09T20:30:40.678');
132
133 assert.equal(date.toISOString(), '2012-10-09T20:30:40.678Z', 'should output ISO8601 on moment.fn.toISOString');
134
135 // big years
136 date = moment.utc('+020123-10-09T20:30:40.678');
137 assert.equal(date.toISOString(), '+020123-10-09T20:30:40.678Z', 'ISO8601 format on big positive year');
138 // negative years
139 date = moment.utc('-000001-10-09T20:30:40.678');
140 assert.equal(date.toISOString(), '-000001-10-09T20:30:40.678Z', 'ISO8601 format on negative year');
141 // big negative years
142 date = moment.utc('-020123-10-09T20:30:40.678');
143 assert.equal(date.toISOString(), '-020123-10-09T20:30:40.678Z', 'ISO8601 format on big negative year');
144 });
145
146 test('long years', function (assert) {
147 assert.equal(moment.utc().year(2).format('YYYYYY'), '+000002', 'small year with YYYYYY');
148 assert.equal(moment.utc().year(2012).format('YYYYYY'), '+002012', 'regular year with YYYYYY');
149 assert.equal(moment.utc().year(20123).format('YYYYYY'), '+020123', 'big year with YYYYYY');
150
151 assert.equal(moment.utc().year(-1).format('YYYYYY'), '-000001', 'small negative year with YYYYYY');
152 assert.equal(moment.utc().year(-2012).format('YYYYYY'), '-002012', 'negative year with YYYYYY');
153 assert.equal(moment.utc().year(-20123).format('YYYYYY'), '-020123', 'big negative year with YYYYYY');
154 });
155
156 test('iso week formats', function (assert) {
157 // http://en.wikipedia.org/wiki/ISO_week_date
158 var cases = {
159 '2005-01-02': '2004-53',
160 '2005-12-31': '2005-52',
161 '2007-01-01': '2007-01',
162 '2007-12-30': '2007-52',
163 '2007-12-31': '2008-01',
164 '2008-01-01': '2008-01',
165 '2008-12-28': '2008-52',
166 '2008-12-29': '2009-01',
167 '2008-12-30': '2009-01',
168 '2008-12-31': '2009-01',
169 '2009-01-01': '2009-01',
170 '2009-12-31': '2009-53',
171 '2010-01-01': '2009-53',
172 '2010-01-02': '2009-53',
173 '2010-01-03': '2009-53',
174 '404-12-31': '0404-53',
175 '405-12-31': '0405-52'
176 }, i, isoWeek, formatted2, formatted1;
177
178 for (i in cases) {
179 isoWeek = cases[i].split('-').pop();
180 formatted2 = moment(i, 'YYYY-MM-DD').format('WW');
181 assert.equal(isoWeek, formatted2, i + ': WW should be ' + isoWeek + ', but ' + formatted2);
182 isoWeek = isoWeek.replace(/^0+/, '');
183 formatted1 = moment(i, 'YYYY-MM-DD').format('W');
184 assert.equal(isoWeek, formatted1, i + ': W should be ' + isoWeek + ', but ' + formatted1);
185 }
186 });
187
188 test('iso week year formats', function (assert) {
189 // http://en.wikipedia.org/wiki/ISO_week_date
190 var cases = {
191 '2005-01-02': '2004-53',
192 '2005-12-31': '2005-52',
193 '2007-01-01': '2007-01',
194 '2007-12-30': '2007-52',
195 '2007-12-31': '2008-01',
196 '2008-01-01': '2008-01',
197 '2008-12-28': '2008-52',
198 '2008-12-29': '2009-01',
199 '2008-12-30': '2009-01',
200 '2008-12-31': '2009-01',
201 '2009-01-01': '2009-01',
202 '2009-12-31': '2009-53',
203 '2010-01-01': '2009-53',
204 '2010-01-02': '2009-53',
205 '2010-01-03': '2009-53',
206 '404-12-31': '0404-53',
207 '405-12-31': '0405-52'
208 }, i, isoWeekYear, formatted5, formatted4, formatted2;
209
210 for (i in cases) {
211 isoWeekYear = cases[i].split('-')[0];
212 formatted5 = moment(i, 'YYYY-MM-DD').format('GGGGG');
213 assert.equal('0' + isoWeekYear, formatted5, i + ': GGGGG should be ' + isoWeekYear + ', but ' + formatted5);
214 formatted4 = moment(i, 'YYYY-MM-DD').format('GGGG');
215 assert.equal(isoWeekYear, formatted4, i + ': GGGG should be ' + isoWeekYear + ', but ' + formatted4);
216 formatted2 = moment(i, 'YYYY-MM-DD').format('GG');
217 assert.equal(isoWeekYear.slice(2, 4), formatted2, i + ': GG should be ' + isoWeekYear + ', but ' + formatted2);
218 }
219 });
220
221 test('week year formats', function (assert) {
222 // http://en.wikipedia.org/wiki/ISO_week_date
223 var cases = {
224 '2005-01-02': '2004-53',
225 '2005-12-31': '2005-52',
226 '2007-01-01': '2007-01',
227 '2007-12-30': '2007-52',
228 '2007-12-31': '2008-01',
229 '2008-01-01': '2008-01',
230 '2008-12-28': '2008-52',
231 '2008-12-29': '2009-01',
232 '2008-12-30': '2009-01',
233 '2008-12-31': '2009-01',
234 '2009-01-01': '2009-01',
235 '2009-12-31': '2009-53',
236 '2010-01-01': '2009-53',
237 '2010-01-02': '2009-53',
238 '2010-01-03': '2009-53',
239 '404-12-31': '0404-53',
240 '405-12-31': '0405-52'
241 }, i, isoWeekYear, formatted5, formatted4, formatted2;
242
243 moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
244
245 for (i in cases) {
246 isoWeekYear = cases[i].split('-')[0];
247 formatted5 = moment(i, 'YYYY-MM-DD').format('ggggg');
248 assert.equal('0' + isoWeekYear, formatted5, i + ': ggggg should be ' + isoWeekYear + ', but ' + formatted5);
249 formatted4 = moment(i, 'YYYY-MM-DD').format('gggg');
250 assert.equal(isoWeekYear, formatted4, i + ': gggg should be ' + isoWeekYear + ', but ' + formatted4);
251 formatted2 = moment(i, 'YYYY-MM-DD').format('gg');
252 assert.equal(isoWeekYear.slice(2, 4), formatted2, i + ': gg should be ' + isoWeekYear + ', but ' + formatted2);
253 }
254 });
255
256 test('iso weekday formats', function (assert) {
257 assert.equal(moment([1985, 1, 4]).format('E'), '1', 'Feb 4 1985 is Monday -- 1st day');
258 assert.equal(moment([2029, 8, 18]).format('E'), '2', 'Sep 18 2029 is Tuesday -- 2nd day');
259 assert.equal(moment([2013, 3, 24]).format('E'), '3', 'Apr 24 2013 is Wednesday -- 3rd day');
260 assert.equal(moment([2015, 2, 5]).format('E'), '4', 'Mar 5 2015 is Thursday -- 4th day');
261 assert.equal(moment([1970, 0, 2]).format('E'), '5', 'Jan 2 1970 is Friday -- 5th day');
262 assert.equal(moment([2001, 4, 12]).format('E'), '6', 'May 12 2001 is Saturday -- 6th day');
263 assert.equal(moment([2000, 0, 2]).format('E'), '7', 'Jan 2 2000 is Sunday -- 7th day');
264 });
265
266 test('weekday formats', function (assert) {
267 moment.locale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
268 assert.equal(moment([1985, 1, 6]).format('e'), '0', 'Feb 6 1985 is Wednesday -- 0th day');
269 assert.equal(moment([2029, 8, 20]).format('e'), '1', 'Sep 20 2029 is Thursday -- 1st day');
270 assert.equal(moment([2013, 3, 26]).format('e'), '2', 'Apr 26 2013 is Friday -- 2nd day');
271 assert.equal(moment([2015, 2, 7]).format('e'), '3', 'Mar 7 2015 is Saturday -- 3nd day');
272 assert.equal(moment([1970, 0, 4]).format('e'), '4', 'Jan 4 1970 is Sunday -- 4th day');
273 assert.equal(moment([2001, 4, 14]).format('e'), '5', 'May 14 2001 is Monday -- 5th day');
274 assert.equal(moment([2000, 0, 4]).format('e'), '6', 'Jan 4 2000 is Tuesday -- 6th day');
275 });
276
277 test('toString is just human readable format', function (assert) {
278 var b = moment(new Date(2009, 1, 5, 15, 25, 50, 125));
279 assert.equal(b.toString(), b.format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'));
280 });
281
282 test('toJSON skips postformat', function (assert) {
283 moment.locale('postformat', {
284 postformat: function (s) {
285 s.replace(/./g, 'X');
286 }
287 });
288 assert.equal(moment.utc([2000, 0, 1]).toJSON(), '2000-01-01T00:00:00.000Z', 'toJSON doesn\'t postformat');
289 moment.locale('postformat', null);
290 });
291
292 test('calendar day timezone', function (assert) {
293 moment.locale('en');
294 var zones = [60, -60, 90, -90, 360, -360, 720, -720],
295 b = moment().utc().startOf('day').subtract({m : 1}),
296 c = moment().local().startOf('day').subtract({m : 1}),
297 d = moment().local().startOf('day').subtract({d : 2}),
298 i, z, a;
299
300 for (i = 0; i < zones.length; ++i) {
301 z = zones[i];
302 a = moment().utcOffset(z).startOf('day').subtract({m: 1});
303 assert.equal(moment(a).utcOffset(z).calendar(), 'Yesterday at 11:59 PM',
304 'Yesterday at 11:59 PM, not Today, or the wrong time, tz = ' + z);
305 }
306
307 assert.equal(moment(b).utc().calendar(), 'Yesterday at 11:59 PM', 'Yesterday at 11:59 PM, not Today, or the wrong time');
308 assert.equal(moment(c).local().calendar(), 'Yesterday at 11:59 PM', 'Yesterday at 11:59 PM, not Today, or the wrong time');
309 assert.equal(moment(c).local().calendar(d), 'Tomorrow at 11:59 PM', 'Tomorrow at 11:59 PM, not Yesterday, or the wrong time');
310 });
311
312 test('calendar with custom formats', function (assert) {
313 assert.equal(moment().calendar(null, {sameDay: '[Today]'}), 'Today', 'Today');
314 assert.equal(moment().add(1, 'days').calendar(null, {nextDay: '[Tomorrow]'}), 'Tomorrow', 'Tomorrow');
315 assert.equal(moment([1985, 1, 4]).calendar(null, {sameElse: 'YYYY-MM-DD'}), '1985-02-04', 'Else');
316 });
317
318 test('invalid', function (assert) {
319 assert.equal(moment.invalid().format(), 'Invalid date');
320 assert.equal(moment.invalid().format('YYYY-MM-DD'), 'Invalid date');
321 });
322
323 test('quarter formats', function (assert) {
324 assert.equal(moment([1985, 1, 4]).format('Q'), '1', 'Feb 4 1985 is Q1');
325 assert.equal(moment([2029, 8, 18]).format('Q'), '3', 'Sep 18 2029 is Q3');
326 assert.equal(moment([2013, 3, 24]).format('Q'), '2', 'Apr 24 2013 is Q2');
327 assert.equal(moment([2015, 2, 5]).format('Q'), '1', 'Mar 5 2015 is Q1');
328 assert.equal(moment([1970, 0, 2]).format('Q'), '1', 'Jan 2 1970 is Q1');
329 assert.equal(moment([2001, 11, 12]).format('Q'), '4', 'Dec 12 2001 is Q4');
330 assert.equal(moment([2000, 0, 2]).format('[Q]Q-YYYY'), 'Q1-2000', 'Jan 2 2000 is Q1');
331 });
332
333 test('full expanded format is returned from abbreviated formats', function (assert) {
334 var locales = '';
335
336 locales += 'af ar-ma ar-sa ar-tn ar az be bg bn bo br bs';
337 locales += 'ca cs cv cy da de-at de el en-au en-ca en-gb';
338 locales += 'en eo es et eu fa fi fo fr-ca fr fy gl he hi';
339 locales += 'hr hu hy-am id is it ja jv ka km ko lb lt lv';
340 locales += 'me mk ml mr ms-my my nb ne nl nn pl pt-rb pt';
341 locales += 'ro ru si sk sl sq sr-cyrl sr sv ta th tl-ph';
342 locales += 'tr tzm-latn tzm uk uz vi zh-cn zh-tw';
343
344 locales.split(' ').forEach(function (locale) {
345 var data, tokens;
346 data = moment().locale(locale).localeData()._longDateFormat;
347 tokens = Object.keys(data);
348 tokens.forEach(function (token) {
349 // Check each format string to make sure it does not contain any
350 // tokens that need to be expanded.
351 tokens.forEach(function (i) {
352 // strip escaped sequences
353 var format = data[i].replace(/(\[[^\]]*\])/g, '');
354 assert.equal(false, !!~format.indexOf(token), 'locale ' + locale + ' contains ' + token + ' in ' + i);
355 });
356 });
357 });
358 });
359
360 test('milliseconds', function (assert) {
361 var m = moment('123', 'SSS');
362
363 assert.equal(m.format('S'), '1');
364 assert.equal(m.format('SS'), '12');
365 assert.equal(m.format('SSS'), '123');
366 assert.equal(m.format('SSSS'), '1230');
367 assert.equal(m.format('SSSSS'), '12300');
368 assert.equal(m.format('SSSSSS'), '123000');
369 assert.equal(m.format('SSSSSSS'), '1230000');
370 assert.equal(m.format('SSSSSSSS'), '12300000');
371 assert.equal(m.format('SSSSSSSSS'), '123000000');
372 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('from_to');
4
5 test('from', function (assert) {
6 var start = moment();
7 moment.locale('en');
8 assert.equal(start.from(start.clone().add(5, 'seconds')), 'a few seconds ago', '5 seconds = a few seconds ago');
9 assert.equal(start.from(start.clone().add(1, 'minute')), 'a minute ago', '1 minute = a minute ago');
10 assert.equal(start.from(start.clone().add(5, 'minutes')), '5 minutes ago', '5 minutes = 5 minutes ago');
11
12 assert.equal(start.from(start.clone().subtract(5, 'seconds')), 'in a few seconds', '5 seconds = in a few seconds');
13 assert.equal(start.from(start.clone().subtract(1, 'minute')), 'in a minute', '1 minute = in a minute');
14 assert.equal(start.from(start.clone().subtract(5, 'minutes')), 'in 5 minutes', '5 minutes = in 5 minutes');
15 });
16
17 test('from with absolute duration', function (assert) {
18 var start = moment();
19 moment.locale('en');
20 assert.equal(start.from(start.clone().add(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
21 assert.equal(start.from(start.clone().add(1, 'minute'), true), 'a minute', '1 minute = a minute');
22 assert.equal(start.from(start.clone().add(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
23
24 assert.equal(start.from(start.clone().subtract(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
25 assert.equal(start.from(start.clone().subtract(1, 'minute'), true), 'a minute', '1 minute = a minute');
26 assert.equal(start.from(start.clone().subtract(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
27 });
28
29 test('to', function (assert) {
30 var start = moment();
31 moment.locale('en');
32 assert.equal(start.to(start.clone().subtract(5, 'seconds')), 'a few seconds ago', '5 seconds = a few seconds ago');
33 assert.equal(start.to(start.clone().subtract(1, 'minute')), 'a minute ago', '1 minute = a minute ago');
34 assert.equal(start.to(start.clone().subtract(5, 'minutes')), '5 minutes ago', '5 minutes = 5 minutes ago');
35
36 assert.equal(start.to(start.clone().add(5, 'seconds')), 'in a few seconds', '5 seconds = in a few seconds');
37 assert.equal(start.to(start.clone().add(1, 'minute')), 'in a minute', '1 minute = in a minute');
38 assert.equal(start.to(start.clone().add(5, 'minutes')), 'in 5 minutes', '5 minutes = in 5 minutes');
39 });
40
41 test('to with absolute duration', function (assert) {
42 var start = moment();
43 moment.locale('en');
44 assert.equal(start.to(start.clone().add(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
45 assert.equal(start.to(start.clone().add(1, 'minute'), true), 'a minute', '1 minute = a minute');
46 assert.equal(start.to(start.clone().add(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
47
48 assert.equal(start.to(start.clone().subtract(5, 'seconds'), true), 'a few seconds', '5 seconds = a few seconds');
49 assert.equal(start.to(start.clone().subtract(1, 'minute'), true), 'a minute', '1 minute = a minute');
50 assert.equal(start.to(start.clone().subtract(5, 'minutes'), true), '5 minutes', '5 minutes = 5 minutes');
51 });
52
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('getters and setters');
4
5 test('getters', function (assert) {
6 var a = moment([2011, 9, 12, 6, 7, 8, 9]);
7 assert.equal(a.year(), 2011, 'year');
8 assert.equal(a.month(), 9, 'month');
9 assert.equal(a.date(), 12, 'date');
10 assert.equal(a.day(), 3, 'day');
11 assert.equal(a.hours(), 6, 'hour');
12 assert.equal(a.minutes(), 7, 'minute');
13 assert.equal(a.seconds(), 8, 'second');
14 assert.equal(a.milliseconds(), 9, 'milliseconds');
15 });
16
17 test('getters programmatic', function (assert) {
18 var a = moment([2011, 9, 12, 6, 7, 8, 9]);
19 assert.equal(a.get('year'), 2011, 'year');
20 assert.equal(a.get('month'), 9, 'month');
21 assert.equal(a.get('date'), 12, 'date');
22 assert.equal(a.get('day'), 3, 'day');
23 assert.equal(a.get('hour'), 6, 'hour');
24 assert.equal(a.get('minute'), 7, 'minute');
25 assert.equal(a.get('second'), 8, 'second');
26 assert.equal(a.get('milliseconds'), 9, 'milliseconds');
27
28 //actual getters tested elsewhere
29 assert.equal(a.get('weekday'), a.weekday(), 'weekday');
30 assert.equal(a.get('isoWeekday'), a.isoWeekday(), 'isoWeekday');
31 assert.equal(a.get('week'), a.week(), 'week');
32 assert.equal(a.get('isoWeek'), a.isoWeek(), 'isoWeek');
33 assert.equal(a.get('dayOfYear'), a.dayOfYear(), 'dayOfYear');
34 });
35
36 test('setters plural', function (assert) {
37 var a = moment();
38 a.years(2011);
39 a.months(9);
40 a.dates(12);
41 a.hours(6);
42 a.minutes(7);
43 a.seconds(8);
44 a.milliseconds(9);
45 assert.equal(a.years(), 2011, 'years');
46 assert.equal(a.months(), 9, 'months');
47 assert.equal(a.dates(), 12, 'dates');
48 assert.equal(a.days(), 3, 'days');
49 assert.equal(a.hours(), 6, 'hours');
50 assert.equal(a.minutes(), 7, 'minutes');
51 assert.equal(a.seconds(), 8, 'seconds');
52 assert.equal(a.milliseconds(), 9, 'milliseconds');
53 });
54
55 test('setters singular', function (assert) {
56 var a = moment();
57 a.year(2011);
58 a.month(9);
59 a.date(12);
60 a.hour(6);
61 a.minute(7);
62 a.second(8);
63 a.millisecond(9);
64 assert.equal(a.year(), 2011, 'year');
65 assert.equal(a.month(), 9, 'month');
66 assert.equal(a.date(), 12, 'date');
67 assert.equal(a.day(), 3, 'day');
68 assert.equal(a.hour(), 6, 'hour');
69 assert.equal(a.minute(), 7, 'minute');
70 assert.equal(a.second(), 8, 'second');
71 assert.equal(a.millisecond(), 9, 'milliseconds');
72 });
73
74 test('setters', function (assert) {
75 var a = moment();
76 a.year(2011);
77 a.month(9);
78 a.date(12);
79 a.hours(6);
80 a.minutes(7);
81 a.seconds(8);
82 a.milliseconds(9);
83 assert.equal(a.year(), 2011, 'year');
84 assert.equal(a.month(), 9, 'month');
85 assert.equal(a.date(), 12, 'date');
86 assert.equal(a.day(), 3, 'day');
87 assert.equal(a.hours(), 6, 'hour');
88 assert.equal(a.minutes(), 7, 'minute');
89 assert.equal(a.seconds(), 8, 'second');
90 assert.equal(a.milliseconds(), 9, 'milliseconds');
91
92 // Test month() behavior. See https://github.com/timrwood/moment/pull/822
93 a = moment('20130531', 'YYYYMMDD');
94 a.month(3);
95 assert.equal(a.month(), 3, 'month edge case');
96 });
97
98 test('setter programmatic', function (assert) {
99 var a = moment();
100 a.set('year', 2011);
101 a.set('month', 9);
102 a.set('date', 12);
103 a.set('hours', 6);
104 a.set('minutes', 7);
105 a.set('seconds', 8);
106 a.set('milliseconds', 9);
107 assert.equal(a.year(), 2011, 'year');
108 assert.equal(a.month(), 9, 'month');
109 assert.equal(a.date(), 12, 'date');
110 assert.equal(a.day(), 3, 'day');
111 assert.equal(a.hours(), 6, 'hour');
112 assert.equal(a.minutes(), 7, 'minute');
113 assert.equal(a.seconds(), 8, 'second');
114 assert.equal(a.milliseconds(), 9, 'milliseconds');
115
116 // Test month() behavior. See https://github.com/timrwood/moment/pull/822
117 a = moment('20130531', 'YYYYMMDD');
118 a.month(3);
119 assert.equal(a.month(), 3, 'month edge case');
120 });
121
122 // Disable this, until we weekYear setter is fixed.
123 // https://github.com/moment/moment/issues/1379
124 // test('setters programatic with weeks', function (assert) {
125 // var a = moment();
126 // a.set('weekYear', 2001);
127 // a.set('week', 49);
128 // a.set('day', 4);
129 // assert.equals(a.weekYear(), 2001);
130 // assert.equals(a.week(), 49);
131 // assert.equals(a.day(), 4);
132
133 // a.set('weekday', 1);
134 // assert.equals(a.weekday(), 1);
135
136 // assert.done();
137 //},
138
139 // I think this suffers from the same issue as the non-iso version.
140 // test('setters programatic with weeks ISO', function (assert) {
141 // var a = moment();
142 // a.set('isoWeekYear', 2001);
143 // a.set('isoWeek', 49);
144 // a.set('isoWeekday', 4);
145
146 // assert.equals(a.weekYear(), 2001);
147 // assert.equals(a.week(), 49);
148 // assert.equals(a.day(), 4);
149
150 // assert.done();
151 //},
152
153 test('setters strings', function (assert) {
154 var a = moment([2012]).locale('en');
155 assert.equal(a.clone().day(0).day('Wednesday').day(), 3, 'day full name');
156 assert.equal(a.clone().day(0).day('Wed').day(), 3, 'day short name');
157 assert.equal(a.clone().day(0).day('We').day(), 3, 'day minimal name');
158 assert.equal(a.clone().day(0).day('invalid').day(), 0, 'invalid day name');
159 assert.equal(a.clone().month(0).month('April').month(), 3, 'month full name');
160 assert.equal(a.clone().month(0).month('Apr').month(), 3, 'month short name');
161 assert.equal(a.clone().month(0).month('invalid').month(), 0, 'invalid month name');
162 });
163
164 test('setters - falsey values', function (assert) {
165 var a = moment();
166 // ensure minutes wasn't coincidentally 0 already
167 a.minutes(1);
168 a.minutes(0);
169 assert.equal(a.minutes(), 0, 'falsey value');
170 });
171
172 test('chaining setters', function (assert) {
173 var a = moment();
174 a.year(2011)
175 .month(9)
176 .date(12)
177 .hours(6)
178 .minutes(7)
179 .seconds(8);
180 assert.equal(a.year(), 2011, 'year');
181 assert.equal(a.month(), 9, 'month');
182 assert.equal(a.date(), 12, 'date');
183 assert.equal(a.day(), 3, 'day');
184 assert.equal(a.hours(), 6, 'hour');
185 assert.equal(a.minutes(), 7, 'minute');
186 assert.equal(a.seconds(), 8, 'second');
187 });
188
189 test('setter with multiple unit values', function (assert) {
190 var a = moment();
191 a.set({
192 year: 2011,
193 month: 9,
194 date: 12,
195 hours: 6,
196 minutes: 7,
197 seconds: 8,
198 milliseconds: 9
199 });
200 assert.equal(a.year(), 2011, 'year');
201 assert.equal(a.month(), 9, 'month');
202 assert.equal(a.date(), 12, 'date');
203 assert.equal(a.day(), 3, 'day');
204 assert.equal(a.hours(), 6, 'hour');
205 assert.equal(a.minutes(), 7, 'minute');
206 assert.equal(a.seconds(), 8, 'second');
207 assert.equal(a.milliseconds(), 9, 'milliseconds');
208 });
209
210 test('day setter', function (assert) {
211 var a = moment([2011, 0, 15]);
212 assert.equal(moment(a).day(0).date(), 9, 'set from saturday to sunday');
213 assert.equal(moment(a).day(6).date(), 15, 'set from saturday to saturday');
214 assert.equal(moment(a).day(3).date(), 12, 'set from saturday to wednesday');
215
216 a = moment([2011, 0, 9]);
217 assert.equal(moment(a).day(0).date(), 9, 'set from sunday to sunday');
218 assert.equal(moment(a).day(6).date(), 15, 'set from sunday to saturday');
219 assert.equal(moment(a).day(3).date(), 12, 'set from sunday to wednesday');
220
221 a = moment([2011, 0, 12]);
222 assert.equal(moment(a).day(0).date(), 9, 'set from wednesday to sunday');
223 assert.equal(moment(a).day(6).date(), 15, 'set from wednesday to saturday');
224 assert.equal(moment(a).day(3).date(), 12, 'set from wednesday to wednesday');
225
226 assert.equal(moment(a).day(-7).date(), 2, 'set from wednesday to last sunday');
227 assert.equal(moment(a).day(-1).date(), 8, 'set from wednesday to last saturday');
228 assert.equal(moment(a).day(-4).date(), 5, 'set from wednesday to last wednesday');
229
230 assert.equal(moment(a).day(7).date(), 16, 'set from wednesday to next sunday');
231 assert.equal(moment(a).day(13).date(), 22, 'set from wednesday to next saturday');
232 assert.equal(moment(a).day(10).date(), 19, 'set from wednesday to next wednesday');
233
234 assert.equal(moment(a).day(14).date(), 23, 'set from wednesday to second next sunday');
235 assert.equal(moment(a).day(20).date(), 29, 'set from wednesday to second next saturday');
236 assert.equal(moment(a).day(17).date(), 26, 'set from wednesday to second next wednesday');
237 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('invalid');
4
5 test('invalid', function (assert) {
6 var m = moment.invalid();
7 assert.equal(m.isValid(), false);
8 assert.equal(m.parsingFlags().userInvalidated, true);
9 assert.ok(isNaN(m.valueOf()));
10 });
11
12 test('invalid with existing flag', function (assert) {
13 var m = moment.invalid({invalidMonth : 'whatchamacallit'});
14 assert.equal(m.isValid(), false);
15 assert.equal(m.parsingFlags().userInvalidated, false);
16 assert.equal(m.parsingFlags().invalidMonth, 'whatchamacallit');
17 assert.ok(isNaN(m.valueOf()));
18 });
19
20 test('invalid with custom flag', function (assert) {
21 var m = moment.invalid({tooBusyWith : 'reiculating splines'});
22 assert.equal(m.isValid(), false);
23 assert.equal(m.parsingFlags().userInvalidated, false);
24 assert.equal(m.parsingFlags().tooBusyWith, 'reiculating splines');
25 assert.ok(isNaN(m.valueOf()));
26 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('is after');
4
5 test('is after without units', function (assert) {
6 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
7 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, 'year is later');
8 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), true, 'year is earlier');
9 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, 'month is later');
10 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), true, 'month is earlier');
11 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, 'day is later');
12 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), true, 'day is earlier');
13 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, 'hour is later');
14 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), true, 'hour is earlier');
15 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, 'minute is later');
16 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), true, 'minute is earlier');
17 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, 'second is later');
18 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), true, 'second is earlier');
19 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond match');
20 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, 'millisecond is later');
21 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), true, 'millisecond is earlier');
22 assert.equal(m.isAfter(m), false, 'moments are not after themselves');
23 assert.equal(+m, +mCopy, 'isAfter second should not change moment');
24 });
25
26 test('is after year', function (assert) {
27 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
28 assert.equal(m.isAfter(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');
29 assert.equal(m.isAfter(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
30 assert.equal(m.isAfter(moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is later');
31 assert.equal(m.isAfter(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is earlier');
32 assert.equal(m.isAfter(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), false, 'exact start of year');
33 assert.equal(m.isAfter(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), false, 'exact end of year');
34 assert.equal(m.isAfter(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), false, 'start of next year');
35 assert.equal(m.isAfter(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), true, 'end of previous year');
36 assert.equal(m.isAfter(moment(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year'), true, 'end of year far before');
37 assert.equal(m.isAfter(m, 'year'), false, 'same moments are not after the same year');
38 assert.equal(+m, +mCopy, 'isAfter year should not change moment');
39 });
40
41 test('is after month', function (assert) {
42 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
43 assert.equal(m.isAfter(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month match');
44 assert.equal(m.isAfter(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
45 assert.equal(m.isAfter(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year is later');
46 assert.equal(m.isAfter(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month'), true, 'year is earlier');
47 assert.equal(m.isAfter(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), false, 'month is later');
48 assert.equal(m.isAfter(moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), true, 'month is earlier');
49 assert.equal(m.isAfter(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), false, 'exact start of month');
50 assert.equal(m.isAfter(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), false, 'exact end of month');
51 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), false, 'start of next month');
52 assert.equal(m.isAfter(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), true, 'end of previous month');
53 assert.equal(m.isAfter(moment(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month'), true, 'later month but earlier year');
54 assert.equal(m.isAfter(m, 'month'), false, 'same moments are not after the same month');
55 assert.equal(+m, +mCopy, 'isAfter month should not change moment');
56 });
57
58 test('is after day', function (assert) {
59 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
60 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day'), false, 'day match');
61 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');
62 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day'), false, 'year is later');
63 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day'), true, 'year is earlier');
64 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day'), false, 'month is later');
65 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), true, 'month is earlier');
66 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day'), false, 'day is later');
67 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day'), true, 'day is earlier');
68 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day'), false, 'exact start of day');
69 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day'), false, 'exact end of day');
70 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day'), false, 'start of next day');
71 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day'), true, 'end of previous day');
72 assert.equal(m.isAfter(moment(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day'), true, 'later day but earlier year');
73 assert.equal(m.isAfter(m, 'day'), false, 'same moments are not after the same day');
74 assert.equal(+m, +mCopy, 'isAfter day should not change moment');
75 });
76
77 test('is after hour', function (assert) {
78 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
79 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour match');
80 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');
81 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'year is later');
82 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour'), true, 'year is earlier');
83 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour'), false, 'month is later');
84 assert.equal(m.isAfter(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), true, 'month is earlier');
85 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour'), false, 'day is later');
86 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour'), true, 'day is earlier');
87 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour'), false, 'hour is later');
88 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour is earlier');
89 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour'), false, 'exact start of hour');
90 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour'), false, 'exact end of hour');
91 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour'), false, 'start of next hour');
92 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour'), true, 'end of previous hour');
93 assert.equal(m.isAfter(m, 'hour'), false, 'same moments are not after the same hour');
94 assert.equal(+m, +mCopy, 'isAfter hour should not change moment');
95 });
96
97 test('is after minute', function (assert) {
98 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
99 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');
100 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');
101 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'year is later');
102 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute'), true, 'year is earlier');
103 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute'), false, 'month is later');
104 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), true, 'month is earlier');
105 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute'), false, 'day is later');
106 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute'), true, 'day is earlier');
107 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute'), false, 'hour is later');
108 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute'), true, 'hour is earler');
109 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute'), false, 'minute is later');
110 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute'), true, 'minute is earlier');
111 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute'), false, 'exact start of minute');
112 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute'), false, 'exact end of minute');
113 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute'), false, 'start of next minute');
114 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute'), true, 'end of previous minute');
115 assert.equal(m.isAfter(m, 'minute'), false, 'same moments are not after the same minute');
116 assert.equal(+m, +mCopy, 'isAfter minute should not change moment');
117 });
118
119 test('is after second', function (assert) {
120 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
121 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second'), false, 'second match');
122 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');
123 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second'), false, 'year is later');
124 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second'), true, 'year is earlier');
125 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second'), false, 'month is later');
126 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), true, 'month is earlier');
127 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second'), false, 'day is later');
128 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second'), true, 'day is earlier');
129 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second'), false, 'hour is later');
130 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second'), true, 'hour is earlier');
131 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second'), false, 'minute is later');
132 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second'), true, 'minute is earlier');
133 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second'), false, 'second is later');
134 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second'), true, 'second is earlier');
135 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second'), false, 'exact start of second');
136 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second'), false, 'exact end of second');
137 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second'), false, 'start of next second');
138 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second'), true, 'end of previous second');
139 assert.equal(m.isAfter(m, 'second'), false, 'same moments are not after the same second');
140 assert.equal(+m, +mCopy, 'isAfter second should not change moment');
141 });
142
143 test('is after millisecond', function (assert) {
144 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
145 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond match');
146 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'plural should work');
147 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is later');
148 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'year is earlier');
149 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is later');
150 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), true, 'month is earlier');
151 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), false, 'day is later');
152 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), true, 'day is earlier');
153 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), false, 'hour is later');
154 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), true, 'hour is earlier');
155 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), false, 'minute is later');
156 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), true, 'minute is earlier');
157 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), false, 'second is later');
158 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), true, 'second is earlier');
159 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), false, 'millisecond is later');
160 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), true, 'millisecond is earlier');
161 assert.equal(m.isAfter(m, 'millisecond'), false, 'same moments are not after the same millisecond');
162 assert.equal(+m, +mCopy, 'isAfter millisecond should not change moment');
163 });
164
165 test('is after invalid', function (assert) {
166 var m = moment(), invalid = moment.invalid();
167 assert.equal(m.isAfter(invalid), false, 'valid moment is not after invalid moment');
168 assert.equal(invalid.isAfter(m), false, 'invalid moment is not after valid moment');
169 assert.equal(m.isAfter(invalid, 'year'), false, 'invalid moment year');
170 assert.equal(m.isAfter(invalid, 'month'), false, 'invalid moment month');
171 assert.equal(m.isAfter(invalid, 'day'), false, 'invalid moment day');
172 assert.equal(m.isAfter(invalid, 'hour'), false, 'invalid moment hour');
173 assert.equal(m.isAfter(invalid, 'minute'), false, 'invalid moment minute');
174 assert.equal(m.isAfter(invalid, 'second'), false, 'invalid moment second');
175 assert.equal(m.isAfter(invalid, 'milliseconds'), false, 'invalid moment milliseconds');
176 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('is before');
4
5 test('is after without units', function (assert) {
6 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
7 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), true, 'year is later');
8 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, 'year is earlier');
9 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), true, 'month is later');
10 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, 'month is earlier');
11 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), true, 'day is later');
12 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, 'day is earlier');
13 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), true, 'hour is later');
14 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, 'hour is earlier');
15 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), true, 'minute is later');
16 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, 'minute is earlier');
17 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), true, 'second is later');
18 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, 'second is earlier');
19 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond match');
20 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), true, 'millisecond is later');
21 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, 'millisecond is earlier');
22 assert.equal(m.isBefore(m), false, 'moments are not before themselves');
23 assert.equal(+m, +mCopy, 'isBefore second should not change moment');
24 });
25
26 test('is before year', function (assert) {
27 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
28 assert.equal(m.isBefore(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');
29 assert.equal(m.isBefore(moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
30 assert.equal(m.isBefore(moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is later');
31 assert.equal(m.isBefore(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is earlier');
32 assert.equal(m.isBefore(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), false, 'exact start of year');
33 assert.equal(m.isBefore(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), false, 'exact end of year');
34 assert.equal(m.isBefore(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), true, 'start of next year');
35 assert.equal(m.isBefore(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of previous year');
36 assert.equal(m.isBefore(moment(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of year far before');
37 assert.equal(m.isBefore(m, 'year'), false, 'same moments are not before the same year');
38 assert.equal(+m, +mCopy, 'isBefore year should not change moment');
39 });
40
41 test('is before month', function (assert) {
42 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
43 assert.equal(m.isBefore(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month match');
44 assert.equal(m.isBefore(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
45 assert.equal(m.isBefore(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), true, 'year is later');
46 assert.equal(m.isBefore(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year is earlier');
47 assert.equal(m.isBefore(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), true, 'month is later');
48 assert.equal(m.isBefore(moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), false, 'month is earlier');
49 assert.equal(m.isBefore(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), false, 'exact start of month');
50 assert.equal(m.isBefore(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), false, 'exact end of month');
51 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), true, 'start of next month');
52 assert.equal(m.isBefore(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), false, 'end of previous month');
53 assert.equal(m.isBefore(moment(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month'), false, 'later month but earlier year');
54 assert.equal(m.isBefore(m, 'month'), false, 'same moments are not before the same month');
55 assert.equal(+m, +mCopy, 'isBefore month should not change moment');
56 });
57
58 test('is before day', function (assert) {
59 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
60 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day'), false, 'day match');
61 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');
62 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day'), true, 'year is later');
63 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day'), false, 'year is earlier');
64 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day'), true, 'month is later');
65 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), false, 'month is earlier');
66 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day'), true, 'day is later');
67 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day'), false, 'day is earlier');
68 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day'), false, 'exact start of day');
69 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day'), false, 'exact end of day');
70 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day'), true, 'start of next day');
71 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day'), false, 'end of previous day');
72 assert.equal(m.isBefore(moment(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day'), false, 'later day but earlier year');
73 assert.equal(m.isBefore(m, 'day'), false, 'same moments are not before the same day');
74 assert.equal(+m, +mCopy, 'isBefore day should not change moment');
75 });
76
77 test('is before hour', function (assert) {
78 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
79 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour match');
80 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');
81 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour'), true, 'year is later');
82 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'year is earlier');
83 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour'), true, 'month is later');
84 assert.equal(m.isBefore(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), false, 'month is earlier');
85 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour'), true, 'day is later');
86 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour'), false, 'day is earlier');
87 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour'), true, 'hour is later');
88 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour is earlier');
89 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour'), false, 'exact start of hour');
90 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour'), false, 'exact end of hour');
91 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour'), true, 'start of next hour');
92 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour'), false, 'end of previous hour');
93 assert.equal(m.isBefore(m, 'hour'), false, 'same moments are not before the same hour');
94 assert.equal(+m, +mCopy, 'isBefore hour should not change moment');
95 });
96
97 test('is before minute', function (assert) {
98 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);
99 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');
100 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');
101 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute'), true, 'year is later');
102 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'year is earlier');
103 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute'), true, 'month is later');
104 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), false, 'month is earlier');
105 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute'), true, 'day is later');
106 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute'), false, 'day is earlier');
107 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute'), true, 'hour is later');
108 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute'), false, 'hour is earler');
109 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute'), true, 'minute is later');
110 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute'), false, 'minute is earlier');
111 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute'), false, 'exact start of minute');
112 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute'), false, 'exact end of minute');
113 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute'), true, 'start of next minute');
114 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute'), false, 'end of previous minute');
115 assert.equal(m.isBefore(m, 'minute'), false, 'same moments are not before the same minute');
116 assert.equal(+m, +mCopy, 'isBefore minute should not change moment');
117 });
118
119 test('is before second', function (assert) {
120 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
121 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second'), false, 'second match');
122 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');
123 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second'), true, 'year is later');
124 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second'), false, 'year is earlier');
125 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second'), true, 'month is later');
126 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), false, 'month is earlier');
127 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second'), true, 'day is later');
128 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second'), false, 'day is earlier');
129 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second'), true, 'hour is later');
130 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second'), false, 'hour is earlier');
131 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second'), true, 'minute is later');
132 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second'), false, 'minute is earlier');
133 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second'), true, 'second is later');
134 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second'), false, 'second is earlier');
135 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second'), false, 'exact start of second');
136 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second'), false, 'exact end of second');
137 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second'), true, 'start of next second');
138 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second'), false, 'end of previous second');
139 assert.equal(m.isBefore(m, 'second'), false, 'same moments are not before the same second');
140 assert.equal(+m, +mCopy, 'isBefore second should not change moment');
141 });
142
143 test('is before millisecond', function (assert) {
144 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
145 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond match');
146 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds'), false, 'plural should work');
147 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'year is later');
148 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is earlier');
149 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), true, 'month is later');
150 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is earlier');
151 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), true, 'day is later');
152 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), false, 'day is earlier');
153 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), true, 'hour is later');
154 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), false, 'hour is earlier');
155 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), true, 'minute is later');
156 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), false, 'minute is earlier');
157 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), true, 'second is later');
158 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), false, 'second is earlier');
159 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), true, 'millisecond is later');
160 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), false, 'millisecond is earlier');
161 assert.equal(m.isBefore(m, 'millisecond'), false, 'same moments are not before the same millisecond');
162 assert.equal(+m, +mCopy, 'isBefore millisecond should not change moment');
163 });
164
165 test('is before invalid', function (assert) {
166 var m = moment(), invalid = moment.invalid();
167 assert.equal(m.isBefore(invalid), false, 'valid moment is not before invalid moment');
168 assert.equal(invalid.isBefore(m), false, 'invalid moment is not before valid moment');
169 assert.equal(m.isBefore(invalid, 'year'), false, 'invalid moment year');
170 assert.equal(m.isBefore(invalid, 'month'), false, 'invalid moment month');
171 assert.equal(m.isBefore(invalid, 'day'), false, 'invalid moment day');
172 assert.equal(m.isBefore(invalid, 'hour'), false, 'invalid moment hour');
173 assert.equal(m.isBefore(invalid, 'minute'), false, 'invalid moment minute');
174 assert.equal(m.isBefore(invalid, 'second'), false, 'invalid moment second');
175 assert.equal(m.isBefore(invalid, 'milliseconds'), false, 'invalid moment milliseconds');
176 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('is between');
4
5 test('is between without units', function (assert) {
6 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
7 assert.equal(m.isBetween(
8 moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
9 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'year is later');
10 assert.equal(m.isBetween(
11 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
12 moment(new Date(2013, 3, 2, 3, 4, 5, 10))), false, 'year is earlier');
13 assert.equal(m.isBetween(
14 moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
15 moment(new Date(2012, 3, 2, 3, 4, 5, 10))), true, 'year is between');
16 assert.equal(m.isBetween(
17 moment(new Date(2011, 1, 2, 3, 4, 5, 10)),
18 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'month is later');
19 assert.equal(m.isBetween(
20 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
21 moment(new Date(2011, 5, 2, 3, 4, 5, 10))), false, 'month is earlier');
22 assert.equal(m.isBetween(
23 moment(new Date(2011, 2, 2, 3, 4, 5, 10)),
24 moment(new Date(2011, 4, 2, 3, 4, 5, 10))), true, 'month is between');
25 assert.equal(m.isBetween(
26 moment(new Date(2011, 3, 1, 3, 4, 5, 10)),
27 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'day is later');
28 assert.equal(m.isBetween(
29 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
30 moment(new Date(2011, 3, 4, 3, 4, 5, 10))), false, 'day is earlier');
31 assert.equal(m.isBetween(
32 moment(new Date(2011, 3, 1, 3, 4, 5, 10)),
33 moment(new Date(2011, 3, 3, 3, 4, 5, 10))), true, 'day is between');
34 assert.equal(m.isBetween(
35 moment(new Date(2011, 3, 2, 1, 4, 5, 10)),
36 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'hour is later');
37 assert.equal(m.isBetween(
38 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
39 moment(new Date(2011, 3, 2, 5, 4, 5, 10))), false, 'hour is earlier');
40 assert.equal(m.isBetween(
41 moment(new Date(2011, 3, 2, 2, 4, 5, 10)),
42 moment(new Date(2011, 3, 2, 4, 4, 5, 10))), true, 'hour is between');
43 assert.equal(m.isBetween(
44 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
45 moment(new Date(2011, 3, 2, 3, 6, 5, 10))), false, 'minute is later');
46 assert.equal(m.isBetween(
47 moment(new Date(2011, 3, 2, 3, 2, 5, 10)),
48 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'minute is earlier');
49 assert.equal(m.isBetween(
50 moment(new Date(2011, 3, 2, 3, 3, 5, 10)),
51 moment(new Date(2011, 3, 2, 3, 5, 5, 10))), true, 'minute is between');
52 assert.equal(m.isBetween(
53 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
54 moment(new Date(2011, 3, 2, 3, 4, 7, 10))), false, 'second is later');
55 assert.equal(m.isBetween(
56 moment(new Date(2011, 3, 2, 3, 4, 3, 10)),
57 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'second is earlier');
58 assert.equal(m.isBetween(
59 moment(new Date(2011, 3, 2, 3, 4, 4, 10)),
60 moment(new Date(2011, 3, 2, 3, 4, 6, 10))), true, 'second is between');
61 assert.equal(m.isBetween(
62 moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
63 moment(new Date(2011, 3, 2, 3, 4, 5, 12))), false, 'millisecond is later');
64 assert.equal(m.isBetween(
65 moment(new Date(2011, 3, 2, 3, 4, 5, 8)),
66 moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond is earlier');
67 assert.equal(m.isBetween(
68 moment(new Date(2011, 3, 2, 3, 4, 5, 9)),
69 moment(new Date(2011, 3, 2, 3, 4, 5, 11))), true, 'millisecond is between');
70 assert.equal(m.isBetween(m, m), false, 'moments are not between themselves');
71 assert.equal(+m, +mCopy, 'isBetween second should not change moment');
72 });
73
74 test('is between year', function (assert) {
75 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
76 assert.equal(m.isBetween(
77 moment(new Date(2011, 5, 6, 7, 8, 9, 10)),
78 moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');
79 assert.equal(m.isBetween(
80 moment(new Date(2010, 5, 6, 7, 8, 9, 10)),
81 moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
82 assert.equal(m.isBetween(
83 moment(new Date(2010, 5, 6, 7, 8, 9, 10)),
84 moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is between');
85 assert.equal(m.isBetween(
86 moment(new Date(2011, 5, 6, 7, 8, 9, 10)),
87 moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is earlier');
88 assert.equal(m.isBetween(
89 moment(new Date(2010, 5, 6, 7, 8, 9, 10)),
90 moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is later');
91 assert.equal(m.isBetween(m, 'year'), false, 'same moments are not between the same year');
92 assert.equal(+m, +mCopy, 'isBetween year should not change moment');
93 });
94
95 test('is between month', function (assert) {
96 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
97 assert.equal(m.isBetween(
98 moment(new Date(2011, 1, 6, 7, 8, 9, 10)),
99 moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), false, 'month match');
100 assert.equal(m.isBetween(
101 moment(new Date(2011, 0, 6, 7, 8, 9, 10)),
102 moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
103 assert.equal(m.isBetween(
104 moment(new Date(2011, 0, 31, 23, 59, 59, 999)),
105 moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), true, 'month is between');
106 assert.equal(m.isBetween(
107 moment(new Date(2011, 1, 6, 7, 8, 9, 10)),
108 moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month is earlier');
109 assert.equal(m.isBetween(
110 moment(new Date(2011, 11, 6, 7, 8, 9, 10)),
111 moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), false, 'month is later');
112 assert.equal(m.isBetween(m, 'month'), false, 'same moments are not between the same month');
113 assert.equal(+m, +mCopy, 'isBetween month should not change moment');
114 });
115
116 test('is between day', function (assert) {
117 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
118 assert.equal(m.isBetween(
119 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
120 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), false, 'day match');
121 assert.equal(m.isBetween(
122 moment(new Date(2011, 1, 1, 7, 8, 9, 10)),
123 moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'days'), true, 'plural should work');
124 assert.equal(m.isBetween(
125 moment(new Date(2011, 1, 1, 7, 8, 9, 10)),
126 moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day'), true, 'day is between');
127 assert.equal(m.isBetween(
128 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
129 moment(new Date(2011, 1, 4, 7, 8, 9, 10)), 'day'), false, 'day is earlier');
130 assert.equal(m.isBetween(
131 moment(new Date(2011, 1, 1, 7, 8, 9, 10)),
132 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), false, 'day is later');
133 assert.equal(m.isBetween(m, 'day'), false, 'same moments are not between the same day');
134 assert.equal(+m, +mCopy, 'isBetween day should not change moment');
135 });
136
137 test('is between hour', function (assert) {
138 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
139 assert.equal(m.isBetween(
140 moment(new Date(2011, 1, 2, 3, 5, 9, 10)),
141 moment(new Date(2011, 1, 2, 3, 9, 9, 10)), 'hour'), false, 'hour match');
142 assert.equal(m.isBetween(
143 moment(new Date(2011, 1, 2, 1, 59, 59, 999)),
144 moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hours'), true, 'plural should work');
145 assert.equal(m.isBetween(
146 moment(new Date(2011, 1, 2, 2, 59, 59, 999)),
147 moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour'), true, 'hour is between');
148 assert.equal(m.isBetween(
149 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
150 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'hour'), false, 'hour is earlier');
151 assert.equal(m.isBetween(
152 moment(new Date(2011, 1, 2, 7, 8, 9, 10)),
153 moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'hour'), false, 'hour is later');
154 assert.equal(m.isBetween(m, 'hour'), false, 'same moments are not between the same hour');
155 assert.equal(+m, +mCopy, 'isBetween hour should not change moment');
156 });
157
158 test('is between minute', function (assert) {
159 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
160 assert.equal(m.isBetween(
161 moment(new Date(2011, 1, 2, 3, 4, 9, 10)),
162 moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');
163 assert.equal(m.isBetween(
164 moment(new Date(2011, 1, 2, 3, 3, 9, 10)),
165 moment(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minutes'), true, 'plural should work');
166 assert.equal(m.isBetween(
167 moment(new Date(2011, 1, 2, 3, 3, 59, 999)),
168 moment(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute'), true, 'minute is between');
169 assert.equal(m.isBetween(
170 moment(new Date(2011, 1, 2, 3, 5, 0, 0)),
171 moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'minute'), false, 'minute is earlier');
172 assert.equal(m.isBetween(
173 moment(new Date(2011, 1, 2, 3, 2, 9, 10)),
174 moment(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute'), false, 'minute is later');
175 assert.equal(m.isBetween(m, 'minute'), false, 'same moments are not between the same minute');
176 assert.equal(+m, +mCopy, 'isBetween minute should not change moment');
177 });
178
179 test('is between second', function (assert) {
180 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
181 assert.equal(m.isBetween(
182 moment(new Date(2011, 1, 2, 3, 4, 5, 10)),
183 moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second'), false, 'second match');
184 assert.equal(m.isBetween(
185 moment(new Date(2011, 1, 2, 3, 4, 4, 10)),
186 moment(new Date(2011, 1, 2, 3, 4, 6, 10)), 'seconds'), true, 'plural should work');
187 assert.equal(m.isBetween(
188 moment(new Date(2011, 1, 2, 3, 4, 4, 999)),
189 moment(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second'), true, 'second is between');
190 assert.equal(m.isBetween(
191 moment(new Date(2011, 1, 2, 3, 4, 6, 0)),
192 moment(new Date(2011, 1, 2, 3, 4, 7, 10)), 'second'), false, 'second is earlier');
193 assert.equal(m.isBetween(
194 moment(new Date(2011, 1, 2, 3, 4, 3, 10)),
195 moment(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second'), false, 'second is later');
196 assert.equal(m.isBetween(m, 'second'), false, 'same moments are not between the same second');
197 assert.equal(+m, +mCopy, 'isBetween second should not change moment');
198 });
199
200 test('is between millisecond', function (assert) {
201 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
202 assert.equal(m.isBetween(
203 moment(new Date(2011, 1, 2, 3, 4, 5, 6)),
204 moment(new Date(2011, 1, 2, 3, 4, 5, 6)), 'millisecond'), false, 'millisecond match');
205 assert.equal(m.isBetween(
206 moment(new Date(2011, 1, 2, 3, 4, 5, 5)),
207 moment(new Date(2011, 1, 2, 3, 4, 5, 7)), 'milliseconds'), true, 'plural should work');
208 assert.equal(m.isBetween(
209 moment(new Date(2011, 1, 2, 3, 4, 5, 5)),
210 moment(new Date(2011, 1, 2, 3, 4, 5, 7)), 'millisecond'), true, 'millisecond is between');
211 assert.equal(m.isBetween(
212 moment(new Date(2011, 1, 2, 3, 4, 5, 7)),
213 moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond is earlier');
214 assert.equal(m.isBetween(
215 moment(new Date(2011, 1, 2, 3, 4, 5, 4)),
216 moment(new Date(2011, 1, 2, 3, 4, 5, 6)), 'millisecond'), false, 'millisecond is later');
217 assert.equal(m.isBetween(m, 'millisecond'), false, 'same moments are not between the same millisecond');
218 assert.equal(+m, +mCopy, 'isBetween millisecond should not change moment');
219 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('is date');
4
5 test('isDate recognizes Date objects', function (assert) {
6 assert.ok(moment.isDate(new Date()), 'no args (now)');
7 assert.ok(moment.isDate(new Date([2014, 2, 15])), 'array args');
8 assert.ok(moment.isDate(new Date('2014-03-15')), 'string args');
9 assert.ok(moment.isDate(new Date('does NOT look like a date')), 'invalid date');
10 });
11
12 test('isDate rejects non-Date objects', function (assert) {
13 assert.ok(!moment.isDate(), 'nothing');
14 assert.ok(!moment.isDate(undefined), 'undefined');
15 assert.ok(!moment.isDate(null), 'string args');
16 assert.ok(!moment.isDate(42), 'number');
17 assert.ok(!moment.isDate('2014-03-15'), 'string');
18 assert.ok(!moment.isDate([2014, 2, 15]), 'array');
19 assert.ok(!moment.isDate({year: 2014, month: 2, day: 15}), 'object');
20 assert.ok(!moment.isDate({toString: function () {
21 return '[object Date]';
22 }}), 'lying object');
23 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('is moment');
4
5 test('is moment object', function (assert) {
6 var MyObj = function () {},
7 extend = function (a, b) {
8 var i;
9 for (i in b) {
10 a[i] = b[i];
11 }
12 return a;
13 };
14 MyObj.prototype.toDate = function () {
15 return new Date();
16 };
17
18 assert.ok(moment.isMoment(moment()), 'simple moment object');
19 assert.ok(moment.isMoment(moment(null)), 'invalid moment object');
20 assert.ok(moment.isMoment(extend({}, moment())), 'externally cloned moments are moments');
21 assert.ok(moment.isMoment(extend({}, moment.utc())), 'externally cloned utc moments are moments');
22
23 assert.ok(!moment.isMoment(new MyObj()), 'myObj is not moment object');
24 assert.ok(!moment.isMoment(moment), 'moment function is not moment object');
25 assert.ok(!moment.isMoment(new Date()), 'date object is not moment object');
26 assert.ok(!moment.isMoment(Object), 'Object is not moment object');
27 assert.ok(!moment.isMoment('foo'), 'string is not moment object');
28 assert.ok(!moment.isMoment(1), 'number is not moment object');
29 assert.ok(!moment.isMoment(NaN), 'NaN is not moment object');
30 assert.ok(!moment.isMoment(null), 'null is not moment object');
31 assert.ok(!moment.isMoment(undefined), 'undefined is not moment object');
32 });
33
34 test('is moment with hacked hasOwnProperty', function (assert) {
35 var obj = {};
36 // HACK to suppress jshint warning about bad property name
37 obj['hasOwnMoney'.replace('Money', 'Property')] = function () {
38 return true;
39 };
40
41 assert.ok(!moment.isMoment(obj), 'isMoment works even if passed object has a wrong hasOwnProperty implementation (ie8)');
42 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('is same');
4
5 test('is same without units', function (assert) {
6 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
7 assert.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, 'year is later');
8 assert.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, 'year is earlier');
9 assert.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, 'month is later');
10 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, 'month is earlier');
11 assert.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, 'day is later');
12 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, 'day is earlier');
13 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, 'hour is later');
14 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, 'hour is earlier');
15 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, 'minute is later');
16 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, 'minute is earlier');
17 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, 'second is later');
18 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, 'second is earlier');
19 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), true, 'millisecond match');
20 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, 'millisecond is later');
21 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, 'millisecond is earlier');
22 assert.equal(m.isSame(m), true, 'moments are the same as themselves');
23 assert.equal(+m, +mCopy, 'isSame second should not change moment');
24 });
25
26 test('is same year', function (assert) {
27 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
28 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year match');
29 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');
30 assert.equal(m.isSame(moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year mismatch');
31 assert.equal(m.isSame(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), true, 'exact start of year');
32 assert.equal(m.isSame(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), true, 'exact end of year');
33 assert.equal(m.isSame(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), false, 'start of next year');
34 assert.equal(m.isSame(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of previous year');
35 assert.equal(m.isSame(m, 'year'), true, 'same moments are in the same year');
36 assert.equal(+m, +mCopy, 'isSame year should not change moment');
37 });
38
39 test('is same month', function (assert) {
40 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);
41 assert.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), true, 'month match');
42 assert.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');
43 assert.equal(m.isSame(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year mismatch');
44 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), false, 'month mismatch');
45 assert.equal(m.isSame(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), true, 'exact start of month');
46 assert.equal(m.isSame(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), true, 'exact end of month');
47 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), false, 'start of next month');
48 assert.equal(m.isSame(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), false, 'end of previous month');
49 assert.equal(m.isSame(m, 'month'), true, 'same moments are in the same month');
50 assert.equal(+m, +mCopy, 'isSame month should not change moment');
51 });
52
53 test('is same day', function (assert) {
54 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
55 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), true, 'day match');
56 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');
57 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 7, 8, 9, 10)), 'day'), false, 'year mismatch');
58 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), false, 'month mismatch');
59 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day'), false, 'day mismatch');
60 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 0, 0, 0, 0)), 'day'), true, 'exact start of day');
61 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 23, 59, 59, 999)), 'day'), true, 'exact end of day');
62 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 0, 0, 0, 0)), 'day'), false, 'start of next day');
63 assert.equal(m.isSame(moment(new Date(2011, 1, 1, 23, 59, 59, 999)), 'day'), false, 'end of previous day');
64 assert.equal(m.isSame(m, 'day'), true, 'same moments are in the same day');
65 assert.equal(+m, +mCopy, 'isSame day should not change moment');
66 });
67
68 test('is same hour', function (assert) {
69 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
70 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), true, 'hour match');
71 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');
72 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 8, 9, 10)), 'hour'), false, 'year mismatch');
73 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 8, 9, 10)), 'hour'), false, 'month mismatch');
74 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 8, 9, 10)), 'hour'), false, 'day mismatch');
75 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 8, 9, 10)), 'hour'), false, 'hour mismatch');
76 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 0, 0, 0)), 'hour'), true, 'exact start of hour');
77 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 59, 59, 999)), 'hour'), true, 'exact end of hour');
78 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour'), false, 'start of next hour');
79 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 2, 59, 59, 999)), 'hour'), false, 'end of previous hour');
80 assert.equal(m.isSame(m, 'hour'), true, 'same moments are in the same hour');
81 assert.equal(+m, +mCopy, 'isSame hour should not change moment');
82 });
83
84 test('is same minute', function (assert) {
85 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
86 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute'), true, 'minute match');
87 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');
88 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 9, 10)), 'minute'), false, 'year mismatch');
89 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), false, 'month mismatch');
90 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 9, 10)), 'minute'), false, 'day mismatch');
91 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 9, 10)), 'minute'), false, 'hour mismatch');
92 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minute'), false, 'minute mismatch');
93 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 0, 0)), 'minute'), true, 'exact start of minute');
94 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 59, 999)), 'minute'), true, 'exact end of minute');
95 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute'), false, 'start of next minute');
96 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute'), false, 'end of previous minute');
97 assert.equal(m.isSame(m, 'minute'), true, 'same moments are in the same minute');
98 assert.equal(+m, +mCopy, 'isSame minute should not change moment');
99 });
100
101 test('is same second', function (assert) {
102 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
103 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second'), true, 'second match');
104 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');
105 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 5, 10)), 'second'), false, 'year mismatch');
106 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), false, 'month mismatch');
107 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 5, 10)), 'second'), false, 'day mismatch');
108 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 5, 10)), 'second'), false, 'hour mismatch');
109 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 5, 10)), 'second'), false, 'minute mismatch');
110 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 10)), 'second'), false, 'second mismatch');
111 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 0)), 'second'), true, 'exact start of second');
112 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 999)), 'second'), true, 'exact end of second');
113 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second'), false, 'start of next second');
114 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second'), false, 'end of previous second');
115 assert.equal(m.isSame(m, 'second'), true, 'same moments are in the same second');
116 assert.equal(+m, +mCopy, 'isSame second should not change moment');
117 });
118
119 test('is same millisecond', function (assert) {
120 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
121 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'millisecond match');
122 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'plural should work');
123 assert.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is later');
124 assert.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is earlier');
125 assert.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is later');
126 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is earlier');
127 assert.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), false, 'day is later');
128 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), false, 'day is earlier');
129 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), false, 'hour is later');
130 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), false, 'hour is earlier');
131 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), false, 'minute is later');
132 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), false, 'minute is earlier');
133 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), false, 'second is later');
134 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), false, 'second is earlier');
135 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), false, 'millisecond is later');
136 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), false, 'millisecond is earlier');
137 assert.equal(m.isSame(m, 'millisecond'), true, 'same moments are in the same millisecond');
138 assert.equal(+m, +mCopy, 'isSame millisecond should not change moment');
139 });
140
141 test('is same with utc offset moments', function (assert) {
142 assert.ok(moment.parseZone('2013-02-01T-05:00').isSame(moment('2013-02-01'), 'year'), 'zoned vs local moment');
143 assert.ok(moment('2013-02-01').isSame(moment('2013-02-01').utcOffset('-05:00'), 'year'), 'local vs zoned moment');
144 assert.ok(moment.parseZone('2013-02-01T-05:00').isSame(moment.parseZone('2013-02-01T-06:30'), 'year'),
145 'zoned vs (differently) zoned moment');
146 });
147
148 test('is same with invalid moments', function (assert) {
149 assert.equal(moment.invalid().isSame(moment.invalid()), false, 'invalid moments are not considered equal');
150 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('is valid');
4
5 test('array bad month', function (assert) {
6 assert.equal(moment([2010, -1]).isValid(), false, 'month -1 invalid');
7 assert.equal(moment([2100, 12]).isValid(), false, 'month 12 invalid');
8 });
9
10 test('array good month', function (assert) {
11 for (var i = 0; i < 12; i++) {
12 assert.equal(moment([2010, i]).isValid(), true, 'month ' + i);
13 assert.equal(moment.utc([2010, i]).isValid(), true, 'month ' + i);
14 }
15 });
16
17 test('array bad date', function (assert) {
18 var tests = [
19 moment([2010, 0, 0]),
20 moment([2100, 0, 32]),
21 moment.utc([2010, 0, 0]),
22 moment.utc([2100, 0, 32])
23 ],
24 i, m;
25
26 for (i in tests) {
27 m = tests[i];
28 assert.equal(m.isValid(), false);
29 }
30 });
31
32 test('h/hh with hour > 12', function (assert) {
33 assert.ok(moment('06/20/2014 11:51 PM', 'MM/DD/YYYY hh:mm A', true).isValid(), '11 for hh');
34 assert.ok(moment('06/20/2014 11:51 AM', 'MM/DD/YYYY hh:mm A', true).isValid(), '11 for hh');
35 assert.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A').isValid(), 'non-strict validity 23 for hh');
36 assert.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A').parsingFlags().bigHour, 'non-strict bigHour 23 for hh');
37 assert.ok(!moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A', true).isValid(), 'validity 23 for hh');
38 assert.ok(moment('06/20/2014 23:51 PM', 'MM/DD/YYYY hh:mm A', true).parsingFlags().bigHour, 'bigHour 23 for hh');
39 });
40
41 test('array bad date leap year', function (assert) {
42 assert.equal(moment([2010, 1, 29]).isValid(), false, '2010 feb 29');
43 assert.equal(moment([2100, 1, 29]).isValid(), false, '2100 feb 29');
44 assert.equal(moment([2008, 1, 30]).isValid(), false, '2008 feb 30');
45 assert.equal(moment([2000, 1, 30]).isValid(), false, '2000 feb 30');
46
47 assert.equal(moment.utc([2010, 1, 29]).isValid(), false, 'utc 2010 feb 29');
48 assert.equal(moment.utc([2100, 1, 29]).isValid(), false, 'utc 2100 feb 29');
49 assert.equal(moment.utc([2008, 1, 30]).isValid(), false, 'utc 2008 feb 30');
50 assert.equal(moment.utc([2000, 1, 30]).isValid(), false, 'utc 2000 feb 30');
51 });
52
53 test('string + formats bad date', function (assert) {
54 assert.equal(moment('2020-00-00', []).isValid(), false, 'invalid on empty array');
55 assert.equal(moment('2020-00-00', ['YYYY-MM-DD', 'DD-MM-YYYY']).isValid(), false, 'invalid on all in array');
56 assert.equal(moment('2020-00-00', ['DD-MM-YYYY', 'YYYY-MM-DD']).isValid(), false, 'invalid on all in array');
57 assert.equal(moment('2020-01-01', ['YYYY-MM-DD', 'DD-MM-YYYY']).isValid(), true, 'valid on first');
58 assert.equal(moment('2020-01-01', ['DD-MM-YYYY', 'YYYY-MM-DD']).isValid(), true, 'valid on last');
59 assert.equal(moment('2020-01-01', ['YYYY-MM-DD', 'YYYY-DD-MM']).isValid(), true, 'valid on both');
60 assert.equal(moment('2020-13-01', ['YYYY-MM-DD', 'YYYY-DD-MM']).isValid(), true, 'valid on last');
61
62 assert.equal(moment('12-13-2012', ['DD-MM-YYYY', 'YYYY-MM-DD']).isValid(), false, 'month rollover');
63 assert.equal(moment('12-13-2012', ['DD-MM-YYYY', 'DD-MM-YYYY']).isValid(), false, 'month rollover');
64 assert.equal(moment('38-12-2012', ['DD-MM-YYYY']).isValid(), false, 'day rollover');
65 });
66
67 test('string nonsensical with format', function (assert) {
68 assert.equal(moment('fail', 'MM-DD-YYYY').isValid(), false, 'string \'fail\' with format \'MM-DD-YYYY\'');
69 assert.equal(moment('xx-xx-2001', 'DD-MM-YYY').isValid(), true, 'string \'xx-xx-2001\' with format \'MM-DD-YYYY\'');
70 });
71
72 test('string with bad month name', function (assert) {
73 assert.equal(moment('01-Nam-2012', 'DD-MMM-YYYY').isValid(), false, '\'Nam\' is an invalid month');
74 assert.equal(moment('01-Aug-2012', 'DD-MMM-YYYY').isValid(), true, '\'Aug\' is a valid month');
75 });
76
77 test('string with spaceless format', function (assert) {
78 assert.equal(moment('10Sep2001', 'DDMMMYYYY').isValid(), true, 'Parsing 10Sep2001 should result in a valid date');
79 });
80
81 test('invalid string iso 8601', function (assert) {
82 var tests = [
83 '2010-00-00',
84 '2010-01-00',
85 '2010-01-40',
86 '2010-01-01T24:01', // 24:00:00 is actually valid
87 '2010-01-01T23:60',
88 '2010-01-01T23:59:60'
89 ], i;
90
91 for (i = 0; i < tests.length; i++) {
92 assert.equal(moment(tests[i]).isValid(), false, tests[i] + ' should be invalid');
93 assert.equal(moment.utc(tests[i]).isValid(), false, tests[i] + ' should be invalid');
94 }
95 });
96
97 test('invalid string iso 8601 + timezone', function (assert) {
98 var tests = [
99 '2010-00-00T+00:00',
100 '2010-01-00T+00:00',
101 '2010-01-40T+00:00',
102 '2010-01-40T24:01+00:00',
103 '2010-01-40T23:60+00:00',
104 '2010-01-40T23:59:60+00:00',
105 '2010-01-40T23:59:59.9999+00:00'
106 ], i;
107
108 for (i = 0; i < tests.length; i++) {
109 assert.equal(moment(tests[i]).isValid(), false, tests[i] + ' should be invalid');
110 assert.equal(moment.utc(tests[i]).isValid(), false, tests[i] + ' should be invalid');
111 }
112 });
113
114 test('valid string iso 8601 + timezone', function (assert) {
115 var tests = [
116 '2010-01-01',
117 '2010-01-30',
118 '2010-01-30T23+00:00',
119 '2010-01-30T23:59+00:00',
120 '2010-01-30T23:59:59+00:00',
121 '2010-01-30T23:59:59.999+00:00',
122 '2010-01-30T23:59:59.999-07:00',
123 '2010-01-30T00:00:00.000+07:00',
124 '2010-01-30 00:00:00.000Z'
125 ], i;
126
127 for (i = 0; i < tests.length; i++) {
128 assert.equal(moment(tests[i]).isValid(), true, tests[i] + ' should be valid in normal');
129 assert.equal(moment.utc(tests[i]).isValid(), true, tests[i] + ' should be valid in normal');
130 assert.equal(moment(tests[i], moment.ISO_8601, true).isValid(), true, tests[i] + ' should be valid in strict');
131 assert.equal(moment.utc(tests[i], moment.ISO_8601, true).isValid(), true, tests[i] + ' should be valid in strict');
132 }
133 });
134
135 test('invalidAt', function (assert) {
136 assert.equal(moment([2000, 12]).invalidAt(), 1, 'month 12 is invalid: 0-11');
137 assert.equal(moment([2000, 1, 30]).invalidAt(), 2, '30 is not a valid february day');
138 assert.equal(moment([2000, 1, 29, 25]).invalidAt(), 3, '25 is invalid hour');
139 assert.equal(moment([2000, 1, 29, 24, 1]).invalidAt(), 3, '24:01 is invalid hour');
140 assert.equal(moment([2000, 1, 29, 23, 60]).invalidAt(), 4, '60 is invalid minute');
141 assert.equal(moment([2000, 1, 29, 23, 59, 60]).invalidAt(), 5, '60 is invalid second');
142 assert.equal(moment([2000, 1, 29, 23, 59, 59, 1000]).invalidAt(), 6, '1000 is invalid millisecond');
143 assert.equal(moment([2000, 1, 29, 23, 59, 59, 999]).invalidAt(), -1, '-1 if everything is fine');
144 });
145
146 test('valid Unix timestamp', function (assert) {
147 assert.equal(moment(1371065286, 'X').isValid(), true, 'number integer');
148 assert.equal(moment(1379066897.0, 'X').isValid(), true, 'number whole 1dp');
149 assert.equal(moment(1379066897.7, 'X').isValid(), true, 'number 1dp');
150 assert.equal(moment(1379066897.00, 'X').isValid(), true, 'number whole 2dp');
151 assert.equal(moment(1379066897.07, 'X').isValid(), true, 'number 2dp');
152 assert.equal(moment(1379066897.17, 'X').isValid(), true, 'number 2dp');
153 assert.equal(moment(1379066897.000, 'X').isValid(), true, 'number whole 3dp');
154 assert.equal(moment(1379066897.007, 'X').isValid(), true, 'number 3dp');
155 assert.equal(moment(1379066897.017, 'X').isValid(), true, 'number 3dp');
156 assert.equal(moment(1379066897.157, 'X').isValid(), true, 'number 3dp');
157 assert.equal(moment('1371065286', 'X').isValid(), true, 'string integer');
158 assert.equal(moment('1379066897.', 'X').isValid(), true, 'string trailing .');
159 assert.equal(moment('1379066897.0', 'X').isValid(), true, 'string whole 1dp');
160 assert.equal(moment('1379066897.7', 'X').isValid(), true, 'string 1dp');
161 assert.equal(moment('1379066897.00', 'X').isValid(), true, 'string whole 2dp');
162 assert.equal(moment('1379066897.07', 'X').isValid(), true, 'string 2dp');
163 assert.equal(moment('1379066897.17', 'X').isValid(), true, 'string 2dp');
164 assert.equal(moment('1379066897.000', 'X').isValid(), true, 'string whole 3dp');
165 assert.equal(moment('1379066897.007', 'X').isValid(), true, 'string 3dp');
166 assert.equal(moment('1379066897.017', 'X').isValid(), true, 'string 3dp');
167 assert.equal(moment('1379066897.157', 'X').isValid(), true, 'string 3dp');
168 });
169
170 test('invalid Unix timestamp', function (assert) {
171 assert.equal(moment(undefined, 'X').isValid(), false, 'undefined');
172 assert.equal(moment('undefined', 'X').isValid(), false, 'string undefined');
173 try {
174 assert.equal(moment(null, 'X').isValid(), false, 'null');
175 } catch (e) {
176 assert.ok(true, 'null');
177 }
178
179 assert.equal(moment('null', 'X').isValid(), false, 'string null');
180 assert.equal(moment([], 'X').isValid(), false, 'array');
181 assert.equal(moment('{}', 'X').isValid(), false, 'object');
182 try {
183 assert.equal(moment('', 'X').isValid(), false, 'string empty');
184 } catch (e) {
185 assert.ok(true, 'string empty');
186 }
187
188 assert.equal(moment(' ', 'X').isValid(), false, 'string space');
189 });
190
191 test('valid Unix offset milliseconds', function (assert) {
192 assert.equal(moment(1234567890123, 'x').isValid(), true, 'number integer');
193 assert.equal(moment('1234567890123', 'x').isValid(), true, 'string integer');
194 });
195
196 test('invalid Unix offset milliseconds', function (assert) {
197 assert.equal(moment(undefined, 'x').isValid(), false, 'undefined');
198 assert.equal(moment('undefined', 'x').isValid(), false, 'string undefined');
199 try {
200 assert.equal(moment(null, 'x').isValid(), false, 'null');
201 } catch (e) {
202 assert.ok(true, 'null');
203 }
204
205 assert.equal(moment('null', 'x').isValid(), false, 'string null');
206 assert.equal(moment([], 'x').isValid(), false, 'array');
207 assert.equal(moment('{}', 'x').isValid(), false, 'object');
208 try {
209 assert.equal(moment('', 'x').isValid(), false, 'string empty');
210 } catch (e) {
211 assert.ok(true, 'string empty');
212 }
213
214 assert.equal(moment(' ', 'x').isValid(), false, 'string space');
215 });
216
217 test('empty', function (assert) {
218 assert.equal(moment(null).isValid(), false, 'null');
219 assert.equal(moment('').isValid(), false, 'empty string');
220 assert.equal(moment(null, 'YYYY').isValid(), false, 'format + null');
221 assert.equal(moment('', 'YYYY').isValid(), false, 'format + empty string');
222 assert.equal(moment(' ', 'YYYY').isValid(), false, 'format + empty when trimmed');
223 });
224
225 test('days of the year', function (assert) {
226 assert.equal(moment('2010 300', 'YYYY DDDD').isValid(), true, 'day 300 of year valid');
227 assert.equal(moment('2010 365', 'YYYY DDDD').isValid(), true, 'day 365 of year valid');
228 assert.equal(moment('2010 366', 'YYYY DDDD').isValid(), false, 'day 366 of year invalid');
229 assert.equal(moment('2012 365', 'YYYY DDDD').isValid(), true, 'day 365 of leap year valid');
230 assert.equal(moment('2012 366', 'YYYY DDDD').isValid(), true, 'day 366 of leap year valid');
231 assert.equal(moment('2012 367', 'YYYY DDDD').isValid(), false, 'day 367 of leap year invalid');
232 });
233
234 test('24:00:00.000 is valid', function (assert) {
235 assert.equal(moment('2014-01-01 24', 'YYYY-MM-DD HH').isValid(), true, '24 is valid');
236 assert.equal(moment('2014-01-01 24:00', 'YYYY-MM-DD HH:mm').isValid(), true, '24:00 is valid');
237 assert.equal(moment('2014-01-01 24:01', 'YYYY-MM-DD HH:mm').isValid(), false, '24:01 is not valid');
238 });
239
240 test('oddball permissiveness', function (assert) {
241 //https://github.com/moment/moment/issues/1128
242 assert.ok(moment('2010-10-3199', ['MM/DD/YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']).isValid());
243
244 //https://github.com/moment/moment/issues/1122
245 assert.ok(moment('3:25', ['h:mma', 'hh:mma', 'H:mm', 'HH:mm']).isValid());
246 });
247
248 test('0 hour is invalid in strict', function (assert) {
249 assert.equal(moment('00:01', 'hh:mm', true).isValid(), false, '00 hour is invalid in strict');
250 assert.equal(moment('00:01', 'hh:mm').isValid(), true, '00 hour is valid in normal');
251 assert.equal(moment('0:01', 'h:mm', true).isValid(), false, '0 hour is invalid in strict');
252 assert.equal(moment('0:01', 'h:mm').isValid(), true, '0 hour is valid in normal');
253 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('leap year');
4
5 test('leap year', function (assert) {
6 assert.equal(moment([2010, 0, 1]).isLeapYear(), false, '2010');
7 assert.equal(moment([2100, 0, 1]).isLeapYear(), false, '2100');
8 assert.equal(moment([2008, 0, 1]).isLeapYear(), true, '2008');
9 assert.equal(moment([2000, 0, 1]).isLeapYear(), true, '2000');
10 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('listers');
4
5 test('default', function (assert) {
6 assert.deepEqual(moment.months(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
7 assert.deepEqual(moment.monthsShort(), ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
8 assert.deepEqual(moment.weekdays(), ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']);
9 assert.deepEqual(moment.weekdaysShort(), ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
10 assert.deepEqual(moment.weekdaysMin(), ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']);
11 });
12
13 test('index', function (assert) {
14 assert.equal(moment.months(0), 'January');
15 assert.equal(moment.months(2), 'March');
16 assert.equal(moment.monthsShort(0), 'Jan');
17 assert.equal(moment.monthsShort(2), 'Mar');
18 assert.equal(moment.weekdays(0), 'Sunday');
19 assert.equal(moment.weekdays(2), 'Tuesday');
20 assert.equal(moment.weekdaysShort(0), 'Sun');
21 assert.equal(moment.weekdaysShort(2), 'Tue');
22 assert.equal(moment.weekdaysMin(0), 'Su');
23 assert.equal(moment.weekdaysMin(2), 'Tu');
24 });
25
26 test('localized', function (assert) {
27 var months = 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_'),
28 monthsShort = 'on_tw_th_fo_fi_si_se_ei_ni_te_el_tw'.split('_'),
29 weekdays = 'one_two_three_four_five_six_seven'.split('_'),
30 weekdaysShort = 'on_tw_th_fo_fi_si_se'.split('_'),
31 weekdaysMin = '1_2_3_4_5_6_7'.split('_');
32
33 moment.locale('numerologists', {
34 months : months,
35 monthsShort : monthsShort,
36 weekdays : weekdays,
37 weekdaysShort: weekdaysShort,
38 weekdaysMin: weekdaysMin
39 });
40
41 assert.deepEqual(moment.months(), months);
42 assert.deepEqual(moment.monthsShort(), monthsShort);
43 assert.deepEqual(moment.weekdays(), weekdays);
44 assert.deepEqual(moment.weekdaysShort(), weekdaysShort);
45 assert.deepEqual(moment.weekdaysMin(), weekdaysMin);
46
47 assert.equal(moment.months(0), 'one');
48 assert.equal(moment.monthsShort(0), 'on');
49 assert.equal(moment.weekdays(0), 'one');
50 assert.equal(moment.weekdaysShort(0), 'on');
51 assert.equal(moment.weekdaysMin(0), '1');
52
53 assert.equal(moment.months(2), 'three');
54 assert.equal(moment.monthsShort(2), 'th');
55 assert.equal(moment.weekdays(2), 'three');
56 assert.equal(moment.weekdaysShort(2), 'th');
57 assert.equal(moment.weekdaysMin(2), '3');
58 });
59
60 test('with functions', function (assert) {
61 var monthsShort = 'one_two_three_four_five_six_seven_eight_nine_ten_eleven_twelve'.split('_'),
62 monthsShortWeird = 'onesy_twosy_threesy_foursy_fivesy_sixsy_sevensy_eightsy_ninesy_tensy_elevensy_twelvesy'.split('_');
63
64 moment.locale('difficult', {
65
66 monthsShort: function (m, format) {
67 var arr = format.match(/-MMM-/) ? monthsShortWeird : monthsShort;
68 return arr[m.month()];
69 }
70 });
71
72 assert.deepEqual(moment.monthsShort(), monthsShort);
73 assert.deepEqual(moment.monthsShort('MMM'), monthsShort);
74 assert.deepEqual(moment.monthsShort('-MMM-'), monthsShortWeird);
75
76 assert.deepEqual(moment.monthsShort('MMM', 2), 'three');
77 assert.deepEqual(moment.monthsShort('-MMM-', 2), 'threesy');
78 assert.deepEqual(moment.monthsShort(2), 'three');
79 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2 import each from '../helpers/each';
3
4 module('locale', {
5 setup : function () {
6 // TODO: Remove once locales are switched to ES6
7 each([{
8 name: 'en-gb',
9 data: {}
10 }, {
11 name: 'en-ca',
12 data: {}
13 }, {
14 name: 'es',
15 data: {
16 relativeTime: {past: 'hace %s', s: 'unos segundos', d: 'un día'},
17 months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_')
18 }
19 }, {
20 name: 'fr',
21 data: {}
22 }, {
23 name: 'fr-ca',
24 data: {}
25 }, {
26 name: 'it',
27 data: {}
28 }, {
29 name: 'zh-cn',
30 data: {
31 months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_')
32 }
33 }], function (locale) {
34 if (moment.locale(locale.name) !== locale.name) {
35 moment.defineLocale(locale.name, locale.data);
36 }
37 });
38 moment.locale('en');
39 }
40 });
41
42 test('library getters and setters', function (assert) {
43 var r = moment.locale('en');
44
45 assert.equal(r, 'en', 'locale should return en by default');
46 assert.equal(moment.locale(), 'en', 'locale should return en by default');
47
48 moment.locale('fr');
49 assert.equal(moment.locale(), 'fr', 'locale should return the changed locale');
50
51 moment.locale('en-gb');
52 assert.equal(moment.locale(), 'en-gb', 'locale should return the changed locale');
53
54 moment.locale('en');
55 assert.equal(moment.locale(), 'en', 'locale should reset');
56
57 moment.locale('does-not-exist');
58 assert.equal(moment.locale(), 'en', 'locale should reset');
59
60 moment.locale('EN');
61 assert.equal(moment.locale(), 'en', 'Normalize locale key case');
62
63 moment.locale('EN_gb');
64 assert.equal(moment.locale(), 'en-gb', 'Normalize locale key underscore');
65 });
66
67 test('library setter array of locales', function (assert) {
68 assert.equal(moment.locale(['non-existent', 'fr', 'also-non-existent']), 'fr', 'passing an array uses the first valid locale');
69 assert.equal(moment.locale(['es', 'fr', 'also-non-existent']), 'es', 'passing an array uses the first valid locale');
70 });
71
72 test('library setter locale substrings', function (assert) {
73 assert.equal(moment.locale('fr-crap'), 'fr', 'use substrings');
74 assert.equal(moment.locale('fr-does-not-exist'), 'fr', 'uses deep substrings');
75 assert.equal(moment.locale('fr-CA-does-not-exist'), 'fr-ca', 'uses deepest substring');
76 });
77
78 test('library getter locale array and substrings', function (assert) {
79 assert.equal(moment.locale(['en-CH', 'fr']), 'en', 'prefer root locale to shallower ones');
80 assert.equal(moment.locale(['en-gb-leeds', 'en-CA']), 'en-gb', 'prefer root locale to shallower ones');
81 assert.equal(moment.locale(['en-fake', 'en-CA']), 'en-ca', 'prefer alternatives with shared roots');
82 assert.equal(moment.locale(['en-fake', 'en-fake2', 'en-ca']), 'en-ca', 'prefer alternatives with shared roots');
83 assert.equal(moment.locale(['fake-CA', 'fake-MX', 'fr']), 'fr', 'always find something if possible');
84 assert.equal(moment.locale(['fake-CA', 'fake-MX', 'fr']), 'fr', 'always find something if possible');
85 assert.equal(moment.locale(['fake-CA', 'fake-MX', 'fr-fake-fake-fake']), 'fr', 'always find something if possible');
86 assert.equal(moment.locale(['en', 'en-CA']), 'en', 'prefer earlier if it works');
87 });
88
89 test('library ensure inheritance', function (assert) {
90 moment.locale('made-up', {
91 // I put them out of order
92 months : 'February_March_April_May_June_July_August_September_October_November_December_January'.split('_')
93 // the rest of the properties should be inherited.
94 });
95
96 assert.equal(moment([2012, 5, 6]).format('MMMM'), 'July', 'Override some of the configs');
97 assert.equal(moment([2012, 5, 6]).format('MMM'), 'Jun', 'But not all of them');
98 });
99
100 test('library ensure inheritance LT L LL LLL LLLL', function (assert) {
101 var locale = 'test-inherit-lt';
102
103 moment.defineLocale(locale, {
104 longDateFormat : {
105 LT : '-[LT]-',
106 L : '-[L]-',
107 LL : '-[LL]-',
108 LLL : '-[LLL]-',
109 LLLL : '-[LLLL]-'
110 },
111 calendar : {
112 sameDay : '[sameDay] LT',
113 nextDay : '[nextDay] L',
114 nextWeek : '[nextWeek] LL',
115 lastDay : '[lastDay] LLL',
116 lastWeek : '[lastWeek] LLLL',
117 sameElse : 'L'
118 }
119 });
120
121 moment.locale('es');
122
123 assert.equal(moment().locale(locale).calendar(), 'sameDay -LT-', 'Should use instance locale in LT formatting');
124 assert.equal(moment().add(1, 'days').locale(locale).calendar(), 'nextDay -L-', 'Should use instance locale in L formatting');
125 assert.equal(moment().add(-1, 'days').locale(locale).calendar(), 'lastDay -LLL-', 'Should use instance locale in LL formatting');
126 assert.equal(moment().add(4, 'days').locale(locale).calendar(), 'nextWeek -LL-', 'Should use instance locale in LLL formatting');
127 assert.equal(moment().add(-4, 'days').locale(locale).calendar(), 'lastWeek -LLLL-', 'Should use instance locale in LLLL formatting');
128 });
129
130 test('library localeData', function (assert) {
131 moment.locale('en');
132
133 var jan = moment([2000, 0]);
134
135 assert.equal(moment.localeData().months(jan), 'January', 'no arguments returns global');
136 assert.equal(moment.localeData('zh-cn').months(jan), '一月', 'a string returns the locale based on key');
137 assert.equal(moment.localeData(moment().locale('es')).months(jan), 'Enero', 'if you pass in a moment it uses the moment\'s locale');
138 });
139
140 test('library deprecations', function (assert) {
141 moment.lang('dude', {months: ['Movember']});
142 assert.equal(moment.locale(), 'dude', 'setting the lang sets the locale');
143 assert.equal(moment.lang(), moment.locale());
144 assert.equal(moment.langData(), moment.localeData(), 'langData is localeData');
145 });
146
147 test('defineLocale', function (assert) {
148 moment.locale('en');
149 moment.defineLocale('dude', {months: ['Movember']});
150 assert.equal(moment().locale(), 'dude', 'defineLocale also sets it');
151 assert.equal(moment().locale('dude').locale(), 'dude', 'defineLocale defines a locale');
152 });
153
154 test('library convenience', function (assert) {
155 moment.locale('something', {week: {dow: 3}});
156 moment.locale('something');
157 assert.equal(moment.locale(), 'something', 'locale can be used to create the locale too');
158 });
159
160 test('firstDayOfWeek firstDayOfYear locale getters', function (assert) {
161 moment.locale('something', {week: {dow: 3, doy: 4}});
162 moment.locale('something');
163 assert.equal(moment.localeData().firstDayOfWeek(), 3, 'firstDayOfWeek');
164 assert.equal(moment.localeData().firstDayOfYear(), 4, 'firstDayOfYear');
165 });
166
167 test('instance locale method', function (assert) {
168 moment.locale('en');
169
170 assert.equal(moment([2012, 5, 6]).format('MMMM'), 'June', 'Normally default to global');
171 assert.equal(moment([2012, 5, 6]).locale('es').format('MMMM'), 'Junio', 'Use the instance specific locale');
172 assert.equal(moment([2012, 5, 6]).format('MMMM'), 'June', 'Using an instance specific locale does not affect other moments');
173 });
174
175 test('instance locale method with array', function (assert) {
176 var m = moment().locale(['non-existent', 'fr', 'also-non-existent']);
177 assert.equal(m.locale(), 'fr', 'passing an array uses the first valid locale');
178 m = moment().locale(['es', 'fr', 'also-non-existent']);
179 assert.equal(m.locale(), 'es', 'passing an array uses the first valid locale');
180 });
181
182 test('instance getter locale substrings', function (assert) {
183 var m = moment();
184
185 m.locale('fr-crap');
186 assert.equal(m.locale(), 'fr', 'use substrings');
187
188 m.locale('fr-does-not-exist');
189 assert.equal(m.locale(), 'fr', 'uses deep substrings');
190 });
191
192 test('instance locale persists with manipulation', function (assert) {
193 moment.locale('en');
194
195 assert.equal(moment([2012, 5, 6]).locale('es').add({days: 1}).format('MMMM'), 'Junio', 'With addition');
196 assert.equal(moment([2012, 5, 6]).locale('es').day(0).format('MMMM'), 'Junio', 'With day getter');
197 assert.equal(moment([2012, 5, 6]).locale('es').endOf('day').format('MMMM'), 'Junio', 'With endOf');
198 });
199
200 test('instance locale persists with cloning', function (assert) {
201 moment.locale('en');
202
203 var a = moment([2012, 5, 6]).locale('es'),
204 b = a.clone(),
205 c = moment(a);
206
207 assert.equal(b.format('MMMM'), 'Junio', 'using moment.fn.clone()');
208 assert.equal(b.format('MMMM'), 'Junio', 'using moment()');
209 });
210
211 test('duration locale method', function (assert) {
212 moment.locale('en');
213
214 assert.equal(moment.duration({seconds: 44}).humanize(), 'a few seconds', 'Normally default to global');
215 assert.equal(moment.duration({seconds: 44}).locale('es').humanize(), 'unos segundos', 'Use the instance specific locale');
216 assert.equal(moment.duration({seconds: 44}).humanize(), 'a few seconds', 'Using an instance specific locale does not affect other durations');
217 });
218
219 test('duration locale persists with cloning', function (assert) {
220 moment.locale('en');
221
222 var a = moment.duration({seconds: 44}).locale('es'),
223 b = moment.duration(a);
224
225 assert.equal(b.humanize(), 'unos segundos', 'using moment.duration()');
226 });
227
228 test('changing the global locale doesn\'t affect existing duration instances', function (assert) {
229 var mom = moment.duration();
230 moment.locale('fr');
231 assert.equal('en', mom.locale());
232 });
233
234 test('duration deprecations', function (assert) {
235 assert.equal(moment.duration().lang(), moment.duration().localeData(), 'duration.lang is the same as duration.localeData');
236 });
237
238 test('from and fromNow with invalid date', function (assert) {
239 assert.equal(moment(NaN).from(), 'Invalid date', 'moment.from with invalid moment');
240 assert.equal(moment(NaN).fromNow(), 'Invalid date', 'moment.fromNow with invalid moment');
241 });
242
243 test('from relative time future', function (assert) {
244 var start = moment([2007, 1, 28]);
245
246 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 44})), 'in a few seconds', '44 seconds = a few seconds');
247 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 45})), 'in a minute', '45 seconds = a minute');
248 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 89})), 'in a minute', '89 seconds = a minute');
249 assert.equal(start.from(moment([2007, 1, 28]).subtract({s: 90})), 'in 2 minutes', '90 seconds = 2 minutes');
250 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 44})), 'in 44 minutes', '44 minutes = 44 minutes');
251 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 45})), 'in an hour', '45 minutes = an hour');
252 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 89})), 'in an hour', '89 minutes = an hour');
253 assert.equal(start.from(moment([2007, 1, 28]).subtract({m: 90})), 'in 2 hours', '90 minutes = 2 hours');
254 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 5})), 'in 5 hours', '5 hours = 5 hours');
255 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 21})), 'in 21 hours', '21 hours = 21 hours');
256 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 22})), 'in a day', '22 hours = a day');
257 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 35})), 'in a day', '35 hours = a day');
258 assert.equal(start.from(moment([2007, 1, 28]).subtract({h: 36})), 'in 2 days', '36 hours = 2 days');
259 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 1})), 'in a day', '1 day = a day');
260 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 5})), 'in 5 days', '5 days = 5 days');
261 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 25})), 'in 25 days', '25 days = 25 days');
262 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 26})), 'in a month', '26 days = a month');
263 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 30})), 'in a month', '30 days = a month');
264 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 45})), 'in a month', '45 days = a month');
265 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 47})), 'in 2 months', '47 days = 2 months');
266 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 74})), 'in 2 months', '74 days = 2 months');
267 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 78})), 'in 3 months', '78 days = 3 months');
268 assert.equal(start.from(moment([2007, 1, 28]).subtract({M: 1})), 'in a month', '1 month = a month');
269 assert.equal(start.from(moment([2007, 1, 28]).subtract({M: 5})), 'in 5 months', '5 months = 5 months');
270 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 315})), 'in 10 months', '315 days = 10 months');
271 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 344})), 'in a year', '344 days = a year');
272 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 345})), 'in a year', '345 days = a year');
273 assert.equal(start.from(moment([2007, 1, 28]).subtract({d: 548})), 'in 2 years', '548 days = in 2 years');
274 assert.equal(start.from(moment([2007, 1, 28]).subtract({y: 1})), 'in a year', '1 year = a year');
275 assert.equal(start.from(moment([2007, 1, 28]).subtract({y: 5})), 'in 5 years', '5 years = 5 years');
276 });
277
278 test('from relative time past', function (assert) {
279 var start = moment([2007, 1, 28]);
280
281 assert.equal(start.from(moment([2007, 1, 28]).add({s: 44})), 'a few seconds ago', '44 seconds = a few seconds');
282 assert.equal(start.from(moment([2007, 1, 28]).add({s: 45})), 'a minute ago', '45 seconds = a minute');
283 assert.equal(start.from(moment([2007, 1, 28]).add({s: 89})), 'a minute ago', '89 seconds = a minute');
284 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90})), '2 minutes ago', '90 seconds = 2 minutes');
285 assert.equal(start.from(moment([2007, 1, 28]).add({m: 44})), '44 minutes ago', '44 minutes = 44 minutes');
286 assert.equal(start.from(moment([2007, 1, 28]).add({m: 45})), 'an hour ago', '45 minutes = an hour');
287 assert.equal(start.from(moment([2007, 1, 28]).add({m: 89})), 'an hour ago', '89 minutes = an hour');
288 assert.equal(start.from(moment([2007, 1, 28]).add({m: 90})), '2 hours ago', '90 minutes = 2 hours');
289 assert.equal(start.from(moment([2007, 1, 28]).add({h: 5})), '5 hours ago', '5 hours = 5 hours');
290 assert.equal(start.from(moment([2007, 1, 28]).add({h: 21})), '21 hours ago', '21 hours = 21 hours');
291 assert.equal(start.from(moment([2007, 1, 28]).add({h: 22})), 'a day ago', '22 hours = a day');
292 assert.equal(start.from(moment([2007, 1, 28]).add({h: 35})), 'a day ago', '35 hours = a day');
293 assert.equal(start.from(moment([2007, 1, 28]).add({h: 36})), '2 days ago', '36 hours = 2 days');
294 assert.equal(start.from(moment([2007, 1, 28]).add({d: 1})), 'a day ago', '1 day = a day');
295 assert.equal(start.from(moment([2007, 1, 28]).add({d: 5})), '5 days ago', '5 days = 5 days');
296 assert.equal(start.from(moment([2007, 1, 28]).add({d: 25})), '25 days ago', '25 days = 25 days');
297 assert.equal(start.from(moment([2007, 1, 28]).add({d: 26})), 'a month ago', '26 days = a month');
298 assert.equal(start.from(moment([2007, 1, 28]).add({d: 30})), 'a month ago', '30 days = a month');
299 assert.equal(start.from(moment([2007, 1, 28]).add({d: 43})), 'a month ago', '43 days = a month');
300 assert.equal(start.from(moment([2007, 1, 28]).add({d: 46})), '2 months ago', '46 days = 2 months');
301 assert.equal(start.from(moment([2007, 1, 28]).add({d: 74})), '2 months ago', '75 days = 2 months');
302 assert.equal(start.from(moment([2007, 1, 28]).add({d: 76})), '3 months ago', '76 days = 3 months');
303 assert.equal(start.from(moment([2007, 1, 28]).add({M: 1})), 'a month ago', '1 month = a month');
304 assert.equal(start.from(moment([2007, 1, 28]).add({M: 5})), '5 months ago', '5 months = 5 months');
305 assert.equal(start.from(moment([2007, 1, 28]).add({d: 315})), '10 months ago', '315 days = 10 months');
306 assert.equal(start.from(moment([2007, 1, 28]).add({d: 344})), 'a year ago', '344 days = a year');
307 assert.equal(start.from(moment([2007, 1, 28]).add({d: 345})), 'a year ago', '345 days = a year');
308 assert.equal(start.from(moment([2007, 1, 28]).add({d: 548})), '2 years ago', '548 days = 2 years');
309 assert.equal(start.from(moment([2007, 1, 28]).add({y: 1})), 'a year ago', '1 year = a year');
310 assert.equal(start.from(moment([2007, 1, 28]).add({y: 5})), '5 years ago', '5 years = 5 years');
311 });
312
313 test('instance locale used with from', function (assert) {
314 moment.locale('en');
315
316 var a = moment([2012, 5, 6]).locale('es'),
317 b = moment([2012, 5, 7]);
318
319 assert.equal(a.from(b), 'hace un día', 'preserve locale of first moment');
320 assert.equal(b.from(a), 'in a day', 'do not preserve locale of second moment');
321 });
322
323 test('instance localeData', function (assert) {
324 moment.defineLocale('dude', {week: {dow: 3}});
325 assert.equal(moment().locale('dude').localeData()._week.dow, 3);
326 });
327
328 test('month name callback function', function (assert) {
329 function fakeReplace(m, format) {
330 if (/test/.test(format)) {
331 return 'test';
332 }
333 if (m.date() === 1) {
334 return 'date';
335 }
336 return 'default';
337 }
338
339 moment.locale('made-up-2', {
340 months : fakeReplace,
341 monthsShort : fakeReplace,
342 weekdays : fakeReplace,
343 weekdaysShort : fakeReplace,
344 weekdaysMin : fakeReplace
345 });
346
347 assert.equal(moment().format('[test] dd ddd dddd MMM MMMM'), 'test test test test test test', 'format month name function should be able to access the format string');
348 assert.equal(moment([2011, 0, 1]).format('dd ddd dddd MMM MMMM'), 'date date date date date', 'format month name function should be able to access the moment object');
349 assert.equal(moment([2011, 0, 2]).format('dd ddd dddd MMM MMMM'), 'default default default default default', 'format month name function should be able to access the moment object');
350 });
351
352 test('changing parts of a locale config', function (assert) {
353 moment.locale('partial-lang', {
354 months : 'a b c d e f g h i j k l'.split(' ')
355 });
356
357 assert.equal(moment([2011, 0, 1]).format('MMMM'), 'a', 'should be able to set locale values when creating the localeuage');
358
359 moment.locale('partial-lang', {
360 monthsShort : 'A B C D E F G H I J K L'.split(' ')
361 });
362
363 assert.equal(moment([2011, 0, 1]).format('MMMM MMM'), 'a A', 'should be able to set locale values after creating the localeuage');
364 });
365
366 test('start/endOf week feature for first-day-is-monday locales', function (assert) {
367 moment.locale('monday-lang', {
368 week : {
369 dow : 1 // Monday is the first day of the week
370 }
371 });
372
373 moment.locale('monday-lang');
374 assert.equal(moment([2013, 0, 1]).startOf('week').day(), 1, 'for locale monday-lang first day of the week should be monday');
375 assert.equal(moment([2013, 0, 1]).endOf('week').day(), 0, 'for locale monday-lang last day of the week should be sunday');
376 });
377
378 test('meridiem parsing', function (assert) {
379 moment.locale('meridiem-parsing', {
380 meridiemParse : /[bd]/i,
381 isPM : function (input) {
382 return input === 'b';
383 }
384 });
385
386 moment.locale('meridiem-parsing');
387 assert.equal(moment('2012-01-01 3b', 'YYYY-MM-DD ha').hour(), 15, 'Custom parsing of meridiem should work');
388 assert.equal(moment('2012-01-01 3d', 'YYYY-MM-DD ha').hour(), 3, 'Custom parsing of meridiem should work');
389 });
390
391 test('invalid date formatting', function (assert) {
392 moment.locale('has-invalid', {
393 invalidDate: 'KHAAAAAAAAAAAN!'
394 });
395
396 assert.equal(moment.invalid().format(), 'KHAAAAAAAAAAAN!');
397 assert.equal(moment.invalid().format('YYYY-MM-DD'), 'KHAAAAAAAAAAAN!');
398 });
399
400 test('return locale name', function (assert) {
401 var registered = moment.locale('return-this', {});
402
403 assert.equal(registered, 'return-this', 'returns the locale configured');
404 });
405
406 test('changing the global locale doesn\'t affect existing instances', function (assert) {
407 var mom = moment();
408 moment.locale('fr');
409 assert.equal('en', mom.locale());
410 });
411
412 test('setting a language on instance returns the original moment for chaining', function (assert) {
413 var mom = moment();
414
415 assert.equal(mom.lang('fr'), mom, 'setting the language (lang) returns the original moment for chaining');
416 assert.equal(mom.locale('it'), mom, 'setting the language (locale) returns the original moment for chaining');
417 });
418
419 test('lang(key) changes the language of the instance', function (assert) {
420 var m = moment().month(0);
421 m.lang('fr');
422 assert.equal(m.locale(), 'fr', 'm.lang(key) changes instance locale');
423 });
424
425 test('moment#locale(false) resets to global locale', function (assert) {
426 var m = moment();
427
428 moment.locale('fr');
429 m.locale('it');
430
431 assert.equal(moment.locale(), 'fr', 'global locale is it');
432 assert.equal(m.locale(), 'it', 'instance locale is it');
433 m.locale(false);
434 assert.equal(m.locale(), 'fr', 'instance locale reset to global locale');
435 });
436
437 test('moment().locale with missing key doesn\'t change locale', function (assert) {
438 assert.equal(moment().locale('boo').localeData(), moment.localeData(),
439 'preserve global locale in case of bad locale id');
440 });
441
442 test('moment().lang with missing key doesn\'t change locale', function (assert) {
443 assert.equal(moment().lang('boo').localeData(), moment.localeData(),
444 'preserve global locale in case of bad locale id');
445 });
446
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('min max');
4
5 test('min', function (assert) {
6 var now = moment(),
7 future = now.clone().add(1, 'month'),
8 past = now.clone().subtract(1, 'month'),
9 invalid = moment.invalid();
10
11 assert.equal(moment.min(now, future, past), past, 'min(now, future, past)');
12 assert.equal(moment.min(future, now, past), past, 'min(future, now, past)');
13 assert.equal(moment.min(future, past, now), past, 'min(future, past, now)');
14 assert.equal(moment.min(past, future, now), past, 'min(past, future, now)');
15 assert.equal(moment.min(now, past), past, 'min(now, past)');
16 assert.equal(moment.min(past, now), past, 'min(past, now)');
17 assert.equal(moment.min(now), now, 'min(now, past)');
18
19 assert.equal(moment.min([now, future, past]), past, 'min([now, future, past])');
20 assert.equal(moment.min([now, past]), past, 'min(now, past)');
21 assert.equal(moment.min([now]), now, 'min(now)');
22
23 assert.equal(moment.min([now, invalid]), invalid, 'min(now, invalid)');
24 assert.equal(moment.min([invalid, now]), invalid, 'min(invalid, now)');
25 });
26
27 test('max', function (assert) {
28 var now = moment(),
29 future = now.clone().add(1, 'month'),
30 past = now.clone().subtract(1, 'month'),
31 invalid = moment.invalid();
32
33 assert.equal(moment.max(now, future, past), future, 'max(now, future, past)');
34 assert.equal(moment.max(future, now, past), future, 'max(future, now, past)');
35 assert.equal(moment.max(future, past, now), future, 'max(future, past, now)');
36 assert.equal(moment.max(past, future, now), future, 'max(past, future, now)');
37 assert.equal(moment.max(now, past), now, 'max(now, past)');
38 assert.equal(moment.max(past, now), now, 'max(past, now)');
39 assert.equal(moment.max(now), now, 'max(now, past)');
40
41 assert.equal(moment.max([now, future, past]), future, 'max([now, future, past])');
42 assert.equal(moment.max([now, past]), now, 'max(now, past)');
43 assert.equal(moment.max([now]), now, 'max(now)');
44
45 assert.equal(moment.max([now, invalid]), invalid, 'max(now, invalid)');
46 assert.equal(moment.max([invalid, now]), invalid, 'max(invalid, now)');
47 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('mutable');
4
5 test('manipulation methods', function (assert) {
6 var m = moment();
7
8 assert.equal(m, m.year(2011), 'year() should be mutable');
9 assert.equal(m, m.month(1), 'month() should be mutable');
10 assert.equal(m, m.hours(7), 'hours() should be mutable');
11 assert.equal(m, m.minutes(33), 'minutes() should be mutable');
12 assert.equal(m, m.seconds(44), 'seconds() should be mutable');
13 assert.equal(m, m.milliseconds(55), 'milliseconds() should be mutable');
14 assert.equal(m, m.day(2), 'day() should be mutable');
15 assert.equal(m, m.startOf('week'), 'startOf() should be mutable');
16 assert.equal(m, m.add(1, 'days'), 'add() should be mutable');
17 assert.equal(m, m.subtract(2, 'years'), 'subtract() should be mutable');
18 assert.equal(m, m.local(), 'local() should be mutable');
19 assert.equal(m, m.utc(), 'utc() should be mutable');
20 });
21
22 test('non mutable methods', function (assert) {
23 var m = moment();
24 assert.notEqual(m, m.clone(), 'clone() should not be mutable');
25 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('normalize units');
4
5 test('normalize units', function (assert) {
6 var fullKeys = ['year', 'quarter', 'month', 'isoWeek', 'week', 'day', 'hour', 'minute', 'second', 'millisecond', 'date', 'dayOfYear', 'weekday', 'isoWeekday', 'weekYear', 'isoWeekYear'],
7 aliases = ['y', 'Q', 'M', 'W', 'w', 'd', 'h', 'm', 's', 'ms', 'D', 'DDD', 'e', 'E', 'gg', 'GG'],
8 length = fullKeys.length,
9 fullKey,
10 fullKeyCaps,
11 fullKeyPlural,
12 fullKeyCapsPlural,
13 fullKeyLower,
14 alias,
15 index;
16
17 for (index = 0; index < length; index += 1) {
18 fullKey = fullKeys[index];
19 fullKeyCaps = fullKey.toUpperCase();
20 fullKeyLower = fullKey.toLowerCase();
21 fullKeyPlural = fullKey + 's';
22 fullKeyCapsPlural = fullKeyCaps + 's';
23 alias = aliases[index];
24 assert.equal(moment.normalizeUnits(fullKey), fullKey, 'Testing full key ' + fullKey);
25 assert.equal(moment.normalizeUnits(fullKeyCaps), fullKey, 'Testing full key capitalised ' + fullKey);
26 assert.equal(moment.normalizeUnits(fullKeyPlural), fullKey, 'Testing full key plural ' + fullKey);
27 assert.equal(moment.normalizeUnits(fullKeyCapsPlural), fullKey, 'Testing full key capitalised and plural ' + fullKey);
28 assert.equal(moment.normalizeUnits(alias), fullKey, 'Testing alias ' + fullKey);
29 }
30 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('parsing flags');
4
5 function flags () {
6 return moment.apply(null, arguments).parsingFlags();
7 }
8
9 test('overflow with array', function (assert) {
10 //months
11 assert.equal(flags([2010, 0]).overflow, -1, 'month 0 valid');
12 assert.equal(flags([2010, 1]).overflow, -1, 'month 1 valid');
13 assert.equal(flags([2010, -1]).overflow, 1, 'month -1 invalid');
14 assert.equal(flags([2100, 12]).overflow, 1, 'month 12 invalid');
15
16 //days
17 assert.equal(flags([2010, 1, 16]).overflow, -1, 'date valid');
18 assert.equal(flags([2010, 1, -1]).overflow, 2, 'date -1 invalid');
19 assert.equal(flags([2010, 1, 0]).overflow, 2, 'date 0 invalid');
20 assert.equal(flags([2010, 1, 32]).overflow, 2, 'date 32 invalid');
21 assert.equal(flags([2012, 1, 29]).overflow, -1, 'date leap year valid');
22 assert.equal(flags([2010, 1, 29]).overflow, 2, 'date leap year invalid');
23
24 //hours
25 assert.equal(flags([2010, 1, 1, 8]).overflow, -1, 'hour valid');
26 assert.equal(flags([2010, 1, 1, 0]).overflow, -1, 'hour 0 valid');
27 assert.equal(flags([2010, 1, 1, -1]).overflow, 3, 'hour -1 invalid');
28 assert.equal(flags([2010, 1, 1, 25]).overflow, 3, 'hour 25 invalid');
29 assert.equal(flags([2010, 1, 1, 24, 1]).overflow, 3, 'hour 24:01 invalid');
30
31 //minutes
32 assert.equal(flags([2010, 1, 1, 8, 15]).overflow, -1, 'minute valid');
33 assert.equal(flags([2010, 1, 1, 8, 0]).overflow, -1, 'minute 0 valid');
34 assert.equal(flags([2010, 1, 1, 8, -1]).overflow, 4, 'minute -1 invalid');
35 assert.equal(flags([2010, 1, 1, 8, 60]).overflow, 4, 'minute 60 invalid');
36
37 //seconds
38 assert.equal(flags([2010, 1, 1, 8, 15, 12]).overflow, -1, 'second valid');
39 assert.equal(flags([2010, 1, 1, 8, 15, 0]).overflow, -1, 'second 0 valid');
40 assert.equal(flags([2010, 1, 1, 8, 15, -1]).overflow, 5, 'second -1 invalid');
41 assert.equal(flags([2010, 1, 1, 8, 15, 60]).overflow, 5, 'second 60 invalid');
42
43 //milliseconds
44 assert.equal(flags([2010, 1, 1, 8, 15, 12, 345]).overflow, -1, 'millisecond valid');
45 assert.equal(flags([2010, 1, 1, 8, 15, 12, 0]).overflow, -1, 'millisecond 0 valid');
46 assert.equal(flags([2010, 1, 1, 8, 15, 12, -1]).overflow, 6, 'millisecond -1 invalid');
47 assert.equal(flags([2010, 1, 1, 8, 15, 12, 1000]).overflow, 6, 'millisecond 1000 invalid');
48
49 // 24 hrs
50 assert.equal(flags([2010, 1, 1, 24, 0, 0, 0]).overflow, -1, '24:00:00.000 is fine');
51 assert.equal(flags([2010, 1, 1, 24, 1, 0, 0]).overflow, 3, '24:01:00.000 is wrong hour');
52 assert.equal(flags([2010, 1, 1, 24, 0, 1, 0]).overflow, 3, '24:00:01.000 is wrong hour');
53 assert.equal(flags([2010, 1, 1, 24, 0, 0, 1]).overflow, 3, '24:00:00.001 is wrong hour');
54 });
55
56 test('overflow without format', function (assert) {
57 //months
58 assert.equal(flags('2001-01', 'YYYY-MM').overflow, -1, 'month 1 valid');
59 assert.equal(flags('2001-12', 'YYYY-MM').overflow, -1, 'month 12 valid');
60 assert.equal(flags('2001-13', 'YYYY-MM').overflow, 1, 'month 13 invalid');
61
62 //days
63 assert.equal(flags('2010-01-16', 'YYYY-MM-DD').overflow, -1, 'date 16 valid');
64 assert.equal(flags('2010-01-0', 'YYYY-MM-DD').overflow, 2, 'date 0 invalid');
65 assert.equal(flags('2010-01-32', 'YYYY-MM-DD').overflow, 2, 'date 32 invalid');
66 assert.equal(flags('2012-02-29', 'YYYY-MM-DD').overflow, -1, 'date leap year valid');
67 assert.equal(flags('2010-02-29', 'YYYY-MM-DD').overflow, 2, 'date leap year invalid');
68
69 //days of the year
70 assert.equal(flags('2010 300', 'YYYY DDDD').overflow, -1, 'day 300 of year valid');
71 assert.equal(flags('2010 365', 'YYYY DDDD').overflow, -1, 'day 365 of year valid');
72 assert.equal(flags('2010 366', 'YYYY DDDD').overflow, 2, 'day 366 of year invalid');
73 assert.equal(flags('2012 366', 'YYYY DDDD').overflow, -1, 'day 366 of leap year valid');
74 assert.equal(flags('2012 367', 'YYYY DDDD').overflow, 2, 'day 367 of leap year invalid');
75
76 //hours
77 assert.equal(flags('08', 'HH').overflow, -1, 'hour valid');
78 assert.equal(flags('00', 'HH').overflow, -1, 'hour 0 valid');
79 assert.equal(flags('25', 'HH').overflow, 3, 'hour 25 invalid');
80 assert.equal(flags('24:01', 'HH:mm').overflow, 3, 'hour 24:01 invalid');
81
82 //minutes
83 assert.equal(flags('08:15', 'HH:mm').overflow, -1, 'minute valid');
84 assert.equal(flags('08:00', 'HH:mm').overflow, -1, 'minute 0 valid');
85 assert.equal(flags('08:60', 'HH:mm').overflow, 4, 'minute 60 invalid');
86
87 //seconds
88 assert.equal(flags('08:15:12', 'HH:mm:ss').overflow, -1, 'second valid');
89 assert.equal(flags('08:15:00', 'HH:mm:ss').overflow, -1, 'second 0 valid');
90 assert.equal(flags('08:15:60', 'HH:mm:ss').overflow, 5, 'second 60 invalid');
91
92 //milliseconds
93 assert.equal(flags('08:15:12:345', 'HH:mm:ss:SSSS').overflow, -1, 'millisecond valid');
94 assert.equal(flags('08:15:12:000', 'HH:mm:ss:SSSS').overflow, -1, 'millisecond 0 valid');
95
96 //this is OK because we don't match the last digit, so it's 100 ms
97 assert.equal(flags('08:15:12:1000', 'HH:mm:ss:SSSS').overflow, -1, 'millisecond 1000 actually valid');
98 });
99
100 test('extra tokens', function (assert) {
101 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD').unusedTokens, [], 'nothing extra');
102 assert.deepEqual(flags('1982-05', 'YYYY-MM-DD').unusedTokens, ['DD'], 'extra formatting token');
103 assert.deepEqual(flags('1982', 'YYYY-MM-DD').unusedTokens, ['MM', 'DD'], 'multiple extra formatting tokens');
104 assert.deepEqual(flags('1982-05', 'YYYY-MM-').unusedTokens, [], 'extra non-formatting token');
105 assert.deepEqual(flags('1982-05-', 'YYYY-MM-DD').unusedTokens, ['DD'], 'non-extra non-formatting token');
106 assert.deepEqual(flags('1982 05 1982', 'YYYY-MM-DD').unusedTokens, [], 'different non-formatting token');
107 });
108
109 test('extra tokens strict', function (assert) {
110 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD', true).unusedTokens, [], 'nothing extra');
111 assert.deepEqual(flags('1982-05', 'YYYY-MM-DD', true).unusedTokens, ['-', 'DD'], 'extra formatting token');
112 assert.deepEqual(flags('1982', 'YYYY-MM-DD', true).unusedTokens, ['-', 'MM', '-', 'DD'], 'multiple extra formatting tokens');
113 assert.deepEqual(flags('1982-05', 'YYYY-MM-', true).unusedTokens, ['-'], 'extra non-formatting token');
114 assert.deepEqual(flags('1982-05-', 'YYYY-MM-DD', true).unusedTokens, ['DD'], 'non-extra non-formatting token');
115 assert.deepEqual(flags('1982 05 1982', 'YYYY-MM-DD', true).unusedTokens, ['-', '-'], 'different non-formatting token');
116 });
117
118 test('unused input', function (assert) {
119 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD').unusedInput, [], 'normal input');
120 assert.deepEqual(flags('1982-05-25 this is more stuff', 'YYYY-MM-DD').unusedInput, [' this is more stuff'], 'trailing nonsense');
121 assert.deepEqual(flags('1982-05-25 09:30', 'YYYY-MM-DD').unusedInput, [' 09:30'], ['trailing legit-looking input']);
122 assert.deepEqual(flags('1982-05-25 some junk', 'YYYY-MM-DD [some junk]').unusedInput, [], 'junk that actually gets matched');
123 assert.deepEqual(flags('stuff at beginning 1982-05-25', 'YYYY-MM-DD').unusedInput, ['stuff at beginning '], 'leading junk');
124 assert.deepEqual(flags('junk 1982 more junk 05 yet more junk25', 'YYYY-MM-DD').unusedInput, ['junk ', ' more junk ', ' yet more junk'], 'interstitial junk');
125 });
126
127 test('unused input strict', function (assert) {
128 assert.deepEqual(flags('1982-05-25', 'YYYY-MM-DD', true).unusedInput, [], 'normal input');
129 assert.deepEqual(flags('1982-05-25 this is more stuff', 'YYYY-MM-DD', true).unusedInput, [' this is more stuff'], 'trailing nonsense');
130 assert.deepEqual(flags('1982-05-25 09:30', 'YYYY-MM-DD', true).unusedInput, [' 09:30'], ['trailing legit-looking input']);
131 assert.deepEqual(flags('1982-05-25 some junk', 'YYYY-MM-DD [some junk]', true).unusedInput, [], 'junk that actually gets matched');
132 assert.deepEqual(flags('stuff at beginning 1982-05-25', 'YYYY-MM-DD', true).unusedInput, ['stuff at beginning '], 'leading junk');
133 assert.deepEqual(flags('junk 1982 more junk 05 yet more junk25', 'YYYY-MM-DD', true).unusedInput, ['junk ', ' more junk ', ' yet more junk'], 'interstitial junk');
134 });
135
136 test('chars left over', function (assert) {
137 assert.equal(flags('1982-05-25', 'YYYY-MM-DD').charsLeftOver, 0, 'normal input');
138 assert.equal(flags('1982-05-25 this is more stuff', 'YYYY-MM-DD').charsLeftOver, ' this is more stuff'.length, 'trailing nonsense');
139 assert.equal(flags('1982-05-25 09:30', 'YYYY-MM-DD').charsLeftOver, ' 09:30'.length, 'trailing legit-looking input');
140 assert.equal(flags('stuff at beginning 1982-05-25', 'YYYY-MM-DD').charsLeftOver, 'stuff at beginning '.length, 'leading junk');
141 assert.equal(flags('1982 junk 05 more junk25', 'YYYY-MM-DD').charsLeftOver, [' junk ', ' more junk'].join('').length, 'interstitial junk');
142 assert.equal(flags('stuff at beginning 1982 junk 05 more junk25', 'YYYY-MM-DD').charsLeftOver, ['stuff at beginning ', ' junk ', ' more junk'].join('').length, 'leading and interstitial junk');
143 });
144
145 test('empty', function (assert) {
146 assert.equal(flags('1982-05-25', 'YYYY-MM-DD').empty, false, 'normal input');
147 assert.equal(flags('nothing here', 'YYYY-MM-DD').empty, true, 'pure garbage');
148 assert.equal(flags('junk but has the number 2000 in it', 'YYYY-MM-DD').empty, false, 'only mostly garbage');
149 assert.equal(flags('', 'YYYY-MM-DD').empty, true, 'empty string');
150 assert.equal(flags('', 'YYYY-MM-DD').empty, true, 'blank string');
151 });
152
153 test('null', function (assert) {
154 assert.equal(flags('1982-05-25', 'YYYY-MM-DD').nullInput, false, 'normal input');
155 assert.equal(flags(null).nullInput, true, 'just null');
156 assert.equal(flags(null, 'YYYY-MM-DD').nullInput, true, 'null with format');
157 });
158
159 test('invalid month', function (assert) {
160 assert.equal(flags('1982 May', 'YYYY MMMM').invalidMonth, null, 'normal input');
161 assert.equal(flags('1982 Laser', 'YYYY MMMM').invalidMonth, 'Laser', 'bad month name');
162 });
163
164 test('empty format array', function (assert) {
165 assert.equal(flags('1982 May', ['YYYY MMM']).invalidFormat, false, 'empty format array');
166 assert.equal(flags('1982 May', []).invalidFormat, true, 'empty format array');
167 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 var symbolMap = {
4 '1': '!',
5 '2': '@',
6 '3': '#',
7 '4': '$',
8 '5': '%',
9 '6': '^',
10 '7': '&',
11 '8': '*',
12 '9': '(',
13 '0': ')'
14 },
15 numberMap = {
16 '!': '1',
17 '@': '2',
18 '#': '3',
19 '$': '4',
20 '%': '5',
21 '^': '6',
22 '&': '7',
23 '*': '8',
24 '(': '9',
25 ')': '0'
26 };
27
28 module('preparse and postformat', {
29 setup: function () {
30 moment.locale('symbol', {
31 preparse: function (string) {
32 return string.replace(/[!@#$%\^&*()]/g, function (match) {
33 return numberMap[match];
34 });
35 },
36
37 postformat: function (string) {
38 return string.replace(/\d/g, function (match) {
39 return symbolMap[match];
40 });
41 }
42 });
43 }
44 });
45
46 test('transform', function (assert) {
47 assert.equal(moment.utc('@)!@-)*-@&', 'YYYY-MM-DD').unix(), 1346025600, 'preparse string + format');
48 assert.equal(moment.utc('@)!@-)*-@&').unix(), 1346025600, 'preparse ISO8601 string');
49 assert.equal(moment.unix(1346025600).utc().format('YYYY-MM-DD'), '@)!@-)*-@&', 'postformat');
50 });
51
52 test('transform from', function (assert) {
53 var start = moment([2007, 1, 28]);
54
55 assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '@ minutes', 'postformat should work on moment.fn.from');
56 assert.equal(moment().add(6, 'd').fromNow(true), '^ days', 'postformat should work on moment.fn.fromNow');
57 assert.equal(moment.duration(10, 'h').humanize(), '!) hours', 'postformat should work on moment.duration.fn.humanize');
58 });
59
60 test('calendar day', function (assert) {
61 var a = moment().hours(2).minutes(0).seconds(0);
62
63 assert.equal(moment(a).calendar(), 'Today at @:)) AM', 'today at the same time');
64 assert.equal(moment(a).add({m: 25}).calendar(), 'Today at @:@% AM', 'Now plus 25 min');
65 assert.equal(moment(a).add({h: 1}).calendar(), 'Today at #:)) AM', 'Now plus 1 hour');
66 assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at @:)) AM', 'tomorrow at the same time');
67 assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at !:)) AM', 'Now minus 1 hour');
68 assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at @:)) AM', 'yesterday at the same time');
69 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('quarter');
4
5 test('library quarter getter', function (assert) {
6 assert.equal(moment([1985, 1, 4]).quarter(), 1, 'Feb 4 1985 is Q1');
7 assert.equal(moment([2029, 8, 18]).quarter(), 3, 'Sep 18 2029 is Q3');
8 assert.equal(moment([2013, 3, 24]).quarter(), 2, 'Apr 24 2013 is Q2');
9 assert.equal(moment([2015, 2, 5]).quarter(), 1, 'Mar 5 2015 is Q1');
10 assert.equal(moment([1970, 0, 2]).quarter(), 1, 'Jan 2 1970 is Q1');
11 assert.equal(moment([2001, 11, 12]).quarter(), 4, 'Dec 12 2001 is Q4');
12 assert.equal(moment([2000, 0, 2]).quarter(), 1, 'Jan 2 2000 is Q1');
13 });
14
15 test('quarter setter singular', function (assert) {
16 var m = moment([2014, 4, 11]);
17 assert.equal(m.quarter(2).month(), 4, 'set same quarter');
18 assert.equal(m.quarter(3).month(), 7, 'set 3rd quarter');
19 assert.equal(m.quarter(1).month(), 1, 'set 1st quarter');
20 assert.equal(m.quarter(4).month(), 10, 'set 4th quarter');
21 });
22
23 test('quarter setter plural', function (assert) {
24 var m = moment([2014, 4, 11]);
25 assert.equal(m.quarters(2).month(), 4, 'set same quarter');
26 assert.equal(m.quarters(3).month(), 7, 'set 3rd quarter');
27 assert.equal(m.quarters(1).month(), 1, 'set 1st quarter');
28 assert.equal(m.quarters(4).month(), 10, 'set 4th quarter');
29 });
30
31 test('quarter setter programmatic', function (assert) {
32 var m = moment([2014, 4, 11]);
33 assert.equal(m.set('quarter', 2).month(), 4, 'set same quarter');
34 assert.equal(m.set('quarter', 3).month(), 7, 'set 3rd quarter');
35 assert.equal(m.set('quarter', 1).month(), 1, 'set 1st quarter');
36 assert.equal(m.set('quarter', 4).month(), 10, 'set 4th quarter');
37 });
38
39 test('quarter setter programmatic plural', function (assert) {
40 var m = moment([2014, 4, 11]);
41 assert.equal(m.set('quarters', 2).month(), 4, 'set same quarter');
42 assert.equal(m.set('quarters', 3).month(), 7, 'set 3rd quarter');
43 assert.equal(m.set('quarters', 1).month(), 1, 'set 1st quarter');
44 assert.equal(m.set('quarters', 4).month(), 10, 'set 4th quarter');
45 });
46
47 test('quarter setter programmatic abbr', function (assert) {
48 var m = moment([2014, 4, 11]);
49 assert.equal(m.set('Q', 2).month(), 4, 'set same quarter');
50 assert.equal(m.set('Q', 3).month(), 7, 'set 3rd quarter');
51 assert.equal(m.set('Q', 1).month(), 1, 'set 1st quarter');
52 assert.equal(m.set('Q', 4).month(), 10, 'set 4th quarter');
53 });
54
55 test('quarter setter only month changes', function (assert) {
56 var m = moment([2014, 4, 11, 1, 2, 3, 4]).quarter(4);
57 assert.equal(m.year(), 2014, 'keep year');
58 assert.equal(m.month(), 10, 'set month');
59 assert.equal(m.date(), 11, 'keep date');
60 assert.equal(m.hour(), 1, 'keep hour');
61 assert.equal(m.minute(), 2, 'keep minutes');
62 assert.equal(m.second(), 3, 'keep seconds');
63 assert.equal(m.millisecond(), 4, 'keep milliseconds');
64 });
65
66 test('quarter setter bubble to next year', function (assert) {
67 var m = moment([2014, 4, 11, 1, 2, 3, 4]).quarter(7);
68 assert.equal(m.year(), 2015, 'year bubbled');
69 assert.equal(m.month(), 7, 'set month');
70 assert.equal(m.date(), 11, 'keep date');
71 assert.equal(m.hour(), 1, 'keep hour');
72 assert.equal(m.minute(), 2, 'keep minutes');
73 assert.equal(m.second(), 3, 'keep seconds');
74 assert.equal(m.millisecond(), 4, 'keep milliseconds');
75 });
76
77 test('quarter diff', function (assert) {
78 assert.equal(moment('2014-01-01').diff(moment('2014-04-01'), 'quarter'),
79 -1, 'diff -1 quarter');
80 assert.equal(moment('2014-04-01').diff(moment('2014-01-01'), 'quarter'),
81 1, 'diff 1 quarter');
82 assert.equal(moment('2014-05-01').diff(moment('2014-01-01'), 'quarter'),
83 1, 'diff 1 quarter');
84 assert.ok(Math.abs((4 / 3) - moment('2014-05-01').diff(
85 moment('2014-01-01'), 'quarter', true)) < 0.00001,
86 'diff 1 1/3 quarter');
87 assert.equal(moment('2015-01-01').diff(moment('2014-01-01'), 'quarter'),
88 4, 'diff 4 quarters');
89 });
90
91 test('quarter setter bubble to previous year', function (assert) {
92 var m = moment([2014, 4, 11, 1, 2, 3, 4]).quarter(-3);
93 assert.equal(m.year(), 2013, 'year bubbled');
94 assert.equal(m.month(), 1, 'set month');
95 assert.equal(m.date(), 11, 'keep date');
96 assert.equal(m.hour(), 1, 'keep hour');
97 assert.equal(m.minute(), 2, 'keep minutes');
98 assert.equal(m.second(), 3, 'keep seconds');
99 assert.equal(m.millisecond(), 4, 'keep milliseconds');
100 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('relative time');
4
5 test('default thresholds fromNow', function (assert) {
6 var a = moment();
7
8 // Seconds to minutes threshold
9 a.subtract(44, 'seconds');
10 assert.equal(a.fromNow(), 'a few seconds ago', 'Below default seconds to minutes threshold');
11 a.subtract(1, 'seconds');
12 assert.equal(a.fromNow(), 'a minute ago', 'Above default seconds to minutes threshold');
13
14 // Minutes to hours threshold
15 a = moment();
16 a.subtract(44, 'minutes');
17 assert.equal(a.fromNow(), '44 minutes ago', 'Below default minute to hour threshold');
18 a.subtract(1, 'minutes');
19 assert.equal(a.fromNow(), 'an hour ago', 'Above default minute to hour threshold');
20
21 // Hours to days threshold
22 a = moment();
23 a.subtract(21, 'hours');
24 assert.equal(a.fromNow(), '21 hours ago', 'Below default hours to day threshold');
25 a.subtract(1, 'hours');
26 assert.equal(a.fromNow(), 'a day ago', 'Above default hours to day threshold');
27
28 // Days to month threshold
29 a = moment();
30 a.subtract(25, 'days');
31 assert.equal(a.fromNow(), '25 days ago', 'Below default days to month (singular) threshold');
32 a.subtract(1, 'days');
33 assert.equal(a.fromNow(), 'a month ago', 'Above default days to month (singular) threshold');
34
35 // months to year threshold
36 a = moment();
37 a.subtract(10, 'months');
38 assert.equal(a.fromNow(), '10 months ago', 'Below default days to years threshold');
39 a.subtract(1, 'month');
40 assert.equal(a.fromNow(), 'a year ago', 'Above default days to years threshold');
41 });
42
43 test('default thresholds toNow', function (assert) {
44 var a = moment();
45
46 // Seconds to minutes threshold
47 a.subtract(44, 'seconds');
48 assert.equal(a.toNow(), 'in a few seconds', 'Below default seconds to minutes threshold');
49 a.subtract(1, 'seconds');
50 assert.equal(a.toNow(), 'in a minute', 'Above default seconds to minutes threshold');
51
52 // Minutes to hours threshold
53 a = moment();
54 a.subtract(44, 'minutes');
55 assert.equal(a.toNow(), 'in 44 minutes', 'Below default minute to hour threshold');
56 a.subtract(1, 'minutes');
57 assert.equal(a.toNow(), 'in an hour', 'Above default minute to hour threshold');
58
59 // Hours to days threshold
60 a = moment();
61 a.subtract(21, 'hours');
62 assert.equal(a.toNow(), 'in 21 hours', 'Below default hours to day threshold');
63 a.subtract(1, 'hours');
64 assert.equal(a.toNow(), 'in a day', 'Above default hours to day threshold');
65
66 // Days to month threshold
67 a = moment();
68 a.subtract(25, 'days');
69 assert.equal(a.toNow(), 'in 25 days', 'Below default days to month (singular) threshold');
70 a.subtract(1, 'days');
71 assert.equal(a.toNow(), 'in a month', 'Above default days to month (singular) threshold');
72
73 // months to year threshold
74 a = moment();
75 a.subtract(10, 'months');
76 assert.equal(a.toNow(), 'in 10 months', 'Below default days to years threshold');
77 a.subtract(1, 'month');
78 assert.equal(a.toNow(), 'in a year', 'Above default days to years threshold');
79 });
80
81 test('custom thresholds', function (assert) {
82 // Seconds to minutes threshold
83 moment.relativeTimeThreshold('s', 55);
84
85 var a = moment();
86 a.subtract(54, 'seconds');
87 assert.equal(a.fromNow(), 'a few seconds ago', 'Below custom seconds to minutes threshold');
88 a.subtract(1, 'seconds');
89 assert.equal(a.fromNow(), 'a minute ago', 'Above custom seconds to minutes threshold');
90
91 moment.relativeTimeThreshold('s', 45);
92
93 // Minutes to hours threshold
94 moment.relativeTimeThreshold('m', 55);
95 a = moment();
96 a.subtract(54, 'minutes');
97 assert.equal(a.fromNow(), '54 minutes ago', 'Below custom minutes to hours threshold');
98 a.subtract(1, 'minutes');
99 assert.equal(a.fromNow(), 'an hour ago', 'Above custom minutes to hours threshold');
100 moment.relativeTimeThreshold('m', 45);
101
102 // Hours to days threshold
103 moment.relativeTimeThreshold('h', 24);
104 a = moment();
105 a.subtract(23, 'hours');
106 assert.equal(a.fromNow(), '23 hours ago', 'Below custom hours to days threshold');
107 a.subtract(1, 'hours');
108 assert.equal(a.fromNow(), 'a day ago', 'Above custom hours to days threshold');
109 moment.relativeTimeThreshold('h', 22);
110
111 // Days to month threshold
112 moment.relativeTimeThreshold('d', 28);
113 a = moment();
114 a.subtract(27, 'days');
115 assert.equal(a.fromNow(), '27 days ago', 'Below custom days to month (singular) threshold');
116 a.subtract(1, 'days');
117 assert.equal(a.fromNow(), 'a month ago', 'Above custom days to month (singular) threshold');
118 moment.relativeTimeThreshold('d', 26);
119
120 // months to years threshold
121 moment.relativeTimeThreshold('M', 9);
122 a = moment();
123 a.subtract(8, 'months');
124 assert.equal(a.fromNow(), '8 months ago', 'Below custom days to years threshold');
125 a.subtract(1, 'months');
126 assert.equal(a.fromNow(), 'a year ago', 'Above custom days to years threshold');
127 moment.relativeTimeThreshold('M', 11);
128 });
129
130 test('retrive threshold settings', function (assert) {
131 moment.relativeTimeThreshold('m', 45);
132 var minuteThreshold = moment.relativeTimeThreshold('m');
133
134 assert.equal(minuteThreshold, 45, 'Can retrieve minute setting');
135 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('start and end of units');
4
5 test('start of year', function (assert) {
6 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('year'),
7 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('years'),
8 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('y');
9 assert.equal(+m, +ms, 'Plural or singular should work');
10 assert.equal(+m, +ma, 'Full or abbreviated should work');
11 assert.equal(m.year(), 2011, 'keep the year');
12 assert.equal(m.month(), 0, 'strip out the month');
13 assert.equal(m.date(), 1, 'strip out the day');
14 assert.equal(m.hours(), 0, 'strip out the hours');
15 assert.equal(m.minutes(), 0, 'strip out the minutes');
16 assert.equal(m.seconds(), 0, 'strip out the seconds');
17 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
18 });
19
20 test('end of year', function (assert) {
21 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('year'),
22 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('years'),
23 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('y');
24 assert.equal(+m, +ms, 'Plural or singular should work');
25 assert.equal(+m, +ma, 'Full or abbreviated should work');
26 assert.equal(m.year(), 2011, 'keep the year');
27 assert.equal(m.month(), 11, 'set the month');
28 assert.equal(m.date(), 31, 'set the day');
29 assert.equal(m.hours(), 23, 'set the hours');
30 assert.equal(m.minutes(), 59, 'set the minutes');
31 assert.equal(m.seconds(), 59, 'set the seconds');
32 assert.equal(m.milliseconds(), 999, 'set the seconds');
33 });
34
35 test('start of quarter', function (assert) {
36 var m = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).startOf('quarter'),
37 ms = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).startOf('quarters'),
38 ma = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).startOf('Q');
39 assert.equal(+m, +ms, 'Plural or singular should work');
40 assert.equal(+m, +ma, 'Full or abbreviated should work');
41 assert.equal(m.year(), 2011, 'keep the year');
42 assert.equal(m.quarter(), 2, 'keep the quarter');
43 assert.equal(m.month(), 3, 'strip out the month');
44 assert.equal(m.date(), 1, 'strip out the day');
45 assert.equal(m.hours(), 0, 'strip out the hours');
46 assert.equal(m.minutes(), 0, 'strip out the minutes');
47 assert.equal(m.seconds(), 0, 'strip out the seconds');
48 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
49 });
50
51 test('end of quarter', function (assert) {
52 var m = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).endOf('quarter'),
53 ms = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).endOf('quarters'),
54 ma = moment(new Date(2011, 4, 2, 3, 4, 5, 6)).endOf('Q');
55 assert.equal(+m, +ms, 'Plural or singular should work');
56 assert.equal(+m, +ma, 'Full or abbreviated should work');
57 assert.equal(m.year(), 2011, 'keep the year');
58 assert.equal(m.quarter(), 2, 'keep the quarter');
59 assert.equal(m.month(), 5, 'set the month');
60 assert.equal(m.date(), 30, 'set the day');
61 assert.equal(m.hours(), 23, 'set the hours');
62 assert.equal(m.minutes(), 59, 'set the minutes');
63 assert.equal(m.seconds(), 59, 'set the seconds');
64 assert.equal(m.milliseconds(), 999, 'set the seconds');
65 });
66
67 test('start of month', function (assert) {
68 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('month'),
69 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('months'),
70 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('M');
71 assert.equal(+m, +ms, 'Plural or singular should work');
72 assert.equal(+m, +ma, 'Full or abbreviated should work');
73 assert.equal(m.year(), 2011, 'keep the year');
74 assert.equal(m.month(), 1, 'keep the month');
75 assert.equal(m.date(), 1, 'strip out the day');
76 assert.equal(m.hours(), 0, 'strip out the hours');
77 assert.equal(m.minutes(), 0, 'strip out the minutes');
78 assert.equal(m.seconds(), 0, 'strip out the seconds');
79 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
80 });
81
82 test('end of month', function (assert) {
83 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('month'),
84 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('months'),
85 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('M');
86 assert.equal(+m, +ms, 'Plural or singular should work');
87 assert.equal(+m, +ma, 'Full or abbreviated should work');
88 assert.equal(m.year(), 2011, 'keep the year');
89 assert.equal(m.month(), 1, 'keep the month');
90 assert.equal(m.date(), 28, 'set the day');
91 assert.equal(m.hours(), 23, 'set the hours');
92 assert.equal(m.minutes(), 59, 'set the minutes');
93 assert.equal(m.seconds(), 59, 'set the seconds');
94 assert.equal(m.milliseconds(), 999, 'set the seconds');
95 });
96
97 test('start of week', function (assert) {
98 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('week'),
99 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('weeks'),
100 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('w');
101 assert.equal(+m, +ms, 'Plural or singular should work');
102 assert.equal(+m, +ma, 'Full or abbreviated should work');
103 assert.equal(m.year(), 2011, 'keep the year');
104 assert.equal(m.month(), 0, 'rolls back to January');
105 assert.equal(m.day(), 0, 'set day of week');
106 assert.equal(m.date(), 30, 'set correct date');
107 assert.equal(m.hours(), 0, 'strip out the hours');
108 assert.equal(m.minutes(), 0, 'strip out the minutes');
109 assert.equal(m.seconds(), 0, 'strip out the seconds');
110 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
111 });
112
113 test('end of week', function (assert) {
114 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('week'),
115 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks'),
116 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('weeks');
117 assert.equal(+m, +ms, 'Plural or singular should work');
118 assert.equal(+m, +ma, 'Full or abbreviated should work');
119 assert.equal(m.year(), 2011, 'keep the year');
120 assert.equal(m.month(), 1, 'keep the month');
121 assert.equal(m.day(), 6, 'set the day of the week');
122 assert.equal(m.date(), 5, 'set the day');
123 assert.equal(m.hours(), 23, 'set the hours');
124 assert.equal(m.minutes(), 59, 'set the minutes');
125 assert.equal(m.seconds(), 59, 'set the seconds');
126 assert.equal(m.milliseconds(), 999, 'set the seconds');
127 });
128
129 test('start of iso-week', function (assert) {
130 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('isoWeek'),
131 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('isoWeeks'),
132 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('W');
133 assert.equal(+m, +ms, 'Plural or singular should work');
134 assert.equal(+m, +ma, 'Full or abbreviated should work');
135 assert.equal(m.year(), 2011, 'keep the year');
136 assert.equal(m.month(), 0, 'rollback to January');
137 assert.equal(m.isoWeekday(), 1, 'set day of iso-week');
138 assert.equal(m.date(), 31, 'set correct date');
139 assert.equal(m.hours(), 0, 'strip out the hours');
140 assert.equal(m.minutes(), 0, 'strip out the minutes');
141 assert.equal(m.seconds(), 0, 'strip out the seconds');
142 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
143 });
144
145 test('end of iso-week', function (assert) {
146 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('isoWeek'),
147 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('isoWeeks'),
148 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('W');
149 assert.equal(+m, +ms, 'Plural or singular should work');
150 assert.equal(+m, +ma, 'Full or abbreviated should work');
151 assert.equal(m.year(), 2011, 'keep the year');
152 assert.equal(m.month(), 1, 'keep the month');
153 assert.equal(m.isoWeekday(), 7, 'set the day of the week');
154 assert.equal(m.date(), 6, 'set the day');
155 assert.equal(m.hours(), 23, 'set the hours');
156 assert.equal(m.minutes(), 59, 'set the minutes');
157 assert.equal(m.seconds(), 59, 'set the seconds');
158 assert.equal(m.milliseconds(), 999, 'set the seconds');
159 });
160
161 test('start of day', function (assert) {
162 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('day'),
163 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('days'),
164 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('d');
165 assert.equal(+m, +ms, 'Plural or singular should work');
166 assert.equal(+m, +ma, 'Full or abbreviated should work');
167 assert.equal(m.year(), 2011, 'keep the year');
168 assert.equal(m.month(), 1, 'keep the month');
169 assert.equal(m.date(), 2, 'keep the day');
170 assert.equal(m.hours(), 0, 'strip out the hours');
171 assert.equal(m.minutes(), 0, 'strip out the minutes');
172 assert.equal(m.seconds(), 0, 'strip out the seconds');
173 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
174 });
175
176 test('end of day', function (assert) {
177 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('day'),
178 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('days'),
179 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('d');
180 assert.equal(+m, +ms, 'Plural or singular should work');
181 assert.equal(+m, +ma, 'Full or abbreviated should work');
182 assert.equal(m.year(), 2011, 'keep the year');
183 assert.equal(m.month(), 1, 'keep the month');
184 assert.equal(m.date(), 2, 'keep the day');
185 assert.equal(m.hours(), 23, 'set the hours');
186 assert.equal(m.minutes(), 59, 'set the minutes');
187 assert.equal(m.seconds(), 59, 'set the seconds');
188 assert.equal(m.milliseconds(), 999, 'set the seconds');
189 });
190
191 test('start of hour', function (assert) {
192 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hour'),
193 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hours'),
194 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('h');
195 assert.equal(+m, +ms, 'Plural or singular should work');
196 assert.equal(+m, +ma, 'Full or abbreviated should work');
197 assert.equal(m.year(), 2011, 'keep the year');
198 assert.equal(m.month(), 1, 'keep the month');
199 assert.equal(m.date(), 2, 'keep the day');
200 assert.equal(m.hours(), 3, 'keep the hours');
201 assert.equal(m.minutes(), 0, 'strip out the minutes');
202 assert.equal(m.seconds(), 0, 'strip out the seconds');
203 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
204 });
205
206 test('end of hour', function (assert) {
207 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hour'),
208 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('hours'),
209 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('h');
210 assert.equal(+m, +ms, 'Plural or singular should work');
211 assert.equal(+m, +ma, 'Full or abbreviated should work');
212 assert.equal(m.year(), 2011, 'keep the year');
213 assert.equal(m.month(), 1, 'keep the month');
214 assert.equal(m.date(), 2, 'keep the day');
215 assert.equal(m.hours(), 3, 'keep the hours');
216 assert.equal(m.minutes(), 59, 'set the minutes');
217 assert.equal(m.seconds(), 59, 'set the seconds');
218 assert.equal(m.milliseconds(), 999, 'set the seconds');
219 });
220
221 test('start of minute', function (assert) {
222 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minute'),
223 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('minutes'),
224 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('m');
225 assert.equal(+m, +ms, 'Plural or singular should work');
226 assert.equal(+m, +ma, 'Full or abbreviated should work');
227 assert.equal(m.year(), 2011, 'keep the year');
228 assert.equal(m.month(), 1, 'keep the month');
229 assert.equal(m.date(), 2, 'keep the day');
230 assert.equal(m.hours(), 3, 'keep the hours');
231 assert.equal(m.minutes(), 4, 'keep the minutes');
232 assert.equal(m.seconds(), 0, 'strip out the seconds');
233 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
234 });
235
236 test('end of minute', function (assert) {
237 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minute'),
238 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('minutes'),
239 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('m');
240 assert.equal(+m, +ms, 'Plural or singular should work');
241 assert.equal(+m, +ma, 'Full or abbreviated should work');
242 assert.equal(m.year(), 2011, 'keep the year');
243 assert.equal(m.month(), 1, 'keep the month');
244 assert.equal(m.date(), 2, 'keep the day');
245 assert.equal(m.hours(), 3, 'keep the hours');
246 assert.equal(m.minutes(), 4, 'keep the minutes');
247 assert.equal(m.seconds(), 59, 'set the seconds');
248 assert.equal(m.milliseconds(), 999, 'set the seconds');
249 });
250
251 test('start of second', function (assert) {
252 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('second'),
253 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('seconds'),
254 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('s');
255 assert.equal(+m, +ms, 'Plural or singular should work');
256 assert.equal(+m, +ma, 'Full or abbreviated should work');
257 assert.equal(m.year(), 2011, 'keep the year');
258 assert.equal(m.month(), 1, 'keep the month');
259 assert.equal(m.date(), 2, 'keep the day');
260 assert.equal(m.hours(), 3, 'keep the hours');
261 assert.equal(m.minutes(), 4, 'keep the minutes');
262 assert.equal(m.seconds(), 5, 'keep the the seconds');
263 assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
264 });
265
266 test('end of second', function (assert) {
267 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('second'),
268 ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('seconds'),
269 ma = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('s');
270 assert.equal(+m, +ms, 'Plural or singular should work');
271 assert.equal(+m, +ma, 'Full or abbreviated should work');
272 assert.equal(m.year(), 2011, 'keep the year');
273 assert.equal(m.month(), 1, 'keep the month');
274 assert.equal(m.date(), 2, 'keep the day');
275 assert.equal(m.hours(), 3, 'keep the hours');
276 assert.equal(m.minutes(), 4, 'keep the minutes');
277 assert.equal(m.seconds(), 5, 'keep the seconds');
278 assert.equal(m.milliseconds(), 999, 'set the seconds');
279 });
280
281 test('startOf across DST +1', function (assert) {
282 var oldUpdateOffset = moment.updateOffset,
283 // Based on a real story somewhere in America/Los_Angeles
284 dstAt = moment('2014-03-09T02:00:00-08:00').parseZone(),
285 m;
286
287 moment.updateOffset = function (mom, keepTime) {
288 if (mom.isBefore(dstAt)) {
289 mom.utcOffset(-8, keepTime);
290 } else {
291 mom.utcOffset(-7, keepTime);
292 }
293 };
294
295 m = moment('2014-03-15T00:00:00-07:00').parseZone();
296 m.startOf('M');
297 assert.equal(m.format(), '2014-03-01T00:00:00-08:00', 'startOf(\'month\') across +1');
298
299 m = moment('2014-03-09T09:00:00-07:00').parseZone();
300 m.startOf('d');
301 assert.equal(m.format(), '2014-03-09T00:00:00-08:00', 'startOf(\'day\') across +1');
302
303 m = moment('2014-03-09T03:05:00-07:00').parseZone();
304 m.startOf('h');
305 assert.equal(m.format(), '2014-03-09T03:00:00-07:00', 'startOf(\'hour\') after +1');
306
307 m = moment('2014-03-09T01:35:00-08:00').parseZone();
308 m.startOf('h');
309 assert.equal(m.format(), '2014-03-09T01:00:00-08:00', 'startOf(\'hour\') before +1');
310
311 // There is no such time as 2:30-7 to try startOf('hour') across that
312
313 moment.updateOffset = oldUpdateOffset;
314 });
315
316 test('startOf across DST -1', function (assert) {
317 var oldUpdateOffset = moment.updateOffset,
318 // Based on a real story somewhere in America/Los_Angeles
319 dstAt = moment('2014-11-02T02:00:00-07:00').parseZone(),
320 m;
321
322 moment.updateOffset = function (mom, keepTime) {
323 if (mom.isBefore(dstAt)) {
324 mom.utcOffset(-7, keepTime);
325 } else {
326 mom.utcOffset(-8, keepTime);
327 }
328 };
329
330 m = moment('2014-11-15T00:00:00-08:00').parseZone();
331 m.startOf('M');
332 assert.equal(m.format(), '2014-11-01T00:00:00-07:00', 'startOf(\'month\') across -1');
333
334 m = moment('2014-11-02T09:00:00-08:00').parseZone();
335 m.startOf('d');
336 assert.equal(m.format(), '2014-11-02T00:00:00-07:00', 'startOf(\'day\') across -1');
337
338 // note that utc offset is -8
339 m = moment('2014-11-02T01:30:00-08:00').parseZone();
340 m.startOf('h');
341 assert.equal(m.format(), '2014-11-02T01:00:00-08:00', 'startOf(\'hour\') after +1');
342
343 // note that utc offset is -7
344 m = moment('2014-11-02T01:30:00-07:00').parseZone();
345 m.startOf('h');
346 assert.equal(m.format(), '2014-11-02T01:00:00-07:00', 'startOf(\'hour\') before +1');
347
348 moment.updateOffset = oldUpdateOffset;
349 });
350
351 test('endOf millisecond and no-arg', function (assert) {
352 var m = moment();
353 assert.equal(+m, +m.clone().endOf(), 'endOf without argument should change time');
354 assert.equal(+m, +m.clone().endOf('ms'), 'endOf with ms argument should change time');
355 assert.equal(+m, +m.clone().endOf('millisecond'), 'endOf with millisecond argument should change time');
356 assert.equal(+m, +m.clone().endOf('milliseconds'), 'endOf with milliseconds argument should change time');
357 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('string prototype');
4
5 test('string prototype overrides call', function (assert) {
6 var prior = String.prototype.call, b;
7 String.prototype.call = function () {
8 return null;
9 };
10
11 b = moment(new Date(2011, 7, 28, 15, 25, 50, 125));
12 assert.equal(b.format('MMMM Do YYYY, h:mm a'), 'August 28th 2011, 3:25 pm');
13
14 String.prototype.call = prior;
15 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('to type');
4
5 test('toObject', function (assert) {
6 var expected = {
7 years:2010,
8 months:3,
9 date:5,
10 hours:15,
11 minutes:10,
12 seconds:3,
13 milliseconds:123
14 };
15 assert.deepEqual(moment(expected).toObject(), expected, 'toObject invalid');
16 });
17
18 test('toArray', function (assert) {
19 var expected = [2014, 11, 26, 11, 46, 58, 17];
20 assert.deepEqual(moment(expected).toArray(), expected, 'toArray invalid');
21 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('utc');
4
5 test('utc and local', function (assert) {
6 var m = moment(Date.UTC(2011, 1, 2, 3, 4, 5, 6)), offset, expected;
7 m.utc();
8 // utc
9 assert.equal(m.date(), 2, 'the day should be correct for utc');
10 assert.equal(m.day(), 3, 'the date should be correct for utc');
11 assert.equal(m.hours(), 3, 'the hours should be correct for utc');
12
13 // local
14 m.local();
15 if (m.zone() > 180) {
16 assert.equal(m.date(), 1, 'the date should be correct for local');
17 assert.equal(m.day(), 2, 'the day should be correct for local');
18 } else {
19 assert.equal(m.date(), 2, 'the date should be correct for local');
20 assert.equal(m.day(), 3, 'the day should be correct for local');
21 }
22 offset = Math.floor(m.utcOffset() / 60);
23 expected = (24 + 3 + offset) % 24;
24 assert.equal(m.hours(), expected, 'the hours (' + m.hours() + ') should be correct for local');
25 assert.equal(moment().utc().utcOffset(), 0, 'timezone in utc should always be zero');
26 });
27
28 test('creating with utc and no arguments', function (assert) {
29 var startOfTest = new Date().valueOf(),
30 momentDefaultUtcTime = moment.utc().valueOf(),
31 afterMomentCreationTime = new Date().valueOf();
32
33 assert.ok(startOfTest <= momentDefaultUtcTime, 'moment UTC default time should be now, not in the past');
34 assert.ok(momentDefaultUtcTime <= afterMomentCreationTime, 'moment UTC default time should be now, not in the future');
35 });
36
37 test('creating with utc and a date parameter array', function (assert) {
38 var m = moment.utc([2011, 1, 2, 3, 4, 5, 6]);
39 assert.equal(m.date(), 2, 'the day should be correct for utc array');
40 assert.equal(m.hours(), 3, 'the hours should be correct for utc array');
41
42 m = moment.utc('2011-02-02 3:04:05', 'YYYY-MM-DD HH:mm:ss');
43 assert.equal(m.date(), 2, 'the day should be correct for utc parsing format');
44 assert.equal(m.hours(), 3, 'the hours should be correct for utc parsing format');
45
46 m = moment.utc('2011-02-02T03:04:05+00:00');
47 assert.equal(m.date(), 2, 'the day should be correct for utc parsing iso');
48 assert.equal(m.hours(), 3, 'the hours should be correct for utc parsing iso');
49 });
50
51 test('creating with utc without timezone', function (assert) {
52 var m = moment.utc('2012-01-02T08:20:00');
53 assert.equal(m.date(), 2, 'the day should be correct for utc parse without timezone');
54 assert.equal(m.hours(), 8, 'the hours should be correct for utc parse without timezone');
55
56 m = moment.utc('2012-01-02T08:20:00+09:00');
57 assert.equal(m.date(), 1, 'the day should be correct for utc parse with timezone');
58 assert.equal(m.hours(), 23, 'the hours should be correct for utc parse with timezone');
59 });
60
61 test('cloning with utc offset', function (assert) {
62 var m = moment.utc('2012-01-02T08:20:00');
63 assert.equal(moment.utc(m)._isUTC, true, 'the local offset should be converted to UTC');
64 assert.equal(moment.utc(m.clone().utc())._isUTC, true, 'the local offset should stay in UTC');
65
66 m.utcOffset(120);
67 assert.equal(moment.utc(m)._isUTC, true, 'the explicit utc offset should stay in UTC');
68 assert.equal(moment.utc(m).utcOffset(), 0, 'the explicit utc offset should have an offset of 0');
69 });
70
71 test('weekday with utc', function (assert) {
72 assert.equal(
73 moment('2013-09-15T00:00:00Z').utc().weekday(), // first minute of the day
74 moment('2013-09-15T23:59:00Z').utc().weekday(), // last minute of the day
75 'a UTC-moment\'s .weekday() should not be affected by the local timezone'
76 );
77 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('utc offset');
4
5 test('setter / getter blackbox', function (assert) {
6 var m = moment([2010]);
7
8 assert.equal(m.clone().utcOffset(0).utcOffset(), 0, 'utcOffset 0');
9
10 assert.equal(m.clone().utcOffset(1).utcOffset(), 60, 'utcOffset 1 is 60');
11 assert.equal(m.clone().utcOffset(60).utcOffset(), 60, 'utcOffset 60');
12 assert.equal(m.clone().utcOffset('+01:00').utcOffset(), 60, 'utcOffset +01:00 is 60');
13 assert.equal(m.clone().utcOffset('+0100').utcOffset(), 60, 'utcOffset +0100 is 60');
14
15 assert.equal(m.clone().utcOffset(-1).utcOffset(), -60, 'utcOffset -1 is -60');
16 assert.equal(m.clone().utcOffset(-60).utcOffset(), -60, 'utcOffset -60');
17 assert.equal(m.clone().utcOffset('-01:00').utcOffset(), -60, 'utcOffset -01:00 is -60');
18 assert.equal(m.clone().utcOffset('-0100').utcOffset(), -60, 'utcOffset -0100 is -60');
19
20 assert.equal(m.clone().utcOffset(1.5).utcOffset(), 90, 'utcOffset 1.5 is 90');
21 assert.equal(m.clone().utcOffset(90).utcOffset(), 90, 'utcOffset 1.5 is 90');
22 assert.equal(m.clone().utcOffset('+01:30').utcOffset(), 90, 'utcOffset +01:30 is 90');
23 assert.equal(m.clone().utcOffset('+0130').utcOffset(), 90, 'utcOffset +0130 is 90');
24
25 assert.equal(m.clone().utcOffset(-1.5).utcOffset(), -90, 'utcOffset -1.5');
26 assert.equal(m.clone().utcOffset(-90).utcOffset(), -90, 'utcOffset -90');
27 assert.equal(m.clone().utcOffset('-01:30').utcOffset(), -90, 'utcOffset +01:30 is 90');
28 assert.equal(m.clone().utcOffset('-0130').utcOffset(), -90, 'utcOffset +0130 is 90');
29 });
30
31 test('utcOffset shorthand hours -> minutes', function (assert) {
32 var i;
33 for (i = -15; i <= 15; ++i) {
34 assert.equal(moment().utcOffset(i).utcOffset(), i * 60,
35 '' + i + ' -> ' + i * 60);
36 }
37 assert.equal(moment().utcOffset(-16).utcOffset(), -16, '-16 -> -16');
38 assert.equal(moment().utcOffset(16).utcOffset(), 16, '16 -> 16');
39 });
40
41 test('isLocal, isUtc, isUtcOffset', function (assert) {
42 assert.ok(moment().isLocal(), 'moment() creates objects in local time');
43 assert.ok(!moment.utc().isLocal(), 'moment.utc creates objects NOT in local time');
44 assert.ok(moment.utc().local().isLocal(), 'moment.fn.local() converts to local time');
45 assert.ok(!moment().utcOffset(5).isLocal(), 'moment.fn.utcOffset(N) puts objects NOT in local time');
46 assert.ok(moment().utcOffset(5).local().isLocal(), 'moment.fn.local() converts to local time');
47
48 assert.ok(moment.utc().isUtc(), 'moment.utc() creates objects in utc time');
49 assert.ok(moment().utcOffset(0).isUtc(), 'utcOffset(0) is equivalent to utc mode');
50 assert.ok(!moment().utcOffset(1).isUtc(), 'utcOffset(1) is NOT equivalent to utc mode');
51
52 assert.ok(!moment().isUtcOffset(), 'moment() creates objects NOT in utc-offset mode');
53 assert.ok(moment.utc().isUtcOffset(), 'moment.utc() creates objects in utc-offset mode');
54 assert.ok(moment().utcOffset(3).isUtcOffset(), 'utcOffset(N != 0) creates objects in utc-offset mode');
55 assert.ok(moment().utcOffset(0).isUtcOffset(), 'utcOffset(0) creates objects in utc-offset mode');
56 });
57
58 test('isUTC', function (assert) {
59 assert.ok(moment.utc().isUTC(), 'moment.utc() creates objects in utc time');
60 assert.ok(moment().utcOffset(0).isUTC(), 'utcOffset(0) is equivalent to utc mode');
61 assert.ok(!moment().utcOffset(1).isUTC(), 'utcOffset(1) is NOT equivalent to utc mode');
62 });
63
64 test('change hours when changing the utc offset', function (assert) {
65 var m = moment.utc([2000, 0, 1, 6]);
66 assert.equal(m.hour(), 6, 'UTC 6AM should be 6AM at +0000');
67
68 // sanity check
69 m.utcOffset(0);
70 assert.equal(m.hour(), 6, 'UTC 6AM should be 6AM at +0000');
71
72 m.utcOffset(-60);
73 assert.equal(m.hour(), 5, 'UTC 6AM should be 5AM at -0100');
74
75 m.utcOffset(60);
76 assert.equal(m.hour(), 7, 'UTC 6AM should be 7AM at +0100');
77 });
78
79 test('change minutes when changing the utc offset', function (assert) {
80 var m = moment.utc([2000, 0, 1, 6, 31]);
81
82 m.utcOffset(0);
83 assert.equal(m.format('HH:mm'), '06:31', 'UTC 6:31AM should be 6:31AM at +0000');
84
85 m.utcOffset(-30);
86 assert.equal(m.format('HH:mm'), '06:01', 'UTC 6:31AM should be 6:01AM at -0030');
87
88 m.utcOffset(30);
89 assert.equal(m.format('HH:mm'), '07:01', 'UTC 6:31AM should be 7:01AM at +0030');
90
91 m.utcOffset(-1380);
92 assert.equal(m.format('HH:mm'), '07:31', 'UTC 6:31AM should be 7:31AM at +1380');
93 });
94
95 test('distance from the unix epoch', function (assert) {
96 var zoneA = moment(),
97 zoneB = moment(zoneA),
98 zoneC = moment(zoneA),
99 zoneD = moment(zoneA),
100 zoneE = moment(zoneA);
101
102 zoneB.utc();
103 assert.equal(+zoneA, +zoneB, 'moment should equal moment.utc');
104
105 zoneC.utcOffset(60);
106 assert.equal(+zoneA, +zoneC, 'moment should equal moment.utcOffset(60)');
107
108 zoneD.utcOffset(-480);
109 assert.equal(+zoneA, +zoneD,
110 'moment should equal moment.utcOffset(-480)');
111
112 zoneE.utcOffset(-1000);
113 assert.equal(+zoneA, +zoneE,
114 'moment should equal moment.utcOffset(-1000)');
115 });
116
117 test('update offset after changing any values', function (assert) {
118 var oldOffset = moment.updateOffset,
119 m = moment.utc([2000, 6, 1]);
120
121 moment.updateOffset = function (mom, keepTime) {
122 if (mom.__doChange) {
123 if (+mom > 962409600000) {
124 mom.utcOffset(-120, keepTime);
125 } else {
126 mom.utcOffset(-60, keepTime);
127 }
128 }
129 };
130
131 assert.equal(m.format('ZZ'), '+0000', 'should be at +0000');
132 assert.equal(m.format('HH:mm'), '00:00', 'should start 12AM at +0000 timezone');
133
134 m.__doChange = true;
135 m.add(1, 'h');
136
137 assert.equal(m.format('ZZ'), '-0200', 'should be at -0200');
138 assert.equal(m.format('HH:mm'), '23:00', '1AM at +0000 should be 11PM at -0200 timezone');
139
140 m.subtract(1, 'h');
141
142 assert.equal(m.format('ZZ'), '-0100', 'should be at -0100');
143 assert.equal(m.format('HH:mm'), '23:00', '12AM at +0000 should be 11PM at -0100 timezone');
144
145 moment.updateOffset = oldOffset;
146 });
147
148 //////////////////
149 test('getters and setters', function (assert) {
150 var a = moment([2011, 5, 20]);
151
152 assert.equal(a.clone().utcOffset(-120).year(2012).year(), 2012, 'should get and set year correctly');
153 assert.equal(a.clone().utcOffset(-120).month(1).month(), 1, 'should get and set month correctly');
154 assert.equal(a.clone().utcOffset(-120).date(2).date(), 2, 'should get and set date correctly');
155 assert.equal(a.clone().utcOffset(-120).day(1).day(), 1, 'should get and set day correctly');
156 assert.equal(a.clone().utcOffset(-120).hour(1).hour(), 1, 'should get and set hour correctly');
157 assert.equal(a.clone().utcOffset(-120).minute(1).minute(), 1, 'should get and set minute correctly');
158 });
159
160 test('getters', function (assert) {
161 var a = moment.utc([2012, 0, 1, 0, 0, 0]);
162
163 assert.equal(a.clone().utcOffset(-120).year(), 2011, 'should get year correctly');
164 assert.equal(a.clone().utcOffset(-120).month(), 11, 'should get month correctly');
165 assert.equal(a.clone().utcOffset(-120).date(), 31, 'should get date correctly');
166 assert.equal(a.clone().utcOffset(-120).hour(), 22, 'should get hour correctly');
167 assert.equal(a.clone().utcOffset(-120).minute(), 0, 'should get minute correctly');
168
169 assert.equal(a.clone().utcOffset(120).year(), 2012, 'should get year correctly');
170 assert.equal(a.clone().utcOffset(120).month(), 0, 'should get month correctly');
171 assert.equal(a.clone().utcOffset(120).date(), 1, 'should get date correctly');
172 assert.equal(a.clone().utcOffset(120).hour(), 2, 'should get hour correctly');
173 assert.equal(a.clone().utcOffset(120).minute(), 0, 'should get minute correctly');
174
175 assert.equal(a.clone().utcOffset(90).year(), 2012, 'should get year correctly');
176 assert.equal(a.clone().utcOffset(90).month(), 0, 'should get month correctly');
177 assert.equal(a.clone().utcOffset(90).date(), 1, 'should get date correctly');
178 assert.equal(a.clone().utcOffset(90).hour(), 1, 'should get hour correctly');
179 assert.equal(a.clone().utcOffset(90).minute(), 30, 'should get minute correctly');
180 });
181
182 test('from', function (assert) {
183 var zoneA = moment(),
184 zoneB = moment(zoneA).utcOffset(-720),
185 zoneC = moment(zoneA).utcOffset(-360),
186 zoneD = moment(zoneA).utcOffset(690),
187 other = moment(zoneA).add(35, 'm');
188
189 assert.equal(zoneA.from(other), zoneB.from(other), 'moment#from should be the same in all zones');
190 assert.equal(zoneA.from(other), zoneC.from(other), 'moment#from should be the same in all zones');
191 assert.equal(zoneA.from(other), zoneD.from(other), 'moment#from should be the same in all zones');
192 });
193
194 test('diff', function (assert) {
195 var zoneA = moment(),
196 zoneB = moment(zoneA).utcOffset(-720),
197 zoneC = moment(zoneA).utcOffset(-360),
198 zoneD = moment(zoneA).utcOffset(690),
199 other = moment(zoneA).add(35, 'm');
200
201 assert.equal(zoneA.diff(other), zoneB.diff(other), 'moment#diff should be the same in all zones');
202 assert.equal(zoneA.diff(other), zoneC.diff(other), 'moment#diff should be the same in all zones');
203 assert.equal(zoneA.diff(other), zoneD.diff(other), 'moment#diff should be the same in all zones');
204
205 assert.equal(zoneA.diff(other, 'minute', true), zoneB.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
206 assert.equal(zoneA.diff(other, 'minute', true), zoneC.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
207 assert.equal(zoneA.diff(other, 'minute', true), zoneD.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
208
209 assert.equal(zoneA.diff(other, 'hour', true), zoneB.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
210 assert.equal(zoneA.diff(other, 'hour', true), zoneC.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
211 assert.equal(zoneA.diff(other, 'hour', true), zoneD.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
212 });
213
214 test('unix offset and timestamp', function (assert) {
215 var zoneA = moment(),
216 zoneB = moment(zoneA).utcOffset(-720),
217 zoneC = moment(zoneA).utcOffset(-360),
218 zoneD = moment(zoneA).utcOffset(690);
219
220 assert.equal(zoneA.unix(), zoneB.unix(), 'moment#unix should be the same in all zones');
221 assert.equal(zoneA.unix(), zoneC.unix(), 'moment#unix should be the same in all zones');
222 assert.equal(zoneA.unix(), zoneD.unix(), 'moment#unix should be the same in all zones');
223
224 assert.equal(+zoneA, +zoneB, 'moment#valueOf should be the same in all zones');
225 assert.equal(+zoneA, +zoneC, 'moment#valueOf should be the same in all zones');
226 assert.equal(+zoneA, +zoneD, 'moment#valueOf should be the same in all zones');
227 });
228
229 test('cloning', function (assert) {
230 assert.equal(moment().utcOffset(-120).clone().utcOffset(), -120,
231 'explicit cloning should retain the offset');
232 assert.equal(moment().utcOffset(120).clone().utcOffset(), 120,
233 'explicit cloning should retain the offset');
234 assert.equal(moment(moment().utcOffset(-120)).utcOffset(), -120,
235 'implicit cloning should retain the offset');
236 assert.equal(moment(moment().utcOffset(120)).utcOffset(), 120,
237 'implicit cloning should retain the offset');
238 });
239
240 test('start of / end of', function (assert) {
241 var a = moment.utc([2010, 1, 2, 0, 0, 0]).utcOffset(-450);
242
243 assert.equal(a.clone().startOf('day').hour(), 0,
244 'start of day should work on moments with utc offset');
245 assert.equal(a.clone().startOf('day').minute(), 0,
246 'start of day should work on moments with utc offset');
247 assert.equal(a.clone().startOf('hour').minute(), 0,
248 'start of hour should work on moments with utc offset');
249
250 assert.equal(a.clone().endOf('day').hour(), 23,
251 'end of day should work on moments with utc offset');
252 assert.equal(a.clone().endOf('day').minute(), 59,
253 'end of day should work on moments with utc offset');
254 assert.equal(a.clone().endOf('hour').minute(), 59,
255 'end of hour should work on moments with utc offset');
256 });
257
258 test('reset offset with moment#utc', function (assert) {
259 var a = moment.utc([2012]).utcOffset(-480);
260
261 assert.equal(a.clone().hour(), 16, 'different utc offset should have different hour');
262 assert.equal(a.clone().utc().hour(), 0, 'calling moment#utc should reset the offset');
263 });
264
265 test('reset offset with moment#local', function (assert) {
266 var a = moment([2012]).utcOffset(-480);
267
268 assert.equal(a.clone().local().hour(), 0, 'calling moment#local should reset the offset');
269 });
270
271 test('toDate', function (assert) {
272 var zoneA = new Date(),
273 zoneB = moment(zoneA).utcOffset(-720).toDate(),
274 zoneC = moment(zoneA).utcOffset(-360).toDate(),
275 zoneD = moment(zoneA).utcOffset(690).toDate();
276
277 assert.equal(+zoneA, +zoneB, 'moment#toDate should output a date with the right unix timestamp');
278 assert.equal(+zoneA, +zoneC, 'moment#toDate should output a date with the right unix timestamp');
279 assert.equal(+zoneA, +zoneD, 'moment#toDate should output a date with the right unix timestamp');
280 });
281
282 test('same / before / after', function (assert) {
283 var zoneA = moment().utc(),
284 zoneB = moment(zoneA).utcOffset(-120),
285 zoneC = moment(zoneA).utcOffset(120);
286
287 assert.ok(zoneA.isSame(zoneB), 'two moments with different offsets should be the same');
288 assert.ok(zoneA.isSame(zoneC), 'two moments with different offsets should be the same');
289
290 assert.ok(zoneA.isSame(zoneB, 'hour'), 'two moments with different offsets should be the same hour');
291 assert.ok(zoneA.isSame(zoneC, 'hour'), 'two moments with different offsets should be the same hour');
292
293 zoneA.add(1, 'hour');
294
295 assert.ok(zoneA.isAfter(zoneB), 'isAfter should work with two moments with different offsets');
296 assert.ok(zoneA.isAfter(zoneC), 'isAfter should work with two moments with different offsets');
297
298 assert.ok(zoneA.isAfter(zoneB, 'hour'), 'isAfter:hour should work with two moments with different offsets');
299 assert.ok(zoneA.isAfter(zoneC, 'hour'), 'isAfter:hour should work with two moments with different offsets');
300
301 zoneA.subtract(2, 'hour');
302
303 assert.ok(zoneA.isBefore(zoneB), 'isBefore should work with two moments with different offsets');
304 assert.ok(zoneA.isBefore(zoneC), 'isBefore should work with two moments with different offsets');
305
306 assert.ok(zoneA.isBefore(zoneB, 'hour'), 'isBefore:hour should work with two moments with different offsets');
307 assert.ok(zoneA.isBefore(zoneC, 'hour'), 'isBefore:hour should work with two moments with different offsets');
308 });
309
310 test('add / subtract over dst', function (assert) {
311 var oldOffset = moment.updateOffset,
312 m = moment.utc([2000, 2, 31, 3]);
313
314 moment.updateOffset = function (mom, keepTime) {
315 if (mom.clone().utc().month() > 2) {
316 mom.utcOffset(60, keepTime);
317 } else {
318 mom.utcOffset(0, keepTime);
319 }
320 };
321
322 assert.equal(m.hour(), 3, 'should start at 00:00');
323
324 m.add(24, 'hour');
325
326 assert.equal(m.hour(), 4, 'adding 24 hours should disregard dst');
327
328 m.subtract(24, 'hour');
329
330 assert.equal(m.hour(), 3, 'subtracting 24 hours should disregard dst');
331
332 m.add(1, 'day');
333
334 assert.equal(m.hour(), 3, 'adding 1 day should have the same hour');
335
336 m.subtract(1, 'day');
337
338 assert.equal(m.hour(), 3, 'subtracting 1 day should have the same hour');
339
340 m.add(1, 'month');
341
342 assert.equal(m.hour(), 3, 'adding 1 month should have the same hour');
343
344 m.subtract(1, 'month');
345
346 assert.equal(m.hour(), 3, 'subtracting 1 month should have the same hour');
347
348 moment.updateOffset = oldOffset;
349 });
350
351 test('isDST', function (assert) {
352 var oldOffset = moment.updateOffset;
353
354 moment.updateOffset = function (mom, keepTime) {
355 if (mom.month() > 2 && mom.month() < 9) {
356 mom.utcOffset(60, keepTime);
357 } else {
358 mom.utcOffset(0, keepTime);
359 }
360 };
361
362 assert.ok(!moment().month(0).isDST(), 'Jan should not be summer dst');
363 assert.ok(moment().month(6).isDST(), 'Jul should be summer dst');
364 assert.ok(!moment().month(11).isDST(), 'Dec should not be summer dst');
365
366 moment.updateOffset = function (mom) {
367 if (mom.month() > 2 && mom.month() < 9) {
368 mom.utcOffset(0);
369 } else {
370 mom.utcOffset(60);
371 }
372 };
373
374 assert.ok(moment().month(0).isDST(), 'Jan should be winter dst');
375 assert.ok(!moment().month(6).isDST(), 'Jul should not be winter dst');
376 assert.ok(moment().month(11).isDST(), 'Dec should be winter dst');
377
378 moment.updateOffset = oldOffset;
379 });
380
381 test('zone names', function (assert) {
382 assert.equal(moment().zoneAbbr(), '', 'Local zone abbr should be empty');
383 assert.equal(moment().format('z'), '', 'Local zone formatted abbr should be empty');
384 assert.equal(moment().zoneName(), '', 'Local zone name should be empty');
385 assert.equal(moment().format('zz'), '', 'Local zone formatted name should be empty');
386
387 assert.equal(moment.utc().zoneAbbr(), 'UTC', 'UTC zone abbr should be UTC');
388 assert.equal(moment.utc().format('z'), 'UTC', 'UTC zone formatted abbr should be UTC');
389 assert.equal(moment.utc().zoneName(), 'Coordinated Universal Time', 'UTC zone abbr should be Coordinated Universal Time');
390 assert.equal(moment.utc().format('zz'), 'Coordinated Universal Time', 'UTC zone formatted abbr should be Coordinated Universal Time');
391 });
392
393 test('hours alignment with UTC', function (assert) {
394 assert.equal(moment().utcOffset(-120).hasAlignedHourOffset(), true);
395 assert.equal(moment().utcOffset(180).hasAlignedHourOffset(), true);
396 assert.equal(moment().utcOffset(-90).hasAlignedHourOffset(), false);
397 assert.equal(moment().utcOffset(90).hasAlignedHourOffset(), false);
398 });
399
400 test('hours alignment with other zone', function (assert) {
401 var m = moment().utcOffset(-120);
402
403 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-180)), true);
404 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(180)), true);
405 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-90)), false);
406 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(90)), false);
407
408 m = moment().utcOffset(-90);
409
410 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-180)), false);
411 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(180)), false);
412 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-30)), true);
413 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(30)), true);
414
415 m = moment().utcOffset(60);
416
417 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-180)), true);
418 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(180)), true);
419 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-90)), false);
420 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(90)), false);
421
422 m = moment().utcOffset(-25);
423
424 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(35)), true);
425 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-85)), true);
426
427 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(-35)), false);
428 assert.equal(m.hasAlignedHourOffset(moment().utcOffset(85)), false);
429 });
430
431 test('parse zone', function (assert) {
432 var m = moment('2013-01-01T00:00:00-13:00').parseZone();
433 assert.equal(m.utcOffset(), -13 * 60);
434 assert.equal(m.hours(), 0);
435 });
436
437 test('parse zone static', function (assert) {
438 var m = moment.parseZone('2013-01-01T00:00:00-13:00');
439 assert.equal(m.utcOffset(), -13 * 60);
440 assert.equal(m.hours(), 0);
441 });
442
443 test('parse zone with more arguments', function (assert) {
444 var m;
445 m = moment.parseZone('2013 01 01 05 -13:00', 'YYYY MM DD HH ZZ');
446 assert.equal(m.format(), '2013-01-01T05:00:00-13:00', 'accept input and format');
447 m = moment.parseZone('2013-01-01-13:00', 'YYYY MM DD ZZ', true);
448 assert.equal(m.isValid(), false, 'accept input, format and strict flag');
449 m = moment.parseZone('2013-01-01-13:00', ['DD MM YYYY ZZ', 'YYYY MM DD ZZ']);
450 assert.equal(m.format(), '2013-01-01T00:00:00-13:00', 'accept input and array of formats');
451 });
452
453 test('parse zone with a timezone from the format string', function (assert) {
454 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY ZZ #####').parseZone();
455
456 assert.equal(m.utcOffset(), -4 * 60);
457 });
458
459 test('parse zone without a timezone included in the format string', function (assert) {
460 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY').parseZone();
461
462 assert.equal(m.utcOffset(), 11 * 60);
463 });
464
465 test('timezone format', function (assert) {
466 assert.equal(moment().utcOffset(60).format('ZZ'), '+0100', '-60 -> +0100');
467 assert.equal(moment().utcOffset(90).format('ZZ'), '+0130', '-90 -> +0130');
468 assert.equal(moment().utcOffset(120).format('ZZ'), '+0200', '-120 -> +0200');
469
470 assert.equal(moment().utcOffset(-60).format('ZZ'), '-0100', '+60 -> -0100');
471 assert.equal(moment().utcOffset(-90).format('ZZ'), '-0130', '+90 -> -0130');
472 assert.equal(moment().utcOffset(-120).format('ZZ'), '-0200', '+120 -> -0200');
473 });
474
475 test('local to utc, keepLocalTime = true', function (assert) {
476 var m = moment(),
477 fmt = 'YYYY-DD-MM HH:mm:ss';
478 assert.equal(m.clone().utc(true).format(fmt), m.format(fmt), 'local to utc failed to keep local time');
479 });
480
481 test('local to utc, keepLocalTime = false', function (assert) {
482 var m = moment();
483 assert.equal(m.clone().utc().valueOf(), m.valueOf(), 'local to utc failed to keep utc time (implicit)');
484 assert.equal(m.clone().utc(false).valueOf(), m.valueOf(), 'local to utc failed to keep utc time (explicit)');
485 });
486
487 test('local to zone, keepLocalTime = true', function (assert) {
488 var m = moment(),
489 fmt = 'YYYY-DD-MM HH:mm:ss',
490 z;
491
492 // Apparently there is -12:00 and +14:00
493 // http://en.wikipedia.org/wiki/UTC+14:00
494 // http://en.wikipedia.org/wiki/UTC-12:00
495 for (z = -12; z <= 14; ++z) {
496 assert.equal(m.clone().utcOffset(z * 60, true).format(fmt),
497 m.format(fmt),
498 'local to utcOffset(' + z + ':00) failed to keep local time');
499 }
500 });
501
502 test('local to zone, keepLocalTime = false', function (assert) {
503 var m = moment(),
504 z;
505
506 // Apparently there is -12:00 and +14:00
507 // http://en.wikipedia.org/wiki/UTC+14:00
508 // http://en.wikipedia.org/wiki/UTC-12:00
509 for (z = -12; z <= 14; ++z) {
510 assert.equal(m.clone().utcOffset(z * 60).valueOf(),
511 m.valueOf(),
512 'local to utcOffset(' + z + ':00) failed to keep utc time (implicit)');
513 assert.equal(m.clone().utcOffset(z * 60, false).valueOf(),
514 m.valueOf(),
515 'local to utcOffset(' + z + ':00) failed to keep utc time (explicit)');
516 }
517 });
518
519 test('utc to local, keepLocalTime = true', function (assert) {
520 var um = moment.utc(),
521 fmt = 'YYYY-DD-MM HH:mm:ss';
522
523 assert.equal(um.clone().local(true).format(fmt), um.format(fmt), 'utc to local failed to keep local time');
524 });
525
526 test('utc to local, keepLocalTime = false', function (assert) {
527 var um = moment.utc();
528 assert.equal(um.clone().local().valueOf(), um.valueOf(), 'utc to local failed to keep utc time (implicit)');
529 assert.equal(um.clone().local(false).valueOf(), um.valueOf(), 'utc to local failed to keep utc time (explicit)');
530 });
531
532 test('zone to local, keepLocalTime = true', function (assert) {
533 var m = moment(),
534 fmt = 'YYYY-DD-MM HH:mm:ss',
535 z;
536
537 // Apparently there is -12:00 and +14:00
538 // http://en.wikipedia.org/wiki/UTC+14:00
539 // http://en.wikipedia.org/wiki/UTC-12:00
540 for (z = -12; z <= 14; ++z) {
541 m.utcOffset(z * 60);
542
543 assert.equal(m.clone().local(true).format(fmt),
544 m.format(fmt),
545 'utcOffset(' + z + ':00) to local failed to keep local time');
546 }
547 });
548
549 test('zone to local, keepLocalTime = false', function (assert) {
550 var m = moment(),
551 z;
552
553 // Apparently there is -12:00 and +14:00
554 // http://en.wikipedia.org/wiki/UTC+14:00
555 // http://en.wikipedia.org/wiki/UTC-12:00
556 for (z = -12; z <= 14; ++z) {
557 m.utcOffset(z * 60);
558
559 assert.equal(m.clone().local(false).valueOf(), m.valueOf(),
560 'utcOffset(' + z + ':00) to local failed to keep utc time (explicit)');
561 assert.equal(m.clone().local().valueOf(), m.valueOf(),
562 'utcOffset(' + z + ':00) to local failed to keep utc time (implicit)');
563 }
564 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('week year');
4
5 test('iso week year', function (assert) {
6 // Some examples taken from http://en.wikipedia.org/wiki/ISO_week
7 assert.equal(moment([2005, 0, 1]).isoWeekYear(), 2004);
8 assert.equal(moment([2005, 0, 2]).isoWeekYear(), 2004);
9 assert.equal(moment([2005, 0, 3]).isoWeekYear(), 2005);
10 assert.equal(moment([2005, 11, 31]).isoWeekYear(), 2005);
11 assert.equal(moment([2006, 0, 1]).isoWeekYear(), 2005);
12 assert.equal(moment([2006, 0, 2]).isoWeekYear(), 2006);
13 assert.equal(moment([2007, 0, 1]).isoWeekYear(), 2007);
14 assert.equal(moment([2007, 11, 30]).isoWeekYear(), 2007);
15 assert.equal(moment([2007, 11, 31]).isoWeekYear(), 2008);
16 assert.equal(moment([2008, 0, 1]).isoWeekYear(), 2008);
17 assert.equal(moment([2008, 11, 28]).isoWeekYear(), 2008);
18 assert.equal(moment([2008, 11, 29]).isoWeekYear(), 2009);
19 assert.equal(moment([2008, 11, 30]).isoWeekYear(), 2009);
20 assert.equal(moment([2008, 11, 31]).isoWeekYear(), 2009);
21 assert.equal(moment([2009, 0, 1]).isoWeekYear(), 2009);
22 assert.equal(moment([2010, 0, 1]).isoWeekYear(), 2009);
23 assert.equal(moment([2010, 0, 2]).isoWeekYear(), 2009);
24 assert.equal(moment([2010, 0, 3]).isoWeekYear(), 2009);
25 assert.equal(moment([2010, 0, 4]).isoWeekYear(), 2010);
26 });
27
28 test('week year', function (assert) {
29 // Some examples taken from http://en.wikipedia.org/wiki/ISO_week
30 moment.locale('dow: 1,doy: 4', {week: {dow: 1, doy: 4}}); // like iso
31 assert.equal(moment([2005, 0, 1]).weekYear(), 2004);
32 assert.equal(moment([2005, 0, 2]).weekYear(), 2004);
33 assert.equal(moment([2005, 0, 3]).weekYear(), 2005);
34 assert.equal(moment([2005, 11, 31]).weekYear(), 2005);
35 assert.equal(moment([2006, 0, 1]).weekYear(), 2005);
36 assert.equal(moment([2006, 0, 2]).weekYear(), 2006);
37 assert.equal(moment([2007, 0, 1]).weekYear(), 2007);
38 assert.equal(moment([2007, 11, 30]).weekYear(), 2007);
39 assert.equal(moment([2007, 11, 31]).weekYear(), 2008);
40 assert.equal(moment([2008, 0, 1]).weekYear(), 2008);
41 assert.equal(moment([2008, 11, 28]).weekYear(), 2008);
42 assert.equal(moment([2008, 11, 29]).weekYear(), 2009);
43 assert.equal(moment([2008, 11, 30]).weekYear(), 2009);
44 assert.equal(moment([2008, 11, 31]).weekYear(), 2009);
45 assert.equal(moment([2009, 0, 1]).weekYear(), 2009);
46 assert.equal(moment([2010, 0, 1]).weekYear(), 2009);
47 assert.equal(moment([2010, 0, 2]).weekYear(), 2009);
48 assert.equal(moment([2010, 0, 3]).weekYear(), 2009);
49 assert.equal(moment([2010, 0, 4]).weekYear(), 2010);
50
51 moment.locale('dow: 1,doy: 7', {week: {dow: 1, doy: 7}});
52 assert.equal(moment([2004, 11, 26]).weekYear(), 2004);
53 assert.equal(moment([2004, 11, 27]).weekYear(), 2005);
54 assert.equal(moment([2005, 11, 25]).weekYear(), 2005);
55 assert.equal(moment([2005, 11, 26]).weekYear(), 2006);
56 assert.equal(moment([2006, 11, 31]).weekYear(), 2006);
57 assert.equal(moment([2007, 0, 1]).weekYear(), 2007);
58 assert.equal(moment([2007, 11, 30]).weekYear(), 2007);
59 assert.equal(moment([2007, 11, 31]).weekYear(), 2008);
60 assert.equal(moment([2008, 11, 28]).weekYear(), 2008);
61 assert.equal(moment([2008, 11, 29]).weekYear(), 2009);
62 assert.equal(moment([2009, 11, 27]).weekYear(), 2009);
63 assert.equal(moment([2009, 11, 28]).weekYear(), 2010);
64 });
65
66 // Verifies that the week number, week day computation is correct for all dow, doy combinations
67 test('week year roundtrip', function (assert) {
68 var dow, doy, wd, m;
69 for (dow = 0; dow < 7; ++dow) {
70 for (doy = dow; doy < dow + 7; ++doy) {
71 for (wd = 0; wd < 7; ++wd) {
72 moment.locale('dow: ' + dow + ', doy: ' + doy, {week: {dow: dow, doy: doy}});
73 // We use the 10th week as the 1st one can spill to the previous year
74 m = moment('2015 10 ' + wd, 'gggg w d', true);
75 assert.equal(m.format('gggg w d'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
76 m = moment('2015 10 ' + wd, 'gggg w e', true);
77 assert.equal(m.format('gggg w e'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
78 }
79 }
80 }
81 });
82
83 test('week numbers 2012/2013', function (assert) {
84 moment.locale('dow: 6, doy: 12', {week: {dow: 6, doy: 12}});
85 assert.equal(52, moment('2012-12-28', 'YYYY-MM-DD').week()); // 51 -- should be 52?
86 assert.equal(1, moment('2012-12-29', 'YYYY-MM-DD').week()); // 52 -- should be 1
87 assert.equal(1, moment('2013-01-01', 'YYYY-MM-DD').week()); // 52 -- should be 1
88 assert.equal(2, moment('2013-01-08', 'YYYY-MM-DD').week()); // 53 -- should be 2
89 assert.equal(2, moment('2013-01-11', 'YYYY-MM-DD').week()); // 53 -- should be 2
90 assert.equal(3, moment('2013-01-12', 'YYYY-MM-DD').week()); // 1 -- should be 3
91 assert.equal(52, moment().weeksInYear(2012)); // 52
92 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('week day');
4
5 test('iso weekday', function (assert) {
6 var i;
7
8 for (i = 0; i < 7; ++i) {
9 moment.locale('dow:' + i + ',doy: 6', {week: {dow: i, doy: 6}});
10 assert.equal(moment([1985, 1, 4]).isoWeekday(), 1, 'Feb 4 1985 is Monday -- 1st day');
11 assert.equal(moment([2029, 8, 18]).isoWeekday(), 2, 'Sep 18 2029 is Tuesday -- 2nd day');
12 assert.equal(moment([2013, 3, 24]).isoWeekday(), 3, 'Apr 24 2013 is Wednesday -- 3rd day');
13 assert.equal(moment([2015, 2, 5]).isoWeekday(), 4, 'Mar 5 2015 is Thursday -- 4th day');
14 assert.equal(moment([1970, 0, 2]).isoWeekday(), 5, 'Jan 2 1970 is Friday -- 5th day');
15 assert.equal(moment([2001, 4, 12]).isoWeekday(), 6, 'May 12 2001 is Saturday -- 6th day');
16 assert.equal(moment([2000, 0, 2]).isoWeekday(), 7, 'Jan 2 2000 is Sunday -- 7th day');
17 }
18 });
19
20 test('iso weekday setter', function (assert) {
21 var a = moment([2011, 0, 10]);
22 assert.equal(moment(a).isoWeekday(1).date(), 10, 'set from mon to mon');
23 assert.equal(moment(a).isoWeekday(4).date(), 13, 'set from mon to thu');
24 assert.equal(moment(a).isoWeekday(7).date(), 16, 'set from mon to sun');
25 assert.equal(moment(a).isoWeekday(-6).date(), 3, 'set from mon to last mon');
26 assert.equal(moment(a).isoWeekday(-3).date(), 6, 'set from mon to last thu');
27 assert.equal(moment(a).isoWeekday(0).date(), 9, 'set from mon to last sun');
28 assert.equal(moment(a).isoWeekday(8).date(), 17, 'set from mon to next mon');
29 assert.equal(moment(a).isoWeekday(11).date(), 20, 'set from mon to next thu');
30 assert.equal(moment(a).isoWeekday(14).date(), 23, 'set from mon to next sun');
31
32 a = moment([2011, 0, 13]);
33 assert.equal(moment(a).isoWeekday(1).date(), 10, 'set from thu to mon');
34 assert.equal(moment(a).isoWeekday(4).date(), 13, 'set from thu to thu');
35 assert.equal(moment(a).isoWeekday(7).date(), 16, 'set from thu to sun');
36 assert.equal(moment(a).isoWeekday(-6).date(), 3, 'set from thu to last mon');
37 assert.equal(moment(a).isoWeekday(-3).date(), 6, 'set from thu to last thu');
38 assert.equal(moment(a).isoWeekday(0).date(), 9, 'set from thu to last sun');
39 assert.equal(moment(a).isoWeekday(8).date(), 17, 'set from thu to next mon');
40 assert.equal(moment(a).isoWeekday(11).date(), 20, 'set from thu to next thu');
41 assert.equal(moment(a).isoWeekday(14).date(), 23, 'set from thu to next sun');
42
43 a = moment([2011, 0, 16]);
44 assert.equal(moment(a).isoWeekday(1).date(), 10, 'set from sun to mon');
45 assert.equal(moment(a).isoWeekday(4).date(), 13, 'set from sun to thu');
46 assert.equal(moment(a).isoWeekday(7).date(), 16, 'set from sun to sun');
47 assert.equal(moment(a).isoWeekday(-6).date(), 3, 'set from sun to last mon');
48 assert.equal(moment(a).isoWeekday(-3).date(), 6, 'set from sun to last thu');
49 assert.equal(moment(a).isoWeekday(0).date(), 9, 'set from sun to last sun');
50 assert.equal(moment(a).isoWeekday(8).date(), 17, 'set from sun to next mon');
51 assert.equal(moment(a).isoWeekday(11).date(), 20, 'set from sun to next thu');
52 assert.equal(moment(a).isoWeekday(14).date(), 23, 'set from sun to next sun');
53 });
54
55 test('weekday first day of week Sunday (dow 0)', function (assert) {
56 moment.locale('dow: 0,doy: 6', {week: {dow: 0, doy: 6}});
57 assert.equal(moment([1985, 1, 3]).weekday(), 0, 'Feb 3 1985 is Sunday -- 0th day');
58 assert.equal(moment([2029, 8, 17]).weekday(), 1, 'Sep 17 2029 is Monday -- 1st day');
59 assert.equal(moment([2013, 3, 23]).weekday(), 2, 'Apr 23 2013 is Tuesday -- 2nd day');
60 assert.equal(moment([2015, 2, 4]).weekday(), 3, 'Mar 4 2015 is Wednesday -- 3nd day');
61 assert.equal(moment([1970, 0, 1]).weekday(), 4, 'Jan 1 1970 is Thursday -- 4th day');
62 assert.equal(moment([2001, 4, 11]).weekday(), 5, 'May 11 2001 is Friday -- 5th day');
63 assert.equal(moment([2000, 0, 1]).weekday(), 6, 'Jan 1 2000 is Saturday -- 6th day');
64 });
65
66 test('weekday first day of week Monday (dow 1)', function (assert) {
67 moment.locale('dow: 1,doy: 6', {week: {dow: 1, doy: 6}});
68 assert.equal(moment([1985, 1, 4]).weekday(), 0, 'Feb 4 1985 is Monday -- 0th day');
69 assert.equal(moment([2029, 8, 18]).weekday(), 1, 'Sep 18 2029 is Tuesday -- 1st day');
70 assert.equal(moment([2013, 3, 24]).weekday(), 2, 'Apr 24 2013 is Wednesday -- 2nd day');
71 assert.equal(moment([2015, 2, 5]).weekday(), 3, 'Mar 5 2015 is Thursday -- 3nd day');
72 assert.equal(moment([1970, 0, 2]).weekday(), 4, 'Jan 2 1970 is Friday -- 4th day');
73 assert.equal(moment([2001, 4, 12]).weekday(), 5, 'May 12 2001 is Saturday -- 5th day');
74 assert.equal(moment([2000, 0, 2]).weekday(), 6, 'Jan 2 2000 is Sunday -- 6th day');
75 });
76
77 test('weekday first day of week Tuesday (dow 2)', function (assert) {
78 moment.locale('dow: 2,doy: 6', {week: {dow: 2, doy: 6}});
79 assert.equal(moment([1985, 1, 5]).weekday(), 0, 'Feb 5 1985 is Tuesday -- 0th day');
80 assert.equal(moment([2029, 8, 19]).weekday(), 1, 'Sep 19 2029 is Wednesday -- 1st day');
81 assert.equal(moment([2013, 3, 25]).weekday(), 2, 'Apr 25 2013 is Thursday -- 2nd day');
82 assert.equal(moment([2015, 2, 6]).weekday(), 3, 'Mar 6 2015 is Friday -- 3nd day');
83 assert.equal(moment([1970, 0, 3]).weekday(), 4, 'Jan 3 1970 is Staturday -- 4th day');
84 assert.equal(moment([2001, 4, 13]).weekday(), 5, 'May 13 2001 is Sunday -- 5th day');
85 assert.equal(moment([2000, 0, 3]).weekday(), 6, 'Jan 3 2000 is Monday -- 6th day');
86 });
87
88 test('weekday first day of week Wednesday (dow 3)', function (assert) {
89 moment.locale('dow: 3,doy: 6', {week: {dow: 3, doy: 6}});
90 assert.equal(moment([1985, 1, 6]).weekday(), 0, 'Feb 6 1985 is Wednesday -- 0th day');
91 assert.equal(moment([2029, 8, 20]).weekday(), 1, 'Sep 20 2029 is Thursday -- 1st day');
92 assert.equal(moment([2013, 3, 26]).weekday(), 2, 'Apr 26 2013 is Friday -- 2nd day');
93 assert.equal(moment([2015, 2, 7]).weekday(), 3, 'Mar 7 2015 is Saturday -- 3nd day');
94 assert.equal(moment([1970, 0, 4]).weekday(), 4, 'Jan 4 1970 is Sunday -- 4th day');
95 assert.equal(moment([2001, 4, 14]).weekday(), 5, 'May 14 2001 is Monday -- 5th day');
96 assert.equal(moment([2000, 0, 4]).weekday(), 6, 'Jan 4 2000 is Tuesday -- 6th day');
97 moment.locale('dow:3,doy:6', null);
98 });
99
100 test('weekday first day of week Thursday (dow 4)', function (assert) {
101 moment.locale('dow: 4,doy: 6', {week: {dow: 4, doy: 6}});
102 assert.equal(moment([1985, 1, 7]).weekday(), 0, 'Feb 7 1985 is Thursday -- 0th day');
103 assert.equal(moment([2029, 8, 21]).weekday(), 1, 'Sep 21 2029 is Friday -- 1st day');
104 assert.equal(moment([2013, 3, 27]).weekday(), 2, 'Apr 27 2013 is Saturday -- 2nd day');
105 assert.equal(moment([2015, 2, 8]).weekday(), 3, 'Mar 8 2015 is Sunday -- 3nd day');
106 assert.equal(moment([1970, 0, 5]).weekday(), 4, 'Jan 5 1970 is Monday -- 4th day');
107 assert.equal(moment([2001, 4, 15]).weekday(), 5, 'May 15 2001 is Tuesday -- 5th day');
108 assert.equal(moment([2000, 0, 5]).weekday(), 6, 'Jan 5 2000 is Wednesday -- 6th day');
109 });
110
111 test('weekday first day of week Friday (dow 5)', function (assert) {
112 moment.locale('dow: 5,doy: 6', {week: {dow: 5, doy: 6}});
113 assert.equal(moment([1985, 1, 8]).weekday(), 0, 'Feb 8 1985 is Friday -- 0th day');
114 assert.equal(moment([2029, 8, 22]).weekday(), 1, 'Sep 22 2029 is Staturday -- 1st day');
115 assert.equal(moment([2013, 3, 28]).weekday(), 2, 'Apr 28 2013 is Sunday -- 2nd day');
116 assert.equal(moment([2015, 2, 9]).weekday(), 3, 'Mar 9 2015 is Monday -- 3nd day');
117 assert.equal(moment([1970, 0, 6]).weekday(), 4, 'Jan 6 1970 is Tuesday -- 4th day');
118 assert.equal(moment([2001, 4, 16]).weekday(), 5, 'May 16 2001 is Wednesday -- 5th day');
119 assert.equal(moment([2000, 0, 6]).weekday(), 6, 'Jan 6 2000 is Thursday -- 6th day');
120 });
121
122 test('weekday first day of week Saturday (dow 6)', function (assert) {
123 moment.locale('dow: 6,doy: 6', {week: {dow: 6, doy: 6}});
124 assert.equal(moment([1985, 1, 9]).weekday(), 0, 'Feb 9 1985 is Staturday -- 0th day');
125 assert.equal(moment([2029, 8, 23]).weekday(), 1, 'Sep 23 2029 is Sunday -- 1st day');
126 assert.equal(moment([2013, 3, 29]).weekday(), 2, 'Apr 29 2013 is Monday -- 2nd day');
127 assert.equal(moment([2015, 2, 10]).weekday(), 3, 'Mar 10 2015 is Tuesday -- 3nd day');
128 assert.equal(moment([1970, 0, 7]).weekday(), 4, 'Jan 7 1970 is Wednesday -- 4th day');
129 assert.equal(moment([2001, 4, 17]).weekday(), 5, 'May 17 2001 is Thursday -- 5th day');
130 assert.equal(moment([2000, 0, 7]).weekday(), 6, 'Jan 7 2000 is Friday -- 6th day');
131 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('weeks');
4
5 test('day of year', function (assert) {
6 assert.equal(moment([2000, 0, 1]).dayOfYear(), 1, 'Jan 1 2000 should be day 1 of the year');
7 assert.equal(moment([2000, 1, 28]).dayOfYear(), 59, 'Feb 28 2000 should be day 59 of the year');
8 assert.equal(moment([2000, 1, 29]).dayOfYear(), 60, 'Feb 28 2000 should be day 60 of the year');
9 assert.equal(moment([2000, 11, 31]).dayOfYear(), 366, 'Dec 31 2000 should be day 366 of the year');
10 assert.equal(moment([2001, 0, 1]).dayOfYear(), 1, 'Jan 1 2001 should be day 1 of the year');
11 assert.equal(moment([2001, 1, 28]).dayOfYear(), 59, 'Feb 28 2001 should be day 59 of the year');
12 assert.equal(moment([2001, 2, 1]).dayOfYear(), 60, 'Mar 1 2001 should be day 60 of the year');
13 assert.equal(moment([2001, 11, 31]).dayOfYear(), 365, 'Dec 31 2001 should be day 365 of the year');
14 });
15
16 test('day of year setters', function (assert) {
17 assert.equal(moment([2000, 0, 1]).dayOfYear(200).dayOfYear(), 200, 'Setting Jan 1 2000 day of the year to 200 should work');
18 assert.equal(moment([2000, 1, 28]).dayOfYear(200).dayOfYear(), 200, 'Setting Feb 28 2000 day of the year to 200 should work');
19 assert.equal(moment([2000, 1, 29]).dayOfYear(200).dayOfYear(), 200, 'Setting Feb 28 2000 day of the year to 200 should work');
20 assert.equal(moment([2000, 11, 31]).dayOfYear(200).dayOfYear(), 200, 'Setting Dec 31 2000 day of the year to 200 should work');
21 assert.equal(moment().dayOfYear(1).dayOfYear(), 1, 'Setting day of the year to 1 should work');
22 assert.equal(moment().dayOfYear(59).dayOfYear(), 59, 'Setting day of the year to 59 should work');
23 assert.equal(moment().dayOfYear(60).dayOfYear(), 60, 'Setting day of the year to 60 should work');
24 assert.equal(moment().dayOfYear(365).dayOfYear(), 365, 'Setting day of the year to 365 should work');
25 });
26
27 test('iso weeks year starting sunday', function (assert) {
28 assert.equal(moment([2012, 0, 1]).isoWeek(), 52, 'Jan 1 2012 should be iso week 52');
29 assert.equal(moment([2012, 0, 2]).isoWeek(), 1, 'Jan 2 2012 should be iso week 1');
30 assert.equal(moment([2012, 0, 8]).isoWeek(), 1, 'Jan 8 2012 should be iso week 1');
31 assert.equal(moment([2012, 0, 9]).isoWeek(), 2, 'Jan 9 2012 should be iso week 2');
32 assert.equal(moment([2012, 0, 15]).isoWeek(), 2, 'Jan 15 2012 should be iso week 2');
33 });
34
35 test('iso weeks year starting monday', function (assert) {
36 assert.equal(moment([2007, 0, 1]).isoWeek(), 1, 'Jan 1 2007 should be iso week 1');
37 assert.equal(moment([2007, 0, 7]).isoWeek(), 1, 'Jan 7 2007 should be iso week 1');
38 assert.equal(moment([2007, 0, 8]).isoWeek(), 2, 'Jan 8 2007 should be iso week 2');
39 assert.equal(moment([2007, 0, 14]).isoWeek(), 2, 'Jan 14 2007 should be iso week 2');
40 assert.equal(moment([2007, 0, 15]).isoWeek(), 3, 'Jan 15 2007 should be iso week 3');
41 });
42
43 test('iso weeks year starting tuesday', function (assert) {
44 assert.equal(moment([2007, 11, 31]).isoWeek(), 1, 'Dec 31 2007 should be iso week 1');
45 assert.equal(moment([2008, 0, 1]).isoWeek(), 1, 'Jan 1 2008 should be iso week 1');
46 assert.equal(moment([2008, 0, 6]).isoWeek(), 1, 'Jan 6 2008 should be iso week 1');
47 assert.equal(moment([2008, 0, 7]).isoWeek(), 2, 'Jan 7 2008 should be iso week 2');
48 assert.equal(moment([2008, 0, 13]).isoWeek(), 2, 'Jan 13 2008 should be iso week 2');
49 assert.equal(moment([2008, 0, 14]).isoWeek(), 3, 'Jan 14 2008 should be iso week 3');
50 });
51
52 test('iso weeks year starting wednesday', function (assert) {
53 assert.equal(moment([2002, 11, 30]).isoWeek(), 1, 'Dec 30 2002 should be iso week 1');
54 assert.equal(moment([2003, 0, 1]).isoWeek(), 1, 'Jan 1 2003 should be iso week 1');
55 assert.equal(moment([2003, 0, 5]).isoWeek(), 1, 'Jan 5 2003 should be iso week 1');
56 assert.equal(moment([2003, 0, 6]).isoWeek(), 2, 'Jan 6 2003 should be iso week 2');
57 assert.equal(moment([2003, 0, 12]).isoWeek(), 2, 'Jan 12 2003 should be iso week 2');
58 assert.equal(moment([2003, 0, 13]).isoWeek(), 3, 'Jan 13 2003 should be iso week 3');
59 });
60
61 test('iso weeks year starting thursday', function (assert) {
62 assert.equal(moment([2008, 11, 29]).isoWeek(), 1, 'Dec 29 2008 should be iso week 1');
63 assert.equal(moment([2009, 0, 1]).isoWeek(), 1, 'Jan 1 2009 should be iso week 1');
64 assert.equal(moment([2009, 0, 4]).isoWeek(), 1, 'Jan 4 2009 should be iso week 1');
65 assert.equal(moment([2009, 0, 5]).isoWeek(), 2, 'Jan 5 2009 should be iso week 2');
66 assert.equal(moment([2009, 0, 11]).isoWeek(), 2, 'Jan 11 2009 should be iso week 2');
67 assert.equal(moment([2009, 0, 13]).isoWeek(), 3, 'Jan 12 2009 should be iso week 3');
68 });
69
70 test('iso weeks year starting friday', function (assert) {
71 assert.equal(moment([2009, 11, 28]).isoWeek(), 53, 'Dec 28 2009 should be iso week 53');
72 assert.equal(moment([2010, 0, 1]).isoWeek(), 53, 'Jan 1 2010 should be iso week 53');
73 assert.equal(moment([2010, 0, 3]).isoWeek(), 53, 'Jan 3 2010 should be iso week 53');
74 assert.equal(moment([2010, 0, 4]).isoWeek(), 1, 'Jan 4 2010 should be iso week 1');
75 assert.equal(moment([2010, 0, 10]).isoWeek(), 1, 'Jan 10 2010 should be iso week 1');
76 assert.equal(moment([2010, 0, 11]).isoWeek(), 2, 'Jan 11 2010 should be iso week 2');
77 });
78
79 test('iso weeks year starting saturday', function (assert) {
80 assert.equal(moment([2010, 11, 27]).isoWeek(), 52, 'Dec 27 2010 should be iso week 52');
81 assert.equal(moment([2011, 0, 1]).isoWeek(), 52, 'Jan 1 2011 should be iso week 52');
82 assert.equal(moment([2011, 0, 2]).isoWeek(), 52, 'Jan 2 2011 should be iso week 52');
83 assert.equal(moment([2011, 0, 3]).isoWeek(), 1, 'Jan 3 2011 should be iso week 1');
84 assert.equal(moment([2011, 0, 9]).isoWeek(), 1, 'Jan 9 2011 should be iso week 1');
85 assert.equal(moment([2011, 0, 10]).isoWeek(), 2, 'Jan 10 2011 should be iso week 2');
86 });
87
88 test('iso weeks year starting sunday formatted', function (assert) {
89 assert.equal(moment([2012, 0, 1]).format('W WW Wo'), '52 52 52nd', 'Jan 1 2012 should be iso week 52');
90 assert.equal(moment([2012, 0, 2]).format('W WW Wo'), '1 01 1st', 'Jan 2 2012 should be iso week 1');
91 assert.equal(moment([2012, 0, 8]).format('W WW Wo'), '1 01 1st', 'Jan 8 2012 should be iso week 1');
92 assert.equal(moment([2012, 0, 9]).format('W WW Wo'), '2 02 2nd', 'Jan 9 2012 should be iso week 2');
93 assert.equal(moment([2012, 0, 15]).format('W WW Wo'), '2 02 2nd', 'Jan 15 2012 should be iso week 2');
94 });
95
96 test('weeks plural year starting sunday', function (assert) {
97 assert.equal(moment([2012, 0, 1]).weeks(), 1, 'Jan 1 2012 should be week 1');
98 assert.equal(moment([2012, 0, 7]).weeks(), 1, 'Jan 7 2012 should be week 1');
99 assert.equal(moment([2012, 0, 8]).weeks(), 2, 'Jan 8 2012 should be week 2');
100 assert.equal(moment([2012, 0, 14]).weeks(), 2, 'Jan 14 2012 should be week 2');
101 assert.equal(moment([2012, 0, 15]).weeks(), 3, 'Jan 15 2012 should be week 3');
102 });
103
104 test('iso weeks plural year starting sunday', function (assert) {
105 assert.equal(moment([2012, 0, 1]).isoWeeks(), 52, 'Jan 1 2012 should be iso week 52');
106 assert.equal(moment([2012, 0, 2]).isoWeeks(), 1, 'Jan 2 2012 should be iso week 1');
107 assert.equal(moment([2012, 0, 8]).isoWeeks(), 1, 'Jan 8 2012 should be iso week 1');
108 assert.equal(moment([2012, 0, 9]).isoWeeks(), 2, 'Jan 9 2012 should be iso week 2');
109 assert.equal(moment([2012, 0, 15]).isoWeeks(), 2, 'Jan 15 2012 should be iso week 2');
110 });
111
112 test('weeks setter', function (assert) {
113 assert.equal(moment([2012, 0, 1]).week(30).week(), 30, 'Setting Jan 1 2012 to week 30 should work');
114 assert.equal(moment([2012, 0, 7]).week(30).week(), 30, 'Setting Jan 7 2012 to week 30 should work');
115 assert.equal(moment([2012, 0, 8]).week(30).week(), 30, 'Setting Jan 8 2012 to week 30 should work');
116 assert.equal(moment([2012, 0, 14]).week(30).week(), 30, 'Setting Jan 14 2012 to week 30 should work');
117 assert.equal(moment([2012, 0, 15]).week(30).week(), 30, 'Setting Jan 15 2012 to week 30 should work');
118 });
119
120 test('iso weeks setter', function (assert) {
121 assert.equal(moment([2012, 0, 1]).isoWeeks(25).isoWeeks(), 25, 'Setting Jan 1 2012 to week 25 should work');
122 assert.equal(moment([2012, 0, 2]).isoWeeks(24).isoWeeks(), 24, 'Setting Jan 2 2012 to week 24 should work');
123 assert.equal(moment([2012, 0, 8]).isoWeeks(23).isoWeeks(), 23, 'Setting Jan 8 2012 to week 23 should work');
124 assert.equal(moment([2012, 0, 9]).isoWeeks(22).isoWeeks(), 22, 'Setting Jan 9 2012 to week 22 should work');
125 assert.equal(moment([2012, 0, 15]).isoWeeks(21).isoWeeks(), 21, 'Setting Jan 15 2012 to week 21 should work');
126 });
127
128 test('iso weeks setter day of year', function (assert) {
129 assert.equal(moment([2012, 0, 1]).isoWeek(1).dayOfYear(), 9, 'Setting Jan 1 2012 to week 1 should be day of year 8');
130 assert.equal(moment([2012, 0, 1]).isoWeek(1).year(), 2011, 'Setting Jan 1 2012 to week 1 should be year 2011');
131 assert.equal(moment([2012, 0, 2]).isoWeek(1).dayOfYear(), 2, 'Setting Jan 2 2012 to week 1 should be day of year 2');
132 assert.equal(moment([2012, 0, 8]).isoWeek(1).dayOfYear(), 8, 'Setting Jan 8 2012 to week 1 should be day of year 8');
133 assert.equal(moment([2012, 0, 9]).isoWeek(1).dayOfYear(), 2, 'Setting Jan 9 2012 to week 1 should be day of year 2');
134 assert.equal(moment([2012, 0, 15]).isoWeek(1).dayOfYear(), 8, 'Setting Jan 15 2012 to week 1 should be day of year 8');
135 });
136
137 test('years with iso week 53', function (assert) {
138 // Based on a table taken from http://en.wikipedia.org/wiki/ISO_week_date
139 // (as downloaded on 2014-01-06) listing the 71 years in a 400-year cycle
140 // that have 53 weeks; in this case reflecting the 2000 based cycle
141 assert.equal(moment([2004, 11, 31]).isoWeek(), 53, 'Dec 31 2004 should be iso week 53');
142 assert.equal(moment([2009, 11, 31]).isoWeek(), 53, 'Dec 31 2009 should be iso week 53');
143 assert.equal(moment([2015, 11, 31]).isoWeek(), 53, 'Dec 31 2015 should be iso week 53');
144 assert.equal(moment([2020, 11, 31]).isoWeek(), 53, 'Dec 31 2020 should be iso week 53');
145 assert.equal(moment([2026, 11, 31]).isoWeek(), 53, 'Dec 31 2026 should be iso week 53');
146 assert.equal(moment([2032, 11, 31]).isoWeek(), 53, 'Dec 31 2032 should be iso week 53');
147 assert.equal(moment([2037, 11, 31]).isoWeek(), 53, 'Dec 31 2037 should be iso week 53');
148 assert.equal(moment([2043, 11, 31]).isoWeek(), 53, 'Dec 31 2043 should be iso week 53');
149 assert.equal(moment([2048, 11, 31]).isoWeek(), 53, 'Dec 31 2048 should be iso week 53');
150 assert.equal(moment([2054, 11, 31]).isoWeek(), 53, 'Dec 31 2054 should be iso week 53');
151 assert.equal(moment([2060, 11, 31]).isoWeek(), 53, 'Dec 31 2060 should be iso week 53');
152 assert.equal(moment([2065, 11, 31]).isoWeek(), 53, 'Dec 31 2065 should be iso week 53');
153 assert.equal(moment([2071, 11, 31]).isoWeek(), 53, 'Dec 31 2071 should be iso week 53');
154 assert.equal(moment([2076, 11, 31]).isoWeek(), 53, 'Dec 31 2076 should be iso week 53');
155 assert.equal(moment([2082, 11, 31]).isoWeek(), 53, 'Dec 31 2082 should be iso week 53');
156 assert.equal(moment([2088, 11, 31]).isoWeek(), 53, 'Dec 31 2088 should be iso week 53');
157 assert.equal(moment([2093, 11, 31]).isoWeek(), 53, 'Dec 31 2093 should be iso week 53');
158 assert.equal(moment([2099, 11, 31]).isoWeek(), 53, 'Dec 31 2099 should be iso week 53');
159 assert.equal(moment([2105, 11, 31]).isoWeek(), 53, 'Dec 31 2105 should be iso week 53');
160 assert.equal(moment([2111, 11, 31]).isoWeek(), 53, 'Dec 31 2111 should be iso week 53');
161 assert.equal(moment([2116, 11, 31]).isoWeek(), 53, 'Dec 31 2116 should be iso week 53');
162 assert.equal(moment([2122, 11, 31]).isoWeek(), 53, 'Dec 31 2122 should be iso week 53');
163 assert.equal(moment([2128, 11, 31]).isoWeek(), 53, 'Dec 31 2128 should be iso week 53');
164 assert.equal(moment([2133, 11, 31]).isoWeek(), 53, 'Dec 31 2133 should be iso week 53');
165 assert.equal(moment([2139, 11, 31]).isoWeek(), 53, 'Dec 31 2139 should be iso week 53');
166 assert.equal(moment([2144, 11, 31]).isoWeek(), 53, 'Dec 31 2144 should be iso week 53');
167 assert.equal(moment([2150, 11, 31]).isoWeek(), 53, 'Dec 31 2150 should be iso week 53');
168 assert.equal(moment([2156, 11, 31]).isoWeek(), 53, 'Dec 31 2156 should be iso week 53');
169 assert.equal(moment([2161, 11, 31]).isoWeek(), 53, 'Dec 31 2161 should be iso week 53');
170 assert.equal(moment([2167, 11, 31]).isoWeek(), 53, 'Dec 31 2167 should be iso week 53');
171 assert.equal(moment([2172, 11, 31]).isoWeek(), 53, 'Dec 31 2172 should be iso week 53');
172 assert.equal(moment([2178, 11, 31]).isoWeek(), 53, 'Dec 31 2178 should be iso week 53');
173 assert.equal(moment([2184, 11, 31]).isoWeek(), 53, 'Dec 31 2184 should be iso week 53');
174 assert.equal(moment([2189, 11, 31]).isoWeek(), 53, 'Dec 31 2189 should be iso week 53');
175 assert.equal(moment([2195, 11, 31]).isoWeek(), 53, 'Dec 31 2195 should be iso week 53');
176 assert.equal(moment([2201, 11, 31]).isoWeek(), 53, 'Dec 31 2201 should be iso week 53');
177 assert.equal(moment([2207, 11, 31]).isoWeek(), 53, 'Dec 31 2207 should be iso week 53');
178 assert.equal(moment([2212, 11, 31]).isoWeek(), 53, 'Dec 31 2212 should be iso week 53');
179 assert.equal(moment([2218, 11, 31]).isoWeek(), 53, 'Dec 31 2218 should be iso week 53');
180 assert.equal(moment([2224, 11, 31]).isoWeek(), 53, 'Dec 31 2224 should be iso week 53');
181 assert.equal(moment([2229, 11, 31]).isoWeek(), 53, 'Dec 31 2229 should be iso week 53');
182 assert.equal(moment([2235, 11, 31]).isoWeek(), 53, 'Dec 31 2235 should be iso week 53');
183 assert.equal(moment([2240, 11, 31]).isoWeek(), 53, 'Dec 31 2240 should be iso week 53');
184 assert.equal(moment([2246, 11, 31]).isoWeek(), 53, 'Dec 31 2246 should be iso week 53');
185 assert.equal(moment([2252, 11, 31]).isoWeek(), 53, 'Dec 31 2252 should be iso week 53');
186 assert.equal(moment([2257, 11, 31]).isoWeek(), 53, 'Dec 31 2257 should be iso week 53');
187 assert.equal(moment([2263, 11, 31]).isoWeek(), 53, 'Dec 31 2263 should be iso week 53');
188 assert.equal(moment([2268, 11, 31]).isoWeek(), 53, 'Dec 31 2268 should be iso week 53');
189 assert.equal(moment([2274, 11, 31]).isoWeek(), 53, 'Dec 31 2274 should be iso week 53');
190 assert.equal(moment([2280, 11, 31]).isoWeek(), 53, 'Dec 31 2280 should be iso week 53');
191 assert.equal(moment([2285, 11, 31]).isoWeek(), 53, 'Dec 31 2285 should be iso week 53');
192 assert.equal(moment([2291, 11, 31]).isoWeek(), 53, 'Dec 31 2291 should be iso week 53');
193 assert.equal(moment([2296, 11, 31]).isoWeek(), 53, 'Dec 31 2296 should be iso week 53');
194 assert.equal(moment([2303, 11, 31]).isoWeek(), 53, 'Dec 31 2303 should be iso week 53');
195 assert.equal(moment([2308, 11, 31]).isoWeek(), 53, 'Dec 31 2308 should be iso week 53');
196 assert.equal(moment([2314, 11, 31]).isoWeek(), 53, 'Dec 31 2314 should be iso week 53');
197 assert.equal(moment([2320, 11, 31]).isoWeek(), 53, 'Dec 31 2320 should be iso week 53');
198 assert.equal(moment([2325, 11, 31]).isoWeek(), 53, 'Dec 31 2325 should be iso week 53');
199 assert.equal(moment([2331, 11, 31]).isoWeek(), 53, 'Dec 31 2331 should be iso week 53');
200 assert.equal(moment([2336, 11, 31]).isoWeek(), 53, 'Dec 31 2336 should be iso week 53');
201 assert.equal(moment([2342, 11, 31]).isoWeek(), 53, 'Dec 31 2342 should be iso week 53');
202 assert.equal(moment([2348, 11, 31]).isoWeek(), 53, 'Dec 31 2348 should be iso week 53');
203 assert.equal(moment([2353, 11, 31]).isoWeek(), 53, 'Dec 31 2353 should be iso week 53');
204 assert.equal(moment([2359, 11, 31]).isoWeek(), 53, 'Dec 31 2359 should be iso week 53');
205 assert.equal(moment([2364, 11, 31]).isoWeek(), 53, 'Dec 31 2364 should be iso week 53');
206 assert.equal(moment([2370, 11, 31]).isoWeek(), 53, 'Dec 31 2370 should be iso week 53');
207 assert.equal(moment([2376, 11, 31]).isoWeek(), 53, 'Dec 31 2376 should be iso week 53');
208 assert.equal(moment([2381, 11, 31]).isoWeek(), 53, 'Dec 31 2381 should be iso week 53');
209 assert.equal(moment([2387, 11, 31]).isoWeek(), 53, 'Dec 31 2387 should be iso week 53');
210 assert.equal(moment([2392, 11, 31]).isoWeek(), 53, 'Dec 31 2392 should be iso week 53');
211 assert.equal(moment([2398, 11, 31]).isoWeek(), 53, 'Dec 31 2398 should be iso week 53');
212 });
213
214 test('count years with iso week 53', function (assert) {
215 // Based on http://en.wikipedia.org/wiki/ISO_week_date (as seen on 2014-01-06)
216 // stating that there are 71 years in a 400-year cycle that have 53 weeks;
217 // in this case reflecting the 2000 based cycle
218 var count = 0, i;
219 for (i = 0; i < 400; i++) {
220 count += (moment([2000 + i, 11, 31]).isoWeek() === 53) ? 1 : 0;
221 }
222 assert.equal(count, 71, 'Should have 71 years in 400-year cycle with iso week 53');
223 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('weeks in year');
4
5 test('isoWeeksInYear', function (assert) {
6 assert.equal(moment([2004]).isoWeeksInYear(), 53, '2004 has 53 iso weeks');
7 assert.equal(moment([2005]).isoWeeksInYear(), 52, '2005 has 53 iso weeks');
8 assert.equal(moment([2006]).isoWeeksInYear(), 52, '2006 has 53 iso weeks');
9 assert.equal(moment([2007]).isoWeeksInYear(), 52, '2007 has 52 iso weeks');
10 assert.equal(moment([2008]).isoWeeksInYear(), 52, '2008 has 53 iso weeks');
11 assert.equal(moment([2009]).isoWeeksInYear(), 53, '2009 has 53 iso weeks');
12 assert.equal(moment([2010]).isoWeeksInYear(), 52, '2010 has 52 iso weeks');
13 assert.equal(moment([2011]).isoWeeksInYear(), 52, '2011 has 52 iso weeks');
14 assert.equal(moment([2012]).isoWeeksInYear(), 52, '2012 has 52 iso weeks');
15 assert.equal(moment([2013]).isoWeeksInYear(), 52, '2013 has 52 iso weeks');
16 assert.equal(moment([2014]).isoWeeksInYear(), 52, '2014 has 52 iso weeks');
17 assert.equal(moment([2015]).isoWeeksInYear(), 53, '2015 has 53 iso weeks');
18 });
19
20 test('weeksInYear doy/dow = 1/4', function (assert) {
21 moment.locale('1/4', {week: {dow: 1, doy: 4}});
22
23 assert.equal(moment([2004]).weeksInYear(), 53, '2004 has 53 weeks');
24 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');
25 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');
26 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
27 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
28 assert.equal(moment([2009]).weeksInYear(), 53, '2009 has 53 weeks');
29 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');
30 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');
31 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');
32 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
33 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
34 assert.equal(moment([2015]).weeksInYear(), 53, '2015 has 53 weeks');
35 });
36
37 test('weeksInYear doy/dow = 6/12', function (assert) {
38 moment.locale('6/12', {week: {dow: 6, doy: 12}});
39
40 assert.equal(moment([2004]).weeksInYear(), 53, '2004 has 53 weeks');
41 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');
42 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');
43 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
44 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
45 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');
46 assert.equal(moment([2010]).weeksInYear(), 53, '2010 has 52 weeks');
47 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');
48 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');
49 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
50 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
51 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');
52 });
53
54 test('weeksInYear doy/dow = 1/7', function (assert) {
55 moment.locale('1/7', {week: {dow: 1, doy: 7}});
56
57 assert.equal(moment([2004]).weeksInYear(), 52, '2004 has 53 weeks');
58 assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 53 weeks');
59 assert.equal(moment([2006]).weeksInYear(), 53, '2006 has 53 weeks');
60 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
61 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
62 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');
63 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');
64 assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');
65 assert.equal(moment([2012]).weeksInYear(), 53, '2012 has 52 weeks');
66 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
67 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
68 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');
69 });
70
71 test('weeksInYear doy/dow = 0/6', function (assert) {
72 moment.locale('0/6', {week: {dow: 0, doy: 6}});
73
74 assert.equal(moment([2004]).weeksInYear(), 52, '2004 has 53 weeks');
75 assert.equal(moment([2005]).weeksInYear(), 53, '2005 has 53 weeks');
76 assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 53 weeks');
77 assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
78 assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 53 weeks');
79 assert.equal(moment([2009]).weeksInYear(), 52, '2009 has 53 weeks');
80 assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');
81 assert.equal(moment([2011]).weeksInYear(), 53, '2011 has 52 weeks');
82 assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');
83 assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
84 assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
85 assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 53 weeks');
86 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('zone switching');
4
5 test('local to utc, keepLocalTime = true', function (assert) {
6 var m = moment(),
7 fmt = 'YYYY-DD-MM HH:mm:ss';
8 assert.equal(m.clone().utc(true).format(fmt), m.format(fmt), 'local to utc failed to keep local time');
9 });
10
11 test('local to utc, keepLocalTime = false', function (assert) {
12 var m = moment();
13 assert.equal(m.clone().utc().valueOf(), m.valueOf(), 'local to utc failed to keep utc time (implicit)');
14 assert.equal(m.clone().utc(false).valueOf(), m.valueOf(), 'local to utc failed to keep utc time (explicit)');
15 });
16
17 test('local to zone, keepLocalTime = true', function (assert) {
18 var m = moment(),
19 fmt = 'YYYY-DD-MM HH:mm:ss',
20 z;
21
22 // Apparently there is -12:00 and +14:00
23 // http://en.wikipedia.org/wiki/UTC+14:00
24 // http://en.wikipedia.org/wiki/UTC-12:00
25 for (z = -12; z <= 14; ++z) {
26 assert.equal(m.clone().zone(z * 60, true).format(fmt), m.format(fmt),
27 'local to zone(' + z + ':00) failed to keep local time');
28 }
29 });
30
31 test('local to zone, keepLocalTime = false', function (assert) {
32 var m = moment(),
33 z;
34
35 // Apparently there is -12:00 and +14:00
36 // http://en.wikipedia.org/wiki/UTC+14:00
37 // http://en.wikipedia.org/wiki/UTC-12:00
38 for (z = -12; z <= 14; ++z) {
39 assert.equal(m.clone().zone(z * 60).valueOf(), m.valueOf(),
40 'local to zone(' + z + ':00) failed to keep utc time (implicit)');
41 assert.equal(m.clone().zone(z * 60, false).valueOf(), m.valueOf(),
42 'local to zone(' + z + ':00) failed to keep utc time (explicit)');
43 }
44 });
45
46 test('utc to local, keepLocalTime = true', function (assert) {
47 var um = moment.utc(),
48 fmt = 'YYYY-DD-MM HH:mm:ss';
49
50 assert.equal(um.clone().local(true).format(fmt), um.format(fmt), 'utc to local failed to keep local time');
51 });
52
53 test('utc to local, keepLocalTime = false', function (assert) {
54 var um = moment.utc();
55 assert.equal(um.clone().local().valueOf(), um.valueOf(), 'utc to local failed to keep utc time (implicit)');
56 assert.equal(um.clone().local(false).valueOf(), um.valueOf(), 'utc to local failed to keep utc time (explicit)');
57 });
58
59 test('zone to local, keepLocalTime = true', function (assert) {
60 var m = moment(),
61 fmt = 'YYYY-DD-MM HH:mm:ss',
62 z;
63
64 // Apparently there is -12:00 and +14:00
65 // http://en.wikipedia.org/wiki/UTC+14:00
66 // http://en.wikipedia.org/wiki/UTC-12:00
67 for (z = -12; z <= 14; ++z) {
68 m.zone(z * 60);
69
70 assert.equal(m.clone().local(true).format(fmt), m.format(fmt),
71 'zone(' + z + ':00) to local failed to keep local time');
72 }
73 });
74
75 test('zone to local, keepLocalTime = false', function (assert) {
76 var m = moment(),
77 z;
78
79 // Apparently there is -12:00 and +14:00
80 // http://en.wikipedia.org/wiki/UTC+14:00
81 // http://en.wikipedia.org/wiki/UTC-12:00
82 for (z = -12; z <= 14; ++z) {
83 m.zone(z * 60);
84
85 assert.equal(m.clone().local(false).valueOf(), m.valueOf(),
86 'zone(' + z + ':00) to local failed to keep utc time (explicit)');
87 assert.equal(m.clone().local().valueOf(), m.valueOf(),
88 'zone(' + z + ':00) to local failed to keep utc time (implicit)');
89 }
90 });
0 import { module, test } from '../qunit';
1 import moment from '../../moment';
2
3 module('zones');
4
5 test('set zone', function (assert) {
6 var zone = moment();
7
8 zone.zone(0);
9 assert.equal(zone.zone(), 0, 'should be able to set the zone to 0');
10
11 zone.zone(60);
12 assert.equal(zone.zone(), 60, 'should be able to set the zone to 60');
13
14 zone.zone(-60);
15 assert.equal(zone.zone(), -60, 'should be able to set the zone to -60');
16 });
17
18 test('set zone shorthand', function (assert) {
19 var zone = moment();
20
21 zone.zone(1);
22 assert.equal(zone.zone(), 60, 'setting the zone to 1 should imply hours and convert to 60');
23
24 zone.zone(-1);
25 assert.equal(zone.zone(), -60, 'setting the zone to -1 should imply hours and convert to -60');
26
27 zone.zone(15);
28 assert.equal(zone.zone(), 900, 'setting the zone to 15 should imply hours and convert to 900');
29
30 zone.zone(-15);
31 assert.equal(zone.zone(), -900, 'setting the zone to -15 should imply hours and convert to -900');
32
33 zone.zone(16);
34 assert.equal(zone.zone(), 16, 'setting the zone to 16 should imply minutes');
35
36 zone.zone(-16);
37 assert.equal(zone.zone(), -16, 'setting the zone to -16 should imply minutes');
38 });
39
40 test('set zone with string', function (assert) {
41 var zone = moment();
42
43 zone.zone('+00:00');
44 assert.equal(zone.zone(), 0, 'set the zone with a timezone string');
45
46 zone.zone('2013-03-07T07:00:00-08:00');
47 assert.equal(zone.zone(), 480, 'set the zone with a string that does not begin with the timezone');
48
49 zone.zone('2013-03-07T07:00:00+0100');
50 assert.equal(zone.zone(), -60, 'set the zone with a string that uses the +0000 syntax');
51
52 zone.zone('03-07-2013T07:00:00-08:00');
53 assert.equal(zone.zone(), 480, 'set the zone with a string with a non-ISO 8601 date');
54 });
55
56 test('change hours when changing the zone', function (assert) {
57 var zone = moment.utc([2000, 0, 1, 6]);
58
59 zone.zone(0);
60 assert.equal(zone.hour(), 6, 'UTC 6AM should be 6AM at +0000');
61
62 zone.zone(60);
63 assert.equal(zone.hour(), 5, 'UTC 6AM should be 5AM at -0100');
64
65 zone.zone(-60);
66 assert.equal(zone.hour(), 7, 'UTC 6AM should be 7AM at +0100');
67 });
68
69 test('change minutes when changing the zone', function (assert) {
70 var zone = moment.utc([2000, 0, 1, 6, 31]);
71
72 zone.zone(0);
73 assert.equal(zone.format('HH:mm'), '06:31', 'UTC 6:31AM should be 6:31AM at +0000');
74
75 zone.zone(30);
76 assert.equal(zone.format('HH:mm'), '06:01', 'UTC 6:31AM should be 6:01AM at -0030');
77
78 zone.zone(-30);
79 assert.equal(zone.format('HH:mm'), '07:01', 'UTC 6:31AM should be 7:01AM at +0030');
80
81 zone.zone(1380);
82 assert.equal(zone.format('HH:mm'), '07:31', 'UTC 6:31AM should be 7:31AM at +1380');
83 });
84
85 test('distance from the unix epoch', function (assert) {
86 var zoneA = moment(),
87 zoneB = moment(zoneA),
88 zoneC = moment(zoneA),
89 zoneD = moment(zoneA),
90 zoneE = moment(zoneA);
91
92 zoneB.utc();
93 assert.equal(+zoneA, +zoneB, 'moment should equal moment.utc');
94
95 zoneC.zone(-60);
96 assert.equal(+zoneA, +zoneC, 'moment should equal moment.zone(-60)');
97
98 zoneD.zone(480);
99 assert.equal(+zoneA, +zoneD, 'moment should equal moment.zone(480)');
100
101 zoneE.zone(1000);
102 assert.equal(+zoneA, +zoneE, 'moment should equal moment.zone(1000)');
103 });
104
105 test('update offset after changing any values', function (assert) {
106 var oldOffset = moment.updateOffset,
107 m = moment.utc([2000, 6, 1]);
108
109 moment.updateOffset = function (mom, keepTime) {
110 if (mom.__doChange) {
111 if (+mom > 962409600000) {
112 mom.zone(120, keepTime);
113 } else {
114 mom.zone(60, keepTime);
115 }
116 }
117 };
118
119 assert.equal(m.format('ZZ'), '+0000', 'should be at +0000');
120 assert.equal(m.format('HH:mm'), '00:00', 'should start 12AM at +0000 timezone');
121
122 m.__doChange = true;
123 m.add(1, 'h');
124
125 assert.equal(m.format('ZZ'), '-0200', 'should be at -0200');
126 assert.equal(m.format('HH:mm'), '23:00', '1AM at +0000 should be 11PM at -0200 timezone');
127
128 m.subtract(1, 'h');
129
130 assert.equal(m.format('ZZ'), '-0100', 'should be at -0100');
131 assert.equal(m.format('HH:mm'), '23:00', '12AM at +0000 should be 11PM at -0100 timezone');
132
133 moment.updateOffset = oldOffset;
134 });
135
136 test('getters and setters', function (assert) {
137 var a = moment([2011, 5, 20]);
138
139 assert.equal(a.clone().zone(120).year(2012).year(), 2012, 'should get and set year correctly');
140 assert.equal(a.clone().zone(120).month(1).month(), 1, 'should get and set month correctly');
141 assert.equal(a.clone().zone(120).date(2).date(), 2, 'should get and set date correctly');
142 assert.equal(a.clone().zone(120).day(1).day(), 1, 'should get and set day correctly');
143 assert.equal(a.clone().zone(120).hour(1).hour(), 1, 'should get and set hour correctly');
144 assert.equal(a.clone().zone(120).minute(1).minute(), 1, 'should get and set minute correctly');
145 });
146
147 test('getters', function (assert) {
148 var a = moment.utc([2012, 0, 1, 0, 0, 0]);
149
150 assert.equal(a.clone().zone(120).year(), 2011, 'should get year correctly');
151 assert.equal(a.clone().zone(120).month(), 11, 'should get month correctly');
152 assert.equal(a.clone().zone(120).date(), 31, 'should get date correctly');
153 assert.equal(a.clone().zone(120).hour(), 22, 'should get hour correctly');
154 assert.equal(a.clone().zone(120).minute(), 0, 'should get minute correctly');
155
156 assert.equal(a.clone().zone(-120).year(), 2012, 'should get year correctly');
157 assert.equal(a.clone().zone(-120).month(), 0, 'should get month correctly');
158 assert.equal(a.clone().zone(-120).date(), 1, 'should get date correctly');
159 assert.equal(a.clone().zone(-120).hour(), 2, 'should get hour correctly');
160 assert.equal(a.clone().zone(-120).minute(), 0, 'should get minute correctly');
161
162 assert.equal(a.clone().zone(-90).year(), 2012, 'should get year correctly');
163 assert.equal(a.clone().zone(-90).month(), 0, 'should get month correctly');
164 assert.equal(a.clone().zone(-90).date(), 1, 'should get date correctly');
165 assert.equal(a.clone().zone(-90).hour(), 1, 'should get hour correctly');
166 assert.equal(a.clone().zone(-90).minute(), 30, 'should get minute correctly');
167 });
168
169 test('from', function (assert) {
170 var zoneA = moment(),
171 zoneB = moment(zoneA).zone(720),
172 zoneC = moment(zoneA).zone(360),
173 zoneD = moment(zoneA).zone(-690),
174 other = moment(zoneA).add(35, 'm');
175
176 assert.equal(zoneA.from(other), zoneB.from(other), 'moment#from should be the same in all zones');
177 assert.equal(zoneA.from(other), zoneC.from(other), 'moment#from should be the same in all zones');
178 assert.equal(zoneA.from(other), zoneD.from(other), 'moment#from should be the same in all zones');
179 });
180
181 test('diff', function (assert) {
182 var zoneA = moment(),
183 zoneB = moment(zoneA).zone(720),
184 zoneC = moment(zoneA).zone(360),
185 zoneD = moment(zoneA).zone(-690),
186 other = moment(zoneA).add(35, 'm');
187
188 assert.equal(zoneA.diff(other), zoneB.diff(other), 'moment#diff should be the same in all zones');
189 assert.equal(zoneA.diff(other), zoneC.diff(other), 'moment#diff should be the same in all zones');
190 assert.equal(zoneA.diff(other), zoneD.diff(other), 'moment#diff should be the same in all zones');
191
192 assert.equal(zoneA.diff(other, 'minute', true), zoneB.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
193 assert.equal(zoneA.diff(other, 'minute', true), zoneC.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
194 assert.equal(zoneA.diff(other, 'minute', true), zoneD.diff(other, 'minute', true), 'moment#diff should be the same in all zones');
195
196 assert.equal(zoneA.diff(other, 'hour', true), zoneB.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
197 assert.equal(zoneA.diff(other, 'hour', true), zoneC.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
198 assert.equal(zoneA.diff(other, 'hour', true), zoneD.diff(other, 'hour', true), 'moment#diff should be the same in all zones');
199 });
200
201 test('unix offset and timestamp', function (assert) {
202 var zoneA = moment(),
203 zoneB = moment(zoneA).zone(720),
204 zoneC = moment(zoneA).zone(360),
205 zoneD = moment(zoneA).zone(-690);
206
207 assert.equal(zoneA.unix(), zoneB.unix(), 'moment#unix should be the same in all zones');
208 assert.equal(zoneA.unix(), zoneC.unix(), 'moment#unix should be the same in all zones');
209 assert.equal(zoneA.unix(), zoneD.unix(), 'moment#unix should be the same in all zones');
210
211 assert.equal(+zoneA, +zoneB, 'moment#valueOf should be the same in all zones');
212 assert.equal(+zoneA, +zoneC, 'moment#valueOf should be the same in all zones');
213 assert.equal(+zoneA, +zoneD, 'moment#valueOf should be the same in all zones');
214 });
215
216 test('cloning', function (assert) {
217 assert.equal(moment().zone(120).clone().zone(), 120, 'explicit cloning should retain the zone');
218 assert.equal(moment().zone(-120).clone().zone(), -120, 'explicit cloning should retain the zone');
219 assert.equal(moment(moment().zone(120)).zone(), 120, 'implicit cloning should retain the zone');
220 assert.equal(moment(moment().zone(-120)).zone(), -120, 'implicit cloning should retain the zone');
221 });
222
223 test('start of / end of', function (assert) {
224 var a = moment.utc([2010, 1, 2, 0, 0, 0]).zone(450);
225
226 assert.equal(a.clone().startOf('day').hour(), 0, 'start of day should work on moments with a zone');
227 assert.equal(a.clone().startOf('day').minute(), 0, 'start of day should work on moments with a zone');
228 assert.equal(a.clone().startOf('hour').minute(), 0, 'start of hour should work on moments with a zone');
229
230 assert.equal(a.clone().endOf('day').hour(), 23, 'end of day should work on moments with a zone');
231 assert.equal(a.clone().endOf('day').minute(), 59, 'end of day should work on moments with a zone');
232 assert.equal(a.clone().endOf('hour').minute(), 59, 'end of hour should work on moments with a zone');
233 });
234
235 test('reset zone with moment#utc', function (assert) {
236 var a = moment.utc([2012]).zone(480);
237
238 assert.equal(a.clone().hour(), 16, 'different zone should have different hour');
239 assert.equal(a.clone().utc().hour(), 0, 'calling moment#utc should reset the offset');
240 });
241
242 test('reset zone with moment#local', function (assert) {
243 var a = moment([2012]).zone(480);
244
245 assert.equal(a.clone().local().hour(), 0, 'calling moment#local should reset the offset');
246 });
247
248 test('toDate', function (assert) {
249 var zoneA = new Date(),
250 zoneB = moment(zoneA).zone(720).toDate(),
251 zoneC = moment(zoneA).zone(360).toDate(),
252 zoneD = moment(zoneA).zone(-690).toDate();
253
254 assert.equal(+zoneA, +zoneB, 'moment#toDate should output a date with the right unix timestamp');
255 assert.equal(+zoneA, +zoneC, 'moment#toDate should output a date with the right unix timestamp');
256 assert.equal(+zoneA, +zoneD, 'moment#toDate should output a date with the right unix timestamp');
257 });
258
259 test('same / before / after', function (assert) {
260 var zoneA = moment().utc(),
261 zoneB = moment(zoneA).zone(120),
262 zoneC = moment(zoneA).zone(-120);
263
264 assert.ok(zoneA.isSame(zoneB), 'two moments with different offsets should be the same');
265 assert.ok(zoneA.isSame(zoneC), 'two moments with different offsets should be the same');
266
267 assert.ok(zoneA.isSame(zoneB, 'hour'), 'two moments with different offsets should be the same hour');
268 assert.ok(zoneA.isSame(zoneC, 'hour'), 'two moments with different offsets should be the same hour');
269
270 zoneA.add(1, 'hour');
271
272 assert.ok(zoneA.isAfter(zoneB), 'isAfter should work with two moments with different offsets');
273 assert.ok(zoneA.isAfter(zoneC), 'isAfter should work with two moments with different offsets');
274
275 assert.ok(zoneA.isAfter(zoneB, 'hour'), 'isAfter:hour should work with two moments with different offsets');
276 assert.ok(zoneA.isAfter(zoneC, 'hour'), 'isAfter:hour should work with two moments with different offsets');
277
278 zoneA.subtract(2, 'hour');
279
280 assert.ok(zoneA.isBefore(zoneB), 'isBefore should work with two moments with different offsets');
281 assert.ok(zoneA.isBefore(zoneC), 'isBefore should work with two moments with different offsets');
282
283 assert.ok(zoneA.isBefore(zoneB, 'hour'), 'isBefore:hour should work with two moments with different offsets');
284 assert.ok(zoneA.isBefore(zoneC, 'hour'), 'isBefore:hour should work with two moments with different offsets');
285 });
286
287 test('add / subtract over dst', function (assert) {
288 var oldOffset = moment.updateOffset,
289 m = moment.utc([2000, 2, 31, 3]);
290
291 moment.updateOffset = function (mom, keepTime) {
292 if (mom.clone().utc().month() > 2) {
293 mom.zone(-60, keepTime);
294 } else {
295 mom.zone(0, keepTime);
296 }
297 };
298
299 assert.equal(m.hour(), 3, 'should start at 00:00');
300
301 m.add(24, 'hour');
302
303 assert.equal(m.hour(), 4, 'adding 24 hours should disregard dst');
304
305 m.subtract(24, 'hour');
306
307 assert.equal(m.hour(), 3, 'subtracting 24 hours should disregard dst');
308
309 m.add(1, 'day');
310
311 assert.equal(m.hour(), 3, 'adding 1 day should have the same hour');
312
313 m.subtract(1, 'day');
314
315 assert.equal(m.hour(), 3, 'subtracting 1 day should have the same hour');
316
317 m.add(1, 'month');
318
319 assert.equal(m.hour(), 3, 'adding 1 month should have the same hour');
320
321 m.subtract(1, 'month');
322
323 assert.equal(m.hour(), 3, 'subtracting 1 month should have the same hour');
324
325 moment.updateOffset = oldOffset;
326 });
327
328 test('isDST', function (assert) {
329 var oldOffset = moment.updateOffset;
330
331 moment.updateOffset = function (mom, keepTime) {
332 if (mom.month() > 2 && mom.month() < 9) {
333 mom.zone(-60, keepTime);
334 } else {
335 mom.zone(0, keepTime);
336 }
337 };
338
339 assert.ok(!moment().month(0).isDST(), 'Jan should not be summer dst');
340 assert.ok(moment().month(6).isDST(), 'Jul should be summer dst');
341 assert.ok(!moment().month(11).isDST(), 'Dec should not be summer dst');
342
343 moment.updateOffset = function (mom) {
344 if (mom.month() > 2 && mom.month() < 9) {
345 mom.zone(0);
346 } else {
347 mom.zone(-60);
348 }
349 };
350
351 assert.ok(moment().month(0).isDST(), 'Jan should be winter dst');
352 assert.ok(!moment().month(6).isDST(), 'Jul should not be winter dst');
353 assert.ok(moment().month(11).isDST(), 'Dec should be winter dst');
354
355 moment.updateOffset = oldOffset;
356 });
357
358 test('zone names', function (assert) {
359 assert.equal(moment().zoneAbbr(), '', 'Local zone abbr should be empty');
360 assert.equal(moment().format('z'), '', 'Local zone formatted abbr should be empty');
361 assert.equal(moment().zoneName(), '', 'Local zone name should be empty');
362 assert.equal(moment().format('zz'), '', 'Local zone formatted name should be empty');
363
364 assert.equal(moment.utc().zoneAbbr(), 'UTC', 'UTC zone abbr should be UTC');
365 assert.equal(moment.utc().format('z'), 'UTC', 'UTC zone formatted abbr should be UTC');
366 assert.equal(moment.utc().zoneName(), 'Coordinated Universal Time', 'UTC zone abbr should be Coordinated Universal Time');
367 assert.equal(moment.utc().format('zz'), 'Coordinated Universal Time', 'UTC zone formatted abbr should be Coordinated Universal Time');
368 });
369
370 test('hours alignment with UTC', function (assert) {
371 assert.equal(moment().zone(120).hasAlignedHourOffset(), true);
372 assert.equal(moment().zone(-180).hasAlignedHourOffset(), true);
373 assert.equal(moment().zone(90).hasAlignedHourOffset(), false);
374 assert.equal(moment().zone(-90).hasAlignedHourOffset(), false);
375 });
376
377 test('hours alignment with other zone', function (assert) {
378 var m = moment().zone(120);
379
380 assert.equal(m.hasAlignedHourOffset(moment().zone(180)), true);
381 assert.equal(m.hasAlignedHourOffset(moment().zone(-180)), true);
382 assert.equal(m.hasAlignedHourOffset(moment().zone(90)), false);
383 assert.equal(m.hasAlignedHourOffset(moment().zone(-90)), false);
384
385 m = moment().zone(90);
386
387 assert.equal(m.hasAlignedHourOffset(moment().zone(180)), false);
388 assert.equal(m.hasAlignedHourOffset(moment().zone(-180)), false);
389 assert.equal(m.hasAlignedHourOffset(moment().zone(30)), true);
390 assert.equal(m.hasAlignedHourOffset(moment().zone(-30)), true);
391
392 m = moment().zone(-60);
393
394 assert.equal(m.hasAlignedHourOffset(moment().zone(180)), true);
395 assert.equal(m.hasAlignedHourOffset(moment().zone(-180)), true);
396 assert.equal(m.hasAlignedHourOffset(moment().zone(90)), false);
397 assert.equal(m.hasAlignedHourOffset(moment().zone(-90)), false);
398
399 m = moment().zone(25);
400
401 assert.equal(m.hasAlignedHourOffset(moment().zone(-35)), true);
402 assert.equal(m.hasAlignedHourOffset(moment().zone(85)), true);
403
404 assert.equal(m.hasAlignedHourOffset(moment().zone(35)), false);
405 assert.equal(m.hasAlignedHourOffset(moment().zone(-85)), false);
406 });
407
408 test('parse zone', function (assert) {
409 var m = moment('2013-01-01T00:00:00-13:00').parseZone();
410 assert.equal(m.zone(), 13 * 60);
411 assert.equal(m.hours(), 0);
412 });
413
414 test('parse zone static', function (assert) {
415 var m = moment.parseZone('2013-01-01T00:00:00-13:00');
416 assert.equal(m.zone(), 13 * 60);
417 assert.equal(m.hours(), 0);
418 });
419
420 test('parse zone with more arguments', function (assert) {
421 var m;
422 m = moment.parseZone('2013 01 01 05 -13:00', 'YYYY MM DD HH ZZ');
423 assert.equal(m.format(), '2013-01-01T05:00:00-13:00', 'accept input and format');
424 m = moment.parseZone('2013-01-01-13:00', 'YYYY MM DD ZZ', true);
425 assert.equal(m.isValid(), false, 'accept input, format and strict flag');
426 m = moment.parseZone('2013-01-01-13:00', ['DD MM YYYY ZZ', 'YYYY MM DD ZZ']);
427 assert.equal(m.format(), '2013-01-01T00:00:00-13:00', 'accept input and array of formats');
428 });
429
430 test('parse zone with a timezone from the format string', function (assert) {
431 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY ZZ #####').parseZone();
432
433 assert.equal(m.zone(), 4 * 60);
434 });
435
436 test('parse zone without a timezone included in the format string', function (assert) {
437 var m = moment('11-12-2013 -0400 +1100', 'DD-MM-YYYY').parseZone();
438
439 assert.equal(m.zone(), -11 * 60);
440 });
441
442 test('timezone format', function (assert) {
443 assert.equal(moment().zone(-60).format('ZZ'), '+0100', '-60 -> +0100');
444 assert.equal(moment().zone(-90).format('ZZ'), '+0130', '-90 -> +0130');
445 assert.equal(moment().zone(-120).format('ZZ'), '+0200', '-120 -> +0200');
446
447 assert.equal(moment().zone(+60).format('ZZ'), '-0100', '+60 -> -0100');
448 assert.equal(moment().zone(+90).format('ZZ'), '-0130', '+90 -> -0130');
449 assert.equal(moment().zone(+120).format('ZZ'), '-0200', '+120 -> -0200');
450 });
0 /*global QUnit:false*/
1
2 import moment from '../moment';
3
4 export var test = QUnit.test;
5
6 export function module (name, lifecycle) {
7 QUnit.module(name, {
8 setup : function () {
9 moment.locale('en');
10 moment.createFromInputFallback = function () {
11 throw new Error('input not handled by moment');
12 };
13 if (lifecycle && lifecycle.setup) {
14 lifecycle.setup();
15 }
16 },
17 teardown : function () {
18 if (lifecycle && lifecycle.teardown) {
19 lifecycle.teardown();
20 }
21 }
22 });
23 }
24
25 export function localeModule (name, lifecycle) {
26 QUnit.module('locale:' + name, {
27 setup : function () {
28 moment.locale(name);
29 moment.createFromInputFallback = function () {
30 throw new Error('input not handled by moment');
31 };
32 if (lifecycle && lifecycle.setup) {
33 lifecycle.setup();
34 }
35 },
36 teardown : function () {
37 moment.locale('en');
38 if (lifecycle && lifecycle.teardown) {
39 lifecycle.teardown();
40 }
41 }
42 });
43 }
0 module.exports = function (grunt) {
1 grunt.registerTask('bump_version', function (version) {
2 if (!version || version.split('.').length !== 3) {
3 grunt.fail.fatal('malformed version. Use\n\n grunt bump_version:1.2.3');
4 }
5
6 grunt.config('string-replace.moment-js', {
7 files: {'src/moment.js': 'src/moment.js'},
8 options: {
9 replacements: [
10 {
11 pattern: /\/\/! version : .*/,
12 replacement: '//! version : ' + version
13 }, {
14 pattern: /moment\.version = '.*'/,
15 replacement: "moment.version = '" + version + "'"
16 }
17 ]
18 }
19 });
20
21 grunt.config('string-replace.package-json', {
22 files: {'package.json': 'package.json'},
23 options: {
24 replacements: [
25 {
26 pattern: /"version": .*/,
27 replacement: '"version": "' + version + '",'
28 }
29 ]
30 }
31 });
32
33 grunt.config('string-replace.component-json', {
34 files: {'component.json': 'component.json'},
35 options: {
36 replacements: [
37 {
38 pattern: /"version": .*/,
39 replacement: '"version": "' + version + '",'
40 }
41 ]
42 }
43 });
44
45 grunt.config('string-replace.moment-js-nuspec', {
46 files: {'Moment.js.nuspec': 'Moment.js.nuspec'},
47 options: {
48 replacements: [
49 {
50 pattern: /<version>.*<\/version>/,
51 replacement: '<version>' + version + '</version>'
52 }
53 ]
54 }
55 });
56
57 grunt.task.run([
58 'string-replace:moment-js',
59 'string-replace:package-json',
60 'string-replace:component-json',
61 'string-replace:moment-js-nuspec'
62 ]);
63 });
64 };
0 module.exports = function (grunt) {
1 // Pull requests do not have secure variables enabled for security reasons.
2 // Use this task before launching travis-sauce-browser task, so it would
3 // exit early and won't try connecting to SauceLabs without credentials.
4 grunt.registerTask('check-sauce-creds', function () {
5 if (process.env.SAUCE_USERNAME === undefined) {
6 grunt.log.writeln('No sauce credentials found');
7 grunt.task.clearQueue();
8 } else {
9 grunt.log.writeln('Sauce credentials found');
10 }
11 });
12 };
0 module.exports = function (grunt) {
1 grunt.registerTask('component', function () {
2 var config = JSON.parse(grunt.file.read('component.json'));
3
4 config.files = grunt.file.expand('locale/*.js');
5 config.files.unshift('moment.js');
6
7 grunt.file.write('component.json', JSON.stringify(config, true, 2) + '\n');
8 });
9 };
0
1 module.exports = function (grunt) {
2 grunt.registerTask('embedLocales', function () {
3 var config = grunt.config('embedLocales');
4
5 var files = grunt.file.expand(config.targetLocales);
6 var embeddedContents = determineEmbeddedContent(files);
7
8 var momentContents = grunt.file.read(config.moment);
9 var modifiedContents = momentContents.replace('/* EMBED_LOCALES */', function () {
10 // If we don't do this, $ symbols in locale files may get interpreted in
11 // the regex replacement
12 return embeddedContents;
13 });
14
15 grunt.file.write(config.dest, modifiedContents);
16 });
17
18 var languageReset = 'moment.locale(\'en\');';
19
20 function determineEmbeddedContent(files) {
21 var embeddedContent = '';
22 files.forEach(function (file) {
23 embeddedContent += transformFile(file);
24 });
25 embeddedContent += '\n ' + languageReset + '\n';
26 return embeddedContent;
27 }
28
29 var reTransform = /function \(factory\) \{[^]*\}(?=\(function \(moment\) \{)/gm;
30 var replaceWith =
31 'function (factory) {\n' +
32 ' factory(moment);\n' +
33 '}';
34
35 function transformFile(file) {
36 var fileContents = grunt.file.read(file);
37
38 if (!fileContents.match(reTransform)) {
39 grunt.warn('Warning: all locale files must use the common UMD wrapper pattern. Failed locale file: ' + file);
40 return '';
41 }
42
43 return fileContents.replace(reTransform, replaceWith);
44 }
45 };
46
0 var https = require('https'),
1 zlib = require('zlib'),
2 path = require('path'),
3 fs = require('fs');
4
5 var count = 0;
6 var resolved = 0;
7
8 var outputs = [];
9
10 var done;
11
12 function check() {
13 if (resolved === count) {
14 normalize();
15 display();
16 }
17 }
18
19 function makeBar(length) {
20 var i = '';
21 while (i.length < length) {
22 i += '=';
23 }
24 return i;
25 }
26
27 function normalize() {
28 var i,
29 max = 0,
30 max2 = 0;
31 for (i = 0; i < count; i++) {
32 max = Math.max(max, outputs[i].gzip);
33 max2 = Math.max(max2, outputs[i].original);
34 }
35 for (i = 0; i < count; i++) {
36 outputs[i].bargraph = makeBar((outputs[i].gzip / max) * 80);
37 outputs[i].bargraph2 = makeBar((outputs[i].original / max2) * 80);
38 }
39 }
40
41 function display() {
42 var i;
43 for (i = 0; i < count; i++) {
44 console.log(outputs[i].version + ' ' + outputs[i].gzip + ' ' + outputs[i].original);
45 console.log('gzip ' + outputs[i].bargraph);
46 console.log('orig ' + outputs[i].bargraph2);
47 }
48 done();
49 }
50
51 function getSizeAtVersion(version, path) {
52 var data = '',
53 op = {},
54
55 req = https.request({
56 host: 'raw.github.com',
57 port: 443,
58 path: '/timrwood/moment/' + version + path
59 }, function (res) {
60 res.setEncoding('utf8');
61 res.on('data', function (chunk) {
62 data += chunk;
63 });
64 res.on('end', function (e) {
65 zlib.gzip(data, function (error, result) {
66 op.version = version;
67 op.gzip = result.length;
68 op.original = data.length;
69 resolved++;
70 check();
71 });
72 });
73 });
74
75 req.on('error', function (e) {
76 console.log('problem with request: ' + e.message);
77 });
78 req.end();
79 count++;
80 outputs.push(op);
81 }
82
83 function getRemote() {
84 var oldVersions = '1.0.1 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.4.0'.split(' '),
85 newVersions = '1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.7.1'.split(' '),
86 i;
87
88 for (i = 0; i < oldVersions.length; i++) {
89 getSizeAtVersion(oldVersions[i], '/moment.min.js');
90 }
91 for (i = 0; i < newVersions.length; i++) {
92 getSizeAtVersion(newVersions[i], '/min/moment.min.js');
93 }
94 }
95
96 function getLocal() {
97 count++;
98 var op = {};
99 outputs.push(op);
100 fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
101 if (err) {
102 throw err;
103 }
104 zlib.gzip(data, function (error, result) {
105 op.version = '.next';
106 op.gzip = result.length;
107 op.original = data.length;
108 resolved++;
109 check();
110 });
111 });
112 }
113
114
115
116 module.exports = function (grunt) {
117 grunt.registerTask('history', 'Check the codebase filesize over different releases.', function () {
118 done = this.async();
119 getRemote();
120 getLocal();
121 });
122 };
0 module.exports = function (grunt) {
1 // If this fails you might need to follow:
2 //
3 // http://stackoverflow.com/questions/15181888/nuget-on-linux-error-getting-response-stream
4 //
5 // $ sudo mozroots --import --machine --sync
6 // $ sudo certmgr -ssl -m https://go.microsoft.com
7 // $ sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
8 // $ sudo certmgr -ssl -m https://nuget.org
9
10 grunt.config('nugetpack', {
11 dist: {
12 src: 'Moment.js.nuspec',
13 dest: './'
14 }
15 });
16 grunt.config('nugetpush', {
17 dist: {
18 src: 'Moment.js.*.nupkg'
19 }
20 });
21 grunt.config('clean.nuget', {
22 src: 'Moment.js.*.nupkg'
23 });
24
25 grunt.registerTask('nuget-publish', [
26 'nugetpack', 'nugetpush', 'clean:nuget'
27 ]);
28 };
0 module.exports = function (grunt) {
1 grunt.task.registerTask('qtest', 'run tests locally', function () {
2 var done = this.async();
3
4 var testrunner = require('qunit');
5
6 testrunner.options.log.assertions = false;
7 testrunner.options.log.tests = false;
8 testrunner.options.log.summary = false;
9 testrunner.options.log.testing = false;
10 testrunner.options.maxBlockDuration = 120000;
11
12 var tests;
13
14 if (grunt.option('only') != null) {
15 tests = grunt.file.expand.apply(null, grunt.option('only').split(',').map(function (file) {
16 if (file === 'moment') {
17 return 'build/umd/test/moment/*.js';
18 } else if (file === 'locale') {
19 return 'build/umd/test/locale/*.js';
20 } else {
21 return 'build/umd/test/' + file + '.js';
22 }
23 }));
24 } else {
25 tests = grunt.file.expand('build/umd/test/moment/*.js',
26 'build/umd/test/locale/*.js');
27 }
28
29 testrunner.run({
30 code: 'build/umd/moment.js',
31 tests: tests
32 }, function (err, report) {
33 if (err) {
34 console.log('woot', err, report);
35 done(err);
36 return;
37 }
38 err = null;
39 if (report.failed !== 0) {
40 err = new Error(report.failed + ' tests failed');
41 }
42 done(err);
43 });
44 });
45 };
0 var https = require('https'),
1 zlib = require('zlib'),
2 path = require('path'),
3 fs = require('fs');
4
5 var stable = '1.7.1',
6 done;
7
8 function getVersion(path, cb) {
9 var data = '',
10 req = https.request({
11 host: 'raw.github.com',
12 port: 443,
13 path: '/timrwood/moment/' + path
14 }, function (res) {
15 res.setEncoding('utf8');
16 res.on('data', function (chunk) {
17 data += chunk;
18 });
19 res.on('end', function (e) {
20 zlib.gzip(data, function (error, result) {
21 cb(data.length, result.length);
22 });
23 });
24 });
25 req.on('error', function (e) {
26 console.log('problem with request: ' + e.message);
27 });
28 req.end();
29 }
30
31 function printDiffs(stableLen, stableGzip, currentLen, currentGzip) {
32 var diff = currentLen - stableLen,
33 gzipDiff = currentGzip - stableGzip;
34
35 console.log('Filesize difference from current branch to ' + stable);
36 console.log(stable + ' ' + stableLen + ' / ' + stableGzip);
37 console.log('curr ' + currentLen + ' / ' + currentGzip);
38 console.log('diff ' + (diff > 0 ? '+' : '') + diff);
39 console.log('gzip ' + (gzipDiff > 0 ? '+' : '') + gzipDiff);
40 }
41
42
43 module.exports = function (grunt) {
44 grunt.registerTask('size', 'Check the codebase filesize against the latest stable version.', function () {
45 done = this.async();
46 fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
47 if (err) {
48 throw err;
49 }
50 zlib.gzip(data, function (error, result) {
51 getVersion(stable + '/min/moment.min.js', function (stableLength, stableGzipLength) {
52 printDiffs(stableLength, stableGzipLength, data.length, result.length);
53 done();
54 });
55 });
56 });
57 });
58 };
0 module.exports = function (grunt) {
1 var esperanto = require('esperanto');
2 var path = require('path');
3 var Promise = require('es6-promise').Promise;
4 var TMP_DIR = 'build/tmp';
5
6 function moveComments(code) {
7 var comments = [], rest = [];
8 code.split('\n').forEach(function (line) {
9 if (line.trim().slice(0, 3) === '//!') {
10 comments.push(line.trim());
11 } else {
12 rest.push(line);
13 }
14 });
15
16 return comments.concat([''], rest).join('\n');
17 }
18
19 var headerCache = {};
20 function getHeaderByFile(headerFile) {
21 if (!(headerFile in headerCache)) {
22 headerCache[headerFile] = grunt.file.read(headerFile);
23 }
24 return headerCache[headerFile];
25 }
26
27 function transpile(opts) {
28 // base, entry, skip, headerFile, skipLines, target
29 var umdName = opts.headerFile ? 'not_used' : opts.umdName,
30 header = opts.headerFile ? getHeaderByFile(opts.headerFile) : '',
31 skipLines = opts.skipLines ? opts.skipLines : 0;
32
33 return esperanto.bundle({
34 base: opts.base,
35 entry: opts.entry,
36 skip: opts.skip || []
37 }).then(function (bundle) {
38 var umd = bundle.toUmd({name: umdName}),
39 fixed = header + umd.code.split('\n').slice(skipLines).join('\n');
40 if (opts.moveComments) {
41 fixed = moveComments(fixed);
42 }
43 grunt.file.write(opts.target, fixed);
44 });
45 }
46
47 function transpileMany(opts) {
48 var batchSize = 50,
49 promise = Promise.resolve(null),
50 files = grunt.file.expand({cwd: opts.base}, opts.pattern),
51 i,
52 transpileOne = function (i) {
53 promise = promise.then(function () {
54 return Promise.all(files.slice(i, i + batchSize).map(function (file) {
55 return transpile({
56 base: opts.base,
57 entry: file,
58 headerFile: opts.headerFile,
59 skip: opts.skip,
60 skipLines: opts.skipLines,
61 moveComments: opts.moveComments,
62 target: path.join(opts.targetDir, file)
63 });
64 }));
65 });
66 };
67
68 for (i = 0; i < files.length; i += batchSize) {
69 transpileOne(i);
70 }
71
72 return promise;
73 }
74
75 function prepareTemp(base) {
76 var files = grunt.file.expand({cwd: base}, '**/*.js'),
77 tmpDir = TMP_DIR;
78 if (grunt.file.exists(tmpDir)) {
79 return;
80 }
81 files.forEach(function (file) {
82 grunt.file.copy(path.join(base, file), path.join(tmpDir, file));
83 });
84 }
85
86 function transpileCode(opts) {
87 var entry = opts.entry || path.basename(opts.target);
88 prepareTemp(opts.base);
89 grunt.file.write(path.join(TMP_DIR, entry), opts.code);
90 return transpile({
91 base: TMP_DIR,
92 entry: entry,
93 umdName: opts.umdName || 'not_used',
94 headerFile: opts.headerFile,
95 skipLines: opts.skipLines,
96 moveComments: opts.moveComments,
97 target: opts.target,
98 skip: opts.skip
99 });
100 }
101
102 function generateLocales(target, localeFiles) {
103 var files = localeFiles,
104 code = files.map(function (file) {
105 var identifier = path.basename(file, '.js').replace('-', '_');
106 return 'import ' + identifier + ' from "./' + file + '";';
107 }).join('\n');
108 return transpileCode({
109 base: 'src',
110 code: code,
111 target: target,
112 skip: ['moment'],
113 headerFile: 'templates/locale-header.js',
114 skipLines: 5
115 });
116 }
117
118 function generateMomentWithLocales(target, localeFiles) {
119 var files = localeFiles,
120 importCode = files.map(function (file) {
121 var identifier = path.basename(file, '.js').replace('-', '_');
122 var fileNoExt = file.replace('.js', '');
123 return 'import ' + identifier + ' from "./' + fileNoExt + '";';
124 }).join('\n'),
125 code = 'import * as moment_export from "./moment";\n\n' +
126 importCode + '\n\n' +
127 'export default moment_export;';
128
129 return transpileCode({
130 base: 'src',
131 code: code,
132 umdName: 'moment',
133 target: target
134 }).then(function () {
135 var code = grunt.file.read(target);
136 var getDefaultRegExp = new RegExp('var ([a-z$_]+) =\\s+{[^]\\s+get default \\(\\) { return ([a-z$_]+); }[^]\\s+}', '');
137 var crap = code.match(getDefaultRegExp);
138 if (crap.length !== 3) {
139 grunt.file.write('/tmp/crap.js', code);
140 throw new Error('Failed to detect get default crap, check /tmp/crap.js');
141 }
142 code = code.replace(getDefaultRegExp, '');
143
144 var buildExportVars = ['moment_with_locales', 'moment_with_locales_custom'];
145 buildExportVars.forEach(function (buildExportVar) {
146 var languageReset = buildExportVar + '.locale(\'en\');';
147 code = code.replace('var ' + buildExportVar + ' = ' + crap[1] + ';',
148 'var ' + buildExportVar + ' = ' + crap[2] + ';\n' +
149 ' ' + languageReset);
150 });
151
152 if (code.match('get default')) {
153 grunt.file.write('/tmp/crap.js', code);
154 throw new Error('Stupid shit es6 get default plaguing the code, check /tmp/crap.js');
155 }
156 grunt.file.write(target, code);
157 });
158 }
159
160 grunt.task.registerTask('transpile-raw', 'convert es6 to umd', function () {
161 var done = this.async();
162
163 transpile({
164 base: 'src',
165 entry: 'moment.js',
166 umdName: 'moment',
167 target: 'build/umd/moment.js',
168 moveComments: true
169 }).then(function () {
170 grunt.log.ok('build/umd/moment.js');
171 }).then(function () {
172 return transpileMany({
173 base: 'src',
174 pattern: 'locale/*.js',
175 headerFile: 'templates/locale-header.js',
176 skipLines: 5,
177 moveComments: true,
178 targetDir: 'build/umd',
179 skip: ['moment']
180 });
181 }).then(function () {
182 grunt.log.ok('build/umd/locale/*.js');
183 }).then(function () {
184 return transpileMany({
185 base: 'src',
186 pattern: 'test/moment/*.js',
187 headerFile: 'templates/test-header.js',
188 skipLines: 5,
189 moveComments: true,
190 targetDir: 'build/umd',
191 skip: ['moment']
192 });
193 }).then(function () {
194 grunt.log.ok('build/umd/test/moment/*.js');
195 }).then(function () {
196 return transpileMany({
197 base: 'src',
198 pattern: 'test/locale/*.js',
199 headerFile: 'templates/test-header.js',
200 skipLines: 5,
201 moveComments: true,
202 targetDir: 'build/umd',
203 skip: ['moment']
204 });
205 }).then(function () {
206 grunt.log.ok('build/umd/test/locale/*.js');
207 }).then(function () {
208 return generateLocales('build/umd/min/locales.js',
209 grunt.file.expand({cwd: 'src'}, 'locale/*.js'));
210 }).then(function () {
211 grunt.log.ok('build/umd/min/locales.js');
212 }).then(function () {
213 return generateMomentWithLocales('build/umd/min/moment-with-locales.js',
214 grunt.file.expand({cwd: 'src'}, 'locale/*.js'));
215 }).then(function () {
216 grunt.log.ok('build/umd/min/moment-with-locales.js');
217 }).then(done, function (e) {
218 grunt.log.error('error transpiling', e);
219 done(e);
220 });
221 });
222
223 grunt.task.registerTask('transpile-custom-raw',
224 'build just custom language bundles',
225 function (locales) {
226 var done = this.async();
227
228 var localeFiles = locales.split(',').map(function (locale) {
229 var file = grunt.file.expand({cwd: 'src'}, 'locale/' + locale + '.js');
230 if (file.length !== 1) {
231 // we failed to find a locale
232 done(new Error('could not find locale: ' + locale));
233 done = null;
234 } else {
235 return file[0];
236 }
237 });
238
239 // There was an issue with a locale
240 if (done == null) {
241 return;
242 }
243
244 return generateLocales(
245 'build/umd/min/locales.custom.js', localeFiles
246 ).then(function () {
247 grunt.log.ok('build/umd/min/locales.custom.js');
248 }).then(function () {
249 return generateMomentWithLocales('build/umd/min/moment-with-locales.custom.js',
250 localeFiles);
251 }).then(function () {
252 grunt.log.ok('build/umd/min/moment-with-locales.custom.js');
253 }).then(done, function (e) {
254 grunt.log.error('error transpiling-custom', e);
255 done(e);
256 });
257 });
258
259 grunt.config('clean.build', [
260 'build'
261 ]);
262
263 grunt.config('concat.tests', {
264 src: 'build/umd/test/**/*.js',
265 dest: 'build/umd/min/tests.js'
266 });
267
268 grunt.task.registerTask('transpile',
269 'builds all es5 files, optinally creating custom locales',
270 function (locales) {
271 var tasks = [
272 'clean:build',
273 'transpile-raw',
274 'concat:tests'
275 ];
276
277 if (locales) {
278 tasks.push('transpile-custom-raw:' + locales);
279 }
280
281 grunt.task.run(tasks);
282 });
283 };
0 module.exports = function (grunt) {
1 grunt.config('copy.index-files', {
2 expand: true,
3 cwd: 'build/umd/',
4 src: [
5 'moment.js',
6 'locale/*.js',
7 'min/locales.js',
8 'min/moment-with-locales.js',
9 'min/tests.js'
10 ],
11 dest: '.'
12 });
13
14 grunt.registerTask('update-index', ['copy:index-files']);
15 };
0 var fs = require('fs');
1
2
3 module.exports = function (grunt) {
4 var ZONE_TAB = '/usr/share/zoneinfo/zone.tab';
5
6 grunt.registerTask('zones', 'Run the unit tests in different timezones.', function () {
7 var done = this.async();
8
9 getAllTimezones(function (err, zones) {
10 if (err != null) {
11 throw err;
12 }
13 (function iterator(i) {
14 if (i >= zones.length) {
15 return done();
16 }
17 runTestsInZone(zones[i], function (err) {
18 if (err != null) {
19 throw err;
20 }
21 iterator(i + 1);
22 });
23 }(0));
24 });
25 });
26
27 function getAllTimezones (callback) {
28 fs.readFile(ZONE_TAB, 'ascii', function (err, content) {
29 if (err != null) {
30 callback(err);
31 }
32 callback(null, content.split(/\r\n|\r|\n/)
33 // remove empty and commented lines
34 .filter(function (line) {
35 return line && !/^#/.test(line);
36 })
37 // country code TAB coordinates TAB timezone
38 .map(function (line) {
39 return line.split('\t')[2];
40 }));
41 });
42 }
43
44 function runTestsInZone (zone, next) {
45 grunt.log.ok('Running tests in zone ' + zone);
46 grunt.util.spawn({
47 cmd: 'grunt',
48 opts: {
49 env: {
50 'PATH': process.env.PATH,
51 'TZ': zone
52 }
53 },
54 args: ['--no-color', 'nodeunit']
55 }, function (err, result, code) {
56 if (code !== 0) {
57 grunt.log.error(result.stdout.split(/\r\n|\r|\n/)
58 .filter(function (line) {
59 return /^(>>|Warning:|$)/.test(line);
60 })
61 .map(function (line) {
62 return (line.substr(0, 3) === '>> ' ? line.substr(3) : line);
63 })
64 .join('\n'));
65 }
66 next();
67 });
68 }
69 };
0 /*global define:false*/
1
2 import moment from "./moment";
3
4 define("moment", [], function () {
5 return moment;
6 });
0 /*global define:false*/
1
2 import moment from "./moment";
3
4 define([], function () {
5 return moment;
6 });
0 /*global window:false*/
1
2 import moment from "./moment";
3
4 window.moment = moment;
0 (function (global, factory) {
1 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
2 typeof define === 'function' && define.amd ? define(['moment'], factory) :
3 factory(global.moment)
4 }(this, function (moment) { 'use strict';
0 (function (global, factory) {
1 typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
2 typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
3 factory(global.moment)
4 }(this, function (moment) { 'use strict';