@learncard/react 2.6.8 → 2.6.10

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