@learncard/react 2.7.20 → 2.7.22

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 (245) hide show
  1. package/dist/base.css +1 -1
  2. package/dist/base.js +1 -1
  3. package/dist/cjs/{AchievementCard-2ad4cb64.js → AchievementCard-496e93b5.js} +4 -4
  4. package/dist/cjs/{AchievementCard-2ad4cb64.js.map → AchievementCard-496e93b5.js.map} +1 -1
  5. package/dist/cjs/{BoostGenericCard-e540e459.js → BoostGenericCard-1bfe4385.js} +8 -8
  6. package/dist/cjs/BoostGenericCard-1bfe4385.js.map +1 -0
  7. package/dist/cjs/{BoostSmallCard-9dc75a95.js → BoostSmallCard-bba7c0c9.js} +5 -5
  8. package/dist/cjs/BoostSmallCard-bba7c0c9.js.map +1 -0
  9. package/dist/cjs/Button-a7af702b.js.map +1 -1
  10. package/dist/cjs/{CertificateDisplayCard-11ebf814.js → CertificateDisplayCard-c5583200.js} +31 -19
  11. package/dist/{esm/CertificateDisplayCard-b69fd06f.js.map → cjs/CertificateDisplayCard-c5583200.js.map} +1 -1
  12. package/dist/cjs/Checkmark-f611aa4d.js.map +1 -1
  13. package/dist/cjs/CircleCheckButton-82d47ee2.js.map +1 -1
  14. package/dist/cjs/CircleIcon-617c38fa.js.map +1 -1
  15. package/dist/cjs/CircleSpinner-093cce04.js.map +1 -1
  16. package/dist/cjs/Coins-acd63f46.js.map +1 -1
  17. package/dist/cjs/CourseCard-338a32ee.js.map +1 -1
  18. package/dist/cjs/{CourseVerticalCard-5a73ab74.js → CourseVerticalCard-841960b1.js} +3 -3
  19. package/dist/cjs/{CourseVerticalCard-5a73ab74.js.map → CourseVerticalCard-841960b1.js.map} +1 -1
  20. package/dist/cjs/FlippyCard-209549c5.js.map +1 -1
  21. package/dist/cjs/GenericArrow-8dfb261d.js.map +1 -1
  22. package/dist/cjs/{GenericCard-46248807.js → GenericCard-5659339e.js} +7 -8
  23. package/dist/cjs/GenericCard-5659339e.js.map +1 -0
  24. package/dist/cjs/JobHistoryCard-05a3f98b.js.map +1 -1
  25. package/dist/cjs/JobListCard-458c8585.js.map +1 -1
  26. package/dist/cjs/LearnCardCreditCardBackFace-87cc8b9f.js.map +1 -1
  27. package/dist/cjs/{LearnCardCreditCardFrontFace-94be6a62.js → LearnCardCreditCardFrontFace-39eeb89a.js} +2 -2
  28. package/dist/cjs/{LearnCardCreditCardFrontFace-94be6a62.js.map → LearnCardCreditCardFrontFace-39eeb89a.js.map} +1 -1
  29. package/dist/cjs/LearnPill-21b47475.js.map +1 -1
  30. package/dist/cjs/{Lightbox-f19e13d2.js → Lightbox-880f4672.js} +22 -19
  31. package/dist/cjs/{Lightbox-f19e13d2.js.map → Lightbox-880f4672.js.map} +1 -1
  32. package/dist/cjs/Lightbulb-19c89d3c.js.map +1 -1
  33. package/dist/cjs/{MeritBadgeDisplayCard-70930ef2.js → MeritBadgeDisplayCard-306c0f77.js} +23 -17
  34. package/dist/{esm/MeritBadgeDisplayCard-575a61ed.js.map → cjs/MeritBadgeDisplayCard-306c0f77.js.map} +1 -1
  35. package/dist/cjs/{MeritBadgeSkillsCount-41a273ae.js → MeritBadgeSkillsCount-e48b2202.js} +10 -4
  36. package/dist/cjs/{MeritBadgeSkillsCount-41a273ae.js.map → MeritBadgeSkillsCount-e48b2202.js.map} +1 -1
  37. package/dist/cjs/MiniVCThumbnail-a78e44f2.js.map +1 -1
  38. package/dist/cjs/Notification-d212fa7b.js.map +1 -1
  39. package/dist/cjs/NotificationBoostCard-70dfa17e.js.map +1 -1
  40. package/dist/cjs/NotificationUserAcceptedBoostCard-423b9320.js.map +1 -1
  41. package/dist/cjs/NotificationUserCard-d4dab06c.js.map +1 -1
  42. package/dist/cjs/PuzzlePiece-937c216a.js.map +1 -1
  43. package/dist/cjs/{QRCodeCard-2a818136.js → QRCodeCard-b56c11cc.js} +2 -2
  44. package/dist/cjs/{QRCodeCard-2a818136.js.map → QRCodeCard-b56c11cc.js.map} +1 -1
  45. package/dist/cjs/QRCodeIcon-81c6e96b.js.map +1 -1
  46. package/dist/cjs/RoundedPill-bda7c067.js.map +1 -1
  47. package/dist/cjs/{SchoolIDCard-c7b4153a.js → SchoolIDCard-5a0b8568.js} +1206 -10
  48. package/dist/cjs/SchoolIDCard-5a0b8568.js.map +1 -0
  49. package/dist/cjs/{SkillTabCard-d8f3f5d4.js → SkillTabCard-66677f3c.js} +2 -2
  50. package/dist/cjs/{SkillTabCard-d8f3f5d4.js.map → SkillTabCard-66677f3c.js.map} +1 -1
  51. package/dist/cjs/SkillVerticalCard-3eb3a8e9.js.map +1 -1
  52. package/dist/cjs/SkillsCard-4b6dbb4f.js.map +1 -1
  53. package/dist/cjs/SkillsStatsCard-97a35a88.js.map +1 -1
  54. package/dist/cjs/SmallAchievementCard-a1fa862b.js.map +1 -1
  55. package/dist/cjs/Trophy-3d323be3.js.map +1 -1
  56. package/dist/cjs/User-301088ac.js.map +1 -1
  57. package/dist/cjs/{VCCard-cf3590eb.js → VCCard-4dbd6d24.js} +4 -18
  58. package/dist/{esm/VCCard-6c8c3ff1.js.map → cjs/VCCard-4dbd6d24.js.map} +1 -1
  59. package/dist/cjs/{VCDisplayBackFace-9c064eef.js → VCDisplayBackFace-0473d345.js} +3 -3
  60. package/dist/cjs/{VCDisplayBackFace-9c064eef.js.map → VCDisplayBackFace-0473d345.js.map} +1 -1
  61. package/dist/cjs/{VCDisplayCard-929fe8b9.js → VCDisplayCard-4edf82c6.js} +3 -3
  62. package/dist/cjs/{VCDisplayCard-929fe8b9.js.map → VCDisplayCard-4edf82c6.js.map} +1 -1
  63. package/dist/cjs/{VCDisplayCard2-19613b61.js → VCDisplayCard2-1720f1f1.js} +67 -48
  64. package/dist/{esm/VCDisplayCard2-06c93532.js.map → cjs/VCDisplayCard2-1720f1f1.js.map} +1 -1
  65. package/dist/cjs/VCThumbnail-6bf86bb2.js.map +1 -1
  66. package/dist/cjs/VCVerificationCheck-46fa75d3.js.map +1 -1
  67. package/dist/cjs/{VCVerificationPill-09953688.js → VCVerificationPill-b8d9a33d.js} +2 -2
  68. package/dist/cjs/{VCVerificationPill-09953688.js.map → VCVerificationPill-b8d9a33d.js.map} +1 -1
  69. package/dist/cjs/{VerifierStateBadgeAndText-fd0bd814.js → VerifierStateBadgeAndText-855df7d5.js} +14 -7
  70. package/dist/cjs/VerifierStateBadgeAndText-855df7d5.js.map +1 -0
  71. package/dist/cjs/{constants-737d10f6.js → constants-5bc954cb.js} +10 -10
  72. package/dist/cjs/{constants-737d10f6.js.map → constants-5bc954cb.js.map} +1 -1
  73. package/dist/cjs/{credential.helpers-afb94f02.js → credential.helpers-04044bbd.js} +855 -1285
  74. package/dist/cjs/credential.helpers-04044bbd.js.map +1 -0
  75. package/dist/cjs/icons-0404f605.js.map +1 -1
  76. package/dist/cjs/index-5488badc.js.map +1 -1
  77. package/dist/cjs/index-7cd11826.js.map +1 -1
  78. package/dist/cjs/index-c831a2f6.js +2448 -0
  79. package/dist/cjs/index-c831a2f6.js.map +1 -0
  80. package/dist/cjs/{index-8082a131.js → index-ec1d26f1.js} +17 -21
  81. package/dist/cjs/index-ec1d26f1.js.map +1 -0
  82. package/dist/cjs/index.js +52 -52
  83. package/dist/cjs/index10.js +6 -6
  84. package/dist/cjs/index12.js +1 -1
  85. package/dist/cjs/index13.js +52 -52
  86. package/dist/cjs/index17.js +2 -2
  87. package/dist/cjs/index19.js +1 -1
  88. package/dist/cjs/index2.js +21 -21
  89. package/dist/cjs/index21.js +8 -7
  90. package/dist/cjs/index21.js.map +1 -1
  91. package/dist/cjs/index27.js +2 -2
  92. package/dist/cjs/index29.js +1 -1
  93. package/dist/cjs/index3.js +2 -2
  94. package/dist/cjs/index30.js +1 -2
  95. package/dist/cjs/index30.js.map +1 -1
  96. package/dist/cjs/index33.js +3 -3
  97. package/dist/cjs/index37.js +13 -13
  98. package/dist/cjs/index38.js +5 -4
  99. package/dist/cjs/index38.js.map +1 -1
  100. package/dist/cjs/index39.js +6 -5
  101. package/dist/cjs/index39.js.map +1 -1
  102. package/dist/cjs/index4.js +19 -19
  103. package/dist/cjs/index40.js +9 -9
  104. package/dist/cjs/index41.js +2 -1
  105. package/dist/cjs/index41.js.map +1 -1
  106. package/dist/cjs/index44.js +2 -2
  107. package/dist/cjs/index6.js +7 -6
  108. package/dist/cjs/index6.js.map +1 -1
  109. package/dist/cjs/notifications-56c6fc94.js.map +1 -1
  110. package/dist/cjs/types-8eab1382.js.map +1 -1
  111. package/dist/cjs/types-e4d9a257.js.map +1 -1
  112. package/dist/cjs/{types.esm-c33cbec2.js → types.esm-41aaa0d4.js} +50 -40
  113. package/dist/cjs/types.esm-41aaa0d4.js.map +1 -0
  114. package/dist/esm/{AchievementCard-1d5d1b61.js → AchievementCard-017092a3.js} +4 -4
  115. package/dist/esm/{AchievementCard-1d5d1b61.js.map → AchievementCard-017092a3.js.map} +1 -1
  116. package/dist/esm/{BoostGenericCard-de8e2a84.js → BoostGenericCard-f5200b85.js} +4 -4
  117. package/dist/esm/BoostGenericCard-f5200b85.js.map +1 -0
  118. package/dist/esm/{BoostSmallCard-902844fc.js → BoostSmallCard-7180158e.js} +6 -6
  119. package/dist/esm/BoostSmallCard-7180158e.js.map +1 -0
  120. package/dist/esm/Button-5f805204.js.map +1 -1
  121. package/dist/esm/{CertificateDisplayCard-b69fd06f.js → CertificateDisplayCard-6b7a31bc.js} +31 -19
  122. package/dist/{cjs/CertificateDisplayCard-11ebf814.js.map → esm/CertificateDisplayCard-6b7a31bc.js.map} +1 -1
  123. package/dist/esm/Checkmark-d8b8f43d.js.map +1 -1
  124. package/dist/esm/CircleCheckButton-5a97f071.js.map +1 -1
  125. package/dist/esm/CircleIcon-4200733b.js.map +1 -1
  126. package/dist/esm/CircleSpinner-9b8b1a6b.js.map +1 -1
  127. package/dist/esm/Coins-ed119ec6.js.map +1 -1
  128. package/dist/esm/CourseCard-663ff174.js.map +1 -1
  129. package/dist/esm/{CourseVerticalCard-6b11b2a1.js → CourseVerticalCard-130b0d91.js} +3 -3
  130. package/dist/esm/{CourseVerticalCard-6b11b2a1.js.map → CourseVerticalCard-130b0d91.js.map} +1 -1
  131. package/dist/esm/FlippyCard-a2de5cf1.js.map +1 -1
  132. package/dist/esm/GenericArrow-0dba1707.js.map +1 -1
  133. package/dist/esm/{GenericCard-7b21d3e2.js → GenericCard-fe56887c.js} +4 -5
  134. package/dist/esm/GenericCard-fe56887c.js.map +1 -0
  135. package/dist/esm/JobHistoryCard-80d4ef27.js.map +1 -1
  136. package/dist/esm/JobListCard-1299ff04.js.map +1 -1
  137. package/dist/esm/LearnCardCreditCardBackFace-9baa9e6b.js.map +1 -1
  138. package/dist/esm/{LearnCardCreditCardFrontFace-f61b789c.js → LearnCardCreditCardFrontFace-d50efb25.js} +2 -2
  139. package/dist/esm/{LearnCardCreditCardFrontFace-f61b789c.js.map → LearnCardCreditCardFrontFace-d50efb25.js.map} +1 -1
  140. package/dist/esm/LearnPill-b8885ed1.js.map +1 -1
  141. package/dist/esm/{Lightbox-a1aab9ea.js → Lightbox-883afe8f.js} +22 -19
  142. package/dist/esm/{Lightbox-a1aab9ea.js.map → Lightbox-883afe8f.js.map} +1 -1
  143. package/dist/esm/Lightbulb-b6eca510.js.map +1 -1
  144. package/dist/esm/{MeritBadgeDisplayCard-575a61ed.js → MeritBadgeDisplayCard-0fd4c3c7.js} +23 -17
  145. package/dist/{cjs/MeritBadgeDisplayCard-70930ef2.js.map → esm/MeritBadgeDisplayCard-0fd4c3c7.js.map} +1 -1
  146. package/dist/esm/{MeritBadgeSkillsCount-8f371ab1.js → MeritBadgeSkillsCount-d0c9dd6e.js} +10 -4
  147. package/dist/esm/{MeritBadgeSkillsCount-8f371ab1.js.map → MeritBadgeSkillsCount-d0c9dd6e.js.map} +1 -1
  148. package/dist/esm/MiniVCThumbnail-6a07e810.js.map +1 -1
  149. package/dist/esm/Notification-95d159d2.js.map +1 -1
  150. package/dist/esm/NotificationBoostCard-e614c341.js.map +1 -1
  151. package/dist/esm/NotificationUserAcceptedBoostCard-8c13bd3f.js.map +1 -1
  152. package/dist/esm/NotificationUserCard-dbcc80f9.js.map +1 -1
  153. package/dist/esm/PuzzlePiece-1fb12c2e.js.map +1 -1
  154. package/dist/esm/{QRCodeCard-79d4d253.js → QRCodeCard-aa2b9967.js} +2 -2
  155. package/dist/esm/{QRCodeCard-79d4d253.js.map → QRCodeCard-aa2b9967.js.map} +1 -1
  156. package/dist/esm/QRCodeIcon-e9569804.js.map +1 -1
  157. package/dist/esm/RoundedPill-6a6e8aaf.js.map +1 -1
  158. package/dist/esm/{SchoolIDCard-01422d53.js → SchoolIDCard-5abd1bd9.js} +1205 -9
  159. package/dist/esm/SchoolIDCard-5abd1bd9.js.map +1 -0
  160. package/dist/esm/{SkillTabCard-8177895b.js → SkillTabCard-cfe117a2.js} +2 -2
  161. package/dist/esm/{SkillTabCard-8177895b.js.map → SkillTabCard-cfe117a2.js.map} +1 -1
  162. package/dist/esm/SkillVerticalCard-108f49bb.js.map +1 -1
  163. package/dist/esm/SkillsCard-92a51db2.js.map +1 -1
  164. package/dist/esm/SkillsStatsCard-1628fe9c.js.map +1 -1
  165. package/dist/esm/SmallAchievementCard-d0220751.js.map +1 -1
  166. package/dist/esm/Trophy-ad67f46a.js.map +1 -1
  167. package/dist/esm/User-161c7f37.js.map +1 -1
  168. package/dist/esm/{VCCard-6c8c3ff1.js → VCCard-aa590ccb.js} +4 -18
  169. package/dist/{cjs/VCCard-cf3590eb.js.map → esm/VCCard-aa590ccb.js.map} +1 -1
  170. package/dist/esm/{VCDisplayBackFace-c618851f.js → VCDisplayBackFace-ac7bbe0b.js} +3 -3
  171. package/dist/esm/{VCDisplayBackFace-c618851f.js.map → VCDisplayBackFace-ac7bbe0b.js.map} +1 -1
  172. package/dist/esm/{VCDisplayCard-fb298063.js → VCDisplayCard-b7dc3160.js} +3 -3
  173. package/dist/esm/{VCDisplayCard-fb298063.js.map → VCDisplayCard-b7dc3160.js.map} +1 -1
  174. package/dist/esm/{VCDisplayCard2-06c93532.js → VCDisplayCard2-b8e77e57.js} +67 -48
  175. package/dist/{cjs/VCDisplayCard2-19613b61.js.map → esm/VCDisplayCard2-b8e77e57.js.map} +1 -1
  176. package/dist/esm/VCThumbnail-3c254bda.js.map +1 -1
  177. package/dist/esm/VCVerificationCheck-80249524.js.map +1 -1
  178. package/dist/esm/{VCVerificationPill-dc9dda81.js → VCVerificationPill-43167fd5.js} +2 -2
  179. package/dist/esm/{VCVerificationPill-dc9dda81.js.map → VCVerificationPill-43167fd5.js.map} +1 -1
  180. package/dist/esm/{VerifierStateBadgeAndText-86214479.js → VerifierStateBadgeAndText-26578052.js} +14 -7
  181. package/dist/esm/VerifierStateBadgeAndText-26578052.js.map +1 -0
  182. package/dist/esm/constants-a7601fa8.js.map +1 -1
  183. package/dist/esm/{credential.helpers-cdc2f4a3.js → credential.helpers-93170224.js} +801 -1231
  184. package/dist/esm/credential.helpers-93170224.js.map +1 -0
  185. package/dist/esm/icons-03afd795.js.map +1 -1
  186. package/dist/esm/index-28917993.js.map +1 -1
  187. package/dist/esm/{index-dff96076.js → index-2ef835bd.js} +17 -21
  188. package/dist/esm/index-2ef835bd.js.map +1 -0
  189. package/dist/esm/index-5d5219f7.js.map +1 -1
  190. package/dist/esm/index-705f3821.js +2438 -0
  191. package/dist/esm/index-705f3821.js.map +1 -0
  192. package/dist/esm/index.js +42 -42
  193. package/dist/esm/index10.js +6 -6
  194. package/dist/esm/index12.js +1 -1
  195. package/dist/esm/index13.js +42 -42
  196. package/dist/esm/index17.js +2 -2
  197. package/dist/esm/index19.js +1 -1
  198. package/dist/esm/index2.js +21 -21
  199. package/dist/esm/index21.js +8 -7
  200. package/dist/esm/index21.js.map +1 -1
  201. package/dist/esm/index27.js +2 -2
  202. package/dist/esm/index3.js +2 -2
  203. package/dist/esm/index30.js +1 -2
  204. package/dist/esm/index30.js.map +1 -1
  205. package/dist/esm/index33.js +3 -3
  206. package/dist/esm/index37.js +13 -13
  207. package/dist/esm/index38.js +5 -4
  208. package/dist/esm/index38.js.map +1 -1
  209. package/dist/esm/index39.js +6 -5
  210. package/dist/esm/index39.js.map +1 -1
  211. package/dist/esm/index4.js +19 -19
  212. package/dist/esm/index40.js +9 -9
  213. package/dist/esm/index41.js +2 -1
  214. package/dist/esm/index41.js.map +1 -1
  215. package/dist/esm/index44.js +2 -2
  216. package/dist/esm/index6.js +7 -6
  217. package/dist/esm/index6.js.map +1 -1
  218. package/dist/esm/notifications-009bbd80.js.map +1 -1
  219. package/dist/esm/types-b32d28d5.js.map +1 -1
  220. package/dist/esm/types-cfde3c2b.js.map +1 -1
  221. package/dist/esm/{types.esm-4ec5392e.js → types.esm-3a1994d5.js} +50 -40
  222. package/dist/esm/types.esm-3a1994d5.js.map +1 -0
  223. package/dist/main.css +1 -1
  224. package/dist/main.js +1 -1
  225. package/package.json +3 -3
  226. package/dist/cjs/BoostGenericCard-e540e459.js.map +0 -1
  227. package/dist/cjs/BoostSmallCard-9dc75a95.js.map +0 -1
  228. package/dist/cjs/GenericCard-46248807.js.map +0 -1
  229. package/dist/cjs/SchoolIDCard-c7b4153a.js.map +0 -1
  230. package/dist/cjs/VerifierStateBadgeAndText-fd0bd814.js.map +0 -1
  231. package/dist/cjs/credential.helpers-afb94f02.js.map +0 -1
  232. package/dist/cjs/index-8082a131.js.map +0 -1
  233. package/dist/cjs/index-838fa72c.js +0 -1186
  234. package/dist/cjs/index-838fa72c.js.map +0 -1
  235. package/dist/cjs/types.esm-c33cbec2.js.map +0 -1
  236. package/dist/esm/BoostGenericCard-de8e2a84.js.map +0 -1
  237. package/dist/esm/BoostSmallCard-902844fc.js.map +0 -1
  238. package/dist/esm/GenericCard-7b21d3e2.js.map +0 -1
  239. package/dist/esm/SchoolIDCard-01422d53.js.map +0 -1
  240. package/dist/esm/VerifierStateBadgeAndText-86214479.js.map +0 -1
  241. package/dist/esm/credential.helpers-cdc2f4a3.js.map +0 -1
  242. package/dist/esm/index-4fa491c1.js +0 -1184
  243. package/dist/esm/index-4fa491c1.js.map +0 -1
  244. package/dist/esm/index-dff96076.js.map +0 -1
  245. package/dist/esm/types.esm-4ec5392e.js.map +0 -1
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var types_esm = require('./types.esm-c33cbec2.js');
5
- var index = require('./index-5488badc.js');
4
+ var index = require('./index-c831a2f6.js');
5
+ var types_esm = require('./types.esm-41aaa0d4.js');
6
+ var index$1 = require('./index-5488badc.js');
6
7
  var PuzzlePiece = require('./PuzzlePiece-937c216a.js');
