@learncard/react 2.6.9 → 2.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/base.css +1 -1
  2. package/dist/base.js +1 -1
  3. package/dist/cjs/{AchievementCard-52b029e8.js → AchievementCard-e5815d57.js} +4 -4
  4. package/dist/cjs/{AchievementCard-52b029e8.js.map → AchievementCard-e5815d57.js.map} +1 -1
  5. package/dist/cjs/AwardRibbon-14ba45fb.js.map +1 -1
  6. package/dist/cjs/{BoostGenericCard-7a29863b.js → BoostGenericCard-4bb2ca13.js} +8 -9
  7. package/dist/cjs/{BoostGenericCard-7a29863b.js.map → BoostGenericCard-4bb2ca13.js.map} +1 -1
  8. package/dist/cjs/{BoostSmallCard-2c5b5dfe.js → BoostSmallCard-fb2c326b.js} +8 -8
  9. package/dist/cjs/{BoostSmallCard-2c5b5dfe.js.map → BoostSmallCard-fb2c326b.js.map} +1 -1
  10. package/dist/cjs/Button-a7af702b.js.map +1 -1
  11. package/dist/cjs/Checkmark-f611aa4d.js.map +1 -1
  12. package/dist/cjs/CircleCheckButton-43c96841.js.map +1 -1
  13. package/dist/cjs/CircleIcon-a45953f5.js.map +1 -1
  14. package/dist/cjs/CircleSpinner-093cce04.js.map +1 -1
  15. package/dist/cjs/CourseCard-338a32ee.js.map +1 -1
  16. package/dist/cjs/{CourseVerticalCard-b76f5407.js → CourseVerticalCard-18166b12.js} +3 -3
  17. package/dist/cjs/{CourseVerticalCard-b76f5407.js.map → CourseVerticalCard-18166b12.js.map} +1 -1
  18. package/dist/cjs/FlippyCard-209549c5.js.map +1 -1
  19. package/dist/cjs/GenericArrow-8dfb261d.js.map +1 -1
  20. package/dist/cjs/{GenericCard-4241c598.js → GenericCard-561e9d34.js} +7 -7
  21. package/dist/cjs/{GenericCard-4241c598.js.map → GenericCard-561e9d34.js.map} +1 -1
  22. package/dist/cjs/JobHistoryCard-05a3f98b.js.map +1 -1
  23. package/dist/cjs/JobListCard-a3e030e0.js.map +1 -1
  24. package/dist/cjs/LearnCardCreditCardBackFace-87cc8b9f.js.map +1 -1
  25. package/dist/cjs/{LearnCardCreditCardFrontFace-4452fd7a.js → LearnCardCreditCardFrontFace-94be6a62.js} +2 -2
  26. package/dist/cjs/{LearnCardCreditCardFrontFace-4452fd7a.js.map → LearnCardCreditCardFrontFace-94be6a62.js.map} +1 -1
  27. package/dist/cjs/LearnPill-0b3170ea.js.map +1 -1
  28. package/dist/cjs/{Lightbox-cda1e0d5.js → Lightbox-31a90d97.js} +23 -26
  29. package/dist/cjs/{Lightbox-cda1e0d5.js.map → Lightbox-31a90d97.js.map} +1 -1
  30. package/dist/cjs/Lightbulb-1c28af02.js.map +1 -1
  31. package/dist/cjs/MiniVCThumbnail-a78e44f2.js.map +1 -1
  32. package/dist/cjs/Notification-9d230f1b.js.map +1 -1
  33. package/dist/cjs/NotificationBoostCard-3b3bd47d.js.map +1 -1
  34. package/dist/cjs/NotificationUserAcceptedBoostCard-423b9320.js.map +1 -1
  35. package/dist/cjs/NotificationUserCard-d4dab06c.js.map +1 -1
  36. package/dist/cjs/{QRCodeCard-efaa58e1.js → QRCodeCard-2a818136.js} +2 -2
  37. package/dist/cjs/{QRCodeCard-efaa58e1.js.map → QRCodeCard-2a818136.js.map} +1 -1
  38. package/dist/cjs/RoundedPill-85e7ed68.js.map +1 -1
  39. package/dist/cjs/SchoolIDCard-1baf77e8.js.map +1 -1
  40. package/dist/cjs/{SkillTabCard-14ba0618.js → SkillTabCard-c89279ab.js} +2 -2
  41. package/dist/cjs/{SkillTabCard-14ba0618.js.map → SkillTabCard-c89279ab.js.map} +1 -1
  42. package/dist/cjs/SkillVerticalCard-3eb3a8e9.js.map +1 -1
  43. package/dist/cjs/SkillsCard-4b6dbb4f.js.map +1 -1
  44. package/dist/cjs/SkillsStatsCard-97a35a88.js.map +1 -1
  45. package/dist/cjs/SmallAchievementCard-c76701ce.js.map +1 -1
  46. package/dist/cjs/Trophy-9ede7f2b.js.map +1 -1
  47. package/dist/cjs/User-92f9cf40.js.map +1 -1
  48. package/dist/cjs/{VCCard-46382b57.js → VCCard-579989b4.js} +7 -4
  49. package/dist/cjs/{VCCard-46382b57.js.map → VCCard-579989b4.js.map} +1 -1
  50. package/dist/cjs/{VCDisplayBackFace-85c80890.js → VCDisplayBackFace-7ee3d096.js} +3 -3
  51. package/dist/cjs/{VCDisplayBackFace-85c80890.js.map → VCDisplayBackFace-7ee3d096.js.map} +1 -1
  52. package/dist/cjs/{VCDisplayCard-03fc6bd1.js → VCDisplayCard-05393c28.js} +3 -3
  53. package/dist/cjs/{VCDisplayCard-03fc6bd1.js.map → VCDisplayCard-05393c28.js.map} +1 -1
  54. package/dist/cjs/{VCDisplayCard2-9b974b70.js → VCDisplayCard2-30a3240b.js} +30 -49
  55. package/dist/cjs/VCDisplayCard2-30a3240b.js.map +1 -0
  56. package/dist/cjs/VCThumbnail-6bf86bb2.js.map +1 -1
  57. package/dist/cjs/VCVerificationCheck-46fa75d3.js.map +1 -1
  58. package/dist/cjs/{VCVerificationPill-ac05903b.js → VCVerificationPill-f629fd71.js} +2 -2
  59. package/dist/cjs/{VCVerificationPill-ac05903b.js.map → VCVerificationPill-f629fd71.js.map} +1 -1
  60. package/dist/cjs/{constants-3f8ed765.js → constants-a9665278.js} +10 -10
  61. package/dist/cjs/{constants-3f8ed765.js.map → constants-a9665278.js.map} +1 -1
  62. package/dist/cjs/{credential.helpers-40149659.js → credential.helpers-a4559d6b.js} +1260 -985
  63. package/dist/cjs/credential.helpers-a4559d6b.js.map +1 -0
  64. package/dist/cjs/icons-ac6eb6ec.js.map +1 -1
  65. package/dist/cjs/{index-82de573c.js → index-8082a131.js} +21 -17
  66. package/dist/cjs/index-8082a131.js.map +1 -0
  67. package/dist/cjs/index-d057eaee.js.map +1 -1
  68. package/dist/cjs/index-d836b84d.js.map +1 -1
  69. package/dist/cjs/index.js +23 -24
  70. package/dist/cjs/index.js.map +1 -1
  71. package/dist/cjs/index11.js +1 -1
  72. package/dist/cjs/index12.js +23 -24
  73. package/dist/cjs/index12.js.map +1 -1
  74. package/dist/cjs/index16.js +2 -2
  75. package/dist/cjs/index18.js +1 -1
  76. package/dist/cjs/index2.js +15 -15
  77. package/dist/cjs/index25.js +2 -2
  78. package/dist/cjs/index27.js +1 -1
  79. package/dist/cjs/index3.js +2 -2
  80. package/dist/cjs/index31.js +3 -3
  81. package/dist/cjs/index35.js +8 -9
  82. package/dist/cjs/index35.js.map +1 -1
  83. package/dist/cjs/index36.js +4 -5
  84. package/dist/cjs/index36.js.map +1 -1
  85. package/dist/cjs/index37.js +5 -6
  86. package/dist/cjs/index37.js.map +1 -1
  87. package/dist/cjs/index38.js +5 -6
  88. package/dist/cjs/index38.js.map +1 -1
  89. package/dist/cjs/index39.js +1 -2
  90. package/dist/cjs/index39.js.map +1 -1
  91. package/dist/cjs/index4.js +5 -5
  92. package/dist/cjs/index42.js +2 -2
  93. package/dist/cjs/index9.js +6 -6
  94. package/dist/cjs/notifications-56c6fc94.js.map +1 -1
  95. package/dist/cjs/types-c83b33ec.js.map +1 -1
  96. package/dist/cjs/types-e4d9a257.js.map +1 -1
  97. package/dist/cjs/{types.esm-e38e568c.js → types.esm-8d2141ba.js} +114 -259
  98. package/dist/cjs/types.esm-8d2141ba.js.map +1 -0
  99. package/dist/esm/{AchievementCard-51b4814b.js → AchievementCard-c4121d5c.js} +4 -4
  100. package/dist/esm/{AchievementCard-51b4814b.js.map → AchievementCard-c4121d5c.js.map} +1 -1
  101. package/dist/esm/AwardRibbon-3e682281.js.map +1 -1
  102. package/dist/esm/{BoostGenericCard-ab82b8aa.js → BoostGenericCard-5aecf426.js} +3 -4
  103. package/dist/esm/{BoostGenericCard-ab82b8aa.js.map → BoostGenericCard-5aecf426.js.map} +1 -1
  104. package/dist/esm/{BoostSmallCard-2cc5a41a.js → BoostSmallCard-930b33fc.js} +3 -3
  105. package/dist/esm/{BoostSmallCard-2cc5a41a.js.map → BoostSmallCard-930b33fc.js.map} +1 -1
  106. package/dist/esm/Button-5f805204.js.map +1 -1
  107. package/dist/esm/Checkmark-d8b8f43d.js.map +1 -1
  108. package/dist/esm/CircleCheckButton-551054f6.js.map +1 -1
  109. package/dist/esm/CircleIcon-38b874e2.js.map +1 -1
  110. package/dist/esm/CircleSpinner-9b8b1a6b.js.map +1 -1
  111. package/dist/esm/CourseCard-663ff174.js.map +1 -1
  112. package/dist/esm/{CourseVerticalCard-922a0860.js → CourseVerticalCard-64c29ffb.js} +3 -3
  113. package/dist/esm/{CourseVerticalCard-922a0860.js.map → CourseVerticalCard-64c29ffb.js.map} +1 -1
  114. package/dist/esm/FlippyCard-a2de5cf1.js.map +1 -1
  115. package/dist/esm/GenericArrow-0dba1707.js.map +1 -1
  116. package/dist/esm/GenericCard-d732daa0.js +1 -1
  117. package/dist/esm/GenericCard-d732daa0.js.map +1 -1
  118. package/dist/esm/JobHistoryCard-80d4ef27.js.map +1 -1
  119. package/dist/esm/JobListCard-678e3c39.js.map +1 -1
  120. package/dist/esm/LearnCardCreditCardBackFace-9baa9e6b.js.map +1 -1
  121. package/dist/esm/{LearnCardCreditCardFrontFace-cf793917.js → LearnCardCreditCardFrontFace-f61b789c.js} +2 -2
  122. package/dist/esm/{LearnCardCreditCardFrontFace-cf793917.js.map → LearnCardCreditCardFrontFace-f61b789c.js.map} +1 -1
  123. package/dist/esm/LearnPill-8684ba99.js.map +1 -1
  124. package/dist/esm/{Lightbox-de99baca.js → Lightbox-35809729.js} +23 -26
  125. package/dist/esm/{Lightbox-de99baca.js.map → Lightbox-35809729.js.map} +1 -1
  126. package/dist/esm/Lightbulb-a3c1679f.js.map +1 -1
  127. package/dist/esm/MiniVCThumbnail-6a07e810.js.map +1 -1
  128. package/dist/esm/Notification-0f58ef6a.js.map +1 -1
  129. package/dist/esm/NotificationBoostCard-134edf94.js.map +1 -1
  130. package/dist/esm/NotificationUserAcceptedBoostCard-8c13bd3f.js.map +1 -1
  131. package/dist/esm/NotificationUserCard-dbcc80f9.js.map +1 -1
  132. package/dist/esm/{QRCodeCard-c57e2067.js → QRCodeCard-79d4d253.js} +2 -2
  133. package/dist/esm/{QRCodeCard-c57e2067.js.map → QRCodeCard-79d4d253.js.map} +1 -1
  134. package/dist/esm/RoundedPill-731211b3.js.map +1 -1
  135. package/dist/esm/SchoolIDCard-3b746226.js.map +1 -1
  136. package/dist/esm/{SkillTabCard-d86c6452.js → SkillTabCard-77074988.js} +2 -2
  137. package/dist/esm/{SkillTabCard-d86c6452.js.map → SkillTabCard-77074988.js.map} +1 -1
  138. package/dist/esm/SkillVerticalCard-108f49bb.js.map +1 -1
  139. package/dist/esm/SkillsCard-92a51db2.js.map +1 -1
  140. package/dist/esm/SkillsStatsCard-1628fe9c.js.map +1 -1
  141. package/dist/esm/SmallAchievementCard-2d87ac82.js.map +1 -1
  142. package/dist/esm/Trophy-702610b8.js.map +1 -1
  143. package/dist/esm/User-fd276ad5.js.map +1 -1
  144. package/dist/esm/{VCCard-67827b2a.js → VCCard-7cb07eaf.js} +7 -4
  145. package/dist/esm/{VCCard-67827b2a.js.map → VCCard-7cb07eaf.js.map} +1 -1
  146. package/dist/esm/{VCDisplayBackFace-4c132537.js → VCDisplayBackFace-65f7b72d.js} +3 -3
  147. package/dist/esm/{VCDisplayBackFace-4c132537.js.map → VCDisplayBackFace-65f7b72d.js.map} +1 -1
  148. package/dist/esm/{VCDisplayCard-45555392.js → VCDisplayCard-5937271f.js} +3 -3
  149. package/dist/esm/{VCDisplayCard-45555392.js.map → VCDisplayCard-5937271f.js.map} +1 -1
  150. package/dist/esm/{VCDisplayCard2-081f4ffa.js → VCDisplayCard2-80423d2b.js} +30 -49
  151. package/dist/esm/VCDisplayCard2-80423d2b.js.map +1 -0
  152. package/dist/esm/VCThumbnail-3c254bda.js.map +1 -1
  153. package/dist/esm/VCVerificationCheck-80249524.js.map +1 -1
  154. package/dist/esm/{VCVerificationPill-f4734545.js → VCVerificationPill-aa9d7bde.js} +2 -2
  155. package/dist/esm/{VCVerificationPill-f4734545.js.map → VCVerificationPill-aa9d7bde.js.map} +1 -1
  156. package/dist/esm/constants-af6897d5.js.map +1 -1
  157. package/dist/esm/{credential.helpers-3572f72c.js → credential.helpers-f57b9258.js} +1243 -968
  158. package/dist/esm/credential.helpers-f57b9258.js.map +1 -0
  159. package/dist/esm/icons-9d160530.js.map +1 -1
  160. package/dist/esm/index-7103ad3c.js.map +1 -1
  161. package/dist/esm/{index-aa1098e1.js → index-dff96076.js} +21 -17
  162. package/dist/esm/index-dff96076.js.map +1 -0
  163. package/dist/esm/index-e588d5bb.js.map +1 -1
  164. package/dist/esm/index.js +20 -21
  165. package/dist/esm/index.js.map +1 -1
  166. package/dist/esm/index12.js +20 -21
  167. package/dist/esm/index12.js.map +1 -1
  168. package/dist/esm/index16.js +2 -2
  169. package/dist/esm/index18.js +1 -1
  170. package/dist/esm/index2.js +15 -15
  171. package/dist/esm/index25.js +2 -2
  172. package/dist/esm/index3.js +2 -2
  173. package/dist/esm/index31.js +3 -3
  174. package/dist/esm/index35.js +8 -9
  175. package/dist/esm/index35.js.map +1 -1
  176. package/dist/esm/index36.js +4 -5
  177. package/dist/esm/index36.js.map +1 -1
  178. package/dist/esm/index37.js +5 -6
  179. package/dist/esm/index37.js.map +1 -1
  180. package/dist/esm/index38.js +5 -6
  181. package/dist/esm/index38.js.map +1 -1
  182. package/dist/esm/index39.js +1 -2
  183. package/dist/esm/index39.js.map +1 -1
  184. package/dist/esm/index4.js +5 -5
  185. package/dist/esm/index42.js +2 -2
  186. package/dist/esm/index9.js +6 -6
  187. package/dist/esm/notifications-009bbd80.js.map +1 -1
  188. package/dist/esm/types-7081a9e5.js.map +1 -1
  189. package/dist/esm/types-b32d28d5.js.map +1 -1
  190. package/dist/esm/{types.esm-d135a91a.js → types.esm-ee3ac019.js} +114 -259
  191. package/dist/esm/types.esm-ee3ac019.js.map +1 -0
  192. package/dist/index.d.ts +57 -57
  193. package/dist/main.css +1 -1
  194. package/dist/main.js +1 -1
  195. package/package.json +4 -4
  196. package/dist/cjs/VCDisplayCard2-9b974b70.js.map +0 -1
  197. package/dist/cjs/credential.helpers-40149659.js.map +0 -1
  198. package/dist/cjs/index-82de573c.js.map +0 -1
  199. package/dist/cjs/index-a961acab.js +0 -3538
  200. package/dist/cjs/index-a961acab.js.map +0 -1
  201. package/dist/cjs/types.esm-e38e568c.js.map +0 -1
  202. package/dist/esm/VCDisplayCard2-081f4ffa.js.map +0 -1
  203. package/dist/esm/credential.helpers-3572f72c.js.map +0 -1
  204. package/dist/esm/index-aa1098e1.js.map +0 -1
  205. package/dist/esm/index-e1f279c6.js +0 -3529
  206. package/dist/esm/index-e1f279c6.js.map +0 -1
  207. package/dist/esm/types.esm-d135a91a.js.map +0 -1
