@paperless/core 2.22.0-alpha.27 → 2.22.0-alpha.29

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 (213) hide show
  1. package/dist/build/index.esm.js +1 -1
  2. package/dist/{paperless/p-84c43a3d.entry.js → build/p-1c17ee9b.entry.js} +1 -1
  3. package/dist/build/p-25961586.entry.js +1 -0
  4. package/dist/{paperless/p-9f51b9dc.entry.js → build/p-260a97c9.entry.js} +1 -1
  5. package/dist/build/{p-44da0b12.entry.js → p-2a37b400.entry.js} +1 -1
  6. package/dist/build/{p-fff6fa7a.entry.js → p-31399606.entry.js} +1 -1
  7. package/dist/build/{p-fa519af0.js → p-5f422b65.js} +1 -1
  8. package/dist/build/p-60923e39.entry.js +1 -0
  9. package/dist/{paperless/p-d24f045f.entry.js → build/p-6aa93bf9.entry.js} +1 -1
  10. package/dist/build/{p-e51c1cd6.entry.js → p-70974f53.entry.js} +1 -1
  11. package/dist/build/p-75ba802e.entry.js +3 -0
  12. package/dist/build/{p-b781e8db.entry.js → p-8c1bf7ea.entry.js} +1 -1
  13. package/dist/{paperless/p-7d018d4d.entry.js → build/p-9e06356b.entry.js} +1 -1
  14. package/dist/build/p-B_lDCj8j.js +1 -0
  15. package/dist/build/p-CeBIrPPx.js +1 -0
  16. package/dist/build/{p-78b15121.entry.js → p-a6369294.entry.js} +1 -1
  17. package/dist/build/p-a9c0aab3.entry.js +1 -0
  18. package/dist/build/p-b85ee4b7.entry.js +1 -0
  19. package/dist/build/{p-76f83633.entry.js → p-ba7ccf80.entry.js} +1 -1
  20. package/dist/build/{p-524eb1cb.entry.js → p-c16870f5.entry.js} +1 -1
  21. package/dist/build/{p-17e598ac.entry.js → p-cf436a7d.entry.js} +1 -1
  22. package/dist/build/{p-0d6f3aa3.entry.js → p-cfbd02e6.entry.js} +1 -1
  23. package/dist/build/{p-cbeb58ba.entry.js → p-e907c9d3.entry.js} +1 -1
  24. package/dist/build/{p-d9b3ace4.entry.js → p-ee7858e4.entry.js} +1 -1
  25. package/dist/build/{p-23cc6b6b.entry.js → p-f1c6f25b.entry.js} +1 -1
  26. package/dist/{paperless/p-5abcc8d2.entry.js → build/p-f5be155f.entry.js} +1 -1
  27. package/dist/build/p-xs4N_Y-0.js +1 -0
  28. package/dist/build/paperless.esm.js +1 -1
  29. package/dist/cjs/{cn-BGmLaIp8.js → cn-Cd68UVBT.js} +30 -274
  30. package/dist/cjs/{floating-ui.dom-33QlkSyu.js → floating-ui.dom-DEq7yeQK.js} +91 -50
  31. package/dist/cjs/index.cjs.js +1 -1
  32. package/dist/cjs/locale-BIZDGOk_.js +75117 -0
  33. package/dist/cjs/p-accordion.cjs.entry.js +1 -1
  34. package/dist/cjs/p-attachment.cjs.entry.js +1 -1
  35. package/dist/cjs/p-badge_3.cjs.entry.js +1 -1
  36. package/dist/cjs/p-button_3.cjs.entry.js +6 -6
  37. package/dist/cjs/p-calendar.cjs.entry.js +75 -302
  38. package/dist/cjs/p-card-container.cjs.entry.js +1 -1
  39. package/dist/cjs/p-checkbox_3.cjs.entry.js +2 -2
  40. package/dist/cjs/p-content-slider.cjs.entry.js +1 -1
  41. package/dist/cjs/p-cropper.cjs.entry.js +88 -32
  42. package/dist/cjs/p-datepicker.cjs.entry.js +41 -2891
  43. package/dist/cjs/p-divider.cjs.entry.js +1 -1
  44. package/dist/cjs/p-dropdown-menu-item_2.cjs.entry.js +1 -1
  45. package/dist/cjs/p-empty-state_8.cjs.entry.js +12 -18
  46. package/dist/cjs/p-field_3.cjs.entry.js +1 -1
  47. package/dist/cjs/p-illustration.cjs.entry.js +1 -1
  48. package/dist/cjs/p-label.cjs.entry.js +1 -1
  49. package/dist/cjs/p-listing.cjs.entry.js +1 -1
  50. package/dist/cjs/p-navigation-item.cjs.entry.js +1 -1
  51. package/dist/cjs/p-pagination_3.cjs.entry.js +2 -2
  52. package/dist/cjs/p-select.cjs.entry.js +1 -1
  53. package/dist/cjs/p-table.cjs.entry.js +1 -1
  54. package/dist/cjs/p-tooltip.cjs.entry.js +1 -1
  55. package/dist/collection/components/atoms/loader/loader.component.js +1 -1
  56. package/dist/collection/components/molecules/button/button.component.js +8 -7
  57. package/dist/collection/components/molecules/calendar/calendar.component.js +1 -2
  58. package/dist/collection/components/molecules/datepicker/datepicker.component.js +2 -2
  59. package/dist/collection/components/molecules/pagination/pages/pagination-pages.component.js +1 -1
  60. package/dist/components/index.js +1 -1
  61. package/dist/components/{p-BtuWYjfq.js → p--JDhF4GL.js} +1 -1
  62. package/dist/components/{p-DW-MndqD.js → p-0y7dmBHx.js} +1 -1
  63. package/dist/components/{p-DxmwiGc9.js → p-B4tCVctO.js} +1 -1
  64. package/dist/components/{p-LfH4pSix.js → p-BA1QFuzs.js} +1 -1
  65. package/dist/components/{p-Bno5n2sV.js → p-BBmuctek.js} +1 -1
  66. package/dist/components/p-BE2DRulM.js +1 -0
  67. package/dist/components/{p-Dbt4VuQm.js → p-BPP8ZYwN.js} +1 -1
  68. package/dist/components/{p-BeiMfpUZ.js → p-BV-h5ALt.js} +1 -1
  69. package/dist/components/{p-C_dax2wr.js → p-BX8yg_1a.js} +1 -1
  70. package/dist/components/{p-CjI4hMLv.js → p-BaXKEl7X.js} +1 -1
  71. package/dist/components/{p-BfJQbKrn.js → p-CCvROjOe.js} +1 -1
  72. package/dist/components/p-CHydrUrt.js +1 -0
  73. package/dist/components/{p-Bi6PK1YV.js → p-CccN0jY7.js} +1 -1
  74. package/dist/components/p-CeBIrPPx.js +1 -0
  75. package/dist/components/{p-BMb-TnTI.js → p-Coxruux_.js} +1 -1
  76. package/dist/components/{p-B9n8mzrj.js → p-DAuzJ_qL.js} +1 -1
  77. package/dist/components/{p-BAIZ48ms.js → p-DZjr9R4d.js} +1 -1
  78. package/dist/components/{p-BBNOzE00.js → p-Djf2rBRX.js} +1 -1
  79. package/dist/components/p-Dl4hxOHI.js +1 -0
  80. package/dist/components/{p-BIQLsxW1.js → p-DuYGcgJi.js} +1 -1
  81. package/dist/components/{p-CFu8cH3m.js → p-DxNTB_Qq.js} +1 -1
  82. package/dist/components/{p-CgOKCXab.js → p-JhZXmipA.js} +1 -1
  83. package/dist/components/{p-ChfXIxTQ.js → p-KuL1SNit.js} +1 -1
  84. package/dist/components/p-accordion.js +1 -1
  85. package/dist/components/p-attachment.js +1 -1
  86. package/dist/components/p-button.js +1 -1
  87. package/dist/components/p-calendar.js +1 -1
  88. package/dist/components/p-card-container.js +1 -1
  89. package/dist/components/p-card-header.js +1 -1
  90. package/dist/components/p-content-slider.js +1 -1
  91. package/dist/components/p-cropper.js +2 -2
  92. package/dist/components/p-datepicker.js +1 -1
  93. package/dist/components/p-divider.js +1 -1
  94. package/dist/components/p-drawer-header.js +1 -1
  95. package/dist/components/p-drawer.js +1 -1
  96. package/dist/components/p-dropdown-menu-item.js +1 -1
  97. package/dist/components/p-dropdown.js +1 -1
  98. package/dist/components/p-empty-state.js +1 -1
  99. package/dist/components/p-field-container.js +1 -1
  100. package/dist/components/p-field.js +1 -1
  101. package/dist/components/p-floating-menu-container.js +1 -1
  102. package/dist/components/p-helper.js +1 -1
  103. package/dist/components/p-illustration.js +1 -1
  104. package/dist/components/p-label.js +1 -1
  105. package/dist/components/p-listing.js +1 -1
  106. package/dist/components/p-modal-footer.js +1 -1
  107. package/dist/components/p-modal-header.js +1 -1
  108. package/dist/components/p-modal.js +1 -1
  109. package/dist/components/p-navbar.js +1 -1
  110. package/dist/components/p-navigation-item.js +1 -1
  111. package/dist/components/p-pagination-pages.js +1 -1
  112. package/dist/components/p-pagination-size.js +1 -1
  113. package/dist/components/p-pagination.js +1 -1
  114. package/dist/components/{p-PFAC3Kay.js → p-prb4IQlb.js} +1 -1
  115. package/dist/components/p-profile.js +1 -1
  116. package/dist/components/p-segment-item.js +1 -1
  117. package/dist/components/p-select.js +1 -1
  118. package/dist/components/{p-CCOwunss.js → p-swqKzLDH.js} +1 -1
  119. package/dist/components/p-tab-container.js +1 -1
  120. package/dist/components/p-table-cell.js +1 -1
  121. package/dist/components/p-table-footer.js +1 -1
  122. package/dist/components/p-table-header.js +1 -1
  123. package/dist/components/p-table-row-actions-container.js +1 -1
  124. package/dist/components/p-table-row.js +1 -1
  125. package/dist/components/p-table.js +1 -1
  126. package/dist/components/p-tooltip.js +1 -1
  127. package/dist/components/p-xs4N_Y-0.js +1 -0
  128. package/dist/esm/{cn-BniKgfyU.js → cn-CsNqHcjL.js} +30 -274
  129. package/dist/esm/{floating-ui.dom-DGLCmOXW.js → floating-ui.dom-CeBIrPPx.js} +91 -50
  130. package/dist/esm/index.js +1 -1
  131. package/dist/esm/locale-B_lDCj8j.js +75114 -0
  132. package/dist/esm/p-accordion.entry.js +1 -1
  133. package/dist/esm/p-attachment.entry.js +1 -1
  134. package/dist/esm/p-badge_3.entry.js +1 -1
  135. package/dist/esm/p-button_3.entry.js +6 -6
  136. package/dist/esm/p-calendar.entry.js +63 -290
  137. package/dist/esm/p-card-container.entry.js +1 -1
  138. package/dist/esm/p-checkbox_3.entry.js +2 -2
  139. package/dist/esm/p-content-slider.entry.js +1 -1
  140. package/dist/esm/p-cropper.entry.js +88 -32
  141. package/dist/esm/p-datepicker.entry.js +37 -2887
  142. package/dist/esm/p-divider.entry.js +1 -1
  143. package/dist/esm/p-dropdown-menu-item_2.entry.js +1 -1
  144. package/dist/esm/p-empty-state_8.entry.js +12 -18
  145. package/dist/esm/p-field_3.entry.js +1 -1
  146. package/dist/esm/p-illustration.entry.js +1 -1
  147. package/dist/esm/p-label.entry.js +1 -1
  148. package/dist/esm/p-listing.entry.js +1 -1
  149. package/dist/esm/p-navigation-item.entry.js +1 -1
  150. package/dist/esm/p-pagination_3.entry.js +2 -2
  151. package/dist/esm/p-select.entry.js +1 -1
  152. package/dist/esm/p-table.entry.js +1 -1
  153. package/dist/esm/p-tooltip.entry.js +1 -1
  154. package/dist/index.html +1 -1
  155. package/dist/paperless/index.esm.js +1 -1
  156. package/dist/{build/p-84c43a3d.entry.js → paperless/p-1c17ee9b.entry.js} +1 -1
  157. package/dist/paperless/p-25961586.entry.js +1 -0
  158. package/dist/{build/p-9f51b9dc.entry.js → paperless/p-260a97c9.entry.js} +1 -1
  159. package/dist/paperless/{p-44da0b12.entry.js → p-2a37b400.entry.js} +1 -1
  160. package/dist/paperless/{p-fff6fa7a.entry.js → p-31399606.entry.js} +1 -1
  161. package/dist/paperless/p-60923e39.entry.js +1 -0
  162. package/dist/{build/p-d24f045f.entry.js → paperless/p-6aa93bf9.entry.js} +1 -1
  163. package/dist/paperless/{p-e51c1cd6.entry.js → p-70974f53.entry.js} +1 -1
  164. package/dist/paperless/p-75ba802e.entry.js +3 -0
  165. package/dist/paperless/{p-b781e8db.entry.js → p-8c1bf7ea.entry.js} +1 -1
  166. package/dist/{build/p-7d018d4d.entry.js → paperless/p-9e06356b.entry.js} +1 -1
  167. package/dist/paperless/p-B_lDCj8j.js +1 -0
  168. package/dist/paperless/p-CeBIrPPx.js +1 -0
  169. package/dist/paperless/{p-78b15121.entry.js → p-a6369294.entry.js} +1 -1
  170. package/dist/paperless/p-a9c0aab3.entry.js +1 -0
  171. package/dist/paperless/p-b85ee4b7.entry.js +1 -0
  172. package/dist/paperless/{p-76f83633.entry.js → p-ba7ccf80.entry.js} +1 -1
  173. package/dist/paperless/{p-524eb1cb.entry.js → p-c16870f5.entry.js} +1 -1
  174. package/dist/paperless/{p-17e598ac.entry.js → p-cf436a7d.entry.js} +1 -1
  175. package/dist/paperless/{p-0d6f3aa3.entry.js → p-cfbd02e6.entry.js} +1 -1
  176. package/dist/paperless/{p-cbeb58ba.entry.js → p-e907c9d3.entry.js} +1 -1
  177. package/dist/paperless/{p-d9b3ace4.entry.js → p-ee7858e4.entry.js} +1 -1
  178. package/dist/paperless/{p-23cc6b6b.entry.js → p-f1c6f25b.entry.js} +1 -1
  179. package/dist/{build/p-5abcc8d2.entry.js → paperless/p-f5be155f.entry.js} +1 -1
  180. package/dist/paperless/p-xs4N_Y-0.js +1 -0
  181. package/dist/paperless/paperless.esm.js +1 -1
  182. package/dist/sw.js +1 -1
  183. package/dist/sw.js.map +1 -1
  184. package/dist/types/components/molecules/button/button.component.d.ts +1 -1
  185. package/dist/types/components.d.ts +3 -1
  186. package/dist/workbox-d13932f0.js +1 -1
  187. package/dist/workbox-d13932f0.js.map +1 -1
  188. package/hydrate/index.js +75313 -6268
  189. package/hydrate/index.mjs +75313 -6268
  190. package/package.json +10 -11
  191. package/dist/build/p-1f7ab568.entry.js +0 -1
  192. package/dist/build/p-20077155.entry.js +0 -1
  193. package/dist/build/p-3452b2f5.entry.js +0 -3
  194. package/dist/build/p-CT54OXR2.js +0 -1
  195. package/dist/build/p-DGLCmOXW.js +0 -1
  196. package/dist/build/p-KEbntKvf.js +0 -1
  197. package/dist/build/p-b090e928.entry.js +0 -1
  198. package/dist/build/p-bafe9297.entry.js +0 -1
  199. package/dist/cjs/index-DG6V15XP.js +0 -2871
  200. package/dist/components/p-CPpl-J0y.js +0 -1
  201. package/dist/components/p-CT54OXR2.js +0 -1
  202. package/dist/components/p-D4bALv5t.js +0 -1
  203. package/dist/components/p-DGLCmOXW.js +0 -1
  204. package/dist/components/p-DeSgaQxj.js +0 -1
  205. package/dist/esm/index-KEbntKvf.js +0 -2839
  206. package/dist/paperless/p-1f7ab568.entry.js +0 -1
  207. package/dist/paperless/p-20077155.entry.js +0 -1
  208. package/dist/paperless/p-3452b2f5.entry.js +0 -3
  209. package/dist/paperless/p-CT54OXR2.js +0 -1
  210. package/dist/paperless/p-DGLCmOXW.js +0 -1
  211. package/dist/paperless/p-KEbntKvf.js +0 -1
  212. package/dist/paperless/p-b090e928.entry.js +0 -1
  213. package/dist/paperless/p-bafe9297.entry.js +0 -1