7
8
  var User = require('./User-301088ac.js');
8
9
  var Trophy = require('./Trophy-3d323be3.js');
@@ -142,78 +143,6 @@ const SocialBadgesIcon = ({
142
143
  }));
143
144
  };
144
145
 
145
- function toInteger(dirtyNumber) {
146
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
147
- return NaN;
148
- }
149
-
150
- var number = Number(dirtyNumber);
151
-
152
- if (isNaN(number)) {
153
- return number;
154
- }
155
-
156
- return number < 0 ? Math.ceil(number) : Math.floor(number);
157
- }
158
-
159
- function requiredArgs(required, args) {
160
- if (args.length < required) {
161
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
162
- }
163
- }
164
-
165
- /**
166
- * @name toDate
167
- * @category Common Helpers
168
- * @summary Convert the given argument to an instance of Date.
169
- *
170
- * @description
171
- * Convert the given argument to an instance of Date.
172
- *
173
- * If the argument is an instance of Date, the function returns its clone.
174
- *
175
- * If the argument is a number, it is treated as a timestamp.
176
- *
177
- * If the argument is none of the above, the function returns Invalid Date.
178
- *
179
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
180
- *
181
- * @param {Date|Number} argument - the value to convert
182
- * @returns {Date} the parsed date in the local time zone
183
- * @throws {TypeError} 1 argument required
184
- *
185
- * @example
186
- * // Clone the date:
187
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
188
- * //=> Tue Feb 11 2014 11:30:30
189
- *
190
- * @example
191
- * // Convert the timestamp to date:
192
- * const result = toDate(1392098430000)
193
- * //=> Tue Feb 11 2014 11:30:30
194
- */
195
-
196
- function toDate(argument) {
197
- requiredArgs(1, arguments);
198
- var argStr = Object.prototype.toString.call(argument); // Clone the date
199
-
200
- if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
201
- // Prevent the date to lose the milliseconds when passed to new Date() in IE10
202
- return new Date(argument.getTime());
203
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
204
- return new Date(argument);
205
- } else {
206
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
207
- // eslint-disable-next-line no-console
208
- 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
209
-
210
- console.warn(new Error().stack);
211
- }
212
-
213
- return new Date(NaN);
214
- }
215
- }
216
-
217
146
  /**
218
147
  * @name addMilliseconds
219
148
  * @category Millisecond Helpers
@@ -222,10 +151,6 @@ function toDate(argument) {
222
151
  * @description
223
152
  * Add the specified number of milliseconds to the given date.
224
153
  *
225
- * ### v2.0.0 breaking changes:
226
- *
227
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
228
- *
229
154
  * @param {Date|Number} date - the date to be changed
230
155
  * @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`.
231
156
  * @returns {Date} the new date with the milliseconds added
@@ -236,11 +161,10 @@ function toDate(argument) {
236
161
  * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
237
162
  * //=> Thu Jul 10 2014 12:45:30.750
238
163
  */
239
-
240
164
  function addMilliseconds(dirtyDate, dirtyAmount) {
241
- requiredArgs(2, arguments);
242
- var timestamp = toDate(dirtyDate).getTime();
243
- var amount = toInteger(dirtyAmount);
165
+ index.requiredArgs(2, arguments);
166
+ var timestamp = index.toDate(dirtyDate).getTime();
167
+ var amount = index.toInteger(dirtyAmount);
244
168
  return new Date(timestamp + amount);
245
169
  }
246
170
 
@@ -269,10 +193,6 @@ function getTimezoneOffsetInMilliseconds(date) {
269
193
  * @description
270
194
  * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
271
195
  *
272
- * ### v2.0.0 breaking changes:
273
- *
274
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
275
- *
276
196
  * @param {*} value - the value to check
277
197
  * @returns {boolean} true if the given value is a date
278
198
  * @throws {TypeError} 1 arguments required
@@ -297,10 +217,9 @@ function getTimezoneOffsetInMilliseconds(date) {
297
217
  * const result = isDate({})
298
218
  * //=> false
299
219
  */
300
-
301
220
  function isDate(value) {
302
- requiredArgs(1, arguments);
303
- return value instanceof Date || typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]';
221
+ index.requiredArgs(1, arguments);
222
+ return value instanceof Date || index._typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
304
223
  }
305
224
 
306
225
  /**
@@ -315,32 +234,6 @@ function isDate(value) {
315
234
  *
316
235
  * Time value of Date: http://es5.github.io/#x15.9.1.1
317
236
  *
318
- * ### v2.0.0 breaking changes:
319
- *
320
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
321
- *
322
- * - Now `isValid` doesn't throw an exception
323
- * if the first argument is not an instance of Date.
324
- * Instead, argument is converted beforehand using `toDate`.
325
- *
326
- * Examples:
327
- *
328
- * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
329
- * |---------------------------|---------------|---------------|
330
- * | `new Date()` | `true` | `true` |
331
- * | `new Date('2016-01-01')` | `true` | `true` |
332
- * | `new Date('')` | `false` | `false` |
333
- * | `new Date(1488370835081)` | `true` | `true` |
334
- * | `new Date(NaN)` | `false` | `false` |
335
- * | `'2016-01-01'` | `TypeError` | `false` |
336
- * | `''` | `TypeError` | `false` |
337
- * | `1488370835081` | `TypeError` | `true` |
338
- * | `NaN` | `TypeError` | `false` |
339
- *
340
- * We introduce this change to make *date-fns* consistent with ECMAScript behavior
341
- * that try to coerce arguments to the expected type
342
- * (which is also the case with other *date-fns* functions).
343
- *
344
237
  * @param {*} date - the date to check
345
238
  * @returns {Boolean} the date is valid
346
239
  * @throws {TypeError} 1 argument required
@@ -360,811 +253,148 @@ function isDate(value) {
360
253
  * const result = isValid(new Date(''))
361
254
  * //=> false
362
255
  */
363
-
364
256
  function isValid(dirtyDate) {
365
- requiredArgs(1, arguments);
366
-
257
+ index.requiredArgs(1, arguments);
367
258
  if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
368
259
  return false;
369
260
  }
370
-
371
- var date = toDate(dirtyDate);
261
+ var date = index.toDate(dirtyDate);
372
262
  return !isNaN(Number(date));
373
263
  }
374
264
 