@@ -1,5 +1,76 @@
1
- import { V as VerificationStatusEnum } from './types.esm-d135a91a.js';
2
- import { r as requiredArgs, t as toDate, a as toInteger, g as getUTCWeekYear, b as getUTCISOWeekYear, c as getUTCWeek, d as getUTCISOWeek, e as getDefaultOptions } from './index-e1f279c6.js';
1
+ import { V as VerificationStatusEnum } from './types.esm-ee3ac019.js';
2
+
3
+ function toInteger(dirtyNumber) {
4
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
5
+ return NaN;
6
+ }
7
+
8
+ var number = Number(dirtyNumber);
9
+
10
+ if (isNaN(number)) {
11
+ return number;
12
+ }
13
+
14
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
15
+ }
16
+
17
+ function requiredArgs(required, args) {
18
+ if (args.length < required) {
19
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
20
+ }
21
+ }
22
+
23
+ /**
24
+ * @name toDate
25
+ * @category Common Helpers
26
+ * @summary Convert the given argument to an instance of Date.
27
+ *
28
+ * @description
29
+ * Convert the given argument to an instance of Date.
30
+ *
31
+ * If the argument is an instance of Date, the function returns its clone.
32
+ *
33
+ * If the argument is a number, it is treated as a timestamp.
34
+ *
35
+ * If the argument is none of the above, the function returns Invalid Date.
36
+ *
37
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
38
+ *
39
+ * @param {Date|Number} argument - the value to convert
40
+ * @returns {Date} the parsed date in the local time zone
41
+ * @throws {TypeError} 1 argument required
42
+ *
43
+ * @example
44
+ * // Clone the date:
45
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
46
+ * //=> Tue Feb 11 2014 11:30:30
47
+ *
48
+ * @example
49
+ * // Convert the timestamp to date:
50
+ * const result = toDate(1392098430000)
51
+ * //=> Tue Feb 11 2014 11:30:30
52
+ */
53
+
54
+ function toDate(argument) {
55
+ requiredArgs(1, arguments);
56
+ var argStr = Object.prototype.toString.call(argument); // Clone the date
57
+
58
+ if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
59
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
60
+ return new Date(argument.getTime());
61
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
62
+ return new Date(argument);
63
+ } else {
64
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
65
+ // eslint-disable-next-line no-console
66
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
67
+
68
+ console.warn(new Error().stack);
69
+ }
70
+
71
+ return new Date(NaN);
72
+ }
73
+ }
3
74
 
