New upstream version 2.17.0+ds
Julien Puydt
7 years ago
0 | 0 | Changelog |
1 | 1 | ========= |
2 | ||
3 | ### 2.17.0 [Also available here](https://gist.github.com/ichernev/ed58f76fb95205eeac653d719972b90c) | |
4 | * Release Nov 22, 2016 | |
5 | ||
6 | * [#3435](https://github.com/moment/moment/pull/3435) [new locale] yo: Yoruba (Nigeria) locale | |
7 | * [#3595](https://github.com/moment/moment/pull/3595) [bugfix] Fix accidental reference to global "value" variable | |
8 | * [#3506](https://github.com/moment/moment/pull/3506) [bugfix] Fix invalid moments returning valid dates to method calls | |
9 | * [#3563](https://github.com/moment/moment/pull/3563) [locale] ca: Change future relative time | |
10 | * [#3504](https://github.com/moment/moment/pull/3504) [tests] Fixes [#3463](https://github.com/moment/moment/issues/3463), parseZone not handling Z correctly (tests only) | |
11 | * [#3591](https://github.com/moment/moment/pull/3591) [misc] typescript: update typescript to 2.0.8, add strictNullChecks=true | |
12 | * [#3597](https://github.com/moment/moment/pull/3597) [misc] Fixed capitalization in nuget spec | |
2 | 13 | |
3 | 14 | ### 2.16.0 [See full changelog](https://gist.github.com/ichernev/17bffc1005a032cb1a8ac4c1558b4994) |
4 | 15 | * Release Nov 9, 2016 |
1 | 1 | <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> |
2 | 2 | <metadata> |
3 | 3 | <id>Moment.js</id> |
4 | <version>2.16.0</version> | |
4 | <version>2.17.0</version> | |
5 | 5 | <authors>Tim Wood, Iskren Chernev, Moment.js contributors</authors> |
6 | 6 | <owners>Cory Deppen, Iskren Chernev</owners> |
7 | <description>A lightweight javascript date library for parsing, manipulating, and formatting dates.</description> | |
7 | <description>A lightweight JavaScript date library for parsing, manipulating, and formatting dates.</description> | |
8 | 8 | <releaseNotes> |
9 | * Release Nov 9, 2016 -- full changelog https://gist.github.com/ichernev/17bffc1005a032cb1a8ac4c1558b4994 | |
10 | * [3515] [feature] Default to current week (fixes #2300) | |
11 | * [3546] [bugfix] lazy loading of locales | |
12 | * [3523] [3581] Fix multiple issue in parseZone | |
9 | * Release Nov 22, 2016 -- full changelog https://gist.github.com/ichernev/ed58f76fb95205eeac653d719972b90c | |
10 | * [#3591](https://github.com/moment/moment/pull/3591) [misc] typescript: update typescript to 2.0.8, add strictNullChecks=true | |
13 | 11 | </releaseNotes> |
14 | 12 | <projectUrl>http://momentjs.com/</projectUrl> |
15 | 13 | <iconUrl>http://pbs.twimg.com/profile_images/482670411402858496/Xrtdc94q_normal.png</iconUrl> |
0 | 0 | { |
1 | 1 | "name": "moment", |
2 | "version": "2.16.0", | |
2 | "version": "2.17.0", | |
3 | 3 | "main": "moment.js", |
4 | 4 | "description": "Parse, validate, manipulate, and display dates in JavaScript.", |
5 | 5 | "files": [ |
109 | 109 | "locale/uz.js", |
110 | 110 | "locale/vi.js", |
111 | 111 | "locale/x-pseudo.js", |
112 | "locale/yo.js", | |
112 | 113 | "locale/zh-cn.js", |
113 | 114 | "locale/zh-hk.js", |
114 | 115 | "locale/zh-tw.js" |
44 | 44 | sameElse : 'L' |
45 | 45 | }, |
46 | 46 | relativeTime : { |
47 | future : 'en %s', | |
47 | future : 'd\'aquí %s', | |
48 | 48 | past : 'fa %s', |
49 | 49 | s : 'uns segons', |
50 | 50 | m : 'un minut', |
0 | //! moment.js locale configuration | |
1 | //! locale : Yoruba Nigeria (yo) | |
2 | //! author : Atolagbe Abisoye : https://github.com/andela-batolagbe | |
3 | ||
4 | ;(function (global, factory) { | |
5 | typeof exports === 'object' && typeof module !== 'undefined' | |
6 | && typeof require === 'function' ? 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 yo = moment.defineLocale('yo', { | |
13 | months : 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'), | |
14 | monthsShort : 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'), | |
15 | weekdays : 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'), | |
16 | weekdaysShort : 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'), | |
17 | weekdaysMin : 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'), | |
18 | longDateFormat : { | |
19 | LT : 'h:mm A', | |
20 | LTS : 'h:mm:ss A', | |
21 | L : 'DD/MM/YYYY', | |
22 | LL : 'D MMMM YYYY', | |
23 | LLL : 'D MMMM YYYY h:mm A', | |
24 | LLLL : 'dddd, D MMMM YYYY h:mm A' | |
25 | }, | |
26 | calendar : { | |
27 | sameDay : '[Ònì ni] LT', | |
28 | nextDay : '[Ọ̀la ni] LT', | |
29 | nextWeek : 'dddd [Ọsẹ̀ tón\'bọ] [ni] LT', | |
30 | lastDay : '[Àna ni] LT', | |
31 | lastWeek : 'dddd [Ọsẹ̀ tólọ́] [ni] LT', | |
32 | sameElse : 'L' | |
33 | }, | |
34 | relativeTime : { | |
35 | future : 'ní %s', | |
36 | past : '%s kọjá', | |
37 | s : 'ìsẹjú aayá die', | |
38 | m : 'ìsẹjú kan', | |
39 | mm : 'ìsẹjú %d', | |
40 | h : 'wákati kan', | |
41 | hh : 'wákati %d', | |
42 | d : 'ọjọ́ kan', | |
43 | dd : 'ọjọ́ %d', | |
44 | M : 'osù kan', | |
45 | MM : 'osù %d', | |
46 | y : 'ọdún kan', | |
47 | yy : 'ọdún %d' | |
48 | }, | |
49 | ordinalParse : /ọjọ́\s\d{1,2}/, | |
50 | ordinal : 'ọjọ́ %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 yo; | |
58 | ||
59 | }))); |
5 | 5 | Package.describe({ |
6 | 6 | name: packageName, |
7 | 7 | summary: 'Moment.js (official): parse, validate, manipulate, and display dates - official Meteor packaging', |
8 | version: '2.16.0', | |
8 | version: '2.17.0', | |
9 | 9 | git: 'https://github.com/moment/moment.git' |
10 | 10 | }); |
11 | 11 |
1335 | 1335 | sameElse : 'L' |
1336 | 1336 | }, |
1337 | 1337 | relativeTime : { |
1338 | future : 'en %s', | |
1338 | future : 'd\'aquí %s', | |
1339 | 1339 | past : 'fa %s', |
1340 | 1340 | s : 'uns segons', |
1341 | 1341 | m : 'un minut', |
8269 | 8269 | }); |
8270 | 8270 | |
8271 | 8271 | //! moment.js locale configuration |
8272 | //! locale : Yoruba Nigeria (yo) | |
8273 | //! author : Atolagbe Abisoye : https://github.com/andela-batolagbe | |
8274 | ||
8275 | moment.defineLocale('yo', { | |
8276 | months : 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'), | |
8277 | monthsShort : 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'), | |
8278 | weekdays : 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'), | |
8279 | weekdaysShort : 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'), | |
8280 | weekdaysMin : 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'), | |
8281 | longDateFormat : { | |
8282 | LT : 'h:mm A', | |
8283 | LTS : 'h:mm:ss A', | |
8284 | L : 'DD/MM/YYYY', | |
8285 | LL : 'D MMMM YYYY', | |
8286 | LLL : 'D MMMM YYYY h:mm A', | |
8287 | LLLL : 'dddd, D MMMM YYYY h:mm A' | |
8288 | }, | |
8289 | calendar : { | |
8290 | sameDay : '[Ònì ni] LT', | |
8291 | nextDay : '[Ọ̀la ni] LT', | |
8292 | nextWeek : 'dddd [Ọsẹ̀ tón\'bọ] [ni] LT', | |
8293 | lastDay : '[Àna ni] LT', | |
8294 | lastWeek : 'dddd [Ọsẹ̀ tólọ́] [ni] LT', | |
8295 | sameElse : 'L' | |
8296 | }, | |
8297 | relativeTime : { | |
8298 | future : 'ní %s', | |
8299 | past : '%s kọjá', | |
8300 | s : 'ìsẹjú aayá die', | |
8301 | m : 'ìsẹjú kan', | |
8302 | mm : 'ìsẹjú %d', | |
8303 | h : 'wákati kan', | |
8304 | hh : 'wákati %d', | |
8305 | d : 'ọjọ́ kan', | |
8306 | dd : 'ọjọ́ %d', | |
8307 | M : 'osù kan', | |
8308 | MM : 'osù %d', | |
8309 | y : 'ọdún kan', | |
8310 | yy : 'ọdún %d' | |
8311 | }, | |
8312 | ordinalParse : /ọjọ́\s\d{1,2}/, | |
8313 | ordinal : 'ọjọ́ %d', | |
8314 | week : { | |
8315 | dow : 1, // Monday is the first day of the week. | |
8316 | doy : 4 // The week that contains Jan 4th is the first week of the year. | |
8317 | } | |
8318 | }); | |
8319 | ||
8320 | //! moment.js locale configuration | |
8272 | 8321 | //! locale : Chinese (China) [zh-cn] |
8273 | 8322 | //! author : suupic : https://github.com/suupic |
8274 | 8323 | //! author : Zeno Zeng : https://github.com/zenozeng |
35 | 35 | } |
36 | 36 | |
37 | 37 | function isNumber(input) { |
38 | return typeof value === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
38 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
39 | 39 | } |
40 | 40 | |
41 | 41 | function isDate(input) { |
227 | 227 | function Moment(config) { |
228 | 228 | copyConfig(this, config); |
229 | 229 | this._d = new Date(config._d != null ? config._d.getTime() : NaN); |
230 | if (!this.isValid()) { | |
231 | this._d = new Date(NaN); | |
232 | } | |
230 | 233 | // Prevent infinite loop in case updateOffset creates new moment |
231 | 234 | // objects. |
232 | 235 | if (updateInProgress === false) { |
4254 | 4257 | // Side effect imports |
4255 | 4258 | |
4256 | 4259 | //! moment.js |
4257 | //! version : 2.16.0 | |
4260 | //! version : 2.17.0 | |
4258 | 4261 | //! authors : Tim Wood, Iskren Chernev, Moment.js contributors |
4259 | 4262 | //! license : MIT |
4260 | 4263 | //! momentjs.com |
4261 | 4264 | |
4262 | hooks.version = '2.16.0'; | |
4265 | hooks.version = '2.17.0'; | |
4263 | 4266 | |
4264 | 4267 | setHookCallback(createLocal); |
4265 | 4268 | |
5622 | 5625 | sameElse : 'L' |
5623 | 5626 | }, |
5624 | 5627 | relativeTime : { |
5625 | future : 'en %s', | |
5628 | future : 'd\'aquí %s', | |
5626 | 5629 | past : 'fa %s', |
5627 | 5630 | s : 'uns segons', |
5628 | 5631 | m : 'un minut', |
12552 | 12555 | }); |
12553 | 12556 | |
12554 | 12557 | //! moment.js locale configuration |
12558 | //! locale : Yoruba Nigeria (yo) | |
12559 | //! author : Atolagbe Abisoye : https://github.com/andela-batolagbe | |
12560 | ||
12561 | hooks.defineLocale('yo', { | |
12562 | months : 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'), | |
12563 | monthsShort : 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'), | |
12564 | weekdays : 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'), | |
12565 | weekdaysShort : 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'), | |
12566 | weekdaysMin : 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'), | |
12567 | longDateFormat : { | |
12568 | LT : 'h:mm A', | |
12569 | LTS : 'h:mm:ss A', | |
12570 | L : 'DD/MM/YYYY', | |
12571 | LL : 'D MMMM YYYY', | |
12572 | LLL : 'D MMMM YYYY h:mm A', | |
12573 | LLLL : 'dddd, D MMMM YYYY h:mm A' | |
12574 | }, | |
12575 | calendar : { | |
12576 | sameDay : '[Ònì ni] LT', | |
12577 | nextDay : '[Ọ̀la ni] LT', | |
12578 | nextWeek : 'dddd [Ọsẹ̀ tón\'bọ] [ni] LT', | |
12579 | lastDay : '[Àna ni] LT', | |
12580 | lastWeek : 'dddd [Ọsẹ̀ tólọ́] [ni] LT', | |
12581 | sameElse : 'L' | |
12582 | }, | |
12583 | relativeTime : { | |
12584 | future : 'ní %s', | |
12585 | past : '%s kọjá', | |
12586 | s : 'ìsẹjú aayá die', | |
12587 | m : 'ìsẹjú kan', | |
12588 | mm : 'ìsẹjú %d', | |
12589 | h : 'wákati kan', | |
12590 | hh : 'wákati %d', | |
12591 | d : 'ọjọ́ kan', | |
12592 | dd : 'ọjọ́ %d', | |
12593 | M : 'osù kan', | |
12594 | MM : 'osù %d', | |
12595 | y : 'ọdún kan', | |
12596 | yy : 'ọdún %d' | |
12597 | }, | |
12598 | ordinalParse : /ọjọ́\s\d{1,2}/, | |
12599 | ordinal : 'ọjọ́ %d', | |
12600 | week : { | |
12601 | dow : 1, // Monday is the first day of the week. | |
12602 | doy : 4 // The week that contains Jan 4th is the first week of the year. | |
12603 | } | |
12604 | }); | |
12605 | ||
12606 | //! moment.js locale configuration | |
12555 | 12607 | //! locale : Chinese (China) [zh-cn] |
12556 | 12608 | //! author : suupic : https://github.com/suupic |
12557 | 12609 | //! author : Zeno Zeng : https://github.com/zenozeng |
7118 | 7118 | }); |
7119 | 7119 | |
7120 | 7120 | test('suffix', function (assert) { |
7121 | assert.equal(moment(30000).from(0), 'en uns segons', 'prefix'); | |
7121 | assert.equal(moment(30000).from(0), 'd\'aquí uns segons', 'prefix'); | |
7122 | 7122 | assert.equal(moment(0).from(30000), 'fa uns segons', 'suffix'); |
7123 | 7123 | }); |
7124 | 7124 | |
7127 | 7127 | }); |
7128 | 7128 | |
7129 | 7129 | test('fromNow', function (assert) { |
7130 | assert.equal(moment().add({s: 30}).fromNow(), 'en uns segons', 'en uns segons'); | |
7131 | assert.equal(moment().add({d: 5}).fromNow(), 'en 5 dies', 'en 5 dies'); | |
7130 | assert.equal(moment().add({s: 30}).fromNow(), 'd\'aquí uns segons', 'd\'aquí uns segons'); | |
7131 | assert.equal(moment().add({d: 5}).fromNow(), 'd\'aquí 5 dies', 'd\'aquí 5 dies'); | |
7132 | 7132 | }); |
7133 | 7133 | |
7134 | 7134 | test('calendar day', function (assert) { |
49670 | 49670 | assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', 'Jan 8 2012 should be week 1'); |
49671 | 49671 | assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2'); |
49672 | 49672 | assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2'); |
49673 | }); | |
49674 | ||
49675 | }))); | |
49676 | ||
49677 | ||
49678 | ;(function (global, factory) { | |
49679 | typeof exports === 'object' && typeof module !== 'undefined' | |
49680 | && typeof require === 'function' ? factory(require('../../moment')) : | |
49681 | typeof define === 'function' && define.amd ? define(['../../moment'], factory) : | |
49682 | factory(global.moment) | |
49683 | }(this, (function (moment) { 'use strict'; | |
49684 | ||
49685 | function each(array, callback) { | |
49686 | var i; | |
49687 | for (i = 0; i < array.length; i++) { | |
49688 | callback(array[i], i, array); | |
49689 | } | |
49690 | } | |
49691 | ||
49692 | function objectKeys(obj) { | |
49693 | if (Object.keys) { | |
49694 | return Object.keys(obj); | |
49695 | } else { | |
49696 | // IE8 | |
49697 | var res = [], i; | |
49698 | for (i in obj) { | |
49699 | if (obj.hasOwnProperty(i)) { | |
49700 | res.push(i); | |
49701 | } | |
49702 | } | |
49703 | return res; | |
49704 | } | |
49705 | } | |
49706 | ||
49707 | // Pick the first defined of two or three arguments. | |
49708 | ||
49709 | function defineCommonLocaleTests(locale, options) { | |
49710 | test('lenient ordinal parsing', function (assert) { | |
49711 | var i, ordinalStr, testMoment; | |
49712 | for (i = 1; i <= 31; ++i) { | |
49713 | ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); | |
49714 | testMoment = moment(ordinalStr, 'YYYY MM Do'); | |
49715 | assert.equal(testMoment.year(), 2014, | |
49716 | 'lenient ordinal parsing ' + i + ' year check'); | |
49717 | assert.equal(testMoment.month(), 0, | |
49718 | 'lenient ordinal parsing ' + i + ' month check'); | |
49719 | assert.equal(testMoment.date(), i, | |
49720 | 'lenient ordinal parsing ' + i + ' date check'); | |
49721 | } | |
49722 | }); | |
49723 | ||
49724 | test('lenient ordinal parsing of number', function (assert) { | |
49725 | var i, testMoment; | |
49726 | for (i = 1; i <= 31; ++i) { | |
49727 | testMoment = moment('2014 01 ' + i, 'YYYY MM Do'); | |
49728 | assert.equal(testMoment.year(), 2014, | |
49729 | 'lenient ordinal parsing of number ' + i + ' year check'); | |
49730 | assert.equal(testMoment.month(), 0, | |
49731 | 'lenient ordinal parsing of number ' + i + ' month check'); | |
49732 | assert.equal(testMoment.date(), i, | |
49733 | 'lenient ordinal parsing of number ' + i + ' date check'); | |
49734 | } | |
49735 | }); | |
49736 | ||
49737 | test('strict ordinal parsing', function (assert) { | |
49738 | var i, ordinalStr, testMoment; | |
49739 | for (i = 1; i <= 31; ++i) { | |
49740 | ordinalStr = moment([2014, 0, i]).format('YYYY MM Do'); | |
49741 | testMoment = moment(ordinalStr, 'YYYY MM Do', true); | |
49742 | assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i); | |
49743 | } | |
49744 | }); | |
49745 | ||
49746 | test('meridiem invariant', function (assert) { | |
49747 | var h, m, t1, t2; | |
49748 | for (h = 0; h < 24; ++h) { | |
49749 | for (m = 0; m < 60; m += 15) { | |
49750 | t1 = moment.utc([2000, 0, 1, h, m]); | |
49751 | t2 = moment.utc(t1.format('A h:mm'), 'A h:mm'); | |
49752 | assert.equal(t2.format('HH:mm'), t1.format('HH:mm'), | |
49753 | 'meridiem at ' + t1.format('HH:mm')); | |
49754 | } | |
49755 | } | |
49756 | }); | |
49757 | ||
49758 | test('date format correctness', function (assert) { | |
49759 | var data, tokens; | |
49760 | data = moment.localeData()._longDateFormat; | |
49761 | tokens = objectKeys(data); | |
49762 | each(tokens, function (srchToken) { | |
49763 | // Check each format string to make sure it does not contain any | |
49764 | // tokens that need to be expanded. | |
49765 | each(tokens, function (baseToken) { | |
49766 | // strip escaped sequences | |
49767 | var format = data[baseToken].replace(/(\[[^\]]*\])/g, ''); | |
49768 | assert.equal(false, !!~format.indexOf(srchToken), | |
49769 | 'contains ' + srchToken + ' in ' + baseToken); | |
49770 | }); | |
49771 | }); | |
49772 | }); | |
49773 | ||
49774 | test('month parsing correctness', function (assert) { | |
49775 | var i, m; | |
49776 | ||
49777 | if (locale === 'tr') { | |
49778 | // I can't fix it :( | |
49779 | expect(0); | |
49780 | return; | |
49781 | } | |
49782 | function tester(format) { | |
49783 | var r; | |
49784 | r = moment(m.format(format), format); | |
49785 | assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format); | |
49786 | r = moment(m.format(format).toLocaleUpperCase(), format); | |
49787 | assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper'); | |
49788 | r = moment(m.format(format).toLocaleLowerCase(), format); | |
49789 | assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower'); | |
49790 | ||
49791 | r = moment(m.format(format), format, true); | |
49792 | assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict'); | |
49793 | r = moment(m.format(format).toLocaleUpperCase(), format, true); | |
49794 | assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict'); | |
49795 | r = moment(m.format(format).toLocaleLowerCase(), format, true); | |
49796 | assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict'); | |
49797 | } | |
49798 | ||
49799 | for (i = 0; i < 12; ++i) { | |
49800 | m = moment([2015, i, 15, 18]); | |
49801 | tester('MMM'); | |
49802 | tester('MMM.'); | |
49803 | tester('MMMM'); | |
49804 | tester('MMMM.'); | |
49805 | } | |
49806 | }); | |
49807 | ||
49808 | test('weekday parsing correctness', function (assert) { | |
49809 | var i, m; | |
49810 | ||
49811 | if (locale === 'tr' || locale === 'az' || locale === 'ro') { | |
49812 | // tr, az: There is a lower-case letter (ı), that converted to | |
49813 | // upper then lower changes to i | |
49814 | // ro: there is the letter ț which behaves weird under IE8 | |
49815 | expect(0); | |
49816 | return; | |
49817 | } | |
49818 | function tester(format) { | |
49819 | var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format + ' ' + m.toISOString(); | |
49820 | r = moment(m.format(format), format); | |
49821 | assert.equal(r.weekday(), m.weekday(), baseMsg); | |
49822 | r = moment(m.format(format).toLocaleUpperCase(), format); | |
49823 | assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper'); | |
49824 | r = moment(m.format(format).toLocaleLowerCase(), format); | |
49825 | assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower'); | |
49826 | ||
49827 | r = moment(m.format(format), format, true); | |
49828 | assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict'); | |
49829 | r = moment(m.format(format).toLocaleUpperCase(), format, true); | |
49830 | assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict'); | |
49831 | r = moment(m.format(format).toLocaleLowerCase(), format, true); | |
49832 | assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict'); | |
49833 | } | |
49834 | ||
49835 | for (i = 0; i < 7; ++i) { | |
49836 | m = moment.utc([2015, 0, i + 1, 18]); | |
49837 | tester('dd'); | |
49838 | tester('ddd'); | |
49839 | tester('dddd'); | |
49840 | } | |
49841 | }); | |
49842 | } | |
49843 | ||
49844 | function setupDeprecationHandler(test, moment$$1, scope) { | |
49845 | test._expectedDeprecations = null; | |
49846 | test._observedDeprecations = null; | |
49847 | test._oldSupress = moment$$1.suppressDeprecationWarnings; | |
49848 | moment$$1.suppressDeprecationWarnings = true; | |
49849 | test.expectedDeprecations = function () { | |
49850 | test._expectedDeprecations = arguments; | |
49851 | test._observedDeprecations = []; | |
49852 | }; | |
49853 | moment$$1.deprecationHandler = function (name, msg) { | |
49854 | var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations); | |
49855 | if (deprecationId === -1) { | |
49856 | throw new Error('Unexpected deprecation thrown name=' + | |
49857 | name + ' msg=' + msg); | |
49858 | } | |
49859 | test._observedDeprecations[deprecationId] = 1; | |
49860 | }; | |
49861 | } | |
49862 | ||
49863 | function teardownDeprecationHandler(test, moment$$1, scope) { | |
49864 | moment$$1.suppressDeprecationWarnings = test._oldSupress; | |
49865 | ||
49866 | if (test._expectedDeprecations != null) { | |
49867 | var missedDeprecations = []; | |
49868 | each(test._expectedDeprecations, function (deprecationPattern, id) { | |
49869 | if (test._observedDeprecations[id] !== 1) { | |
49870 | missedDeprecations.push(deprecationPattern); | |
49871 | } | |
49872 | }); | |
49873 | if (missedDeprecations.length !== 0) { | |
49874 | throw new Error('Expected deprecation warnings did not happen: ' + | |
49875 | missedDeprecations.join(' ')); | |
49876 | } | |
49877 | } | |
49878 | } | |
49879 | ||
49880 | function matchedDeprecation(name, msg, deprecations) { | |
49881 | if (deprecations == null) { | |
49882 | return -1; | |
49883 | } | |
49884 | for (var i = 0; i < deprecations.length; ++i) { | |
49885 | if (name != null && name === deprecations[i]) { | |
49886 | return i; | |
49887 | } | |
49888 | if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) { | |
49889 | return i; | |
49890 | } | |
49891 | } | |
49892 | return -1; | |
49893 | } | |
49894 | ||
49895 | /*global QUnit:false*/ | |
49896 | ||
49897 | var test = QUnit.test; | |
49898 | ||
49899 | var expect = QUnit.expect; | |
49900 | ||
49901 | ||
49902 | ||
49903 | function localeModule (name, lifecycle) { | |
49904 | QUnit.module('locale:' + name, { | |
49905 | setup : function () { | |
49906 | moment.locale(name); | |
49907 | moment.createFromInputFallback = function (config) { | |
49908 | throw new Error('input not handled by moment: ' + config._i); | |
49909 | }; | |
49910 | setupDeprecationHandler(test, moment, 'locale'); | |
49911 | if (lifecycle && lifecycle.setup) { | |
49912 | lifecycle.setup(); | |
49913 | } | |
49914 | }, | |
49915 | teardown : function () { | |
49916 | moment.locale('en'); | |
49917 | teardownDeprecationHandler(test, moment, 'locale'); | |
49918 | if (lifecycle && lifecycle.teardown) { | |
49919 | lifecycle.teardown(); | |
49920 | } | |
49921 | } | |
49922 | }); | |
49923 | defineCommonLocaleTests(name, -1, -1); | |
49924 | } | |
49925 | ||
49926 | localeModule('yo'); | |
49927 | ||
49928 | test('parse', function (assert) { | |
49929 | var tests = 'Sẹ́rẹ́ Sẹ́r_Èrèlè Èrl_Ẹrẹ̀nà Ẹrn_Ìgbé Ìgb_Èbibi Èbi_Òkùdu Òkù_Agẹmo Agẹ_Ògún Ògú_Owewe Owe_Ọ̀wàrà Ọ̀wà_Bélú Bél_Ọ̀pẹ̀̀ Ọ̀pẹ̀̀'.split('_'), i; | |
49930 | function equalTest(input, mmm, i) { | |
49931 | assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1)); | |
49932 | } | |
49933 | for (i = 0; i < 12; i++) { | |
49934 | tests[i] = tests[i].split(' '); | |
49935 | equalTest(tests[i][0], 'MMM', i); | |
49936 | equalTest(tests[i][1], 'MMM', i); | |
49937 | equalTest(tests[i][0], 'MMMM', i); | |
49938 | equalTest(tests[i][1], 'MMMM', i); | |
49939 | equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i); | |
49940 | equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i); | |
49941 | equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i); | |
49942 | equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i); | |
49943 | } | |
49944 | }); | |
49945 | ||
49946 | test('format', function (assert) { | |
49947 | var a = [ | |
49948 | ['dddd, MMMM Do YYYY, h:mm:ss a', 'Àìkú, Èrèlè ọjọ́ 14 2010, 3:25:50 pm'], | |
49949 | ['ddd, hA', 'Àìk, 3PM'], | |
49950 | ['M Mo MM MMMM MMM', '2 ọjọ́ 2 02 Èrèlè Èrl'], | |
49951 | ['YYYY YY', '2010 10'], | |
49952 | ['D Do DD', '14 ọjọ́ 14 14'], | |
49953 | ['d do dddd ddd dd', '0 ọjọ́ 0 Àìkú Àìk Àì'], | |
49954 | ['DDD DDDo DDDD', '45 ọjọ́ 45 045'], | |
49955 | ['w wo ww', '6 ọjọ́ 6 06'], | |
49956 | ['h hh', '3 03'], | |
49957 | ['H HH', '15 15'], | |
49958 | ['m mm', '25 25'], | |
49959 | ['s ss', '50 50'], | |
49960 | ['a A', 'pm PM'], | |
49961 | ['[the] DDDo [day of the year]', 'the ọjọ́ 45 day of the year'], | |
49962 | ['LTS', '3:25:50 PM'], | |
49963 | ['L', '14/02/2010'], | |
49964 | ['LL', '14 Èrèlè 2010'], | |
49965 | ['LLL', '14 Èrèlè 2010 3:25 PM'], | |
49966 | ['LLLL', 'Àìkú, 14 Èrèlè 2010 3:25 PM'], | |
49967 | ['l', '14/2/2010'], | |
49968 | ['ll', '14 Èrl 2010'], | |
49969 | ['lll', '14 Èrl 2010 3:25 PM'], | |
49970 | ['llll', 'Àìk, 14 Èrl 2010 3:25 PM'] | |
49971 | ], | |
49972 | b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), | |
49973 | i; | |
49974 | for (i = 0; i < a.length; i++) { | |
49975 | assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); | |
49976 | } | |
49977 | }); | |
49978 | ||
49979 | test('format ordinal', function (assert) { | |
49980 | assert.equal(moment([2011, 0, 1]).format('DDDo'), 'ọjọ́ 1', 'ọjọ́ 1'); | |
49981 | assert.equal(moment([2011, 0, 2]).format('DDDo'), 'ọjọ́ 2', 'ọjọ́ 2'); | |
49982 | assert.equal(moment([2011, 0, 3]).format('DDDo'), 'ọjọ́ 3', 'ọjọ́ 3'); | |
49983 | assert.equal(moment([2011, 0, 4]).format('DDDo'), 'ọjọ́ 4', 'ọjọ́ 4'); | |
49984 | assert.equal(moment([2011, 0, 5]).format('DDDo'), 'ọjọ́ 5', 'ọjọ́ 5'); | |
49985 | assert.equal(moment([2011, 0, 6]).format('DDDo'), 'ọjọ́ 6', 'ọjọ́ 6'); | |
49986 | assert.equal(moment([2011, 0, 7]).format('DDDo'), 'ọjọ́ 7', 'ọjọ́ 7'); | |
49987 | assert.equal(moment([2011, 0, 8]).format('DDDo'), 'ọjọ́ 8', 'ọjọ́ 8'); | |
49988 | assert.equal(moment([2011, 0, 9]).format('DDDo'), 'ọjọ́ 9', 'ọjọ́ 9'); | |
49989 | assert.equal(moment([2011, 0, 10]).format('DDDo'), 'ọjọ́ 10', 'ọjọ́ 10'); | |
49990 | ||
49991 | assert.equal(moment([2011, 0, 11]).format('DDDo'), 'ọjọ́ 11', 'ọjọ́ 11'); | |
49992 | assert.equal(moment([2011, 0, 12]).format('DDDo'), 'ọjọ́ 12', 'ọjọ́ 12'); | |
49993 | assert.equal(moment([2011, 0, 13]).format('DDDo'), 'ọjọ́ 13', 'ọjọ́ 13'); | |
49994 | assert.equal(moment([2011, 0, 14]).format('DDDo'), 'ọjọ́ 14', 'ọjọ́ 14'); | |
49995 | assert.equal(moment([2011, 0, 15]).format('DDDo'), 'ọjọ́ 15', 'ọjọ́ 15'); | |
49996 | assert.equal(moment([2011, 0, 16]).format('DDDo'), 'ọjọ́ 16', 'ọjọ́ 16'); | |
49997 | assert.equal(moment([2011, 0, 17]).format('DDDo'), 'ọjọ́ 17', 'ọjọ́ 17'); | |
49998 | assert.equal(moment([2011, 0, 18]).format('DDDo'), 'ọjọ́ 18', 'ọjọ́ 18'); | |
49999 | assert.equal(moment([2011, 0, 19]).format('DDDo'), 'ọjọ́ 19', 'ọjọ́ 19'); | |
50000 | assert.equal(moment([2011, 0, 20]).format('DDDo'), 'ọjọ́ 20', 'ọjọ́ 20'); | |
50001 | ||
50002 | assert.equal(moment([2011, 0, 21]).format('DDDo'), 'ọjọ́ 21', 'ọjọ́ 21'); | |
50003 | assert.equal(moment([2011, 0, 22]).format('DDDo'), 'ọjọ́ 22', 'ọjọ́ 22'); | |
50004 | assert.equal(moment([2011, 0, 23]).format('DDDo'), 'ọjọ́ 23', 'ọjọ́ 23'); | |
50005 | assert.equal(moment([2011, 0, 24]).format('DDDo'), 'ọjọ́ 24', 'ọjọ́ 24'); | |
50006 | assert.equal(moment([2011, 0, 25]).format('DDDo'), 'ọjọ́ 25', 'ọjọ́ 25'); | |
50007 | assert.equal(moment([2011, 0, 26]).format('DDDo'), 'ọjọ́ 26', 'ọjọ́ 26'); | |
50008 | assert.equal(moment([2011, 0, 27]).format('DDDo'), 'ọjọ́ 27', 'ọjọ́ 27'); | |
50009 | assert.equal(moment([2011, 0, 28]).format('DDDo'), 'ọjọ́ 28', 'ọjọ́ 28'); | |
50010 | assert.equal(moment([2011, 0, 29]).format('DDDo'), 'ọjọ́ 29', 'ọjọ́ 29'); | |
50011 | assert.equal(moment([2011, 0, 30]).format('DDDo'), 'ọjọ́ 30', 'ọjọ́ 30'); | |
50012 | ||
50013 | assert.equal(moment([2011, 0, 31]).format('DDDo'), 'ọjọ́ 31', 'ọjọ́ 31'); | |
50014 | }); | |
50015 | ||
50016 | test('format month', function (assert) { | |
50017 | var expected = 'Sẹ́rẹ́ Sẹ́r_Èrèlè Èrl_Ẹrẹ̀nà Ẹrn_Ìgbé Ìgb_Èbibi Èbi_Òkùdu Òkù_Agẹmo Agẹ_Ògún Ògú_Owewe Owe_Ọ̀wàrà Ọ̀wà_Bélú Bél_Ọ̀pẹ̀̀ Ọ̀pẹ̀̀'.split('_'), | |
50018 | i; | |
50019 | for (i = 0; i < expected.length; i++) { | |
50020 | assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]); | |
50021 | } | |
50022 | }); | |
50023 | ||
50024 | test('format week', function (assert) { | |
50025 | var expected = 'Àìkú Àìk Àì_Ajé Ajé Aj_Ìsẹ́gun Ìsẹ́ Ìs_Ọjọ́rú Ọjr Ọr_Ọjọ́bọ Ọjb Ọb_Ẹtì Ẹtì Ẹt_Àbámẹ́ta Àbá Àb'.split('_'), | |
50026 | i; | |
50027 | for (i = 0; i < expected.length; i++) { | |
50028 | assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); | |
50029 | } | |
50030 | }); | |
50031 | ||
50032 | test('from', function (assert) { | |
50033 | var start = moment([2007, 1, 28]); | |
50034 | assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ìsẹjú aayá die', '44 seconds = ìsẹjú aayá die'); | |
50035 | assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ìsẹjú kan', '45 seconds = ìsẹjú kan'); | |
50036 | assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ìsẹjú kan', '89 seconds = a minute'); | |
50037 | assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'ìsẹjú 2', '90 seconds = ìsẹjú 2'); | |
50038 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), 'ìsẹjú 44', 'ìsẹjú 44 = ìsẹjú 44'); | |
50039 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'wákati kan', 'ìsẹjú 45 = wákati kan'); | |
50040 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'wákati kan', 'ìsẹjú 89 = wákati kan'); | |
50041 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'wákati 2', 'ìsẹjú 90 = wákati 2'); | |
50042 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'wákati 5', 'wákati 5 = wákati 5'); | |
50043 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), 'wákati 21', 'wákati 21 = wákati 21'); | |
50044 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ọjọ́ kan', '22 wákati = ọjọ́ kan'); | |
50045 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ọjọ́ kan', '35 wákati = ọjọ́ kan'); | |
50046 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'ọjọ́ 2', 'wákati 36 = ọjọ́ 2'); | |
50047 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ọjọ́ kan', '1 = ọjọ́ kan'); | |
50048 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'ọjọ́ 5', 'ọjọ́ 5 = ọjọ́ 5'); | |
50049 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), 'ọjọ́ 25', 'ọjọ́ 25 = ọjọ́ 25'); | |
50050 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'osù kan', 'ọjọ́ 26 = osù kan'); | |
50051 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'osù kan', 'ọjọ́ 30 = osù kan'); | |
50052 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'osù kan', 'ọjọ́ 43 = osù kan'); | |
50053 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'osù 2', 'ọjọ́ 46 = osù 2'); | |
50054 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'osù 2', 'ọjọ́ 75 = osù 2'); | |
50055 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'osù 3', 'ọjọ́ 76 = osù 3'); | |
50056 | assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'osù kan', 'osù 1 = osù kan'); | |
50057 | assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'osù 5', 'osù 5 = osù 5'); | |
50058 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ọdún kan', 'ọjọ 345 = ọdún kan'); | |
50059 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'ọdún 2', 'ọjọ 548 = ọdún 2'); | |
50060 | assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ọdún kan', 'ọdún 1 = ọdún kan'); | |
50061 | assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'ọdún 5', 'ọdún 5 = ọdún 5'); | |
50062 | }); | |
50063 | ||
50064 | test('suffix', function (assert) { | |
50065 | assert.equal(moment(30000).from(0), 'ní ìsẹjú aayá die', 'prefix'); | |
50066 | assert.equal(moment(0).from(30000), 'ìsẹjú aayá die kọjá', 'suffix'); | |
50067 | }); | |
50068 | ||
50069 | test('now from now', function (assert) { | |
50070 | assert.equal(moment().fromNow(), 'ìsẹjú aayá die kọjá', 'now from now should display as in the past'); | |
50071 | }); | |
50072 | ||
50073 | test('fromNow', function (assert) { | |
50074 | assert.equal(moment().add({s: 30}).fromNow(), 'ní ìsẹjú aayá die', 'ní ìsẹjú aayá die'); | |
50075 | assert.equal(moment().add({d: 5}).fromNow(), 'ní ọjọ́ 5', 'ní ọjọ́ 5'); | |
50076 | }); | |
50077 | ||
50078 | test('calendar day', function (assert) { | |
50079 | var a = moment().hours(12).minutes(0).seconds(0); | |
50080 | ||
50081 | assert.equal(moment(a).calendar(), 'Ònì ni 12:00 PM', 'today at the same time'); | |
50082 | assert.equal(moment(a).add({m: 25}).calendar(), 'Ònì ni 12:25 PM', 'Now plus 25 min'); | |
50083 | assert.equal(moment(a).add({h: 1}).calendar(), 'Ònì ni 1:00 PM', 'Now plus 1 hour'); | |
50084 | assert.equal(moment(a).add({d: 1}).calendar(), 'Ọ̀la ni 12:00 PM', 'tomorrow at the same time'); | |
50085 | assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ònì ni 11:00 AM', 'Now minus 1 hour'); | |
50086 | assert.equal(moment(a).subtract({d: 1}).calendar(), 'Àna ni 12:00 PM', 'yesterday at the same time'); | |
50087 | }); | |
50088 | ||
50089 | test('calendar next week', function (assert) { | |
50090 | var i, m; | |
50091 | ||
50092 | for (i = 2; i < 7; i++) { | |
50093 | m = moment().add({d: i}); | |
50094 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tón\'bọ] [ni] LT'), 'Today + ' + i + ' days current time'); | |
50095 | m.hours(0).minutes(0).seconds(0).milliseconds(0); | |
50096 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tón\'bọ] [ni] LT'), 'Today + ' + i + ' days beginning of day'); | |
50097 | m.hours(23).minutes(59).seconds(59).milliseconds(999); | |
50098 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tón\'bọ] [ni] LT'), 'Today + ' + i + ' days end of day'); | |
50099 | } | |
50100 | }); | |
50101 | ||
50102 | test('calendar last week', function (assert) { | |
50103 | var i, m; | |
50104 | ||
50105 | for (i = 2; i < 7; i++) { | |
50106 | m = moment().subtract({d: i}); | |
50107 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tólọ́] [ni] LT'), 'Today - ' + i + ' days current time'); | |
50108 | m.hours(0).minutes(0).seconds(0).milliseconds(0); | |
50109 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tólọ́] [ni] LT'), 'Today - ' + i + ' days beginning of day'); | |
50110 | m.hours(23).minutes(59).seconds(59).milliseconds(999); | |
50111 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tólọ́] [ni] LT'), 'Today - ' + i + ' days end of day'); | |
50112 | } | |
50113 | }); | |
50114 | ||
50115 | test('calendar all else', function (assert) { | |
50116 | var weeksAgo = moment().subtract({w: 1}), | |
50117 | weeksFromNow = moment().add({w: 1}); | |
50118 | ||
50119 | assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago'); | |
50120 | assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week'); | |
50121 | ||
50122 | weeksAgo = moment().subtract({w: 2}); | |
50123 | weeksFromNow = moment().add({w: 2}); | |
50124 | ||
50125 | assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago'); | |
50126 | assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks'); | |
50127 | }); | |
50128 | ||
50129 | test('weeks year starting sunday format', function (assert) { | |
50130 | assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 ọjọ́ 52', 'Jan 1 2012 should be week 52'); | |
50131 | assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 ọjọ́ 1', 'Jan 2 2012 should be week 1'); | |
50132 | assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 ọjọ́ 1', 'Jan 8 2012 should be week 1'); | |
50133 | assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 ọjọ́ 2', 'Jan 9 2012 should be week 2'); | |
50134 | assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 ọjọ́ 2', 'Jan 15 2012 should be week 2'); | |
49673 | 50135 | }); |
49674 | 50136 | |
49675 | 50137 | }))); |
53269 | 53731 | assert.ok(moment('1/1/2016 extra data', ['a', 'M/D/YYYY']).isValid(), 'took second format, does not pick up on meridiem parsed from first format (good copy)'); |
53270 | 53732 | }); |
53271 | 53733 | |
53734 | test('invalid dates return invalid for methods that access the _d prop', function (assert) { | |
53735 | var momentAsDate = moment(['2015', '12', '1']).toDate(); | |
53736 | assert.ok(momentAsDate instanceof Date, 'toDate returns a Date object'); | |
53737 | assert.ok(isNaN(momentAsDate.getTime()), 'toDate returns an invalid Date invalid'); | |
53738 | }); | |
53739 | ||
53272 | 53740 | }))); |
53273 | 53741 | |
53274 | 53742 | |
60644 | 61112 | var expect = QUnit.expect; |
60645 | 61113 | |
60646 | 61114 | function isNumber(input) { |
60647 | return typeof value === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
61115 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
60648 | 61116 | } |
60649 | 61117 | |
60650 | 61118 | test('isNumber recognizes numbers', function (assert) { |
72434 | 72902 | |
72435 | 72903 | test('parse zone without a timezone', function (assert) { |
72436 | 72904 | test.expectedDeprecations(); |
72437 | var m = moment.parseZone('2016-02-01T00:00:00'); | |
72905 | var m1 = moment.parseZone('2016-02-01T00:00:00'); | |
72906 | var m2 = moment.parseZone('2016-02-01T00:00:00Z'); | |
72907 | var m3 = moment.parseZone('2016-02-01T00:00:00+00:00'); //Someone might argue this is not necessary, you could even argue that is wrong being here. | |
72908 | var m4 = moment.parseZone('2016-02-01T00:00:00+0000'); //Someone might argue this is not necessary, you could even argue that is wrong being here. | |
72438 | 72909 | assert.equal( |
72439 | m.format('M D YYYY HH:mm:ss ZZ'), | |
72910 | m1.format('M D YYYY HH:mm:ss ZZ'), | |
72440 | 72911 | '2 1 2016 00:00:00 +0000', |
72441 | 72912 | 'Not providing a timezone should keep the time and change the zone to 0' |
72442 | 72913 | ); |
72914 | assert.equal( | |
72915 | m2.format('M D YYYY HH:mm:ss ZZ'), | |
72916 | '2 1 2016 00:00:00 +0000', | |
72917 | 'Not providing a timezone should keep the time and change the zone to 0' | |
72918 | ); | |
72919 | assert.equal( | |
72920 | m3.format('M D YYYY HH:mm:ss ZZ'), | |
72921 | '2 1 2016 00:00:00 +0000', | |
72922 | 'Not providing a timezone should keep the time and change the zone to 0' | |
72923 | ); | |
72924 | assert.equal( | |
72925 | m4.format('M D YYYY HH:mm:ss ZZ'), | |
72926 | '2 1 2016 00:00:00 +0000', | |
72927 | 'Not providing a timezone should keep the time and change the zone to 0' | |
72928 | ); | |
72443 | 72929 | }); |
72444 | 72930 | |
72445 | 72931 | }))); |
66 | 66 | lastWeek?: CalendarSpecVal; |
67 | 67 | sameElse?: CalendarSpecVal; |
68 | 68 | |
69 | // any additonal properties might be used with moment.calendarFormat | |
70 | [x: string]: CalendarSpecVal; | |
69 | // any additional properties might be used with moment.calendarFormat | |
70 | [x: string]: CalendarSpecVal | undefined; | |
71 | 71 | } |
72 | 72 | |
73 | 73 | type RelativeTimeSpecVal = ( |
247 | 247 | overflow: number; |
248 | 248 | charsLeftOver: number; |
249 | 249 | nullInput: boolean; |
250 | invalidMonth: string; | |
250 | invalidMonth: string | null; | |
251 | 251 | invalidFormat: boolean; |
252 | 252 | userInvalidated: boolean; |
253 | 253 | iso: boolean; |
254 | 254 | parsedDateParts: any[]; |
255 | meridiem: string; | |
255 | meridiem: string | null; | |
256 | 256 | } |
257 | 257 | |
258 | 258 | interface MomentParsingFlagsOpt { |
388 | 388 | to: MomentInput; |
389 | 389 | } |
390 | 390 | |
391 | type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject; | |
392 | type DurationInputArg1 = Duration | number | string | FromTo | DurationInputObject; | |
391 | type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | null | undefined; | |
392 | type DurationInputArg1 = Duration | number | string | FromTo | DurationInputObject | null | undefined; | |
393 | 393 | type DurationInputArg2 = unitOfTime.DurationConstructor; |
394 | 394 | type LocaleSpecifier = string | Moment | Duration | string[]; |
395 | 395 | |
631 | 631 | |
632 | 632 | export function locale(language?: string): string; |
633 | 633 | export function locale(language?: string[]): string; |
634 | export function locale(language?: string, definition?: LocaleSpecification): string; | |
634 | export function locale(language?: string, definition?: LocaleSpecification | null | undefined): string; | |
635 | 635 | |
636 | 636 | export function localeData(key?: string | string[]): Locale; |
637 | ||
638 | export function updateLocale(language: string, locale: LocaleSpecification): Locale; | |
639 | 637 | |
640 | 638 | export function duration(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration; |
641 | 639 | |
685 | 683 | */ |
686 | 684 | export function now(): number; |
687 | 685 | |
688 | export function defineLocale(language: string, localeSpec: LocaleSpecification): Locale; | |
689 | export function updateLocale(language: string, localeSpec: LocaleSpecification): Locale; | |
686 | export function defineLocale(language: string, localeSpec: LocaleSpecification | null): Locale; | |
687 | export function updateLocale(language: string, localeSpec: LocaleSpecification | null): Locale; | |
690 | 688 | |
691 | 689 | export function locales(): string[]; |
692 | 690 |
0 | 0 | //! moment.js |
1 | //! version : 2.16.0 | |
1 | //! version : 2.17.0 | |
2 | 2 | //! authors : Tim Wood, Iskren Chernev, Moment.js contributors |
3 | 3 | //! license : MIT |
4 | 4 | //! momentjs.com |
41 | 41 | } |
42 | 42 | |
43 | 43 | function isNumber(input) { |
44 | return typeof value === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
44 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
45 | 45 | } |
46 | 46 | |
47 | 47 | function isDate(input) { |
233 | 233 | function Moment(config) { |
234 | 234 | copyConfig(this, config); |
235 | 235 | this._d = new Date(config._d != null ? config._d.getTime() : NaN); |
236 | if (!this.isValid()) { | |
237 | this._d = new Date(NaN); | |
238 | } | |
236 | 239 | // Prevent infinite loop in case updateOffset creates new moment |
237 | 240 | // objects. |
238 | 241 | if (updateInProgress === false) { |
4260 | 4263 | // Side effect imports |
4261 | 4264 | |
4262 | 4265 | |
4263 | hooks.version = '2.16.0'; | |
4266 | hooks.version = '2.17.0'; | |
4264 | 4267 | |
4265 | 4268 | setHookCallback(createLocal); |
4266 | 4269 |
0 | 0 | { |
1 | 1 | "name": "moment", |
2 | "version": "2.16.0", | |
2 | "version": "2.17.0", | |
3 | 3 | "description": "Parse, validate, manipulate, and display dates", |
4 | 4 | "homepage": "http://momentjs.com", |
5 | 5 | "author": "Iskren Ivov Chernev <iskren.chernev@gmail.com> (https://github.com/ichernev)", |
64 | 64 | "qunit-cli": "^0.1.4", |
65 | 65 | "rollup": "latest", |
66 | 66 | "spacejam": "latest", |
67 | "typescript": "^1.8.10", | |
67 | "typescript": "^2.0.8", | |
68 | 68 | "coveralls": "^2.11.2", |
69 | 69 | "nyc": "^2.1.4" |
70 | 70 | }, |
59 | 59 | export function Moment(config) { |
60 | 60 | copyConfig(this, config); |
61 | 61 | this._d = new Date(config._d != null ? config._d.getTime() : NaN); |
62 | if (!this.isValid()) { | |
63 | this._d = new Date(NaN); | |
64 | } | |
62 | 65 | // Prevent infinite loop in case updateOffset creates new moment |
63 | 66 | // objects. |
64 | 67 | if (updateInProgress === false) { |
0 | 0 | export default function isNumber(input) { |
1 | return typeof value === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
1 | return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]'; | |
2 | 2 | } |
38 | 38 | sameElse : 'L' |
39 | 39 | }, |
40 | 40 | relativeTime : { |
41 | future : 'en %s', | |
41 | future : 'd\'aquí %s', | |
42 | 42 | past : 'fa %s', |
43 | 43 | s : 'uns segons', |
44 | 44 | m : 'un minut', |
0 | //! moment.js locale configuration | |
1 | //! locale : Yoruba Nigeria (yo) | |
2 | //! author : Atolagbe Abisoye : https://github.com/andela-batolagbe | |
3 | ||
4 | import moment from '../moment'; | |
5 | ||
6 | export default moment.defineLocale('yo', { | |
7 | months : 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'), | |
8 | monthsShort : 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'), | |
9 | weekdays : 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'), | |
10 | weekdaysShort : 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'), | |
11 | weekdaysMin : 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'), | |
12 | longDateFormat : { | |
13 | LT : 'h:mm A', | |
14 | LTS : 'h:mm:ss A', | |
15 | L : 'DD/MM/YYYY', | |
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 : '[Ònì ni] LT', | |
22 | nextDay : '[Ọ̀la ni] LT', | |
23 | nextWeek : 'dddd [Ọsẹ̀ tón\'bọ] [ni] LT', | |
24 | lastDay : '[Àna ni] LT', | |
25 | lastWeek : 'dddd [Ọsẹ̀ tólọ́] [ni] LT', | |
26 | sameElse : 'L' | |
27 | }, | |
28 | relativeTime : { | |
29 | future : 'ní %s', | |
30 | past : '%s kọjá', | |
31 | s : 'ìsẹjú aayá die', | |
32 | m : 'ìsẹjú kan', | |
33 | mm : 'ìsẹjú %d', | |
34 | h : 'wákati kan', | |
35 | hh : 'wákati %d', | |
36 | d : 'ọjọ́ kan', | |
37 | dd : 'ọjọ́ %d', | |
38 | M : 'osù kan', | |
39 | MM : 'osù %d', | |
40 | y : 'ọdún kan', | |
41 | yy : 'ọdún %d' | |
42 | }, | |
43 | ordinalParse : /ọjọ́\s\d{1,2}/, | |
44 | ordinal : 'ọjọ́ %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 | }); |
0 | 0 | //! moment.js |
1 | //! version : 2.16.0 | |
1 | //! version : 2.17.0 | |
2 | 2 | //! authors : Tim Wood, Iskren Chernev, Moment.js contributors |
3 | 3 | //! license : MIT |
4 | 4 | //! momentjs.com |
5 | 5 | |
6 | 6 | import { hooks as moment, setHookCallback } from './lib/utils/hooks'; |
7 | 7 | |
8 | moment.version = '2.16.0'; | |
8 | moment.version = '2.17.0'; | |
9 | 9 | |
10 | 10 | import { |
11 | 11 | min, |
136 | 136 | }); |
137 | 137 | |
138 | 138 | test('suffix', function (assert) { |
139 | assert.equal(moment(30000).from(0), 'en uns segons', 'prefix'); | |
139 | assert.equal(moment(30000).from(0), 'd\'aquí uns segons', 'prefix'); | |
140 | 140 | assert.equal(moment(0).from(30000), 'fa uns segons', 'suffix'); |
141 | 141 | }); |
142 | 142 | |
145 | 145 | }); |
146 | 146 | |
147 | 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'); | |
148 | assert.equal(moment().add({s: 30}).fromNow(), 'd\'aquí uns segons', 'd\'aquí uns segons'); | |
149 | assert.equal(moment().add({d: 5}).fromNow(), 'd\'aquí 5 dies', 'd\'aquí 5 dies'); | |
150 | 150 | }); |
151 | 151 | |
152 | 152 | test('calendar day', function (assert) { |
0 | import { localeModule, test } from '../qunit'; | |
1 | import moment from '../../moment'; | |
2 | localeModule('yo'); | |
3 | ||
4 | test('parse', function (assert) { | |
5 | var tests = 'Sẹ́rẹ́ Sẹ́r_Èrèlè Èrl_Ẹrẹ̀nà Ẹrn_Ìgbé Ìgb_Èbibi Èbi_Òkùdu Òkù_Agẹmo Agẹ_Ògún Ògú_Owewe Owe_Ọ̀wàrà Ọ̀wà_Bélú Bél_Ọ̀pẹ̀̀ Ọ̀pẹ̀̀'.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', 'Àìkú, Èrèlè ọjọ́ 14 2010, 3:25:50 pm'], | |
25 | ['ddd, hA', 'Àìk, 3PM'], | |
26 | ['M Mo MM MMMM MMM', '2 ọjọ́ 2 02 Èrèlè Èrl'], | |
27 | ['YYYY YY', '2010 10'], | |
28 | ['D Do DD', '14 ọjọ́ 14 14'], | |
29 | ['d do dddd ddd dd', '0 ọjọ́ 0 Àìkú Àìk Àì'], | |
30 | ['DDD DDDo DDDD', '45 ọjọ́ 45 045'], | |
31 | ['w wo ww', '6 ọjọ́ 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 ọjọ́ 45 day of the year'], | |
38 | ['LTS', '3:25:50 PM'], | |
39 | ['L', '14/02/2010'], | |
40 | ['LL', '14 Èrèlè 2010'], | |
41 | ['LLL', '14 Èrèlè 2010 3:25 PM'], | |
42 | ['LLLL', 'Àìkú, 14 Èrèlè 2010 3:25 PM'], | |
43 | ['l', '14/2/2010'], | |
44 | ['ll', '14 Èrl 2010'], | |
45 | ['lll', '14 Èrl 2010 3:25 PM'], | |
46 | ['llll', 'Àìk, 14 Èrl 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'), 'ọjọ́ 1', 'ọjọ́ 1'); | |
57 | assert.equal(moment([2011, 0, 2]).format('DDDo'), 'ọjọ́ 2', 'ọjọ́ 2'); | |
58 | assert.equal(moment([2011, 0, 3]).format('DDDo'), 'ọjọ́ 3', 'ọjọ́ 3'); | |
59 | assert.equal(moment([2011, 0, 4]).format('DDDo'), 'ọjọ́ 4', 'ọjọ́ 4'); | |
60 | assert.equal(moment([2011, 0, 5]).format('DDDo'), 'ọjọ́ 5', 'ọjọ́ 5'); | |
61 | assert.equal(moment([2011, 0, 6]).format('DDDo'), 'ọjọ́ 6', 'ọjọ́ 6'); | |
62 | assert.equal(moment([2011, 0, 7]).format('DDDo'), 'ọjọ́ 7', 'ọjọ́ 7'); | |
63 | assert.equal(moment([2011, 0, 8]).format('DDDo'), 'ọjọ́ 8', 'ọjọ́ 8'); | |
64 | assert.equal(moment([2011, 0, 9]).format('DDDo'), 'ọjọ́ 9', 'ọjọ́ 9'); | |
65 | assert.equal(moment([2011, 0, 10]).format('DDDo'), 'ọjọ́ 10', 'ọjọ́ 10'); | |
66 | ||
67 | assert.equal(moment([2011, 0, 11]).format('DDDo'), 'ọjọ́ 11', 'ọjọ́ 11'); | |
68 | assert.equal(moment([2011, 0, 12]).format('DDDo'), 'ọjọ́ 12', 'ọjọ́ 12'); | |
69 | assert.equal(moment([2011, 0, 13]).format('DDDo'), 'ọjọ́ 13', 'ọjọ́ 13'); | |
70 | assert.equal(moment([2011, 0, 14]).format('DDDo'), 'ọjọ́ 14', 'ọjọ́ 14'); | |
71 | assert.equal(moment([2011, 0, 15]).format('DDDo'), 'ọjọ́ 15', 'ọjọ́ 15'); | |
72 | assert.equal(moment([2011, 0, 16]).format('DDDo'), 'ọjọ́ 16', 'ọjọ́ 16'); | |
73 | assert.equal(moment([2011, 0, 17]).format('DDDo'), 'ọjọ́ 17', 'ọjọ́ 17'); | |
74 | assert.equal(moment([2011, 0, 18]).format('DDDo'), 'ọjọ́ 18', 'ọjọ́ 18'); | |
75 | assert.equal(moment([2011, 0, 19]).format('DDDo'), 'ọjọ́ 19', 'ọjọ́ 19'); | |
76 | assert.equal(moment([2011, 0, 20]).format('DDDo'), 'ọjọ́ 20', 'ọjọ́ 20'); | |
77 | ||
78 | assert.equal(moment([2011, 0, 21]).format('DDDo'), 'ọjọ́ 21', 'ọjọ́ 21'); | |
79 | assert.equal(moment([2011, 0, 22]).format('DDDo'), 'ọjọ́ 22', 'ọjọ́ 22'); | |
80 | assert.equal(moment([2011, 0, 23]).format('DDDo'), 'ọjọ́ 23', 'ọjọ́ 23'); | |
81 | assert.equal(moment([2011, 0, 24]).format('DDDo'), 'ọjọ́ 24', 'ọjọ́ 24'); | |
82 | assert.equal(moment([2011, 0, 25]).format('DDDo'), 'ọjọ́ 25', 'ọjọ́ 25'); | |
83 | assert.equal(moment([2011, 0, 26]).format('DDDo'), 'ọjọ́ 26', 'ọjọ́ 26'); | |
84 | assert.equal(moment([2011, 0, 27]).format('DDDo'), 'ọjọ́ 27', 'ọjọ́ 27'); | |
85 | assert.equal(moment([2011, 0, 28]).format('DDDo'), 'ọjọ́ 28', 'ọjọ́ 28'); | |
86 | assert.equal(moment([2011, 0, 29]).format('DDDo'), 'ọjọ́ 29', 'ọjọ́ 29'); | |
87 | assert.equal(moment([2011, 0, 30]).format('DDDo'), 'ọjọ́ 30', 'ọjọ́ 30'); | |
88 | ||
89 | assert.equal(moment([2011, 0, 31]).format('DDDo'), 'ọjọ́ 31', 'ọjọ́ 31'); | |
90 | }); | |
91 | ||
92 | test('format month', function (assert) { | |
93 | var expected = 'Sẹ́rẹ́ Sẹ́r_Èrèlè Èrl_Ẹrẹ̀nà Ẹrn_Ìgbé Ìgb_Èbibi Èbi_Òkùdu Òkù_Agẹmo Agẹ_Ògún Ògú_Owewe Owe_Ọ̀wàrà Ọ̀wà_Bélú Bél_Ọ̀pẹ̀̀ Ọ̀pẹ̀̀'.split('_'), | |
94 | 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 = 'Àìkú Àìk Àì_Ajé Ajé Aj_Ìsẹ́gun Ìsẹ́ Ìs_Ọjọ́rú Ọjr Ọr_Ọjọ́bọ Ọjb Ọb_Ẹtì Ẹtì Ẹt_Àbámẹ́ta Àbá Àb'.split('_'), | |
102 | 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), 'ìsẹjú aayá die', '44 seconds = ìsẹjú aayá die'); | |
111 | assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ìsẹjú kan', '45 seconds = ìsẹjú kan'); | |
112 | assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ìsẹjú kan', '89 seconds = a minute'); | |
113 | assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'ìsẹjú 2', '90 seconds = ìsẹjú 2'); | |
114 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), 'ìsẹjú 44', 'ìsẹjú 44 = ìsẹjú 44'); | |
115 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'wákati kan', 'ìsẹjú 45 = wákati kan'); | |
116 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'wákati kan', 'ìsẹjú 89 = wákati kan'); | |
117 | assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'wákati 2', 'ìsẹjú 90 = wákati 2'); | |
118 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'wákati 5', 'wákati 5 = wákati 5'); | |
119 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), 'wákati 21', 'wákati 21 = wákati 21'); | |
120 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ọjọ́ kan', '22 wákati = ọjọ́ kan'); | |
121 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ọjọ́ kan', '35 wákati = ọjọ́ kan'); | |
122 | assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'ọjọ́ 2', 'wákati 36 = ọjọ́ 2'); | |
123 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ọjọ́ kan', '1 = ọjọ́ kan'); | |
124 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'ọjọ́ 5', 'ọjọ́ 5 = ọjọ́ 5'); | |
125 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), 'ọjọ́ 25', 'ọjọ́ 25 = ọjọ́ 25'); | |
126 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'osù kan', 'ọjọ́ 26 = osù kan'); | |
127 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'osù kan', 'ọjọ́ 30 = osù kan'); | |
128 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'osù kan', 'ọjọ́ 43 = osù kan'); | |
129 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'osù 2', 'ọjọ́ 46 = osù 2'); | |
130 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'osù 2', 'ọjọ́ 75 = osù 2'); | |
131 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'osù 3', 'ọjọ́ 76 = osù 3'); | |
132 | assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'osù kan', 'osù 1 = osù kan'); | |
133 | assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'osù 5', 'osù 5 = osù 5'); | |
134 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ọdún kan', 'ọjọ 345 = ọdún kan'); | |
135 | assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'ọdún 2', 'ọjọ 548 = ọdún 2'); | |
136 | assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ọdún kan', 'ọdún 1 = ọdún kan'); | |
137 | assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'ọdún 5', 'ọdún 5 = ọdún 5'); | |
138 | }); | |
139 | ||
140 | test('suffix', function (assert) { | |
141 | assert.equal(moment(30000).from(0), 'ní ìsẹjú aayá die', 'prefix'); | |
142 | assert.equal(moment(0).from(30000), 'ìsẹjú aayá die kọjá', 'suffix'); | |
143 | }); | |
144 | ||
145 | test('now from now', function (assert) { | |
146 | assert.equal(moment().fromNow(), 'ìsẹjú aayá die kọjá', 'now from now should display as in the past'); | |
147 | }); | |
148 | ||
149 | test('fromNow', function (assert) { | |
150 | assert.equal(moment().add({s: 30}).fromNow(), 'ní ìsẹjú aayá die', 'ní ìsẹjú aayá die'); | |
151 | assert.equal(moment().add({d: 5}).fromNow(), 'ní ọjọ́ 5', 'ní ọjọ́ 5'); | |
152 | }); | |
153 | ||
154 | test('calendar day', function (assert) { | |
155 | var a = moment().hours(12).minutes(0).seconds(0); | |
156 | ||
157 | assert.equal(moment(a).calendar(), 'Ònì ni 12:00 PM', 'today at the same time'); | |
158 | assert.equal(moment(a).add({m: 25}).calendar(), 'Ònì ni 12:25 PM', 'Now plus 25 min'); | |
159 | assert.equal(moment(a).add({h: 1}).calendar(), 'Ònì ni 1:00 PM', 'Now plus 1 hour'); | |
160 | assert.equal(moment(a).add({d: 1}).calendar(), 'Ọ̀la ni 12:00 PM', 'tomorrow at the same time'); | |
161 | assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ònì ni 11:00 AM', 'Now minus 1 hour'); | |
162 | assert.equal(moment(a).subtract({d: 1}).calendar(), 'Àna ni 12:00 PM', '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 [Ọsẹ̀ tón\'bọ] [ni] LT'), 'Today + ' + i + ' days current time'); | |
171 | m.hours(0).minutes(0).seconds(0).milliseconds(0); | |
172 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tón\'bọ] [ni] 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 [Ọsẹ̀ tón\'bọ] [ni] 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('dddd [Ọsẹ̀ tólọ́] [ni] LT'), 'Today - ' + i + ' days current time'); | |
184 | m.hours(0).minutes(0).seconds(0).milliseconds(0); | |
185 | assert.equal(m.calendar(), m.format('dddd [Ọsẹ̀ tólọ́] [ni] 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 [Ọsẹ̀ tólọ́] [ni] 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 format', function (assert) { | |
206 | assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 ọjọ́ 52', 'Jan 1 2012 should be week 52'); | |
207 | assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 ọjọ́ 1', 'Jan 2 2012 should be week 1'); | |
208 | assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 ọjọ́ 1', 'Jan 8 2012 should be week 1'); | |
209 | assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 ọjọ́ 2', 'Jan 9 2012 should be week 2'); | |
210 | assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 ọjọ́ 2', 'Jan 15 2012 should be week 2'); | |
211 | }); |
1099 | 1099 | assert.ok(moment('02:30 p more extra stuff', 'hh:mm a').isValid(), 'because other tokens were parsed, date is valid'); |
1100 | 1100 | assert.ok(moment('1/1/2016 extra data', ['a', 'M/D/YYYY']).isValid(), 'took second format, does not pick up on meridiem parsed from first format (good copy)'); |
1101 | 1101 | }); |
1102 | ||
1103 | test('invalid dates return invalid for methods that access the _d prop', function (assert) { | |
1104 | var momentAsDate = moment(['2015', '12', '1']).toDate(); | |
1105 | assert.ok(momentAsDate instanceof Date, 'toDate returns a Date object'); | |
1106 | assert.ok(isNaN(momentAsDate.getTime()), 'toDate returns an invalid Date invalid'); | |
1107 | }); |
460 | 460 | |
461 | 461 | test('parse zone without a timezone', function (assert) { |
462 | 462 | test.expectedDeprecations(); |
463 | var m = moment.parseZone('2016-02-01T00:00:00'); | |
463 | var m1 = moment.parseZone('2016-02-01T00:00:00'); | |
464 | var m2 = moment.parseZone('2016-02-01T00:00:00Z'); | |
465 | var m3 = moment.parseZone('2016-02-01T00:00:00+00:00'); //Someone might argue this is not necessary, you could even argue that is wrong being here. | |
466 | var m4 = moment.parseZone('2016-02-01T00:00:00+0000'); //Someone might argue this is not necessary, you could even argue that is wrong being here. | |
464 | 467 | assert.equal( |
465 | m.format('M D YYYY HH:mm:ss ZZ'), | |
468 | m1.format('M D YYYY HH:mm:ss ZZ'), | |
466 | 469 | '2 1 2016 00:00:00 +0000', |
467 | 470 | 'Not providing a timezone should keep the time and change the zone to 0' |
468 | 471 | ); |
469 | }); | |
472 | assert.equal( | |
473 | m2.format('M D YYYY HH:mm:ss ZZ'), | |
474 | '2 1 2016 00:00:00 +0000', | |
475 | 'Not providing a timezone should keep the time and change the zone to 0' | |
476 | ); | |
477 | assert.equal( | |
478 | m3.format('M D YYYY HH:mm:ss ZZ'), | |
479 | '2 1 2016 00:00:00 +0000', | |
480 | 'Not providing a timezone should keep the time and change the zone to 0' | |
481 | ); | |
482 | assert.equal( | |
483 | m4.format('M D YYYY HH:mm:ss ZZ'), | |
484 | '2 1 2016 00:00:00 +0000', | |
485 | 'Not providing a timezone should keep the time and change the zone to 0' | |
486 | ); | |
487 | }); |
21 | 21 | dest: './' |
22 | 22 | } |
23 | 23 | }); |
24 | grunt.registerTask('nugetkey_pre', function () { | |
25 | grunt.option('key', process.env.NUGET_KEY); | |
26 | grunt.option('source', 'https://www.nuget.org/api/v2/package'); | |
27 | }); | |
28 | grunt.registerTask('nugetkey_post', function () { | |
29 | grunt.option('key', null); | |
30 | grunt.option('source', null); | |
31 | }); | |
24 | 32 | grunt.config('nugetpush', { |
25 | 33 | dist: { |
26 | 34 | src: 'Moment.js.*.nupkg' |
31 | 39 | }); |
32 | 40 | |
33 | 41 | grunt.registerTask('nuget-publish', [ |
34 | 'nugetpack', 'nugetpush', 'clean:nuget' | |
42 | 'nugetpack', 'nugetkey_pre', 'nugetkey', 'nugetkey_post', 'nugetpush', 'clean:nuget' | |
35 | 43 | ]); |
36 | 44 | }; |
21 | 21 | var day11 = moment(Date.UTC.apply({}, array)); |
22 | 22 | var day12 = moment.unix(1318781876); |
23 | 23 | |
24 | moment(null); | |
25 | moment(undefined); | |
24 | 26 | moment({ years: 2010, months: 3, days: 5, hours: 15, minutes: 10, seconds: 3, milliseconds: 123 }); |
25 | 27 | moment("20140101", "YYYYMMDD", true); |
26 | 28 | moment("20140101", "YYYYMMDD", "en"); |
222 | 224 | localLang.format('LLLL'); |
223 | 225 | globalLang.format('LLLL'); |
224 | 226 | |
227 | moment.duration(null); | |
228 | moment.duration(undefined); | |
225 | 229 | moment.duration(100); |
226 | 230 | moment.duration(2, 'seconds'); |
227 | 231 | moment.duration({ |
253 | 257 | moment.locale(); |
254 | 258 | moment.locale('en'); |
255 | 259 | moment.locale(['en', 'fr']); |
260 | ||
261 | moment.defineLocale('en', null); | |
262 | moment.updateLocale('en', null); | |
263 | moment.locale('en', null); | |
256 | 264 | |
257 | 265 | // Defining a custom language: |
258 | 266 | moment.locale('en', { |