nxt-pick-datetime 22.0.0 → 22.1.0
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/assets/picker.scss +674 -675
- package/fesm2022/nxt-pick-datetime-moment-adapter.mjs +202 -235
- package/fesm2022/nxt-pick-datetime-moment-adapter.mjs.map +1 -1
- package/fesm2022/nxt-pick-datetime-native-adapter.mjs +348 -384
- package/fesm2022/nxt-pick-datetime-native-adapter.mjs.map +1 -1
- package/fesm2022/nxt-pick-datetime.mjs +5170 -4330
- package/fesm2022/nxt-pick-datetime.mjs.map +1 -1
- package/package.json +2 -2
- package/types/nxt-pick-datetime-moment-adapter.d.ts +12 -15
- package/types/nxt-pick-datetime-native-adapter.d.ts +2 -5
- package/types/nxt-pick-datetime.d.ts +1603 -1182
|
@@ -1,396 +1,360 @@
|
|
|
1
|
-
import { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from
|
|
2
|
-
import { Platform } from
|
|
3
|
-
import * as i0 from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The default month names to use if Intl API is not available.
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
1
|
+
import { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from "nxt-pick-datetime";
|
|
2
|
+
import { Platform } from "@angular/cdk/platform";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import { Injectable, LOCALE_ID, inject } from "@angular/core";
|
|
11
5
|
const DEFAULT_MONTH_NAMES = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
6
|
+
long: [
|
|
7
|
+
"January",
|
|
8
|
+
"February",
|
|
9
|
+
"March",
|
|
10
|
+
"April",
|
|
11
|
+
"May",
|
|
12
|
+
"June",
|
|
13
|
+
"July",
|
|
14
|
+
"August",
|
|
15
|
+
"September",
|
|
16
|
+
"October",
|
|
17
|
+
"November",
|
|
18
|
+
"December"
|
|
19
|
+
],
|
|
20
|
+
short: [
|
|
21
|
+
"Jan",
|
|
22
|
+
"Feb",
|
|
23
|
+
"Mar",
|
|
24
|
+
"Apr",
|
|
25
|
+
"May",
|
|
26
|
+
"Jun",
|
|
27
|
+
"Jul",
|
|
28
|
+
"Aug",
|
|
29
|
+
"Sep",
|
|
30
|
+
"Oct",
|
|
31
|
+
"Nov",
|
|
32
|
+
"Dec"
|
|
33
|
+
],
|
|
34
|
+
narrow: [
|
|
35
|
+
"J",
|
|
36
|
+
"F",
|
|
37
|
+
"M",
|
|
38
|
+
"A",
|
|
39
|
+
"M",
|
|
40
|
+
"J",
|
|
41
|
+
"J",
|
|
42
|
+
"A",
|
|
43
|
+
"S",
|
|
44
|
+
"O",
|
|
45
|
+
"N",
|
|
46
|
+
"D"
|
|
47
|
+
]
|
|
41
48
|
};
|
|
42
|
-
/**
|
|
43
|
-
* The default day of the week names to use if Intl API is not available.
|
|
44
|
-
*
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
49
|
const DEFAULT_DAY_OF_WEEK_NAMES = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
long: [
|
|
51
|
+
"Sunday",
|
|
52
|
+
"Monday",
|
|
53
|
+
"Tuesday",
|
|
54
|
+
"Wednesday",
|
|
55
|
+
"Thursday",
|
|
56
|
+
"Friday",
|
|
57
|
+
"Saturday"
|
|
58
|
+
],
|
|
59
|
+
short: [
|
|
60
|
+
"Sun",
|
|
61
|
+
"Mon",
|
|
62
|
+
"Tue",
|
|
63
|
+
"Wed",
|
|
64
|
+
"Thu",
|
|
65
|
+
"Fri",
|
|
66
|
+
"Sat"
|
|
67
|
+
],
|
|
68
|
+
narrow: [
|
|
69
|
+
"S",
|
|
70
|
+
"M",
|
|
71
|
+
"T",
|
|
72
|
+
"W",
|
|
73
|
+
"T",
|
|
74
|
+
"F",
|
|
75
|
+
"S"
|
|
76
|
+
]
|
|
59
77
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
const DEFAULT_DATE_NAMES = range(31, i => String(i + 1));
|
|
66
|
-
/**
|
|
67
|
-
* Whether the browser supports the Intl API.
|
|
68
|
-
*
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
const SUPPORTS_INTL_API = typeof Intl !== 'undefined';
|
|
72
|
-
/**
|
|
73
|
-
* Matches strings that have the form of a valid RFC 3339 string
|
|
74
|
-
* (https://tools.ietf.org/html/rfc3339). Note that the string may not actually be a valid date
|
|
75
|
-
* because the regex will match strings an with out of bounds month, date, etc.
|
|
76
|
-
*
|
|
77
|
-
* @internal
|
|
78
|
-
*/
|
|
78
|
+
const DEFAULT_DATE_NAMES = range(31, (i) => String(i + 1));
|
|
79
|
+
const SUPPORTS_INTL_API = typeof Intl !== "undefined";
|
|
79
80
|
const ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;
|
|
80
|
-
/**
|
|
81
|
-
* Creates an array and fills it with values.
|
|
82
|
-
*
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
81
|
function range(length, valueFunction) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
return valuesArray;
|
|
91
|
-
}
|
|
92
|
-
class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
93
|
-
constructor() {
|
|
94
|
-
const platform = inject(Platform);
|
|
95
|
-
const dateTimeLocale = inject(LOCALE_ID, { optional: true });
|
|
96
|
-
super();
|
|
97
|
-
super.setLocale(dateTimeLocale);
|
|
98
|
-
// IE does its own time zone correction, so we disable this on IE.
|
|
99
|
-
this.useUtcForDisplay = !platform.TRIDENT;
|
|
100
|
-
this._clampDate = platform.TRIDENT || platform.EDGE;
|
|
101
|
-
}
|
|
102
|
-
getYear(date) {
|
|
103
|
-
return date.getFullYear();
|
|
104
|
-
}
|
|
105
|
-
getMonth(date) {
|
|
106
|
-
return date.getMonth();
|
|
107
|
-
}
|
|
108
|
-
getDay(date) {
|
|
109
|
-
return date.getDay();
|
|
110
|
-
}
|
|
111
|
-
getDate(date) {
|
|
112
|
-
return date.getDate();
|
|
113
|
-
}
|
|
114
|
-
getHours(date) {
|
|
115
|
-
return date.getHours();
|
|
116
|
-
}
|
|
117
|
-
getMinutes(date) {
|
|
118
|
-
return date.getMinutes();
|
|
119
|
-
}
|
|
120
|
-
getSeconds(date) {
|
|
121
|
-
return date.getSeconds();
|
|
122
|
-
}
|
|
123
|
-
getTime(date) {
|
|
124
|
-
return date.getTime();
|
|
125
|
-
}
|
|
126
|
-
getNumDaysInMonth(date) {
|
|
127
|
-
const lastDateOfMonth = this.createDateWithOverflow(this.getYear(date), this.getMonth(date) + 1, 0);
|
|
128
|
-
return this.getDate(lastDateOfMonth);
|
|
129
|
-
}
|
|
130
|
-
differenceInCalendarDays(dateLeft, dateRight) {
|
|
131
|
-
if (this.isValid(dateLeft) && this.isValid(dateRight)) {
|
|
132
|
-
const dateLeftStartOfDay = this.createDate(this.getYear(dateLeft), this.getMonth(dateLeft), this.getDate(dateLeft));
|
|
133
|
-
const dateRightStartOfDay = this.createDate(this.getYear(dateRight), this.getMonth(dateRight), this.getDate(dateRight));
|
|
134
|
-
const timeStampLeft = this.getTime(dateLeftStartOfDay) -
|
|
135
|
-
dateLeftStartOfDay.getTimezoneOffset() *
|
|
136
|
-
this.milliseondsInMinute;
|
|
137
|
-
const timeStampRight = this.getTime(dateRightStartOfDay) -
|
|
138
|
-
dateRightStartOfDay.getTimezoneOffset() *
|
|
139
|
-
this.milliseondsInMinute;
|
|
140
|
-
return Math.round((timeStampLeft - timeStampRight) / this.millisecondsInDay);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
getYearName(date) {
|
|
147
|
-
if (SUPPORTS_INTL_API) {
|
|
148
|
-
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
149
|
-
year: 'numeric',
|
|
150
|
-
timeZone: 'utc'
|
|
151
|
-
});
|
|
152
|
-
return this.stripDirectionalityCharacters(this._format(dtf, date));
|
|
153
|
-
}
|
|
154
|
-
return String(this.getYear(date));
|
|
155
|
-
}
|
|
156
|
-
getMonthNames(style) {
|
|
157
|
-
if (SUPPORTS_INTL_API) {
|
|
158
|
-
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
159
|
-
month: style,
|
|
160
|
-
timeZone: 'utc'
|
|
161
|
-
});
|
|
162
|
-
return range(12, i => this.stripDirectionalityCharacters(this._format(dtf, new Date(2017, i, 1))));
|
|
163
|
-
}
|
|
164
|
-
return DEFAULT_MONTH_NAMES[style];
|
|
165
|
-
}
|
|
166
|
-
getDayOfWeekNames(style) {
|
|
167
|
-
if (SUPPORTS_INTL_API) {
|
|
168
|
-
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
169
|
-
weekday: style,
|
|
170
|
-
timeZone: 'utc'
|
|
171
|
-
});
|
|
172
|
-
return range(7, i => this.stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
|
|
173
|
-
}
|
|
174
|
-
return DEFAULT_DAY_OF_WEEK_NAMES[style];
|
|
175
|
-
}
|
|
176
|
-
getDateNames() {
|
|
177
|
-
if (SUPPORTS_INTL_API) {
|
|
178
|
-
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
179
|
-
day: 'numeric',
|
|
180
|
-
timeZone: 'utc'
|
|
181
|
-
});
|
|
182
|
-
return range(31, i => this.stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
|
|
183
|
-
}
|
|
184
|
-
return DEFAULT_DATE_NAMES;
|
|
185
|
-
}
|
|
186
|
-
toIso8601(date) {
|
|
187
|
-
return date.toISOString();
|
|
188
|
-
}
|
|
189
|
-
isEqual(dateLeft, dateRight) {
|
|
190
|
-
if (this.isValid(dateLeft) && this.isValid(dateRight)) {
|
|
191
|
-
return dateLeft.getTime() === dateRight.getTime();
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
isSameDay(dateLeft, dateRight) {
|
|
198
|
-
if (this.isValid(dateLeft) && this.isValid(dateRight)) {
|
|
199
|
-
const dateLeftStartOfDay = this.clone(dateLeft);
|
|
200
|
-
const dateRightStartOfDay = this.clone(dateRight);
|
|
201
|
-
dateLeftStartOfDay.setHours(0, 0, 0, 0);
|
|
202
|
-
dateRightStartOfDay.setHours(0, 0, 0, 0);
|
|
203
|
-
return (dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime());
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
isValid(date) {
|
|
210
|
-
return date && !isNaN(date.getTime());
|
|
211
|
-
}
|
|
212
|
-
invalid() {
|
|
213
|
-
return new Date(NaN);
|
|
214
|
-
}
|
|
215
|
-
isDateInstance(obj) {
|
|
216
|
-
return obj instanceof Date;
|
|
217
|
-
}
|
|
218
|
-
addCalendarYears(date, amount) {
|
|
219
|
-
return this.addCalendarMonths(date, amount * 12);
|
|
220
|
-
}
|
|
221
|
-
addCalendarMonths(date, amount) {
|
|
222
|
-
const result = this.clone(date);
|
|
223
|
-
amount = Number(amount);
|
|
224
|
-
const desiredMonth = result.getMonth() + amount;
|
|
225
|
-
const dateWithDesiredMonth = new Date(0);
|
|
226
|
-
dateWithDesiredMonth.setFullYear(result.getFullYear(), desiredMonth, 1);
|
|
227
|
-
dateWithDesiredMonth.setHours(0, 0, 0, 0);
|
|
228
|
-
const daysInMonth = this.getNumDaysInMonth(dateWithDesiredMonth);
|
|
229
|
-
// Set the last day of the new month
|
|
230
|
-
// if the original date was the last day of the longer month
|
|
231
|
-
result.setMonth(desiredMonth, Math.min(daysInMonth, result.getDate()));
|
|
232
|
-
return result;
|
|
233
|
-
}
|
|
234
|
-
addCalendarDays(date, amount) {
|
|
235
|
-
const result = this.clone(date);
|
|
236
|
-
amount = Number(amount);
|
|
237
|
-
result.setDate(result.getDate() + amount);
|
|
238
|
-
return result;
|
|
239
|
-
}
|
|
240
|
-
setHours(date, amount) {
|
|
241
|
-
const result = this.clone(date);
|
|
242
|
-
result.setHours(amount);
|
|
243
|
-
return result;
|
|
244
|
-
}
|
|
245
|
-
setMinutes(date, amount) {
|
|
246
|
-
const result = this.clone(date);
|
|
247
|
-
result.setMinutes(amount);
|
|
248
|
-
return result;
|
|
249
|
-
}
|
|
250
|
-
setSeconds(date, amount) {
|
|
251
|
-
const result = this.clone(date);
|
|
252
|
-
result.setSeconds(amount);
|
|
253
|
-
return result;
|
|
254
|
-
}
|
|
255
|
-
createDate(year, month, date, hours = 0, minutes = 0, seconds = 0) {
|
|
256
|
-
if (month < 0 || month > 11) {
|
|
257
|
-
throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
|
|
258
|
-
}
|
|
259
|
-
if (date < 1) {
|
|
260
|
-
throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
|
|
261
|
-
}
|
|
262
|
-
if (hours < 0 || hours > 23) {
|
|
263
|
-
throw Error(`Invalid hours "${hours}". Hours has to be between 0 and 23.`);
|
|
264
|
-
}
|
|
265
|
-
if (minutes < 0 || minutes > 59) {
|
|
266
|
-
throw Error(`Invalid minutes "${minutes}". Minutes has to between 0 and 59.`);
|
|
267
|
-
}
|
|
268
|
-
if (seconds < 0 || seconds > 59) {
|
|
269
|
-
throw Error(`Invalid seconds "${seconds}". Seconds has to be between 0 and 59.`);
|
|
270
|
-
}
|
|
271
|
-
const result = this.createDateWithOverflow(year, month, date, hours, minutes, seconds);
|
|
272
|
-
// Check that the date wasn't above the upper bound for the month, causing the month to overflow
|
|
273
|
-
// For example, createDate(2017, 1, 31) would try to create a date 2017/02/31 which is invalid
|
|
274
|
-
if (result.getMonth() !== month) {
|
|
275
|
-
throw Error(`Invalid date "${date}" for month with index "${month}".`);
|
|
276
|
-
}
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
|
-
clone(date) {
|
|
280
|
-
return this.createDate(this.getYear(date), this.getMonth(date), this.getDate(date), this.getHours(date), this.getMinutes(date), this.getSeconds(date));
|
|
281
|
-
}
|
|
282
|
-
now() {
|
|
283
|
-
return new Date();
|
|
284
|
-
}
|
|
285
|
-
format(date, displayFormat) {
|
|
286
|
-
if (!this.isValid(date)) {
|
|
287
|
-
throw Error('JSNativeDate: Cannot format invalid date.');
|
|
288
|
-
}
|
|
289
|
-
if (SUPPORTS_INTL_API) {
|
|
290
|
-
if (this._clampDate &&
|
|
291
|
-
(date.getFullYear() < 1 || date.getFullYear() > 9999)) {
|
|
292
|
-
date = this.clone(date);
|
|
293
|
-
date.setFullYear(Math.max(1, Math.min(9999, date.getFullYear())));
|
|
294
|
-
}
|
|
295
|
-
displayFormat = { ...displayFormat, timeZone: 'utc' };
|
|
296
|
-
const dtf = new Intl.DateTimeFormat(this.locale(), displayFormat);
|
|
297
|
-
return this.stripDirectionalityCharacters(this._format(dtf, date));
|
|
298
|
-
}
|
|
299
|
-
return this.stripDirectionalityCharacters(date.toDateString());
|
|
300
|
-
}
|
|
301
|
-
parse(value, _parseFormat) {
|
|
302
|
-
// There is no way using the native JS Date to set the parse format or locale
|
|
303
|
-
if (typeof value === 'number') {
|
|
304
|
-
return new Date(value);
|
|
305
|
-
}
|
|
306
|
-
return value ? new Date(Date.parse(value)) : undefined;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Returns the given value if given a valid Date or undefined. Deserializes valid ISO 8601 strings
|
|
310
|
-
* (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into undefined. Returns an
|
|
311
|
-
* invalid date for all other values.
|
|
312
|
-
*/
|
|
313
|
-
deserialize(value) {
|
|
314
|
-
if (typeof value === 'string') {
|
|
315
|
-
if (!value) {
|
|
316
|
-
return undefined;
|
|
317
|
-
}
|
|
318
|
-
// The `Date` constructor accepts formats other than ISO 8601, so we need to make sure the
|
|
319
|
-
// string is the right format first.
|
|
320
|
-
if (ISO_8601_REGEX.test(value)) {
|
|
321
|
-
const date = new Date(value);
|
|
322
|
-
if (this.isValid(date)) {
|
|
323
|
-
return date;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return super.deserialize(value);
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Creates a date but allows the month and date to overflow.
|
|
331
|
-
*/
|
|
332
|
-
createDateWithOverflow(year, month, date, hours = 0, minutes = 0, seconds = 0) {
|
|
333
|
-
const result = new Date(year, month, date, hours, minutes, seconds);
|
|
334
|
-
if (year >= 0 && year < 100) {
|
|
335
|
-
result.setFullYear(this.getYear(result) - 1900);
|
|
336
|
-
}
|
|
337
|
-
return result;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while
|
|
341
|
-
* other browsers do not. We remove them to make output consistent and because they interfere with
|
|
342
|
-
* date parsing.
|
|
343
|
-
*/
|
|
344
|
-
stripDirectionalityCharacters(str) {
|
|
345
|
-
return str.replace(/[\u200e\u200f]/g, '');
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* When converting Date object to string, javascript built-in functions may return wrong
|
|
349
|
-
* results because it applies its internal DST rules. The DST rules around the world change
|
|
350
|
-
* very frequently, and the current valid rule is not always valid in previous years though.
|
|
351
|
-
* We work around this problem building a new Date object which has its internal UTC
|
|
352
|
-
* representation with the local date and time.
|
|
353
|
-
*/
|
|
354
|
-
_format(dtf, date) {
|
|
355
|
-
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
356
|
-
return dtf.format(d);
|
|
357
|
-
}
|
|
358
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NativeDateTimeAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
359
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NativeDateTimeAdapter }); }
|
|
82
|
+
const valuesArray = Array(length);
|
|
83
|
+
for (let i = 0; i < length; i++) valuesArray[i] = valueFunction(i);
|
|
84
|
+
return valuesArray;
|
|
360
85
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
86
|
+
var NativeDateTimeAdapter = class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
87
|
+
constructor() {
|
|
88
|
+
const platform = inject(Platform);
|
|
89
|
+
const dateTimeLocale = inject(LOCALE_ID, { optional: true });
|
|
90
|
+
super();
|
|
91
|
+
super.setLocale(dateTimeLocale);
|
|
92
|
+
this.useUtcForDisplay = !platform.TRIDENT;
|
|
93
|
+
this._clampDate = platform.TRIDENT || platform.EDGE;
|
|
94
|
+
}
|
|
95
|
+
getYear(date) {
|
|
96
|
+
return date.getFullYear();
|
|
97
|
+
}
|
|
98
|
+
getMonth(date) {
|
|
99
|
+
return date.getMonth();
|
|
100
|
+
}
|
|
101
|
+
getDay(date) {
|
|
102
|
+
return date.getDay();
|
|
103
|
+
}
|
|
104
|
+
getDate(date) {
|
|
105
|
+
return date.getDate();
|
|
106
|
+
}
|
|
107
|
+
getHours(date) {
|
|
108
|
+
return date.getHours();
|
|
109
|
+
}
|
|
110
|
+
getMinutes(date) {
|
|
111
|
+
return date.getMinutes();
|
|
112
|
+
}
|
|
113
|
+
getSeconds(date) {
|
|
114
|
+
return date.getSeconds();
|
|
115
|
+
}
|
|
116
|
+
getTime(date) {
|
|
117
|
+
return date.getTime();
|
|
118
|
+
}
|
|
119
|
+
getNumDaysInMonth(date) {
|
|
120
|
+
const lastDateOfMonth = this.createDateWithOverflow(this.getYear(date), this.getMonth(date) + 1, 0);
|
|
121
|
+
return this.getDate(lastDateOfMonth);
|
|
122
|
+
}
|
|
123
|
+
differenceInCalendarDays(dateLeft, dateRight) {
|
|
124
|
+
if (this.isValid(dateLeft) && this.isValid(dateRight)) {
|
|
125
|
+
const dateLeftStartOfDay = this.createDate(this.getYear(dateLeft), this.getMonth(dateLeft), this.getDate(dateLeft));
|
|
126
|
+
const dateRightStartOfDay = this.createDate(this.getYear(dateRight), this.getMonth(dateRight), this.getDate(dateRight));
|
|
127
|
+
const timeStampLeft = this.getTime(dateLeftStartOfDay) - dateLeftStartOfDay.getTimezoneOffset() * this.milliseondsInMinute;
|
|
128
|
+
const timeStampRight = this.getTime(dateRightStartOfDay) - dateRightStartOfDay.getTimezoneOffset() * this.milliseondsInMinute;
|
|
129
|
+
return Math.round((timeStampLeft - timeStampRight) / this.millisecondsInDay);
|
|
130
|
+
} else return;
|
|
131
|
+
}
|
|
132
|
+
getYearName(date) {
|
|
133
|
+
if (SUPPORTS_INTL_API) {
|
|
134
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
135
|
+
year: "numeric",
|
|
136
|
+
timeZone: "utc"
|
|
137
|
+
});
|
|
138
|
+
return this.stripDirectionalityCharacters(this._format(dtf, date));
|
|
139
|
+
}
|
|
140
|
+
return String(this.getYear(date));
|
|
141
|
+
}
|
|
142
|
+
getMonthNames(style) {
|
|
143
|
+
if (SUPPORTS_INTL_API) {
|
|
144
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
145
|
+
month: style,
|
|
146
|
+
timeZone: "utc"
|
|
147
|
+
});
|
|
148
|
+
return range(12, (i) => this.stripDirectionalityCharacters(this._format(dtf, new Date(2017, i, 1))));
|
|
149
|
+
}
|
|
150
|
+
return DEFAULT_MONTH_NAMES[style];
|
|
151
|
+
}
|
|
152
|
+
getDayOfWeekNames(style) {
|
|
153
|
+
if (SUPPORTS_INTL_API) {
|
|
154
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
155
|
+
weekday: style,
|
|
156
|
+
timeZone: "utc"
|
|
157
|
+
});
|
|
158
|
+
return range(7, (i) => this.stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
|
|
159
|
+
}
|
|
160
|
+
return DEFAULT_DAY_OF_WEEK_NAMES[style];
|
|
161
|
+
}
|
|
162
|
+
getDateNames() {
|
|
163
|
+
if (SUPPORTS_INTL_API) {
|
|
164
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
165
|
+
day: "numeric",
|
|
166
|
+
timeZone: "utc"
|
|
167
|
+
});
|
|
168
|
+
return range(31, (i) => this.stripDirectionalityCharacters(this._format(dtf, new Date(2017, 0, i + 1))));
|
|
169
|
+
}
|
|
170
|
+
return DEFAULT_DATE_NAMES;
|
|
171
|
+
}
|
|
172
|
+
toIso8601(date) {
|
|
173
|
+
return date.toISOString();
|
|
174
|
+
}
|
|
175
|
+
isEqual(dateLeft, dateRight) {
|
|
176
|
+
if (this.isValid(dateLeft) && this.isValid(dateRight)) return dateLeft.getTime() === dateRight.getTime();
|
|
177
|
+
else return false;
|
|
178
|
+
}
|
|
179
|
+
isSameDay(dateLeft, dateRight) {
|
|
180
|
+
if (this.isValid(dateLeft) && this.isValid(dateRight)) {
|
|
181
|
+
const dateLeftStartOfDay = this.clone(dateLeft);
|
|
182
|
+
const dateRightStartOfDay = this.clone(dateRight);
|
|
183
|
+
dateLeftStartOfDay.setHours(0, 0, 0, 0);
|
|
184
|
+
dateRightStartOfDay.setHours(0, 0, 0, 0);
|
|
185
|
+
return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime();
|
|
186
|
+
} else return false;
|
|
187
|
+
}
|
|
188
|
+
isValid(date) {
|
|
189
|
+
return date && !isNaN(date.getTime());
|
|
190
|
+
}
|
|
191
|
+
invalid() {
|
|
192
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
193
|
+
}
|
|
194
|
+
isDateInstance(obj) {
|
|
195
|
+
return obj instanceof Date;
|
|
196
|
+
}
|
|
197
|
+
addCalendarYears(date, amount) {
|
|
198
|
+
return this.addCalendarMonths(date, amount * 12);
|
|
199
|
+
}
|
|
200
|
+
addCalendarMonths(date, amount) {
|
|
201
|
+
const result = this.clone(date);
|
|
202
|
+
amount = Number(amount);
|
|
203
|
+
const desiredMonth = result.getMonth() + amount;
|
|
204
|
+
const dateWithDesiredMonth = /* @__PURE__ */ new Date(0);
|
|
205
|
+
dateWithDesiredMonth.setFullYear(result.getFullYear(), desiredMonth, 1);
|
|
206
|
+
dateWithDesiredMonth.setHours(0, 0, 0, 0);
|
|
207
|
+
const daysInMonth = this.getNumDaysInMonth(dateWithDesiredMonth);
|
|
208
|
+
result.setMonth(desiredMonth, Math.min(daysInMonth, result.getDate()));
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
addCalendarDays(date, amount) {
|
|
212
|
+
const result = this.clone(date);
|
|
213
|
+
amount = Number(amount);
|
|
214
|
+
result.setDate(result.getDate() + amount);
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
setHours(date, amount) {
|
|
218
|
+
const result = this.clone(date);
|
|
219
|
+
result.setHours(amount);
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
setMinutes(date, amount) {
|
|
223
|
+
const result = this.clone(date);
|
|
224
|
+
result.setMinutes(amount);
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
setSeconds(date, amount) {
|
|
228
|
+
const result = this.clone(date);
|
|
229
|
+
result.setSeconds(amount);
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
createDate(year, month, date, hours = 0, minutes = 0, seconds = 0) {
|
|
233
|
+
if (month < 0 || month > 11) throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
|
|
234
|
+
if (date < 1) throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
|
|
235
|
+
if (hours < 0 || hours > 23) throw Error(`Invalid hours "${hours}". Hours has to be between 0 and 23.`);
|
|
236
|
+
if (minutes < 0 || minutes > 59) throw Error(`Invalid minutes "${minutes}". Minutes has to between 0 and 59.`);
|
|
237
|
+
if (seconds < 0 || seconds > 59) throw Error(`Invalid seconds "${seconds}". Seconds has to be between 0 and 59.`);
|
|
238
|
+
const result = this.createDateWithOverflow(year, month, date, hours, minutes, seconds);
|
|
239
|
+
if (result.getMonth() !== month) throw Error(`Invalid date "${date}" for month with index "${month}".`);
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
clone(date) {
|
|
243
|
+
return this.createDate(this.getYear(date), this.getMonth(date), this.getDate(date), this.getHours(date), this.getMinutes(date), this.getSeconds(date));
|
|
244
|
+
}
|
|
245
|
+
now() {
|
|
246
|
+
return /* @__PURE__ */ new Date();
|
|
247
|
+
}
|
|
248
|
+
format(date, displayFormat) {
|
|
249
|
+
if (!this.isValid(date)) throw Error("JSNativeDate: Cannot format invalid date.");
|
|
250
|
+
if (SUPPORTS_INTL_API) {
|
|
251
|
+
if (this._clampDate && (date.getFullYear() < 1 || date.getFullYear() > 9999)) {
|
|
252
|
+
date = this.clone(date);
|
|
253
|
+
date.setFullYear(Math.max(1, Math.min(9999, date.getFullYear())));
|
|
254
|
+
}
|
|
255
|
+
displayFormat = {
|
|
256
|
+
...displayFormat,
|
|
257
|
+
timeZone: "utc"
|
|
258
|
+
};
|
|
259
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), displayFormat);
|
|
260
|
+
return this.stripDirectionalityCharacters(this._format(dtf, date));
|
|
261
|
+
}
|
|
262
|
+
return this.stripDirectionalityCharacters(date.toDateString());
|
|
263
|
+
}
|
|
264
|
+
parse(value, _parseFormat) {
|
|
265
|
+
if (typeof value === "number") return new Date(value);
|
|
266
|
+
return value ? new Date(Date.parse(value)) : void 0;
|
|
267
|
+
}
|
|
268
|
+
deserialize(value) {
|
|
269
|
+
if (typeof value === "string") {
|
|
270
|
+
if (!value) return;
|
|
271
|
+
if (ISO_8601_REGEX.test(value)) {
|
|
272
|
+
const date = new Date(value);
|
|
273
|
+
if (this.isValid(date)) return date;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return super.deserialize(value);
|
|
277
|
+
}
|
|
278
|
+
createDateWithOverflow(year, month, date, hours = 0, minutes = 0, seconds = 0) {
|
|
279
|
+
const result = new Date(year, month, date, hours, minutes, seconds);
|
|
280
|
+
if (year >= 0 && year < 100) result.setFullYear(this.getYear(result) - 1900);
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
stripDirectionalityCharacters(str) {
|
|
284
|
+
return str.replace(/[\u200e\u200f]/g, "");
|
|
285
|
+
}
|
|
286
|
+
_format(dtf, date) {
|
|
287
|
+
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
288
|
+
return dtf.format(d);
|
|
289
|
+
}
|
|
290
|
+
static {
|
|
291
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
292
|
+
minVersion: "12.0.0",
|
|
293
|
+
version: "22.2.5",
|
|
294
|
+
ngImport: i0,
|
|
295
|
+
type: NativeDateTimeAdapter,
|
|
296
|
+
deps: [],
|
|
297
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
static {
|
|
301
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
302
|
+
minVersion: "12.0.0",
|
|
303
|
+
version: "22.2.5",
|
|
304
|
+
ngImport: i0,
|
|
305
|
+
type: NativeDateTimeAdapter
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
310
|
+
minVersion: "12.0.0",
|
|
311
|
+
version: "22.2.5",
|
|
312
|
+
ngImport: i0,
|
|
313
|
+
type: NativeDateTimeAdapter,
|
|
314
|
+
decorators: [{ type: Injectable }],
|
|
315
|
+
ctorParameters: () => []
|
|
316
|
+
});
|
|
368
317
|
const NXT_NATIVE_DATE_TIME_FORMATS = {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
318
|
+
parseInput: null,
|
|
319
|
+
fullPickerInput: {
|
|
320
|
+
year: "numeric",
|
|
321
|
+
month: "numeric",
|
|
322
|
+
day: "numeric",
|
|
323
|
+
hour: "numeric",
|
|
324
|
+
minute: "numeric"
|
|
325
|
+
},
|
|
326
|
+
datePickerInput: {
|
|
327
|
+
year: "numeric",
|
|
328
|
+
month: "numeric",
|
|
329
|
+
day: "numeric"
|
|
330
|
+
},
|
|
331
|
+
timePickerInput: {
|
|
332
|
+
hour: "numeric",
|
|
333
|
+
minute: "numeric"
|
|
334
|
+
},
|
|
335
|
+
monthYearLabel: {
|
|
336
|
+
year: "numeric",
|
|
337
|
+
month: "short"
|
|
338
|
+
},
|
|
339
|
+
dateA11yLabel: {
|
|
340
|
+
year: "numeric",
|
|
341
|
+
month: "long",
|
|
342
|
+
day: "numeric"
|
|
343
|
+
},
|
|
344
|
+
monthYearA11yLabel: {
|
|
345
|
+
year: "numeric",
|
|
346
|
+
month: "long"
|
|
347
|
+
}
|
|
376
348
|
};
|
|
377
|
-
|
|
378
349
|
function provideNativeDateTimeAdapter() {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
useValue: NXT_NATIVE_DATE_TIME_FORMATS
|
|
387
|
-
}
|
|
388
|
-
];
|
|
350
|
+
return [{
|
|
351
|
+
provide: DateTimeAdapter,
|
|
352
|
+
useClass: NativeDateTimeAdapter
|
|
353
|
+
}, {
|
|
354
|
+
provide: NXT_DATE_TIME_FORMATS,
|
|
355
|
+
useValue: NXT_NATIVE_DATE_TIME_FORMATS
|
|
356
|
+
}];
|
|
389
357
|
}
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Generated bundle index. Do not edit.
|
|
393
|
-
*/
|
|
394
|
-
|
|
395
358
|
export { provideNativeDateTimeAdapter };
|
|
396
|
-
|
|
359
|
+
|
|
360
|
+
//# sourceMappingURL=nxt-pick-datetime-native-adapter.mjs.map
|