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