375
- var formatDistanceLocale = {
376
- lessThanXSeconds: {
377
- one: 'less than a second',
378
- other: 'less than {{count}} seconds'
379
- },
380
- xSeconds: {
381
- one: '1 second',
382
- other: '{{count}} seconds'
383
- },
384
- halfAMinute: 'half a minute',
385
- lessThanXMinutes: {
386
- one: 'less than a minute',
387
- other: 'less than {{count}} minutes'
388
- },
389
- xMinutes: {
390
- one: '1 minute',
391
- other: '{{count}} minutes'
392
- },
393
- aboutXHours: {
394
- one: 'about 1 hour',
395
- other: 'about {{count}} hours'
396
- },
397
- xHours: {
398
- one: '1 hour',
399
- other: '{{count}} hours'
400
- },
401
- xDays: {
402
- one: '1 day',
403
- other: '{{count}} days'
265
+ /**
266
+ * @name subMilliseconds
267
+ * @category Millisecond Helpers
268
+ * @summary Subtract the specified number of milliseconds from the given date.
269
+ *
270
+ * @description
271
+ * Subtract the specified number of milliseconds from the given date.
272
+ *
273
+ * @param {Date|Number} date - the date to be changed
274
+ * @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`.
275
+ * @returns {Date} the new date with the milliseconds subtracted
276
+ * @throws {TypeError} 2 arguments required
277
+ *
278
+ * @example
279
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
280
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
281
+ * //=> Thu Jul 10 2014 12:45:29.250
282
+ */
283
+ function subMilliseconds(dirtyDate, dirtyAmount) {
284
+ index.requiredArgs(2, arguments);
285
+ var amount = index.toInteger(dirtyAmount);
286
+ return addMilliseconds(dirtyDate, -amount);
287
+ }
288
+
289
+ var MILLISECONDS_IN_DAY = 86400000;
290
+ function getUTCDayOfYear(dirtyDate) {
291
+ index.requiredArgs(1, arguments);
292
+ var date = index.toDate(dirtyDate);
293
+ var timestamp = date.getTime();
294
+ date.setUTCMonth(0, 1);
295
+ date.setUTCHours(0, 0, 0, 0);
296
+ var startOfYearTimestamp = date.getTime();
297
+ var difference = timestamp - startOfYearTimestamp;
298
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
299
+ }
300
+
301
+ function addLeadingZeros(number, targetLength) {
302
+ var sign = number < 0 ? '-' : '';
303
+ var output = Math.abs(number).toString();
304
+ while (output.length < targetLength) {
305
+ output = '0' + output;
306
+ }
307
+ return sign + output;
308
+ }
309
+
310
+ /*
311
+ * | | Unit | | Unit |
312
+ * |-----|--------------------------------|-----|--------------------------------|
313
+ * | a | AM, PM | A* | |
314
+ * | d | Day of month | D | |
315
+ * | h | Hour [1-12] | H | Hour [0-23] |
316
+ * | m | Minute | M | Month |
317
+ * | s | Second | S | Fraction of second |
318
+ * | y | Year (abs) | Y | |
319
+ *
320
+ * Letters marked by * are not implemented but reserved by Unicode standard.
321
+ */
322
+ var formatters$1 = {
323
+ // Year
324
+ y: function y(date, token) {
325
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
326
+ // | Year | y | yy | yyy | yyyy | yyyyy |
327
+ // |----------|-------|----|-------|-------|-------|
328
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
329
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
330
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
331
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
332
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
333
+
334
+ var signedYear = date.getUTCFullYear();
335
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
336
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
337
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
404
338
  },
405
- aboutXWeeks: {
406
- one: 'about 1 week',
407
- other: 'about {{count}} weeks'
339
+ // Month
340
+ M: function M(date, token) {
341
+ var month = date.getUTCMonth();
342
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
408
343
  },
409
- xWeeks: {
410
- one: '1 week',
411
- other: '{{count}} weeks'
344
+ // Day of the month
345
+ d: function d(date, token) {
346
+ return addLeadingZeros(date.getUTCDate(), token.length);
412
347
  },
413
- aboutXMonths: {
414
- one: 'about 1 month',
415
- other: 'about {{count}} months'
348
+ // AM or PM
349
+ a: function a(date, token) {
350
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
351
+ switch (token) {
352
+ case 'a':
353
+ case 'aa':
354
+ return dayPeriodEnumValue.toUpperCase();
355
+ case 'aaa':
356
+ return dayPeriodEnumValue;
357
+ case 'aaaaa':
358
+ return dayPeriodEnumValue[0];
359
+ case 'aaaa':
360
+ default:
361
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
362
+ }
416
363
  },
417
- xMonths: {
418
- one: '1 month',
419
- other: '{{count}} months'
364
+ // Hour [1-12]
365
+ h: function h(date, token) {
366
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
420
367
  },
421
- aboutXYears: {
422
- one: 'about 1 year',
423
- other: 'about {{count}} years'
368
+ // Hour [0-23]
369
+ H: function H(date, token) {
370
+ return addLeadingZeros(date.getUTCHours(), token.length);
424
371
  },
425
- xYears: {
426
- one: '1 year',
427
- other: '{{count}} years'
372
+ // Minute
373
+ m: function m(date, token) {
374
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
428
375
  },
429
- overXYears: {
430
- one: 'over 1 year',
431
- other: 'over {{count}} years'
376
+ // Second
377
+ s: function s(date, token) {
378
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
432
379
  },
433
- almostXYears: {
434
- one: 'almost 1 year',
435
- other: 'almost {{count}} years'
436
- }
437
- };
438
-
439
- var formatDistance = function (token, count, options) {
440
- var result;
441
- var tokenValue = formatDistanceLocale[token];
442
-
443
- if (typeof tokenValue === 'string') {
444
- result = tokenValue;
445
- } else if (count === 1) {
446
- result = tokenValue.one;
447
- } else {
448
- result = tokenValue.other.replace('{{count}}', count.toString());
449
- }
450
-
451
- if (options !== null && options !== void 0 && options.addSuffix) {
452
- if (options.comparison && options.comparison > 0) {
453
- return 'in ' + result;
454
- } else {
455
- return result + ' ago';
456
- }
380
+ // Fraction of second
381
+ S: function S(date, token) {
382
+ var numberOfDigits = token.length;
383
+ var milliseconds = date.getUTCMilliseconds();
384
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
385
+ return addLeadingZeros(fractionalSeconds, token.length);
457
386
  }
458
-
459
- return result;
460
387
  };
461
388
 
462
- function buildFormatLongFn(args) {
463
- return function () {
464
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
465
- // TODO: Remove String()
466
- var width = options.width ? String(options.width) : args.defaultWidth;
467
- var format = args.formats[width] || args.formats[args.defaultWidth];
468
- return format;
469
- };
470
- }
471
-
472
- var dateFormats = {
473
- full: 'EEEE, MMMM do, y',
474
- long: 'MMMM do, y',
475
- medium: 'MMM d, y',
476
- short: 'MM/dd/yyyy'
477
- };
478
- var timeFormats = {
479
- full: 'h:mm:ss a zzzz',
480
- long: 'h:mm:ss a z',
481
- medium: 'h:mm:ss a',
482
- short: 'h:mm a'
483
- };
484
- var dateTimeFormats = {
485
- full: "{{date}} 'at' {{time}}",
486
- long: "{{date}} 'at' {{time}}",
487
- medium: '{{date}}, {{time}}',
488
- short: '{{date}}, {{time}}'
489
- };
490
- var formatLong = {
491
- date: buildFormatLongFn({
492
- formats: dateFormats,
493
- defaultWidth: 'full'
494
- }),
495
- time: buildFormatLongFn({
496
- formats: timeFormats,
497
- defaultWidth: 'full'
498
- }),
499
- dateTime: buildFormatLongFn({
500
- formats: dateTimeFormats,
501
- defaultWidth: 'full'
502
- })
503
- };
504
-
505
- var formatRelativeLocale = {
506
- lastWeek: "'last' eeee 'at' p",
507
- yesterday: "'yesterday at' p",
508
- today: "'today at' p",
509
- tomorrow: "'tomorrow at' p",
510
- nextWeek: "eeee 'at' p",
511
- other: 'P'
512
- };
513
-
514
- var formatRelative = function (token, _date, _baseDate, _options) {
515
- return formatRelativeLocale[token];
516
- };
517
-
518
- function buildLocalizeFn(args) {
519
- return function (dirtyIndex, dirtyOptions) {
520
- var options = dirtyOptions || {};
521
- var context = options.context ? String(options.context) : 'standalone';
522
- var valuesArray;
523
-
524
- if (context === 'formatting' && args.formattingValues) {
525
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
526
- var width = options.width ? String(options.width) : defaultWidth;
527
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
528
- } else {
529
- var _defaultWidth = args.defaultWidth;
530
-
531
- var _width = options.width ? String(options.width) : args.defaultWidth;
532
-
533
- valuesArray = args.values[_width] || args.values[_defaultWidth];
534
- }
535
-
536
- 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!
537
-
538
- return valuesArray[index];
539
- };
540
- }
541
-
542
- var eraValues = {
543
- narrow: ['B', 'A'],
544
- abbreviated: ['BC', 'AD'],
545
- wide: ['Before Christ', 'Anno Domini']
546
- };
547
- var quarterValues = {
548
- narrow: ['1', '2', '3', '4'],
549
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
550
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
551
- }; // Note: in English, the names of days of the week and months are capitalized.
552
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
553
- // Generally, formatted dates should look like they are in the middle of a sentence,
554
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
555
-
556
- var monthValues = {
557
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
558
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
559
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
560
- };
561
- var dayValues = {
562
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
563
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
564
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
565
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
566
- };
567
- var dayPeriodValues = {
568
- narrow: {
569
- am: 'a',
570
- pm: 'p',
571
- midnight: 'mi',
572
- noon: 'n',
573
- morning: 'morning',
574
- afternoon: 'afternoon',
575
- evening: 'evening',
576
- night: 'night'
577
- },
578
- abbreviated: {
579
- am: 'AM',
580
- pm: 'PM',
581
- midnight: 'midnight',
582
- noon: 'noon',
583
- morning: 'morning',
584
- afternoon: 'afternoon',
585
- evening: 'evening',
586
- night: 'night'
587
- },
588
- wide: {
589
- am: 'a.m.',
590
- pm: 'p.m.',
591
- midnight: 'midnight',
592
- noon: 'noon',
593
- morning: 'morning',
594
- afternoon: 'afternoon',
595
- evening: 'evening',
596
- night: 'night'
597
- }
598
- };
599
- var formattingDayPeriodValues = {
600
- narrow: {
601
- am: 'a',
602
- pm: 'p',
603
- midnight: 'mi',
604
- noon: 'n',
605
- morning: 'in the morning',
606
- afternoon: 'in the afternoon',
607
- evening: 'in the evening',
608
- night: 'at night'
609
- },
610
- abbreviated: {
611
- am: 'AM',
612
- pm: 'PM',
613
- midnight: 'midnight',
614
- noon: 'noon',
615
- morning: 'in the morning',
616
- afternoon: 'in the afternoon',
617
- evening: 'in the evening',
618
- night: 'at night'
619
- },
620
- wide: {
621
- am: 'a.m.',
622
- pm: 'p.m.',
623
- midnight: 'midnight',
624
- noon: 'noon',
625
- morning: 'in the morning',
626
- afternoon: 'in the afternoon',
627
- evening: 'in the evening',
628
- night: 'at night'
629
- }
630
- };
631
-
632
- var ordinalNumber = function (dirtyNumber, _options) {
633
- var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
634
- // if they are different for different grammatical genders,
635
- // use `options.unit`.
636
- //
637
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
638
- // 'day', 'hour', 'minute', 'second'.
639
-
640
- var rem100 = number % 100;
641
-
642
- if (rem100 > 20 || rem100 < 10) {
643
- switch (rem100 % 10) {
644
- case 1:
645
- return number + 'st';
646
-
647
- case 2:
648
- return number + 'nd';
649
-
650
- case 3:
651
- return number + 'rd';
652
- }
653
- }
654
-
655
- return number + 'th';
656
- };
657
-
658
- var localize = {
659
- ordinalNumber: ordinalNumber,
660
- era: buildLocalizeFn({
661
- values: eraValues,
662
- defaultWidth: 'wide'
663
- }),
664
- quarter: buildLocalizeFn({
665
- values: quarterValues,
666
- defaultWidth: 'wide',
667
- argumentCallback: function (quarter) {
668
- return quarter - 1;
669
- }
670
- }),
671
- month: buildLocalizeFn({
672
- values: monthValues,
673
- defaultWidth: 'wide'
674
- }),
675
- day: buildLocalizeFn({
676
- values: dayValues,
677
- defaultWidth: 'wide'
678
- }),
679
- dayPeriod: buildLocalizeFn({
680
- values: dayPeriodValues,
681
- defaultWidth: 'wide',
682
- formattingValues: formattingDayPeriodValues,
683
- defaultFormattingWidth: 'wide'
684
- })
685
- };
686
-
687
- function buildMatchFn(args) {
688
- return function (string) {
689
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
690
- var width = options.width;
691
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
692
- var matchResult = string.match(matchPattern);
693
-
694
- if (!matchResult) {
695
- return null;
696
- }
697
-
698
- var matchedString = matchResult[0];
699
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
700
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
701
- return pattern.test(matchedString);
702
- }) : findKey(parsePatterns, function (pattern) {
703
- return pattern.test(matchedString);
704
- });
705
- var value;
706
- value = args.valueCallback ? args.valueCallback(key) : key;
707
- value = options.valueCallback ? options.valueCallback(value) : value;
708
- var rest = string.slice(matchedString.length);
709
- return {
710
- value: value,
711
- rest: rest
712
- };
713
- };
714
- }
715
-
716
- function findKey(object, predicate) {
717
- for (var key in object) {
718
- if (object.hasOwnProperty(key) && predicate(object[key])) {
719
- return key;
720
- }
721
- }
722
-
723
- return undefined;
724
- }
725
-
726
- function findIndex(array, predicate) {
727
- for (var key = 0; key < array.length; key++) {
728
- if (predicate(array[key])) {
729
- return key;
730
- }
731
- }
732
-
733
- return undefined;
734
- }
735
-
736
- function buildMatchPatternFn(args) {
737
- return function (string) {
738
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
739
- var matchResult = string.match(args.matchPattern);
740
- if (!matchResult) return null;
741
- var matchedString = matchResult[0];
742
- var parseResult = string.match(args.parsePattern);
743
- if (!parseResult) return null;
744
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
745
- value = options.valueCallback ? options.valueCallback(value) : value;
746
- var rest = string.slice(matchedString.length);
747
- return {
748
- value: value,
749
- rest: rest
750
- };
751
- };
752
- }
753
-
754
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
755
- var parseOrdinalNumberPattern = /\d+/i;
756
- var matchEraPatterns = {
757
- narrow: /^(b|a)/i,
758
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
759
- wide: /^(before christ|before common era|anno domini|common era)/i
760
- };
761
- var parseEraPatterns = {
762
- any: [/^b/i, /^(a|c)/i]
763
- };
764
- var matchQuarterPatterns = {
765
- narrow: /^[1234]/i,
766
- abbreviated: /^q[1234]/i,
767
- wide: /^[1234](th|st|nd|rd)? quarter/i
768
- };
769
- var parseQuarterPatterns = {
770
- any: [/1/i, /2/i, /3/i, /4/i]
771
- };
772
- var matchMonthPatterns = {
773
- narrow: /^[jfmasond]/i,
774
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
775
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
776
- };
777
- var parseMonthPatterns = {
778
- 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],
779
- 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]
780
- };
781
- var matchDayPatterns = {
782
- narrow: /^[smtwf]/i,
783
- short: /^(su|mo|tu|we|th|fr|sa)/i,
784
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
785
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
786
- };
787
- var parseDayPatterns = {
788
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
789
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
790
- };
791
- var matchDayPeriodPatterns = {
792
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
793
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
794
- };
795
- var parseDayPeriodPatterns = {
796
- any: {
797
- am: /^a/i,
798
- pm: /^p/i,
799
- midnight: /^mi/i,
800
- noon: /^no/i,
801
- morning: /morning/i,
802
- afternoon: /afternoon/i,
803
- evening: /evening/i,
804
- night: /night/i
805
- }
806
- };
807
- var match = {
808
- ordinalNumber: buildMatchPatternFn({
809
- matchPattern: matchOrdinalNumberPattern,
810
- parsePattern: parseOrdinalNumberPattern,
811
- valueCallback: function (value) {
812
- return parseInt(value, 10);
813
- }
814
- }),
815
- era: buildMatchFn({
816
- matchPatterns: matchEraPatterns,
817
- defaultMatchWidth: 'wide',
818
- parsePatterns: parseEraPatterns,
819
- defaultParseWidth: 'any'
820
- }),
821
- quarter: buildMatchFn({
822
- matchPatterns: matchQuarterPatterns,
823
- defaultMatchWidth: 'wide',
824
- parsePatterns: parseQuarterPatterns,
825
- defaultParseWidth: 'any',
826
- valueCallback: function (index) {
827
- return index + 1;
828
- }
829
- }),
830
- month: buildMatchFn({
831
- matchPatterns: matchMonthPatterns,
832
- defaultMatchWidth: 'wide',
833
- parsePatterns: parseMonthPatterns,
834
- defaultParseWidth: 'any'
835
- }),
836
- day: buildMatchFn({
837
- matchPatterns: matchDayPatterns,
838
- defaultMatchWidth: 'wide',
839
- parsePatterns: parseDayPatterns,
840
- defaultParseWidth: 'any'
841
- }),
842
- dayPeriod: buildMatchFn({
843
- matchPatterns: matchDayPeriodPatterns,
844
- defaultMatchWidth: 'any',
845
- parsePatterns: parseDayPeriodPatterns,
846
- defaultParseWidth: 'any'
847
- })
848
- };
849
-
850
- /**
851
- * @type {Locale}
852
- * @category Locales
853
- * @summary English locale (United States).
854
- * @language English
855
- * @iso-639-2 eng
856
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
857
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
858
- */
859
- var locale = {
860
- code: 'en-US',
861
- formatDistance: formatDistance,
862
- formatLong: formatLong,
863
- formatRelative: formatRelative,
864
- localize: localize,
865
- match: match,
866
- options: {
867
- weekStartsOn: 0
868
- /* Sunday */
869
- ,
870
- firstWeekContainsDate: 1
871
- }
872
- };
873
-
874
- /**
875
- * @name subMilliseconds
876
- * @category Millisecond Helpers
877
- * @summary Subtract the specified number of milliseconds from the given date.
878
- *
879
- * @description
880
- * Subtract the specified number of milliseconds from the given date.
881
- *
882
- * ### v2.0.0 breaking changes:
883
- *
884
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
885
- *
886
- * @param {Date|Number} date - the date to be changed
887
- * @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`.
888
- * @returns {Date} the new date with the milliseconds subtracted
889
- * @throws {TypeError} 2 arguments required
890
- *
891
- * @example
892
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
893
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
894
- * //=> Thu Jul 10 2014 12:45:29.250
895
- */
896
-
897
- function subMilliseconds(dirtyDate, dirtyAmount) {
898
- requiredArgs(2, arguments);
899
- var amount = toInteger(dirtyAmount);
900
- return addMilliseconds(dirtyDate, -amount);
901
- }
902
-
903
- var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
904
- // See issue: https://github.com/date-fns/date-fns/issues/376
905
-
906
- function getUTCDayOfYear(dirtyDate) {
907
- requiredArgs(1, arguments);
908
- var date = toDate(dirtyDate);
909
- var timestamp = date.getTime();
910
- date.setUTCMonth(0, 1);
911
- date.setUTCHours(0, 0, 0, 0);
912
- var startOfYearTimestamp = date.getTime();
913
- var difference = timestamp - startOfYearTimestamp;
914
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
915
- }
916
-
917
- // See issue: https://github.com/date-fns/date-fns/issues/376
918
-
919
- function startOfUTCISOWeek(dirtyDate) {
920
- requiredArgs(1, arguments);
921
- var weekStartsOn = 1;
922
- var date = toDate(dirtyDate);
923
- var day = date.getUTCDay();
924
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
925
- date.setUTCDate(date.getUTCDate() - diff);
926
- date.setUTCHours(0, 0, 0, 0);
927
- return date;
928
- }
929
-
930
- // See issue: https://github.com/date-fns/date-fns/issues/376
931
-
932
- function getUTCISOWeekYear(dirtyDate) {
933
- requiredArgs(1, arguments);
934
- var date = toDate(dirtyDate);
935
- var year = date.getUTCFullYear();
936
- var fourthOfJanuaryOfNextYear = new Date(0);
937
- fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
938
- fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
939
- var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
940
- var fourthOfJanuaryOfThisYear = new Date(0);
941
- fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
942
- fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
943
- var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
944
-
945
- if (date.getTime() >= startOfNextYear.getTime()) {
946
- return year + 1;
947
- } else if (date.getTime() >= startOfThisYear.getTime()) {
948
- return year;
949
- } else {
950
- return year - 1;
951
- }
952
- }
953
-
954
- // See issue: https://github.com/date-fns/date-fns/issues/376
955
-
956
- function startOfUTCISOWeekYear(dirtyDate) {
957
- requiredArgs(1, arguments);
958
- var year = getUTCISOWeekYear(dirtyDate);
959
- var fourthOfJanuary = new Date(0);
960
- fourthOfJanuary.setUTCFullYear(year, 0, 4);
961
- fourthOfJanuary.setUTCHours(0, 0, 0, 0);
962
- var date = startOfUTCISOWeek(fourthOfJanuary);
963
- return date;
964
- }
965
-
966
- var MILLISECONDS_IN_WEEK$1 = 604800000; // This function will be a part of public API when UTC function will be implemented.
967
- // See issue: https://github.com/date-fns/date-fns/issues/376
968
-
969
- function getUTCISOWeek(dirtyDate) {
970
- requiredArgs(1, arguments);
971
- var date = toDate(dirtyDate);
972
- var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
973
- // because the number of milliseconds in a week is not constant
974
- // (e.g. it's different in the week of the daylight saving time clock shift)
975
-
976
- return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
977
- }
978
-
979
- // See issue: https://github.com/date-fns/date-fns/issues/376
980
-
981
- function startOfUTCWeek(dirtyDate, dirtyOptions) {
982
- requiredArgs(1, arguments);
983
- var options = dirtyOptions || {};
984
- var locale = options.locale;
985
- var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
986
- var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
987
- var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
988
-
989
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
990
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
991
- }
992
-
993
- var date = toDate(dirtyDate);
994
- var day = date.getUTCDay();
995
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
996
- date.setUTCDate(date.getUTCDate() - diff);
997
- date.setUTCHours(0, 0, 0, 0);
998
- return date;
999
- }
1000
-
1001
- // See issue: https://github.com/date-fns/date-fns/issues/376
1002
-
1003
- function getUTCWeekYear(dirtyDate, dirtyOptions) {
1004
- requiredArgs(1, arguments);
1005
- var date = toDate(dirtyDate);
1006
- var year = date.getUTCFullYear();
1007
- var options = dirtyOptions || {};
1008
- var locale = options.locale;
1009
- var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
1010
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
1011
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
1012
-
1013
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
1014
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
1015
- }
1016
-
1017
- var firstWeekOfNextYear = new Date(0);
1018
- firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
1019
- firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
1020
- var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, dirtyOptions);
1021
- var firstWeekOfThisYear = new Date(0);
1022
- firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
1023
- firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
1024
- var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, dirtyOptions);
1025
-
1026
- if (date.getTime() >= startOfNextYear.getTime()) {
1027
- return year + 1;
1028
- } else if (date.getTime() >= startOfThisYear.getTime()) {
1029
- return year;
1030
- } else {
1031
- return year - 1;
1032
- }
1033
- }
1034
-
1035
- // See issue: https://github.com/date-fns/date-fns/issues/376
1036
-
1037
- function startOfUTCWeekYear(dirtyDate, dirtyOptions) {
1038
- requiredArgs(1, arguments);
1039
- var options = dirtyOptions || {};
1040
- var locale = options.locale;
1041
- var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
1042
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
1043
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
1044
- var year = getUTCWeekYear(dirtyDate, dirtyOptions);
1045
- var firstWeek = new Date(0);
1046
- firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
1047
- firstWeek.setUTCHours(0, 0, 0, 0);
1048
- var date = startOfUTCWeek(firstWeek, dirtyOptions);
1049
- return date;
1050
- }
1051
-
1052
- var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented.
1053
- // See issue: https://github.com/date-fns/date-fns/issues/376
1054
-
1055
- function getUTCWeek(dirtyDate, options) {
1056
- requiredArgs(1, arguments);
1057
- var date = toDate(dirtyDate);
1058
- var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer
1059
- // because the number of milliseconds in a week is not constant
1060
- // (e.g. it's different in the week of the daylight saving time clock shift)
1061
-
1062
- return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
1063
- }
1064
-
1065
- function addLeadingZeros(number, targetLength) {
1066
- var sign = number < 0 ? '-' : '';
1067
- var output = Math.abs(number).toString();
1068
-
1069
- while (output.length < targetLength) {
1070
- output = '0' + output;
1071
- }
1072
-
1073
- return sign + output;
1074
- }
1075
-
1076
- /*
1077
- * | | Unit | | Unit |
1078
- * |-----|--------------------------------|-----|--------------------------------|
1079
- * | a | AM, PM | A* | |
1080
- * | d | Day of month | D | |
1081
- * | h | Hour [1-12] | H | Hour [0-23] |
1082
- * | m | Minute | M | Month |
1083
- * | s | Second | S | Fraction of second |
1084
- * | y | Year (abs) | Y | |
1085
- *
1086
- * Letters marked by * are not implemented but reserved by Unicode standard.
1087
- */
1088
-
1089
- var formatters$1 = {
1090
- // Year
1091
- y: function (date, token) {
1092
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
1093
- // | Year | y | yy | yyy | yyyy | yyyyy |
1094
- // |----------|-------|----|-------|-------|-------|
1095
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
1096
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
1097
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
1098
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
1099
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
1100
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
1101
-
1102
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
1103
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
1104
- },
1105
- // Month
1106
- M: function (date, token) {
1107
- var month = date.getUTCMonth();
1108
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
1109
- },
1110
- // Day of the month
1111
- d: function (date, token) {
1112
- return addLeadingZeros(date.getUTCDate(), token.length);
1113
- },
1114
- // AM or PM
1115
- a: function (date, token) {
1116
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
1117
-
1118
- switch (token) {
1119
- case 'a':
1120
- case 'aa':
1121
- return dayPeriodEnumValue.toUpperCase();
1122
-
1123
- case 'aaa':
1124
- return dayPeriodEnumValue;
1125
-
1126
- case 'aaaaa':
1127
- return dayPeriodEnumValue[0];
1128
-
1129
- case 'aaaa':
1130
- default:
1131
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
1132
- }
1133
- },
1134
- // Hour [1-12]
1135
- h: function (date, token) {
1136
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
1137
- },
1138
- // Hour [0-23]
1139
- H: function (date, token) {
1140
- return addLeadingZeros(date.getUTCHours(), token.length);
1141
- },
1142
- // Minute
1143
- m: function (date, token) {
1144
- return addLeadingZeros(date.getUTCMinutes(), token.length);
1145
- },
1146
- // Second
1147
- s: function (date, token) {
1148
- return addLeadingZeros(date.getUTCSeconds(), token.length);
1149
- },
1150
- // Fraction of second
1151
- S: function (date, token) {
1152
- var numberOfDigits = token.length;
1153
- var milliseconds = date.getUTCMilliseconds();
1154
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
1155
- return addLeadingZeros(fractionalSeconds, token.length);
1156
- }
1157
- };
1158
-
1159
- var dayPeriodEnum = {
1160
- am: 'am',
1161
- pm: 'pm',
1162
- midnight: 'midnight',
1163
- noon: 'noon',
1164
- morning: 'morning',
1165
- afternoon: 'afternoon',
1166
- evening: 'evening',
1167
- night: 'night'
389
+ var dayPeriodEnum = {
390
+ am: 'am',
391
+ pm: 'pm',
392
+ midnight: 'midnight',
393
+ noon: 'noon',
394
+ morning: 'morning',
395
+ afternoon: 'afternoon',
396
+ evening: 'evening',
397
+ night: 'night'
1168
398
  };
1169
399
  /*
1170
400
  * | | Unit | | Unit |
@@ -1214,9 +444,8 @@ var dayPeriodEnum = {
1214
444
 
1215
445
  var formatters = {
1216
446
  // Era
1217
- G: function (date, token, localize) {
447
+ G: function G(date, token, localize) {
1218
448
  var era = date.getUTCFullYear() > 0 ? 1 : 0;
1219
-
1220
449
  switch (token) {
1221
450
  // AD, BC
1222
451
  case 'G':
@@ -1226,13 +455,11 @@ var formatters = {
1226
455
  width: 'abbreviated'
1227
456
  });
1228
457
  // A, B
1229
-
1230
458
  case 'GGGGG':
1231
459
  return localize.era(era, {
1232
460
  width: 'narrow'
1233
461
  });
1234
462
  // Anno Domini, Before Christ
1235
-
1236
463
  case 'GGGG':
1237
464
  default:
1238
465
  return localize.era(era, {
@@ -1241,44 +468,45 @@ var formatters = {
1241
468
  }
1242
469
  },
1243
470
  // Year
1244
- y: function (date, token, localize) {
471
+ y: function y(date, token, localize) {
1245
472
  // Ordinal number
1246
473
  if (token === 'yo') {
1247
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
1248
-
474
+ var signedYear = date.getUTCFullYear();
475
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
1249
476
  var year = signedYear > 0 ? signedYear : 1 - signedYear;
1250
477
  return localize.ordinalNumber(year, {
1251
478
  unit: 'year'
1252
479
  });
1253
480
  }
1254
-
1255
481
  return formatters$1.y(date, token);
1256
482
  },
1257
483
  // Local week-numbering year
1258
- Y: function (date, token, localize, options) {
1259
- var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)
1260
-
1261
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year
484
+ Y: function Y(date, token, localize, options) {
485
+ var signedWeekYear = index.getUTCWeekYear(date, options);
486
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
487
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
1262
488
 
489
+ // Two digit year
1263
490
  if (token === 'YY') {
1264
491
  var twoDigitYear = weekYear % 100;
1265
492
  return addLeadingZeros(twoDigitYear, 2);
1266
- } // Ordinal number
1267
-
493
+ }
1268
494
 
495
+ // Ordinal number
1269
496
  if (token === 'Yo') {
1270
497
  return localize.ordinalNumber(weekYear, {
1271
498
  unit: 'year'
1272
499
  });
1273
- } // Padding
1274
-
500
+ }
1275
501
 
502
+ // Padding
1276
503
  return addLeadingZeros(weekYear, token.length);
1277
504
  },
1278
505
  // ISO week-numbering year
1279
- R: function (date, token) {
1280
- var isoWeekYear = getUTCISOWeekYear(date); // Padding
506
+ R: function R(date, token) {
507
+ var isoWeekYear = index.getUTCISOWeekYear(date);
1281
508
 
509
+ // Padding
1282
510
  return addLeadingZeros(isoWeekYear, token.length);
1283
511
  },
1284
512
  // Extended year. This is a single number designating the year of this calendar system.
@@ -1290,44 +518,38 @@ var formatters = {
1290
518
  // | BC 2 | 2 | -1 |
1291
519
  // Also `yy` always returns the last two digits of a year,
1292
520
  // while `uu` pads single digit years to 2 characters and returns other years unchanged.
1293
- u: function (date, token) {
521
+ u: function u(date, token) {
1294
522
  var year = date.getUTCFullYear();
1295
523
  return addLeadingZeros(year, token.length);
1296
524
  },
1297
525
  // Quarter
1298
- Q: function (date, token, localize) {
526
+ Q: function Q(date, token, localize) {
1299
527
  var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1300
-
1301
528
  switch (token) {
1302
529
  // 1, 2, 3, 4
1303
530
  case 'Q':
1304
531
  return String(quarter);
1305
532
  // 01, 02, 03, 04
1306
-
1307
533
  case 'QQ':
1308
534
  return addLeadingZeros(quarter, 2);
1309
535
  // 1st, 2nd, 3rd, 4th
1310
-
1311
536
  case 'Qo':
1312
537
  return localize.ordinalNumber(quarter, {
1313
538
  unit: 'quarter'
1314
539
  });
1315
540
  // Q1, Q2, Q3, Q4
1316
-
1317
541
  case 'QQQ':
1318
542
  return localize.quarter(quarter, {
1319
543
  width: 'abbreviated',
1320
544
  context: 'formatting'
1321
545
  });
1322
546
  // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1323
-
1324
547
  case 'QQQQQ':
1325
548
  return localize.quarter(quarter, {
1326
549
  width: 'narrow',
1327
550
  context: 'formatting'
1328
551
  });
1329
552
  // 1st quarter, 2nd quarter, ...
1330
-
1331
553
  case 'QQQQ':
1332
554
  default:
1333
555
  return localize.quarter(quarter, {
@@ -1337,39 +559,33 @@ var formatters = {
1337
559
  }
1338
560
  },
1339
561
  // Stand-alone quarter
1340
- q: function (date, token, localize) {
562
+ q: function q(date, token, localize) {
1341
563
  var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1342
-
1343
564
  switch (token) {
1344
565
  // 1, 2, 3, 4
1345
566
  case 'q':
1346
567
  return String(quarter);
1347
568
  // 01, 02, 03, 04
1348
-
1349
569
  case 'qq':
1350
570
  return addLeadingZeros(quarter, 2);
1351
571
  // 1st, 2nd, 3rd, 4th
1352
-
1353
572
  case 'qo':
1354
573
  return localize.ordinalNumber(quarter, {
1355
574
  unit: 'quarter'
1356
575
  });
1357
576
  // Q1, Q2, Q3, Q4
1358
-
1359
577
  case 'qqq':
1360
578
  return localize.quarter(quarter, {
1361
579
  width: 'abbreviated',
1362
580
  context: 'standalone'
1363
581
  });
1364
582
  // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1365
-
1366
583
  case 'qqqqq':
1367
584
  return localize.quarter(quarter, {
1368
585
  width: 'narrow',
1369
586
  context: 'standalone'
1370
587
  });
1371
588
  // 1st quarter, 2nd quarter, ...
1372
-
1373
589
  case 'qqqq':
1374
590
  default:
1375
591
  return localize.quarter(quarter, {
@@ -1379,35 +595,30 @@ var formatters = {
1379
595
  }
1380
596
  },
1381
597
  // Month
1382
- M: function (date, token, localize) {
598
+ M: function M(date, token, localize) {
1383
599
  var month = date.getUTCMonth();
1384
-
1385
600
  switch (token) {
1386
601
  case 'M':
1387
602
  case 'MM':
1388
603
  return formatters$1.M(date, token);
1389
604
  // 1st, 2nd, ..., 12th
1390
-
1391
605
  case 'Mo':
1392
606
  return localize.ordinalNumber(month + 1, {
1393
607
  unit: 'month'
1394
608
  });
1395
609
  // Jan, Feb, ..., Dec
1396
-
1397
610
  case 'MMM':
1398
611
  return localize.month(month, {
1399
612
  width: 'abbreviated',
1400
613
  context: 'formatting'
1401
614
  });
1402
615
  // J, F, ..., D
1403
-
1404
616
  case 'MMMMM':
1405
617
  return localize.month(month, {
1406
618
  width: 'narrow',
1407
619
  context: 'formatting'
1408
620
  });
1409
621
  // January, February, ..., December
1410
-
1411
622
  case 'MMMM':
1412
623
  default:
1413
624
  return localize.month(month, {
@@ -1417,39 +628,33 @@ var formatters = {
1417
628
  }
1418
629
  },
1419
630
  // Stand-alone month
1420
- L: function (date, token, localize) {
631
+ L: function L(date, token, localize) {
1421
632
  var month = date.getUTCMonth();
1422
-
1423
633
  switch (token) {
1424
634
  // 1, 2, ..., 12
1425
635
  case 'L':
1426
636
  return String(month + 1);
1427
637
  // 01, 02, ..., 12
1428
-
1429
638
  case 'LL':
1430
639
  return addLeadingZeros(month + 1, 2);
1431
640
  // 1st, 2nd, ..., 12th
1432
-
1433
641
  case 'Lo':
1434
642
  return localize.ordinalNumber(month + 1, {
1435
643
  unit: 'month'
1436
644
  });
1437
645
  // Jan, Feb, ..., Dec
1438
-
1439
646
  case 'LLL':
1440
647
  return localize.month(month, {
1441
648
  width: 'abbreviated',
1442
649
  context: 'standalone'
1443
650
  });
1444
651
  // J, F, ..., D
1445
-
1446
652
  case 'LLLLL':
1447
653
  return localize.month(month, {
1448
654
  width: 'narrow',
1449
655
  context: 'standalone'
1450
656
  });
1451
657
  // January, February, ..., December
1452
-
1453
658
  case 'LLLL':
1454
659
  default:
1455
660
  return localize.month(month, {
@@ -1459,55 +664,47 @@ var formatters = {
1459
664
  }
1460
665
  },
1461
666
  // Local week of year
1462
- w: function (date, token, localize, options) {
1463
- var week = getUTCWeek(date, options);
1464
-
667
+ w: function w(date, token, localize, options) {
668
+ var week = index.getUTCWeek(date, options);
1465
669
  if (token === 'wo') {
1466
670
  return localize.ordinalNumber(week, {
1467
671
  unit: 'week'
1468
672
  });
1469
673
  }
1470
-
1471
674
  return addLeadingZeros(week, token.length);
1472
675
  },
1473
676
  // ISO week of year
1474
- I: function (date, token, localize) {
1475
- var isoWeek = getUTCISOWeek(date);
1476
-
677
+ I: function I(date, token, localize) {
678
+ var isoWeek = index.getUTCISOWeek(date);
1477
679
  if (token === 'Io') {
1478
680
  return localize.ordinalNumber(isoWeek, {
1479
681
  unit: 'week'
1480
682
  });
1481
683
  }
1482
-
1483
684
  return addLeadingZeros(isoWeek, token.length);
1484
685
  },
1485
686
  // Day of the month
1486
- d: function (date, token, localize) {
687
+ d: function d(date, token, localize) {
1487
688
  if (token === 'do') {
1488
689
  return localize.ordinalNumber(date.getUTCDate(), {
1489
690
  unit: 'date'
1490
691
  });
1491
692
  }
1492
-
1493
693
  return formatters$1.d(date, token);
1494
694
  },
1495
695
  // Day of year
1496
- D: function (date, token, localize) {
696
+ D: function D(date, token, localize) {
1497
697
  var dayOfYear = getUTCDayOfYear(date);
1498
-
1499
698
  if (token === 'Do') {
1500
699
  return localize.ordinalNumber(dayOfYear, {
1501
700
  unit: 'dayOfYear'
1502
701
  });
1503
702
  }
1504
-
1505
703
  return addLeadingZeros(dayOfYear, token.length);
1506
704
  },
1507
705
  // Day of week
1508
- E: function (date, token, localize) {
706
+ E: function E(date, token, localize) {
1509
707
  var dayOfWeek = date.getUTCDay();
1510
-
1511
708
  switch (token) {
1512
709
  // Tue
1513
710
  case 'E':
@@ -1518,21 +715,18 @@ var formatters = {
1518
715
  context: 'formatting'
1519
716
  });
1520
717
  // T
1521
-
1522
718
  case 'EEEEE':
1523
719
  return localize.day(dayOfWeek, {
1524
720
  width: 'narrow',
1525
721
  context: 'formatting'
1526
722
  });
1527
723
  // Tu
1528
-
1529
724
  case 'EEEEEE':
1530
725
  return localize.day(dayOfWeek, {
1531
726
  width: 'short',
1532
727
  context: 'formatting'
1533
728
  });
1534
729
  // Tuesday
1535
-
1536
730
  case 'EEEE':
1537
731
  default:
1538
732
  return localize.day(dayOfWeek, {
@@ -1542,46 +736,39 @@ var formatters = {
1542
736
  }
1543
737
  },
1544
738
  // Local day of week
1545
- e: function (date, token, localize, options) {
739
+ e: function e(date, token, localize, options) {
1546
740
  var dayOfWeek = date.getUTCDay();
1547
741
  var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1548
-
1549
742
  switch (token) {
1550
743
  // Numerical value (Nth day of week with current locale or weekStartsOn)
1551
744
  case 'e':
1552
745
  return String(localDayOfWeek);
1553
746
  // Padded numerical value
1554
-
1555
747
  case 'ee':
1556
748
  return addLeadingZeros(localDayOfWeek, 2);
1557
749
  // 1st, 2nd, ..., 7th
1558
-
1559
750
  case 'eo':
1560
751
  return localize.ordinalNumber(localDayOfWeek, {
1561
752
  unit: 'day'
1562
753
  });
1563
-
1564
754
  case 'eee':
1565
755
  return localize.day(dayOfWeek, {
1566
756
  width: 'abbreviated',
1567
757
  context: 'formatting'
1568
758
  });
1569
759
  // T
1570
-
1571
760
  case 'eeeee':
1572
761
  return localize.day(dayOfWeek, {
1573
762
  width: 'narrow',
1574
763
  context: 'formatting'
1575
764
  });
1576
765
  // Tu
1577
-
1578
766
  case 'eeeeee':
1579
767
  return localize.day(dayOfWeek, {
1580
768
  width: 'short',
1581
769
  context: 'formatting'
1582
770
  });
1583
771
  // Tuesday
1584
-
1585
772
  case 'eeee':
1586
773
  default:
1587
774
  return localize.day(dayOfWeek, {
@@ -1591,46 +778,39 @@ var formatters = {
1591
778
  }
1592
779
  },
1593
780
  // Stand-alone local day of week
1594
- c: function (date, token, localize, options) {
781
+ c: function c(date, token, localize, options) {
1595
782
  var dayOfWeek = date.getUTCDay();
1596
783
  var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1597
-
1598
784
  switch (token) {
1599
785
  // Numerical value (same as in `e`)
1600
786
  case 'c':
1601
787
  return String(localDayOfWeek);
1602
788
  // Padded numerical value
1603
-
1604
789
  case 'cc':
1605
790
  return addLeadingZeros(localDayOfWeek, token.length);
1606
791
  // 1st, 2nd, ..., 7th
1607
-
1608
792
  case 'co':
1609
793
  return localize.ordinalNumber(localDayOfWeek, {
1610
794
  unit: 'day'
1611
795
  });
1612
-
1613
796
  case 'ccc':
1614
797
  return localize.day(dayOfWeek, {
1615
798
  width: 'abbreviated',
1616
799
  context: 'standalone'
1617
800
  });
1618
801
  // T
1619
-
1620
802
  case 'ccccc':
1621
803
  return localize.day(dayOfWeek, {
1622
804
  width: 'narrow',
1623
805
  context: 'standalone'
1624
806
  });
1625
807
  // Tu
1626
-
1627
808
  case 'cccccc':
1628
809
  return localize.day(dayOfWeek, {
1629
810
  width: 'short',
1630
811
  context: 'standalone'
1631
812
  });
1632
813
  // Tuesday
1633
-
1634
814
  case 'cccc':
1635
815
  default:
1636
816
  return localize.day(dayOfWeek, {
@@ -1640,47 +820,40 @@ var formatters = {
1640
820
  }
1641
821
  },
1642
822
  // ISO day of week
1643
- i: function (date, token, localize) {
823
+ i: function i(date, token, localize) {
1644
824
  var dayOfWeek = date.getUTCDay();
1645
825
  var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1646
-
1647
826
  switch (token) {
1648
827
  // 2
1649
828
  case 'i':
1650
829
  return String(isoDayOfWeek);
1651
830
  // 02
1652
-
1653
831
  case 'ii':
1654
832
  return addLeadingZeros(isoDayOfWeek, token.length);
1655
833
  // 2nd
1656
-
1657
834
  case 'io':
1658
835
  return localize.ordinalNumber(isoDayOfWeek, {
1659
836
  unit: 'day'
1660
837
  });
1661
838
  // Tue
1662
-
1663
839
  case 'iii':
1664
840
  return localize.day(dayOfWeek, {
1665
841
  width: 'abbreviated',
1666
842
  context: 'formatting'
1667
843
  });
1668
844
  // T
1669
-
1670
845
  case 'iiiii':
1671
846
  return localize.day(dayOfWeek, {
1672
847
  width: 'narrow',
1673
848
  context: 'formatting'
1674
849
  });
1675
850
  // Tu
1676
-
1677
851
  case 'iiiiii':
1678
852
  return localize.day(dayOfWeek, {
1679
853
  width: 'short',
1680
854
  context: 'formatting'
1681
855
  });
1682
856
  // Tuesday
1683
-
1684
857
  case 'iiii':
1685
858
  default:
1686
859
  return localize.day(dayOfWeek, {
@@ -1690,10 +863,9 @@ var formatters = {
1690
863
  }
1691
864
  },
1692
865
  // AM or PM
1693
- a: function (date, token, localize) {
866
+ a: function a(date, token, localize) {
1694
867
  var hours = date.getUTCHours();
1695
868
  var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1696
-
1697
869
  switch (token) {
1698
870
  case 'a':
1699
871
  case 'aa':
@@ -1701,19 +873,16 @@ var formatters = {
1701
873
  width: 'abbreviated',
1702
874
  context: 'formatting'
1703
875
  });
1704
-
1705
876
  case 'aaa':
1706
877
  return localize.dayPeriod(dayPeriodEnumValue, {
1707
878
  width: 'abbreviated',
1708
879
  context: 'formatting'
1709
880
  }).toLowerCase();
1710
-
1711
881
  case 'aaaaa':
1712
882
  return localize.dayPeriod(dayPeriodEnumValue, {
1713
883
  width: 'narrow',
1714
884
  context: 'formatting'
1715
885
  });
1716
-
1717
886
  case 'aaaa':
1718
887
  default:
1719
888
  return localize.dayPeriod(dayPeriodEnumValue, {
@@ -1723,10 +892,9 @@ var formatters = {
1723
892
  }
1724
893
  },
1725
894
  // AM, PM, midnight, noon
1726
- b: function (date, token, localize) {
895
+ b: function b(date, token, localize) {
1727
896
  var hours = date.getUTCHours();
1728
897
  var dayPeriodEnumValue;
1729
-
1730
898
  if (hours === 12) {
1731
899
  dayPeriodEnumValue = dayPeriodEnum.noon;
1732
900
  } else if (hours === 0) {
@@ -1734,7 +902,6 @@ var formatters = {
1734
902
  } else {
1735
903
  dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1736
904
  }
1737
-
1738
905
  switch (token) {
1739
906
  case 'b':
1740
907
  case 'bb':
@@ -1742,19 +909,16 @@ var formatters = {
1742
909
  width: 'abbreviated',
1743
910
  context: 'formatting'
1744
911
  });
1745
-
1746
912
  case 'bbb':
1747
913
  return localize.dayPeriod(dayPeriodEnumValue, {
1748
914
  width: 'abbreviated',
1749
915
  context: 'formatting'
1750
916
  }).toLowerCase();
1751
-
1752
917
  case 'bbbbb':
1753
918
  return localize.dayPeriod(dayPeriodEnumValue, {
1754
919
  width: 'narrow',
1755
920
  context: 'formatting'
1756
921
  });
1757
-
1758
922
  case 'bbbb':
1759
923
  default:
1760
924
  return localize.dayPeriod(dayPeriodEnumValue, {
@@ -1764,10 +928,9 @@ var formatters = {
1764
928
  }
1765
929
  },
1766
930
  // in the morning, in the afternoon, in the evening, at night
1767
- B: function (date, token, localize) {
931
+ B: function B(date, token, localize) {
1768
932
  var hours = date.getUTCHours();
1769
933
  var dayPeriodEnumValue;
1770
-
1771
934
  if (hours >= 17) {
1772
935
  dayPeriodEnumValue = dayPeriodEnum.evening;
1773
936
  } else if (hours >= 12) {
@@ -1777,7 +940,6 @@ var formatters = {
1777
940
  } else {
1778
941
  dayPeriodEnumValue = dayPeriodEnum.night;
1779
942
  }
1780
-
1781
943
  switch (token) {
1782
944
  case 'B':
1783
945
  case 'BB':
@@ -1786,13 +948,11 @@ var formatters = {
1786
948
  width: 'abbreviated',
1787
949
  context: 'formatting'
1788
950
  });
1789
-
1790
951
  case 'BBBBB':
1791
952
  return localize.dayPeriod(dayPeriodEnumValue, {
1792
953
  width: 'narrow',
1793
954
  context: 'formatting'
1794
955
  });
1795
-
1796
956
  case 'BBBB':
1797
957
  default:
1798
958
  return localize.dayPeriod(dayPeriodEnumValue, {
@@ -1802,7 +962,7 @@ var formatters = {
1802
962
  }
1803
963
  },
1804
964
  // Hour [1-12]
1805
- h: function (date, token, localize) {
965
+ h: function h(date, token, localize) {
1806
966
  if (token === 'ho') {
1807
967
  var hours = date.getUTCHours() % 12;
1808
968
  if (hours === 0) hours = 12;
@@ -1810,133 +970,119 @@ var formatters = {
1810
970
  unit: 'hour'
1811
971
  });
1812
972
  }
1813
-
1814
973
  return formatters$1.h(date, token);
1815
974
  },
1816
975
  // Hour [0-23]
1817
- H: function (date, token, localize) {
976
+ H: function H(date, token, localize) {
1818
977
  if (token === 'Ho') {
1819
978
  return localize.ordinalNumber(date.getUTCHours(), {
1820
979
  unit: 'hour'
1821
980
  });
1822
981
  }
1823
-
1824
982
  return formatters$1.H(date, token);
1825
983
  },
1826
984
  // Hour [0-11]
1827
- K: function (date, token, localize) {
985
+ K: function K(date, token, localize) {
1828
986
  var hours = date.getUTCHours() % 12;
1829
-
1830
987
  if (token === 'Ko') {
1831
988
  return localize.ordinalNumber(hours, {
1832
989
  unit: 'hour'
1833
990
  });
1834
991
  }
1835
-
1836
992
  return addLeadingZeros(hours, token.length);
1837
993
  },
1838
994
  // Hour [1-24]
1839
- k: function (date, token, localize) {
995
+ k: function k(date, token, localize) {
1840
996
  var hours = date.getUTCHours();
1841
997
  if (hours === 0) hours = 24;
1842
-
1843
998
  if (token === 'ko') {
1844
999
  return localize.ordinalNumber(hours, {
1845
1000
  unit: 'hour'
1846
1001
  });
1847
1002
  }
1848
-
1849
1003
  return addLeadingZeros(hours, token.length);
1850
1004
  },
1851
1005
  // Minute
1852
- m: function (date, token, localize) {
1006
+ m: function m(date, token, localize) {
1853
1007
  if (token === 'mo') {
1854
1008
  return localize.ordinalNumber(date.getUTCMinutes(), {
1855
1009
  unit: 'minute'
1856
1010
  });
1857
1011
  }
1858
-
1859
1012
  return formatters$1.m(date, token);
1860
1013
  },
1861
1014
  // Second
1862
- s: function (date, token, localize) {
1015
+ s: function s(date, token, localize) {
1863
1016
  if (token === 'so') {
1864
1017
  return localize.ordinalNumber(date.getUTCSeconds(), {
1865
1018
  unit: 'second'
1866
1019
  });
1867
1020
  }
1868
-
1869
1021
  return formatters$1.s(date, token);
1870
1022
  },
1871
1023
  // Fraction of second
1872
- S: function (date, token) {
1024
+ S: function S(date, token) {
1873
1025
  return formatters$1.S(date, token);
1874
1026
  },
1875
1027
  // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1876
- X: function (date, token, _localize, options) {
1028
+ X: function X(date, token, _localize, options) {
1877
1029
  var originalDate = options._originalDate || date;
1878
1030
  var timezoneOffset = originalDate.getTimezoneOffset();
1879
-
1880
1031
  if (timezoneOffset === 0) {
1881
1032
  return 'Z';
1882
1033
  }
1883
-
1884
1034
  switch (token) {
1885
1035
  // Hours and optional minutes
1886
1036
  case 'X':
1887
1037
  return formatTimezoneWithOptionalMinutes(timezoneOffset);
1038
+
1888
1039
  // Hours, minutes and optional seconds without `:` delimiter
1889
1040
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1890
1041
  // so this token always has the same output as `XX`
1891
-
1892
1042
  case 'XXXX':
1893
1043
  case 'XX':
1894
1044
  // Hours and minutes without `:` delimiter
1895
1045
  return formatTimezone(timezoneOffset);
1046
+
1896
1047
  // Hours, minutes and optional seconds with `:` delimiter
1897
1048
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1898
1049
  // so this token always has the same output as `XXX`
1899
-
1900
1050
  case 'XXXXX':
1901
1051
  case 'XXX': // Hours and minutes with `:` delimiter
1902
-
1903
1052
  default:
1904
1053
  return formatTimezone(timezoneOffset, ':');
1905
1054
  }
1906
1055
  },
1907
1056
  // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1908
- x: function (date, token, _localize, options) {
1057
+ x: function x(date, token, _localize, options) {
1909
1058
  var originalDate = options._originalDate || date;
1910
1059
  var timezoneOffset = originalDate.getTimezoneOffset();
1911
-
1912
1060
  switch (token) {
1913
1061
  // Hours and optional minutes
1914
1062
  case 'x':
1915
1063
  return formatTimezoneWithOptionalMinutes(timezoneOffset);
1064
+
1916
1065
  // Hours, minutes and optional seconds without `:` delimiter
1917
1066
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1918
1067
  // so this token always has the same output as `xx`
1919
-
1920
1068
  case 'xxxx':
1921
1069
  case 'xx':
1922
1070
  // Hours and minutes without `:` delimiter
1923
1071
  return formatTimezone(timezoneOffset);
1072
+
1924
1073
  // Hours, minutes and optional seconds with `:` delimiter
1925
1074
  // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1926
1075
  // so this token always has the same output as `xxx`
1927
-
1928
1076
  case 'xxxxx':
1929
1077
  case 'xxx': // Hours and minutes with `:` delimiter
1930
-
1931
1078
  default:
1932
1079
  return formatTimezone(timezoneOffset, ':');
1933
1080
  }
1934
1081
  },
1935
1082
  // Timezone (GMT)
1936
- O: function (date, token, _localize, options) {
1083
+ O: function O(date, token, _localize, options) {
1937
1084
  var originalDate = options._originalDate || date;
1938
1085
  var timezoneOffset = originalDate.getTimezoneOffset();
1939
-
1940
1086
  switch (token) {
1941
1087
  // Short
1942
1088
  case 'O':
@@ -1944,17 +1090,15 @@ var formatters = {
1944
1090
  case 'OOO':
1945
1091
  return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1946
1092
  // Long
1947
-
1948
1093
  case 'OOOO':
1949
1094
  default:
1950
1095
  return 'GMT' + formatTimezone(timezoneOffset, ':');
1951
1096
  }
1952
1097
  },
1953
1098
  // Timezone (specific non-location)
1954
- z: function (date, token, _localize, options) {
1099
+ z: function z(date, token, _localize, options) {
1955
1100
  var originalDate = options._originalDate || date;
1956
1101
  var timezoneOffset = originalDate.getTimezoneOffset();
1957
-
1958
1102
  switch (token) {
1959
1103
  // Short
1960
1104
  case 'z':
@@ -1962,173 +1106,628 @@ var formatters = {
1962
1106
  case 'zzz':
1963
1107
  return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1964
1108
  // Long
1965
-
1966
1109
  case 'zzzz':
1967
1110
  default:
1968
1111
  return 'GMT' + formatTimezone(timezoneOffset, ':');
1969
1112
  }
1970
1113
  },
1971
1114
  // Seconds timestamp
1972
- t: function (date, token, _localize, options) {
1115
+ t: function t(date, token, _localize, options) {
1973
1116
  var originalDate = options._originalDate || date;
1974
1117
  var timestamp = Math.floor(originalDate.getTime() / 1000);
1975
1118
  return addLeadingZeros(timestamp, token.length);
1976
1119
  },
1977
1120
  // Milliseconds timestamp
1978
- T: function (date, token, _localize, options) {
1121
+ T: function T(date, token, _localize, options) {
1979
1122
  var originalDate = options._originalDate || date;
1980
1123
  var timestamp = originalDate.getTime();
1981
1124
  return addLeadingZeros(timestamp, token.length);
1982
1125
  }
1983
1126
  };
1127
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1128
+ var sign = offset > 0 ? '-' : '+';
1129
+ var absOffset = Math.abs(offset);
1130
+ var hours = Math.floor(absOffset / 60);
1131
+ var minutes = absOffset % 60;
1132
+ if (minutes === 0) {
1133
+ return sign + String(hours);
1134
+ }
1135
+ var delimiter = dirtyDelimiter || '';
1136
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1137
+ }
1138
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1139
+ if (offset % 60 === 0) {
1140
+ var sign = offset > 0 ? '-' : '+';
1141
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1142
+ }
1143
+ return formatTimezone(offset, dirtyDelimiter);
1144
+ }
1145
+ function formatTimezone(offset, dirtyDelimiter) {
1146
+ var delimiter = dirtyDelimiter || '';
1147
+ var sign = offset > 0 ? '-' : '+';
1148
+ var absOffset = Math.abs(offset);
1149
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1150
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1151
+ return sign + hours + delimiter + minutes;
1152
+ }
1153
+
1154
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1155
+ switch (pattern) {
1156
+ case 'P':
1157
+ return formatLong.date({
1158
+ width: 'short'
1159
+ });
1160
+ case 'PP':
1161
+ return formatLong.date({
1162
+ width: 'medium'
1163
+ });
1164
+ case 'PPP':
1165
+ return formatLong.date({
1166
+ width: 'long'
1167
+ });
1168
+ case 'PPPP':
1169
+ default:
1170
+ return formatLong.date({
1171
+ width: 'full'
1172
+ });
1173
+ }
1174
+ };
1175
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1176
+ switch (pattern) {
1177
+ case 'p':
1178
+ return formatLong.time({
1179
+ width: 'short'
1180
+ });
1181
+ case 'pp':
1182
+ return formatLong.time({
1183
+ width: 'medium'
1184
+ });
1185
+ case 'ppp':
1186
+ return formatLong.time({
1187
+ width: 'long'
1188
+ });
1189
+ case 'pppp':
1190
+ default:
1191
+ return formatLong.time({
1192
+ width: 'full'
1193
+ });
1194
+ }
1195
+ };
1196
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1197
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1198
+ var datePattern = matchResult[1];
1199
+ var timePattern = matchResult[2];
1200
+ if (!timePattern) {
1201
+ return dateLongFormatter(pattern, formatLong);
1202
+ }
1203
+ var dateTimeFormat;
1204
+ switch (datePattern) {
1205
+ case 'P':
1206
+ dateTimeFormat = formatLong.dateTime({
1207
+ width: 'short'
1208
+ });
1209
+ break;
1210
+ case 'PP':
1211
+ dateTimeFormat = formatLong.dateTime({
1212
+ width: 'medium'
1213
+ });
1214
+ break;
1215
+ case 'PPP':
1216
+ dateTimeFormat = formatLong.dateTime({
1217
+ width: 'long'
1218
+ });
1219
+ break;
1220
+ case 'PPPP':
1221
+ default:
1222
+ dateTimeFormat = formatLong.dateTime({
1223
+ width: 'full'
1224
+ });
1225
+ break;
1226
+ }
1227
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1228
+ };
1229
+ var longFormatters = {
1230
+ p: timeLongFormatter,
1231
+ P: dateTimeLongFormatter
1232
+ };
1233
+
1234
+ var protectedDayOfYearTokens = ['D', 'DD'];
1235
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1236
+ function isProtectedDayOfYearToken(token) {
1237
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1238
+ }
1239
+ function isProtectedWeekYearToken(token) {
1240
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1241
+ }
1242
+ function throwProtectedError(token, format, input) {
1243
+ if (token === 'YYYY') {
1244
+ 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"));
1245
+ } else if (token === 'YY') {
1246
+ 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"));
1247
+ } else if (token === 'D') {
1248
+ 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"));
1249
+ } else if (token === 'DD') {
1250
+ 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"));
1251
+ }
1252
+ }
1253
+
1254
+ var formatDistanceLocale = {
1255
+ lessThanXSeconds: {
1256
+ one: 'less than a second',
1257
+ other: 'less than {{count}} seconds'
1258
+ },
1259
+ xSeconds: {
1260
+ one: '1 second',
1261
+ other: '{{count}} seconds'
1262
+ },
1263
+ halfAMinute: 'half a minute',
1264
+ lessThanXMinutes: {
1265
+ one: 'less than a minute',
1266
+ other: 'less than {{count}} minutes'
1267
+ },
1268
+ xMinutes: {
1269
+ one: '1 minute',
1270
+ other: '{{count}} minutes'
1271
+ },
1272
+ aboutXHours: {
1273
+ one: 'about 1 hour',
1274
+ other: 'about {{count}} hours'
1275
+ },
1276
+ xHours: {
1277
+ one: '1 hour',
1278
+ other: '{{count}} hours'
1279
+ },
1280
+ xDays: {
1281
+ one: '1 day',
1282
+ other: '{{count}} days'
1283
+ },
1284
+ aboutXWeeks: {
1285
+ one: 'about 1 week',
1286
+ other: 'about {{count}} weeks'
1287
+ },
1288
+ xWeeks: {
1289
+ one: '1 week',
1290
+ other: '{{count}} weeks'
1291
+ },
1292
+ aboutXMonths: {
1293
+ one: 'about 1 month',
1294
+ other: 'about {{count}} months'
1295
+ },
1296
+ xMonths: {
1297
+ one: '1 month',
1298
+ other: '{{count}} months'
1299
+ },
1300
+ aboutXYears: {
1301
+ one: 'about 1 year',
1302
+ other: 'about {{count}} years'
1303
+ },
1304
+ xYears: {
1305
+ one: '1 year',
1306
+ other: '{{count}} years'
1307
+ },
1308
+ overXYears: {
1309
+ one: 'over 1 year',
1310
+ other: 'over {{count}} years'
1311
+ },
1312
+ almostXYears: {
1313
+ one: 'almost 1 year',
1314
+ other: 'almost {{count}} years'
1315
+ }
1316
+ };
1317
+ var formatDistance = function formatDistance(token, count, options) {
1318
+ var result;
1319
+ var tokenValue = formatDistanceLocale[token];
1320
+ if (typeof tokenValue === 'string') {
1321
+ result = tokenValue;
1322
+ } else if (count === 1) {
1323
+ result = tokenValue.one;
1324
+ } else {
1325
+ result = tokenValue.other.replace('{{count}}', count.toString());
1326
+ }
1327
+ if (options !== null && options !== void 0 && options.addSuffix) {
1328
+ if (options.comparison && options.comparison > 0) {
1329
+ return 'in ' + result;
1330
+ } else {
1331
+ return result + ' ago';
1332
+ }
1333
+ }
1334
+ return result;
1335
+ };
1984
1336
 
1985
- function formatTimezoneShort(offset, dirtyDelimiter) {
1986
- var sign = offset > 0 ? '-' : '+';
1987
- var absOffset = Math.abs(offset);
1988
- var hours = Math.floor(absOffset / 60);
1989
- var minutes = absOffset % 60;
1990
-
1991
- if (minutes === 0) {
1992
- return sign + String(hours);
1993
- }
1994
-
1995
- var delimiter = dirtyDelimiter || '';
1996
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1337
+ function buildFormatLongFn(args) {
1338
+ return function () {
1339
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1340
+ // TODO: Remove String()
1341
+ var width = options.width ? String(options.width) : args.defaultWidth;
1342
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1343
+ return format;
1344
+ };
1997
1345
  }
1998
1346
 
1999
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
2000
- if (offset % 60 === 0) {
2001
- var sign = offset > 0 ? '-' : '+';
2002
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
2003
- }
1347
+ var dateFormats = {
1348
+ full: 'EEEE, MMMM do, y',
1349
+ long: 'MMMM do, y',
1350
+ medium: 'MMM d, y',
1351
+ short: 'MM/dd/yyyy'
1352
+ };
1353
+ var timeFormats = {
1354
+ full: 'h:mm:ss a zzzz',
1355
+ long: 'h:mm:ss a z',
1356
+ medium: 'h:mm:ss a',
1357
+ short: 'h:mm a'
1358
+ };
1359
+ var dateTimeFormats = {
1360
+ full: "{{date}} 'at' {{time}}",
1361
+ long: "{{date}} 'at' {{time}}",
1362
+ medium: '{{date}}, {{time}}',
1363
+ short: '{{date}}, {{time}}'
1364
+ };
1365
+ var formatLong = {
1366
+ date: buildFormatLongFn({
1367
+ formats: dateFormats,
1368
+ defaultWidth: 'full'
1369
+ }),
1370
+ time: buildFormatLongFn({
1371
+ formats: timeFormats,
1372
+ defaultWidth: 'full'
1373
+ }),
1374
+ dateTime: buildFormatLongFn({
1375
+ formats: dateTimeFormats,
1376
+ defaultWidth: 'full'
1377
+ })
1378
+ };
2004
1379
 
2005
- return formatTimezone(offset, dirtyDelimiter);
2006
- }
1380
+ var formatRelativeLocale = {
1381
+ lastWeek: "'last' eeee 'at' p",
1382
+ yesterday: "'yesterday at' p",
1383
+ today: "'today at' p",
1384
+ tomorrow: "'tomorrow at' p",
1385
+ nextWeek: "eeee 'at' p",
1386
+ other: 'P'
1387
+ };
1388
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1389
+ return formatRelativeLocale[token];
1390
+ };
2007
1391
 
2008
- function formatTimezone(offset, dirtyDelimiter) {
2009
- var delimiter = dirtyDelimiter || '';
2010
- var sign = offset > 0 ? '-' : '+';
2011
- var absOffset = Math.abs(offset);
2012
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
2013
- var minutes = addLeadingZeros(absOffset % 60, 2);
2014
- return sign + hours + delimiter + minutes;
1392
+ function buildLocalizeFn(args) {
1393
+ return function (dirtyIndex, options) {
1394
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1395
+ var valuesArray;
1396
+ if (context === 'formatting' && args.formattingValues) {
1397
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1398
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1399
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1400
+ } else {
1401
+ var _defaultWidth = args.defaultWidth;
1402
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1403
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1404
+ }
1405
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1406
+ // @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!
1407
+ return valuesArray[index];
1408
+ };
2015
1409
  }
2016
1410
 
2017
- function dateLongFormatter(pattern, formatLong) {
2018
- switch (pattern) {
2019
- case 'P':
2020
- return formatLong.date({
2021
- width: 'short'
2022
- });
2023
-
2024
- case 'PP':
2025
- return formatLong.date({
2026
- width: 'medium'
2027
- });
2028
-
2029
- case 'PPP':
2030
- return formatLong.date({
2031
- width: 'long'
2032
- });
1411
+ var eraValues = {
1412
+ narrow: ['B', 'A'],
1413
+ abbreviated: ['BC', 'AD'],
1414
+ wide: ['Before Christ', 'Anno Domini']
1415
+ };
1416
+ var quarterValues = {
1417
+ narrow: ['1', '2', '3', '4'],
1418
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1419
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1420
+ };
2033
1421
 
2034
- case 'PPPP':
2035
- default:
2036
- return formatLong.date({
2037
- width: 'full'
2038
- });
1422
+ // Note: in English, the names of days of the week and months are capitalized.
1423
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1424
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1425
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1426
+ var monthValues = {
1427
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1428
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1429
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1430
+ };
1431
+ var dayValues = {
1432
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1433
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1434
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1435
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1436
+ };
1437
+ var dayPeriodValues = {
1438
+ narrow: {
1439
+ am: 'a',
1440
+ pm: 'p',
1441
+ midnight: 'mi',
1442
+ noon: 'n',
1443
+ morning: 'morning',
1444
+ afternoon: 'afternoon',
1445
+ evening: 'evening',
1446
+ night: 'night'
1447
+ },
1448
+ abbreviated: {
1449
+ am: 'AM',
1450
+ pm: 'PM',
1451
+ midnight: 'midnight',
1452
+ noon: 'noon',
1453
+ morning: 'morning',
1454
+ afternoon: 'afternoon',
1455
+ evening: 'evening',
1456
+ night: 'night'
1457
+ },
1458
+ wide: {
1459
+ am: 'a.m.',
1460
+ pm: 'p.m.',
1461
+ midnight: 'midnight',
1462
+ noon: 'noon',
1463
+ morning: 'morning',
1464
+ afternoon: 'afternoon',
1465
+ evening: 'evening',
1466
+ night: 'night'
2039
1467
  }
2040
- }
2041
-
2042
- function timeLongFormatter(pattern, formatLong) {
2043
- switch (pattern) {
2044
- case 'p':
2045
- return formatLong.time({
2046
- width: 'short'
2047
- });
1468
+ };
1469
+ var formattingDayPeriodValues = {
1470
+ narrow: {
1471
+ am: 'a',
1472
+ pm: 'p',
1473
+ midnight: 'mi',
1474
+ noon: 'n',
1475
+ morning: 'in the morning',
1476
+ afternoon: 'in the afternoon',
1477
+ evening: 'in the evening',
1478
+ night: 'at night'
1479
+ },
1480
+ abbreviated: {
1481
+ am: 'AM',
1482
+ pm: 'PM',
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'
1489
+ },
1490
+ wide: {
1491
+ am: 'a.m.',
1492
+ pm: 'p.m.',
1493
+ midnight: 'midnight',
1494
+ noon: 'noon',
1495
+ morning: 'in the morning',
1496
+ afternoon: 'in the afternoon',
1497
+ evening: 'in the evening',
1498
+ night: 'at night'
1499
+ }
1500
+ };
1501
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1502
+ var number = Number(dirtyNumber);
2048
1503
 
2049
- case 'pp':
2050
- return formatLong.time({
2051
- width: 'medium'
2052
- });
1504
+ // If ordinal numbers depend on context, for example,
1505
+ // if they are different for different grammatical genders,
1506
+ // use `options.unit`.
1507
+ //
1508
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1509
+ // 'day', 'hour', 'minute', 'second'.
2053
1510
 
2054
- case 'ppp':
2055
- return formatLong.time({
2056
- width: 'long'
2057
- });
1511
+ var rem100 = number % 100;
1512
+ if (rem100 > 20 || rem100 < 10) {
1513
+ switch (rem100 % 10) {
1514
+ case 1:
1515
+ return number + 'st';
1516
+ case 2:
1517
+ return number + 'nd';
1518
+ case 3:
1519
+ return number + 'rd';
1520
+ }
1521
+ }
1522
+ return number + 'th';
1523
+ };
1524
+ var localize = {
1525
+ ordinalNumber: ordinalNumber,
1526
+ era: buildLocalizeFn({
1527
+ values: eraValues,
1528
+ defaultWidth: 'wide'
1529
+ }),
1530
+ quarter: buildLocalizeFn({
1531
+ values: quarterValues,
1532
+ defaultWidth: 'wide',
1533
+ argumentCallback: function argumentCallback(quarter) {
1534
+ return quarter - 1;
1535
+ }
1536
+ }),
1537
+ month: buildLocalizeFn({
1538
+ values: monthValues,
1539
+ defaultWidth: 'wide'
1540
+ }),
1541
+ day: buildLocalizeFn({
1542
+ values: dayValues,
1543
+ defaultWidth: 'wide'
1544
+ }),
1545
+ dayPeriod: buildLocalizeFn({
1546
+ values: dayPeriodValues,
1547
+ defaultWidth: 'wide',
1548
+ formattingValues: formattingDayPeriodValues,
1549
+ defaultFormattingWidth: 'wide'
1550
+ })
1551
+ };
2058
1552
 
2059
- case 'pppp':
2060
- default:
2061
- return formatLong.time({
2062
- width: 'full'
2063
- });
2064
- }
1553
+ function buildMatchFn(args) {
1554
+ return function (string) {
1555
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1556
+ var width = options.width;
1557
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1558
+ var matchResult = string.match(matchPattern);
1559
+ if (!matchResult) {
1560
+ return null;
1561
+ }
1562
+ var matchedString = matchResult[0];
1563
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1564
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1565
+ return pattern.test(matchedString);
1566
+ }) : findKey(parsePatterns, function (pattern) {
1567
+ return pattern.test(matchedString);
1568
+ });
1569
+ var value;
1570
+ value = args.valueCallback ? args.valueCallback(key) : key;
1571
+ value = options.valueCallback ? options.valueCallback(value) : value;
1572
+ var rest = string.slice(matchedString.length);
1573
+ return {
1574
+ value: value,
1575
+ rest: rest
1576
+ };
1577
+ };
2065
1578
  }
2066
-
2067
- function dateTimeLongFormatter(pattern, formatLong) {
2068
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
2069
- var datePattern = matchResult[1];
2070
- var timePattern = matchResult[2];
2071
-
2072
- if (!timePattern) {
2073
- return dateLongFormatter(pattern, formatLong);
1579
+ function findKey(object, predicate) {
1580
+ for (var key in object) {
1581
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1582
+ return key;
1583
+ }
2074
1584
  }
2075
-
2076
- var dateTimeFormat;
2077
-
2078
- switch (datePattern) {
2079
- case 'P':
2080
- dateTimeFormat = formatLong.dateTime({
2081
- width: 'short'
2082
- });
2083
- break;
2084
-
2085
- case 'PP':
2086
- dateTimeFormat = formatLong.dateTime({
2087
- width: 'medium'
2088
- });
2089
- break;
2090
-
2091
- case 'PPP':
2092
- dateTimeFormat = formatLong.dateTime({
2093
- width: 'long'
2094
- });
2095
- break;
2096
-
2097
- case 'PPPP':
2098
- default:
2099
- dateTimeFormat = formatLong.dateTime({
2100
- width: 'full'
2101
- });
2102
- break;
1585
+ return undefined;
1586
+ }
1587
+ function findIndex(array, predicate) {
1588
+ for (var key = 0; key < array.length; key++) {
1589
+ if (predicate(array[key])) {
1590
+ return key;
1591
+ }
2103
1592
  }
1593
+ return undefined;
1594
+ }
2104
1595
 
2105
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
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
+ };
2106
1612
  }
2107
1613
 
2108
- var longFormatters = {
2109
- p: timeLongFormatter,
2110
- P: dateTimeLongFormatter
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
1665
+ }
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
+ })
2111
1708
  };
2112
1709
 
2113
- var protectedDayOfYearTokens = ['D', 'DD'];
2114
- var protectedWeekYearTokens = ['YY', 'YYYY'];
2115
- function isProtectedDayOfYearToken(token) {
2116
- return protectedDayOfYearTokens.indexOf(token) !== -1;
2117
- }
2118
- function isProtectedWeekYearToken(token) {
2119
- return protectedWeekYearTokens.indexOf(token) !== -1;
2120
- }
2121
- function throwProtectedError(token, format, input) {
2122
- if (token === 'YYYY') {
2123
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
2124
- } else if (token === 'YY') {
2125
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
2126
- } else if (token === 'D') {
2127
- 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"));
2128
- } else if (token === 'DD') {
2129
- 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"));
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 /* Sunday */,
1728
+ firstWeekContainsDate: 1
2130
1729
  }
2131
- }
1730
+ };
2132
1731
 
