@utrecht/calendar-react 1.0.4 → 1.0.5

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.
package/dist/css.mjs CHANGED
@@ -1,429 +1,3661 @@
1
- import '@utrecht/calendar-css/src/index.scss';
2
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
1
  import { jsx, jsxs } from 'react/jsx-runtime';
4
- import { startOfWeek, endOfWeek, eachDayOfInterval, isSameDay, endOfDay, parseISO, setYear, getYear, addYears, setMonth, addMonths, format, isSameMonth, formatISO, isBefore, startOfDay, isAfter, startOfMonth, addWeeks } from 'date-fns';
5
- import { enUS } from 'date-fns/locale';
6
- import chunk from 'lodash.chunk';
7
- import { useState } from 'react';
8
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
9
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
10
- import { Button } from '@utrecht/button-react';
11
- import clsx$1, { clsx } from 'clsx';
12
-
13
- var _excluded$c = ["children"];
14
- function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
- function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
- var CalendarNavigation = function CalendarNavigation(_ref) {
17
- var children = _ref.children,
18
- props = _objectWithoutProperties(_ref, _excluded$c);
19
- return jsx("div", _objectSpread$c(_objectSpread$c({
20
- className: "utrecht-calendar__navigation"
21
- }, props), {}, {
22
- children: children
23
- }));
24
- };
25
-
26
- var _excluded$b = ["children", "className"];
27
- function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
- function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
- var CalendarButton = function CalendarButton(_ref) {
30
- var children = _ref.children,
31
- className = _ref.className,
32
- props = _objectWithoutProperties(_ref, _excluded$b);
33
- return jsx(Button, _objectSpread$b(_objectSpread$b({
34
- appearance: "subtle-button"
35
- }, props), {}, {
36
- className: clsx('utrecht-calendar__button', className),
37
- children: children
38
- }));
39
- };
40
-
41
- var _excluded$a = ["children"];
42
- function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
43
- function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
44
- var CalendarIcon = function CalendarIcon(_ref) {
45
- var children = _ref.children,
46
- props = _objectWithoutProperties(_ref, _excluded$a);
47
- return jsx("div", _objectSpread$a(_objectSpread$a({
48
- className: clsx('utrecht-calendar__icon')
49
- }, props), {}, {
50
- children: children
51
- }));
52
- };
53
-
54
- var _excluded$9 = ["onPreviousClick", "onNextClick", "previousIcon", "nextIcon", "children"];
55
- function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
56
- function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
57
- var CalendarNavigationButtons = function CalendarNavigationButtons(_ref) {
58
- var onPreviousClick = _ref.onPreviousClick,
59
- onNextClick = _ref.onNextClick,
60
- previousIcon = _ref.previousIcon,
61
- nextIcon = _ref.nextIcon,
62
- children = _ref.children,
63
- props = _objectWithoutProperties(_ref, _excluded$9);
64
- return jsxs("div", {
65
- className: "utrecht-calendar__navigation-buttons",
66
- children: [jsx(CalendarButton, _objectSpread$9(_objectSpread$9({
67
- onClick: onPreviousClick
68
- }, props), {}, {
69
- children: jsx(CalendarIcon, {
70
- children: previousIcon
71
- })
72
- })), children, jsx(CalendarButton, _objectSpread$9(_objectSpread$9({
73
- onClick: onNextClick
74
- }, props), {}, {
75
- children: jsx(CalendarIcon, {
76
- children: nextIcon
77
- })
78
- }))]
79
- });
80
- };
81
-
82
- var _excluded$8 = ["children"];
83
- function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
84
- function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
85
- var CalendarNavigationLabel = function CalendarNavigationLabel(_ref) {
86
- var children = _ref.children,
87
- props = _objectWithoutProperties(_ref, _excluded$8);
88
- return jsx("time", _objectSpread$8(_objectSpread$8({
89
- className: "utrecht-calendar__navigation-label"
90
- }, props), {}, {
91
- children: children
92
- }));
93
- };
94
-
95
- var _excluded$7 = ["children"];
96
- function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
97
- function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
98
- var CalendarTableDaysContainer = function CalendarTableDaysContainer(_ref) {
99
- var children = _ref.children,
100
- props = _objectWithoutProperties(_ref, _excluded$7);
101
- return jsx("tbody", _objectSpread$7(_objectSpread$7({}, props), {}, {
102
- className: "utrecht-calendar__table-days-container",
103
- children: children
104
- }));
105
- };
106
-
107
- var _excluded$6 = ["children"];
108
- function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
109
- function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
110
- var CalendarTableDaysItem = function CalendarTableDaysItem(_ref) {
111
- var children = _ref.children,
112
- props = _objectWithoutProperties(_ref, _excluded$6);
113
- return jsx("tr", _objectSpread$6(_objectSpread$6({}, props), {}, {
114
- children: children
115
- }));
116
- };
117
-
118
- var _excluded$5 = ["day", "dayOutOfTheMonth", "isToday", "emphasis", "selected", "disabled"];
119
- function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
120
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
121
- var CalendarTableDaysItemDay = function CalendarTableDaysItemDay(_ref) {
122
- var day = _ref.day,
123
- dayOutOfTheMonth = _ref.dayOutOfTheMonth,
124
- isToday = _ref.isToday,
125
- emphasis = _ref.emphasis,
126
- selected = _ref.selected,
127
- disabled = _ref.disabled,
128
- props = _objectWithoutProperties(_ref, _excluded$5);
129
- return jsx("td", {
130
- children: jsx(CalendarButton, _objectSpread$5(_objectSpread$5({
131
- className: clsx$1('utrecht-calendar__table-days-item-day', {
132
- 'utrecht-calendar__table-days-item-day--out-of-the-month': dayOutOfTheMonth
133
- }, {
134
- 'utrecht-calendar__table-days-item-day--is-today': isToday
135
- }, {
136
- 'utrecht-calendar__table-days-item-day--emphasis': emphasis
137
- }, {
138
- 'utrecht-calendar__table-days-item-day--selected': selected
139
- }),
140
- disabled: disabled
141
- }, props), {}, {
142
- children: day
143
- }))
144
- });
145
- };
146
-
147
- var CalendarTableWeeksContainer = function CalendarTableWeeksContainer(_ref) {
148
- var children = _ref.children;
149
- return jsx("thead", {
150
- className: "utrecht-calendar__table-weeks-container",
151
- children: jsx("tr", {
152
- className: "utrecht-calendar__table-weeks-container-content",
153
- children: children
154
- })
155
- });
156
- };
157
-
158
- var _excluded$4 = ["children"];
159
- function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
160
- function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
161
- var CalendarTableWeeksItem = function CalendarTableWeeksItem(_ref) {
162
- var children = _ref.children,
163
- props = _objectWithoutProperties(_ref, _excluded$4);
164
- return jsx("th", _objectSpread$4(_objectSpread$4({}, props), {}, {
165
- className: "utrecht-calendar__table-weeks-item",
166
- children: children
167
- }));
168
- };
169
-
170
- var _excluded$3 = ["title", "titleId"];
171
- function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
172
- function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
173
- var IconArrowLeft = function IconArrowLeft(_ref) {
174
- var title = _ref.title,
175
- titleId = _ref.titleId,
176
- props = _objectWithoutProperties(_ref, _excluded$3);
177
- return jsxs("svg", _objectSpread$3(_objectSpread$3({
178
- width: "100%",
179
- height: "100%",
180
- fill: "none",
181
- xmlns: "http://www.w3.org/2000/svg",
182
- "aria-labelledby": titleId
183
- }, props), {}, {
184
- children: [title ? jsx("title", {
185
- id: titleId,
186
- children: title
187
- }) : null, jsx("path", {
188
- d: "M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41Z",
189
- fill: "currentColor"
190
- })]
191
- }));
192
- };
193
-
194
- var _excluded$2 = ["title", "titleId"];
195
- function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
196
- function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
197
- var IconArrowLeftDouble = function IconArrowLeftDouble(_ref) {
198
- var title = _ref.title,
199
- titleId = _ref.titleId,
200
- props = _objectWithoutProperties(_ref, _excluded$2);
201
- return jsxs("svg", _objectSpread$2(_objectSpread$2({
202
- width: "100%",
203
- height: "100%",
204
- fill: "none",
205
- xmlns: "http://www.w3.org/2000/svg",
206
- "aria-labelledby": titleId
207
- }, props), {}, {
208
- children: [title ? jsx("title", {
209
- id: titleId,
210
- children: title
211
- }) : null, jsx("path", {
212
- d: "M17.59 18 19 16.59 14.42 12 19 7.41 17.59 6l-6 6 6 6Z",
213
- fill: "currentColor"
214
- }), jsx("path", {
215
- d: "m11 18 1.41-1.41L7.83 12l4.58-4.59L11 6l-6 6 6 6Z",
216
- fill: "currentColor"
217
- })]
218
- }));
219
- };
220
-
221
- var _excluded$1 = ["title", "titleId"];
222
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
223
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
224
- var IconArrowRight = function IconArrowRight(_ref) {
225
- var title = _ref.title,
226
- titleId = _ref.titleId,
227
- props = _objectWithoutProperties(_ref, _excluded$1);
228
- return jsxs("svg", _objectSpread$1(_objectSpread$1({
229
- width: "100%",
230
- height: "100%",
231
- fill: "none",
232
- xmlns: "http://www.w3.org/2000/svg",
233
- "aria-labelledby": titleId
234
- }, props), {}, {
235
- children: [title ? jsx("title", {
236
- id: titleId,
237
- children: title
238
- }) : null, jsx("path", {
239
- d: "M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41Z",
240
- fill: "currentColor"
241
- })]
242
- }));
243
- };
244
-
245
- var _excluded = ["title", "titleId"];
246
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
247
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
248
- var IconArrowRightDouble = function IconArrowRightDouble(_ref) {
249
- var title = _ref.title,
250
- titleId = _ref.titleId,
251
- props = _objectWithoutProperties(_ref, _excluded);
252
- return jsxs("svg", _objectSpread(_objectSpread({
253
- fill: "none",
254
- width: "100%",
255
- height: "100%",
256
- xmlns: "http://www.w3.org/2000/svg",
257
- "aria-labelledby": titleId
258
- }, props), {}, {
259
- children: [title ? jsx("title", {
260
- id: titleId,
261
- children: title
262
- }) : null, jsx("path", {
263
- d: "M6.41 6 5 7.41 9.58 12 5 16.59 6.41 18l6-6-6-6Z",
264
- fill: "currentColor"
265
- }), jsx("path", {
266
- d: "m13 6-1.41 1.41L16.17 12l-4.58 4.59L13 18l6-6-6-6Z",
267
- fill: "currentColor"
268
- })]
269
- }));
2
+ import { forwardRef, useState } from 'react';
3
+ import _typeof from '@babel/runtime/helpers/esm/typeof';
4
+
5
+ var css = ".utrecht-calendar{background-color:var(--utrecht-calendar-background-color);inline-size:fit-content}.utrecht-calendar__table{margin-inline:auto;padding-block-end:var(--utrecht-calendar-table-padding-block-end);padding-block-start:var(--utrecht-calendar-table-padding-block-start)}.utrecht-calendar__table-weeks-item{inline-size:var(--utrecht-calendar-table-weeks-item-width);line-height:var(--utrecht-calendar-table-weeks-item-line-height,inherit);padding-block-end:var(--utrecht-calendar-table-weeks-item-padding-block-end);padding-block-start:var(--utrecht-calendar-table-weeks-item-padding-block-start)}.utrecht-calendar__table-days-item-day{--utrecht-calendar-button-border-color:var(--utrecht-calendar-table-days-item-day-border-color);--utrecht-calendar-button-border-width:var(--utrecht-calendar-table-days-item-day-border-width);--utrecht-calendar-button-color:var(--utrecht-calendar-table-days-item-day-color);block-size:var(--utrecht-calendar-table-days-item-day-size);inline-size:var(--utrecht-calendar-table-days-item-day-size)}.utrecht-calendar__table-days-item-day:hover{--utrecht-calendar-button-hover-background-color:var(--utrecht-calendar-table-days-item-day-hover-background-color);--utrecht-calendar-button-hover-border-color:var(--utrecht-calendar-table-days-item-day-hover-border-color);--utrecht-calendar-button-hover-color:var(--utrecht-calendar-table-days-item-day-hover-color)}.utrecht-calendar__table-days-item-day:focus{--utrecht-calendar-button-focus-background-color:var(--utrecht-calendar-table-days-item-day-focus-background-color);--utrecht-calendar-button-focus-border-color:var(--utrecht-calendar-table-days-item-day-focus-border-color);--utrecht-calendar-button-focus-color:var(--utrecht-calendar-table-days-item-day-focus-color)}.utrecht-calendar__table-days-item-day:active{--utrecht-calendar-button-active-background-color:var(\n --utrecht-calendar-table-days-item-day-active-background-color\n );--utrecht-calendar-button-active-border-color:var(--utrecht-calendar-table-days-item-day-active-border-color);--utrecht-calendar-button-active-color:var(--utrecht-calendar-table-days-item-day-active-color)}.utrecht-calendar__table-days-item-day:disabled{--utrecht-calendar-button-disabled-background-color:var(\n --utrecht-calendar-table-days-item-day-disabled-background-color\n );--utrecht-calendar-button-disabled-border-color:var(--utrecht-calendar-table-days-item-day-disabled-border-color);--utrecht-calendar-button-disabled-color:var(--utrecht-calendar-table-days-item-day-disabled-color)}.utrecht-calendar__table-days-item-day--out-of-the-month{--utrecht-calendar-button-background-color:var(\n --utrecht-calendar-table-days-item-day-out-of-the-month-background-color\n );--utrecht-calendar-button-border-color:var(--utrecht-calendar-table-days-item-day-out-of-the-month-border-color);--utrecht-calendar-button-color:var(--utrecht-calendar-table-days-item-day-out-of-the-month-color)}.utrecht-calendar__table-days-item-day--is-today{--utrecht-calendar-button-font-weight:var(--utrecht-calendar-table-days-item-day-is-today-font-weight);--utrecht-calendar-button-background-color:var(--utrecht-calendar-table-days-item-day-is-today-background-color);--utrecht-calendar-button-border-color:var(--utrecht-calendar-table-days-item-day-is-today-border-color);--utrecht-calendar-button-color:var(--utrecht-calendar-table-days-item-day-is-today-color)}.utrecht-calendar__table-days-item-day--emphasis{--utrecht-calendar-button-font-weight:var(--utrecht-calendar-table-days-item-day-emphasis-font-weight);--utrecht-calendar-button-background-color:var(--utrecht-calendar-table-days-item-day-emphasis-background-color);--utrecht-calendar-button-border-color:var(--utrecht-calendar-table-days-item-day-emphasis-border-color);--utrecht-calendar-button-color:var(--utrecht-calendar-table-days-item-day-emphasis-color)}.utrecht-calendar__table-days-item-day--selected{--utrecht-calendar-button-font-weight:var(--utrecht-calendar-table-days-item-day-selected-font-weight);--utrecht-calendar-button-background-color:var(--utrecht-calendar-table-days-item-day-selected-background-color);--utrecht-calendar-button-border-color:var(--utrecht-calendar-table-days-item-day-selected-border-color);--utrecht-calendar-button-color:var(--utrecht-calendar-table-days-item-day-selected-color)}.utrecht-calendar__navigation{background-color:var(--utrecht-calendar-navigation-background-color);color:var(--utrecht-calendar-navigation-color);padding-block-end:var(--utrecht-calendar-navigation-padding-block-end);padding-block-start:var(--utrecht-calendar-navigation-padding-block-start)}.utrecht-calendar__navigation-label{color:var(--utrecht-calendar-navigation-label-color);font-size:var(--utrecht-calendar-navigation-label-font-size);text-align:center}.utrecht-calendar__navigation-buttons{align-items:center;display:flex;flex-grow:1;justify-content:space-between}.utrecht-calendar__button{--utrecht-button-subtle-color:var(--utrecht-calendar-button-color,currentColor);--utrecht-button-subtle-background-color:var(--utrecht-calendar-button-background-color,transparent);--utrecht-button-subtle-border-color:var(--utrecht-calendar-button-border-color,transparent);--utrecht-button-subtle-border-width:var(--utrecht-calendar-button-border-width);--utrecht-button-font-weight:var(--utrecht-calendar-button-font-weight);--utrecht-button-subtle-focus-background-color:var(--utrecht-calendar-button-focus-background-color);--utrecht-button-subtle-focus-border-color:var(--utrecht-calendar-button-focus-border-color);--utrecht-button-subtle-focus-color:var(--utrecht-calendar-button-focus-color);--utrecht-button-subtle-active-background-color:var(--utrecht-calendar-button-active-background-color);--utrecht-button-subtle-active-border-color:var(--utrecht-calendar-button-active-border-color);--utrecht-button-subtle-active-color:var(--utrecht-calendar-button-active-color);--utrecht-button-subtle-hover-background-color:var(--utrecht-calendar-button-hover-background-color);--utrecht-button-subtle-hover-border-color:var(--utrecht-calendar-button-hover-border-color,transparent);--utrecht-button-subtle-hover-color:var(--utrecht-calendar-button-hover-color);--utrecht-button-subtle-disabled-background-color:var(--utrecht-calendar-button-disabled-background-color);--utrecht-button-subtle-disabled-border-color:var(--utrecht-calendar-button-disabled-border-color);--utrecht-button-subtle-disabled-color:var(--utrecht-calendar-button-disabled-color);--utrecht-button-padding-block-end:var(--utrecht-calendar-button-padding-block-end,0);--utrecht-button-padding-block-start:var(--utrecht-calendar-button-padding-block-start,0);--utrecht-button-padding-inline-end:var(--utrecht-calendar-button-padding-inline-end,0);--utrecht-button-padding-inline-start:var(--utrecht-calendar-button-padding-inline-start,0);cursor:pointer}.utrecht-calendar__icon{block-size:var(--utrecht-calendar-icon-size);inline-size:var(--utrecht-calendar-icon-size)}";
6
+
7
+ const insertStyle = function (css) {
8
+ if (typeof document !== 'undefined') {
9
+ var head = document.head || document.getElementsByTagName('head')[0];
10
+ var style = document.createElement('style');
11
+ style.appendChild(document.createTextNode(css));
12
+ head.appendChild(style);
13
+ }
14
+ };
15
+
16
+ function toInteger$1(dirtyNumber) {
17
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
18
+ return NaN;
19
+ }
20
+ var number = Number(dirtyNumber);
21
+ if (isNaN(number)) {
22
+ return number;
23
+ }
24
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
25
+ }
26
+
27
+ function requiredArgs(required, args) {
28
+ if (args.length < required) {
29
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
30
+ }
31
+ }
32
+
33
+ /**
34
+ * @name toDate
35
+ * @category Common Helpers
36
+ * @summary Convert the given argument to an instance of Date.
37
+ *
38
+ * @description
39
+ * Convert the given argument to an instance of Date.
40
+ *
41
+ * If the argument is an instance of Date, the function returns its clone.
42
+ *
43
+ * If the argument is a number, it is treated as a timestamp.
44
+ *
45
+ * If the argument is none of the above, the function returns Invalid Date.
46
+ *
47
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
48
+ *
49
+ * @param {Date|Number} argument - the value to convert
50
+ * @returns {Date} the parsed date in the local time zone
51
+ * @throws {TypeError} 1 argument required
52
+ *
53
+ * @example
54
+ * // Clone the date:
55
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
56
+ * //=> Tue Feb 11 2014 11:30:30
57
+ *
58
+ * @example
59
+ * // Convert the timestamp to date:
60
+ * const result = toDate(1392098430000)
61
+ * //=> Tue Feb 11 2014 11:30:30
62
+ */
63
+ function toDate(argument) {
64
+ requiredArgs(1, arguments);
65
+ var argStr = Object.prototype.toString.call(argument);
66
+
67
+ // Clone the date
68
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
69
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
70
+ return new Date(argument.getTime());
71
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
72
+ return new Date(argument);
73
+ } else {
74
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
75
+ // eslint-disable-next-line no-console
76
+ 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");
77
+ // eslint-disable-next-line no-console
78
+ console.warn(new Error().stack);
79
+ }
80
+ return new Date(NaN);
81
+ }
82
+ }
83
+
84
+ /**
85
+ * @name addDays
86
+ * @category Day Helpers
87
+ * @summary Add the specified number of days to the given date.
88
+ *
89
+ * @description
90
+ * Add the specified number of days to the given date.
91
+ *
92
+ * @param {Date|Number} date - the date to be changed
93
+ * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
94
+ * @returns {Date} - the new date with the days added
95
+ * @throws {TypeError} - 2 arguments required
96
+ *
97
+ * @example
98
+ * // Add 10 days to 1 September 2014:
99
+ * const result = addDays(new Date(2014, 8, 1), 10)
100
+ * //=> Thu Sep 11 2014 00:00:00
101
+ */
102
+ function addDays(dirtyDate, dirtyAmount) {
103
+ requiredArgs(2, arguments);
104
+ var date = toDate(dirtyDate);
105
+ var amount = toInteger$1(dirtyAmount);
106
+ if (isNaN(amount)) {
107
+ return new Date(NaN);
108
+ }
109
+ if (!amount) {
110
+ // If 0 days, no-op to avoid changing times in the hour before end of DST
111
+ return date;
112
+ }
113
+ date.setDate(date.getDate() + amount);
114
+ return date;
115
+ }
116
+
117
+ /**
118
+ * @name addMonths
119
+ * @category Month Helpers
120
+ * @summary Add the specified number of months to the given date.
121
+ *
122
+ * @description
123
+ * Add the specified number of months to the given date.
124
+ *
125
+ * @param {Date|Number} date - the date to be changed
126
+ * @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`.
127
+ * @returns {Date} the new date with the months added
128
+ * @throws {TypeError} 2 arguments required
129
+ *
130
+ * @example
131
+ * // Add 5 months to 1 September 2014:
132
+ * const result = addMonths(new Date(2014, 8, 1), 5)
133
+ * //=> Sun Feb 01 2015 00:00:00
134
+ */
135
+ function addMonths(dirtyDate, dirtyAmount) {
136
+ requiredArgs(2, arguments);
137
+ var date = toDate(dirtyDate);
138
+ var amount = toInteger$1(dirtyAmount);
139
+ if (isNaN(amount)) {
140
+ return new Date(NaN);
141
+ }
142
+ if (!amount) {
143
+ // If 0 months, no-op to avoid changing times in the hour before end of DST
144
+ return date;
145
+ }
146
+ var dayOfMonth = date.getDate();
147
+
148
+ // The JS Date object supports date math by accepting out-of-bounds values for
149
+ // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
150
+ // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
151
+ // want except that dates will wrap around the end of a month, meaning that
152
+ // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
153
+ // we'll default to the end of the desired month by adding 1 to the desired
154
+ // month and using a date of 0 to back up one day to the end of the desired
155
+ // month.
156
+ var endOfDesiredMonth = new Date(date.getTime());
157
+ endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);
158
+ var daysInMonth = endOfDesiredMonth.getDate();
159
+ if (dayOfMonth >= daysInMonth) {
160
+ // If we're already at the end of the month, then this is the correct date
161
+ // and we're done.
162
+ return endOfDesiredMonth;
163
+ } else {
164
+ // Otherwise, we now know that setting the original day-of-month value won't
165
+ // cause an overflow, so set the desired day-of-month. Note that we can't
166
+ // just set the date of `endOfDesiredMonth` because that object may have had
167
+ // its time changed in the unusual case where where a DST transition was on
168
+ // the last day of the month and its local time was in the hour skipped or
169
+ // repeated next to a DST transition. So we use `date` instead which is
170
+ // guaranteed to still have the original time.
171
+ date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
172
+ return date;
173
+ }
174
+ }
175
+
176
+ /**
177
+ * @name addMilliseconds
178
+ * @category Millisecond Helpers
179
+ * @summary Add the specified number of milliseconds to the given date.
180
+ *
181
+ * @description
182
+ * Add the specified number of milliseconds to the given date.
183
+ *
184
+ * @param {Date|Number} date - the date to be changed
185
+ * @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`.
186
+ * @returns {Date} the new date with the milliseconds added
187
+ * @throws {TypeError} 2 arguments required
188
+ *
189
+ * @example
190
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
191
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
192
+ * //=> Thu Jul 10 2014 12:45:30.750
193
+ */
194
+ function addMilliseconds(dirtyDate, dirtyAmount) {
195
+ requiredArgs(2, arguments);
196
+ var timestamp = toDate(dirtyDate).getTime();
197
+ var amount = toInteger$1(dirtyAmount);
198
+ return new Date(timestamp + amount);
199
+ }
200
+
201
+ var defaultOptions = {};
202
+ function getDefaultOptions() {
203
+ return defaultOptions;
204
+ }
205
+
206
+ /**
207
+ * @name startOfWeek
208
+ * @category Week Helpers
209
+ * @summary Return the start of a week for the given date.
210
+ *
211
+ * @description
212
+ * Return the start of a week for the given date.
213
+ * The result will be in the local timezone.
214
+ *
215
+ * @param {Date|Number} date - the original date
216
+ * @param {Object} [options] - an object with options.
217
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
218
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
219
+ * @returns {Date} the start of a week
220
+ * @throws {TypeError} 1 argument required
221
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
222
+ *
223
+ * @example
224
+ * // The start of a week for 2 September 2014 11:55:00:
225
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
226
+ * //=> Sun Aug 31 2014 00:00:00
227
+ *
228
+ * @example
229
+ * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
230
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
231
+ * //=> Mon Sep 01 2014 00:00:00
232
+ */
233
+ function startOfWeek(dirtyDate, options) {
234
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
235
+ requiredArgs(1, arguments);
236
+ var defaultOptions = getDefaultOptions();
237
+ var weekStartsOn = toInteger$1((_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);
238
+
239
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
240
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
241
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
242
+ }
243
+ var date = toDate(dirtyDate);
244
+ var day = date.getDay();
245
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
246
+ date.setDate(date.getDate() - diff);
247
+ date.setHours(0, 0, 0, 0);
248
+ return date;
249
+ }
250
+
251
+ /**
252
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
253
+ * They usually appear for dates that denote time before the timezones were introduced
254
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
255
+ * and GMT+01:00:00 after that date)
256
+ *
257
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
258
+ * which would lead to incorrect calculations.
259
+ *
260
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
261
+ */
262
+ function getTimezoneOffsetInMilliseconds(date) {
263
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
264
+ utcDate.setUTCFullYear(date.getFullYear());
265
+ return date.getTime() - utcDate.getTime();
266
+ }
267
+
268
+ /**
269
+ * @name startOfDay
270
+ * @category Day Helpers
271
+ * @summary Return the start of a day for the given date.
272
+ *
273
+ * @description
274
+ * Return the start of a day for the given date.
275
+ * The result will be in the local timezone.
276
+ *
277
+ * @param {Date|Number} date - the original date
278
+ * @returns {Date} the start of a day
279
+ * @throws {TypeError} 1 argument required
280
+ *
281
+ * @example
282
+ * // The start of a day for 2 September 2014 11:55:00:
283
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
284
+ * //=> Tue Sep 02 2014 00:00:00
285
+ */
286
+ function startOfDay(dirtyDate) {
287
+ requiredArgs(1, arguments);
288
+ var date = toDate(dirtyDate);
289
+ date.setHours(0, 0, 0, 0);
290
+ return date;
291
+ }
292
+
293
+ /**
294
+ * @name addWeeks
295
+ * @category Week Helpers
296
+ * @summary Add the specified number of weeks to the given date.
297
+ *
298
+ * @description
299
+ * Add the specified number of week to the given date.
300
+ *
301
+ * @param {Date|Number} date - the date to be changed
302
+ * @param {Number} amount - the amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
303
+ * @returns {Date} the new date with the weeks added
304
+ * @throws {TypeError} 2 arguments required
305
+ *
306
+ * @example
307
+ * // Add 4 weeks to 1 September 2014:
308
+ * const result = addWeeks(new Date(2014, 8, 1), 4)
309
+ * //=> Mon Sep 29 2014 00:00:00
310
+ */
311
+ function addWeeks(dirtyDate, dirtyAmount) {
312
+ requiredArgs(2, arguments);
313
+ var amount = toInteger$1(dirtyAmount);
314
+ var days = amount * 7;
315
+ return addDays(dirtyDate, days);
316
+ }
317
+
318
+ /**
319
+ * @name addYears
320
+ * @category Year Helpers
321
+ * @summary Add the specified number of years to the given date.
322
+ *
323
+ * @description
324
+ * Add the specified number of years to the given date.
325
+ *
326
+ * @param {Date|Number} date - the date to be changed
327
+ * @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`.
328
+ * @returns {Date} the new date with the years added
329
+ * @throws {TypeError} 2 arguments required
330
+ *
331
+ * @example
332
+ * // Add 5 years to 1 September 2014:
333
+ * const result = addYears(new Date(2014, 8, 1), 5)
334
+ * //=> Sun Sep 01 2019 00:00:00
335
+ */
336
+ function addYears(dirtyDate, dirtyAmount) {
337
+ requiredArgs(2, arguments);
338
+ var amount = toInteger$1(dirtyAmount);
339
+ return addMonths(dirtyDate, amount * 12);
340
+ }
341
+
342
+ /**
343
+ * Days in 1 week.
344
+ *
345
+ * @name daysInWeek
346
+ * @constant
347
+ * @type {number}
348
+ * @default
349
+ */
350
+
351
+ /**
352
+ * Milliseconds in 1 minute
353
+ *
354
+ * @name millisecondsInMinute
355
+ * @constant
356
+ * @type {number}
357
+ * @default
358
+ */
359
+ var millisecondsInMinute = 60000;
360
+
361
+ /**
362
+ * Milliseconds in 1 hour
363
+ *
364
+ * @name millisecondsInHour
365
+ * @constant
366
+ * @type {number}
367
+ * @default
368
+ */
369
+ var millisecondsInHour = 3600000;
370
+
371
+ /**
372
+ * @name isSameDay
373
+ * @category Day Helpers
374
+ * @summary Are the given dates in the same day (and year and month)?
375
+ *
376
+ * @description
377
+ * Are the given dates in the same day (and year and month)?
378
+ *
379
+ * @param {Date|Number} dateLeft - the first date to check
380
+ * @param {Date|Number} dateRight - the second date to check
381
+ * @returns {Boolean} the dates are in the same day (and year and month)
382
+ * @throws {TypeError} 2 arguments required
383
+ *
384
+ * @example
385
+ * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
386
+ * const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
387
+ * //=> true
388
+ *
389
+ * @example
390
+ * // Are 4 September and 4 October in the same day?
391
+ * const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
392
+ * //=> false
393
+ *
394
+ * @example
395
+ * // Are 4 September, 2014 and 4 September, 2015 in the same day?
396
+ * const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
397
+ * //=> false
398
+ */
399
+ function isSameDay(dirtyDateLeft, dirtyDateRight) {
400
+ requiredArgs(2, arguments);
401
+ var dateLeftStartOfDay = startOfDay(dirtyDateLeft);
402
+ var dateRightStartOfDay = startOfDay(dirtyDateRight);
403
+ return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime();
404
+ }
405
+
406
+ /**
407
+ * @name isDate
408
+ * @category Common Helpers
409
+ * @summary Is the given value a date?
410
+ *
411
+ * @description
412
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
413
+ *
414
+ * @param {*} value - the value to check
415
+ * @returns {boolean} true if the given value is a date
416
+ * @throws {TypeError} 1 arguments required
417
+ *
418
+ * @example
419
+ * // For a valid date:
420
+ * const result = isDate(new Date())
421
+ * //=> true
422
+ *
423
+ * @example
424
+ * // For an invalid date:
425
+ * const result = isDate(new Date(NaN))
426
+ * //=> true
427
+ *
428
+ * @example
429
+ * // For some value:
430
+ * const result = isDate('2014-02-31')
431
+ * //=> false
432
+ *
433
+ * @example
434
+ * // For an object:
435
+ * const result = isDate({})
436
+ * //=> false
437
+ */
438
+ function isDate(value) {
439
+ requiredArgs(1, arguments);
440
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
441
+ }
442
+
443
+ /**
444
+ * @name isValid
445
+ * @category Common Helpers
446
+ * @summary Is the given date valid?
447
+ *
448
+ * @description
449
+ * Returns false if argument is Invalid Date and true otherwise.
450
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
451
+ * Invalid Date is a Date, whose time value is NaN.
452
+ *
453
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
454
+ *
455
+ * @param {*} date - the date to check
456
+ * @returns {Boolean} the date is valid
457
+ * @throws {TypeError} 1 argument required
458
+ *
459
+ * @example
460
+ * // For the valid date:
461
+ * const result = isValid(new Date(2014, 1, 31))
462
+ * //=> true
463
+ *
464
+ * @example
465
+ * // For the value, convertable into a date:
466
+ * const result = isValid(1393804800000)
467
+ * //=> true
468
+ *
469
+ * @example
470
+ * // For the invalid date:
471
+ * const result = isValid(new Date(''))
472
+ * //=> false
473
+ */
474
+ function isValid(dirtyDate) {
475
+ requiredArgs(1, arguments);
476
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
477
+ return false;
478
+ }
479
+ var date = toDate(dirtyDate);
480
+ return !isNaN(Number(date));
481
+ }
482
+
483
+ /**
484
+ * @name endOfDay
485
+ * @category Day Helpers
486
+ * @summary Return the end of a day for the given date.
487
+ *
488
+ * @description
489
+ * Return the end of a day for the given date.
490
+ * The result will be in the local timezone.
491
+ *
492
+ * @param {Date|Number} date - the original date
493
+ * @returns {Date} the end of a day
494
+ * @throws {TypeError} 1 argument required
495
+ *
496
+ * @example
497
+ * // The end of a day for 2 September 2014 11:55:00:
498
+ * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
499
+ * //=> Tue Sep 02 2014 23:59:59.999
500
+ */
501
+ function endOfDay(dirtyDate) {
502
+ requiredArgs(1, arguments);
503
+ var date = toDate(dirtyDate);
504
+ date.setHours(23, 59, 59, 999);
505
+ return date;
506
+ }
507
+
508
+ /**
509
+ * @name eachDayOfInterval
510
+ * @category Interval Helpers
511
+ * @summary Return the array of dates within the specified time interval.
512
+ *
513
+ * @description
514
+ * Return the array of dates within the specified time interval.
515
+ *
516
+ * @param {Interval} interval - the interval. See [Interval]{@link https://date-fns.org/docs/Interval}
517
+ * @param {Object} [options] - an object with options.
518
+ * @param {Number} [options.step=1] - the step to increment by. The value should be more than 1.
519
+ * @returns {Date[]} the array with starts of days from the day of the interval start to the day of the interval end
520
+ * @throws {TypeError} 1 argument required
521
+ * @throws {RangeError} `options.step` must be a number greater than 1
522
+ * @throws {RangeError} The start of an interval cannot be after its end
523
+ * @throws {RangeError} Date in interval cannot be `Invalid Date`
524
+ *
525
+ * @example
526
+ * // Each day between 6 October 2014 and 10 October 2014:
527
+ * const result = eachDayOfInterval({
528
+ * start: new Date(2014, 9, 6),
529
+ * end: new Date(2014, 9, 10)
530
+ * })
531
+ * //=> [
532
+ * // Mon Oct 06 2014 00:00:00,
533
+ * // Tue Oct 07 2014 00:00:00,
534
+ * // Wed Oct 08 2014 00:00:00,
535
+ * // Thu Oct 09 2014 00:00:00,
536
+ * // Fri Oct 10 2014 00:00:00
537
+ * // ]
538
+ */
539
+ function eachDayOfInterval(dirtyInterval, options) {
540
+ var _options$step;
541
+ requiredArgs(1, arguments);
542
+ var interval = dirtyInterval || {};
543
+ var startDate = toDate(interval.start);
544
+ var endDate = toDate(interval.end);
545
+ var endTime = endDate.getTime();
546
+
547
+ // Throw an exception if start date is after end date or if any date is `Invalid Date`
548
+ if (!(startDate.getTime() <= endTime)) {
549
+ throw new RangeError('Invalid interval');
550
+ }
551
+ var dates = [];
552
+ var currentDate = startDate;
553
+ currentDate.setHours(0, 0, 0, 0);
554
+ var step = Number((_options$step = void 0 ) !== null && _options$step !== void 0 ? _options$step : 1);
555
+ if (step < 1 || isNaN(step)) throw new RangeError('`options.step` must be a number greater than 1');
556
+ while (currentDate.getTime() <= endTime) {
557
+ dates.push(toDate(currentDate));
558
+ currentDate.setDate(currentDate.getDate() + step);
559
+ currentDate.setHours(0, 0, 0, 0);
560
+ }
561
+ return dates;
562
+ }
563
+
564
+ /**
565
+ * @name startOfMonth
566
+ * @category Month Helpers
567
+ * @summary Return the start of a month for the given date.
568
+ *
569
+ * @description
570
+ * Return the start of a month for the given date.
571
+ * The result will be in the local timezone.
572
+ *
573
+ * @param {Date|Number} date - the original date
574
+ * @returns {Date} the start of a month
575
+ * @throws {TypeError} 1 argument required
576
+ *
577
+ * @example
578
+ * // The start of a month for 2 September 2014 11:55:00:
579
+ * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
580
+ * //=> Mon Sep 01 2014 00:00:00
581
+ */
582
+ function startOfMonth(dirtyDate) {
583
+ requiredArgs(1, arguments);
584
+ var date = toDate(dirtyDate);
585
+ date.setDate(1);
586
+ date.setHours(0, 0, 0, 0);
587
+ return date;
588
+ }
589
+
590
+ /**
591
+ * @name endOfWeek
592
+ * @category Week Helpers
593
+ * @summary Return the end of a week for the given date.
594
+ *
595
+ * @description
596
+ * Return the end of a week for the given date.
597
+ * The result will be in the local timezone.
598
+ *
599
+ * @param {Date|Number} date - the original date
600
+ * @param {Object} [options] - an object with options.
601
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
602
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
603
+ * @returns {Date} the end of a week
604
+ * @throws {TypeError} 1 argument required
605
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
606
+ *
607
+ * @example
608
+ * // The end of a week for 2 September 2014 11:55:00:
609
+ * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
610
+ * //=> Sat Sep 06 2014 23:59:59.999
611
+ *
612
+ * @example
613
+ * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
614
+ * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
615
+ * //=> Sun Sep 07 2014 23:59:59.999
616
+ */
617
+ function endOfWeek(dirtyDate, options) {
618
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
619
+ requiredArgs(1, arguments);
620
+ var defaultOptions = getDefaultOptions();
621
+ var weekStartsOn = toInteger$1((_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);
622
+
623
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
624
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
625
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
626
+ }
627
+ var date = toDate(dirtyDate);
628
+ var day = date.getDay();
629
+ var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
630
+ date.setDate(date.getDate() + diff);
631
+ date.setHours(23, 59, 59, 999);
632
+ return date;
633
+ }
634
+
635
+ /**
636
+ * @name subMilliseconds
637
+ * @category Millisecond Helpers
638
+ * @summary Subtract the specified number of milliseconds from the given date.
639
+ *
640
+ * @description
641
+ * Subtract the specified number of milliseconds from the given date.
642
+ *
643
+ * @param {Date|Number} date - the date to be changed
644
+ * @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`.
645
+ * @returns {Date} the new date with the milliseconds subtracted
646
+ * @throws {TypeError} 2 arguments required
647
+ *
648
+ * @example
649
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
650
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
651
+ * //=> Thu Jul 10 2014 12:45:29.250
652
+ */
653
+ function subMilliseconds(dirtyDate, dirtyAmount) {
654
+ requiredArgs(2, arguments);
655
+ var amount = toInteger$1(dirtyAmount);
656
+ return addMilliseconds(dirtyDate, -amount);
657
+ }
658
+
659
+ var MILLISECONDS_IN_DAY = 86400000;
660
+ function getUTCDayOfYear(dirtyDate) {
661
+ requiredArgs(1, arguments);
662
+ var date = toDate(dirtyDate);
663
+ var timestamp = date.getTime();
664
+ date.setUTCMonth(0, 1);
665
+ date.setUTCHours(0, 0, 0, 0);
666
+ var startOfYearTimestamp = date.getTime();
667
+ var difference = timestamp - startOfYearTimestamp;
668
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
669
+ }
670
+
671
+ function startOfUTCISOWeek(dirtyDate) {
672
+ requiredArgs(1, arguments);
673
+ var weekStartsOn = 1;
674
+ var date = toDate(dirtyDate);
675
+ var day = date.getUTCDay();
676
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
677
+ date.setUTCDate(date.getUTCDate() - diff);
678
+ date.setUTCHours(0, 0, 0, 0);
679
+ return date;
680
+ }
681
+
682
+ function getUTCISOWeekYear(dirtyDate) {
683
+ requiredArgs(1, arguments);
684
+ var date = toDate(dirtyDate);
685
+ var year = date.getUTCFullYear();
686
+ var fourthOfJanuaryOfNextYear = new Date(0);
687
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
688
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
689
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
690
+ var fourthOfJanuaryOfThisYear = new Date(0);
691
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
692
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
693
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
694
+ if (date.getTime() >= startOfNextYear.getTime()) {
695
+ return year + 1;
696
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
697
+ return year;
698
+ } else {
699
+ return year - 1;
700
+ }
701
+ }
702
+
703
+ function startOfUTCISOWeekYear(dirtyDate) {
704
+ requiredArgs(1, arguments);
705
+ var year = getUTCISOWeekYear(dirtyDate);
706
+ var fourthOfJanuary = new Date(0);
707
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
708
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
709
+ var date = startOfUTCISOWeek(fourthOfJanuary);
710
+ return date;
711
+ }
712
+
713
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
714
+ function getUTCISOWeek(dirtyDate) {
715
+ requiredArgs(1, arguments);
716
+ var date = toDate(dirtyDate);
717
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
718
+
719
+ // Round the number of days to the nearest integer
720
+ // because the number of milliseconds in a week is not constant
721
+ // (e.g. it's different in the week of the daylight saving time clock shift)
722
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
723
+ }
724
+
725
+ function startOfUTCWeek(dirtyDate, options) {
726
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
727
+ requiredArgs(1, arguments);
728
+ var defaultOptions = getDefaultOptions();
729
+ var weekStartsOn = toInteger$1((_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);
730
+
731
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
732
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
733
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
734
+ }
735
+ var date = toDate(dirtyDate);
736
+ var day = date.getUTCDay();
737
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
738
+ date.setUTCDate(date.getUTCDate() - diff);
739
+ date.setUTCHours(0, 0, 0, 0);
740
+ return date;
741
+ }
742
+
743
+ function getUTCWeekYear(dirtyDate, options) {
744
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
745
+ requiredArgs(1, arguments);
746
+ var date = toDate(dirtyDate);
747
+ var year = date.getUTCFullYear();
748
+ var defaultOptions = getDefaultOptions();
749
+ var firstWeekContainsDate = toInteger$1((_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);
750
+
751
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
752
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
753
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
754
+ }
755
+ var firstWeekOfNextYear = new Date(0);
756
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
757
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
758
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
759
+ var firstWeekOfThisYear = new Date(0);
760
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
761
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
762
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
763
+ if (date.getTime() >= startOfNextYear.getTime()) {
764
+ return year + 1;
765
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
766
+ return year;
767
+ } else {
768
+ return year - 1;
769
+ }
770
+ }
771
+
772
+ function startOfUTCWeekYear(dirtyDate, options) {
773
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
774
+ requiredArgs(1, arguments);
775
+ var defaultOptions = getDefaultOptions();
776
+ var firstWeekContainsDate = toInteger$1((_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);
777
+ var year = getUTCWeekYear(dirtyDate, options);
778
+ var firstWeek = new Date(0);
779
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
780
+ firstWeek.setUTCHours(0, 0, 0, 0);
781
+ var date = startOfUTCWeek(firstWeek, options);
782
+ return date;
783
+ }
784
+
785
+ var MILLISECONDS_IN_WEEK = 604800000;
786
+ function getUTCWeek(dirtyDate, options) {
787
+ requiredArgs(1, arguments);
788
+ var date = toDate(dirtyDate);
789
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
790
+
791
+ // Round the number of days to the nearest integer
792
+ // because the number of milliseconds in a week is not constant
793
+ // (e.g. it's different in the week of the daylight saving time clock shift)
794
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
795
+ }
796
+
797
+ function addLeadingZeros(number, targetLength) {
798
+ var sign = number < 0 ? '-' : '';
799
+ var output = Math.abs(number).toString();
800
+ while (output.length < targetLength) {
801
+ output = '0' + output;
802
+ }
803
+ return sign + output;
804
+ }
805
+
806
+ /*
807
+ * | | Unit | | Unit |
808
+ * |-----|--------------------------------|-----|--------------------------------|
809
+ * | a | AM, PM | A* | |
810
+ * | d | Day of month | D | |
811
+ * | h | Hour [1-12] | H | Hour [0-23] |
812
+ * | m | Minute | M | Month |
813
+ * | s | Second | S | Fraction of second |
814
+ * | y | Year (abs) | Y | |
815
+ *
816
+ * Letters marked by * are not implemented but reserved by Unicode standard.
817
+ */
818
+ var formatters$1 = {
819
+ // Year
820
+ y: function y(date, token) {
821
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
822
+ // | Year | y | yy | yyy | yyyy | yyyyy |
823
+ // |----------|-------|----|-------|-------|-------|
824
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
825
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
826
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
827
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
828
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
829
+
830
+ var signedYear = date.getUTCFullYear();
831
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
832
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
833
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
834
+ },
835
+ // Month
836
+ M: function M(date, token) {
837
+ var month = date.getUTCMonth();
838
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
839
+ },
840
+ // Day of the month
841
+ d: function d(date, token) {
842
+ return addLeadingZeros(date.getUTCDate(), token.length);
843
+ },
844
+ // AM or PM
845
+ a: function a(date, token) {
846
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
847
+ switch (token) {
848
+ case 'a':
849
+ case 'aa':
850
+ return dayPeriodEnumValue.toUpperCase();
851
+ case 'aaa':
852
+ return dayPeriodEnumValue;
853
+ case 'aaaaa':
854
+ return dayPeriodEnumValue[0];
855
+ case 'aaaa':
856
+ default:
857
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
858
+ }
859
+ },
860
+ // Hour [1-12]
861
+ h: function h(date, token) {
862
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
863
+ },
864
+ // Hour [0-23]
865
+ H: function H(date, token) {
866
+ return addLeadingZeros(date.getUTCHours(), token.length);
867
+ },
868
+ // Minute
869
+ m: function m(date, token) {
870
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
871
+ },
872
+ // Second
873
+ s: function s(date, token) {
874
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
875
+ },
876
+ // Fraction of second
877
+ S: function S(date, token) {
878
+ var numberOfDigits = token.length;
879
+ var milliseconds = date.getUTCMilliseconds();
880
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
881
+ return addLeadingZeros(fractionalSeconds, token.length);
882
+ }
883
+ };
884
+
885
+ var dayPeriodEnum = {
886
+ am: 'am',
887
+ pm: 'pm',
888
+ midnight: 'midnight',
889
+ noon: 'noon',
890
+ morning: 'morning',
891
+ afternoon: 'afternoon',
892
+ evening: 'evening',
893
+ night: 'night'
894
+ };
895
+ /*
896
+ * | | Unit | | Unit |
897
+ * |-----|--------------------------------|-----|--------------------------------|
898
+ * | a | AM, PM | A* | Milliseconds in day |
899
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
900
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
901
+ * | d | Day of month | D | Day of year |
902
+ * | e | Local day of week | E | Day of week |
903
+ * | f | | F* | Day of week in month |
904
+ * | g* | Modified Julian day | G | Era |
905
+ * | h | Hour [1-12] | H | Hour [0-23] |
906
+ * | i! | ISO day of week | I! | ISO week of year |
907
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
908
+ * | k | Hour [1-24] | K | Hour [0-11] |
909
+ * | l* | (deprecated) | L | Stand-alone month |
910
+ * | m | Minute | M | Month |
911
+ * | n | | N | |
912
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
913
+ * | p! | Long localized time | P! | Long localized date |
914
+ * | q | Stand-alone quarter | Q | Quarter |
915
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
916
+ * | s | Second | S | Fraction of second |
917
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
918
+ * | u | Extended year | U* | Cyclic year |
919
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
920
+ * | w | Local week of year | W* | Week of month |
921
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
922
+ * | y | Year (abs) | Y | Local week-numbering year |
923
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
924
+ *
925
+ * Letters marked by * are not implemented but reserved by Unicode standard.
926
+ *
927
+ * Letters marked by ! are non-standard, but implemented by date-fns:
928
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
929
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
930
+ * i.e. 7 for Sunday, 1 for Monday, etc.
931
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
932
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
933
+ * `R` is supposed to be used in conjunction with `I` and `i`
934
+ * for universal ISO week-numbering date, whereas
935
+ * `Y` is supposed to be used in conjunction with `w` and `e`
936
+ * for week-numbering date specific to the locale.
937
+ * - `P` is long localized date format
938
+ * - `p` is long localized time format
939
+ */
940
+
941
+ var formatters = {
942
+ // Era
943
+ G: function G(date, token, localize) {
944
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
945
+ switch (token) {
946
+ // AD, BC
947
+ case 'G':
948
+ case 'GG':
949
+ case 'GGG':
950
+ return localize.era(era, {
951
+ width: 'abbreviated'
952
+ });
953
+ // A, B
954
+ case 'GGGGG':
955
+ return localize.era(era, {
956
+ width: 'narrow'
957
+ });
958
+ // Anno Domini, Before Christ
959
+ case 'GGGG':
960
+ default:
961
+ return localize.era(era, {
962
+ width: 'wide'
963
+ });
964
+ }
965
+ },
966
+ // Year
967
+ y: function y(date, token, localize) {
968
+ // Ordinal number
969
+ if (token === 'yo') {
970
+ var signedYear = date.getUTCFullYear();
971
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
972
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
973
+ return localize.ordinalNumber(year, {
974
+ unit: 'year'
975
+ });
976
+ }
977
+ return formatters$1.y(date, token);
978
+ },
979
+ // Local week-numbering year
980
+ Y: function Y(date, token, localize, options) {
981
+ var signedWeekYear = getUTCWeekYear(date, options);
982
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
983
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
984
+
985
+ // Two digit year
986
+ if (token === 'YY') {
987
+ var twoDigitYear = weekYear % 100;
988
+ return addLeadingZeros(twoDigitYear, 2);
989
+ }
990
+
991
+ // Ordinal number
992
+ if (token === 'Yo') {
993
+ return localize.ordinalNumber(weekYear, {
994
+ unit: 'year'
995
+ });
996
+ }
997
+
998
+ // Padding
999
+ return addLeadingZeros(weekYear, token.length);
1000
+ },
1001
+ // ISO week-numbering year
1002
+ R: function R(date, token) {
1003
+ var isoWeekYear = getUTCISOWeekYear(date);
1004
+
1005
+ // Padding
1006
+ return addLeadingZeros(isoWeekYear, token.length);
1007
+ },
1008
+ // Extended year. This is a single number designating the year of this calendar system.
1009
+ // The main difference between `y` and `u` localizers are B.C. years:
1010
+ // | Year | `y` | `u` |
1011
+ // |------|-----|-----|
1012
+ // | AC 1 | 1 | 1 |
1013
+ // | BC 1 | 1 | 0 |
1014
+ // | BC 2 | 2 | -1 |
1015
+ // Also `yy` always returns the last two digits of a year,
1016
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
1017
+ u: function u(date, token) {
1018
+ var year = date.getUTCFullYear();
1019
+ return addLeadingZeros(year, token.length);
1020
+ },
1021
+ // Quarter
1022
+ Q: function Q(date, token, localize) {
1023
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1024
+ switch (token) {
1025
+ // 1, 2, 3, 4
1026
+ case 'Q':
1027
+ return String(quarter);
1028
+ // 01, 02, 03, 04
1029
+ case 'QQ':
1030
+ return addLeadingZeros(quarter, 2);
1031
+ // 1st, 2nd, 3rd, 4th
1032
+ case 'Qo':
1033
+ return localize.ordinalNumber(quarter, {
1034
+ unit: 'quarter'
1035
+ });
1036
+ // Q1, Q2, Q3, Q4
1037
+ case 'QQQ':
1038
+ return localize.quarter(quarter, {
1039
+ width: 'abbreviated',
1040
+ context: 'formatting'
1041
+ });
1042
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1043
+ case 'QQQQQ':
1044
+ return localize.quarter(quarter, {
1045
+ width: 'narrow',
1046
+ context: 'formatting'
1047
+ });
1048
+ // 1st quarter, 2nd quarter, ...
1049
+ case 'QQQQ':
1050
+ default:
1051
+ return localize.quarter(quarter, {
1052
+ width: 'wide',
1053
+ context: 'formatting'
1054
+ });
1055
+ }
1056
+ },
1057
+ // Stand-alone quarter
1058
+ q: function q(date, token, localize) {
1059
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1060
+ switch (token) {
1061
+ // 1, 2, 3, 4
1062
+ case 'q':
1063
+ return String(quarter);
1064
+ // 01, 02, 03, 04
1065
+ case 'qq':
1066
+ return addLeadingZeros(quarter, 2);
1067
+ // 1st, 2nd, 3rd, 4th
1068
+ case 'qo':
1069
+ return localize.ordinalNumber(quarter, {
1070
+ unit: 'quarter'
1071
+ });
1072
+ // Q1, Q2, Q3, Q4
1073
+ case 'qqq':
1074
+ return localize.quarter(quarter, {
1075
+ width: 'abbreviated',
1076
+ context: 'standalone'
1077
+ });
1078
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1079
+ case 'qqqqq':
1080
+ return localize.quarter(quarter, {
1081
+ width: 'narrow',
1082
+ context: 'standalone'
1083
+ });
1084
+ // 1st quarter, 2nd quarter, ...
1085
+ case 'qqqq':
1086
+ default:
1087
+ return localize.quarter(quarter, {
1088
+ width: 'wide',
1089
+ context: 'standalone'
1090
+ });
1091
+ }
1092
+ },
1093
+ // Month
1094
+ M: function M(date, token, localize) {
1095
+ var month = date.getUTCMonth();
1096
+ switch (token) {
1097
+ case 'M':
1098
+ case 'MM':
1099
+ return formatters$1.M(date, token);
1100
+ // 1st, 2nd, ..., 12th
1101
+ case 'Mo':
1102
+ return localize.ordinalNumber(month + 1, {
1103
+ unit: 'month'
1104
+ });
1105
+ // Jan, Feb, ..., Dec
1106
+ case 'MMM':
1107
+ return localize.month(month, {
1108
+ width: 'abbreviated',
1109
+ context: 'formatting'
1110
+ });
1111
+ // J, F, ..., D
1112
+ case 'MMMMM':
1113
+ return localize.month(month, {
1114
+ width: 'narrow',
1115
+ context: 'formatting'
1116
+ });
1117
+ // January, February, ..., December
1118
+ case 'MMMM':
1119
+ default:
1120
+ return localize.month(month, {
1121
+ width: 'wide',
1122
+ context: 'formatting'
1123
+ });
1124
+ }
1125
+ },
1126
+ // Stand-alone month
1127
+ L: function L(date, token, localize) {
1128
+ var month = date.getUTCMonth();
1129
+ switch (token) {
1130
+ // 1, 2, ..., 12
1131
+ case 'L':
1132
+ return String(month + 1);
1133
+ // 01, 02, ..., 12
1134
+ case 'LL':
1135
+ return addLeadingZeros(month + 1, 2);
1136
+ // 1st, 2nd, ..., 12th
1137
+ case 'Lo':
1138
+ return localize.ordinalNumber(month + 1, {
1139
+ unit: 'month'
1140
+ });
1141
+ // Jan, Feb, ..., Dec
1142
+ case 'LLL':
1143
+ return localize.month(month, {
1144
+ width: 'abbreviated',
1145
+ context: 'standalone'
1146
+ });
1147
+ // J, F, ..., D
1148
+ case 'LLLLL':
1149
+ return localize.month(month, {
1150
+ width: 'narrow',
1151
+ context: 'standalone'
1152
+ });
1153
+ // January, February, ..., December
1154
+ case 'LLLL':
1155
+ default:
1156
+ return localize.month(month, {
1157
+ width: 'wide',
1158
+ context: 'standalone'
1159
+ });
1160
+ }
1161
+ },
1162
+ // Local week of year
1163
+ w: function w(date, token, localize, options) {
1164
+ var week = getUTCWeek(date, options);
1165
+ if (token === 'wo') {
1166
+ return localize.ordinalNumber(week, {
1167
+ unit: 'week'
1168
+ });
1169
+ }
1170
+ return addLeadingZeros(week, token.length);
1171
+ },
1172
+ // ISO week of year
1173
+ I: function I(date, token, localize) {
1174
+ var isoWeek = getUTCISOWeek(date);
1175
+ if (token === 'Io') {
1176
+ return localize.ordinalNumber(isoWeek, {
1177
+ unit: 'week'
1178
+ });
1179
+ }
1180
+ return addLeadingZeros(isoWeek, token.length);
1181
+ },
1182
+ // Day of the month
1183
+ d: function d(date, token, localize) {
1184
+ if (token === 'do') {
1185
+ return localize.ordinalNumber(date.getUTCDate(), {
1186
+ unit: 'date'
1187
+ });
1188
+ }
1189
+ return formatters$1.d(date, token);
1190
+ },
1191
+ // Day of year
1192
+ D: function D(date, token, localize) {
1193
+ var dayOfYear = getUTCDayOfYear(date);
1194
+ if (token === 'Do') {
1195
+ return localize.ordinalNumber(dayOfYear, {
1196
+ unit: 'dayOfYear'
1197
+ });
1198
+ }
1199
+ return addLeadingZeros(dayOfYear, token.length);
1200
+ },
1201
+ // Day of week
1202
+ E: function E(date, token, localize) {
1203
+ var dayOfWeek = date.getUTCDay();
1204
+ switch (token) {
1205
+ // Tue
1206
+ case 'E':
1207
+ case 'EE':
1208
+ case 'EEE':
1209
+ return localize.day(dayOfWeek, {
1210
+ width: 'abbreviated',
1211
+ context: 'formatting'
1212
+ });
1213
+ // T
1214
+ case 'EEEEE':
1215
+ return localize.day(dayOfWeek, {
1216
+ width: 'narrow',
1217
+ context: 'formatting'
1218
+ });
1219
+ // Tu
1220
+ case 'EEEEEE':
1221
+ return localize.day(dayOfWeek, {
1222
+ width: 'short',
1223
+ context: 'formatting'
1224
+ });
1225
+ // Tuesday
1226
+ case 'EEEE':
1227
+ default:
1228
+ return localize.day(dayOfWeek, {
1229
+ width: 'wide',
1230
+ context: 'formatting'
1231
+ });
1232
+ }
1233
+ },
1234
+ // Local day of week
1235
+ e: function e(date, token, localize, options) {
1236
+ var dayOfWeek = date.getUTCDay();
1237
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1238
+ switch (token) {
1239
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
1240
+ case 'e':
1241
+ return String(localDayOfWeek);
1242
+ // Padded numerical value
1243
+ case 'ee':
1244
+ return addLeadingZeros(localDayOfWeek, 2);
1245
+ // 1st, 2nd, ..., 7th
1246
+ case 'eo':
1247
+ return localize.ordinalNumber(localDayOfWeek, {
1248
+ unit: 'day'
1249
+ });
1250
+ case 'eee':
1251
+ return localize.day(dayOfWeek, {
1252
+ width: 'abbreviated',
1253
+ context: 'formatting'
1254
+ });
1255
+ // T
1256
+ case 'eeeee':
1257
+ return localize.day(dayOfWeek, {
1258
+ width: 'narrow',
1259
+ context: 'formatting'
1260
+ });
1261
+ // Tu
1262
+ case 'eeeeee':
1263
+ return localize.day(dayOfWeek, {
1264
+ width: 'short',
1265
+ context: 'formatting'
1266
+ });
1267
+ // Tuesday
1268
+ case 'eeee':
1269
+ default:
1270
+ return localize.day(dayOfWeek, {
1271
+ width: 'wide',
1272
+ context: 'formatting'
1273
+ });
1274
+ }
1275
+ },
1276
+ // Stand-alone local day of week
1277
+ c: function c(date, token, localize, options) {
1278
+ var dayOfWeek = date.getUTCDay();
1279
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1280
+ switch (token) {
1281
+ // Numerical value (same as in `e`)
1282
+ case 'c':
1283
+ return String(localDayOfWeek);
1284
+ // Padded numerical value
1285
+ case 'cc':
1286
+ return addLeadingZeros(localDayOfWeek, token.length);
1287
+ // 1st, 2nd, ..., 7th
1288
+ case 'co':
1289
+ return localize.ordinalNumber(localDayOfWeek, {
1290
+ unit: 'day'
1291
+ });
1292
+ case 'ccc':
1293
+ return localize.day(dayOfWeek, {
1294
+ width: 'abbreviated',
1295
+ context: 'standalone'
1296
+ });
1297
+ // T
1298
+ case 'ccccc':
1299
+ return localize.day(dayOfWeek, {
1300
+ width: 'narrow',
1301
+ context: 'standalone'
1302
+ });
1303
+ // Tu
1304
+ case 'cccccc':
1305
+ return localize.day(dayOfWeek, {
1306
+ width: 'short',
1307
+ context: 'standalone'
1308
+ });
1309
+ // Tuesday
1310
+ case 'cccc':
1311
+ default:
1312
+ return localize.day(dayOfWeek, {
1313
+ width: 'wide',
1314
+ context: 'standalone'
1315
+ });
1316
+ }
1317
+ },
1318
+ // ISO day of week
1319
+ i: function i(date, token, localize) {
1320
+ var dayOfWeek = date.getUTCDay();
1321
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1322
+ switch (token) {
1323
+ // 2
1324
+ case 'i':
1325
+ return String(isoDayOfWeek);
1326
+ // 02
1327
+ case 'ii':
1328
+ return addLeadingZeros(isoDayOfWeek, token.length);
1329
+ // 2nd
1330
+ case 'io':
1331
+ return localize.ordinalNumber(isoDayOfWeek, {
1332
+ unit: 'day'
1333
+ });
1334
+ // Tue
1335
+ case 'iii':
1336
+ return localize.day(dayOfWeek, {
1337
+ width: 'abbreviated',
1338
+ context: 'formatting'
1339
+ });
1340
+ // T
1341
+ case 'iiiii':
1342
+ return localize.day(dayOfWeek, {
1343
+ width: 'narrow',
1344
+ context: 'formatting'
1345
+ });
1346
+ // Tu
1347
+ case 'iiiiii':
1348
+ return localize.day(dayOfWeek, {
1349
+ width: 'short',
1350
+ context: 'formatting'
1351
+ });
1352
+ // Tuesday
1353
+ case 'iiii':
1354
+ default:
1355
+ return localize.day(dayOfWeek, {
1356
+ width: 'wide',
1357
+ context: 'formatting'
1358
+ });
1359
+ }
1360
+ },
1361
+ // AM or PM
1362
+ a: function a(date, token, localize) {
1363
+ var hours = date.getUTCHours();
1364
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1365
+ switch (token) {
1366
+ case 'a':
1367
+ case 'aa':
1368
+ return localize.dayPeriod(dayPeriodEnumValue, {
1369
+ width: 'abbreviated',
1370
+ context: 'formatting'
1371
+ });
1372
+ case 'aaa':
1373
+ return localize.dayPeriod(dayPeriodEnumValue, {
1374
+ width: 'abbreviated',
1375
+ context: 'formatting'
1376
+ }).toLowerCase();
1377
+ case 'aaaaa':
1378
+ return localize.dayPeriod(dayPeriodEnumValue, {
1379
+ width: 'narrow',
1380
+ context: 'formatting'
1381
+ });
1382
+ case 'aaaa':
1383
+ default:
1384
+ return localize.dayPeriod(dayPeriodEnumValue, {
1385
+ width: 'wide',
1386
+ context: 'formatting'
1387
+ });
1388
+ }
1389
+ },
1390
+ // AM, PM, midnight, noon
1391
+ b: function b(date, token, localize) {
1392
+ var hours = date.getUTCHours();
1393
+ var dayPeriodEnumValue;
1394
+ if (hours === 12) {
1395
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1396
+ } else if (hours === 0) {
1397
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1398
+ } else {
1399
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1400
+ }
1401
+ switch (token) {
1402
+ case 'b':
1403
+ case 'bb':
1404
+ return localize.dayPeriod(dayPeriodEnumValue, {
1405
+ width: 'abbreviated',
1406
+ context: 'formatting'
1407
+ });
1408
+ case 'bbb':
1409
+ return localize.dayPeriod(dayPeriodEnumValue, {
1410
+ width: 'abbreviated',
1411
+ context: 'formatting'
1412
+ }).toLowerCase();
1413
+ case 'bbbbb':
1414
+ return localize.dayPeriod(dayPeriodEnumValue, {
1415
+ width: 'narrow',
1416
+ context: 'formatting'
1417
+ });
1418
+ case 'bbbb':
1419
+ default:
1420
+ return localize.dayPeriod(dayPeriodEnumValue, {
1421
+ width: 'wide',
1422
+ context: 'formatting'
1423
+ });
1424
+ }
1425
+ },
1426
+ // in the morning, in the afternoon, in the evening, at night
1427
+ B: function B(date, token, localize) {
1428
+ var hours = date.getUTCHours();
1429
+ var dayPeriodEnumValue;
1430
+ if (hours >= 17) {
1431
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1432
+ } else if (hours >= 12) {
1433
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1434
+ } else if (hours >= 4) {
1435
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1436
+ } else {
1437
+ dayPeriodEnumValue = dayPeriodEnum.night;
1438
+ }
1439
+ switch (token) {
1440
+ case 'B':
1441
+ case 'BB':
1442
+ case 'BBB':
1443
+ return localize.dayPeriod(dayPeriodEnumValue, {
1444
+ width: 'abbreviated',
1445
+ context: 'formatting'
1446
+ });
1447
+ case 'BBBBB':
1448
+ return localize.dayPeriod(dayPeriodEnumValue, {
1449
+ width: 'narrow',
1450
+ context: 'formatting'
1451
+ });
1452
+ case 'BBBB':
1453
+ default:
1454
+ return localize.dayPeriod(dayPeriodEnumValue, {
1455
+ width: 'wide',
1456
+ context: 'formatting'
1457
+ });
1458
+ }
1459
+ },
1460
+ // Hour [1-12]
1461
+ h: function h(date, token, localize) {
1462
+ if (token === 'ho') {
1463
+ var hours = date.getUTCHours() % 12;
1464
+ if (hours === 0) hours = 12;
1465
+ return localize.ordinalNumber(hours, {
1466
+ unit: 'hour'
1467
+ });
1468
+ }
1469
+ return formatters$1.h(date, token);
1470
+ },
1471
+ // Hour [0-23]
1472
+ H: function H(date, token, localize) {
1473
+ if (token === 'Ho') {
1474
+ return localize.ordinalNumber(date.getUTCHours(), {
1475
+ unit: 'hour'
1476
+ });
1477
+ }
1478
+ return formatters$1.H(date, token);
1479
+ },
1480
+ // Hour [0-11]
1481
+ K: function K(date, token, localize) {
1482
+ var hours = date.getUTCHours() % 12;
1483
+ if (token === 'Ko') {
1484
+ return localize.ordinalNumber(hours, {
1485
+ unit: 'hour'
1486
+ });
1487
+ }
1488
+ return addLeadingZeros(hours, token.length);
1489
+ },
1490
+ // Hour [1-24]
1491
+ k: function k(date, token, localize) {
1492
+ var hours = date.getUTCHours();
1493
+ if (hours === 0) hours = 24;
1494
+ if (token === 'ko') {
1495
+ return localize.ordinalNumber(hours, {
1496
+ unit: 'hour'
1497
+ });
1498
+ }
1499
+ return addLeadingZeros(hours, token.length);
1500
+ },
1501
+ // Minute
1502
+ m: function m(date, token, localize) {
1503
+ if (token === 'mo') {
1504
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1505
+ unit: 'minute'
1506
+ });
1507
+ }
1508
+ return formatters$1.m(date, token);
1509
+ },
1510
+ // Second
1511
+ s: function s(date, token, localize) {
1512
+ if (token === 'so') {
1513
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1514
+ unit: 'second'
1515
+ });
1516
+ }
1517
+ return formatters$1.s(date, token);
1518
+ },
1519
+ // Fraction of second
1520
+ S: function S(date, token) {
1521
+ return formatters$1.S(date, token);
1522
+ },
1523
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1524
+ X: function X(date, token, _localize, options) {
1525
+ var originalDate = options._originalDate || date;
1526
+ var timezoneOffset = originalDate.getTimezoneOffset();
1527
+ if (timezoneOffset === 0) {
1528
+ return 'Z';
1529
+ }
1530
+ switch (token) {
1531
+ // Hours and optional minutes
1532
+ case 'X':
1533
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1534
+
1535
+ // Hours, minutes and optional seconds without `:` delimiter
1536
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1537
+ // so this token always has the same output as `XX`
1538
+ case 'XXXX':
1539
+ case 'XX':
1540
+ // Hours and minutes without `:` delimiter
1541
+ return formatTimezone(timezoneOffset);
1542
+
1543
+ // Hours, minutes and optional seconds with `:` delimiter
1544
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1545
+ // so this token always has the same output as `XXX`
1546
+ case 'XXXXX':
1547
+ case 'XXX': // Hours and minutes with `:` delimiter
1548
+ default:
1549
+ return formatTimezone(timezoneOffset, ':');
1550
+ }
1551
+ },
1552
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1553
+ x: function x(date, token, _localize, options) {
1554
+ var originalDate = options._originalDate || date;
1555
+ var timezoneOffset = originalDate.getTimezoneOffset();
1556
+ switch (token) {
1557
+ // Hours and optional minutes
1558
+ case 'x':
1559
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1560
+
1561
+ // Hours, minutes and optional seconds without `:` delimiter
1562
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1563
+ // so this token always has the same output as `xx`
1564
+ case 'xxxx':
1565
+ case 'xx':
1566
+ // Hours and minutes without `:` delimiter
1567
+ return formatTimezone(timezoneOffset);
1568
+
1569
+ // Hours, minutes and optional seconds with `:` delimiter
1570
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1571
+ // so this token always has the same output as `xxx`
1572
+ case 'xxxxx':
1573
+ case 'xxx': // Hours and minutes with `:` delimiter
1574
+ default:
1575
+ return formatTimezone(timezoneOffset, ':');
1576
+ }
1577
+ },
1578
+ // Timezone (GMT)
1579
+ O: function O(date, token, _localize, options) {
1580
+ var originalDate = options._originalDate || date;
1581
+ var timezoneOffset = originalDate.getTimezoneOffset();
1582
+ switch (token) {
1583
+ // Short
1584
+ case 'O':
1585
+ case 'OO':
1586
+ case 'OOO':
1587
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1588
+ // Long
1589
+ case 'OOOO':
1590
+ default:
1591
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1592
+ }
1593
+ },
1594
+ // Timezone (specific non-location)
1595
+ z: function z(date, token, _localize, options) {
1596
+ var originalDate = options._originalDate || date;
1597
+ var timezoneOffset = originalDate.getTimezoneOffset();
1598
+ switch (token) {
1599
+ // Short
1600
+ case 'z':
1601
+ case 'zz':
1602
+ case 'zzz':
1603
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1604
+ // Long
1605
+ case 'zzzz':
1606
+ default:
1607
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1608
+ }
1609
+ },
1610
+ // Seconds timestamp
1611
+ t: function t(date, token, _localize, options) {
1612
+ var originalDate = options._originalDate || date;
1613
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1614
+ return addLeadingZeros(timestamp, token.length);
1615
+ },
1616
+ // Milliseconds timestamp
1617
+ T: function T(date, token, _localize, options) {
1618
+ var originalDate = options._originalDate || date;
1619
+ var timestamp = originalDate.getTime();
1620
+ return addLeadingZeros(timestamp, token.length);
1621
+ }
1622
+ };
1623
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1624
+ var sign = offset > 0 ? '-' : '+';
1625
+ var absOffset = Math.abs(offset);
1626
+ var hours = Math.floor(absOffset / 60);
1627
+ var minutes = absOffset % 60;
1628
+ if (minutes === 0) {
1629
+ return sign + String(hours);
1630
+ }
1631
+ var delimiter = dirtyDelimiter;
1632
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1633
+ }
1634
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1635
+ if (offset % 60 === 0) {
1636
+ var sign = offset > 0 ? '-' : '+';
1637
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1638
+ }
1639
+ return formatTimezone(offset, dirtyDelimiter);
1640
+ }
1641
+ function formatTimezone(offset, dirtyDelimiter) {
1642
+ var delimiter = dirtyDelimiter || '';
1643
+ var sign = offset > 0 ? '-' : '+';
1644
+ var absOffset = Math.abs(offset);
1645
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1646
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1647
+ return sign + hours + delimiter + minutes;
1648
+ }
1649
+
1650
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1651
+ switch (pattern) {
1652
+ case 'P':
1653
+ return formatLong.date({
1654
+ width: 'short'
1655
+ });
1656
+ case 'PP':
1657
+ return formatLong.date({
1658
+ width: 'medium'
1659
+ });
1660
+ case 'PPP':
1661
+ return formatLong.date({
1662
+ width: 'long'
1663
+ });
1664
+ case 'PPPP':
1665
+ default:
1666
+ return formatLong.date({
1667
+ width: 'full'
1668
+ });
1669
+ }
1670
+ };
1671
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1672
+ switch (pattern) {
1673
+ case 'p':
1674
+ return formatLong.time({
1675
+ width: 'short'
1676
+ });
1677
+ case 'pp':
1678
+ return formatLong.time({
1679
+ width: 'medium'
1680
+ });
1681
+ case 'ppp':
1682
+ return formatLong.time({
1683
+ width: 'long'
1684
+ });
1685
+ case 'pppp':
1686
+ default:
1687
+ return formatLong.time({
1688
+ width: 'full'
1689
+ });
1690
+ }
1691
+ };
1692
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1693
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1694
+ var datePattern = matchResult[1];
1695
+ var timePattern = matchResult[2];
1696
+ if (!timePattern) {
1697
+ return dateLongFormatter(pattern, formatLong);
1698
+ }
1699
+ var dateTimeFormat;
1700
+ switch (datePattern) {
1701
+ case 'P':
1702
+ dateTimeFormat = formatLong.dateTime({
1703
+ width: 'short'
1704
+ });
1705
+ break;
1706
+ case 'PP':
1707
+ dateTimeFormat = formatLong.dateTime({
1708
+ width: 'medium'
1709
+ });
1710
+ break;
1711
+ case 'PPP':
1712
+ dateTimeFormat = formatLong.dateTime({
1713
+ width: 'long'
1714
+ });
1715
+ break;
1716
+ case 'PPPP':
1717
+ default:
1718
+ dateTimeFormat = formatLong.dateTime({
1719
+ width: 'full'
1720
+ });
1721
+ break;
1722
+ }
1723
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1724
+ };
1725
+ var longFormatters = {
1726
+ p: timeLongFormatter,
1727
+ P: dateTimeLongFormatter
1728
+ };
1729
+
1730
+ var protectedDayOfYearTokens = ['D', 'DD'];
1731
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1732
+ function isProtectedDayOfYearToken(token) {
1733
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1734
+ }
1735
+ function isProtectedWeekYearToken(token) {
1736
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1737
+ }
1738
+ function throwProtectedError(token, format, input) {
1739
+ if (token === 'YYYY') {
1740
+ 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"));
1741
+ } else if (token === 'YY') {
1742
+ 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"));
1743
+ } else if (token === 'D') {
1744
+ 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"));
1745
+ } else if (token === 'DD') {
1746
+ 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"));
1747
+ }
1748
+ }
1749
+
1750
+ var formatDistanceLocale = {
1751
+ lessThanXSeconds: {
1752
+ one: 'less than a second',
1753
+ other: 'less than {{count}} seconds'
1754
+ },
1755
+ xSeconds: {
1756
+ one: '1 second',
1757
+ other: '{{count}} seconds'
1758
+ },
1759
+ halfAMinute: 'half a minute',
1760
+ lessThanXMinutes: {
1761
+ one: 'less than a minute',
1762
+ other: 'less than {{count}} minutes'
1763
+ },
1764
+ xMinutes: {
1765
+ one: '1 minute',
1766
+ other: '{{count}} minutes'
1767
+ },
1768
+ aboutXHours: {
1769
+ one: 'about 1 hour',
1770
+ other: 'about {{count}} hours'
1771
+ },
1772
+ xHours: {
1773
+ one: '1 hour',
1774
+ other: '{{count}} hours'
1775
+ },
1776
+ xDays: {
1777
+ one: '1 day',
1778
+ other: '{{count}} days'
1779
+ },
1780
+ aboutXWeeks: {
1781
+ one: 'about 1 week',
1782
+ other: 'about {{count}} weeks'
1783
+ },
1784
+ xWeeks: {
1785
+ one: '1 week',
1786
+ other: '{{count}} weeks'
1787
+ },
1788
+ aboutXMonths: {
1789
+ one: 'about 1 month',
1790
+ other: 'about {{count}} months'
1791
+ },
1792
+ xMonths: {
1793
+ one: '1 month',
1794
+ other: '{{count}} months'
1795
+ },
1796
+ aboutXYears: {
1797
+ one: 'about 1 year',
1798
+ other: 'about {{count}} years'
1799
+ },
1800
+ xYears: {
1801
+ one: '1 year',
1802
+ other: '{{count}} years'
1803
+ },
1804
+ overXYears: {
1805
+ one: 'over 1 year',
1806
+ other: 'over {{count}} years'
1807
+ },
1808
+ almostXYears: {
1809
+ one: 'almost 1 year',
1810
+ other: 'almost {{count}} years'
1811
+ }
1812
+ };
1813
+ var formatDistance = function formatDistance(token, count, options) {
1814
+ var result;
1815
+ var tokenValue = formatDistanceLocale[token];
1816
+ if (typeof tokenValue === 'string') {
1817
+ result = tokenValue;
1818
+ } else if (count === 1) {
1819
+ result = tokenValue.one;
1820
+ } else {
1821
+ result = tokenValue.other.replace('{{count}}', count.toString());
1822
+ }
1823
+ if (options !== null && options !== void 0 && options.addSuffix) {
1824
+ if (options.comparison && options.comparison > 0) {
1825
+ return 'in ' + result;
1826
+ } else {
1827
+ return result + ' ago';
1828
+ }
1829
+ }
1830
+ return result;
1831
+ };
1832
+
1833
+ function buildFormatLongFn(args) {
1834
+ return function () {
1835
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1836
+ // TODO: Remove String()
1837
+ var width = options.width ? String(options.width) : args.defaultWidth;
1838
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1839
+ return format;
1840
+ };
1841
+ }
1842
+
1843
+ var dateFormats = {
1844
+ full: 'EEEE, MMMM do, y',
1845
+ long: 'MMMM do, y',
1846
+ medium: 'MMM d, y',
1847
+ short: 'MM/dd/yyyy'
1848
+ };
1849
+ var timeFormats = {
1850
+ full: 'h:mm:ss a zzzz',
1851
+ long: 'h:mm:ss a z',
1852
+ medium: 'h:mm:ss a',
1853
+ short: 'h:mm a'
1854
+ };
1855
+ var dateTimeFormats = {
1856
+ full: "{{date}} 'at' {{time}}",
1857
+ long: "{{date}} 'at' {{time}}",
1858
+ medium: '{{date}}, {{time}}',
1859
+ short: '{{date}}, {{time}}'
1860
+ };
1861
+ var formatLong = {
1862
+ date: buildFormatLongFn({
1863
+ formats: dateFormats,
1864
+ defaultWidth: 'full'
1865
+ }),
1866
+ time: buildFormatLongFn({
1867
+ formats: timeFormats,
1868
+ defaultWidth: 'full'
1869
+ }),
1870
+ dateTime: buildFormatLongFn({
1871
+ formats: dateTimeFormats,
1872
+ defaultWidth: 'full'
1873
+ })
1874
+ };
1875
+
1876
+ var formatRelativeLocale = {
1877
+ lastWeek: "'last' eeee 'at' p",
1878
+ yesterday: "'yesterday at' p",
1879
+ today: "'today at' p",
1880
+ tomorrow: "'tomorrow at' p",
1881
+ nextWeek: "eeee 'at' p",
1882
+ other: 'P'
1883
+ };
1884
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1885
+ return formatRelativeLocale[token];
1886
+ };
1887
+
1888
+ function buildLocalizeFn(args) {
1889
+ return function (dirtyIndex, options) {
1890
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1891
+ var valuesArray;
1892
+ if (context === 'formatting' && args.formattingValues) {
1893
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1894
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1895
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1896
+ } else {
1897
+ var _defaultWidth = args.defaultWidth;
1898
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1899
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1900
+ }
1901
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1902
+ // @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!
1903
+ return valuesArray[index];
1904
+ };
1905
+ }
1906
+
1907
+ var eraValues = {
1908
+ narrow: ['B', 'A'],
1909
+ abbreviated: ['BC', 'AD'],
1910
+ wide: ['Before Christ', 'Anno Domini']
1911
+ };
1912
+ var quarterValues = {
1913
+ narrow: ['1', '2', '3', '4'],
1914
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1915
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1916
+ };
1917
+
1918
+ // Note: in English, the names of days of the week and months are capitalized.
1919
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1920
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1921
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1922
+ var monthValues = {
1923
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1924
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1925
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1926
+ };
1927
+ var dayValues = {
1928
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1929
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1930
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1931
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1932
+ };
1933
+ var dayPeriodValues = {
1934
+ narrow: {
1935
+ am: 'a',
1936
+ pm: 'p',
1937
+ midnight: 'mi',
1938
+ noon: 'n',
1939
+ morning: 'morning',
1940
+ afternoon: 'afternoon',
1941
+ evening: 'evening',
1942
+ night: 'night'
1943
+ },
1944
+ abbreviated: {
1945
+ am: 'AM',
1946
+ pm: 'PM',
1947
+ midnight: 'midnight',
1948
+ noon: 'noon',
1949
+ morning: 'morning',
1950
+ afternoon: 'afternoon',
1951
+ evening: 'evening',
1952
+ night: 'night'
1953
+ },
1954
+ wide: {
1955
+ am: 'a.m.',
1956
+ pm: 'p.m.',
1957
+ midnight: 'midnight',
1958
+ noon: 'noon',
1959
+ morning: 'morning',
1960
+ afternoon: 'afternoon',
1961
+ evening: 'evening',
1962
+ night: 'night'
1963
+ }
1964
+ };
1965
+ var formattingDayPeriodValues = {
1966
+ narrow: {
1967
+ am: 'a',
1968
+ pm: 'p',
1969
+ midnight: 'mi',
1970
+ noon: 'n',
1971
+ morning: 'in the morning',
1972
+ afternoon: 'in the afternoon',
1973
+ evening: 'in the evening',
1974
+ night: 'at night'
1975
+ },
1976
+ abbreviated: {
1977
+ am: 'AM',
1978
+ pm: 'PM',
1979
+ midnight: 'midnight',
1980
+ noon: 'noon',
1981
+ morning: 'in the morning',
1982
+ afternoon: 'in the afternoon',
1983
+ evening: 'in the evening',
1984
+ night: 'at night'
1985
+ },
1986
+ wide: {
1987
+ am: 'a.m.',
1988
+ pm: 'p.m.',
1989
+ midnight: 'midnight',
1990
+ noon: 'noon',
1991
+ morning: 'in the morning',
1992
+ afternoon: 'in the afternoon',
1993
+ evening: 'in the evening',
1994
+ night: 'at night'
1995
+ }
1996
+ };
1997
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1998
+ var number = Number(dirtyNumber);
1999
+
2000
+ // If ordinal numbers depend on context, for example,
2001
+ // if they are different for different grammatical genders,
2002
+ // use `options.unit`.
2003
+ //
2004
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
2005
+ // 'day', 'hour', 'minute', 'second'.
2006
+
2007
+ var rem100 = number % 100;
2008
+ if (rem100 > 20 || rem100 < 10) {
2009
+ switch (rem100 % 10) {
2010
+ case 1:
2011
+ return number + 'st';
2012
+ case 2:
2013
+ return number + 'nd';
2014
+ case 3:
2015
+ return number + 'rd';
2016
+ }
2017
+ }
2018
+ return number + 'th';
2019
+ };
2020
+ var localize = {
2021
+ ordinalNumber: ordinalNumber,
2022
+ era: buildLocalizeFn({
2023
+ values: eraValues,
2024
+ defaultWidth: 'wide'
2025
+ }),
2026
+ quarter: buildLocalizeFn({
2027
+ values: quarterValues,
2028
+ defaultWidth: 'wide',
2029
+ argumentCallback: function argumentCallback(quarter) {
2030
+ return quarter - 1;
2031
+ }
2032
+ }),
2033
+ month: buildLocalizeFn({
2034
+ values: monthValues,
2035
+ defaultWidth: 'wide'
2036
+ }),
2037
+ day: buildLocalizeFn({
2038
+ values: dayValues,
2039
+ defaultWidth: 'wide'
2040
+ }),
2041
+ dayPeriod: buildLocalizeFn({
2042
+ values: dayPeriodValues,
2043
+ defaultWidth: 'wide',
2044
+ formattingValues: formattingDayPeriodValues,
2045
+ defaultFormattingWidth: 'wide'
2046
+ })
2047
+ };
2048
+
2049
+ function buildMatchFn(args) {
2050
+ return function (string) {
2051
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2052
+ var width = options.width;
2053
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
2054
+ var matchResult = string.match(matchPattern);
2055
+ if (!matchResult) {
2056
+ return null;
2057
+ }
2058
+ var matchedString = matchResult[0];
2059
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
2060
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
2061
+ return pattern.test(matchedString);
2062
+ }) : findKey(parsePatterns, function (pattern) {
2063
+ return pattern.test(matchedString);
2064
+ });
2065
+ var value;
2066
+ value = args.valueCallback ? args.valueCallback(key) : key;
2067
+ value = options.valueCallback ? options.valueCallback(value) : value;
2068
+ var rest = string.slice(matchedString.length);
2069
+ return {
2070
+ value: value,
2071
+ rest: rest
2072
+ };
2073
+ };
2074
+ }
2075
+ function findKey(object, predicate) {
2076
+ for (var key in object) {
2077
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
2078
+ return key;
2079
+ }
2080
+ }
2081
+ return undefined;
2082
+ }
2083
+ function findIndex(array, predicate) {
2084
+ for (var key = 0; key < array.length; key++) {
2085
+ if (predicate(array[key])) {
2086
+ return key;
2087
+ }
2088
+ }
2089
+ return undefined;
2090
+ }
2091
+
2092
+ function buildMatchPatternFn(args) {
2093
+ return function (string) {
2094
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2095
+ var matchResult = string.match(args.matchPattern);
2096
+ if (!matchResult) return null;
2097
+ var matchedString = matchResult[0];
2098
+ var parseResult = string.match(args.parsePattern);
2099
+ if (!parseResult) return null;
2100
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
2101
+ value = options.valueCallback ? options.valueCallback(value) : value;
2102
+ var rest = string.slice(matchedString.length);
2103
+ return {
2104
+ value: value,
2105
+ rest: rest
2106
+ };
2107
+ };
2108
+ }
2109
+
2110
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
2111
+ var parseOrdinalNumberPattern = /\d+/i;
2112
+ var matchEraPatterns = {
2113
+ narrow: /^(b|a)/i,
2114
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
2115
+ wide: /^(before christ|before common era|anno domini|common era)/i
2116
+ };
2117
+ var parseEraPatterns = {
2118
+ any: [/^b/i, /^(a|c)/i]
2119
+ };
2120
+ var matchQuarterPatterns = {
2121
+ narrow: /^[1234]/i,
2122
+ abbreviated: /^q[1234]/i,
2123
+ wide: /^[1234](th|st|nd|rd)? quarter/i
2124
+ };
2125
+ var parseQuarterPatterns = {
2126
+ any: [/1/i, /2/i, /3/i, /4/i]
2127
+ };
2128
+ var matchMonthPatterns = {
2129
+ narrow: /^[jfmasond]/i,
2130
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
2131
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
2132
+ };
2133
+ var parseMonthPatterns = {
2134
+ 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],
2135
+ 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]
2136
+ };
2137
+ var matchDayPatterns = {
2138
+ narrow: /^[smtwf]/i,
2139
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
2140
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
2141
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
2142
+ };
2143
+ var parseDayPatterns = {
2144
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
2145
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
2146
+ };
2147
+ var matchDayPeriodPatterns = {
2148
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
2149
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
270
2150
  };