@@ -1,2871 +0,0 @@
1
- 'use strict';
2
-
3
- function _typeof(o) {
4
- "@babel/helpers - typeof";
5
-
6
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
7
- return typeof o;
8
- } : function (o) {
9
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
10
- }, _typeof(o);
11
- }
12
-
13
- function toInteger(dirtyNumber) {
14
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
15
- return NaN;
16
- }
17
- var number = Number(dirtyNumber);
18
- if (isNaN(number)) {
19
- return number;
20
- }
21
- return number < 0 ? Math.ceil(number) : Math.floor(number);
22
- }
23
-
24
- function requiredArgs(required, args) {
25
- if (args.length < required) {
26
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
27
- }
28
- }
29
-
30
- /**
31
- * @name toDate
32
- * @category Common Helpers
33
- * @summary Convert the given argument to an instance of Date.
34
- *
35
- * @description
36
- * Convert the given argument to an instance of Date.
37
- *
38
- * If the argument is an instance of Date, the function returns its clone.
39
- *
40
- * If the argument is a number, it is treated as a timestamp.
41
- *
42
- * If the argument is none of the above, the function returns Invalid Date.
43
- *
44
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
45
- *
46
- * @param {Date|Number} argument - the value to convert
47
- * @returns {Date} the parsed date in the local time zone
48
- * @throws {TypeError} 1 argument required
49
- *
50
- * @example
51
- * // Clone the date:
52
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
53
- * //=> Tue Feb 11 2014 11:30:30
54
- *
55
- * @example
56
- * // Convert the timestamp to date:
57
- * const result = toDate(1392098430000)
58
- * //=> Tue Feb 11 2014 11:30:30
59
- */
60
- function toDate(argument) {
61
- requiredArgs(1, arguments);
62
- var argStr = Object.prototype.toString.call(argument);
63
-
64
- // Clone the date
65
- if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
66
- // Prevent the date to lose the milliseconds when passed to new Date() in IE10
67
- return new Date(argument.getTime());
68
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
69
- return new Date(argument);
70
- } else {
71
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
72
- // eslint-disable-next-line no-console
73
- 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://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
74
- // eslint-disable-next-line no-console
75
- console.warn(new Error().stack);
76
- }
77
- return new Date(NaN);
78
- }
79
- }
80
-
81
- /**
82
- * @name addMonths
83
- * @category Month Helpers
84
- * @summary Add the specified number of months to the given date.
85
- *
86
- * @description
87
- * Add the specified number of months to the given date.
88
- *
89
- * @param {Date|Number} date - the date to be changed
90
- * @param {Number} amount - the amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
91
- * @returns {Date} the new date with the months added
92
- * @throws {TypeError} 2 arguments required
93
- *
94
- * @example
95
- * // Add 5 months to 1 September 2014:
96
- * const result = addMonths(new Date(2014, 8, 1), 5)
97
- * //=> Sun Feb 01 2015 00:00:00
98
- */
99
- function addMonths(dirtyDate, dirtyAmount) {
100
- requiredArgs(2, arguments);
101
- var date = toDate(dirtyDate);
102
- var amount = toInteger(dirtyAmount);
103
- if (isNaN(amount)) {
104
- return new Date(NaN);
105
- }
106
- if (!amount) {
107
- // If 0 months, no-op to avoid changing times in the hour before end of DST
108
- return date;
109
- }
110
- var dayOfMonth = date.getDate();
111
-
112
- // The JS Date object supports date math by accepting out-of-bounds values for
113
- // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
114
- // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
115
- // want except that dates will wrap around the end of a month, meaning that
116
- // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
117
- // we'll default to the end of the desired month by adding 1 to the desired
118
- // month and using a date of 0 to back up one day to the end of the desired
119
- // month.
120
- var endOfDesiredMonth = new Date(date.getTime());
121
- endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);
122
- var daysInMonth = endOfDesiredMonth.getDate();
123
- if (dayOfMonth >= daysInMonth) {
124
- // If we're already at the end of the month, then this is the correct date
125
- // and we're done.
126
- return endOfDesiredMonth;
127
- } else {
128
- // Otherwise, we now know that setting the original day-of-month value won't
129
- // cause an overflow, so set the desired day-of-month. Note that we can't
130
- // just set the date of `endOfDesiredMonth` because that object may have had
131
- // its time changed in the unusual case where where a DST transition was on
132
- // the last day of the month and its local time was in the hour skipped or
133
- // repeated next to a DST transition. So we use `date` instead which is
134
- // guaranteed to still have the original time.
135
- date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
136
- return date;
137
- }
138
- }
139
-
140
- /**
141
- * @name isWeekend
142
- * @category Weekday Helpers
143
- * @summary Does the given date fall on a weekend?
144
- *
145
- * @description
146
- * Does the given date fall on a weekend?
147
- *
148
- * @param {Date|Number} date - the date to check
149
- * @returns {Boolean} the date falls on a weekend
150
- * @throws {TypeError} 1 argument required
151
- *
152
- * @example
153
- * // Does 5 October 2014 fall on a weekend?
154
- * const result = isWeekend(new Date(2014, 9, 5))
155
- * //=> true
156
- */
157
- function isWeekend(dirtyDate) {
158
- requiredArgs(1, arguments);
159
- var date = toDate(dirtyDate);
160
- var day = date.getDay();
161
- return day === 0 || day === 6;
162
- }
163
-
164
- /**
165
- * @name addMilliseconds
166
- * @category Millisecond Helpers
167
- * @summary Add the specified number of milliseconds to the given date.
168
- *
169
- * @description
170
- * Add the specified number of milliseconds to the given date.
171
- *
172
- * @param {Date|Number} date - the date to be changed
173
- * @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`.
174
- * @returns {Date} the new date with the milliseconds added
175
- * @throws {TypeError} 2 arguments required
176
- *
177
- * @example
178
- * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
179
- * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
180
- * //=> Thu Jul 10 2014 12:45:30.750
181
- */
182
- function addMilliseconds(dirtyDate, dirtyAmount) {
183
- requiredArgs(2, arguments);
184
- var timestamp = toDate(dirtyDate).getTime();
185
- var amount = toInteger(dirtyAmount);
186
- return new Date(timestamp + amount);
187
- }
188
-
189
- var defaultOptions = {};
190
- function getDefaultOptions() {
191
- return defaultOptions;
192
- }
193
-
194
- /**
195
- * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
196
- * They usually appear for dates that denote time before the timezones were introduced
197
- * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
198
- * and GMT+01:00:00 after that date)
199
- *
200
- * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
201
- * which would lead to incorrect calculations.
202
- *
203
- * This function returns the timezone offset in milliseconds that takes seconds in account.
204
- */
205
- function getTimezoneOffsetInMilliseconds(date) {
206
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
207
- utcDate.setUTCFullYear(date.getFullYear());
208
- return date.getTime() - utcDate.getTime();
209
- }
210
-
211
- /**
212
- * @name startOfDay
213
- * @category Day Helpers
214
- * @summary Return the start of a day for the given date.
215
- *
216
- * @description
217
- * Return the start of a day for the given date.
218
- * The result will be in the local timezone.
219
- *
220
- * @param {Date|Number} date - the original date
221
- * @returns {Date} the start of a day
222
- * @throws {TypeError} 1 argument required
223
- *
224
- * @example
225
- * // The start of a day for 2 September 2014 11:55:00:
226
- * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
227
- * //=> Tue Sep 02 2014 00:00:00
228
- */
229
- function startOfDay(dirtyDate) {
230
- requiredArgs(1, arguments);
231
- var date = toDate(dirtyDate);
232
- date.setHours(0, 0, 0, 0);
233
- return date;
234
- }
235
-
236
- /**
237
- * @name addYears
238
- * @category Year Helpers
239
- * @summary Add the specified number of years to the given date.
240
- *
241
- * @description
242
- * Add the specified number of years to the given date.
243
- *
244
- * @param {Date|Number} date - the date to be changed
245
- * @param {Number} amount - the amount of years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
246
- * @returns {Date} the new date with the years added
247
- * @throws {TypeError} 2 arguments required
248
- *
249
- * @example
250
- * // Add 5 years to 1 September 2014:
251
- * const result = addYears(new Date(2014, 8, 1), 5)
252
- * //=> Sun Sep 01 2019 00:00:00
253
- */
254
- function addYears(dirtyDate, dirtyAmount) {
255
- requiredArgs(2, arguments);
256
- var amount = toInteger(dirtyAmount);
257
- return addMonths(dirtyDate, amount * 12);
258
- }
259
-
260
- /**
261
- * @name isSameDay
262
- * @category Day Helpers
263
- * @summary Are the given dates in the same day (and year and month)?
264
- *
265
- * @description
266
- * Are the given dates in the same day (and year and month)?
267
- *
268
- * @param {Date|Number} dateLeft - the first date to check
269
- * @param {Date|Number} dateRight - the second date to check
270
- * @returns {Boolean} the dates are in the same day (and year and month)
271
- * @throws {TypeError} 2 arguments required
272
- *
273
- * @example
274
- * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
275
- * const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
276
- * //=> true
277
- *
278
- * @example
279
- * // Are 4 September and 4 October in the same day?
280
- * const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
281
- * //=> false
282
- *
283
- * @example
284
- * // Are 4 September, 2014 and 4 September, 2015 in the same day?
285
- * const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
286
- * //=> false
287
- */
288
- function isSameDay(dirtyDateLeft, dirtyDateRight) {
289
- requiredArgs(2, arguments);
290
- var dateLeftStartOfDay = startOfDay(dirtyDateLeft);
291
- var dateRightStartOfDay = startOfDay(dirtyDateRight);
292
- return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime();
293
- }
294
-
295
- /**
296
- * @name isDate
297
- * @category Common Helpers
298
- * @summary Is the given value a date?
299
- *
300
- * @description
301
- * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
302
- *
303
- * @param {*} value - the value to check
304
- * @returns {boolean} true if the given value is a date
305
- * @throws {TypeError} 1 arguments required
306
- *
307
- * @example
308
- * // For a valid date:
309
- * const result = isDate(new Date())
310
- * //=> true
311
- *
312
- * @example
313
- * // For an invalid date:
314
- * const result = isDate(new Date(NaN))
315
- * //=> true
316
- *
317
- * @example
318
- * // For some value:
319
- * const result = isDate('2014-02-31')
320
- * //=> false
321
- *
322
- * @example
323
- * // For an object:
324
- * const result = isDate({})
325
- * //=> false
326
- */
327
- function isDate(value) {
328
- requiredArgs(1, arguments);
329
- return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
330
- }
331
-
332
- /**
333
- * @name isValid
334
- * @category Common Helpers
335
- * @summary Is the given date valid?
336
- *
337
- * @description
338
- * Returns false if argument is Invalid Date and true otherwise.
339
- * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
340
- * Invalid Date is a Date, whose time value is NaN.
341
- *
342
- * Time value of Date: http://es5.github.io/#x15.9.1.1
343
- *
344
- * @param {*} date - the date to check
345
- * @returns {Boolean} the date is valid
346
- * @throws {TypeError} 1 argument required
347
- *
348
- * @example
349
- * // For the valid date:
350
- * const result = isValid(new Date(2014, 1, 31))
351
- * //=> true
352
- *
353
- * @example
354
- * // For the value, convertable into a date:
355
- * const result = isValid(1393804800000)
356
- * //=> true
357
- *
358
- * @example
359
- * // For the invalid date:
360
- * const result = isValid(new Date(''))
361
- * //=> false
362
- */
363
- function isValid(dirtyDate) {
364
- requiredArgs(1, arguments);
365
- if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
366
- return false;
367
- }
368
- var date = toDate(dirtyDate);
369
- return !isNaN(Number(date));
370
- }
371
-
372
- /**
373
- * @name startOfMonth
374
- * @category Month Helpers
375
- * @summary Return the start of a month for the given date.
376
- *
377
- * @description
378
- * Return the start of a month for the given date.
379
- * The result will be in the local timezone.
380
- *
381
- * @param {Date|Number} date - the original date
382
- * @returns {Date} the start of a month
383
- * @throws {TypeError} 1 argument required
384
- *
385
- * @example
386
- * // The start of a month for 2 September 2014 11:55:00:
387
- * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
388
- * //=> Mon Sep 01 2014 00:00:00
389
- */
390
- function startOfMonth(dirtyDate) {
391
- requiredArgs(1, arguments);
392
- var date = toDate(dirtyDate);
393
- date.setDate(1);
394
- date.setHours(0, 0, 0, 0);
395
- return date;
396
- }
397
-
398
- /**
399
- * @name subMilliseconds
400
- * @category Millisecond Helpers
401
- * @summary Subtract the specified number of milliseconds from the given date.
402
- *
403
- * @description
404
- * Subtract the specified number of milliseconds from the given date.
405
- *
406
- * @param {Date|Number} date - the date to be changed
407
- * @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`.
408
- * @returns {Date} the new date with the milliseconds subtracted
409
- * @throws {TypeError} 2 arguments required
410
- *
411
- * @example
412
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
413
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
414
- * //=> Thu Jul 10 2014 12:45:29.250
415
- */
416
- function subMilliseconds(dirtyDate, dirtyAmount) {
417
- requiredArgs(2, arguments);
418
- var amount = toInteger(dirtyAmount);
419
- return addMilliseconds(dirtyDate, -amount);
420
- }
421
-
422
- var MILLISECONDS_IN_DAY = 86400000;
423
- function getUTCDayOfYear(dirtyDate) {
424
- requiredArgs(1, arguments);
425
- var date = toDate(dirtyDate);
426
- var timestamp = date.getTime();
427
- date.setUTCMonth(0, 1);
428
- date.setUTCHours(0, 0, 0, 0);
429
- var startOfYearTimestamp = date.getTime();
430
- var difference = timestamp - startOfYearTimestamp;
431
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
432
- }
433
-
434
- function startOfUTCISOWeek(dirtyDate) {
435
- requiredArgs(1, arguments);
436
- var weekStartsOn = 1;
437
- var date = toDate(dirtyDate);
438
- var day = date.getUTCDay();
439
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
440
- date.setUTCDate(date.getUTCDate() - diff);
441
- date.setUTCHours(0, 0, 0, 0);
442
- return date;
443
- }
444
-
445
- function getUTCISOWeekYear(dirtyDate) {
446
- requiredArgs(1, arguments);
447
- var date = toDate(dirtyDate);
448
- var year = date.getUTCFullYear();
449
- var fourthOfJanuaryOfNextYear = new Date(0);
450
- fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
451
- fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
452
- var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
453
- var fourthOfJanuaryOfThisYear = new Date(0);
454
- fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
455
- fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
456
- var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
457
- if (date.getTime() >= startOfNextYear.getTime()) {
458
- return year + 1;
459
- } else if (date.getTime() >= startOfThisYear.getTime()) {
460
- return year;
461
- } else {
462
- return year - 1;
463
- }
464
- }
465
-
466
- function startOfUTCISOWeekYear(dirtyDate) {
467
- requiredArgs(1, arguments);
468
- var year = getUTCISOWeekYear(dirtyDate);
469
- var fourthOfJanuary = new Date(0);
470
- fourthOfJanuary.setUTCFullYear(year, 0, 4);
471
- fourthOfJanuary.setUTCHours(0, 0, 0, 0);
472
- var date = startOfUTCISOWeek(fourthOfJanuary);
473
- return date;
474
- }
475
-
476
- var MILLISECONDS_IN_WEEK$1 = 604800000;
477
- function getUTCISOWeek(dirtyDate) {
478
- requiredArgs(1, arguments);
479
- var date = toDate(dirtyDate);
480
- var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
481
-
482
- // Round the number of days to the nearest integer
483
- // because the number of milliseconds in a week is not constant
484
- // (e.g. it's different in the week of the daylight saving time clock shift)
485
- return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
486
- }
487
-
488
- function startOfUTCWeek(dirtyDate, options) {
489
- var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
490
- requiredArgs(1, arguments);
491
- var defaultOptions = getDefaultOptions();
492
- var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_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$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_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.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
493
-
494
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
495
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
496
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
497
- }
498
- var date = toDate(dirtyDate);
499
- var day = date.getUTCDay();
500
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
501
- date.setUTCDate(date.getUTCDate() - diff);
502
- date.setUTCHours(0, 0, 0, 0);
503
- return date;
504
- }
505
-
506
- function getUTCWeekYear(dirtyDate, options) {
507
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
508
- requiredArgs(1, arguments);
509
- var date = toDate(dirtyDate);
510
- var year = date.getUTCFullYear();
511
- var defaultOptions = getDefaultOptions();
512
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_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$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_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 && _ref !== void 0 ? _ref : 1);
513
-
514
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
515
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
516
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
517
- }
518
- var firstWeekOfNextYear = new Date(0);
519
- firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
520
- firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
521
- var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
522
- var firstWeekOfThisYear = new Date(0);
523
- firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
524
- firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
525
- var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
526
- if (date.getTime() >= startOfNextYear.getTime()) {
527
- return year + 1;
528
- } else if (date.getTime() >= startOfThisYear.getTime()) {
529
- return year;
530
- } else {
531
- return year - 1;
532
- }
533
- }
534
-
535
- function startOfUTCWeekYear(dirtyDate, options) {
536
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
537
- requiredArgs(1, arguments);
538
- var defaultOptions = getDefaultOptions();
539
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_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$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_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 && _ref !== void 0 ? _ref : 1);
540
- var year = getUTCWeekYear(dirtyDate, options);
541
- var firstWeek = new Date(0);
542
- firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
543
- firstWeek.setUTCHours(0, 0, 0, 0);
544
- var date = startOfUTCWeek(firstWeek, options);
545
- return date;
546
- }
547
-
548
- var MILLISECONDS_IN_WEEK = 604800000;
549
- function getUTCWeek(dirtyDate, options) {
550
- requiredArgs(1, arguments);
551
- var date = toDate(dirtyDate);
552
- var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
553
-
554
- // Round the number of days to the nearest integer
555
- // because the number of milliseconds in a week is not constant
556
- // (e.g. it's different in the week of the daylight saving time clock shift)
557
- return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
558
- }
559
-
560
- function addLeadingZeros(number, targetLength) {
561
- var sign = number < 0 ? '-' : '';
562
- var output = Math.abs(number).toString();
563
- while (output.length < targetLength) {
564
- output = '0' + output;
565
- }
566
- return sign + output;
567
- }
568
-
569
- /*
570
- * | | Unit | | Unit |
571
- * |-----|--------------------------------|-----|--------------------------------|
572
- * | a | AM, PM | A* | |
573
- * | d | Day of month | D | |
574
- * | h | Hour [1-12] | H | Hour [0-23] |
575
- * | m | Minute | M | Month |
576
- * | s | Second | S | Fraction of second |
577
- * | y | Year (abs) | Y | |
578
- *
579
- * Letters marked by * are not implemented but reserved by Unicode standard.
580
- */
581
- var formatters$1 = {
582
- // Year
583
- y: function y(date, token) {
584
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
585
- // | Year | y | yy | yyy | yyyy | yyyyy |
586
- // |----------|-------|----|-------|-------|-------|
587
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
588
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
589
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
590
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
591
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
592
-
593
- var signedYear = date.getUTCFullYear();
594
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
595
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
596
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
597
- },
598
- // Month
599
- M: function M(date, token) {
600
- var month = date.getUTCMonth();
601
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
602
- },
603
- // Day of the month
604
- d: function d(date, token) {
605
- return addLeadingZeros(date.getUTCDate(), token.length);
606
- },
607
- // AM or PM
608
- a: function a(date, token) {
609
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
610
- switch (token) {
611
- case 'a':
612
- case 'aa':
613
- return dayPeriodEnumValue.toUpperCase();
614
- case 'aaa':
615
- return dayPeriodEnumValue;
616
- case 'aaaaa':
617
- return dayPeriodEnumValue[0];
618
- case 'aaaa':
619
- default:
620
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
621
- }
622
- },
623
- // Hour [1-12]
624
- h: function h(date, token) {
625
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
626
- },
627
- // Hour [0-23]
628
- H: function H(date, token) {
629
- return addLeadingZeros(date.getUTCHours(), token.length);
630
- },
631
- // Minute
632
- m: function m(date, token) {
633
- return addLeadingZeros(date.getUTCMinutes(), token.length);
634
- },
635
- // Second
636
- s: function s(date, token) {
637
- return addLeadingZeros(date.getUTCSeconds(), token.length);
638
- },
639
- // Fraction of second
640
- S: function S(date, token) {
641
- var numberOfDigits = token.length;
642
- var milliseconds = date.getUTCMilliseconds();
643
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
644
- return addLeadingZeros(fractionalSeconds, token.length);
645
- }
646
- };
647
-
648
- var dayPeriodEnum = {
649
- midnight: 'midnight',
650
- noon: 'noon',
651
- morning: 'morning',
652
- afternoon: 'afternoon',
653
- evening: 'evening',
654
- night: 'night'
655
- };
656
- /*
657
- * | | Unit | | Unit |
658
- * |-----|--------------------------------|-----|--------------------------------|
659
- * | a | AM, PM | A* | Milliseconds in day |
660
- * | b | AM, PM, noon, midnight | B | Flexible day period |
661
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
662
- * | d | Day of month | D | Day of year |
663
- * | e | Local day of week | E | Day of week |
664
- * | f | | F* | Day of week in month |
665
- * | g* | Modified Julian day | G | Era |
666
- * | h | Hour [1-12] | H | Hour [0-23] |
667
- * | i! | ISO day of week | I! | ISO week of year |
668
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
669
- * | k | Hour [1-24] | K | Hour [0-11] |
670
- * | l* | (deprecated) | L | Stand-alone month |
671
- * | m | Minute | M | Month |
672
- * | n | | N | |
673
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
674
- * | p! | Long localized time | P! | Long localized date |
675
- * | q | Stand-alone quarter | Q | Quarter |
676
- * | r* | Related Gregorian year | R! | ISO week-numbering year |
677
- * | s | Second | S | Fraction of second |
678
- * | t! | Seconds timestamp | T! | Milliseconds timestamp |
679
- * | u | Extended year | U* | Cyclic year |
680
- * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
681
- * | w | Local week of year | W* | Week of month |
682
- * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
683
- * | y | Year (abs) | Y | Local week-numbering year |
684
- * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
685
- *
686
- * Letters marked by * are not implemented but reserved by Unicode standard.
687
- *
688
- * Letters marked by ! are non-standard, but implemented by date-fns:
689
- * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
690
- * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
691
- * i.e. 7 for Sunday, 1 for Monday, etc.
692
- * - `I` is ISO week of year, as opposed to `w` which is local week of year.
693
- * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
694
- * `R` is supposed to be used in conjunction with `I` and `i`
695
- * for universal ISO week-numbering date, whereas
696
- * `Y` is supposed to be used in conjunction with `w` and `e`
697
- * for week-numbering date specific to the locale.
698
- * - `P` is long localized date format
699
- * - `p` is long localized time format
700
- */
701
-
702
- var formatters = {
703
- // Era
704
- G: function G(date, token, localize) {
705
- var era = date.getUTCFullYear() > 0 ? 1 : 0;
706
- switch (token) {
707
- // AD, BC
708
- case 'G':
709
- case 'GG':
710
- case 'GGG':
711
- return localize.era(era, {
712
- width: 'abbreviated'
713
- });
714
- // A, B
715
- case 'GGGGG':
716
- return localize.era(era, {
717
- width: 'narrow'
718
- });
719
- // Anno Domini, Before Christ
720
- case 'GGGG':
721
- default:
722
- return localize.era(era, {
723
- width: 'wide'
724
- });
725
- }
726
- },
727
- // Year
728
- y: function y(date, token, localize) {
729
- // Ordinal number
730
- if (token === 'yo') {
731
- var signedYear = date.getUTCFullYear();
732
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
733
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
734
- return localize.ordinalNumber(year, {
735
- unit: 'year'
736
- });
737
- }
738
- return formatters$1.y(date, token);
739
- },
740
- // Local week-numbering year
741
- Y: function Y(date, token, localize, options) {
742
- var signedWeekYear = getUTCWeekYear(date, options);
743
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
744
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
745
-
746
- // Two digit year
747
- if (token === 'YY') {
748
- var twoDigitYear = weekYear % 100;
749
- return addLeadingZeros(twoDigitYear, 2);
750
- }
751
-
752
- // Ordinal number
753
- if (token === 'Yo') {
754
- return localize.ordinalNumber(weekYear, {
755
- unit: 'year'
756
- });
757
- }
758
-
759
- // Padding
760
- return addLeadingZeros(weekYear, token.length);
761
- },
762
- // ISO week-numbering year
763
- R: function R(date, token) {
764
- var isoWeekYear = getUTCISOWeekYear(date);
765
-
766
- // Padding
767
- return addLeadingZeros(isoWeekYear, token.length);
768
- },
769
- // Extended year. This is a single number designating the year of this calendar system.
770
- // The main difference between `y` and `u` localizers are B.C. years:
771
- // | Year | `y` | `u` |
772
- // |------|-----|-----|
773
- // | AC 1 | 1 | 1 |
774
- // | BC 1 | 1 | 0 |
775
- // | BC 2 | 2 | -1 |
776
- // Also `yy` always returns the last two digits of a year,
777
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
778
- u: function u(date, token) {
779
- var year = date.getUTCFullYear();
780
- return addLeadingZeros(year, token.length);
781
- },
782
- // Quarter
783
- Q: function Q(date, token, localize) {
784
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
785
- switch (token) {
786
- // 1, 2, 3, 4
787
- case 'Q':
788
- return String(quarter);
789
- // 01, 02, 03, 04
790
- case 'QQ':
791
- return addLeadingZeros(quarter, 2);
792
- // 1st, 2nd, 3rd, 4th
793
- case 'Qo':
794
- return localize.ordinalNumber(quarter, {
795
- unit: 'quarter'
796
- });
797
- // Q1, Q2, Q3, Q4
798
- case 'QQQ':
799
- return localize.quarter(quarter, {
800
- width: 'abbreviated',
801
- context: 'formatting'
802
- });
803
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
804
- case 'QQQQQ':
805
- return localize.quarter(quarter, {
806
- width: 'narrow',
807
- context: 'formatting'
808
- });
809
- // 1st quarter, 2nd quarter, ...
810
- case 'QQQQ':
811
- default:
812
- return localize.quarter(quarter, {
813
- width: 'wide',
814
- context: 'formatting'
815
- });
816
- }
817
- },
818
- // Stand-alone quarter
819
- q: function q(date, token, localize) {
820
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
821
- switch (token) {
822
- // 1, 2, 3, 4
823
- case 'q':
824
- return String(quarter);
825
- // 01, 02, 03, 04
826
- case 'qq':
827
- return addLeadingZeros(quarter, 2);
828
- // 1st, 2nd, 3rd, 4th
829
- case 'qo':
830
- return localize.ordinalNumber(quarter, {
831
- unit: 'quarter'
832
- });
833
- // Q1, Q2, Q3, Q4
834
- case 'qqq':
835
- return localize.quarter(quarter, {
836
- width: 'abbreviated',
837
- context: 'standalone'
838
- });
839
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
840
- case 'qqqqq':
841
- return localize.quarter(quarter, {
842
- width: 'narrow',
843
- context: 'standalone'
844
- });
845
- // 1st quarter, 2nd quarter, ...
846
- case 'qqqq':
847
- default:
848
- return localize.quarter(quarter, {
849
- width: 'wide',
850
- context: 'standalone'
851
- });
852
- }
853
- },
854
- // Month
855
- M: function M(date, token, localize) {
856
- var month = date.getUTCMonth();
857
- switch (token) {
858
- case 'M':
859
- case 'MM':
860
- return formatters$1.M(date, token);
861
- // 1st, 2nd, ..., 12th
862
- case 'Mo':
863
- return localize.ordinalNumber(month + 1, {
864
- unit: 'month'
865
- });
866
- // Jan, Feb, ..., Dec
867
- case 'MMM':
868
- return localize.month(month, {
869
- width: 'abbreviated',
870
- context: 'formatting'
871
- });
872
- // J, F, ..., D
873
- case 'MMMMM':
874
- return localize.month(month, {
875
- width: 'narrow',
876
- context: 'formatting'
877
- });
878
- // January, February, ..., December
879
- case 'MMMM':
880
- default:
881
- return localize.month(month, {
882
- width: 'wide',
883
- context: 'formatting'
884
- });
885
- }
886
- },
887
- // Stand-alone month
888
- L: function L(date, token, localize) {
889
- var month = date.getUTCMonth();
890
- switch (token) {
891
- // 1, 2, ..., 12
892
- case 'L':
893
- return String(month + 1);
894
- // 01, 02, ..., 12
895
- case 'LL':
896
- return addLeadingZeros(month + 1, 2);
897
- // 1st, 2nd, ..., 12th
898
- case 'Lo':
899
- return localize.ordinalNumber(month + 1, {
900
- unit: 'month'
901
- });
902
- // Jan, Feb, ..., Dec
903
- case 'LLL':
904
- return localize.month(month, {
905
- width: 'abbreviated',
906
- context: 'standalone'
907
- });
908
- // J, F, ..., D
909
- case 'LLLLL':
910
- return localize.month(month, {
911
- width: 'narrow',
912
- context: 'standalone'
913
- });
914
- // January, February, ..., December
915
- case 'LLLL':
916
- default:
917
- return localize.month(month, {
918
- width: 'wide',
919
- context: 'standalone'
920
- });
921
- }
922
- },
923
- // Local week of year
924
- w: function w(date, token, localize, options) {
925
- var week = getUTCWeek(date, options);
926
- if (token === 'wo') {
927
- return localize.ordinalNumber(week, {
928
- unit: 'week'
929
- });
930
- }
931
- return addLeadingZeros(week, token.length);
932
- },
933
- // ISO week of year
934
- I: function I(date, token, localize) {
935
- var isoWeek = getUTCISOWeek(date);
936
- if (token === 'Io') {
937
- return localize.ordinalNumber(isoWeek, {
938
- unit: 'week'
939
- });
940
- }
941
- return addLeadingZeros(isoWeek, token.length);
942
- },
943
- // Day of the month
944
- d: function d(date, token, localize) {
945
- if (token === 'do') {
946
- return localize.ordinalNumber(date.getUTCDate(), {
947
- unit: 'date'
948
- });
949
- }
950
- return formatters$1.d(date, token);
951
- },
952
- // Day of year
953
- D: function D(date, token, localize) {
954
- var dayOfYear = getUTCDayOfYear(date);
955
- if (token === 'Do') {
956
- return localize.ordinalNumber(dayOfYear, {
957
- unit: 'dayOfYear'
958
- });
959
- }
960
- return addLeadingZeros(dayOfYear, token.length);
961
- },
962
- // Day of week
963
- E: function E(date, token, localize) {
964
- var dayOfWeek = date.getUTCDay();
965
- switch (token) {
966
- // Tue
967
- case 'E':
968
- case 'EE':
969
- case 'EEE':
970
- return localize.day(dayOfWeek, {
971
- width: 'abbreviated',
972
- context: 'formatting'
973
- });
974
- // T
975
- case 'EEEEE':
976
- return localize.day(dayOfWeek, {
977
- width: 'narrow',
978
- context: 'formatting'
979
- });
980
- // Tu
981
- case 'EEEEEE':
982
- return localize.day(dayOfWeek, {
983
- width: 'short',
984
- context: 'formatting'
985
- });
986
- // Tuesday
987
- case 'EEEE':
988
- default:
989
- return localize.day(dayOfWeek, {
990
- width: 'wide',
991
- context: 'formatting'
992
- });
993
- }
994
- },
995
- // Local day of week
996
- e: function e(date, token, localize, options) {
997
- var dayOfWeek = date.getUTCDay();
998
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
999
- switch (token) {
1000
- // Numerical value (Nth day of week with current locale or weekStartsOn)
1001
- case 'e':
1002
- return String(localDayOfWeek);
1003
- // Padded numerical value
1004
- case 'ee':
1005
- return addLeadingZeros(localDayOfWeek, 2);
1006
- // 1st, 2nd, ..., 7th
1007
- case 'eo':
1008
- return localize.ordinalNumber(localDayOfWeek, {
1009
- unit: 'day'
1010
- });
1011
- case 'eee':
1012
- return localize.day(dayOfWeek, {
1013
- width: 'abbreviated',
1014
- context: 'formatting'
1015
- });
1016
- // T
1017
- case 'eeeee':
1018
- return localize.day(dayOfWeek, {
1019
- width: 'narrow',
1020
- context: 'formatting'
1021
- });
1022
- // Tu
1023
- case 'eeeeee':
1024
- return localize.day(dayOfWeek, {
1025
- width: 'short',
1026
- context: 'formatting'
1027
- });
1028
- // Tuesday
1029
- case 'eeee':
1030
- default:
1031
- return localize.day(dayOfWeek, {
1032
- width: 'wide',
1033
- context: 'formatting'
1034
- });
1035
- }
1036
- },
1037
- // Stand-alone local day of week
1038
- c: function c(date, token, localize, options) {
1039
- var dayOfWeek = date.getUTCDay();
1040
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1041
- switch (token) {
1042
- // Numerical value (same as in `e`)
1043
- case 'c':
1044
- return String(localDayOfWeek);
1045
- // Padded numerical value
1046
- case 'cc':
1047
- return addLeadingZeros(localDayOfWeek, token.length);
1048
- // 1st, 2nd, ..., 7th
1049
- case 'co':
1050
- return localize.ordinalNumber(localDayOfWeek, {
1051
- unit: 'day'
1052
- });
1053
- case 'ccc':
1054
- return localize.day(dayOfWeek, {
1055
- width: 'abbreviated',
1056
- context: 'standalone'
1057
- });
1058
- // T
1059
- case 'ccccc':
1060
- return localize.day(dayOfWeek, {
1061
- width: 'narrow',
1062
- context: 'standalone'
1063
- });
1064
- // Tu
1065
- case 'cccccc':
1066
- return localize.day(dayOfWeek, {
1067
- width: 'short',
1068
- context: 'standalone'
1069
- });
1070
- // Tuesday
1071
- case 'cccc':
1072
- default:
1073
- return localize.day(dayOfWeek, {
1074
- width: 'wide',
1075
- context: 'standalone'
1076
- });
1077
- }
1078
- },
1079
- // ISO day of week
1080
- i: function i(date, token, localize) {
1081
- var dayOfWeek = date.getUTCDay();
1082
- var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1083
- switch (token) {
1084
- // 2
1085
- case 'i':
1086
- return String(isoDayOfWeek);
1087
- // 02
1088
- case 'ii':
1089
- return addLeadingZeros(isoDayOfWeek, token.length);
1090
- // 2nd
1091
- case 'io':
1092
- return localize.ordinalNumber(isoDayOfWeek, {
1093
- unit: 'day'
1094
- });
1095
- // Tue
1096
- case 'iii':
1097
- return localize.day(dayOfWeek, {
1098
- width: 'abbreviated',
1099
- context: 'formatting'
1100
- });
1101
- // T
1102
- case 'iiiii':
1103
- return localize.day(dayOfWeek, {
1104
- width: 'narrow',
1105
- context: 'formatting'
1106
- });
1107
- // Tu
1108
- case 'iiiiii':
1109
- return localize.day(dayOfWeek, {
1110
- width: 'short',
1111
- context: 'formatting'
1112
- });
1113
- // Tuesday
1114
- case 'iiii':
1115
- default:
1116
- return localize.day(dayOfWeek, {
1117
- width: 'wide',
1118
- context: 'formatting'
1119
- });
1120
- }
1121
- },
1122
- // AM or PM
1123
- a: function a(date, token, localize) {
1124
- var hours = date.getUTCHours();
1125
- var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1126
- switch (token) {
1127
- case 'a':
1128
- case 'aa':
1129
- return localize.dayPeriod(dayPeriodEnumValue, {
1130
- width: 'abbreviated',
1131
- context: 'formatting'
1132
- });
1133
- case 'aaa':
1134
- return localize.dayPeriod(dayPeriodEnumValue, {
1135
- width: 'abbreviated',
1136
- context: 'formatting'
1137
- }).toLowerCase();
1138
- case 'aaaaa':
1139
- return localize.dayPeriod(dayPeriodEnumValue, {
1140
- width: 'narrow',
1141
- context: 'formatting'
1142
- });
1143
- case 'aaaa':
1144
- default:
1145
- return localize.dayPeriod(dayPeriodEnumValue, {
1146
- width: 'wide',
1147
- context: 'formatting'
1148
- });
1149
- }
1150
- },
1151
- // AM, PM, midnight, noon
1152
- b: function b(date, token, localize) {
1153
- var hours = date.getUTCHours();
1154
- var dayPeriodEnumValue;
1155
- if (hours === 12) {
1156
- dayPeriodEnumValue = dayPeriodEnum.noon;
1157
- } else if (hours === 0) {
1158
- dayPeriodEnumValue = dayPeriodEnum.midnight;
1159
- } else {
1160
- dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1161
- }
1162
- switch (token) {
1163
- case 'b':
1164
- case 'bb':
1165
- return localize.dayPeriod(dayPeriodEnumValue, {
1166
- width: 'abbreviated',
1167
- context: 'formatting'
1168
- });
1169
- case 'bbb':
1170
- return localize.dayPeriod(dayPeriodEnumValue, {
1171
- width: 'abbreviated',
1172
- context: 'formatting'
1173
- }).toLowerCase();
1174
- case 'bbbbb':
1175
- return localize.dayPeriod(dayPeriodEnumValue, {
1176
- width: 'narrow',
1177
- context: 'formatting'
1178
- });
1179
- case 'bbbb':
1180
- default:
1181
- return localize.dayPeriod(dayPeriodEnumValue, {
1182
- width: 'wide',
1183
- context: 'formatting'
1184
- });
1185
- }
1186
- },
1187
- // in the morning, in the afternoon, in the evening, at night
1188
- B: function B(date, token, localize) {
1189
- var hours = date.getUTCHours();
1190
- var dayPeriodEnumValue;
1191
- if (hours >= 17) {
1192
- dayPeriodEnumValue = dayPeriodEnum.evening;
1193
- } else if (hours >= 12) {
1194
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
1195
- } else if (hours >= 4) {
1196
- dayPeriodEnumValue = dayPeriodEnum.morning;
1197
- } else {
1198
- dayPeriodEnumValue = dayPeriodEnum.night;
1199
- }
1200
- switch (token) {
1201
- case 'B':
1202
- case 'BB':
1203
- case 'BBB':
1204
- return localize.dayPeriod(dayPeriodEnumValue, {
1205
- width: 'abbreviated',
1206
- context: 'formatting'
1207
- });
1208
- case 'BBBBB':
1209
- return localize.dayPeriod(dayPeriodEnumValue, {
1210
- width: 'narrow',
1211
- context: 'formatting'
1212
- });
1213
- case 'BBBB':
1214
- default:
1215
- return localize.dayPeriod(dayPeriodEnumValue, {
1216
- width: 'wide',
1217
- context: 'formatting'
1218
- });
1219
- }
1220
- },
1221
- // Hour [1-12]
1222
- h: function h(date, token, localize) {
1223
- if (token === 'ho') {
1224
- var hours = date.getUTCHours() % 12;
1225
- if (hours === 0) hours = 12;
1226
- return localize.ordinalNumber(hours, {
1227
- unit: 'hour'
1228
- });
1229
- }
1230
- return formatters$1.h(date, token);
1231
- },
1232
- // Hour [0-23]
1233
- H: function H(date, token, localize) {
1234
- if (token === 'Ho') {
1235
- return localize.ordinalNumber(date.getUTCHours(), {
1236
- unit: 'hour'
1237
- });
1238
- }
1239
- return formatters$1.H(date, token);
1240
- },
1241
- // Hour [0-11]
1242
- K: function K(date, token, localize) {
1243
- var hours = date.getUTCHours() % 12;
1244
- if (token === 'Ko') {
1245
- return localize.ordinalNumber(hours, {
1246
- unit: 'hour'
1247
- });
1248
- }
1249
- return addLeadingZeros(hours, token.length);
1250
- },
1251
- // Hour [1-24]
1252
- k: function k(date, token, localize) {
1253
- var hours = date.getUTCHours();
1254
- if (hours === 0) hours = 24;
1255
- if (token === 'ko') {
1256
- return localize.ordinalNumber(hours, {
1257
- unit: 'hour'
1258
- });
1259
- }
1260
- return addLeadingZeros(hours, token.length);
1261
- },
1262
- // Minute
1263
- m: function m(date, token, localize) {
1264
- if (token === 'mo') {
1265
- return localize.ordinalNumber(date.getUTCMinutes(), {
1266
- unit: 'minute'
1267
- });
1268
- }
1269
- return formatters$1.m(date, token);
1270
- },
1271
- // Second
1272
- s: function s(date, token, localize) {
1273
- if (token === 'so') {
1274
- return localize.ordinalNumber(date.getUTCSeconds(), {
1275
- unit: 'second'
1276
- });
1277
- }
1278
- return formatters$1.s(date, token);
1279
- },
1280
- // Fraction of second
1281
- S: function S(date, token) {
1282
- return formatters$1.S(date, token);
1283
- },
1284
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1285
- X: function X(date, token, _localize, options) {
1286
- var originalDate = options._originalDate || date;
1287
- var timezoneOffset = originalDate.getTimezoneOffset();
1288
- if (timezoneOffset === 0) {
1289
- return 'Z';
1290
- }
1291
- switch (token) {
1292
- // Hours and optional minutes
1293
- case 'X':
1294
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1295
-
1296
- // Hours, minutes and optional seconds without `:` delimiter
1297
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1298
- // so this token always has the same output as `XX`
1299
- case 'XXXX':
1300
- case 'XX':
1301
- // Hours and minutes without `:` delimiter
1302
- return formatTimezone(timezoneOffset);
1303
-
1304
- // Hours, minutes and optional seconds with `:` delimiter
1305
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1306
- // so this token always has the same output as `XXX`
1307
- case 'XXXXX':
1308
- case 'XXX': // Hours and minutes with `:` delimiter
1309
- default:
1310
- return formatTimezone(timezoneOffset, ':');
1311
- }
1312
- },
1313
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1314
- x: function x(date, token, _localize, options) {
1315
- var originalDate = options._originalDate || date;
1316
- var timezoneOffset = originalDate.getTimezoneOffset();
1317
- switch (token) {
1318
- // Hours and optional minutes
1319
- case 'x':
1320
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1321
-
1322
- // Hours, minutes and optional seconds without `:` delimiter
1323
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1324
- // so this token always has the same output as `xx`
1325
- case 'xxxx':
1326
- case 'xx':
1327
- // Hours and minutes without `:` delimiter
1328
- return formatTimezone(timezoneOffset);
1329
-
1330
- // Hours, minutes and optional seconds with `:` delimiter
1331
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1332
- // so this token always has the same output as `xxx`
1333
- case 'xxxxx':
1334
- case 'xxx': // Hours and minutes with `:` delimiter
1335
- default:
1336
- return formatTimezone(timezoneOffset, ':');
1337
- }
1338
- },
1339
- // Timezone (GMT)
1340
- O: function O(date, token, _localize, options) {
1341
- var originalDate = options._originalDate || date;
1342
- var timezoneOffset = originalDate.getTimezoneOffset();
1343
- switch (token) {
1344
- // Short
1345
- case 'O':
1346
- case 'OO':
1347
- case 'OOO':
1348
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1349
- // Long
1350
- case 'OOOO':
1351
- default:
1352
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1353
- }
1354
- },
1355
- // Timezone (specific non-location)
1356
- z: function z(date, token, _localize, options) {
1357
- var originalDate = options._originalDate || date;
1358
- var timezoneOffset = originalDate.getTimezoneOffset();
1359
- switch (token) {
1360
- // Short
1361
- case 'z':
1362
- case 'zz':
1363
- case 'zzz':
1364
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1365
- // Long
1366
- case 'zzzz':
1367
- default:
1368
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1369
- }
1370
- },
1371
- // Seconds timestamp
1372
- t: function t(date, token, _localize, options) {
1373
- var originalDate = options._originalDate || date;
1374
- var timestamp = Math.floor(originalDate.getTime() / 1000);
1375
- return addLeadingZeros(timestamp, token.length);
1376
- },
1377
- // Milliseconds timestamp
1378
- T: function T(date, token, _localize, options) {
1379
- var originalDate = options._originalDate || date;
1380
- var timestamp = originalDate.getTime();
1381
- return addLeadingZeros(timestamp, token.length);
1382
- }
1383
- };
1384
- function formatTimezoneShort(offset, dirtyDelimiter) {
1385
- var sign = offset > 0 ? '-' : '+';
1386
- var absOffset = Math.abs(offset);
1387
- var hours = Math.floor(absOffset / 60);
1388
- var minutes = absOffset % 60;
1389
- if (minutes === 0) {
1390
- return sign + String(hours);
1391
- }
1392
- var delimiter = dirtyDelimiter;
1393
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1394
- }
1395
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1396
- if (offset % 60 === 0) {
1397
- var sign = offset > 0 ? '-' : '+';
1398
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1399
- }
1400
- return formatTimezone(offset, dirtyDelimiter);
1401
- }
1402
- function formatTimezone(offset, dirtyDelimiter) {
1403
- var delimiter = dirtyDelimiter || '';
1404
- var sign = offset > 0 ? '-' : '+';
1405
- var absOffset = Math.abs(offset);
1406
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1407
- var minutes = addLeadingZeros(absOffset % 60, 2);
1408
- return sign + hours + delimiter + minutes;
1409
- }
1410
-
1411
- var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1412
- switch (pattern) {
1413
- case 'P':
1414
- return formatLong.date({
1415
- width: 'short'
1416
- });
1417
- case 'PP':
1418
- return formatLong.date({
1419
- width: 'medium'
1420
- });
1421
- case 'PPP':
1422
- return formatLong.date({
1423
- width: 'long'
1424
- });
1425
- case 'PPPP':
1426
- default:
1427
- return formatLong.date({
1428
- width: 'full'
1429
- });
1430
- }
1431
- };
1432
- var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1433
- switch (pattern) {
1434
- case 'p':
1435
- return formatLong.time({
1436
- width: 'short'
1437
- });
1438
- case 'pp':
1439
- return formatLong.time({
1440
- width: 'medium'
1441
- });
1442
- case 'ppp':
1443
- return formatLong.time({
1444
- width: 'long'
1445
- });
1446
- case 'pppp':
1447
- default:
1448
- return formatLong.time({
1449
- width: 'full'
1450
- });
1451
- }
1452
- };
1453
- var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1454
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
1455
- var datePattern = matchResult[1];
1456
- var timePattern = matchResult[2];
1457
- if (!timePattern) {
1458
- return dateLongFormatter(pattern, formatLong);
1459
- }
1460
- var dateTimeFormat;
1461
- switch (datePattern) {
1462
- case 'P':
1463
- dateTimeFormat = formatLong.dateTime({
1464
- width: 'short'
1465
- });
1466
- break;
1467
- case 'PP':
1468
- dateTimeFormat = formatLong.dateTime({
1469
- width: 'medium'
1470
- });
1471
- break;
1472
- case 'PPP':
1473
- dateTimeFormat = formatLong.dateTime({
1474
- width: 'long'
1475
- });
1476
- break;
1477
- case 'PPPP':
1478
- default:
1479
- dateTimeFormat = formatLong.dateTime({
1480
- width: 'full'
1481
- });
1482
- break;
1483
- }
1484
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1485
- };
1486
- var longFormatters = {
1487
- p: timeLongFormatter,
1488
- P: dateTimeLongFormatter
1489
- };
1490
-
1491
- var protectedDayOfYearTokens = ['D', 'DD'];
1492
- var protectedWeekYearTokens = ['YY', 'YYYY'];
1493
- function isProtectedDayOfYearToken(token) {
1494
- return protectedDayOfYearTokens.indexOf(token) !== -1;
1495
- }
1496
- function isProtectedWeekYearToken(token) {
1497
- return protectedWeekYearTokens.indexOf(token) !== -1;
1498
- }
1499
- function throwProtectedError(token, format, input) {
1500
- if (token === 'YYYY') {
1501
- 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"));
1502
- } else if (token === 'YY') {
1503
- 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"));
1504
- } else if (token === 'D') {
1505
- 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"));
1506
- } else if (token === 'DD') {
1507
- 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"));
1508
- }
1509
- }
1510
-
1511
- var formatDistanceLocale$1 = {
1512
- lessThanXSeconds: {
1513
- one: 'less than a second',
1514
- other: 'less than {{count}} seconds'
1515
- },
1516
- xSeconds: {
1517
- one: '1 second',
1518
- other: '{{count}} seconds'
1519
- },
1520
- halfAMinute: 'half a minute',
1521
- lessThanXMinutes: {
1522
- one: 'less than a minute',
1523
- other: 'less than {{count}} minutes'
1524
- },
1525
- xMinutes: {
1526
- one: '1 minute',
1527
- other: '{{count}} minutes'
1528
- },
1529
- aboutXHours: {
1530
- one: 'about 1 hour',
1531
- other: 'about {{count}} hours'
1532
- },
1533
- xHours: {
1534
- one: '1 hour',
1535
- other: '{{count}} hours'
1536
- },
1537
- xDays: {
1538
- one: '1 day',
1539
- other: '{{count}} days'
1540
- },
1541
- aboutXWeeks: {
1542
- one: 'about 1 week',
1543
- other: 'about {{count}} weeks'
1544
- },
1545
- xWeeks: {
1546
- one: '1 week',
1547
- other: '{{count}} weeks'
1548
- },
1549
- aboutXMonths: {
1550
- one: 'about 1 month',
1551
- other: 'about {{count}} months'
1552
- },
1553
- xMonths: {
1554
- one: '1 month',
1555
- other: '{{count}} months'
1556
- },
1557
- aboutXYears: {
1558
- one: 'about 1 year',
1559
- other: 'about {{count}} years'
1560
- },
1561
- xYears: {
1562
- one: '1 year',
1563
- other: '{{count}} years'
1564
- },
1565
- overXYears: {
1566
- one: 'over 1 year',
1567
- other: 'over {{count}} years'
1568
- },
1569
- almostXYears: {
1570
- one: 'almost 1 year',
1571
- other: 'almost {{count}} years'
1572
- }
1573
- };
1574
- var formatDistance$1 = function formatDistance(token, count, options) {
1575
- var result;
1576
- var tokenValue = formatDistanceLocale$1[token];
1577
- if (typeof tokenValue === 'string') {
1578
- result = tokenValue;
1579
- } else if (count === 1) {
1580
- result = tokenValue.one;
1581
- } else {
1582
- result = tokenValue.other.replace('{{count}}', count.toString());
1583
- }
1584
- if (options !== null && options !== void 0 && options.addSuffix) {
1585
- if (options.comparison && options.comparison > 0) {
1586
- return 'in ' + result;
1587
- } else {
1588
- return result + ' ago';
1589
- }
1590
- }
1591
- return result;
1592
- };
1593
-
1594
- function buildFormatLongFn(args) {
1595
- return function () {
1596
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1597
- // TODO: Remove String()
1598
- var width = options.width ? String(options.width) : args.defaultWidth;
1599
- var format = args.formats[width] || args.formats[args.defaultWidth];
1600
- return format;
1601
- };
1602
- }
1603
-
1604
- var dateFormats$1 = {
1605
- full: 'EEEE, MMMM do, y',
1606
- long: 'MMMM do, y',
1607
- medium: 'MMM d, y',
1608
- short: 'MM/dd/yyyy'
1609
- };
1610
- var timeFormats$1 = {
1611
- full: 'h:mm:ss a zzzz',
1612
- long: 'h:mm:ss a z',
1613
- medium: 'h:mm:ss a',
1614
- short: 'h:mm a'
1615
- };
1616
- var dateTimeFormats$1 = {
1617
- full: "{{date}} 'at' {{time}}",
1618
- long: "{{date}} 'at' {{time}}",
1619
- medium: '{{date}}, {{time}}',
1620
- short: '{{date}}, {{time}}'
1621
- };
1622
- var formatLong$1 = {
1623
- date: buildFormatLongFn({
1624
- formats: dateFormats$1,
1625
- defaultWidth: 'full'
1626
- }),
1627
- time: buildFormatLongFn({
1628
- formats: timeFormats$1,
1629
- defaultWidth: 'full'
1630
- }),
1631
- dateTime: buildFormatLongFn({
1632
- formats: dateTimeFormats$1,
1633
- defaultWidth: 'full'
1634
- })
1635
- };
1636
-
1637
- var formatRelativeLocale$1 = {
1638
- lastWeek: "'last' eeee 'at' p",
1639
- yesterday: "'yesterday at' p",
1640
- today: "'today at' p",
1641
- tomorrow: "'tomorrow at' p",
1642
- nextWeek: "eeee 'at' p",
1643
- other: 'P'
1644
- };
1645
- var formatRelative$1 = function formatRelative(token, _date, _baseDate, _options) {
1646
- return formatRelativeLocale$1[token];
1647
- };
1648
-
1649
- function buildLocalizeFn(args) {
1650
- return function (dirtyIndex, options) {
1651
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1652
- var valuesArray;
1653
- if (context === 'formatting' && args.formattingValues) {
1654
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1655
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1656
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1657
- } else {
1658
- var _defaultWidth = args.defaultWidth;
1659
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1660
- valuesArray = args.values[_width] || args.values[_defaultWidth];
1661
- }
1662
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1663
- // @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!
1664
- return valuesArray[index];
1665
- };
1666
- }
1667
-
1668
- var eraValues$1 = {
1669
- narrow: ['B', 'A'],
1670
- abbreviated: ['BC', 'AD'],
1671
- wide: ['Before Christ', 'Anno Domini']
1672
- };
1673
- var quarterValues$1 = {
1674
- narrow: ['1', '2', '3', '4'],
1675
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1676
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1677
- };
1678
-
1679
- // Note: in English, the names of days of the week and months are capitalized.
1680
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1681
- // Generally, formatted dates should look like they are in the middle of a sentence,
1682
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
1683
- var monthValues$1 = {
1684
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1685
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1686
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1687
- };
1688
- var dayValues$1 = {
1689
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1690
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1691
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1692
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1693
- };
1694
- var dayPeriodValues$1 = {
1695
- narrow: {
1696
- am: 'a',
1697
- pm: 'p',
1698
- midnight: 'mi',
1699
- noon: 'n',
1700
- morning: 'morning',
1701
- afternoon: 'afternoon',
1702
- evening: 'evening',
1703
- night: 'night'
1704
- },
1705
- abbreviated: {
1706
- am: 'AM',
1707
- pm: 'PM',
1708
- midnight: 'midnight',
1709
- noon: 'noon',
1710
- morning: 'morning',
1711
- afternoon: 'afternoon',
1712
- evening: 'evening',
1713
- night: 'night'
1714
- },
1715
- wide: {
1716
- am: 'a.m.',
1717
- pm: 'p.m.',
1718
- midnight: 'midnight',
1719
- noon: 'noon',
1720
- morning: 'morning',
1721
- afternoon: 'afternoon',
1722
- evening: 'evening',
1723
- night: 'night'
1724
- }
1725
- };
1726
- var formattingDayPeriodValues = {
1727
- narrow: {
1728
- am: 'a',
1729
- pm: 'p',
1730
- midnight: 'mi',
1731
- noon: 'n',
1732
- morning: 'in the morning',
1733
- afternoon: 'in the afternoon',
1734
- evening: 'in the evening',
1735
- night: 'at night'
1736
- },
1737
- abbreviated: {
1738
- am: 'AM',
1739
- pm: 'PM',
1740
- midnight: 'midnight',
1741
- noon: 'noon',
1742
- morning: 'in the morning',
1743
- afternoon: 'in the afternoon',
1744
- evening: 'in the evening',
1745
- night: 'at night'
1746
- },
1747
- wide: {
1748
- am: 'a.m.',
1749
- pm: 'p.m.',
1750
- midnight: 'midnight',
1751
- noon: 'noon',
1752
- morning: 'in the morning',
1753
- afternoon: 'in the afternoon',
1754
- evening: 'in the evening',
1755
- night: 'at night'
1756
- }
1757
- };
1758
- var ordinalNumber$1 = function ordinalNumber(dirtyNumber, _options) {
1759
- var number = Number(dirtyNumber);
1760
-
1761
- // If ordinal numbers depend on context, for example,
1762
- // if they are different for different grammatical genders,
1763
- // use `options.unit`.
1764
- //
1765
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1766
- // 'day', 'hour', 'minute', 'second'.
1767
-
1768
- var rem100 = number % 100;
1769
- if (rem100 > 20 || rem100 < 10) {
1770
- switch (rem100 % 10) {
1771
- case 1:
1772
- return number + 'st';
1773
- case 2:
1774
- return number + 'nd';
1775
- case 3:
1776
- return number + 'rd';
1777
- }
1778
- }
1779
- return number + 'th';
1780
- };
1781
- var localize$1 = {
1782
- ordinalNumber: ordinalNumber$1,
1783
- era: buildLocalizeFn({
1784
- values: eraValues$1,
1785
- defaultWidth: 'wide'
1786
- }),
1787
- quarter: buildLocalizeFn({
1788
- values: quarterValues$1,
1789
- defaultWidth: 'wide',
1790
- argumentCallback: function argumentCallback(quarter) {
1791
- return quarter - 1;
1792
- }
1793
- }),
1794
- month: buildLocalizeFn({
1795
- values: monthValues$1,
1796
- defaultWidth: 'wide'
1797
- }),
1798
- day: buildLocalizeFn({
1799
- values: dayValues$1,
1800
- defaultWidth: 'wide'
1801
- }),
1802
- dayPeriod: buildLocalizeFn({
1803
- values: dayPeriodValues$1,
1804
- defaultWidth: 'wide',
1805
- formattingValues: formattingDayPeriodValues,
1806
- defaultFormattingWidth: 'wide'
1807
- })
1808
- };
1809
-
1810
- function buildMatchFn(args) {
1811
- return function (string) {
1812
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1813
- var width = options.width;
1814
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1815
- var matchResult = string.match(matchPattern);
1816
- if (!matchResult) {
1817
- return null;
1818
- }
1819
- var matchedString = matchResult[0];
1820
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1821
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1822
- return pattern.test(matchedString);
1823
- }) : findKey(parsePatterns, function (pattern) {
1824
- return pattern.test(matchedString);
1825
- });
1826
- var value;
1827
- value = args.valueCallback ? args.valueCallback(key) : key;
1828
- value = options.valueCallback ? options.valueCallback(value) : value;
1829
- var rest = string.slice(matchedString.length);
1830
- return {
1831
- value: value,
1832
- rest: rest
1833
- };
1834
- };
1835
- }
1836
- function findKey(object, predicate) {
1837
- for (var key in object) {
1838
- if (object.hasOwnProperty(key) && predicate(object[key])) {
1839
- return key;
1840
- }
1841
- }
1842
- return undefined;
1843
- }
1844
- function findIndex(array, predicate) {
1845
- for (var key = 0; key < array.length; key++) {
1846
- if (predicate(array[key])) {
1847
- return key;
1848
- }
1849
- }
1850
- return undefined;
1851
- }
1852
-
1853
- function buildMatchPatternFn(args) {
1854
- return function (string) {
1855
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1856
- var matchResult = string.match(args.matchPattern);
1857
- if (!matchResult) return null;
1858
- var matchedString = matchResult[0];
1859
- var parseResult = string.match(args.parsePattern);
1860
- if (!parseResult) return null;
1861
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1862
- value = options.valueCallback ? options.valueCallback(value) : value;
1863
- var rest = string.slice(matchedString.length);
1864
- return {
1865
- value: value,
1866
- rest: rest
1867
- };
1868
- };
1869
- }
1870
-
1871
- var matchOrdinalNumberPattern$1 = /^(\d+)(th|st|nd|rd)?/i;
1872
- var parseOrdinalNumberPattern$1 = /\d+/i;
1873
- var matchEraPatterns$1 = {
1874
- narrow: /^(b|a)/i,
1875
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1876
- wide: /^(before christ|before common era|anno domini|common era)/i
1877
- };
1878
- var parseEraPatterns$1 = {
1879
- any: [/^b/i, /^(a|c)/i]
1880
- };
1881
- var matchQuarterPatterns$1 = {
1882
- narrow: /^[1234]/i,
1883
- abbreviated: /^q[1234]/i,
1884
- wide: /^[1234](th|st|nd|rd)? quarter/i
1885
- };
1886
- var parseQuarterPatterns$1 = {
1887
- any: [/1/i, /2/i, /3/i, /4/i]
1888
- };
1889
- var matchMonthPatterns$1 = {
1890
- narrow: /^[jfmasond]/i,
1891
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1892
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1893
- };
1894
- var parseMonthPatterns$1 = {
1895
- 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],
1896
- 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]
1897
- };
1898
- var matchDayPatterns$1 = {
1899
- narrow: /^[smtwf]/i,
1900
- short: /^(su|mo|tu|we|th|fr|sa)/i,
1901
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1902
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1903
- };
1904
- var parseDayPatterns$1 = {
1905
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1906
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1907
- };
1908
- var matchDayPeriodPatterns$1 = {
1909
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1910
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1911
- };
1912
- var parseDayPeriodPatterns$1 = {
1913
- any: {
1914
- am: /^a/i,
1915
- pm: /^p/i,
1916
- midnight: /^mi/i,
1917
- noon: /^no/i,
1918
- morning: /morning/i,
1919
- afternoon: /afternoon/i,
1920
- evening: /evening/i,
1921
- night: /night/i
1922
- }
1923
- };
1924
- var match$1 = {
1925
- ordinalNumber: buildMatchPatternFn({
1926
- matchPattern: matchOrdinalNumberPattern$1,
1927
- parsePattern: parseOrdinalNumberPattern$1,
1928
- valueCallback: function valueCallback(value) {
1929
- return parseInt(value, 10);
1930
- }
1931
- }),
1932
- era: buildMatchFn({
1933
- matchPatterns: matchEraPatterns$1,
1934
- defaultMatchWidth: 'wide',
1935
- parsePatterns: parseEraPatterns$1,
1936
- defaultParseWidth: 'any'
1937
- }),
1938
- quarter: buildMatchFn({
1939
- matchPatterns: matchQuarterPatterns$1,
1940
- defaultMatchWidth: 'wide',
1941
- parsePatterns: parseQuarterPatterns$1,
1942
- defaultParseWidth: 'any',
1943
- valueCallback: function valueCallback(index) {
1944
- return index + 1;
1945
- }
1946
- }),
1947
- month: buildMatchFn({
1948
- matchPatterns: matchMonthPatterns$1,
1949
- defaultMatchWidth: 'wide',
1950
- parsePatterns: parseMonthPatterns$1,
1951
- defaultParseWidth: 'any'
1952
- }),
1953
- day: buildMatchFn({
1954
- matchPatterns: matchDayPatterns$1,
1955
- defaultMatchWidth: 'wide',
1956
- parsePatterns: parseDayPatterns$1,
1957
- defaultParseWidth: 'any'
1958
- }),
1959
- dayPeriod: buildMatchFn({
1960
- matchPatterns: matchDayPeriodPatterns$1,
1961
- defaultMatchWidth: 'any',
1962
- parsePatterns: parseDayPeriodPatterns$1,
1963
- defaultParseWidth: 'any'
1964
- })
1965
- };
1966
-
1967
- /**
1968
- * @type {Locale}
1969
- * @category Locales
1970
- * @summary English locale (United States).
1971
- * @language English
1972
- * @iso-639-2 eng
1973
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1974
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1975
- */
1976
- var locale$1 = {
1977
- code: 'en-US',
1978
- formatDistance: formatDistance$1,
1979
- formatLong: formatLong$1,
1980
- formatRelative: formatRelative$1,
1981
- localize: localize$1,
1982
- match: match$1,
1983
- options: {
1984
- weekStartsOn: 0 /* Sunday */,
1985
- firstWeekContainsDate: 1
1986
- }
1987
- };
1988
-
1989
- // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1990
- // (one of the certain letters followed by `o`)
1991
- // - (\w)\1* matches any sequences of the same letter
1992
- // - '' matches two quote characters in a row
1993
- // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1994
- // except a single quote symbol, which ends the sequence.
1995
- // Two quote characters do not end the sequence.
1996
- // If there is no matching single quote
1997
- // then the sequence will continue until the end of the string.
1998
- // - . matches any single character unmatched by previous parts of the RegExps
1999
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2000
-
2001
- // This RegExp catches symbols escaped by quotes, and also
2002
- // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2003
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2004
- var escapedStringRegExp = /^'([^]*?)'?$/;
2005
- var doubleQuoteRegExp = /''/g;
2006
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2007
-
2008
- /**
2009
- * @name format
2010
- * @category Common Helpers
2011
- * @summary Format the date.
2012
- *
2013
- * @description
2014
- * Return the formatted date string in the given format. The result may vary by locale.
2015
- *
2016
- * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2017
- * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2018
- *
2019
- * The characters wrapped between two single quotes characters (') are escaped.
2020
- * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2021
- * (see the last example)
2022
- *
2023
- * Format of the string is based on Unicode Technical Standard #35:
2024
- * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2025
- * with a few additions (see note 7 below the table).
2026
- *
2027
- * Accepted patterns:
2028
- * | Unit | Pattern | Result examples | Notes |
2029
- * |---------------------------------|---------|-----------------------------------|-------|
2030
- * | Era | G..GGG | AD, BC | |
2031
- * | | GGGG | Anno Domini, Before Christ | 2 |
2032
- * | | GGGGG | A, B | |
2033
- * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2034
- * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2035
- * | | yy | 44, 01, 00, 17 | 5 |
2036
- * | | yyy | 044, 001, 1900, 2017 | 5 |
2037
- * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2038
- * | | yyyyy | ... | 3,5 |
2039
- * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2040
- * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2041
- * | | YY | 44, 01, 00, 17 | 5,8 |
2042
- * | | YYY | 044, 001, 1900, 2017 | 5 |
2043
- * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2044
- * | | YYYYY | ... | 3,5 |
2045
- * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2046
- * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2047
- * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2048
- * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2049
- * | | RRRRR | ... | 3,5,7 |
2050
- * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2051
- * | | uu | -43, 01, 1900, 2017 | 5 |
2052
- * | | uuu | -043, 001, 1900, 2017 | 5 |
2053
- * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2054
- * | | uuuuu | ... | 3,5 |
2055
- * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2056
- * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2057
- * | | QQ | 01, 02, 03, 04 | |
2058
- * | | QQQ | Q1, Q2, Q3, Q4 | |
2059
- * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2060
- * | | QQQQQ | 1, 2, 3, 4 | 4 |
2061
- * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2062
- * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2063
- * | | qq | 01, 02, 03, 04 | |
2064
- * | | qqq | Q1, Q2, Q3, Q4 | |
2065
- * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2066
- * | | qqqqq | 1, 2, 3, 4 | 4 |
2067
- * | Month (formatting) | M | 1, 2, ..., 12 | |
2068
- * | | Mo | 1st, 2nd, ..., 12th | 7 |
2069
- * | | MM | 01, 02, ..., 12 | |
2070
- * | | MMM | Jan, Feb, ..., Dec | |
2071
- * | | MMMM | January, February, ..., December | 2 |
2072
- * | | MMMMM | J, F, ..., D | |
2073
- * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2074
- * | | Lo | 1st, 2nd, ..., 12th | 7 |
2075
- * | | LL | 01, 02, ..., 12 | |
2076
- * | | LLL | Jan, Feb, ..., Dec | |
2077
- * | | LLLL | January, February, ..., December | 2 |
2078
- * | | LLLLL | J, F, ..., D | |
2079
- * | Local week of year | w | 1, 2, ..., 53 | |
2080
- * | | wo | 1st, 2nd, ..., 53th | 7 |
2081
- * | | ww | 01, 02, ..., 53 | |
2082
- * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2083
- * | | Io | 1st, 2nd, ..., 53th | 7 |
2084
- * | | II | 01, 02, ..., 53 | 7 |
2085
- * | Day of month | d | 1, 2, ..., 31 | |
2086
- * | | do | 1st, 2nd, ..., 31st | 7 |
2087
- * | | dd | 01, 02, ..., 31 | |
2088
- * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2089
- * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2090
- * | | DD | 01, 02, ..., 365, 366 | 9 |
2091
- * | | DDD | 001, 002, ..., 365, 366 | |
2092
- * | | DDDD | ... | 3 |
2093
- * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2094
- * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2095
- * | | EEEEE | M, T, W, T, F, S, S | |
2096
- * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2097
- * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2098
- * | | io | 1st, 2nd, ..., 7th | 7 |
2099
- * | | ii | 01, 02, ..., 07 | 7 |
2100
- * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2101
- * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2102
- * | | iiiii | M, T, W, T, F, S, S | 7 |
2103
- * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2104
- * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2105
- * | | eo | 2nd, 3rd, ..., 1st | 7 |
2106
- * | | ee | 02, 03, ..., 01 | |
2107
- * | | eee | Mon, Tue, Wed, ..., Sun | |
2108
- * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2109
- * | | eeeee | M, T, W, T, F, S, S | |
2110
- * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2111
- * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2112
- * | | co | 2nd, 3rd, ..., 1st | 7 |
2113
- * | | cc | 02, 03, ..., 01 | |
2114
- * | | ccc | Mon, Tue, Wed, ..., Sun | |
2115
- * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2116
- * | | ccccc | M, T, W, T, F, S, S | |
2117
- * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2118
- * | AM, PM | a..aa | AM, PM | |
2119
- * | | aaa | am, pm | |
2120
- * | | aaaa | a.m., p.m. | 2 |
2121
- * | | aaaaa | a, p | |
2122
- * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2123
- * | | bbb | am, pm, noon, midnight | |
2124
- * | | bbbb | a.m., p.m., noon, midnight | 2 |
2125
- * | | bbbbb | a, p, n, mi | |
2126
- * | Flexible day period | B..BBB | at night, in the morning, ... | |
2127
- * | | BBBB | at night, in the morning, ... | 2 |
2128
- * | | BBBBB | at night, in the morning, ... | |
2129
- * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2130
- * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2131
- * | | hh | 01, 02, ..., 11, 12 | |
2132
- * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2133
- * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2134
- * | | HH | 00, 01, 02, ..., 23 | |
2135
- * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2136
- * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2137
- * | | KK | 01, 02, ..., 11, 00 | |
2138
- * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2139
- * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2140
- * | | kk | 24, 01, 02, ..., 23 | |
2141
- * | Minute | m | 0, 1, ..., 59 | |
2142
- * | | mo | 0th, 1st, ..., 59th | 7 |
2143
- * | | mm | 00, 01, ..., 59 | |
2144
- * | Second | s | 0, 1, ..., 59 | |
2145
- * | | so | 0th, 1st, ..., 59th | 7 |
2146
- * | | ss | 00, 01, ..., 59 | |
2147
- * | Fraction of second | S | 0, 1, ..., 9 | |
2148
- * | | SS | 00, 01, ..., 99 | |
2149
- * | | SSS | 000, 001, ..., 999 | |
2150
- * | | SSSS | ... | 3 |
2151
- * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2152
- * | | XX | -0800, +0530, Z | |
2153
- * | | XXX | -08:00, +05:30, Z | |
2154
- * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2155
- * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2156
- * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2157
- * | | xx | -0800, +0530, +0000 | |
2158
- * | | xxx | -08:00, +05:30, +00:00 | 2 |
2159
- * | | xxxx | -0800, +0530, +0000, +123456 | |
2160
- * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2161
- * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2162
- * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2163
- * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2164
- * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2165
- * | Seconds timestamp | t | 512969520 | 7 |
2166
- * | | tt | ... | 3,7 |
2167
- * | Milliseconds timestamp | T | 512969520900 | 7 |
2168
- * | | TT | ... | 3,7 |
2169
- * | Long localized date | P | 04/29/1453 | 7 |
2170
- * | | PP | Apr 29, 1453 | 7 |
2171
- * | | PPP | April 29th, 1453 | 7 |
2172
- * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2173
- * | Long localized time | p | 12:00 AM | 7 |
2174
- * | | pp | 12:00:00 AM | 7 |
2175
- * | | ppp | 12:00:00 AM GMT+2 | 7 |
2176
- * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2177
- * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2178
- * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2179
- * | | PPPppp | April 29th, 1453 at ... | 7 |
2180
- * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2181
- * Notes:
2182
- * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2183
- * are the same as "stand-alone" units, but are different in some languages.
2184
- * "Formatting" units are declined according to the rules of the language
2185
- * in the context of a date. "Stand-alone" units are always nominative singular:
2186
- *
2187
- * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2188
- *
2189
- * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2190
- *
2191
- * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2192
- * the single quote characters (see below).
2193
- * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2194
- * the output will be the same as default pattern for this unit, usually
2195
- * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2196
- * are marked with "2" in the last column of the table.
2197
- *
2198
- * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2199
- *
2200
- * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2201
- *
2202
- * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2203
- *
2204
- * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2205
- *
2206
- * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2207
- *
2208
- * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2209
- * The output will be padded with zeros to match the length of the pattern.
2210
- *
2211
- * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2212
- *
2213
- * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2214
- * These tokens represent the shortest form of the quarter.
2215
- *
2216
- * 5. The main difference between `y` and `u` patterns are B.C. years:
2217
- *
2218
- * | Year | `y` | `u` |
2219
- * |------|-----|-----|
2220
- * | AC 1 | 1 | 1 |
2221
- * | BC 1 | 1 | 0 |
2222
- * | BC 2 | 2 | -1 |
2223
- *
2224
- * Also `yy` always returns the last two digits of a year,
2225
- * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2226
- *
2227
- * | Year | `yy` | `uu` |
2228
- * |------|------|------|
2229
- * | 1 | 01 | 01 |
2230
- * | 14 | 14 | 14 |
2231
- * | 376 | 76 | 376 |
2232
- * | 1453 | 53 | 1453 |
2233
- *
2234
- * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2235
- * except local week-numbering years are dependent on `options.weekStartsOn`
2236
- * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2237
- * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2238
- *
2239
- * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2240
- * so right now these tokens fall back to GMT timezones.
2241
- *
2242
- * 7. These patterns are not in the Unicode Technical Standard #35:
2243
- * - `i`: ISO day of week
2244
- * - `I`: ISO week of year
2245
- * - `R`: ISO week-numbering year
2246
- * - `t`: seconds timestamp
2247
- * - `T`: milliseconds timestamp
2248
- * - `o`: ordinal number modifier
2249
- * - `P`: long localized date
2250
- * - `p`: long localized time
2251
- *
2252
- * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2253
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2254
- *
2255
- * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2256
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2257
- *
2258
- * @param {Date|Number} date - the original date
2259
- * @param {String} format - the string of tokens
2260
- * @param {Object} [options] - an object with options.
2261
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2262
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2263
- * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2264
- * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2265
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2266
- * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2267
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2268
- * @returns {String} the formatted date string
2269
- * @throws {TypeError} 2 arguments required
2270
- * @throws {RangeError} `date` must not be Invalid Date
2271
- * @throws {RangeError} `options.locale` must contain `localize` property
2272
- * @throws {RangeError} `options.locale` must contain `formatLong` property
2273
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2274
- * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2275
- * @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
2276
- * @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
2277
- * @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
2278
- * @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
2279
- * @throws {RangeError} format string contains an unescaped latin alphabet character
2280
- *
2281
- * @example
2282
- * // Represent 11 February 2014 in middle-endian format:
2283
- * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2284
- * //=> '02/11/2014'
2285
- *
2286
- * @example
2287
- * // Represent 2 July 2014 in Esperanto:
2288
- * import { eoLocale } from 'date-fns/locale/eo'
2289
- * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2290
- * locale: eoLocale
2291
- * })
2292
- * //=> '2-a de julio 2014'
2293
- *
2294
- * @example
2295
- * // Escape string by single quote characters:
2296
- * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2297
- * //=> "3 o'clock"
2298
- */
2299
-
2300
- function format(dirtyDate, dirtyFormatStr, options) {
2301
- 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;
2302
- requiredArgs(2, arguments);
2303
- var formatStr = String(dirtyFormatStr);
2304
- var defaultOptions = getDefaultOptions();
2305
- var locale = (_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$1;
2306
- var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2307
-
2308
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2309
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2310
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2311
- }
2312
- var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2313
-
2314
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2315
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2316
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2317
- }
2318
- if (!locale.localize) {
2319
- throw new RangeError('locale must contain localize property');
2320
- }
2321
- if (!locale.formatLong) {
2322
- throw new RangeError('locale must contain formatLong property');
2323
- }
2324
- var originalDate = toDate(dirtyDate);
2325
- if (!isValid(originalDate)) {
2326
- throw new RangeError('Invalid time value');
2327
- }
2328
-
2329
- // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2330
- // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2331
- // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2332
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2333
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
2334
- var formatterOptions = {
2335
- firstWeekContainsDate: firstWeekContainsDate,
2336
- weekStartsOn: weekStartsOn,
2337
- locale: locale,
2338
- _originalDate: originalDate
2339
- };
2340
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2341
- var firstCharacter = substring[0];
2342
- if (firstCharacter === 'p' || firstCharacter === 'P') {
2343
- var longFormatter = longFormatters[firstCharacter];
2344
- return longFormatter(substring, locale.formatLong);
2345
- }
2346
- return substring;
2347
- }).join('').match(formattingTokensRegExp).map(function (substring) {
2348
- // Replace two single quote characters with one single quote character
2349
- if (substring === "''") {
2350
- return "'";
2351
- }
2352
- var firstCharacter = substring[0];
2353
- if (firstCharacter === "'") {
2354
- return cleanEscapedString(substring);
2355
- }
2356
- var formatter = formatters[firstCharacter];
2357
- if (formatter) {
2358
- if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2359
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2360
- }
2361
- if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2362
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2363
- }
2364
- return formatter(utcDate, substring, locale.localize, formatterOptions);
2365
- }
2366
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2367
- throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2368
- }
2369
- return substring;
2370
- }).join('');
2371
- return result;
2372
- }
2373
- function cleanEscapedString(input) {
2374
- var matched = input.match(escapedStringRegExp);
2375
- if (!matched) {
2376
- return input;
2377
- }
2378
- return matched[1].replace(doubleQuoteRegExp, "'");
2379
- }
2380
-
2381
- /**
2382
- * @name getYear
2383
- * @category Year Helpers
2384
- * @summary Get the year of the given date.
2385
- *
2386
- * @description
2387
- * Get the year of the given date.
2388
- *
2389
- * @param {Date|Number} date - the given date
2390
- * @returns {Number} the year
2391
- * @throws {TypeError} 1 argument required
2392
- *
2393
- * @example
2394
- * // Which year is 2 July 2014?
2395
- * const result = getYear(new Date(2014, 6, 2))
2396
- * //=> 2014
2397
- */
2398
- function getYear(dirtyDate) {
2399
- requiredArgs(1, arguments);
2400
- return toDate(dirtyDate).getFullYear();
2401
- }
2402
-
2403
- /**
2404
- * @name isAfter
2405
- * @category Common Helpers
2406
- * @summary Is the first date after the second one?
2407
- *
2408
- * @description
2409
- * Is the first date after the second one?
2410
- *
2411
- * @param {Date|Number} date - the date that should be after the other one to return true
2412
- * @param {Date|Number} dateToCompare - the date to compare with
2413
- * @returns {Boolean} the first date is after the second date
2414
- * @throws {TypeError} 2 arguments required
2415
- *
2416
- * @example
2417
- * // Is 10 July 1989 after 11 February 1987?
2418
- * const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
2419
- * //=> true
2420
- */
2421
- function isAfter(dirtyDate, dirtyDateToCompare) {
2422
- requiredArgs(2, arguments);
2423
- var date = toDate(dirtyDate);
2424
- var dateToCompare = toDate(dirtyDateToCompare);
2425
- return date.getTime() > dateToCompare.getTime();
2426
- }
2427
-
2428
- /**
2429
- * @name isBefore
2430
- * @category Common Helpers
2431
- * @summary Is the first date before the second one?
2432
- *
2433
- * @description
2434
- * Is the first date before the second one?
2435
- *
2436
- * @param {Date|Number} date - the date that should be before the other one to return true
2437
- * @param {Date|Number} dateToCompare - the date to compare with
2438
- * @returns {Boolean} the first date is before the second date
2439
- * @throws {TypeError} 2 arguments required
2440
- *
2441
- * @example
2442
- * // Is 10 July 1989 before 11 February 1987?
2443
- * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
2444
- * //=> false
2445
- */
2446
- function isBefore(dirtyDate, dirtyDateToCompare) {
2447
- requiredArgs(2, arguments);
2448
- var date = toDate(dirtyDate);
2449
- var dateToCompare = toDate(dirtyDateToCompare);
2450
- return date.getTime() < dateToCompare.getTime();
2451
- }
2452
-
2453
- /**
2454
- * @name setYear
2455
- * @category Year Helpers
2456
- * @summary Set the year to the given date.
2457
- *
2458
- * @description
2459
- * Set the year to the given date.
2460
- *
2461
- * @param {Date|Number} date - the date to be changed
2462
- * @param {Number} year - the year of the new date
2463
- * @returns {Date} the new date with the year set
2464
- * @throws {TypeError} 2 arguments required
2465
- *
2466
- * @example
2467
- * // Set year 2013 to 1 September 2014:
2468
- * const result = setYear(new Date(2014, 8, 1), 2013)
2469
- * //=> Sun Sep 01 2013 00:00:00
2470
- */
2471
- function setYear(dirtyDate, dirtyYear) {
2472
- requiredArgs(2, arguments);
2473
- var date = toDate(dirtyDate);
2474
- var year = toInteger(dirtyYear);
2475
-
2476
- // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
2477
- if (isNaN(date.getTime())) {
2478
- return new Date(NaN);
2479
- }
2480
- date.setFullYear(year);
2481
- return date;
2482
- }
2483
-
2484
- /**
2485
- * @name subYears
2486
- * @category Year Helpers
2487
- * @summary Subtract the specified number of years from the given date.
2488
- *
2489
- * @description
2490
- * Subtract the specified number of years from the given date.
2491
- *
2492
- * @param {Date|Number} date - the date to be changed
2493
- * @param {Number} amount - the amount of years to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
2494
- * @returns {Date} the new date with the years subtracted
2495
- * @throws {TypeError} 2 arguments required
2496
- *
2497
- * @example
2498
- * // Subtract 5 years from 1 September 2014:
2499
- * const result = subYears(new Date(2014, 8, 1), 5)
2500
- * //=> Tue Sep 01 2009 00:00:00
2501
- */
2502
- function subYears(dirtyDate, dirtyAmount) {
2503
- requiredArgs(2, arguments);
2504
- var amount = toInteger(dirtyAmount);
2505
- return addYears(dirtyDate, -amount);
2506
- }
2507
-
2508
- var formatDistanceLocale = {
2509
- lessThanXSeconds: {
2510
- one: 'minder dan een seconde',
2511
- other: 'minder dan {{count}} seconden'
2512
- },
2513
- xSeconds: {
2514
- one: '1 seconde',
2515
- other: '{{count}} seconden'
2516
- },
2517
- halfAMinute: 'een halve minuut',
2518
- lessThanXMinutes: {
2519
- one: 'minder dan een minuut',
2520
- other: 'minder dan {{count}} minuten'
2521
- },
2522
- xMinutes: {
2523
- one: 'een minuut',
2524
- other: '{{count}} minuten'
2525
- },
2526
- aboutXHours: {
2527
- one: 'ongeveer 1 uur',
2528
- other: 'ongeveer {{count}} uur'
2529
- },
2530
- xHours: {
2531
- one: '1 uur',
2532
- other: '{{count}} uur'
2533
- },
2534
- xDays: {
2535
- one: '1 dag',
2536
- other: '{{count}} dagen'
2537
- },
2538
- aboutXWeeks: {
2539
- one: 'ongeveer 1 week',
2540
- other: 'ongeveer {{count}} weken'
2541
- },
2542
- xWeeks: {
2543
- one: '1 week',
2544
- other: '{{count}} weken'
2545
- },
2546
- aboutXMonths: {
2547
- one: 'ongeveer 1 maand',
2548
- other: 'ongeveer {{count}} maanden'
2549
- },
2550
- xMonths: {
2551
- one: '1 maand',
2552
- other: '{{count}} maanden'
2553
- },
2554
- aboutXYears: {
2555
- one: 'ongeveer 1 jaar',
2556
- other: 'ongeveer {{count}} jaar'
2557
- },
2558
- xYears: {
2559
- one: '1 jaar',
2560
- other: '{{count}} jaar'
2561
- },
2562
- overXYears: {
2563
- one: 'meer dan 1 jaar',
2564
- other: 'meer dan {{count}} jaar'
2565
- },
2566
- almostXYears: {
2567
- one: 'bijna 1 jaar',
2568
- other: 'bijna {{count}} jaar'
2569
- }
2570
- };
2571
- var formatDistance = function formatDistance(token, count, options) {
2572
- var result;
2573
- var tokenValue = formatDistanceLocale[token];
2574
- if (typeof tokenValue === 'string') {
2575
- result = tokenValue;
2576
- } else if (count === 1) {
2577
- result = tokenValue.one;
2578
- } else {
2579
- result = tokenValue.other.replace('{{count}}', String(count));
2580
- }
2581
- if (options !== null && options !== void 0 && options.addSuffix) {
2582
- if (options.comparison && options.comparison > 0) {
2583
- return 'over ' + result;
2584
- } else {
2585
- return result + ' geleden';
2586
- }
2587
- }
2588
- return result;
2589
- };
2590
-
2591
- var dateFormats = {
2592
- full: 'EEEE d MMMM y',
2593
- long: 'd MMMM y',
2594
- medium: 'd MMM y',
2595
- short: 'dd-MM-y'
2596
- };
2597
- var timeFormats = {
2598
- full: 'HH:mm:ss zzzz',
2599
- long: 'HH:mm:ss z',
2600
- medium: 'HH:mm:ss',
2601
- short: 'HH:mm'
2602
- };
2603
- var dateTimeFormats = {
2604
- full: "{{date}} 'om' {{time}}",
2605
- long: "{{date}} 'om' {{time}}",
2606
- medium: '{{date}}, {{time}}',
2607
- short: '{{date}}, {{time}}'
2608
- };
2609
- var formatLong = {
2610
- date: buildFormatLongFn({
2611
- formats: dateFormats,
2612
- defaultWidth: 'full'
2613
- }),
2614
- time: buildFormatLongFn({
2615
- formats: timeFormats,
2616
- defaultWidth: 'full'
2617
- }),
2618
- dateTime: buildFormatLongFn({
2619
- formats: dateTimeFormats,
2620
- defaultWidth: 'full'
2621
- })
2622
- };
2623
-
2624
- var formatRelativeLocale = {
2625
- lastWeek: "'afgelopen' eeee 'om' p",
2626
- yesterday: "'gisteren om' p",
2627
- today: "'vandaag om' p",
2628
- tomorrow: "'morgen om' p",
2629
- nextWeek: "eeee 'om' p",
2630
- other: 'P'
2631
- };
2632
- var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
2633
- return formatRelativeLocale[token];
2634
- };
2635
-
2636
- var eraValues = {
2637
- narrow: ['v.C.', 'n.C.'],
2638
- abbreviated: ['v.Chr.', 'n.Chr.'],
2639
- wide: ['voor Christus', 'na Christus']
2640
- };
2641
- var quarterValues = {
2642
- narrow: ['1', '2', '3', '4'],
2643
- abbreviated: ['K1', 'K2', 'K3', 'K4'],
2644
- wide: ['1e kwartaal', '2e kwartaal', '3e kwartaal', '4e kwartaal']
2645
- };
2646
- var monthValues = {
2647
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
2648
- abbreviated: ['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
2649
- wide: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december']
2650
- };
2651
- var dayValues = {
2652
- narrow: ['Z', 'M', 'D', 'W', 'D', 'V', 'Z'],
2653
- short: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
2654
- abbreviated: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
2655
- wide: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag']
2656
- };
2657
- var dayPeriodValues = {
2658
- narrow: {
2659
- am: 'AM',
2660
- pm: 'PM',
2661
- midnight: 'middernacht',
2662
- noon: 'het middaguur',
2663
- morning: "'s ochtends",
2664
- afternoon: "'s middags",
2665
- evening: "'s avonds",
2666
- night: "'s nachts"
2667
- },
2668
- abbreviated: {
2669
- am: 'AM',
2670
- pm: 'PM',
2671
- midnight: 'middernacht',
2672
- noon: 'het middaguur',
2673
- morning: "'s ochtends",
2674
- afternoon: "'s middags",
2675
- evening: "'s avonds",
2676
- night: "'s nachts"
2677
- },
2678
- wide: {
2679
- am: 'AM',
2680
- pm: 'PM',
2681
- midnight: 'middernacht',
2682
- noon: 'het middaguur',
2683
- morning: "'s ochtends",
2684
- afternoon: "'s middags",
2685
- evening: "'s avonds",
2686
- night: "'s nachts"
2687
- }
2688
- };
2689
- var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
2690
- var number = Number(dirtyNumber);
2691
- return number + 'e';
2692
- };
2693
- var localize = {
2694
- ordinalNumber: ordinalNumber,
2695
- era: buildLocalizeFn({
2696
- values: eraValues,
2697
- defaultWidth: 'wide'
2698
- }),
2699
- quarter: buildLocalizeFn({
2700
- values: quarterValues,
2701
- defaultWidth: 'wide',
2702
- argumentCallback: function argumentCallback(quarter) {
2703
- return quarter - 1;
2704
- }
2705
- }),
2706
- month: buildLocalizeFn({
2707
- values: monthValues,
2708
- defaultWidth: 'wide'
2709
- }),
2710
- day: buildLocalizeFn({
2711
- values: dayValues,
2712
- defaultWidth: 'wide'
2713
- }),
2714
- dayPeriod: buildLocalizeFn({
2715
- values: dayPeriodValues,
2716
- defaultWidth: 'wide'
2717
- })
2718
- };
2719
-
2720
- var matchOrdinalNumberPattern = /^(\d+)e?/i;
2721
- var parseOrdinalNumberPattern = /\d+/i;
2722
- var matchEraPatterns = {
2723
- narrow: /^([vn]\.? ?C\.?)/,
2724
- abbreviated: /^([vn]\. ?Chr\.?)/,
2725
- wide: /^((voor|na) Christus)/
2726
- };
2727
- var parseEraPatterns = {
2728
- any: [/^v/, /^n/]
2729
- };
2730
- var matchQuarterPatterns = {
2731
- narrow: /^[1234]/i,
2732
- abbreviated: /^K[1234]/i,
2733
- wide: /^[1234]e kwartaal/i
2734
- };
2735
- var parseQuarterPatterns = {
2736
- any: [/1/i, /2/i, /3/i, /4/i]
2737
- };
2738
- var matchMonthPatterns = {
2739
- narrow: /^[jfmasond]/i,
2740
- abbreviated: /^(jan.|feb.|mrt.|apr.|mei|jun.|jul.|aug.|sep.|okt.|nov.|dec.)/i,
2741
- wide: /^(januari|februari|maart|april|mei|juni|juli|augustus|september|oktober|november|december)/i
2742
- };
2743
- var parseMonthPatterns = {
2744
- 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],
2745
- any: [/^jan/i, /^feb/i, /^m(r|a)/i, /^apr/i, /^mei/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i]
2746
- };
2747
- var matchDayPatterns = {
2748
- narrow: /^[zmdwv]/i,
2749
- short: /^(zo|ma|di|wo|do|vr|za)/i,
2750
- abbreviated: /^(zon|maa|din|woe|don|vri|zat)/i,
2751
- wide: /^(zondag|maandag|dinsdag|woensdag|donderdag|vrijdag|zaterdag)/i
2752
- };
2753
- var parseDayPatterns = {
2754
- narrow: [/^z/i, /^m/i, /^d/i, /^w/i, /^d/i, /^v/i, /^z/i],
2755
- any: [/^zo/i, /^ma/i, /^di/i, /^wo/i, /^do/i, /^vr/i, /^za/i]
2756
- };
2757
- var matchDayPeriodPatterns = {
2758
- any: /^(am|pm|middernacht|het middaguur|'s (ochtends|middags|avonds|nachts))/i
2759
- };
2760
- var parseDayPeriodPatterns = {
2761
- any: {
2762
- am: /^am/i,
2763
- pm: /^pm/i,
2764
- midnight: /^middernacht/i,
2765
- noon: /^het middaguur/i,
2766
- morning: /ochtend/i,
2767
- afternoon: /middag/i,
2768
- evening: /avond/i,
2769
- night: /nacht/i
2770
- }
2771
- };
2772
- var match = {
2773
- ordinalNumber: buildMatchPatternFn({
2774
- matchPattern: matchOrdinalNumberPattern,
2775
- parsePattern: parseOrdinalNumberPattern,
2776
- valueCallback: function valueCallback(value) {
2777
- return parseInt(value, 10);
2778
- }
2779
- }),
2780
- era: buildMatchFn({
2781
- matchPatterns: matchEraPatterns,
2782
- defaultMatchWidth: 'wide',
2783
- parsePatterns: parseEraPatterns,
2784
- defaultParseWidth: 'any'
2785
- }),
2786
- quarter: buildMatchFn({
2787
- matchPatterns: matchQuarterPatterns,
2788
- defaultMatchWidth: 'wide',
2789
- parsePatterns: parseQuarterPatterns,
2790
- defaultParseWidth: 'any',
2791
- valueCallback: function valueCallback(index) {
2792
- return index + 1;
2793
- }
2794
- }),
2795
- month: buildMatchFn({
2796
- matchPatterns: matchMonthPatterns,
2797
- defaultMatchWidth: 'wide',
2798
- parsePatterns: parseMonthPatterns,
2799
- defaultParseWidth: 'any'
2800
- }),
2801
- day: buildMatchFn({
2802
- matchPatterns: matchDayPatterns,
2803
- defaultMatchWidth: 'wide',
2804
- parsePatterns: parseDayPatterns,
2805
- defaultParseWidth: 'any'
2806
- }),
2807
- dayPeriod: buildMatchFn({
2808
- matchPatterns: matchDayPeriodPatterns,
2809
- defaultMatchWidth: 'any',
2810
- parsePatterns: parseDayPeriodPatterns,
2811
- defaultParseWidth: 'any'
2812
- })
2813
- };
2814
-
2815
- /**
2816
- * @type {Locale}
2817
- * @category Locales
2818
- * @summary Dutch locale.
2819
- * @language Dutch
2820
- * @iso-639-2 nld
2821
- * @author Jorik Tangelder [@jtangelder]{@link https://github.com/jtangelder}
2822
- * @author Ruben Stolk [@rubenstolk]{@link https://github.com/rubenstolk}
2823
- * @author Lode Vanhove [@bitcrumb]{@link https://github.com/bitcrumb}
2824
- * @author Edo Rivai [@edorivai]{@link https://github.com/edorivai}
2825
- * @author Niels Keurentjes [@curry684]{@link https://github.com/curry684}
2826
- * @author Stefan Vermaas [@stefanvermaas]{@link https://github.com/stefanvermaas}
2827
- */
2828
- var locale = {
2829
- code: 'nl',
2830
- formatDistance: formatDistance,
2831
- formatLong: formatLong,
2832
- formatRelative: formatRelative,
2833
- localize: localize,
2834
- match: match,
2835
- options: {
2836
- weekStartsOn: 1 /* Monday */,
2837
- firstWeekContainsDate: 4
2838
- }
2839
- };
2840
-
2841
- exports._typeof = _typeof;
2842
- exports.addMonths = addMonths;
2843
- exports.addYears = addYears;
2844
- exports.format = format;
2845
- exports.getDefaultOptions = getDefaultOptions;
2846
- exports.getTimezoneOffsetInMilliseconds = getTimezoneOffsetInMilliseconds;
2847
- exports.getUTCISOWeek = getUTCISOWeek;
2848
- exports.getUTCWeek = getUTCWeek;
2849
- exports.getUTCWeekYear = getUTCWeekYear;
2850
- exports.getYear = getYear;
2851
- exports.isAfter = isAfter;
2852
- exports.isBefore = isBefore;
2853
- exports.isProtectedDayOfYearToken = isProtectedDayOfYearToken;
2854
- exports.isProtectedWeekYearToken = isProtectedWeekYearToken;
2855
- exports.isSameDay = isSameDay;
2856
- exports.isValid = isValid;
2857
- exports.isWeekend = isWeekend;
2858
- exports.locale = locale$1;
2859
- exports.locale$1 = locale;
2860
- exports.longFormatters = longFormatters;
2861
- exports.requiredArgs = requiredArgs;
2862
- exports.setYear = setYear;
2863
- exports.startOfDay = startOfDay;
2864
- exports.startOfMonth = startOfMonth;
2865
- exports.startOfUTCISOWeek = startOfUTCISOWeek;
2866
- exports.startOfUTCWeek = startOfUTCWeek;
2867
- exports.subMilliseconds = subMilliseconds;
2868
- exports.subYears = subYears;
2869
- exports.throwProtectedError = throwProtectedError;
2870
- exports.toDate = toDate;
2871
- exports.toInteger = toInteger;