2133
1732
  // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2134
1733
  // (one of the certain letters followed by `o`)
@@ -2140,14 +1739,15 @@ function throwProtectedError(token, format, input) {
2140
1739
  // If there is no matching single quote
2141
1740
  // then the sequence will continue until the end of the string.
2142
1741
  // - . matches any single character unmatched by previous parts of the RegExps
1742
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2143
1743
 
2144
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also
1744
+ // This RegExp catches symbols escaped by quotes, and also
2145
1745
  // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2146
-
2147
1746
  var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2148
1747
  var escapedStringRegExp = /^'([^]*?)'?$/;
2149
1748
  var doubleQuoteRegExp = /''/g;
2150
1749
  var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1750
+
2151
1751
  /**
2152
1752
  * @name format
2153
1753
  * @category Common Helpers
@@ -2157,7 +1757,7 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2157
1757
  * Return the formatted date string in the given format. The result may vary by locale.
2158
1758
  *
2159
1759
  * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2160
- * > See: https://git.io/fxCyr
1760
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2161
1761
  *
2162
1762
  * The characters wrapped between two single quotes characters (') are escaped.
2163
1763
  * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
@@ -2393,30 +1993,10 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2393
1993
  * - `p`: long localized time
2394
1994
  *
2395
1995
  * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2396
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://git.io/fxCyr
1996
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2397
1997
  *
2398
1998
  * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2399
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://git.io/fxCyr
2400
- *
2401
- * ### v2.0.0 breaking changes:
2402
- *
2403
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
2404
- *
2405
- * - The second argument is now required for the sake of explicitness.
2406
- *
2407
- * ```javascript
2408
- * // Before v2.0.0
2409
- * format(new Date(2016, 0, 1))
2410
- *
2411
- * // v2.0.0 onward
2412
- * format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
2413
- * ```
2414
- *
2415
- * - New format string API for `format` function
2416
- * which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
2417
- * See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
2418
- *
2419
- * - Characters are now escaped using single quote symbols (`'`) instead of square brackets.
1999
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2420
2000
  *
2421
2001
  * @param {Date|Number} date - the original date
2422
2002
  * @param {String} format - the string of tokens
@@ -2425,9 +2005,9 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2425
2005
  * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2426
2006
  * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2427
2007
  * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2428
- * see: https://git.io/fxCyr
2008
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2429
2009
  * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2430
- * see: https://git.io/fxCyr
2010
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2431
2011
  * @returns {String} the formatted date string
2432
2012
  * @throws {TypeError} 2 arguments required
2433
2013
  * @throws {RangeError} `date` must not be Invalid Date
@@ -2435,69 +2015,63 @@ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2435
2015
  * @throws {RangeError} `options.locale` must contain `formatLong` property
2436
2016
  * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2437
2017
  * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2438
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2439
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
2440
- * @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
2441
- * @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
2018
+ * @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
2019
+ * @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
2020
+ * @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
2021
+ * @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
2442
2022
  * @throws {RangeError} format string contains an unescaped latin alphabet character
2443
2023
  *
2444
2024
  * @example
2445
2025
  * // Represent 11 February 2014 in middle-endian format:
2446
- * var result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2026
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2447
2027
  * //=> '02/11/2014'
2448
2028
  *
2449
2029
  * @example
2450
2030
  * // Represent 2 July 2014 in Esperanto:
2451
2031
  * import { eoLocale } from 'date-fns/locale/eo'
2452
- * var result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2032
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2453
2033
  * locale: eoLocale
2454
2034
  * })
2455
2035
  * //=> '2-a de julio 2014'
2456
2036
  *
2457
2037
  * @example
2458
2038
  * // Escape string by single quote characters:
2459
- * var result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2039
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2460
2040
  * //=> "3 o'clock"
2461
2041
  */
2462
2042
 
2463
- function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
2464
- requiredArgs(2, arguments);
2043
+ function format(dirtyDate, dirtyFormatStr, options) {
2044
+ 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;
2045
+ index.requiredArgs(2, arguments);
2465
2046
  var formatStr = String(dirtyFormatStr);
2466
- var options = dirtyOptions || {};
2467
- var locale$1 = options.locale || locale;
2468
- var localeFirstWeekContainsDate = locale$1.options && locale$1.options.firstWeekContainsDate;
2469
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
2470
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2047
+ var defaultOptions = index.getDefaultOptions();
2048
+ var locale$1 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : locale;
2049
+ var firstWeekContainsDate = 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);
2471
2050
 
2051
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2472
2052
  if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2473
2053
  throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2474
2054
  }