2151
+ var parseDayPeriodPatterns = {
2152
+ any: {
2153
+ am: /^a/i,
2154
+ pm: /^p/i,
2155
+ midnight: /^mi/i,
2156
+ noon: /^no/i,
2157
+ morning: /morning/i,
2158
+ afternoon: /afternoon/i,
2159
+ evening: /evening/i,
2160
+ night: /night/i
2161
+ }
2162
+ };
2163
+ var match = {
2164
+ ordinalNumber: buildMatchPatternFn({
2165
+ matchPattern: matchOrdinalNumberPattern,
2166
+ parsePattern: parseOrdinalNumberPattern,
2167
+ valueCallback: function valueCallback(value) {
2168
+ return parseInt(value, 10);
2169
+ }
2170
+ }),
2171
+ era: buildMatchFn({
2172
+ matchPatterns: matchEraPatterns,
2173
+ defaultMatchWidth: 'wide',
2174
+ parsePatterns: parseEraPatterns,
2175
+ defaultParseWidth: 'any'
2176
+ }),
2177
+ quarter: buildMatchFn({
2178
+ matchPatterns: matchQuarterPatterns,
2179
+ defaultMatchWidth: 'wide',
2180
+ parsePatterns: parseQuarterPatterns,
2181
+ defaultParseWidth: 'any',
2182
+ valueCallback: function valueCallback(index) {
2183
+ return index + 1;
2184
+ }
2185
+ }),
2186
+ month: buildMatchFn({
2187
+ matchPatterns: matchMonthPatterns,
2188
+ defaultMatchWidth: 'wide',
2189
+ parsePatterns: parseMonthPatterns,
2190
+ defaultParseWidth: 'any'
2191
+ }),
2192
+ day: buildMatchFn({
2193
+ matchPatterns: matchDayPatterns,
2194
+ defaultMatchWidth: 'wide',
2195
+ parsePatterns: parseDayPatterns,
2196
+ defaultParseWidth: 'any'
2197
+ }),
2198
+ dayPeriod: buildMatchFn({
2199
+ matchPatterns: matchDayPeriodPatterns,
2200
+ defaultMatchWidth: 'any',
2201
+ parsePatterns: parseDayPeriodPatterns,
2202
+ defaultParseWidth: 'any'
2203
+ })
2204
+ };
2205
+
2206
+ /**
2207
+ * @type {Locale}
2208
+ * @category Locales
2209
+ * @summary English locale (United States).
2210
+ * @language English
2211
+ * @iso-639-2 eng
2212
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
2213
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
2214
+ */
2215
+ var locale = {
2216
+ code: 'en-US',
2217
+ formatDistance: formatDistance,
2218
+ formatLong: formatLong,
2219
+ formatRelative: formatRelative,
2220
+ localize: localize,
2221
+ match: match,
2222
+ options: {
2223
+ weekStartsOn: 0 /* Sunday */,
2224
+ firstWeekContainsDate: 1
2225
+ }
2226
+ };
2227
+
2228
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2229
+ // (one of the certain letters followed by `o`)
2230
+ // - (\w)\1* matches any sequences of the same letter
2231
+ // - '' matches two quote characters in a row
2232
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2233
+ // except a single quote symbol, which ends the sequence.
2234
+ // Two quote characters do not end the sequence.
2235
+ // If there is no matching single quote
2236
+ // then the sequence will continue until the end of the string.
2237
+ // - . matches any single character unmatched by previous parts of the RegExps
2238
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2239
+
2240
+ // This RegExp catches symbols escaped by quotes, and also
2241
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2242
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2243
+ var escapedStringRegExp = /^'([^]*?)'?$/;
2244
+ var doubleQuoteRegExp = /''/g;
2245
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2246
+
2247
+ /**
2248
+ * @name format
2249
+ * @category Common Helpers
2250
+ * @summary Format the date.
2251
+ *
2252
+ * @description
2253
+ * Return the formatted date string in the given format. The result may vary by locale.
2254
+ *
2255
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2256
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2257
+ *
2258
+ * The characters wrapped between two single quotes characters (') are escaped.
2259
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2260
+ * (see the last example)
2261
+ *
2262
+ * Format of the string is based on Unicode Technical Standard #35:
2263
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2264
+ * with a few additions (see note 7 below the table).
2265
+ *
2266
+ * Accepted patterns:
2267
+ * | Unit | Pattern | Result examples | Notes |
2268
+ * |---------------------------------|---------|-----------------------------------|-------|
2269
+ * | Era | G..GGG | AD, BC | |
2270
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2271
+ * | | GGGGG | A, B | |
2272
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2273
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2274
+ * | | yy | 44, 01, 00, 17 | 5 |
2275
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2276
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2277
+ * | | yyyyy | ... | 3,5 |
2278
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2279
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2280
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2281
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2282
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2283
+ * | | YYYYY | ... | 3,5 |
2284
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2285
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2286
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2287
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2288
+ * | | RRRRR | ... | 3,5,7 |
2289
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2290
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2291
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2292
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2293
+ * | | uuuuu | ... | 3,5 |
2294
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2295
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2296
+ * | | QQ | 01, 02, 03, 04 | |
2297
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2298
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2299
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2300
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2301
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2302
+ * | | qq | 01, 02, 03, 04 | |
2303
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2304
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2305
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2306
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2307
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2308
+ * | | MM | 01, 02, ..., 12 | |
2309
+ * | | MMM | Jan, Feb, ..., Dec | |
2310
+ * | | MMMM | January, February, ..., December | 2 |
2311
+ * | | MMMMM | J, F, ..., D | |
2312
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2313
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2314
+ * | | LL | 01, 02, ..., 12 | |
2315
+ * | | LLL | Jan, Feb, ..., Dec | |
2316
+ * | | LLLL | January, February, ..., December | 2 |
2317
+ * | | LLLLL | J, F, ..., D | |
2318
+ * | Local week of year | w | 1, 2, ..., 53 | |
2319
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2320
+ * | | ww | 01, 02, ..., 53 | |
2321
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2322
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2323
+ * | | II | 01, 02, ..., 53 | 7 |
2324
+ * | Day of month | d | 1, 2, ..., 31 | |
2325
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2326
+ * | | dd | 01, 02, ..., 31 | |
2327
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2328
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2329
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2330
+ * | | DDD | 001, 002, ..., 365, 366 | |
2331
+ * | | DDDD | ... | 3 |
2332
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2333
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2334
+ * | | EEEEE | M, T, W, T, F, S, S | |
2335
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2336
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2337
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2338
+ * | | ii | 01, 02, ..., 07 | 7 |
2339
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2340
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2341
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2342
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2343
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2344
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2345
+ * | | ee | 02, 03, ..., 01 | |
2346
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2347
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2348
+ * | | eeeee | M, T, W, T, F, S, S | |
2349
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2350
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2351
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2352
+ * | | cc | 02, 03, ..., 01 | |
2353
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2354
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2355
+ * | | ccccc | M, T, W, T, F, S, S | |
2356
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2357
+ * | AM, PM | a..aa | AM, PM | |
2358
+ * | | aaa | am, pm | |
2359
+ * | | aaaa | a.m., p.m. | 2 |
2360
+ * | | aaaaa | a, p | |
2361
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2362
+ * | | bbb | am, pm, noon, midnight | |
2363
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2364
+ * | | bbbbb | a, p, n, mi | |
2365
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2366
+ * | | BBBB | at night, in the morning, ... | 2 |
2367
+ * | | BBBBB | at night, in the morning, ... | |
2368
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2369
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2370
+ * | | hh | 01, 02, ..., 11, 12 | |
2371
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2372
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2373
+ * | | HH | 00, 01, 02, ..., 23 | |
2374
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2375
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2376
+ * | | KK | 01, 02, ..., 11, 00 | |
2377
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2378
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2379
+ * | | kk | 24, 01, 02, ..., 23 | |
2380
+ * | Minute | m | 0, 1, ..., 59 | |
2381
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2382
+ * | | mm | 00, 01, ..., 59 | |
2383
+ * | Second | s | 0, 1, ..., 59 | |
2384
+ * | | so | 0th, 1st, ..., 59th | 7 |
2385
+ * | | ss | 00, 01, ..., 59 | |
2386
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2387
+ * | | SS | 00, 01, ..., 99 | |
2388
+ * | | SSS | 000, 001, ..., 999 | |
2389
+ * | | SSSS | ... | 3 |
2390
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2391
+ * | | XX | -0800, +0530, Z | |
2392
+ * | | XXX | -08:00, +05:30, Z | |
2393
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2394
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2395
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2396
+ * | | xx | -0800, +0530, +0000 | |
2397
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2398
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2399
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2400
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2401
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2402
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2403
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2404
+ * | Seconds timestamp | t | 512969520 | 7 |
2405
+ * | | tt | ... | 3,7 |
2406
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2407
+ * | | TT | ... | 3,7 |
2408
+ * | Long localized date | P | 04/29/1453 | 7 |
2409
+ * | | PP | Apr 29, 1453 | 7 |
2410
+ * | | PPP | April 29th, 1453 | 7 |
2411
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2412
+ * | Long localized time | p | 12:00 AM | 7 |
2413
+ * | | pp | 12:00:00 AM | 7 |
2414
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2415
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2416
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2417
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2418
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2419
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2420
+ * Notes:
2421
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2422
+ * are the same as "stand-alone" units, but are different in some languages.
2423
+ * "Formatting" units are declined according to the rules of the language
2424
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2425
+ *
2426
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2427
+ *
2428
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2429
+ *
2430
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2431
+ * the single quote characters (see below).
2432
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2433
+ * the output will be the same as default pattern for this unit, usually
2434
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2435
+ * are marked with "2" in the last column of the table.
2436
+ *
2437
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2438
+ *
2439
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2440
+ *
2441
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2442
+ *
2443
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2444
+ *
2445
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2446
+ *
2447
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2448
+ * The output will be padded with zeros to match the length of the pattern.
2449
+ *
2450
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2451
+ *
2452
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2453
+ * These tokens represent the shortest form of the quarter.
2454
+ *
2455
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2456
+ *
2457
+ * | Year | `y` | `u` |
2458
+ * |------|-----|-----|
2459
+ * | AC 1 | 1 | 1 |
2460
+ * | BC 1 | 1 | 0 |
2461
+ * | BC 2 | 2 | -1 |
2462
+ *
2463
+ * Also `yy` always returns the last two digits of a year,
2464
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2465
+ *
2466
+ * | Year | `yy` | `uu` |
2467
+ * |------|------|------|
2468
+ * | 1 | 01 | 01 |
2469
+ * | 14 | 14 | 14 |
2470
+ * | 376 | 76 | 376 |
2471
+ * | 1453 | 53 | 1453 |
2472
+ *
2473
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2474
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2475
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2476
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2477
+ *
2478
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2479
+ * so right now these tokens fall back to GMT timezones.
2480
+ *
2481
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2482
+ * - `i`: ISO day of week
2483
+ * - `I`: ISO week of year
2484
+ * - `R`: ISO week-numbering year
2485
+ * - `t`: seconds timestamp
2486
+ * - `T`: milliseconds timestamp
2487
+ * - `o`: ordinal number modifier
2488
+ * - `P`: long localized date
2489
+ * - `p`: long localized time
2490
+ *
2491
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2492
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2493
+ *
2494
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2495
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2496
+ *
2497
+ * @param {Date|Number} date - the original date
2498
+ * @param {String} format - the string of tokens
2499
+ * @param {Object} [options] - an object with options.
2500
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2501
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2502
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2503
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2504
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2505
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2506
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2507
+ * @returns {String} the formatted date string
2508
+ * @throws {TypeError} 2 arguments required
2509
+ * @throws {RangeError} `date` must not be Invalid Date
2510
+ * @throws {RangeError} `options.locale` must contain `localize` property
2511
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2512
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2513
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2514
+ * @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
2515
+ * @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
2516
+ * @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
2517
+ * @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
2518
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2519
+ *
2520
+ * @example
2521
+ * // Represent 11 February 2014 in middle-endian format:
2522
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2523
+ * //=> '02/11/2014'
2524
+ *
2525
+ * @example
2526
+ * // Represent 2 July 2014 in Esperanto:
2527
+ * import { eoLocale } from 'date-fns/locale/eo'
2528
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2529
+ * locale: eoLocale
2530
+ * })
2531
+ * //=> '2-a de julio 2014'
2532
+ *
2533
+ * @example
2534
+ * // Escape string by single quote characters:
2535
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2536
+ * //=> "3 o'clock"
2537
+ */
2538
+
2539
+ function format(dirtyDate, dirtyFormatStr, options) {
2540
+ 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;
2541
+ requiredArgs(2, arguments);
2542
+ var formatStr = String(dirtyFormatStr);
2543
+ var defaultOptions = getDefaultOptions();
2544
+ var locale$1 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : locale;
2545
+ var firstWeekContainsDate = toInteger$1((_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);
2546
+
2547
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2548
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2549
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2550
+ }
2551
+ var weekStartsOn = toInteger$1((_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);
2552
+
2553
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2554
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2555
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2556
+ }
2557
+ if (!locale$1.localize) {
2558
+ throw new RangeError('locale must contain localize property');
2559
+ }
2560
+ if (!locale$1.formatLong) {
2561
+ throw new RangeError('locale must contain formatLong property');
2562
+ }
2563
+ var originalDate = toDate(dirtyDate);
2564
+ if (!isValid(originalDate)) {
2565
+ throw new RangeError('Invalid time value');
2566
+ }
2567
+
2568
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2569
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2570
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2571
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2572
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2573
+ var formatterOptions = {
2574
+ firstWeekContainsDate: firstWeekContainsDate,
2575
+ weekStartsOn: weekStartsOn,
2576
+ locale: locale$1,
2577
+ _originalDate: originalDate
2578
+ };
2579
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2580
+ var firstCharacter = substring[0];
2581
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2582
+ var longFormatter = longFormatters[firstCharacter];
2583
+ return longFormatter(substring, locale$1.formatLong);
2584
+ }
2585
+ return substring;
2586
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2587
+ // Replace two single quote characters with one single quote character
2588
+ if (substring === "''") {
2589
+ return "'";
2590
+ }
2591
+ var firstCharacter = substring[0];
2592
+ if (firstCharacter === "'") {
2593
+ return cleanEscapedString(substring);
2594
+ }
2595
+ var formatter = formatters[firstCharacter];
2596
+ if (formatter) {
2597
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2598
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2599
+ }
2600
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2601
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2602
+ }
2603
+ return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2604
+ }
2605
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2606
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2607
+ }
2608
+ return substring;
2609
+ }).join('');
2610
+ return result;
2611
+ }
2612
+ function cleanEscapedString(input) {
2613
+ var matched = input.match(escapedStringRegExp);
2614
+ if (!matched) {
2615
+ return input;
2616
+ }
2617
+ return matched[1].replace(doubleQuoteRegExp, "'");
2618
+ }
2619
+
2620
+ /**
2621
+ * @name formatISO
2622
+ * @category Common Helpers
2623
+ * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).
2624
+ *
2625
+ * @description
2626
+ * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.
2627
+ *
2628
+ * @param {Date|Number} date - the original date
2629
+ * @param {Object} [options] - an object with options.
2630
+ * @param {'extended'|'basic'} [options.format='extended'] - if 'basic', hide delimiters between date and time values.
2631
+ * @param {'complete'|'date'|'time'} [options.representation='complete'] - format date, time with local time zone, or both.
2632
+ * @returns {String} the formatted date string (in local time zone)
2633
+ * @throws {TypeError} 1 argument required
2634
+ * @throws {RangeError} `date` must not be Invalid Date
2635
+ * @throws {RangeError} `options.format` must be 'extended' or 'basic'
2636
+ * @throws {RangeError} `options.representation` must be 'date', 'time' or 'complete'
2637
+ *
2638
+ * @example
2639
+ * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
2640
+ * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))
2641
+ * //=> '2019-09-18T19:00:52Z'
2642
+ *
2643
+ * @example
2644
+ * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):
2645
+ * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
2646
+ * //=> '20190918T190052'
2647
+ *
2648
+ * @example
2649
+ * // Represent 18 September 2019 in ISO 8601 format, date only:
2650
+ * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
2651
+ * //=> '2019-09-18'
2652
+ *
2653
+ * @example
2654
+ * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):
2655
+ * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
2656
+ * //=> '19:00:52Z'
2657
+ */
2658
+ function formatISO(date, options) {
2659
+ var _options$format, _options$representati;
2660
+ requiredArgs(1, arguments);
2661
+ var originalDate = toDate(date);
2662
+ if (isNaN(originalDate.getTime())) {
2663
+ throw new RangeError('Invalid time value');
2664
+ }
2665
+ var format = String((_options$format = void 0 ) !== null && _options$format !== void 0 ? _options$format : 'extended');
2666
+ var representation = String((_options$representati = void 0 ) !== null && _options$representati !== void 0 ? _options$representati : 'complete');
2667
+ if (format !== 'extended' && format !== 'basic') {
2668
+ throw new RangeError("format must be 'extended' or 'basic'");
2669
+ }
2670
+ if (representation !== 'date' && representation !== 'time' && representation !== 'complete') {
2671
+ throw new RangeError("representation must be 'date', 'time', or 'complete'");
2672
+ }
2673
+ var result = '';
2674
+ var tzOffset = '';
2675
+ var dateDelimiter = format === 'extended' ? '-' : '';
2676
+ var timeDelimiter = format === 'extended' ? ':' : '';
2677
+
2678
+ // Representation is either 'date' or 'complete'
2679
+ if (representation !== 'time') {
2680
+ var day = addLeadingZeros(originalDate.getDate(), 2);
2681
+ var month = addLeadingZeros(originalDate.getMonth() + 1, 2);
2682
+ var year = addLeadingZeros(originalDate.getFullYear(), 4);
2683
+
2684
+ // yyyyMMdd or yyyy-MM-dd.
2685
+ result = "".concat(year).concat(dateDelimiter).concat(month).concat(dateDelimiter).concat(day);
2686
+ }
2687
+
2688
+ // Representation is either 'time' or 'complete'
2689
+ if (representation !== 'date') {
2690
+ // Add the timezone.
2691
+ var offset = originalDate.getTimezoneOffset();
2692
+ if (offset !== 0) {
2693
+ var absoluteOffset = Math.abs(offset);
2694
+ var hourOffset = addLeadingZeros(Math.floor(absoluteOffset / 60), 2);
2695
+ var minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);
2696
+ // If less than 0, the sign is +, because it is ahead of time.
2697
+ var sign = offset < 0 ? '+' : '-';
2698
+ tzOffset = "".concat(sign).concat(hourOffset, ":").concat(minuteOffset);
2699
+ } else {
2700
+ tzOffset = 'Z';
2701
+ }
2702
+ var hour = addLeadingZeros(originalDate.getHours(), 2);
2703
+ var minute = addLeadingZeros(originalDate.getMinutes(), 2);
2704
+ var second = addLeadingZeros(originalDate.getSeconds(), 2);
2705
+
2706
+ // If there's also date, separate it with time with 'T'
2707
+ var separator = result === '' ? '' : 'T';
2708
+
2709
+ // Creates a time string consisting of hour, minute, and second, separated by delimiters, if defined.
2710
+ var time = [hour, minute, second].join(timeDelimiter);
2711
+
2712
+ // HHmmss or HH:mm:ss.
2713
+ result = "".concat(result).concat(separator).concat(time).concat(tzOffset);
2714
+ }
2715
+ return result;
2716
+ }
2717
+
2718
+ /**
2719
+ * @name getDaysInMonth
2720
+ * @category Month Helpers
2721
+ * @summary Get the number of days in a month of the given date.
2722
+ *
2723
+ * @description
2724
+ * Get the number of days in a month of the given date.
2725
+ *
2726
+ * @param {Date|Number} date - the given date
2727
+ * @returns {Number} the number of days in a month
2728
+ * @throws {TypeError} 1 argument required
2729
+ *
2730
+ * @example
2731
+ * // How many days are in February 2000?
2732
+ * const result = getDaysInMonth(new Date(2000, 1))
2733
+ * //=> 29
2734
+ */
2735
+ function getDaysInMonth(dirtyDate) {
2736
+ requiredArgs(1, arguments);
2737
+ var date = toDate(dirtyDate);
2738
+ var year = date.getFullYear();
2739
+ var monthIndex = date.getMonth();
2740
+ var lastDayOfMonth = new Date(0);
2741
+ lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
2742
+ lastDayOfMonth.setHours(0, 0, 0, 0);
2743
+ return lastDayOfMonth.getDate();
2744
+ }
2745
+
2746
+ /**
2747
+ * @name getYear
2748
+ * @category Year Helpers
2749
+ * @summary Get the year of the given date.
2750
+ *
2751
+ * @description
2752
+ * Get the year of the given date.
2753
+ *
2754
+ * @param {Date|Number} date - the given date
2755
+ * @returns {Number} the year
2756
+ * @throws {TypeError} 1 argument required
2757
+ *
2758
+ * @example
2759
+ * // Which year is 2 July 2014?
2760
+ * const result = getYear(new Date(2014, 6, 2))
2761
+ * //=> 2014
2762
+ */
2763
+ function getYear(dirtyDate) {
2764
+ requiredArgs(1, arguments);
2765
+ return toDate(dirtyDate).getFullYear();
2766
+ }
2767
+
2768
+ /**
2769
+ * @name isAfter
2770
+ * @category Common Helpers
2771
+ * @summary Is the first date after the second one?
2772
+ *
2773
+ * @description
2774
+ * Is the first date after the second one?
2775
+ *
2776
+ * @param {Date|Number} date - the date that should be after the other one to return true
2777
+ * @param {Date|Number} dateToCompare - the date to compare with
2778
+ * @returns {Boolean} the first date is after the second date
2779
+ * @throws {TypeError} 2 arguments required
2780
+ *
2781
+ * @example
2782
+ * // Is 10 July 1989 after 11 February 1987?
2783
+ * const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
2784
+ * //=> true
2785
+ */
2786
+ function isAfter(dirtyDate, dirtyDateToCompare) {
2787
+ requiredArgs(2, arguments);
2788
+ var date = toDate(dirtyDate);
2789
+ var dateToCompare = toDate(dirtyDateToCompare);
2790
+ return date.getTime() > dateToCompare.getTime();
2791
+ }
2792
+
2793
+ /**
2794
+ * @name isBefore
2795
+ * @category Common Helpers
2796
+ * @summary Is the first date before the second one?
2797
+ *
2798
+ * @description
2799
+ * Is the first date before the second one?
2800
+ *
2801
+ * @param {Date|Number} date - the date that should be before the other one to return true
2802
+ * @param {Date|Number} dateToCompare - the date to compare with
2803
+ * @returns {Boolean} the first date is before the second date
2804
+ * @throws {TypeError} 2 arguments required
2805
+ *
2806
+ * @example
2807
+ * // Is 10 July 1989 before 11 February 1987?
2808
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
2809
+ * //=> false
2810
+ */
2811
+ function isBefore(dirtyDate, dirtyDateToCompare) {
2812
+ requiredArgs(2, arguments);
2813
+ var date = toDate(dirtyDate);
2814
+ var dateToCompare = toDate(dirtyDateToCompare);
2815
+ return date.getTime() < dateToCompare.getTime();
2816
+ }
2817
+
2818
+ /**
2819
+ * @name isSameMonth
2820
+ * @category Month Helpers
2821
+ * @summary Are the given dates in the same month (and year)?
2822
+ *
2823
+ * @description
2824
+ * Are the given dates in the same month (and year)?
2825
+ *
2826
+ * @param {Date|Number} dateLeft - the first date to check
2827
+ * @param {Date|Number} dateRight - the second date to check
2828
+ * @returns {Boolean} the dates are in the same month (and year)
2829
+ * @throws {TypeError} 2 arguments required
2830
+ *
2831
+ * @example
2832
+ * // Are 2 September 2014 and 25 September 2014 in the same month?
2833
+ * const result = isSameMonth(new Date(2014, 8, 2), new Date(2014, 8, 25))
2834
+ * //=> true
2835
+ *
2836
+ * @example
2837
+ * // Are 2 September 2014 and 25 September 2015 in the same month?
2838
+ * const result = isSameMonth(new Date(2014, 8, 2), new Date(2015, 8, 25))
2839
+ * //=> false
2840
+ */
2841
+ function isSameMonth(dirtyDateLeft, dirtyDateRight) {
2842
+ requiredArgs(2, arguments);
2843
+ var dateLeft = toDate(dirtyDateLeft);
2844
+ var dateRight = toDate(dirtyDateRight);
2845
+ return dateLeft.getFullYear() === dateRight.getFullYear() && dateLeft.getMonth() === dateRight.getMonth();
2846
+ }
2847
+
2848
+ /**
2849
+ * @name parseISO
2850
+ * @category Common Helpers
2851
+ * @summary Parse ISO string
2852
+ *
2853
+ * @description
2854
+ * Parse the given string in ISO 8601 format and return an instance of Date.
2855
+ *
2856
+ * Function accepts complete ISO 8601 formats as well as partial implementations.
2857
+ * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
2858
+ *
2859
+ * If the argument isn't a string, the function cannot parse the string or
2860
+ * the values are invalid, it returns Invalid Date.
2861
+ *
2862
+ * @param {String} argument - the value to convert
2863
+ * @param {Object} [options] - an object with options.
2864
+ * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
2865
+ * @returns {Date} the parsed date in the local time zone
2866
+ * @throws {TypeError} 1 argument required
2867
+ * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
2868
+ *
2869
+ * @example
2870
+ * // Convert string '2014-02-11T11:30:30' to date:
2871
+ * const result = parseISO('2014-02-11T11:30:30')
2872
+ * //=> Tue Feb 11 2014 11:30:30
2873
+ *
2874
+ * @example
2875
+ * // Convert string '+02014101' to date,
2876
+ * // if the additional number of digits in the extended year format is 1:
2877
+ * const result = parseISO('+02014101', { additionalDigits: 1 })
2878
+ * //=> Fri Apr 11 2014 00:00:00
2879
+ */
2880
+ function parseISO(argument, options) {
2881
+ var _options$additionalDi;
2882
+ requiredArgs(1, arguments);
2883
+ var additionalDigits = toInteger$1((_options$additionalDi = void 0 ) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);
2884
+ if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
2885
+ throw new RangeError('additionalDigits must be 0, 1 or 2');
2886
+ }
2887
+ if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
2888
+ return new Date(NaN);
2889
+ }
2890
+ var dateStrings = splitDateString(argument);
2891
+ var date;
2892
+ if (dateStrings.date) {
2893
+ var parseYearResult = parseYear(dateStrings.date, additionalDigits);
2894
+ date = parseDate(parseYearResult.restDateString, parseYearResult.year);
2895
+ }
2896
+ if (!date || isNaN(date.getTime())) {
2897
+ return new Date(NaN);
2898
+ }
2899
+ var timestamp = date.getTime();
2900
+ var time = 0;
2901
+ var offset;
2902
+ if (dateStrings.time) {
2903
+ time = parseTime(dateStrings.time);
2904
+ if (isNaN(time)) {
2905
+ return new Date(NaN);
2906
+ }
2907
+ }
2908
+ if (dateStrings.timezone) {
2909
+ offset = parseTimezone(dateStrings.timezone);
2910
+ if (isNaN(offset)) {
2911
+ return new Date(NaN);
2912
+ }
2913
+ } else {
2914
+ var dirtyDate = new Date(timestamp + time);
2915
+ // js parsed string assuming it's in UTC timezone
2916
+ // but we need it to be parsed in our timezone
2917
+ // so we use utc values to build date in our timezone.
2918
+ // Year values from 0 to 99 map to the years 1900 to 1999
2919
+ // so set year explicitly with setFullYear.
2920
+ var result = new Date(0);
2921
+ result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());
2922
+ result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());
2923
+ return result;
2924
+ }
2925
+ return new Date(timestamp + time + offset);
2926
+ }
2927
+ var patterns = {
2928
+ dateTimeDelimiter: /[T ]/,
2929
+ timeZoneDelimiter: /[Z ]/i,
2930
+ timezone: /([Z+-].*)$/
2931
+ };
2932
+ var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
2933
+ var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
2934
+ var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
2935
+ function splitDateString(dateString) {
2936
+ var dateStrings = {};
2937
+ var array = dateString.split(patterns.dateTimeDelimiter);
2938
+ var timeString;
2939
+
2940
+ // The regex match should only return at maximum two array elements.
2941
+ // [date], [time], or [date, time].
2942
+ if (array.length > 2) {
2943
+ return dateStrings;
2944
+ }
2945
+ if (/:/.test(array[0])) {
2946
+ timeString = array[0];
2947
+ } else {
2948
+ dateStrings.date = array[0];
2949
+ timeString = array[1];
2950
+ if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
2951
+ dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
2952
+ timeString = dateString.substr(dateStrings.date.length, dateString.length);
2953
+ }
2954
+ }
2955
+ if (timeString) {
2956
+ var token = patterns.timezone.exec(timeString);
2957
+ if (token) {
2958
+ dateStrings.time = timeString.replace(token[1], '');
2959
+ dateStrings.timezone = token[1];
2960
+ } else {
2961
+ dateStrings.time = timeString;
2962
+ }
2963
+ }
2964
+ return dateStrings;
2965
+ }
2966
+ function parseYear(dateString, additionalDigits) {
2967
+ var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)');
2968
+ var captures = dateString.match(regex);
2969
+ // Invalid ISO-formatted year
2970
+ if (!captures) return {
2971
+ year: NaN,
2972
+ restDateString: ''
2973
+ };
2974
+ var year = captures[1] ? parseInt(captures[1]) : null;
2975
+ var century = captures[2] ? parseInt(captures[2]) : null;
2976
+
2977
+ // either year or century is null, not both
2978
+ return {
2979
+ year: century === null ? year : century * 100,
2980
+ restDateString: dateString.slice((captures[1] || captures[2]).length)
2981
+ };
2982
+ }
2983
+ function parseDate(dateString, year) {
2984
+ // Invalid ISO-formatted year
2985
+ if (year === null) return new Date(NaN);
2986
+ var captures = dateString.match(dateRegex);
2987
+ // Invalid ISO-formatted string
2988
+ if (!captures) return new Date(NaN);
2989
+ var isWeekDate = !!captures[4];
2990
+ var dayOfYear = parseDateUnit(captures[1]);
2991
+ var month = parseDateUnit(captures[2]) - 1;
2992
+ var day = parseDateUnit(captures[3]);
2993
+ var week = parseDateUnit(captures[4]);
2994
+ var dayOfWeek = parseDateUnit(captures[5]) - 1;
2995
+ if (isWeekDate) {
2996
+ if (!validateWeekDate(year, week, dayOfWeek)) {
2997
+ return new Date(NaN);
2998
+ }
2999
+ return dayOfISOWeekYear(year, week, dayOfWeek);
3000
+ } else {
3001
+ var date = new Date(0);
3002
+ if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
3003
+ return new Date(NaN);
3004
+ }
3005
+ date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
3006
+ return date;
3007
+ }
3008
+ }
3009
+ function parseDateUnit(value) {
3010
+ return value ? parseInt(value) : 1;
3011
+ }
3012
+ function parseTime(timeString) {
3013
+ var captures = timeString.match(timeRegex);
3014
+ if (!captures) return NaN; // Invalid ISO-formatted time
3015
+
3016
+ var hours = parseTimeUnit(captures[1]);
3017
+ var minutes = parseTimeUnit(captures[2]);
3018
+ var seconds = parseTimeUnit(captures[3]);
3019
+ if (!validateTime(hours, minutes, seconds)) {
3020
+ return NaN;
3021
+ }
3022
+ return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000;
3023
+ }
3024
+ function parseTimeUnit(value) {
3025
+ return value && parseFloat(value.replace(',', '.')) || 0;
3026
+ }
3027
+ function parseTimezone(timezoneString) {
3028
+ if (timezoneString === 'Z') return 0;
3029
+ var captures = timezoneString.match(timezoneRegex);
3030
+ if (!captures) return 0;
3031
+ var sign = captures[1] === '+' ? -1 : 1;
3032
+ var hours = parseInt(captures[2]);
3033
+ var minutes = captures[3] && parseInt(captures[3]) || 0;
3034
+ if (!validateTimezone(hours, minutes)) {
3035
+ return NaN;
3036
+ }
3037
+ return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
3038
+ }
3039
+ function dayOfISOWeekYear(isoWeekYear, week, day) {
3040
+ var date = new Date(0);
3041
+ date.setUTCFullYear(isoWeekYear, 0, 4);
3042
+ var fourthOfJanuaryDay = date.getUTCDay() || 7;
3043
+ var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
3044
+ date.setUTCDate(date.getUTCDate() + diff);
3045
+ return date;
3046
+ }
3047
+
3048
+ // Validation functions
3049
+
3050
+ // February is null to handle the leap year (using ||)
3051
+ var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
3052
+ function isLeapYearIndex(year) {
3053
+ return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
3054
+ }
3055
+ function validateDate(year, month, date) {
3056
+ return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
3057
+ }
3058
+ function validateDayOfYearDate(year, dayOfYear) {
3059
+ return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
3060
+ }
3061
+ function validateWeekDate(_year, week, day) {
3062
+ return week >= 1 && week <= 53 && day >= 0 && day <= 6;
3063
+ }
3064
+ function validateTime(hours, minutes, seconds) {
3065
+ if (hours === 24) {
3066
+ return minutes === 0 && seconds === 0;
3067
+ }
3068
+ return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
3069
+ }
3070
+ function validateTimezone(_hours, minutes) {
3071
+ return minutes >= 0 && minutes <= 59;
3072
+ }
3073
+
3074
+ /**
3075
+ * @name setMonth
3076
+ * @category Month Helpers
3077
+ * @summary Set the month to the given date.
3078
+ *
3079
+ * @description
3080
+ * Set the month to the given date.
3081
+ *
3082
+ * @param {Date|Number} date - the date to be changed
3083
+ * @param {Number} month - the month of the new date
3084
+ * @returns {Date} the new date with the month set
3085
+ * @throws {TypeError} 2 arguments required
3086
+ *
3087
+ * @example
3088
+ * // Set February to 1 September 2014:
3089
+ * const result = setMonth(new Date(2014, 8, 1), 1)
3090
+ * //=> Sat Feb 01 2014 00:00:00
3091
+ */
3092
+ function setMonth(dirtyDate, dirtyMonth) {
3093
+ requiredArgs(2, arguments);
3094
+ var date = toDate(dirtyDate);
3095
+ var month = toInteger$1(dirtyMonth);
3096
+ var year = date.getFullYear();
3097
+ var day = date.getDate();
3098
+ var dateWithDesiredMonth = new Date(0);
3099
+ dateWithDesiredMonth.setFullYear(year, month, 15);
3100
+ dateWithDesiredMonth.setHours(0, 0, 0, 0);
3101
+ var daysInMonth = getDaysInMonth(dateWithDesiredMonth);
3102
+ // Set the last day of the new month
3103
+ // if the original date was the last day of the longer month
3104
+ date.setMonth(month, Math.min(day, daysInMonth));
3105
+ return date;
3106
+ }
3107
+
3108
+ /**
3109
+ * @name setYear
3110
+ * @category Year Helpers
3111
+ * @summary Set the year to the given date.
3112
+ *
3113
+ * @description
3114
+ * Set the year to the given date.
3115
+ *
3116
+ * @param {Date|Number} date - the date to be changed
3117
+ * @param {Number} year - the year of the new date
3118
+ * @returns {Date} the new date with the year set
3119
+ * @throws {TypeError} 2 arguments required
3120
+ *
3121
+ * @example
3122
+ * // Set year 2013 to 1 September 2014:
3123
+ * const result = setYear(new Date(2014, 8, 1), 2013)
3124
+ * //=> Sun Sep 01 2013 00:00:00
3125
+ */
3126
+ function setYear(dirtyDate, dirtyYear) {
3127
+ requiredArgs(2, arguments);
3128
+ var date = toDate(dirtyDate);
3129
+ var year = toInteger$1(dirtyYear);
3130
+
3131
+ // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
3132
+ if (isNaN(date.getTime())) {
3133
+ return new Date(NaN);
3134
+ }
3135
+ date.setFullYear(year);
3136
+ return date;
3137
+ }
3138
+
3139
+ /**
3140
+ * The base implementation of `_.slice` without an iteratee call guard.
3141
+ *
3142
+ * @private
3143
+ * @param {Array} array The array to slice.
3144
+ * @param {number} [start=0] The start position.
3145
+ * @param {number} [end=array.length] The end position.
3146
+ * @returns {Array} Returns the slice of `array`.
3147
+ */
3148
+ function baseSlice(array, start, end) {
3149
+ var index = -1,
3150
+ length = array.length;
3151
+
3152
+ if (start < 0) {
3153
+ start = -start > length ? 0 : (length + start);
3154
+ }
3155
+ end = end > length ? length : end;
3156
+ if (end < 0) {
3157
+ end += length;
3158
+ }
3159
+ length = start > end ? 0 : ((end - start) >>> 0);
3160
+ start >>>= 0;
3161
+
3162
+ var result = Array(length);
3163
+ while (++index < length) {
3164
+ result[index] = array[index + start];
3165
+ }
3166
+ return result;
3167
+ }
3168
+
3169
+ /** Detect free variable `global` from Node.js. */
3170
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
3171
+
3172
+ /** Detect free variable `self`. */
3173
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
3174
+
3175
+ /** Used as a reference to the global object. */
3176
+ var root = freeGlobal || freeSelf || Function('return this')();
3177
+
3178
+ /** Built-in value references. */
3179
+ var Symbol = root.Symbol;
3180
+
3181
+ /** Used for built-in method references. */
3182
+ var objectProto$1 = Object.prototype;
3183
+
3184
+ /** Used to check objects for own properties. */
3185
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
3186
+
3187
+ /**
3188
+ * Used to resolve the
3189
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
3190
+ * of values.
3191
+ */
3192
+ var nativeObjectToString$1 = objectProto$1.toString;
3193
+
3194
+ /** Built-in value references. */
3195
+ var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
3196
+
3197
+ /**
3198
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
3199
+ *
3200
+ * @private
3201
+ * @param {*} value The value to query.
3202
+ * @returns {string} Returns the raw `toStringTag`.
3203
+ */
3204
+ function getRawTag(value) {
3205
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1),
3206
+ tag = value[symToStringTag$1];
3207
+
3208
+ try {
3209
+ value[symToStringTag$1] = undefined;
3210
+ var unmasked = true;
3211
+ } catch (e) {}
3212
+
3213
+ var result = nativeObjectToString$1.call(value);
3214
+ if (unmasked) {
3215
+ if (isOwn) {
3216
+ value[symToStringTag$1] = tag;
3217
+ } else {
3218
+ delete value[symToStringTag$1];
3219
+ }
3220
+ }
3221
+ return result;
3222
+ }
3223
+
3224
+ /** Used for built-in method references. */
3225
+ var objectProto = Object.prototype;
3226
+
3227
+ /**
3228
+ * Used to resolve the
3229
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
3230
+ * of values.
3231
+ */
3232
+ var nativeObjectToString = objectProto.toString;
3233
+
3234
+ /**
3235
+ * Converts `value` to a string using `Object.prototype.toString`.
3236
+ *
3237
+ * @private
3238
+ * @param {*} value The value to convert.
3239
+ * @returns {string} Returns the converted string.
3240
+ */
3241
+ function objectToString(value) {
3242
+ return nativeObjectToString.call(value);
3243
+ }
3244
+
3245
+ /** `Object#toString` result references. */
3246
+ var nullTag = '[object Null]',
3247
+ undefinedTag = '[object Undefined]';
3248
+
3249
+ /** Built-in value references. */
3250
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
3251
+
3252
+ /**
3253
+ * The base implementation of `getTag` without fallbacks for buggy environments.
3254
+ *
3255
+ * @private
3256
+ * @param {*} value The value to query.
3257
+ * @returns {string} Returns the `toStringTag`.
3258
+ */
3259
+ function baseGetTag(value) {
3260
+ if (value == null) {
3261
+ return value === undefined ? undefinedTag : nullTag;
3262
+ }
3263
+ return (symToStringTag && symToStringTag in Object(value))
3264
+ ? getRawTag(value)
3265
+ : objectToString(value);
3266
+ }
3267
+
3268
+ /**
3269
+ * Checks if `value` is the
3270
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3271
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3272
+ *
3273
+ * @static
3274
+ * @memberOf _
3275
+ * @since 0.1.0
3276
+ * @category Lang
3277
+ * @param {*} value The value to check.
3278
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3279
+ * @example
3280
+ *
3281
+ * _.isObject({});
3282
+ * // => true
3283
+ *
3284
+ * _.isObject([1, 2, 3]);
3285
+ * // => true
3286
+ *
3287
+ * _.isObject(_.noop);
3288
+ * // => true
3289
+ *
3290
+ * _.isObject(null);
3291
+ * // => false
3292
+ */
3293
+ function isObject(value) {
3294
+ var type = typeof value;
3295
+ return value != null && (type == 'object' || type == 'function');
3296
+ }
3297
+
3298
+ /** Used to match a single whitespace character. */
3299
+ var reWhitespace = /\s/;
3300
+
3301
+ /**
3302
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
3303
+ * character of `string`.
3304
+ *
3305
+ * @private
3306
+ * @param {string} string The string to inspect.
3307
+ * @returns {number} Returns the index of the last non-whitespace character.
3308
+ */
3309
+ function trimmedEndIndex(string) {
3310
+ var index = string.length;
3311
+
3312
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
3313
+ return index;
3314
+ }
3315
+
3316
+ /** Used to match leading whitespace. */
3317
+ var reTrimStart = /^\s+/;
3318
+
3319
+ /**
3320
+ * The base implementation of `_.trim`.
3321
+ *
3322
+ * @private
3323
+ * @param {string} string The string to trim.
3324
+ * @returns {string} Returns the trimmed string.
3325
+ */
3326
+ function baseTrim(string) {
3327
+ return string
3328
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
3329
+ : string;
3330
+ }
3331
+
3332
+ /**
3333
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
3334
+ * and has a `typeof` result of "object".
3335
+ *
3336
+ * @static
3337
+ * @memberOf _
3338
+ * @since 4.0.0
3339
+ * @category Lang
3340
+ * @param {*} value The value to check.
3341
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3342
+ * @example
3343
+ *
3344
+ * _.isObjectLike({});
3345
+ * // => true
3346
+ *
3347
+ * _.isObjectLike([1, 2, 3]);
3348
+ * // => true
3349
+ *
3350
+ * _.isObjectLike(_.noop);
3351
+ * // => false
3352
+ *
3353
+ * _.isObjectLike(null);
3354
+ * // => false
3355
+ */
3356
+ function isObjectLike(value) {
3357
+ return value != null && typeof value == 'object';
3358
+ }
3359
+
3360
+ /** `Object#toString` result references. */
3361
+ var symbolTag = '[object Symbol]';
3362
+
3363
+ /**
3364
+ * Checks if `value` is classified as a `Symbol` primitive or object.
3365
+ *
3366
+ * @static
3367
+ * @memberOf _
3368
+ * @since 4.0.0
3369
+ * @category Lang
3370
+ * @param {*} value The value to check.
3371
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
3372
+ * @example
3373
+ *
3374
+ * _.isSymbol(Symbol.iterator);
3375
+ * // => true
3376
+ *
3377
+ * _.isSymbol('abc');
3378
+ * // => false
3379
+ */
3380
+ function isSymbol(value) {
3381
+ return typeof value == 'symbol' ||
3382
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
3383
+ }
3384
+
3385
+ /** Used as references for various `Number` constants. */
3386
+ var NAN = 0 / 0;
3387
+
3388
+ /** Used to detect bad signed hexadecimal string values. */
3389
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
3390
+
3391
+ /** Used to detect binary string values. */
3392
+ var reIsBinary = /^0b[01]+$/i;
3393
+
3394
+ /** Used to detect octal string values. */
3395
+ var reIsOctal = /^0o[0-7]+$/i;
3396
+
3397
+ /** Built-in method references without a dependency on `root`. */
3398
+ var freeParseInt = parseInt;
3399
+
3400
+ /**
3401
+ * Converts `value` to a number.
3402
+ *
3403
+ * @static
3404
+ * @memberOf _
3405
+ * @since 4.0.0
3406
+ * @category Lang
3407
+ * @param {*} value The value to process.
3408
+ * @returns {number} Returns the number.
3409
+ * @example
3410
+ *
3411
+ * _.toNumber(3.2);
3412
+ * // => 3.2
3413
+ *
3414
+ * _.toNumber(Number.MIN_VALUE);
3415
+ * // => 5e-324
3416
+ *
3417
+ * _.toNumber(Infinity);
3418
+ * // => Infinity
3419
+ *
3420
+ * _.toNumber('3.2');
3421
+ * // => 3.2
3422
+ */
3423
+ function toNumber(value) {
3424
+ if (typeof value == 'number') {
3425
+ return value;
3426
+ }
3427
+ if (isSymbol(value)) {
3428
+ return NAN;
3429
+ }
3430
+ if (isObject(value)) {
3431
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
3432
+ value = isObject(other) ? (other + '') : other;
3433
+ }
3434
+ if (typeof value != 'string') {
3435
+ return value === 0 ? value : +value;
3436
+ }
3437
+ value = baseTrim(value);
3438
+ var isBinary = reIsBinary.test(value);
3439
+ return (isBinary || reIsOctal.test(value))
3440
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
3441
+ : (reIsBadHex.test(value) ? NAN : +value);
3442
+ }
3443
+
3444
+ /** Used as references for various `Number` constants. */
3445
+ var INFINITY = 1 / 0,
3446
+ MAX_INTEGER = 1.7976931348623157e+308;
3447
+
3448
+ /**
3449
+ * Converts `value` to a finite number.
3450
+ *
3451
+ * @static
3452
+ * @memberOf _
3453
+ * @since 4.12.0
3454
+ * @category Lang
3455
+ * @param {*} value The value to convert.
3456
+ * @returns {number} Returns the converted number.
3457
+ * @example
3458
+ *
3459
+ * _.toFinite(3.2);
3460
+ * // => 3.2
3461
+ *
3462
+ * _.toFinite(Number.MIN_VALUE);
3463
+ * // => 5e-324
3464
+ *
3465
+ * _.toFinite(Infinity);
3466
+ * // => 1.7976931348623157e+308
3467
+ *
3468
+ * _.toFinite('3.2');
3469
+ * // => 3.2
3470
+ */
3471
+ function toFinite(value) {
3472
+ if (!value) {
3473
+ return value === 0 ? value : 0;
3474
+ }
3475
+ value = toNumber(value);
3476
+ if (value === INFINITY || value === -INFINITY) {
3477
+ var sign = (value < 0 ? -1 : 1);
3478
+ return sign * MAX_INTEGER;
3479
+ }
3480
+ return value === value ? value : 0;
3481
+ }
3482
+
3483
+ /**
3484
+ * Converts `value` to an integer.
3485
+ *
3486
+ * **Note:** This method is loosely based on
3487
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
3488
+ *
3489
+ * @static
3490
+ * @memberOf _
3491
+ * @since 4.0.0
3492
+ * @category Lang
3493
+ * @param {*} value The value to convert.
3494
+ * @returns {number} Returns the converted integer.
3495
+ * @example
3496
+ *
3497
+ * _.toInteger(3.2);
3498
+ * // => 3
3499
+ *
3500
+ * _.toInteger(Number.MIN_VALUE);
3501
+ * // => 0
3502
+ *
3503
+ * _.toInteger(Infinity);
3504
+ * // => 1.7976931348623157e+308
3505
+ *
3506
+ * _.toInteger('3.2');
3507
+ * // => 3
3508
+ */
3509
+ function toInteger(value) {
3510
+ var result = toFinite(value),
3511
+ remainder = result % 1;
3512
+
3513
+ return result === result ? (remainder ? result - remainder : result) : 0;
3514
+ }
3515
+
3516
+ /* Built-in method references for those with the same name as other `lodash` methods. */
3517
+ var nativeCeil = Math.ceil,
3518
+ nativeMax = Math.max;
3519
+
3520
+ /**
3521
+ * Creates an array of elements split into groups the length of `size`.
3522
+ * If `array` can't be split evenly, the final chunk will be the remaining
3523
+ * elements.
3524
+ *
3525
+ * @static
3526
+ * @memberOf _
3527
+ * @since 3.0.0
3528
+ * @category Array
3529
+ * @param {Array} array The array to process.
3530
+ * @param {number} [size=1] The length of each chunk
3531
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
3532
+ * @returns {Array} Returns the new array of chunks.
3533
+ * @example
3534
+ *
3535
+ * _.chunk(['a', 'b', 'c', 'd'], 2);
3536
+ * // => [['a', 'b'], ['c', 'd']]
3537
+ *
3538
+ * _.chunk(['a', 'b', 'c', 'd'], 3);
3539
+ * // => [['a', 'b', 'c'], ['d']]
3540
+ */
3541
+ function chunk(array, size, guard) {
3542
+ if ((size === undefined)) {
3543
+ size = 1;
3544
+ } else {
3545
+ size = nativeMax(toInteger(size), 0);
3546
+ }
3547
+ var length = array == null ? 0 : array.length;
3548
+ if (!length || size < 1) {
3549
+ return [];
3550
+ }
3551
+ var index = 0,
3552
+ resIndex = 0,
3553
+ result = Array(nativeCeil(length / size));
3554
+
3555
+ while (index < length) {
3556
+ result[resIndex++] = baseSlice(array, index, (index += size));
3557
+ }
3558
+ return result;
3559
+ }
3560
+
3561
+ const CalendarNavigation = ({ children, ...props }) => (jsx("div", { className: "utrecht-calendar__navigation", ...props, children: children }));
3562
+
3563
+ function r$1(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r$1(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx$1(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r$1(e))&&(n&&(n+=" "),n+=t);return n}
3564
+
3565
+ const Button = forwardRef(({ appearance, busy, disabled, children, className, hint, icon, label, pressed, type, ...restProps }, ref) => {
3566
+ return (jsxs("button", { ref: ref, className: clsx$1('utrecht-button', busy && 'utrecht-button--busy', disabled && 'utrecht-button--disabled', type === 'submit' && 'utrecht-button--submit', appearance === 'primary-action-button' && 'utrecht-button--primary-action', appearance === 'secondary-action-button' && 'utrecht-button--secondary-action', appearance === 'subtle-button' && 'utrecht-button--subtle', hint === 'danger' && 'utrecht-button--danger', hint === 'warning' && 'utrecht-button--warning', hint === 'ready' && 'utrecht-button--ready', pressed === true && 'utrecht-button--pressed', className), "aria-busy": busy || undefined, "aria-pressed": typeof pressed === 'boolean' ? pressed : undefined, disabled: disabled, type: type || 'button', ...restProps, children: [icon, label && jsx("span", { className: "utrecht-button__label", children: label }), children] }));
3567
+ });
3568
+ Button.displayName = 'Button';
3569
+
3570
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
3571
+
3572
+ const CalendarButton = ({ children, className, ...props }) => (jsx(Button, { appearance: "subtle-button", ...props, className: clsx('utrecht-calendar__button', className), children: children }));
3573
+
3574
+ const CalendarIcon = ({ children, ...props }) => (jsx("div", { className: clsx('utrecht-calendar__icon'), ...props, children: children }));
3575
+
3576
+ const CalendarNavigationButtons = ({ onPreviousClick, onNextClick, previousIcon, nextIcon, children, ...props }) => (jsxs("div", { className: "utrecht-calendar__navigation-buttons", children: [jsx(CalendarButton, { onClick: onPreviousClick, ...props, children: jsx(CalendarIcon, { children: previousIcon }) }), children, jsx(CalendarButton, { onClick: onNextClick, ...props, children: jsx(CalendarIcon, { children: nextIcon }) })] }));
3577
+
3578
+ const CalendarNavigationLabel = ({ children, ...props }) => (jsx("time", { className: "utrecht-calendar__navigation-label", ...props, children: children }));
3579
+
3580
+ const CalendarTableDaysContainer = ({ children, ...props }) => (jsx("tbody", { ...props, className: "utrecht-calendar__table-days-container", children: children }));
3581
+
3582
+ const CalendarTableDaysItem = ({ children, ...props }) => (jsx("tr", { ...props, children: children }));
3583
+
3584
+ const CalendarTableDaysItemDay = ({ day, dayOutOfTheMonth, isToday, emphasis, selected, disabled, ...props }) => (jsx("td", { children: jsx(CalendarButton, { className: clsx('utrecht-calendar__table-days-item-day', { 'utrecht-calendar__table-days-item-day--out-of-the-month': dayOutOfTheMonth }, { 'utrecht-calendar__table-days-item-day--is-today': isToday }, { 'utrecht-calendar__table-days-item-day--emphasis': emphasis }, { 'utrecht-calendar__table-days-item-day--selected': selected }), disabled: disabled, ...props, children: day }) }));
3585
+
3586
+ const CalendarTableWeeksContainer = ({ children }) => (jsx("thead", { className: "utrecht-calendar__table-weeks-container", children: jsx("tr", { className: "utrecht-calendar__table-weeks-container-content", children: children }) }));
3587
+
3588
+ const CalendarTableWeeksItem = ({ children, ...props }) => (jsx("th", { ...props, className: "utrecht-calendar__table-weeks-item", children: children }));
3589
+
3590
+ const IconArrowLeft = ({ title, titleId, ...props }) => (jsxs("svg", { width: "100%", height: "100%", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-labelledby": titleId, ...props, children: [title ? jsx("title", { id: titleId, children: title }) : null, jsx("path", { d: "M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41Z", fill: "currentColor" })] }));
3591
+
3592
+ const IconArrowLeftDouble = ({ title, titleId, ...props }) => (jsxs("svg", { width: "100%", height: "100%", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-labelledby": titleId, ...props, children: [title ? jsx("title", { id: titleId, children: title }) : null, jsx("path", { d: "M17.59 18 19 16.59 14.42 12 19 7.41 17.59 6l-6 6 6 6Z", fill: "currentColor" }), jsx("path", { d: "m11 18 1.41-1.41L7.83 12l4.58-4.59L11 6l-6 6 6 6Z", fill: "currentColor" })] }));
3593
+
3594
+ const IconArrowRight = ({ title, titleId, ...props }) => (jsxs("svg", { width: "100%", height: "100%", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-labelledby": titleId, ...props, children: [title ? jsx("title", { id: titleId, children: title }) : null, jsx("path", { d: "M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41Z", fill: "currentColor" })] }));
3595
+
3596
+ const IconArrowRightDouble = ({ title, titleId, ...props }) => (jsxs("svg", { fill: "none", width: "100%", height: "100%", xmlns: "http://www.w3.org/2000/svg", "aria-labelledby": titleId, ...props, children: [title ? jsx("title", { id: titleId, children: title }) : null, jsx("path", { d: "M6.41 6 5 7.41 9.58 12 5 16.59 6.41 18l6-6-6-6Z", fill: "currentColor" }), jsx("path", { d: "m13 6-1.41 1.41L16.17 12l-4.58 4.59L13 18l6-6-6-6Z", fill: "currentColor" })] }));
271
3597
 
272
3598
  function createCalendar(today) {
273
- var start = startOfWeek(startOfMonth(today), {
274
- weekStartsOn: 1 /* Monday */
275
- });
276
- var end = endOfWeek(addWeeks(start, 5), {
277
- weekStartsOn: 1 /* Monday */
278
- });
279
- return eachDayOfInterval({
280
- start: start,
281
- end: end
282
- });
3599
+ const start = startOfWeek(startOfMonth(today), {
3600
+ weekStartsOn: 1 /* Monday */,
3601
+ });
3602
+ const end = endOfWeek(addWeeks(start, 5), {
3603
+ weekStartsOn: 1 /* Monday */,
3604
+ });
3605
+ return eachDayOfInterval({ start, end });
283
3606
  }
284
3607
  /**
285
3608
  * Calendar Component
286
3609
  * powered by date-fns, so that make it easy to use the `date-fns` date functions & locale
287
3610
  * */
288
- var Calendar = function Calendar(_ref) {
289
- var onCalendarClick = _ref.onCalendarClick,
290
- events = _ref.events,
291
- currentDate = _ref.currentDate,
292
- _ref$locale = _ref.locale,
293
- locale = _ref$locale === void 0 ? enUS : _ref$locale,
294
- _ref$previousYearButt = _ref.previousYearButtonTitle,
295
- previousYearButtonTitle = _ref$previousYearButt === void 0 ? 'Previous year' : _ref$previousYearButt,
296
- _ref$nextYearButtonTi = _ref.nextYearButtonTitle,
297
- nextYearButtonTitle = _ref$nextYearButtonTi === void 0 ? 'Next year' : _ref$nextYearButtonTi,
298
- _ref$previousMonthBut = _ref.previousMonthButtonTitle,
299
- previousMonthButtonTitle = _ref$previousMonthBut === void 0 ? 'Previous month' : _ref$previousMonthBut,
300
- _ref$nextMonthButtonT = _ref.nextMonthButtonTitle,
301
- nextMonthButtonTitle = _ref$nextMonthButtonT === void 0 ? 'Next month' : _ref$nextMonthButtonT,
302
- minDate = _ref.minDate,
303
- maxDate = _ref.maxDate;
304
- var _useState = useState(currentDate || new Date()),
305
- _useState2 = _slicedToArray(_useState, 2),
306
- visibleMonth = _useState2[0],
307
- setVisibleMonth = _useState2[1];
308
- var _useState3 = useState(currentDate),
309
- _useState4 = _slicedToArray(_useState3, 2),
310
- selectedDate = _useState4[0],
311
- setSelectedDate = _useState4[1];
312
- var calendar = createCalendar(visibleMonth);
313
- var start = startOfWeek(visibleMonth, {
314
- weekStartsOn: 1
315
- });
316
- var end = endOfWeek(visibleMonth, {
317
- weekStartsOn: 1
318
- });
319
- var currentWeek = eachDayOfInterval({
320
- start: start,
321
- end: end
322
- }).map(function (day) {
323
- return day;
324
- });
325
- var chunksWeeks = chunk(calendar, calendar.length / 6);
326
- var weeks = chunksWeeks.map(function (week) {
327
- return week.map(function (date) {
328
- var currentEvent = events && events.length > 0 && events.find(function (e) {
329
- return isSameDay(endOfDay(parseISO(e.date)), date);
330
- });
331
- if (currentEvent) {
332
- return {
333
- date: date,
334
- emphasis: currentEvent.emphasis,
335
- selected: currentEvent.selected,
336
- disabled: currentEvent.disabled
337
- };
338
- } else {
339
- return {
340
- date: date,
341
- emphasis: false,
342
- selected: false,
343
- disabled: false
344
- };
345
- }
346
- });
347
- });
348
- return jsxs("div", {
349
- className: "utrecht-calendar",
350
- children: [jsx(CalendarNavigation, {
351
- children: jsx(CalendarNavigationButtons, {
352
- previousIcon: jsx(IconArrowLeftDouble, {
353
- title: previousYearButtonTitle
354
- }),
355
- nextIcon: jsx(IconArrowRightDouble, {
356
- title: nextYearButtonTitle
357
- }),
358
- onPreviousClick: function onPreviousClick() {
359
- return setVisibleMonth(setYear(visibleMonth, getYear(visibleMonth) - 1));
360
- },
361
- onNextClick: function onNextClick() {
362
- return setVisibleMonth(addYears(visibleMonth, 1));
363
- },
364
- children: jsx(CalendarNavigationButtons, {
365
- previousIcon: jsx(IconArrowLeft, {
366
- title: previousMonthButtonTitle
367
- }),
368
- nextIcon: jsx(IconArrowRight, {
369
- title: nextMonthButtonTitle
370
- }),
371
- onPreviousClick: function onPreviousClick() {
372
- return setVisibleMonth(setMonth(visibleMonth, visibleMonth.getMonth() - 1));
373
- },
374
- onNextClick: function onNextClick() {
375
- return setVisibleMonth(addMonths(visibleMonth, 1));
376
- },
377
- children: jsx(CalendarNavigationLabel, {
378
- dateTime: format(visibleMonth, 'yyyy-mm'),
379
- children: format(visibleMonth, 'LLLL Y', {
380
- locale: locale
381
- })
382
- })
383
- })
384
- })
385
- }), jsxs("table", {
386
- className: "utrecht-calendar__table",
387
- role: "grid",
388
- children: [jsx(CalendarTableWeeksContainer, {
389
- children: currentWeek && currentWeek.length > 0 && currentWeek.map(function (day, index) {
390
- return jsx(CalendarTableWeeksItem, {
391
- scope: "col",
392
- abbr: format(day, 'EEEE', {
393
- locale: locale
394
- }),
395
- children: format(day, 'EEEEEE', {
396
- locale: locale
397
- })
398
- }, index);
399
- })
400
- }), jsx(CalendarTableDaysContainer, {
401
- children: weeks && weeks.length > 0 && weeks.map(function (week, index) {
402
- return jsx(CalendarTableDaysItem, {
403
- children: week.map(function (day, index) {
404
- return jsx(CalendarTableDaysItemDay, {
405
- isToday: isSameDay(day.date, Date.now()),
406
- dayOutOfTheMonth: !isSameMonth(day.date, visibleMonth),
407
- onClick: function onClick() {
408
- setVisibleMonth(day.date);
409
- setSelectedDate(day.date);
410
- onCalendarClick(formatISO(day.date));
411
- },
412
- "aria-label": format(day.date, 'eeee dd LLLL Y', {
413
- locale: locale
414
- }),
415
- day: day.date.getDate().toString(),
416
- emphasis: day.emphasis,
417
- selected: day.selected || selectedDate && isSameDay(day.date, selectedDate),
418
- disabled: day.disabled || minDate && isBefore(day.date, startOfDay(minDate)) || maxDate && isAfter(day.date, endOfDay(maxDate))
419
- }, index);
420
- })
421
- }, index);
422
- })
423
- })]
424
- })]
425
- });
3611
+ const Calendar = ({ onCalendarClick, events, currentDate, locale: locale$1 = locale, previousYearButtonTitle = 'Previous year', nextYearButtonTitle = 'Next year', previousMonthButtonTitle = 'Previous month', nextMonthButtonTitle = 'Next month', minDate, maxDate, }) => {
3612
+ const [visibleMonth, setVisibleMonth] = useState(currentDate || new Date());
3613
+ const [selectedDate, setSelectedDate] = useState(currentDate);
3614
+ const calendar = createCalendar(visibleMonth);
3615
+ const start = startOfWeek(visibleMonth, { weekStartsOn: 1 });
3616
+ const end = endOfWeek(visibleMonth, { weekStartsOn: 1 });
3617
+ const currentWeek = eachDayOfInterval({ start, end }).map((day) => day);
3618
+ const chunksWeeks = chunk(calendar, calendar.length / 6);
3619
+ const weeks = chunksWeeks.map((week) => week.map((date) => {
3620
+ const currentEvent = events && events.length > 0 && events.find((e) => isSameDay(endOfDay(parseISO(e.date)), date));
3621
+ if (currentEvent) {
3622
+ return {
3623
+ date,
3624
+ emphasis: currentEvent.emphasis,
3625
+ selected: currentEvent.selected,
3626
+ disabled: currentEvent.disabled,
3627
+ };
3628
+ }
3629
+ else {
3630
+ return {
3631
+ date,
3632
+ emphasis: false,
3633
+ selected: false,
3634
+ disabled: false,
3635
+ };
3636
+ }
3637
+ }));
3638
+ return (jsxs("div", { className: "utrecht-calendar", children: [jsx(CalendarNavigation, { children: jsx(CalendarNavigationButtons, { previousIcon: jsx(IconArrowLeftDouble, { title: previousYearButtonTitle }), nextIcon: jsx(IconArrowRightDouble, { title: nextYearButtonTitle }), onPreviousClick: () => setVisibleMonth(setYear(visibleMonth, getYear(visibleMonth) - 1)), onNextClick: () => setVisibleMonth(addYears(visibleMonth, 1)), children: jsx(CalendarNavigationButtons, { previousIcon: jsx(IconArrowLeft, { title: previousMonthButtonTitle }), nextIcon: jsx(IconArrowRight, { title: nextMonthButtonTitle }), onPreviousClick: () => setVisibleMonth(setMonth(visibleMonth, visibleMonth.getMonth() - 1)), onNextClick: () => setVisibleMonth(addMonths(visibleMonth, 1)), children: jsx(CalendarNavigationLabel, { dateTime: format(visibleMonth, 'yyyy-mm'), children: format(visibleMonth, 'LLLL Y', { locale: locale$1 }) }) }) }) }), jsxs("table", { className: "utrecht-calendar__table", role: "grid", children: [jsx(CalendarTableWeeksContainer, { children: currentWeek &&
3639
+ currentWeek.length > 0 &&
3640
+ currentWeek.map((day, index) => (jsx(CalendarTableWeeksItem, { scope: "col", abbr: format(day, 'EEEE', { locale: locale$1 }), children: format(day, 'EEEEEE', { locale: locale$1 }) }, index))) }), jsx(CalendarTableDaysContainer, { children: weeks &&
3641
+ weeks.length > 0 &&
3642
+ weeks.map((week, index) => (jsx(CalendarTableDaysItem, { children: week.map((day, index) => {
3643
+ return (jsx(CalendarTableDaysItemDay, { isToday: isSameDay(day.date, Date.now()), dayOutOfTheMonth: !isSameMonth(day.date, visibleMonth), onClick: () => {
3644
+ setVisibleMonth(day.date);
3645
+ setSelectedDate(day.date);
3646
+ onCalendarClick(formatISO(day.date));
3647
+ }, "aria-label": format(day.date, 'eeee dd LLLL Y', { locale: locale$1 }), day: day.date.getDate().toString(), emphasis: day.emphasis, selected: day.selected || (selectedDate && isSameDay(day.date, selectedDate)), disabled: day.disabled ||
3648
+ (minDate && isBefore(day.date, startOfDay(minDate))) ||
3649
+ (maxDate && isAfter(day.date, endOfDay(maxDate))) }, index));
3650
+ }) }, index))) })] })] }));
426
3651
  };
427
3652
 
3653
+ /**
3654
+ * @license EUPL-1.2
3655
+ * Copyright (c) 2020-2024 Frameless B.V.
3656
+ * Copyright (c) 2021-2024 Gemeente Utrecht
3657
+ */
3658
+ insertStyle(css);
3659
+
428
3660
  export { Calendar };
429
3661
  //# sourceMappingURL=css.mjs.map