4
75
  /**
5
76
  * @name addMilliseconds
@@ -9,6 +80,10 @@ import { r as requiredArgs, t as toDate, a as toInteger, g as getUTCWeekYear, b
9
80
  * @description
10
81
  * Add the specified number of milliseconds to the given date.
11
82
  *
83
+ * ### v2.0.0 breaking changes:
84
+ *
85
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
86
+ *
12
87
  * @param {Date|Number} date - the date to be changed
13
88
  * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
14
89
  * @returns {Date} the new date with the milliseconds added
@@ -44,7 +119,6 @@ function getTimezoneOffsetInMilliseconds(date) {
44
119
  return date.getTime() - utcDate.getTime();
45
120
  }
46
121
 
47
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
48
122
  /**
49
123
  * @name isDate
50
124
  * @category Common Helpers
@@ -53,6 +127,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
53
127
  * @description
54
128
  * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
55
129
  *
130
+ * ### v2.0.0 breaking changes:
131
+ *
132
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
133
+ *
56
134
  * @param {*} value - the value to check
57
135
  * @returns {boolean} true if the given value is a date
58
136
  * @throws {TypeError} 1 arguments required
@@ -80,7 +158,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
80
158
 
81
159
  function isDate(value) {
82
160
  requiredArgs(1, arguments);
83
- return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
161
+ return value instanceof Date || typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]';
84
162
  }
85
163
 
86
164
  /**
@@ -95,6 +173,32 @@ function isDate(value) {
95
173
  *
96
174
  * Time value of Date: http://es5.github.io/#x15.9.1.1
97
175
  *
176
+ * ### v2.0.0 breaking changes:
177
+ *
178
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
179
+ *
180
+ * - Now `isValid` doesn't throw an exception
181
+ * if the first argument is not an instance of Date.
182
+ * Instead, argument is converted beforehand using `toDate`.
183
+ *
184
+ * Examples:
185
+ *
186
+ * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
187
+ * |---------------------------|---------------|---------------|
188
+ * | `new Date()` | `true` | `true` |
189
+ * | `new Date('2016-01-01')` | `true` | `true` |
190
+ * | `new Date('')` | `false` | `false` |
191
+ * | `new Date(1488370835081)` | `true` | `true` |
192
+ * | `new Date(NaN)` | `false` | `false` |
193
+ * | `'2016-01-01'` | `TypeError` | `false` |
194
+ * | `''` | `TypeError` | `false` |
195
+ * | `1488370835081` | `TypeError` | `true` |
196
+ * | `NaN` | `TypeError` | `false` |
197
+ *
198
+ * We introduce this change to make *date-fns* consistent with ECMAScript behavior
199
+ * that try to coerce arguments to the expected type
200
+ * (which is also the case with other *date-fns* functions).
201
+ *
98
202
  * @param {*} date - the date to check
99
203
  * @returns {Boolean} the date is valid
100
204
  * @throws {TypeError} 1 argument required
@@ -126,167 +230,819 @@ function isValid(dirtyDate) {
126
230
  return !isNaN(Number(date));
127
231
  }
128
232
 
129
- /**
130
- * @name subMilliseconds
131
- * @category Millisecond Helpers
132
- * @summary Subtract the specified number of milliseconds from the given date.
133
- *
134
- * @description
135
- * Subtract the specified number of milliseconds from the given date.
136
- *
137
- * @param {Date|Number} date - the date to be changed
138
- * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
139
- * @returns {Date} the new date with the milliseconds subtracted
140
- * @throws {TypeError} 2 arguments required
141
- *
142
- * @example
143
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
144
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
145
- * //=> Thu Jul 10 2014 12:45:29.250
146
- */
147
-
148
- function subMilliseconds(dirtyDate, dirtyAmount) {
149
- requiredArgs(2, arguments);
150
- var amount = toInteger(dirtyAmount);
151
- return addMilliseconds(dirtyDate, -amount);
152
- }
153
-
154
- var MILLISECONDS_IN_DAY = 86400000;
155
- function getUTCDayOfYear(dirtyDate) {
156
- requiredArgs(1, arguments);
157
- var date = toDate(dirtyDate);
158
- var timestamp = date.getTime();
159
- date.setUTCMonth(0, 1);
160
- date.setUTCHours(0, 0, 0, 0);
161
- var startOfYearTimestamp = date.getTime();
162
- var difference = timestamp - startOfYearTimestamp;
163
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
164
- }
165
-
166
- function addLeadingZeros(number, targetLength) {
167
- var sign = number < 0 ? '-' : '';
168
- var output = Math.abs(number).toString();
169
-
170
- while (output.length < targetLength) {
171
- output = '0' + output;
172
- }
173
-
174
- return sign + output;
175
- }
176
-
177
- /*
178
- * | | Unit | | Unit |
179
- * |-----|--------------------------------|-----|--------------------------------|
180
- * | a | AM, PM | A* | |
181
- * | d | Day of month | D | |
182
- * | h | Hour [1-12] | H | Hour [0-23] |
183
- * | m | Minute | M | Month |
184
- * | s | Second | S | Fraction of second |
185
- * | y | Year (abs) | Y | |
186
- *
187
- * Letters marked by * are not implemented but reserved by Unicode standard.
188
- */
189
-
190
- var formatters$1 = {
191
- // Year
192
- y: function y(date, token) {
193
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
194
- // | Year | y | yy | yyy | yyyy | yyyyy |
195
- // |----------|-------|----|-------|-------|-------|
196
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
197
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
198
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
199
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
200
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
201
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
202
-
203
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
204
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
233
+ var formatDistanceLocale = {
234
+ lessThanXSeconds: {
235
+ one: 'less than a second',
236
+ other: 'less than {{count}} seconds'
205
237
  },
206
- // Month
207
- M: function M(date, token) {
208
- var month = date.getUTCMonth();
209
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
238
+ xSeconds: {
239
+ one: '1 second',
240
+ other: '{{count}} seconds'
210
241
  },
211
- // Day of the month
212
- d: function d(date, token) {
213
- return addLeadingZeros(date.getUTCDate(), token.length);
242
+ halfAMinute: 'half a minute',
243
+ lessThanXMinutes: {
244
+ one: 'less than a minute',
245
+ other: 'less than {{count}} minutes'
214
246
  },
215
- // AM or PM
216
- a: function a(date, token) {
217
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
218
-
219
- switch (token) {
220
- case 'a':
221
- case 'aa':
222
- return dayPeriodEnumValue.toUpperCase();
223
-
224
- case 'aaa':
225
- return dayPeriodEnumValue;
226
-
227
- case 'aaaaa':
228
- return dayPeriodEnumValue[0];
229
-
230
- case 'aaaa':
231
- default:
232
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
233
- }
247
+ xMinutes: {
248
+ one: '1 minute',
249
+ other: '{{count}} minutes'
234
250
  },
235
- // Hour [1-12]
236
- h: function h(date, token) {
237
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
251
+ aboutXHours: {
252
+ one: 'about 1 hour',
253
+ other: 'about {{count}} hours'
238
254
  },
239
- // Hour [0-23]
240
- H: function H(date, token) {
241
- return addLeadingZeros(date.getUTCHours(), token.length);
255
+ xHours: {
256
+ one: '1 hour',
257
+ other: '{{count}} hours'
242
258
  },
243
- // Minute
244
- m: function m(date, token) {
245
- return addLeadingZeros(date.getUTCMinutes(), token.length);
259
+ xDays: {
260
+ one: '1 day',
261
+ other: '{{count}} days'
246
262
  },
247
- // Second
248
- s: function s(date, token) {
249
- return addLeadingZeros(date.getUTCSeconds(), token.length);
263
+ aboutXWeeks: {
264
+ one: 'about 1 week',
265
+ other: 'about {{count}} weeks'
250
266
  },
251
- // Fraction of second
252
- S: function S(date, token) {
253
- var numberOfDigits = token.length;
254
- var milliseconds = date.getUTCMilliseconds();
255
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
256
- return addLeadingZeros(fractionalSeconds, token.length);
267
+ xWeeks: {
268
+ one: '1 week',
269
+ other: '{{count}} weeks'
270
+ },
271
+ aboutXMonths: {
272
+ one: 'about 1 month',
273
+ other: 'about {{count}} months'
274
+ },
275
+ xMonths: {
276
+ one: '1 month',
277
+ other: '{{count}} months'
278
+ },
279
+ aboutXYears: {
280
+ one: 'about 1 year',
281
+ other: 'about {{count}} years'
282
+ },
283
+ xYears: {
284
+ one: '1 year',
285
+ other: '{{count}} years'
286
+ },
287
+ overXYears: {
288
+ one: 'over 1 year',
289
+ other: 'over {{count}} years'
290
+ },
291
+ almostXYears: {
292
+ one: 'almost 1 year',
293
+ other: 'almost {{count}} years'
257
294
  }
258
295
  };
259
296
 
260
- var dayPeriodEnum = {
261
- am: 'am',
262
- pm: 'pm',
263
- midnight: 'midnight',
264
- noon: 'noon',
265
- morning: 'morning',
266
- afternoon: 'afternoon',
267
- evening: 'evening',
268
- night: 'night'
297
+ var formatDistance = function (token, count, options) {
298
+ var result;
299
+ var tokenValue = formatDistanceLocale[token];
300
+
301
+ if (typeof tokenValue === 'string') {
302
+ result = tokenValue;
303
+ } else if (count === 1) {
304
+ result = tokenValue.one;
305
+ } else {
306
+ result = tokenValue.other.replace('{{count}}', count.toString());
307
+ }
308
+
309
+ if (options !== null && options !== void 0 && options.addSuffix) {
310
+ if (options.comparison && options.comparison > 0) {
311
+ return 'in ' + result;
312
+ } else {
313
+ return result + ' ago';
314
+ }
315
+ }
316
+
317
+ return result;
269
318
  };
270
319
 
271
- /*
272
- * | | Unit | | Unit |
273
- * |-----|--------------------------------|-----|--------------------------------|
274
- * | a | AM, PM | A* | Milliseconds in day |
275
- * | b | AM, PM, noon, midnight | B | Flexible day period |
276
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
277
- * | d | Day of month | D | Day of year |
278
- * | e | Local day of week | E | Day of week |
279
- * | f | | F* | Day of week in month |
280
- * | g* | Modified Julian day | G | Era |
281
- * | h | Hour [1-12] | H | Hour [0-23] |
282
- * | i! | ISO day of week | I! | ISO week of year |
283
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
284
- * | k | Hour [1-24] | K | Hour [0-11] |
285
- * | l* | (deprecated) | L | Stand-alone month |
286
- * | m | Minute | M | Month |
287
- * | n | | N | |
288
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
289
- * | p! | Long localized time | P! | Long localized date |
320
+ function buildFormatLongFn(args) {
321
+ return function () {
322
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
323
+ // TODO: Remove String()
324
+ var width = options.width ? String(options.width) : args.defaultWidth;
325
+ var format = args.formats[width] || args.formats[args.defaultWidth];
326
+ return format;
327
+ };
328
+ }
329
+
330
+ var dateFormats = {
331
+ full: 'EEEE, MMMM do, y',
332
+ long: 'MMMM do, y',
333
+ medium: 'MMM d, y',
334
+ short: 'MM/dd/yyyy'
335
+ };
336
+ var timeFormats = {
337
+ full: 'h:mm:ss a zzzz',
338
+ long: 'h:mm:ss a z',
339
+ medium: 'h:mm:ss a',
340
+ short: 'h:mm a'
341
+ };
342
+ var dateTimeFormats = {
343
+ full: "{{date}} 'at' {{time}}",
344
+ long: "{{date}} 'at' {{time}}",
345
+ medium: '{{date}}, {{time}}',
346
+ short: '{{date}}, {{time}}'
347
+ };
348
+ var formatLong = {
349
+ date: buildFormatLongFn({
350
+ formats: dateFormats,
351
+ defaultWidth: 'full'
352
+ }),
353
+ time: buildFormatLongFn({
354
+ formats: timeFormats,
355
+ defaultWidth: 'full'
356
+ }),
357
+ dateTime: buildFormatLongFn({
358
+ formats: dateTimeFormats,
359
+ defaultWidth: 'full'
360
+ })
361
+ };
362
+
363
+ var formatRelativeLocale = {
364
+ lastWeek: "'last' eeee 'at' p",
365
+ yesterday: "'yesterday at' p",
366
+ today: "'today at' p",
367
+ tomorrow: "'tomorrow at' p",
368
+ nextWeek: "eeee 'at' p",
369
+ other: 'P'
370
+ };
371
+
372
+ var formatRelative = function (token, _date, _baseDate, _options) {
373
+ return formatRelativeLocale[token];
374
+ };
375
+
376
+ function buildLocalizeFn(args) {
377
+ return function (dirtyIndex, dirtyOptions) {
378
+ var options = dirtyOptions || {};
379
+ var context = options.context ? String(options.context) : 'standalone';
380
+ var valuesArray;
381
+
382
+ if (context === 'formatting' && args.formattingValues) {
383
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
384
+ var width = options.width ? String(options.width) : defaultWidth;
385
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
386
+ } else {
387
+ var _defaultWidth = args.defaultWidth;
388
+
389
+ var _width = options.width ? String(options.width) : args.defaultWidth;
390
+
391
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
392
+ }
393
+
394
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
395
+
396
+ return valuesArray[index];
397
+ };
398
+ }
399
+
400
+ var eraValues = {
401
+ narrow: ['B', 'A'],
402
+ abbreviated: ['BC', 'AD'],
403
+ wide: ['Before Christ', 'Anno Domini']
404
+ };
405
+ var quarterValues = {
406
+ narrow: ['1', '2', '3', '4'],
407
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
408
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
409
+ }; // Note: in English, the names of days of the week and months are capitalized.
410
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
411
+ // Generally, formatted dates should look like they are in the middle of a sentence,
412
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
413
+
414
+ var monthValues = {
415
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
416
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
417
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
418
+ };
419
+ var dayValues = {
420
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
421
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
422
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
423
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
424
+ };
425
+ var dayPeriodValues = {
426
+ narrow: {
427
+ am: 'a',
428
+ pm: 'p',
429
+ midnight: 'mi',
430
+ noon: 'n',
431
+ morning: 'morning',
432
+ afternoon: 'afternoon',
433
+ evening: 'evening',
434
+ night: 'night'
435
+ },
436
+ abbreviated: {
437
+ am: 'AM',
438
+ pm: 'PM',
439
+ midnight: 'midnight',
440
+ noon: 'noon',
441
+ morning: 'morning',
442
+ afternoon: 'afternoon',
443
+ evening: 'evening',
444
+ night: 'night'
445
+ },
446
+ wide: {
447
+ am: 'a.m.',
448
+ pm: 'p.m.',
449
+ midnight: 'midnight',
450
+ noon: 'noon',
451
+ morning: 'morning',
452
+ afternoon: 'afternoon',
453
+ evening: 'evening',
454
+ night: 'night'
455
+ }
456
+ };
457
+ var formattingDayPeriodValues = {
458
+ narrow: {
459
+ am: 'a',
460
+ pm: 'p',
461
+ midnight: 'mi',
462
+ noon: 'n',
463
+ morning: 'in the morning',
464
+ afternoon: 'in the afternoon',
465
+ evening: 'in the evening',
466
+ night: 'at night'
467
+ },
468
+ abbreviated: {
469
+ am: 'AM',
470
+ pm: 'PM',
471
+ midnight: 'midnight',
472
+ noon: 'noon',
473
+ morning: 'in the morning',
474
+ afternoon: 'in the afternoon',
475
+ evening: 'in the evening',
476
+ night: 'at night'
477
+ },
478
+ wide: {
479
+ am: 'a.m.',
480
+ pm: 'p.m.',
481
+ midnight: 'midnight',
482
+ noon: 'noon',
483
+ morning: 'in the morning',
484
+ afternoon: 'in the afternoon',
485
+ evening: 'in the evening',
486
+ night: 'at night'
487
+ }
488
+ };
489
+
490
+ var ordinalNumber = function (dirtyNumber, _options) {
491
+ var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
492
+ // if they are different for different grammatical genders,
493
+ // use `options.unit`.
494
+ //
495
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
496
+ // 'day', 'hour', 'minute', 'second'.
497
+
498
+ var rem100 = number % 100;
499
+
500
+ if (rem100 > 20 || rem100 < 10) {
501
+ switch (rem100 % 10) {
502
+ case 1:
503
+ return number + 'st';
504
+
505
+ case 2:
506
+ return number + 'nd';
507
+
508
+ case 3:
509
+ return number + 'rd';
510
+ }
511
+ }
512
+
513
+ return number + 'th';
514
+ };
515
+
516
+ var localize = {
517
+ ordinalNumber: ordinalNumber,
518
+ era: buildLocalizeFn({
519
+ values: eraValues,
520
+ defaultWidth: 'wide'
521
+ }),
522
+ quarter: buildLocalizeFn({
523
+ values: quarterValues,
524
+ defaultWidth: 'wide',
525
+ argumentCallback: function (quarter) {
526
+ return quarter - 1;
527
+ }
528
+ }),
529
+ month: buildLocalizeFn({
530
+ values: monthValues,
531
+ defaultWidth: 'wide'
532
+ }),
533
+ day: buildLocalizeFn({
534
+ values: dayValues,
535
+ defaultWidth: 'wide'
536
+ }),
537
+ dayPeriod: buildLocalizeFn({
538
+ values: dayPeriodValues,
539
+ defaultWidth: 'wide',
540
+ formattingValues: formattingDayPeriodValues,
541
+ defaultFormattingWidth: 'wide'
542
+ })
543
+ };
544
+
545
+ function buildMatchFn(args) {
546
+ return function (string) {
547
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
548
+ var width = options.width;
549
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
550
+ var matchResult = string.match(matchPattern);
551
+
552
+ if (!matchResult) {
553
+ return null;
554
+ }
555
+
556
+ var matchedString = matchResult[0];
557
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
558
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
559
+ return pattern.test(matchedString);
560
+ }) : findKey(parsePatterns, function (pattern) {
561
+ return pattern.test(matchedString);
562
+ });
563
+ var value;
564
+ value = args.valueCallback ? args.valueCallback(key) : key;
565
+ value = options.valueCallback ? options.valueCallback(value) : value;
566
+ var rest = string.slice(matchedString.length);
567
+ return {
568
+ value: value,
569
+ rest: rest
570
+ };
571
+ };
572
+ }
573
+
574
+ function findKey(object, predicate) {
575
+ for (var key in object) {
576
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
577
+ return key;
578
+ }
579
+ }
580
+
581
+ return undefined;
582
+ }
583
+
584
+ function findIndex(array, predicate) {
585
+ for (var key = 0; key < array.length; key++) {
586
+ if (predicate(array[key])) {
587
+ return key;
588
+ }
589
+ }
590
+
591
+ return undefined;
592
+ }
593
+
594
+ function buildMatchPatternFn(args) {
595
+ return function (string) {
596
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
597
+ var matchResult = string.match(args.matchPattern);
598
+ if (!matchResult) return null;
599
+ var matchedString = matchResult[0];
600
+ var parseResult = string.match(args.parsePattern);
601
+ if (!parseResult) return null;
602
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
603
+ value = options.valueCallback ? options.valueCallback(value) : value;
604
+ var rest = string.slice(matchedString.length);
605
+ return {
606
+ value: value,
607
+ rest: rest
608
+ };
609
+ };
610
+ }
611
+
612
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
613
+ var parseOrdinalNumberPattern = /\d+/i;
614
+ var matchEraPatterns = {
615
+ narrow: /^(b|a)/i,
616
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
617
+ wide: /^(before christ|before common era|anno domini|common era)/i
618
+ };
619
+ var parseEraPatterns = {
620
+ any: [/^b/i, /^(a|c)/i]
621
+ };
622
+ var matchQuarterPatterns = {
623
+ narrow: /^[1234]/i,
624
+ abbreviated: /^q[1234]/i,
625
+ wide: /^[1234](th|st|nd|rd)? quarter/i
626
+ };
627
+ var parseQuarterPatterns = {
628
+ any: [/1/i, /2/i, /3/i, /4/i]
629
+ };
630
+ var matchMonthPatterns = {
631
+ narrow: /^[jfmasond]/i,
632
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
633
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
634
+ };
635
+ var parseMonthPatterns = {
636
+ narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
637
+ any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
638
+ };
639
+ var matchDayPatterns = {
640
+ narrow: /^[smtwf]/i,
641
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
642
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
643
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
644
+ };
645
+ var parseDayPatterns = {
646
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
647
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
648
+ };
649
+ var matchDayPeriodPatterns = {
650
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
651
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
652
+ };
653
+ var parseDayPeriodPatterns = {
654
+ any: {
655
+ am: /^a/i,
656
+ pm: /^p/i,
657
+ midnight: /^mi/i,
658
+ noon: /^no/i,
659
+ morning: /morning/i,
660
+ afternoon: /afternoon/i,
661
+ evening: /evening/i,
662
+ night: /night/i
663
+ }
664
+ };
665
+ var match = {
666
+ ordinalNumber: buildMatchPatternFn({
667
+ matchPattern: matchOrdinalNumberPattern,
668
+ parsePattern: parseOrdinalNumberPattern,
669
+ valueCallback: function (value) {
670
+ return parseInt(value, 10);
671
+ }
672
+ }),
673
+ era: buildMatchFn({
674
+ matchPatterns: matchEraPatterns,
675
+ defaultMatchWidth: 'wide',
676
+ parsePatterns: parseEraPatterns,
677
+ defaultParseWidth: 'any'
678
+ }),
679
+ quarter: buildMatchFn({
680
+ matchPatterns: matchQuarterPatterns,
681
+ defaultMatchWidth: 'wide',
682
+ parsePatterns: parseQuarterPatterns,
683
+ defaultParseWidth: 'any',
684
+ valueCallback: function (index) {
685
+ return index + 1;
686
+ }
687
+ }),
688
+ month: buildMatchFn({
689
+ matchPatterns: matchMonthPatterns,
690
+ defaultMatchWidth: 'wide',
691
+ parsePatterns: parseMonthPatterns,
692
+ defaultParseWidth: 'any'
693
+ }),
694
+ day: buildMatchFn({
695
+ matchPatterns: matchDayPatterns,
696
+ defaultMatchWidth: 'wide',
697
+ parsePatterns: parseDayPatterns,
698
+ defaultParseWidth: 'any'
699
+ }),
700
+ dayPeriod: buildMatchFn({
701
+ matchPatterns: matchDayPeriodPatterns,
702
+ defaultMatchWidth: 'any',
703
+ parsePatterns: parseDayPeriodPatterns,
704
+ defaultParseWidth: 'any'
705
+ })
706
+ };
707
+
708
+ /**
709
+ * @type {Locale}
710
+ * @category Locales
711
+ * @summary English locale (United States).
712
+ * @language English
713
+ * @iso-639-2 eng
714
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
715
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
716
+ */
717
+ var locale = {
718
+ code: 'en-US',
719
+ formatDistance: formatDistance,
720
+ formatLong: formatLong,
721
+ formatRelative: formatRelative,
722
+ localize: localize,
723
+ match: match,
724
+ options: {
725
+ weekStartsOn: 0
726
+ /* Sunday */
727
+ ,
728
+ firstWeekContainsDate: 1
729
+ }
730
+ };
731
+
732
+ /**
733
+ * @name subMilliseconds
734
+ * @category Millisecond Helpers
735
+ * @summary Subtract the specified number of milliseconds from the given date.
736
+ *
737
+ * @description
738
+ * Subtract the specified number of milliseconds from the given date.
739
+ *
740
+ * ### v2.0.0 breaking changes:
741
+ *
742
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
743
+ *
744
+ * @param {Date|Number} date - the date to be changed
745
+ * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
746
+ * @returns {Date} the new date with the milliseconds subtracted
747
+ * @throws {TypeError} 2 arguments required
748
+ *
749
+ * @example
750
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
751
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
752
+ * //=> Thu Jul 10 2014 12:45:29.250
753
+ */
754
+
755
+ function subMilliseconds(dirtyDate, dirtyAmount) {
756
+ requiredArgs(2, arguments);
757
+ var amount = toInteger(dirtyAmount);
758
+ return addMilliseconds(dirtyDate, -amount);
759
+ }
760
+
761
+ var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
762
+ // See issue: https://github.com/date-fns/date-fns/issues/376
763
+
764
+ function getUTCDayOfYear(dirtyDate) {
765
+ requiredArgs(1, arguments);
766
+ var date = toDate(dirtyDate);
767
+ var timestamp = date.getTime();
768
+ date.setUTCMonth(0, 1);
769
+ date.setUTCHours(0, 0, 0, 0);
770
+ var startOfYearTimestamp = date.getTime();
771
+ var difference = timestamp - startOfYearTimestamp;
772
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
773
+ }
774
+
775
+ // See issue: https://github.com/date-fns/date-fns/issues/376
776
+
777
+ function startOfUTCISOWeek(dirtyDate) {
778
+ requiredArgs(1, arguments);
779
+ var weekStartsOn = 1;
780
+ var date = toDate(dirtyDate);
781
+ var day = date.getUTCDay();
782
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
783
+ date.setUTCDate(date.getUTCDate() - diff);
784
+ date.setUTCHours(0, 0, 0, 0);
785
+ return date;
786
+ }
787
+
788
+ // See issue: https://github.com/date-fns/date-fns/issues/376
789
+
790
+ function getUTCISOWeekYear(dirtyDate) {
791
+ requiredArgs(1, arguments);
792
+ var date = toDate(dirtyDate);
793
+ var year = date.getUTCFullYear();
794
+ var fourthOfJanuaryOfNextYear = new Date(0);
795
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
796
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
797
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
798
+ var fourthOfJanuaryOfThisYear = new Date(0);
799
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
800
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
801
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
802
+
803
+ if (date.getTime() >= startOfNextYear.getTime()) {
804
+ return year + 1;
805
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
806
+ return year;
807
+ } else {
808
+ return year - 1;
809
+ }
810
+ }
811
+
812
+ // See issue: https://github.com/date-fns/date-fns/issues/376
813
+
814
+ function startOfUTCISOWeekYear(dirtyDate) {
815
+ requiredArgs(1, arguments);
816
+ var year = getUTCISOWeekYear(dirtyDate);
817
+ var fourthOfJanuary = new Date(0);
818
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
819
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
820
+ var date = startOfUTCISOWeek(fourthOfJanuary);
821
+ return date;
822
+ }
823
+
824
+ var MILLISECONDS_IN_WEEK$1 = 604800000; // This function will be a part of public API when UTC function will be implemented.
825
+ // See issue: https://github.com/date-fns/date-fns/issues/376
826
+
827
+ function getUTCISOWeek(dirtyDate) {
828
+ requiredArgs(1, arguments);
829
+ var date = toDate(dirtyDate);
830
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
831
+ // because the number of milliseconds in a week is not constant
832
+ // (e.g. it's different in the week of the daylight saving time clock shift)
833
+
834
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
835
+ }
836
+
837
+ // See issue: https://github.com/date-fns/date-fns/issues/376
838
+
839
+ function startOfUTCWeek(dirtyDate, dirtyOptions) {
840
+ requiredArgs(1, arguments);
841
+ var options = dirtyOptions || {};
842
+ var locale = options.locale;
843
+ var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
844
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
845
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
846
+
847
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
848
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
849
+ }
850
+
851
+ var date = toDate(dirtyDate);
852
+ var day = date.getUTCDay();
853
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
854
+ date.setUTCDate(date.getUTCDate() - diff);
855
+ date.setUTCHours(0, 0, 0, 0);
856
+ return date;
857
+ }
858
+
859
+ // See issue: https://github.com/date-fns/date-fns/issues/376
860
+
861
+ function getUTCWeekYear(dirtyDate, dirtyOptions) {
862
+ requiredArgs(1, arguments);
863
+ var date = toDate(dirtyDate);
864
+ var year = date.getUTCFullYear();
865
+ var options = dirtyOptions || {};
866
+ var locale = options.locale;
867
+ var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
868
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
869
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
870
+
871
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
872
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
873
+ }
874
+
875
+ var firstWeekOfNextYear = new Date(0);
876
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
877
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
878
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, dirtyOptions);
879
+ var firstWeekOfThisYear = new Date(0);
880
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
881
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
882
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, dirtyOptions);
883
+
884
+ if (date.getTime() >= startOfNextYear.getTime()) {
885
+ return year + 1;
886
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
887
+ return year;
888
+ } else {
889
+ return year - 1;
890
+ }
891
+ }
892
+
893
+ // See issue: https://github.com/date-fns/date-fns/issues/376
894
+
895
+ function startOfUTCWeekYear(dirtyDate, dirtyOptions) {
896
+ requiredArgs(1, arguments);
897
+ var options = dirtyOptions || {};
898
+ var locale = options.locale;
899
+ var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
900
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
901
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
902
+ var year = getUTCWeekYear(dirtyDate, dirtyOptions);
903
+ var firstWeek = new Date(0);
904
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
905
+ firstWeek.setUTCHours(0, 0, 0, 0);
906
+ var date = startOfUTCWeek(firstWeek, dirtyOptions);
907
+ return date;
908
+ }
909
+
910
+ var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented.
911
+ // See issue: https://github.com/date-fns/date-fns/issues/376
912
+
913
+ function getUTCWeek(dirtyDate, options) {
914
+ requiredArgs(1, arguments);
915
+ var date = toDate(dirtyDate);
916
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer
917
+ // because the number of milliseconds in a week is not constant
918
+ // (e.g. it's different in the week of the daylight saving time clock shift)
919
+
920
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
921
+ }
922
+
923
+ function addLeadingZeros(number, targetLength) {
924
+ var sign = number < 0 ? '-' : '';
925
+ var output = Math.abs(number).toString();
926
+
927
+ while (output.length < targetLength) {
928
+ output = '0' + output;
929
+ }
930
+
931
+ return sign + output;
932
+ }
933
+
934
+ /*
935
+ * | | Unit | | Unit |
936
+ * |-----|--------------------------------|-----|--------------------------------|
937
+ * | a | AM, PM | A* | |
938
+ * | d | Day of month | D | |
939
+ * | h | Hour [1-12] | H | Hour [0-23] |
940
+ * | m | Minute | M | Month |
941
+ * | s | Second | S | Fraction of second |
942
+ * | y | Year (abs) | Y | |
943
+ *
944
+ * Letters marked by * are not implemented but reserved by Unicode standard.
945
+ */
946
+
947
+ var formatters$1 = {
948
+ // Year
949
+ y: function (date, token) {
950
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
951
+ // | Year | y | yy | yyy | yyyy | yyyyy |
952
+ // |----------|-------|----|-------|-------|-------|
953
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
954
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
955
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
956
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
957
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
958
+ var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
959
+
960
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
961
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
962
+ },
963
+ // Month
964
+ M: function (date, token) {
965
+ var month = date.getUTCMonth();
966
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
967
+ },
968
+ // Day of the month
969
+ d: function (date, token) {
970
+ return addLeadingZeros(date.getUTCDate(), token.length);
971
+ },
972
+ // AM or PM
973
+ a: function (date, token) {
974
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
975
+
976
+ switch (token) {
977
+ case 'a':
978
+ case 'aa':
979
+ return dayPeriodEnumValue.toUpperCase();
980
+
981
+ case 'aaa':
982
+ return dayPeriodEnumValue;
983
+
984
+ case 'aaaaa':
985
+ return dayPeriodEnumValue[0];
986
+
987
+ case 'aaaa':
988
+ default:
989
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
990
+ }
991
+ },
992
+ // Hour [1-12]
993
+ h: function (date, token) {
994
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
995
+ },
996
+ // Hour [0-23]
997
+ H: function (date, token) {
998
+ return addLeadingZeros(date.getUTCHours(), token.length);
999
+ },
1000
+ // Minute
1001
+ m: function (date, token) {
1002
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
1003
+ },
1004
+ // Second
1005
+ s: function (date, token) {
1006
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
1007
+ },
1008
+ // Fraction of second
1009
+ S: function (date, token) {
1010
+ var numberOfDigits = token.length;
1011
+ var milliseconds = date.getUTCMilliseconds();
1012
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
1013
+ return addLeadingZeros(fractionalSeconds, token.length);
1014
+ }
1015
+ };
1016
+
1017
+ var dayPeriodEnum = {
1018
+ am: 'am',
1019
+ pm: 'pm',
1020
+ midnight: 'midnight',
1021
+ noon: 'noon',
1022
+ morning: 'morning',
1023
+ afternoon: 'afternoon',
1024
+ evening: 'evening',
1025
+ night: 'night'
1026
+ };
1027
+ /*
1028
+ * | | Unit | | Unit |
1029
+ * |-----|--------------------------------|-----|--------------------------------|
1030
+ * | a | AM, PM | A* | Milliseconds in day |
1031
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
1032
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
1033
+ * | d | Day of month | D | Day of year |
1034
+ * | e | Local day of week | E | Day of week |
1035
+ * | f | | F* | Day of week in month |
1036
+ * | g* | Modified Julian day | G | Era |
1037
+ * | h | Hour [1-12] | H | Hour [0-23] |
1038
+ * | i! | ISO day of week | I! | ISO week of year |
1039
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
1040
+ * | k | Hour [1-24] | K | Hour [0-11] |
1041
+ * | l* | (deprecated) | L | Stand-alone month |
1042
+ * | m | Minute | M | Month |
1043
+ * | n | | N | |
1044
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
1045
+ * | p! | Long localized time | P! | Long localized date |
290
1046
  * | q | Stand-alone quarter | Q | Quarter |
291
1047
  * | r* | Related Gregorian year | R! | ISO week-numbering year |
292
1048
  * | s | Second | S | Fraction of second |
@@ -313,9 +1069,10 @@ var dayPeriodEnum = {
313
1069
  * - `P` is long localized date format
314
1070
  * - `p` is long localized time format
315
1071
  */
1072
+
316
1073
  var formatters = {
317
1074
  // Era
318
- G: function G(date, token, localize) {
1075
+ G: function (date, token, localize) {
319
1076
  var era = date.getUTCFullYear() > 0 ? 1 : 0;
320
1077
 
321
1078
  switch (token) {
@@ -342,7 +1099,7 @@ var formatters = {
342
1099
  }
343
1100
  },
344
1101
  // Year
345
- y: function y(date, token, localize) {
1102
+ y: function (date, token, localize) {
346
1103
  // Ordinal number
347
1104
  if (token === 'yo') {
348
1105
  var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
@@ -356,7 +1113,7 @@ var formatters = {
356
1113
  return formatters$1.y(date, token);
357
1114
  },
358
1115
  // Local week-numbering year
359
- Y: function Y(date, token, localize, options) {
1116
+ Y: function (date, token, localize, options) {
360
1117
  var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)
361
1118
 
362
1119
  var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year
@@ -377,7 +1134,7 @@ var formatters = {
377
1134
  return addLeadingZeros(weekYear, token.length);
378
1135
  },
379
1136
  // ISO week-numbering year
380
- R: function R(date, token) {
1137
+ R: function (date, token) {
381
1138
  var isoWeekYear = getUTCISOWeekYear(date); // Padding
382
1139
 
383
1140
  return addLeadingZeros(isoWeekYear, token.length);
@@ -391,12 +1148,12 @@ var formatters = {
391
1148
  // | BC 2 | 2 | -1 |
392
1149
  // Also `yy` always returns the last two digits of a year,
393
1150
  // while `uu` pads single digit years to 2 characters and returns other years unchanged.
394
- u: function u(date, token) {
1151
+ u: function (date, token) {
395
1152
  var year = date.getUTCFullYear();
396
1153
  return addLeadingZeros(year, token.length);
397
1154
  },
398
1155
  // Quarter
399
- Q: function Q(date, token, localize) {
1156
+ Q: function (date, token, localize) {
400
1157
  var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
401
1158
 
402
1159
  switch (token) {
@@ -438,7 +1195,7 @@ var formatters = {
438
1195
  }
439
1196
  },
440
1197
  // Stand-alone quarter
441
- q: function q(date, token, localize) {
1198
+ q: function (date, token, localize) {
442
1199
  var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
443
1200
 
444
1201
  switch (token) {
@@ -480,7 +1237,7 @@ var formatters = {
480
1237
  }
481
1238
  },
482
1239
  // Month
483
- M: function M(date, token, localize) {
1240
+ M: function (date, token, localize) {
484
1241
  var month = date.getUTCMonth();
485
1242
 
486
1243
  switch (token) {
@@ -518,7 +1275,7 @@ var formatters = {
518
1275
  }
519
1276
  },
520
1277
  // Stand-alone month
521
- L: function L(date, token, localize) {
1278
+ L: function (date, token, localize) {
522
1279
  var month = date.getUTCMonth();
523
1280
 
524
1281
  switch (token) {
@@ -560,7 +1317,7 @@ var formatters = {
560
1317
  }
561
1318
  },
562
1319
  // Local week of year
563
- w: function w(date, token, localize, options) {
1320
+ w: function (date, token, localize, options) {
564
1321
  var week = getUTCWeek(date, options);
565
1322
 
566
1323
  if (token === 'wo') {
@@ -572,7 +1329,7 @@ var formatters = {
572
1329
  return addLeadingZeros(week, token.length);
573
1330
  },
574
1331
  // ISO week of year
575
- I: function I(date, token, localize) {
1332
+ I: function (date, token, localize) {
576
1333
  var isoWeek = getUTCISOWeek(date);
577
1334
 
578
1335
  if (token === 'Io') {
@@ -584,7 +1341,7 @@ var formatters = {
584
1341
  return addLeadingZeros(isoWeek, token.length);
585
1342
  },
586
1343
  // Day of the month
587
- d: function d(date, token, localize) {
1344
+ d: function (date, token, localize) {
588
1345
  if (token === 'do') {
589
1346
  return localize.ordinalNumber(date.getUTCDate(), {
590
1347
  unit: 'date'
@@ -594,7 +1351,7 @@ var formatters = {
594
1351
  return formatters$1.d(date, token);
595
1352
  },
596
1353
  // Day of year
597
- D: function D(date, token, localize) {
1354
+ D: function (date, token, localize) {
598
1355
  var dayOfYear = getUTCDayOfYear(date);
599
1356
 
600
1357
  if (token === 'Do') {
@@ -606,7 +1363,7 @@ var formatters = {
606
1363
  return addLeadingZeros(dayOfYear, token.length);
607
1364
  },
608
1365
  // Day of week
609
- E: function E(date, token, localize) {
1366
+ E: function (date, token, localize) {
610
1367
  var dayOfWeek = date.getUTCDay();
611
1368
 
612
1369
  switch (token) {
@@ -643,7 +1400,7 @@ var formatters = {
643
1400
  }
644
1401
  },
645
1402
  // Local day of week
646
- e: function e(date, token, localize, options) {
1403
+ e: function (date, token, localize, options) {
647
1404
  var dayOfWeek = date.getUTCDay();
648
1405
  var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
649
1406
 
@@ -692,7 +1449,7 @@ var formatters = {
692
1449
  }
693
1450
  },
694
1451
  // Stand-alone local day of week
695
- c: function c(date, token, localize, options) {
1452
+ c: function (date, token, localize, options) {
696
1453
  var dayOfWeek = date.getUTCDay();
697
1454
  var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
698
1455
 
@@ -741,7 +1498,7 @@ var formatters = {
741
1498
  }
742
1499
  },
743
1500
  // ISO day of week
744
- i: function i(date, token, localize) {
1501
+ i: function (date, token, localize) {
745
1502
  var dayOfWeek = date.getUTCDay();
746
1503
  var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
747
1504
 
@@ -791,7 +1548,7 @@ var formatters = {
791
1548
  }
792
1549
  },
793
1550
  // AM or PM
794
- a: function a(date, token, localize) {
1551
+ a: function (date, token, localize) {
795
1552
  var hours = date.getUTCHours();
796
1553
  var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
797
1554
 
@@ -824,7 +1581,7 @@ var formatters = {
824
1581
  }
825
1582
  },
826
1583
  // AM, PM, midnight, noon
827
- b: function b(date, token, localize) {
1584
+ b: function (date, token, localize) {
828
1585
  var hours = date.getUTCHours();
829
1586
  var dayPeriodEnumValue;
830
1587
 
@@ -865,7 +1622,7 @@ var formatters = {
865
1622
  }
866
1623
  },
867
1624
  // in the morning, in the afternoon, in the evening, at night
868
- B: function B(date, token, localize) {
1625
+ B: function (date, token, localize) {
869
1626
  var hours = date.getUTCHours();
870
1627
  var dayPeriodEnumValue;
871
1628
 
@@ -903,831 +1660,333 @@ var formatters = {
903
1660
  }
904
1661
  },
905
1662
  // Hour [1-12]
906
- h: function h(date, token, localize) {
1663
+ h: function (date, token, localize) {
907
1664
  if (token === 'ho') {
908
1665
  var hours = date.getUTCHours() % 12;
909
1666
  if (hours === 0) hours = 12;
910
1667
  return localize.ordinalNumber(hours, {
911
- unit: 'hour'
912
- });
913
- }
914
-
915
- return formatters$1.h(date, token);
916
- },
917
- // Hour [0-23]
918
- H: function H(date, token, localize) {
919
- if (token === 'Ho') {
920
- return localize.ordinalNumber(date.getUTCHours(), {
921
- unit: 'hour'
922
- });
923
- }
924
-
925
- return formatters$1.H(date, token);
926
- },
927
- // Hour [0-11]
928
- K: function K(date, token, localize) {
929
- var hours = date.getUTCHours() % 12;
930
-
931
- if (token === 'Ko') {
932
- return localize.ordinalNumber(hours, {
933
- unit: 'hour'
934
- });
935
- }
936
-
937
- return addLeadingZeros(hours, token.length);
938
- },
939
- // Hour [1-24]
940
- k: function k(date, token, localize) {
941
- var hours = date.getUTCHours();
942
- if (hours === 0) hours = 24;
943
-
944
- if (token === 'ko') {
945
- return localize.ordinalNumber(hours, {
946
- unit: 'hour'
947
- });
948
- }
949
-
950
- return addLeadingZeros(hours, token.length);
951
- },
952
- // Minute
953
- m: function m(date, token, localize) {
954
- if (token === 'mo') {
955
- return localize.ordinalNumber(date.getUTCMinutes(), {
956
- unit: 'minute'
957
- });
958
- }
959
-
960
- return formatters$1.m(date, token);
961
- },
962
- // Second
963
- s: function s(date, token, localize) {
964
- if (token === 'so') {
965
- return localize.ordinalNumber(date.getUTCSeconds(), {
966
- unit: 'second'
967
- });
968
- }
969
-
970
- return formatters$1.s(date, token);
971
- },
972
- // Fraction of second
973
- S: function S(date, token) {
974
- return formatters$1.S(date, token);
975
- },
976
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
977
- X: function X(date, token, _localize, options) {
978
- var originalDate = options._originalDate || date;
979
- var timezoneOffset = originalDate.getTimezoneOffset();
980
-
981
- if (timezoneOffset === 0) {
982
- return 'Z';
983
- }
984
-
985
- switch (token) {
986
- // Hours and optional minutes
987
- case 'X':
988
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
989
- // Hours, minutes and optional seconds without `:` delimiter
990
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
991
- // so this token always has the same output as `XX`
992
-
993
- case 'XXXX':
994
- case 'XX':
995
- // Hours and minutes without `:` delimiter
996
- return formatTimezone(timezoneOffset);
997
- // Hours, minutes and optional seconds with `:` delimiter
998
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
999
- // so this token always has the same output as `XXX`
1000
-
1001
- case 'XXXXX':
1002
- case 'XXX': // Hours and minutes with `:` delimiter
1003
-
1004
- default:
1005
- return formatTimezone(timezoneOffset, ':');
1006
- }
1007
- },
1008
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1009
- x: function x(date, token, _localize, options) {
1010
- var originalDate = options._originalDate || date;
1011
- var timezoneOffset = originalDate.getTimezoneOffset();
1012
-
1013
- switch (token) {
1014
- // Hours and optional minutes
1015
- case 'x':
1016
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1017
- // Hours, minutes and optional seconds without `:` delimiter
1018
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1019
- // so this token always has the same output as `xx`
1020
-
1021
- case 'xxxx':
1022
- case 'xx':
1023
- // Hours and minutes without `:` delimiter
1024
- return formatTimezone(timezoneOffset);
1025
- // Hours, minutes and optional seconds with `:` delimiter
1026
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1027
- // so this token always has the same output as `xxx`
1028
-
1029
- case 'xxxxx':
1030
- case 'xxx': // Hours and minutes with `:` delimiter
1031
-
1032
- default:
1033
- return formatTimezone(timezoneOffset, ':');
1034
- }
1035
- },
1036
- // Timezone (GMT)
1037
- O: function O(date, token, _localize, options) {
1038
- var originalDate = options._originalDate || date;
1039
- var timezoneOffset = originalDate.getTimezoneOffset();
1040
-
1041
- switch (token) {
1042
- // Short
1043
- case 'O':
1044
- case 'OO':
1045
- case 'OOO':
1046
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1047
- // Long
1048
-
1049
- case 'OOOO':
1050
- default:
1051
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1052
- }
1053
- },
1054
- // Timezone (specific non-location)
1055
- z: function z(date, token, _localize, options) {
1056
- var originalDate = options._originalDate || date;
1057
- var timezoneOffset = originalDate.getTimezoneOffset();
1058
-
1059
- switch (token) {
1060
- // Short
1061
- case 'z':
1062
- case 'zz':
1063
- case 'zzz':
1064
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1065
- // Long
1066
-
1067
- case 'zzzz':
1068
- default:
1069
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1070
- }
1071
- },
1072
- // Seconds timestamp
1073
- t: function t(date, token, _localize, options) {
1074
- var originalDate = options._originalDate || date;
1075
- var timestamp = Math.floor(originalDate.getTime() / 1000);
1076
- return addLeadingZeros(timestamp, token.length);
1077
- },
1078
- // Milliseconds timestamp
1079
- T: function T(date, token, _localize, options) {
1080
- var originalDate = options._originalDate || date;
1081
- var timestamp = originalDate.getTime();
1082
- return addLeadingZeros(timestamp, token.length);
1083
- }
1084
- };
1085
-
1086
- function formatTimezoneShort(offset, dirtyDelimiter) {
1087
- var sign = offset > 0 ? '-' : '+';
1088
- var absOffset = Math.abs(offset);
1089
- var hours = Math.floor(absOffset / 60);
1090
- var minutes = absOffset % 60;
1091
-
1092
- if (minutes === 0) {
1093
- return sign + String(hours);
1094
- }
1095
-
1096
- var delimiter = dirtyDelimiter || '';
1097
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1098
- }
1099
-
1100
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1101
- if (offset % 60 === 0) {
1102
- var sign = offset > 0 ? '-' : '+';
1103
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1104
- }
1105
-
1106
- return formatTimezone(offset, dirtyDelimiter);
1107
- }
1108
-
1109
- function formatTimezone(offset, dirtyDelimiter) {
1110
- var delimiter = dirtyDelimiter || '';
1111
- var sign = offset > 0 ? '-' : '+';
1112
- var absOffset = Math.abs(offset);
1113
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1114
- var minutes = addLeadingZeros(absOffset % 60, 2);
1115
- return sign + hours + delimiter + minutes;
1116
- }
1117
-
1118
- var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1119
- switch (pattern) {
1120
- case 'P':
1121
- return formatLong.date({
1122
- width: 'short'
1123
- });
1124
-
1125
- case 'PP':
1126
- return formatLong.date({
1127
- width: 'medium'
1128
- });
1129
-
1130
- case 'PPP':
1131
- return formatLong.date({
1132
- width: 'long'
1133
- });
1134
-
1135
- case 'PPPP':
1136
- default:
1137
- return formatLong.date({
1138
- width: 'full'
1139
- });
1140
- }
1141
- };
1142
-
1143
- var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1144
- switch (pattern) {
1145
- case 'p':
1146
- return formatLong.time({
1147
- width: 'short'
1668
+ unit: 'hour'
1148
1669
  });
1670
+ }
1149
1671
 
1150
- case 'pp':
1151
- return formatLong.time({
1152
- width: 'medium'
1672
+ return formatters$1.h(date, token);
1673
+ },
1674
+ // Hour [0-23]
1675
+ H: function (date, token, localize) {
1676
+ if (token === 'Ho') {
1677
+ return localize.ordinalNumber(date.getUTCHours(), {
1678
+ unit: 'hour'
1153
1679
  });
1680
+ }
1154
1681
 
1155
- case 'ppp':
1156
- return formatLong.time({
1157
- width: 'long'
1158
- });
1682
+ return formatters$1.H(date, token);
1683
+ },
1684
+ // Hour [0-11]
1685
+ K: function (date, token, localize) {
1686
+ var hours = date.getUTCHours() % 12;
1159
1687
 
1160
- case 'pppp':
1161
- default:
1162
- return formatLong.time({
1163
- width: 'full'
1688
+ if (token === 'Ko') {
1689
+ return localize.ordinalNumber(hours, {
1690
+ unit: 'hour'
1164
1691
  });
1165
- }
1166
- };
1167
-
1168
- var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1169
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
1170
- var datePattern = matchResult[1];
1171
- var timePattern = matchResult[2];
1172
-
1173
- if (!timePattern) {
1174
- return dateLongFormatter(pattern, formatLong);
1175
- }
1176
-
1177
- var dateTimeFormat;
1692
+ }
1178
1693
 
1179
- switch (datePattern) {
1180
- case 'P':
1181
- dateTimeFormat = formatLong.dateTime({
1182
- width: 'short'
1183
- });
1184
- break;
1694
+ return addLeadingZeros(hours, token.length);
1695
+ },
1696
+ // Hour [1-24]
1697
+ k: function (date, token, localize) {
1698
+ var hours = date.getUTCHours();
1699
+ if (hours === 0) hours = 24;
1185
1700
 
1186
- case 'PP':
1187
- dateTimeFormat = formatLong.dateTime({
1188
- width: 'medium'
1701
+ if (token === 'ko') {
1702
+ return localize.ordinalNumber(hours, {
1703
+ unit: 'hour'
1189
1704
  });
1190
- break;
1705
+ }
1191
1706
 
1192
- case 'PPP':
1193
- dateTimeFormat = formatLong.dateTime({
1194
- width: 'long'
1707
+ return addLeadingZeros(hours, token.length);
1708
+ },
1709
+ // Minute
1710
+ m: function (date, token, localize) {
1711
+ if (token === 'mo') {
1712
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1713
+ unit: 'minute'
1195
1714
  });
1196
- break;
1715
+ }
1197
1716
 
1198
- case 'PPPP':
1199
- default:
1200
- dateTimeFormat = formatLong.dateTime({
1201
- width: 'full'
1717
+ return formatters$1.m(date, token);
1718
+ },
1719
+ // Second
1720
+ s: function (date, token, localize) {
1721
+ if (token === 'so') {
1722
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1723
+ unit: 'second'
1202
1724
  });
1203
- break;
1204
- }
1205
-
1206
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1207
- };
1208
-
1209
- var longFormatters = {
1210
- p: timeLongFormatter,
1211
- P: dateTimeLongFormatter
1212
- };
1213
-
1214
- var protectedDayOfYearTokens = ['D', 'DD'];
1215
- var protectedWeekYearTokens = ['YY', 'YYYY'];
1216
- function isProtectedDayOfYearToken(token) {
1217
- return protectedDayOfYearTokens.indexOf(token) !== -1;
1218
- }
1219
- function isProtectedWeekYearToken(token) {
1220
- return protectedWeekYearTokens.indexOf(token) !== -1;
1221
- }
1222
- function throwProtectedError(token, format, input) {
1223
- if (token === 'YYYY') {
1224
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1225
- } else if (token === 'YY') {
1226
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1227
- } else if (token === 'D') {
1228
- throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1229
- } else if (token === 'DD') {
1230
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1231
- }
1232
- }
1725
+ }
1233
1726
 
1234
- var formatDistanceLocale = {
1235
- lessThanXSeconds: {
1236
- one: 'less than a second',
1237
- other: 'less than {{count}} seconds'
1238
- },
1239
- xSeconds: {
1240
- one: '1 second',
1241
- other: '{{count}} seconds'
1242
- },
1243
- halfAMinute: 'half a minute',
1244
- lessThanXMinutes: {
1245
- one: 'less than a minute',
1246
- other: 'less than {{count}} minutes'
1247
- },
1248
- xMinutes: {
1249
- one: '1 minute',
1250
- other: '{{count}} minutes'
1251
- },
1252
- aboutXHours: {
1253
- one: 'about 1 hour',
1254
- other: 'about {{count}} hours'
1255
- },
1256
- xHours: {
1257
- one: '1 hour',
1258
- other: '{{count}} hours'
1259
- },
1260
- xDays: {
1261
- one: '1 day',
1262
- other: '{{count}} days'
1263
- },
1264
- aboutXWeeks: {
1265
- one: 'about 1 week',
1266
- other: 'about {{count}} weeks'
1267
- },
1268
- xWeeks: {
1269
- one: '1 week',
1270
- other: '{{count}} weeks'
1271
- },
1272
- aboutXMonths: {
1273
- one: 'about 1 month',
1274
- other: 'about {{count}} months'
1275
- },
1276
- xMonths: {
1277
- one: '1 month',
1278
- other: '{{count}} months'
1279
- },
1280
- aboutXYears: {
1281
- one: 'about 1 year',
1282
- other: 'about {{count}} years'
1283
- },
1284
- xYears: {
1285
- one: '1 year',
1286
- other: '{{count}} years'
1727
+ return formatters$1.s(date, token);
1287
1728
  },
1288
- overXYears: {
1289
- one: 'over 1 year',
1290
- other: 'over {{count}} years'
1729
+ // Fraction of second
1730
+ S: function (date, token) {
1731
+ return formatters$1.S(date, token);
1291
1732
  },
1292
- almostXYears: {
1293
- one: 'almost 1 year',
1294
- other: 'almost {{count}} years'
1295
- }
1296
- };
1297
-
1298
- var formatDistance = function formatDistance(token, count, options) {
1299
- var result;
1300
- var tokenValue = formatDistanceLocale[token];
1301
-
1302
- if (typeof tokenValue === 'string') {
1303
- result = tokenValue;
1304
- } else if (count === 1) {
1305
- result = tokenValue.one;
1306
- } else {
1307
- result = tokenValue.other.replace('{{count}}', count.toString());
1308
- }
1733
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1734
+ X: function (date, token, _localize, options) {
1735
+ var originalDate = options._originalDate || date;
1736
+ var timezoneOffset = originalDate.getTimezoneOffset();
1309
1737
 
1310
- if (options !== null && options !== void 0 && options.addSuffix) {
1311
- if (options.comparison && options.comparison > 0) {
1312
- return 'in ' + result;
1313
- } else {
1314
- return result + ' ago';
1738
+ if (timezoneOffset === 0) {
1739
+ return 'Z';
1315
1740
  }
1316
- }
1317
-
1318
- return result;
1319
- };
1320
-
1321
- function buildFormatLongFn(args) {
1322
- return function () {
1323
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1324
- // TODO: Remove String()
1325
- var width = options.width ? String(options.width) : args.defaultWidth;
1326
- var format = args.formats[width] || args.formats[args.defaultWidth];
1327
- return format;
1328
- };
1329
- }
1330
1741
 
1331
- var dateFormats = {
1332
- full: 'EEEE, MMMM do, y',
1333
- long: 'MMMM do, y',
1334
- medium: 'MMM d, y',
1335
- short: 'MM/dd/yyyy'
1336
- };
1337
- var timeFormats = {
1338
- full: 'h:mm:ss a zzzz',
1339
- long: 'h:mm:ss a z',
1340
- medium: 'h:mm:ss a',
1341
- short: 'h:mm a'
1342
- };
1343
- var dateTimeFormats = {
1344
- full: "{{date}} 'at' {{time}}",
1345
- long: "{{date}} 'at' {{time}}",
1346
- medium: '{{date}}, {{time}}',
1347
- short: '{{date}}, {{time}}'
1348
- };
1349
- var formatLong = {
1350
- date: buildFormatLongFn({
1351
- formats: dateFormats,
1352
- defaultWidth: 'full'
1353
- }),
1354
- time: buildFormatLongFn({
1355
- formats: timeFormats,
1356
- defaultWidth: 'full'
1357
- }),
1358
- dateTime: buildFormatLongFn({
1359
- formats: dateTimeFormats,
1360
- defaultWidth: 'full'
1361
- })
1362
- };
1742
+ switch (token) {
1743
+ // Hours and optional minutes
1744
+ case 'X':
1745
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1746
+ // Hours, minutes and optional seconds without `:` delimiter
1747
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1748
+ // so this token always has the same output as `XX`
1363
1749
 
1364
- var formatRelativeLocale = {
1365
- lastWeek: "'last' eeee 'at' p",
1366
- yesterday: "'yesterday at' p",
1367
- today: "'today at' p",
1368
- tomorrow: "'tomorrow at' p",
1369
- nextWeek: "eeee 'at' p",
1370
- other: 'P'
1371
- };
1750
+ case 'XXXX':
1751
+ case 'XX':
1752
+ // Hours and minutes without `:` delimiter
1753
+ return formatTimezone(timezoneOffset);
1754
+ // Hours, minutes and optional seconds with `:` delimiter
1755
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1756
+ // so this token always has the same output as `XXX`
1372
1757
 
1373
- var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1374
- return formatRelativeLocale[token];
1375
- };
1758
+ case 'XXXXX':
1759
+ case 'XXX': // Hours and minutes with `:` delimiter
1376
1760
 
1377
- function buildLocalizeFn(args) {
1378
- return function (dirtyIndex, options) {
1379
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1380
- var valuesArray;
1761
+ default:
1762
+ return formatTimezone(timezoneOffset, ':');
1763
+ }
1764
+ },
1765
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1766
+ x: function (date, token, _localize, options) {
1767
+ var originalDate = options._originalDate || date;
1768
+ var timezoneOffset = originalDate.getTimezoneOffset();
1381
1769
 
1382
- if (context === 'formatting' && args.formattingValues) {
1383
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1384
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1385
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1386
- } else {
1387
- var _defaultWidth = args.defaultWidth;
1770
+ switch (token) {
1771
+ // Hours and optional minutes
1772
+ case 'x':
1773
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1774
+ // Hours, minutes and optional seconds without `:` delimiter
1775
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1776
+ // so this token always has the same output as `xx`
1777
+
1778
+ case 'xxxx':
1779
+ case 'xx':
1780
+ // Hours and minutes without `:` delimiter
1781
+ return formatTimezone(timezoneOffset);
1782
+ // Hours, minutes and optional seconds with `:` delimiter
1783
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1784
+ // so this token always has the same output as `xxx`
1388
1785
 
1389
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1786
+ case 'xxxxx':
1787
+ case 'xxx': // Hours and minutes with `:` delimiter
1390
1788
 
1391
- valuesArray = args.values[_width] || args.values[_defaultWidth];
1789
+ default:
1790
+ return formatTimezone(timezoneOffset, ':');
1392
1791
  }
1792
+ },
1793
+ // Timezone (GMT)
1794
+ O: function (date, token, _localize, options) {
1795
+ var originalDate = options._originalDate || date;
1796
+ var timezoneOffset = originalDate.getTimezoneOffset();
1393
1797
 
1394
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1798
+ switch (token) {
1799
+ // Short
1800
+ case 'O':
1801
+ case 'OO':
1802
+ case 'OOO':
1803
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1804
+ // Long
1395
1805
 
1396
- return valuesArray[index];
1397
- };
1398
- }
1806
+ case 'OOOO':
1807
+ default:
1808
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1809
+ }
1810
+ },
1811
+ // Timezone (specific non-location)
1812
+ z: function (date, token, _localize, options) {
1813
+ var originalDate = options._originalDate || date;
1814
+ var timezoneOffset = originalDate.getTimezoneOffset();
1399
1815
 
1400
- var eraValues = {
1401
- narrow: ['B', 'A'],
1402
- abbreviated: ['BC', 'AD'],
1403
- wide: ['Before Christ', 'Anno Domini']
1404
- };
1405
- var quarterValues = {
1406
- narrow: ['1', '2', '3', '4'],
1407
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1408
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1409
- }; // Note: in English, the names of days of the week and months are capitalized.
1410
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1411
- // Generally, formatted dates should look like they are in the middle of a sentence,
1412
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
1816
+ switch (token) {
1817
+ // Short
1818
+ case 'z':
1819
+ case 'zz':
1820
+ case 'zzz':
1821
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1822
+ // Long
1413
1823
 
1414
- var monthValues = {
1415
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1416
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1417
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1418
- };
1419
- var dayValues = {
1420
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1421
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1422
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1423
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1424
- };
1425
- var dayPeriodValues = {
1426
- narrow: {
1427
- am: 'a',
1428
- pm: 'p',
1429
- midnight: 'mi',
1430
- noon: 'n',
1431
- morning: 'morning',
1432
- afternoon: 'afternoon',
1433
- evening: 'evening',
1434
- night: 'night'
1824
+ case 'zzzz':
1825
+ default:
1826
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1827
+ }
1435
1828
  },
1436
- abbreviated: {
1437
- am: 'AM',
1438
- pm: 'PM',
1439
- midnight: 'midnight',
1440
- noon: 'noon',
1441
- morning: 'morning',
1442
- afternoon: 'afternoon',
1443
- evening: 'evening',
1444
- night: 'night'
1829
+ // Seconds timestamp
1830
+ t: function (date, token, _localize, options) {
1831
+ var originalDate = options._originalDate || date;
1832
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1833
+ return addLeadingZeros(timestamp, token.length);
1445
1834
  },
1446
- wide: {
1447
- am: 'a.m.',
1448
- pm: 'p.m.',
1449
- midnight: 'midnight',
1450
- noon: 'noon',
1451
- morning: 'morning',
1452
- afternoon: 'afternoon',
1453
- evening: 'evening',
1454
- night: 'night'
1835
+ // Milliseconds timestamp
1836
+ T: function (date, token, _localize, options) {
1837
+ var originalDate = options._originalDate || date;
1838
+ var timestamp = originalDate.getTime();
1839
+ return addLeadingZeros(timestamp, token.length);
1455
1840
  }
1456
1841
  };
1457
- var formattingDayPeriodValues = {
1458
- narrow: {
1459
- am: 'a',
1460
- pm: 'p',
1461
- midnight: 'mi',
1462
- noon: 'n',
1463
- morning: 'in the morning',
1464
- afternoon: 'in the afternoon',
1465
- evening: 'in the evening',
1466
- night: 'at night'
1467
- },
1468
- abbreviated: {
1469
- am: 'AM',
1470
- pm: 'PM',
1471
- midnight: 'midnight',
1472
- noon: 'noon',
1473
- morning: 'in the morning',
1474
- afternoon: 'in the afternoon',
1475
- evening: 'in the evening',
1476
- night: 'at night'
1477
- },
1478
- wide: {
1479
- am: 'a.m.',
1480
- pm: 'p.m.',
1481
- midnight: 'midnight',
1482
- noon: 'noon',
1483
- morning: 'in the morning',
1484
- afternoon: 'in the afternoon',
1485
- evening: 'in the evening',
1486
- night: 'at night'
1842
+
1843
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1844
+ var sign = offset > 0 ? '-' : '+';
1845
+ var absOffset = Math.abs(offset);
1846
+ var hours = Math.floor(absOffset / 60);
1847
+ var minutes = absOffset % 60;
1848
+
1849
+ if (minutes === 0) {
1850
+ return sign + String(hours);
1487
1851
  }
1488
- };
1489
1852
 
1490
- var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1491
- var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
1492
- // if they are different for different grammatical genders,
1493
- // use `options.unit`.
1494
- //
1495
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1496
- // 'day', 'hour', 'minute', 'second'.
1853
+ var delimiter = dirtyDelimiter || '';
1854
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1855
+ }
1497
1856
 
1498
- var rem100 = number % 100;
1857
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1858
+ if (offset % 60 === 0) {
1859
+ var sign = offset > 0 ? '-' : '+';
1860
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1861
+ }
1499
1862
 
1500
- if (rem100 > 20 || rem100 < 10) {
1501
- switch (rem100 % 10) {
1502
- case 1:
1503
- return number + 'st';
1863
+ return formatTimezone(offset, dirtyDelimiter);
1864
+ }
1504
1865
 
1505
- case 2:
1506
- return number + 'nd';
1866
+ function formatTimezone(offset, dirtyDelimiter) {
1867
+ var delimiter = dirtyDelimiter || '';
1868
+ var sign = offset > 0 ? '-' : '+';
1869
+ var absOffset = Math.abs(offset);
1870
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1871
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1872
+ return sign + hours + delimiter + minutes;
1873
+ }
1507
1874
 
1508
- case 3:
1509
- return number + 'rd';
1510
- }
1511
- }
1875
+ function dateLongFormatter(pattern, formatLong) {
1876
+ switch (pattern) {
1877
+ case 'P':
1878
+ return formatLong.date({
1879
+ width: 'short'
1880
+ });
1512
1881
 
1513
- return number + 'th';
1514
- };
1882
+ case 'PP':
1883
+ return formatLong.date({
1884
+ width: 'medium'
1885
+ });
1515
1886
 
1516
- var localize = {
1517
- ordinalNumber: ordinalNumber,
1518
- era: buildLocalizeFn({
1519
- values: eraValues,
1520
- defaultWidth: 'wide'
1521
- }),
1522
- quarter: buildLocalizeFn({
1523
- values: quarterValues,
1524
- defaultWidth: 'wide',
1525
- argumentCallback: function argumentCallback(quarter) {
1526
- return quarter - 1;
1527
- }
1528
- }),
1529
- month: buildLocalizeFn({
1530
- values: monthValues,
1531
- defaultWidth: 'wide'
1532
- }),
1533
- day: buildLocalizeFn({
1534
- values: dayValues,
1535
- defaultWidth: 'wide'
1536
- }),
1537
- dayPeriod: buildLocalizeFn({
1538
- values: dayPeriodValues,
1539
- defaultWidth: 'wide',
1540
- formattingValues: formattingDayPeriodValues,
1541
- defaultFormattingWidth: 'wide'
1542
- })
1543
- };
1887
+ case 'PPP':
1888
+ return formatLong.date({
1889
+ width: 'long'
1890
+ });
1891
+
1892
+ case 'PPPP':
1893
+ default:
1894
+ return formatLong.date({
1895
+ width: 'full'
1896
+ });
1897
+ }
1898
+ }
1544
1899
 
1545
- function buildMatchFn(args) {
1546
- return function (string) {
1547
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1548
- var width = options.width;
1549
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1550
- var matchResult = string.match(matchPattern);
1900
+ function timeLongFormatter(pattern, formatLong) {
1901
+ switch (pattern) {
1902
+ case 'p':
1903
+ return formatLong.time({
1904
+ width: 'short'
1905
+ });
1551
1906
 
1552
- if (!matchResult) {
1553
- return null;
1554
- }
1907
+ case 'pp':
1908
+ return formatLong.time({
1909
+ width: 'medium'
1910
+ });
1555
1911
 
1556
- var matchedString = matchResult[0];
1557
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1558
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1559
- return pattern.test(matchedString);
1560
- }) : findKey(parsePatterns, function (pattern) {
1561
- return pattern.test(matchedString);
1562
- });
1563
- var value;
1564
- value = args.valueCallback ? args.valueCallback(key) : key;
1565
- value = options.valueCallback ? options.valueCallback(value) : value;
1566
- var rest = string.slice(matchedString.length);
1567
- return {
1568
- value: value,
1569
- rest: rest
1570
- };
1571
- };
1572
- }
1912
+ case 'ppp':
1913
+ return formatLong.time({
1914
+ width: 'long'
1915
+ });
1573
1916
 
1574
- function findKey(object, predicate) {
1575
- for (var key in object) {
1576
- if (object.hasOwnProperty(key) && predicate(object[key])) {
1577
- return key;
1578
- }
1917
+ case 'pppp':
1918
+ default:
1919
+ return formatLong.time({
1920
+ width: 'full'
1921
+ });
1579
1922
  }
1580
-
1581
- return undefined;
1582
1923
  }
1583
1924
 
1584
- function findIndex(array, predicate) {
1585
- for (var key = 0; key < array.length; key++) {
1586
- if (predicate(array[key])) {
1587
- return key;
1588
- }
1925
+ function dateTimeLongFormatter(pattern, formatLong) {
1926
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1927
+ var datePattern = matchResult[1];
1928
+ var timePattern = matchResult[2];
1929
+
1930
+ if (!timePattern) {
1931
+ return dateLongFormatter(pattern, formatLong);
1589
1932
  }
1590
1933
 
1591
- return undefined;
1592
- }
1934
+ var dateTimeFormat;
1593
1935
 
1594
- function buildMatchPatternFn(args) {
1595
- return function (string) {
1596
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1597
- var matchResult = string.match(args.matchPattern);
1598
- if (!matchResult) return null;
1599
- var matchedString = matchResult[0];
1600
- var parseResult = string.match(args.parsePattern);
1601
- if (!parseResult) return null;
1602
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1603
- value = options.valueCallback ? options.valueCallback(value) : value;
1604
- var rest = string.slice(matchedString.length);
1605
- return {
1606
- value: value,
1607
- rest: rest
1608
- };
1609
- };
1610
- }
1936
+ switch (datePattern) {
1937
+ case 'P':
1938
+ dateTimeFormat = formatLong.dateTime({
1939
+ width: 'short'
1940
+ });
1941
+ break;
1611
1942
 
1612
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1613
- var parseOrdinalNumberPattern = /\d+/i;
1614
- var matchEraPatterns = {
1615
- narrow: /^(b|a)/i,
1616
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1617
- wide: /^(before christ|before common era|anno domini|common era)/i
1618
- };
1619
- var parseEraPatterns = {
1620
- any: [/^b/i, /^(a|c)/i]
1621
- };
1622
- var matchQuarterPatterns = {
1623
- narrow: /^[1234]/i,
1624
- abbreviated: /^q[1234]/i,
1625
- wide: /^[1234](th|st|nd|rd)? quarter/i
1626
- };
1627
- var parseQuarterPatterns = {
1628
- any: [/1/i, /2/i, /3/i, /4/i]
1629
- };
1630
- var matchMonthPatterns = {
1631
- narrow: /^[jfmasond]/i,
1632
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1633
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1634
- };
1635
- var parseMonthPatterns = {
1636
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
1637
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
1638
- };
1639
- var matchDayPatterns = {
1640
- narrow: /^[smtwf]/i,
1641
- short: /^(su|mo|tu|we|th|fr|sa)/i,
1642
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1643
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1644
- };
1645
- var parseDayPatterns = {
1646
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1647
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1648
- };
1649
- var matchDayPeriodPatterns = {
1650
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1651
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1652
- };
1653
- var parseDayPeriodPatterns = {
1654
- any: {
1655
- am: /^a/i,
1656
- pm: /^p/i,
1657
- midnight: /^mi/i,
1658
- noon: /^no/i,
1659
- morning: /morning/i,
1660
- afternoon: /afternoon/i,
1661
- evening: /evening/i,
1662
- night: /night/i
1943
+ case 'PP':
1944
+ dateTimeFormat = formatLong.dateTime({
1945
+ width: 'medium'
1946
+ });
1947
+ break;
1948
+
1949
+ case 'PPP':
1950
+ dateTimeFormat = formatLong.dateTime({
1951
+ width: 'long'
1952
+ });
1953
+ break;
1954
+
1955
+ case 'PPPP':
1956
+ default:
1957
+ dateTimeFormat = formatLong.dateTime({
1958
+ width: 'full'
1959
+ });
1960
+ break;
1663
1961
  }
1664
- };
1665
- var match = {
1666
- ordinalNumber: buildMatchPatternFn({
1667
- matchPattern: matchOrdinalNumberPattern,
1668
- parsePattern: parseOrdinalNumberPattern,
1669
- valueCallback: function valueCallback(value) {
1670
- return parseInt(value, 10);
1671
- }
1672
- }),
1673
- era: buildMatchFn({
1674
- matchPatterns: matchEraPatterns,
1675
- defaultMatchWidth: 'wide',
1676
- parsePatterns: parseEraPatterns,
1677
- defaultParseWidth: 'any'
1678
- }),
1679
- quarter: buildMatchFn({
1680
- matchPatterns: matchQuarterPatterns,
1681
- defaultMatchWidth: 'wide',
1682
- parsePatterns: parseQuarterPatterns,
1683
- defaultParseWidth: 'any',
1684
- valueCallback: function valueCallback(index) {
1685
- return index + 1;
1686
- }
1687
- }),
1688
- month: buildMatchFn({
1689
- matchPatterns: matchMonthPatterns,
1690
- defaultMatchWidth: 'wide',
1691
- parsePatterns: parseMonthPatterns,
1692
- defaultParseWidth: 'any'
1693
- }),
1694
- day: buildMatchFn({
1695
- matchPatterns: matchDayPatterns,
1696
- defaultMatchWidth: 'wide',
1697
- parsePatterns: parseDayPatterns,
1698
- defaultParseWidth: 'any'
1699
- }),
1700
- dayPeriod: buildMatchFn({
1701
- matchPatterns: matchDayPeriodPatterns,
1702
- defaultMatchWidth: 'any',
1703
- parsePatterns: parseDayPeriodPatterns,
1704
- defaultParseWidth: 'any'
1705
- })
1962
+
1963
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1964
+ }
1965
+
1966
+ var longFormatters = {
1967
+ p: timeLongFormatter,
1968
+ P: dateTimeLongFormatter
1706
1969
  };
1707
1970
 
1708
- /**
1709
- * @type {Locale}
1710
- * @category Locales
1711
- * @summary English locale (United States).
1712
- * @language English
1713
- * @iso-639-2 eng
1714
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1715
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1716
- */
1717
- var locale = {
1718
- code: 'en-US',
1719
- formatDistance: formatDistance,
1720
- formatLong: formatLong,
1721
- formatRelative: formatRelative,
1722
- localize: localize,
1723
- match: match,
1724
- options: {
1725
- weekStartsOn: 0
1726
- /* Sunday */
1727
- ,
1728
- firstWeekContainsDate: 1
1971
+ var protectedDayOfYearTokens = ['D', 'DD'];
1972
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1973
+ function isProtectedDayOfYearToken(token) {
1974
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1975
+ }
1976
+ function isProtectedWeekYearToken(token) {
1977
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1978
+ }
1979
+ function throwProtectedError(token, format, input) {
1980
+ if (token === 'YYYY') {
1981
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
1982
+ } else if (token === 'YY') {
1983
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
1984
+ } else if (token === 'D') {
1985
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
1986
+ } else if (token === 'DD') {
1987
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
1729
1988
  }
1730
- };
1989
+ }
1731
1990
 
1732
1991
  // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1733
1992
  // (one of the certain letters followed by `o`)
@@ -1756,7 +2015,7 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1756
2015
  * Return the formatted date string in the given format. The result may vary by locale.
1757
2016
  *
1758
2017
  * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1759
- * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2018
+ * > See: https://git.io/fxCyr
1760
2019
  *
1761
2020
  * The characters wrapped between two single quotes characters (') are escaped.
1762
2021
  * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
@@ -1992,10 +2251,30 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1992
2251
  * - `p`: long localized time
1993
2252
  *
1994
2253
  * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
1995
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2254
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://git.io/fxCyr
1996
2255
  *
1997
2256
  * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
1998
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2257
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://git.io/fxCyr
2258
+ *
2259
+ * ### v2.0.0 breaking changes:
2260
+ *
2261
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
2262
+ *
2263
+ * - The second argument is now required for the sake of explicitness.
2264
+ *
2265
+ * ```javascript
2266
+ * // Before v2.0.0
2267
+ * format(new Date(2016, 0, 1))
2268
+ *
2269
+ * // v2.0.0 onward
2270
+ * format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
2271
+ * ```
2272
+ *
2273
+ * - New format string API for `format` function
2274
+ * which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
2275
+ * See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
2276
+ *
2277
+ * - Characters are now escaped using single quote symbols (`'`) instead of square brackets.
1999
2278
  *
2000
2279
  * @param {Date|Number} date - the original date
2001
2280
  * @param {String} format - the string of tokens
@@ -2004,9 +2283,9 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2004
2283
  * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2005
2284
  * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2006
2285
  * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2007
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2286
+ * see: https://git.io/fxCyr
2008
2287
  * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2009
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2288
+ * see: https://git.io/fxCyr
2010
2289
  * @returns {String} the formatted date string
2011
2290
  * @throws {TypeError} 2 arguments required
2012
2291
  * @throws {RangeError} `date` must not be Invalid Date
@@ -2014,45 +2293,47 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2014
2293
  * @throws {RangeError} `options.locale` must contain `formatLong` property
2015
2294
  * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2016
2295
  * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2017
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2018
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2019
- * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2020
- * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2296
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2297
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2298
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2299
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2021
2300
  * @throws {RangeError} format string contains an unescaped latin alphabet character
2022
2301
  *
2023
2302
  * @example
2024
2303
  * // Represent 11 February 2014 in middle-endian format:
2025
- * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2304
+ * var result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2026
2305
  * //=> '02/11/2014'
2027
2306
  *
2028
2307
  * @example
2029
2308
  * // Represent 2 July 2014 in Esperanto:
2030
2309
  * import { eoLocale } from 'date-fns/locale/eo'
2031
- * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2310
+ * var result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2032
2311
  * locale: eoLocale
2033
2312
  * })
2034
2313
  * //=> '2-a de julio 2014'
2035
2314
  *
2036
2315
  * @example
2037
2316
  * // Escape string by single quote characters:
2038
- * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2317
+ * var result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2039
2318
  * //=> "3 o'clock"
2040
2319
  */
2041
2320
 
2042
- function format(dirtyDate, dirtyFormatStr, options) {
2043
- var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2044
-
2321
+ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
2045
2322
  requiredArgs(2, arguments);
2046
2323
  var formatStr = String(dirtyFormatStr);
2047
- var defaultOptions = getDefaultOptions();
2048
- var locale$1 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : locale;
2049
- var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2324
+ var options = dirtyOptions || {};
2325
+ var locale$1 = options.locale || locale;
2326
+ var localeFirstWeekContainsDate = locale$1.options && locale$1.options.firstWeekContainsDate;
2327
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
2328
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2050
2329
 
2051
2330
  if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2052
2331
  throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2053
2332
  }
2054
2333
 
2055
- var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2334
+ var localeWeekStartsOn = locale$1.options && locale$1.options.weekStartsOn;
2335
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
2336
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2056
2337
 
2057
2338
  if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2058
2339
  throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
@@ -2088,7 +2369,7 @@ function format(dirtyDate, dirtyFormatStr, options) {
2088
2369
 
2089
2370
  if (firstCharacter === 'p' || firstCharacter === 'P') {
2090
2371
  var longFormatter = longFormatters[firstCharacter];
2091
- return longFormatter(substring, locale$1.formatLong);
2372
+ return longFormatter(substring, locale$1.formatLong, formatterOptions);
2092
2373
  }
2093
2374
 
2094
2375
  return substring;
@@ -2107,12 +2388,12 @@ function format(dirtyDate, dirtyFormatStr, options) {
2107
2388
  var formatter = formatters[firstCharacter];
2108
2389
 
2109
2390
  if (formatter) {
2110
- if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2111
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2391
+ if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
2392
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
2112
2393
  }
2113
2394
 
2114
- if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2115
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2395
+ if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
2396
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
2116
2397
  }
2117
2398
 
2118
2399
  return formatter(utcDate, substring, locale$1.localize, formatterOptions);
@@ -2128,13 +2409,7 @@ function format(dirtyDate, dirtyFormatStr, options) {
2128
2409
  }
2129
2410
 
2130
2411
  function cleanEscapedString(input) {
2131
- var matched = input.match(escapedStringRegExp);
2132
-
2133
- if (!matched) {
2134
- return input;
2135
- }
2136
-
2137
- return matched[1].replace(doubleQuoteRegExp, "'");
2412
+ return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
2138
2413
  }
2139
2414
 
2140
2415
  const getImageFromImage = (image) => {
@@ -2179,4 +2454,4 @@ const getColorForVerificationStatus = (status) => {
2179
2454
  };
2180
2455
 
2181
2456
  export { getImageFromProfile as a, getInfoFromCredential as b, getColorForVerificationStatus as c, format as f, getNameFromProfile as g };
2182
- //# sourceMappingURL=credential.helpers-3572f72c.js.map
2457
+ //# sourceMappingURL=credential.helpers-f57b9258.js.map