2055
+ 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);
2475
2056
 
2476
- var localeWeekStartsOn = locale$1.options && locale$1.options.weekStartsOn;
2477
- var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
2478
- var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2479
-
2057
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2480
2058
  if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2481
2059
  throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2482
2060
  }
2483
-
2484
2061
  if (!locale$1.localize) {
2485
2062
  throw new RangeError('locale must contain localize property');
2486
2063
  }
2487
-
2488
2064
  if (!locale$1.formatLong) {
2489
2065
  throw new RangeError('locale must contain formatLong property');
2490
2066
  }
2491
-
2492
- var originalDate = toDate(dirtyDate);
2493
-
2067
+ var originalDate = index.toDate(dirtyDate);
2494
2068
  if (!isValid(originalDate)) {
2495
2069
  throw new RangeError('Invalid time value');
2496
- } // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2070
+ }
2071
+
2072
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2497
2073
  // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2498
2074
  // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2499
-
2500
-
2501
2075
  var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2502
2076
  var utcDate = subMilliseconds(originalDate, timezoneOffset);
2503
2077
  var formatterOptions = {
@@ -2508,50 +2082,43 @@ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
2508
2082
  };
2509
2083
  var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2510
2084
  var firstCharacter = substring[0];
2511
-
2512
2085
  if (firstCharacter === 'p' || firstCharacter === 'P') {
2513
2086
  var longFormatter = longFormatters[firstCharacter];
2514
- return longFormatter(substring, locale$1.formatLong, formatterOptions);
2087
+ return longFormatter(substring, locale$1.formatLong);
2515
2088
  }
2516
-
2517
2089
  return substring;
2518
2090
  }).join('').match(formattingTokensRegExp).map(function (substring) {
2519
2091
  // Replace two single quote characters with one single quote character
2520
2092
  if (substring === "''") {
2521
2093
  return "'";
2522
2094
  }
2523
-
2524
2095
  var firstCharacter = substring[0];
2525
-
2526
2096
  if (firstCharacter === "'") {
2527
2097
  return cleanEscapedString(substring);
2528
2098
  }
2529
-
2530
2099
  var formatter = formatters[firstCharacter];
2531
-
2532
2100
  if (formatter) {
2533
- if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
2534
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
2101
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2102
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2535
2103
  }
2536
-
2537
- if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
2538
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
2104
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2105
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2539
2106
  }
2540
-
2541
2107
  return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2542
2108
  }
2543
-
2544
2109
  if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2545
2110
  throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2546
2111
  }
2547
-
2548
2112
  return substring;
2549
2113
  }).join('');
2550
2114
  return result;
2551
2115
  }
2552
-
2553
2116
  function cleanEscapedString(input) {
2554
- return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
2117
+ var matched = input.match(escapedStringRegExp);
2118
+ if (!matched) {
2119
+ return input;
2120
+ }
2121
+ return matched[1].replace(doubleQuoteRegExp, "'");
2555
2122
  }
2556
2123
 
2557
2124
  const getImageFromImage = (image) => {
@@ -2596,114 +2163,114 @@ const getColorForVerificationStatus = (status) => {
2596
2163
  return "#000000";
2597
2164
  }
2598
2165
  };
2599
- const getCategoryColor = (category = index.LCCategoryEnum.achievement) => {
2166
+ const getCategoryColor = (category = index$1.LCCategoryEnum.achievement) => {
2600
2167
  switch (category) {
2601
- case index.LCCategoryEnum.socialBadge:
2168
+ case index$1.LCCategoryEnum.socialBadge:
2602
2169
  return "cyan-700";
2603
- case index.LCCategoryEnum.skill:
2170
+ case index$1.LCCategoryEnum.skill:
2604
2171
  return "indigo-600";
2605
- case index.LCCategoryEnum.achievement:
2172
+ case index$1.LCCategoryEnum.achievement:
2606
2173
  return "spice-600";
2607
- case index.LCCategoryEnum.learningHistory:
2174
+ case index$1.LCCategoryEnum.learningHistory:
2608
2175
  return "emerald-700";
2609
- case index.LCCategoryEnum.id:
2176
+ case index$1.LCCategoryEnum.id:
2610
2177
  return "yellow-400";
2611
- case index.LCCategoryEnum.workHistory:
2178
+ case index$1.LCCategoryEnum.workHistory:
2612
2179
  return "blue-400";
2613
- case index.LCCategoryEnum.job:
2180
+ case index$1.LCCategoryEnum.job:
2614
2181
  return "rose-600";
2615
- case index.LCCategoryEnum.course:
2182
+ case index$1.LCCategoryEnum.course:
2616
2183
  return "emerald-700";
2617
- case index.LCCategoryEnum.currency:
2184
+ case index$1.LCCategoryEnum.currency:
2618
2185
  return "cyan-700";
2619
- case index.LCCategoryEnum.membership:
2186
+ case index$1.LCCategoryEnum.membership:
2620
2187
  return "teal-500";
2621
2188
  default:
2622
2189
  return "spice-600";
2623
2190
  }
2624
2191
  };
2625
- const getCategoryPrimaryColor = (category = index.LCCategoryEnum.achievement) => {
2192
+ const getCategoryPrimaryColor = (category = index$1.LCCategoryEnum.achievement) => {
2626
2193
  switch (category) {
2627
- case index.LCCategoryEnum.socialBadge:
2194
+ case index$1.LCCategoryEnum.socialBadge:
2628
2195
  return "cyan";
2629
- case index.LCCategoryEnum.skill:
2196
+ case index$1.LCCategoryEnum.skill:
2630
2197
  return "indigo";
2631
- case index.LCCategoryEnum.achievement:
2198
+ case index$1.LCCategoryEnum.achievement:
2632
2199
  return "spice";
2633
- case index.LCCategoryEnum.learningHistory:
2200
+ case index$1.LCCategoryEnum.learningHistory:
2634
2201
  return "emerald";
2635
- case index.LCCategoryEnum.id:
2202
+ case index$1.LCCategoryEnum.id:
2636
2203
  return "yellow";
2637
- case index.LCCategoryEnum.workHistory:
2204
+ case index$1.LCCategoryEnum.workHistory:
2638
2205
  return "blue";
2639
- case index.LCCategoryEnum.job:
2206
+ case index$1.LCCategoryEnum.job:
2640
2207
  return "rose";
2641
- case index.LCCategoryEnum.course:
2208
+ case index$1.LCCategoryEnum.course:
2642
2209
  return "emerald";
2643
- case index.LCCategoryEnum.currency:
2210
+ case index$1.LCCategoryEnum.currency:
2644
2211
  return "cyan";
2645
- case index.LCCategoryEnum.membership:
2212
+ case index$1.LCCategoryEnum.membership:
2646
2213
  return "teal";
2647
- case index.LCCategoryEnum.accommodations:
2214
+ case index$1.LCCategoryEnum.accommodations:
2648
2215
  return "amber";
2649
- case index.LCCategoryEnum.accomplishments:
2216
+ case index$1.LCCategoryEnum.accomplishments:
2650
2217
  return "lime";
2651
2218
  default:
2652
2219
  return "spice";
2653
2220
  }
2654
2221
  };
2655
- const getCategoryLightColor = (category = index.LCCategoryEnum.achievement) => {
2656
- if (category === index.LCCategoryEnum.meritBadge) {
2222
+ const getCategoryLightColor = (category = index$1.LCCategoryEnum.achievement) => {
2223
+ if (category === index$1.LCCategoryEnum.meritBadge) {
2657
2224
  return "sp-purple-base";
2658
2225
  }
2659
2226
  return `${getCategoryPrimaryColor(category)}-500`;
2660
2227
  };
2661
- const getCategoryDarkColor = (category = index.LCCategoryEnum.achievement) => {
2662
- if (category === index.LCCategoryEnum.meritBadge) {
2228
+ const getCategoryDarkColor = (category = index$1.LCCategoryEnum.achievement) => {
2229
+ if (category === index$1.LCCategoryEnum.meritBadge) {
2663
2230
  return "sp-purple-base";
2664
2231
  }
2665
2232
  return `${getCategoryPrimaryColor(category)}-700`;
2666
2233
  };
2667
- const getCategoryIcon = (category = index.LCCategoryEnum.achievement) => {
2234
+ const getCategoryIcon = (category = index$1.LCCategoryEnum.achievement) => {
2668
2235
  switch (category) {
2669
- case index.LCCategoryEnum.socialBadge:
2236
+ case index$1.LCCategoryEnum.socialBadge:
2670
2237
  return /* @__PURE__ */ React__default["default"].createElement(SocialBadgesIcon, null);
2671
- case index.LCCategoryEnum.skill:
2238
+ case index$1.LCCategoryEnum.skill:
2672
2239
  return /* @__PURE__ */ React__default["default"].createElement(PuzzlePiece.PuzzlePiece, null);
2673
- case index.LCCategoryEnum.achievement:
2240
+ case index$1.LCCategoryEnum.achievement:
2674
2241
  return /* @__PURE__ */ React__default["default"].createElement(Trophy.Trophy, {
2675
2242
  size: "21"
2676
2243
  });
2677
- case index.LCCategoryEnum.course:
2678
- case index.LCCategoryEnum.learningHistory:
2244
+ case index$1.LCCategoryEnum.course:
2245
+ case index$1.LCCategoryEnum.learningHistory:
2679
2246
  return /* @__PURE__ */ React__default["default"].createElement(User.Graduation, {
2680
2247
  size: "21"
2681
2248
  });
2682
- case index.LCCategoryEnum.job:
2683
- case index.LCCategoryEnum.workHistory:
2249
+ case index$1.LCCategoryEnum.job:
2250
+ case index$1.LCCategoryEnum.workHistory:
2684
2251
  return /* @__PURE__ */ React__default["default"].createElement(User.Briefcase, {
2685
2252
  size: "21"
2686
2253
  });
2687
- case index.LCCategoryEnum.id:
2254
+ case index$1.LCCategoryEnum.id:
2688
2255
  return /* @__PURE__ */ React__default["default"].createElement(User.User, {
2689
2256
  size: "21"
2690
2257
  });
2691
- case index.LCCategoryEnum.membership:
2258
+ case index$1.LCCategoryEnum.membership:
2692
2259
  return /* @__PURE__ */ React__default["default"].createElement(KeyIcon, {
2693
2260
  size: "21"
2694
2261
  });
2695
- case index.LCCategoryEnum.currency:
2696
- case index.LCCategoryEnum.accommodations:
2262
+ case index$1.LCCategoryEnum.currency:
2263
+ case index$1.LCCategoryEnum.accommodations:
2697
2264
  return /* @__PURE__ */ React__default["default"].createElement(AccommodationsIcon, {
2698
2265
  size: "21"
2699
2266
  });
2700
- case index.LCCategoryEnum.accomplishments:
2267
+ case index$1.LCCategoryEnum.accomplishments:
2701
2268
  return /* @__PURE__ */ React__default["default"].createElement(AccomplishmentsIcon, {
2702
2269
  size: "21"
2703
2270
  });
2704
- case index.LCCategoryEnum.meritBadge:
2271
+ case index$1.LCCategoryEnum.meritBadge:
2705
2272
  return /* @__PURE__ */ React__default["default"].createElement(ScoutsPledge, null);
2706
- case index.LCCategoryEnum.currency:
2273
+ case index$1.LCCategoryEnum.currency:
2707
2274
  default:
2708
2275
  console.log("\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525}");
2709
2276
  console.log("getCategoryIcon - unhandled category:", category);
@@ -2727,10 +2294,13 @@ const categorizeSkills = (skills) => {
2727
2294
  acc[obj.category].push(obj);
2728
2295
  acc[obj.category].totalSkills++;
2729
2296
  }
2730
- let totalSubskillsCount = acc[obj.category].reduce((total, skill) => {
2731
- var _a2, _b;
2732
- return total + ((_b = (_a2 = skill == null ? void 0 : skill.subskills) == null ? void 0 : _a2.length) != null ? _b : 0);
2733
- }, 0);
2297
+ let totalSubskillsCount = acc[obj.category].reduce(
2298
+ (total, skill) => {
2299
+ var _a2, _b;
2300
+ return total + ((_b = (_a2 = skill == null ? void 0 : skill.subskills) == null ? void 0 : _a2.length) != null ? _b : 0);
2301
+ },
2302
+ 0
2303
+ );
2734
2304
  acc[obj.category].totalSubskillsCount = totalSubskillsCount;
2735
2305
  return acc;
2736
2306
  }, {});
@@ -2760,4 +2330,4 @@ exports.getImageFromProfile = getImageFromProfile;
2760
2330
  exports.getInfoFromCredential = getInfoFromCredential;
2761
2331
  exports.getNameFromProfile = getNameFromProfile;
2762
2332
  exports.getTotalCountOfSkills = getTotalCountOfSkills;
2763
- //# sourceMappingURL=credential.helpers-afb94f02.js.map
2333
+ //# sourceMappingURL=credential.helpers-04044bbd.js.map