inviton-powerduck 0.0.154 → 0.0.155
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/app/powerduck-initializer.ts +3 -3
- package/common/api-http.ts +20 -14
- package/common/css/ladda-themeless-zoomin.min.css +89 -89
- package/common/enum-translation/day-translator.ts +3 -2
- package/common/excel/excel-reader.ts +2 -9
- package/common/extensions/array-extensions.ts +116 -0
- package/common/extensions/string-extensions.ts +92 -0
- package/common/extensions/temporal-extensions.ts +115 -0
- package/common/scroll-utils.ts +2 -1
- package/common/temporal-helpers.ts +551 -0
- package/common/timezone-helper.ts +39 -29
- package/common/utils/cookie.ts +11 -8
- package/common/utils/date-localization-utils.ts +25 -19
- package/common/utils/date-utils.ts +37 -47
- package/common/utils/form-utils.ts +3 -1
- package/common/utils/language-utils.ts +21 -27
- package/common/utils/temporal-utils.ts +43 -0
- package/common/utils/upload-image-helper.ts +1 -1
- package/common/utils/utils.ts +14 -14
- package/common/validation.ts +17 -5
- package/components/chart-js/line-chart-flot.tsx +9 -9
- package/components/chart-js/thirdparty/flot/jquery.flot.categories.min.js +93 -93
- package/components/chart-js/thirdparty/flot/jquery.flot.crosshair.min.js +83 -83
- package/components/chart-js/thirdparty/flot/jquery.flot.navigate.min.js +270 -270
- package/components/chart-js/thirdparty/flot/jquery.flot.pie.min.js +507 -507
- package/components/chart-js/thirdparty/flot/jquery.flot.resize.js +7 -9
- package/components/chart-js/thirdparty/flot/jquery.flot.resize.min.js +9 -11
- package/components/chart-js/thirdparty/flot/jquery.flot.stack.min.js +104 -104
- package/components/chart-js/ts/line-chart-contracts.ts +2 -2
- package/components/container-with-breakpoints/ts/breakpoint-handler.ts +2 -2
- package/components/counter/testall.tsx +89 -75
- package/components/datatable/datatable.tsx +2379 -2375
- package/components/datatable/export-excel-modal.tsx +12 -14
- package/components/datatable/ts/reorder.ts +4 -2
- package/components/dropdown/index.tsx +48 -22
- package/components/dropdown/mobile/legacy_fdd.ts +10 -11
- package/components/dropzone/gallery-dropzone.tsx +394 -382
- package/components/fullcalendar/fullcalendar-draggable-event.tsx +8 -7
- package/components/fullcalendar/timegrid-calendar.tsx +60 -67
- package/components/image-crop/image-cropping-modal.tsx +9 -8
- package/components/image-crop/upload-and-crop.tsx +162 -162
- package/components/image-crop/vendor/jquery.Jcrop.min.css +344 -344
- package/components/import/import-mapper.tsx +2 -2
- package/components/input/daterange-picker.tsx +502 -521
- package/components/input/datetime-picker.tsx +45 -50
- package/components/input/plugins/daterangepicker/daterangepicker.min.css +400 -400
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.min.js +346 -339
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.ts +580 -402
- package/components/input/radio-button-group.tsx +2 -2
- package/components/input/ts/dateInputHelper.ts +1 -0
- package/components/input/wysiwig.tsx +12 -7
- package/components/svg/skilift-svg.tsx +6 -6
- package/package.json +2 -1
- package/common/date-wrapper.ts +0 -422
- package/common/utils/array-extend.ts +0 -215
- package/common/utils/array-remove.ts +0 -10
- package/common/utils/array-sort.ts +0 -56
- package/common/utils/capitalize-string.ts +0 -11
- package/common/utils/format-string.ts +0 -14
- package/common/utils/latinize-string.ts +0 -7
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
// www.jszen.com
|
|
5
5
|
|
|
6
6
|
/* eslint-disable */
|
|
7
|
-
import {
|
|
7
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
8
8
|
import DateUtils from '../../../../common/utils/date-utils';
|
|
9
|
+
import TemporalUtils from '../../../../common/utils/temporal-utils';
|
|
9
10
|
import DaterangePickerConfig from './daterangepicker-config';
|
|
10
11
|
import './daterangepicker.css';
|
|
12
|
+
import { utcEpochMilliseconds } from '../../../../common/extensions/temporal-extensions';
|
|
11
13
|
|
|
12
14
|
(function ($: any) {
|
|
13
15
|
$.dateRangePickerLanguages = {
|
|
@@ -256,41 +258,184 @@ import './daterangepicker.css';
|
|
|
256
258
|
},
|
|
257
259
|
};
|
|
258
260
|
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
const dateNow = () => Temporal.Now.plainDateTimeISO();
|
|
262
|
+
const ensureTemporal = (date: Temporal.PlainDateTime | number | string): Temporal.PlainDateTime => {
|
|
263
|
+
if (date == null) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if ((date as Temporal.PlainDateTime).toPlainDate) {
|
|
268
|
+
return date as Temporal.PlainDateTime;
|
|
269
|
+
} else if (typeof date == 'number') {
|
|
270
|
+
return TemporalUtils.fromEpochMs(date as number);
|
|
271
|
+
} else if (typeof date == 'string') {
|
|
272
|
+
return Temporal.PlainDateTime.from(date as string);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const startOfDay = (date: Temporal.PlainDateTime | number): Temporal.PlainDateTime => {
|
|
277
|
+
return ensureTemporal(date)?.with({
|
|
278
|
+
hour: 0,
|
|
279
|
+
minute: 0,
|
|
280
|
+
second: 0,
|
|
281
|
+
millisecond: 0,
|
|
282
|
+
microsecond: 0
|
|
283
|
+
});
|
|
268
284
|
};
|
|
269
285
|
|
|
270
|
-
const
|
|
286
|
+
const getJsDateDay = (date: Temporal.PlainDateTime): number => {
|
|
287
|
+
//returns date number like in old JS Date object
|
|
288
|
+
const day = date.dayOfWeek;
|
|
289
|
+
if (day == 7) {
|
|
290
|
+
return 0;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return day;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const getHourString = (date: Temporal.PlainDateTime): string => {
|
|
271
297
|
if (date == null) {
|
|
272
298
|
return null;
|
|
273
299
|
}
|
|
274
300
|
|
|
275
|
-
return date.
|
|
301
|
+
return ensureTemporal(date).toLocaleString('sk', {
|
|
276
302
|
hour: '2-digit',
|
|
277
|
-
language: 'sk',
|
|
278
303
|
hour12: false,
|
|
279
304
|
});
|
|
280
305
|
};
|
|
281
306
|
|
|
282
|
-
const getMinuteString = (date:
|
|
307
|
+
const getMinuteString = (date: Temporal.PlainDateTime): string => {
|
|
283
308
|
if (date == null) {
|
|
284
309
|
return null;
|
|
285
310
|
}
|
|
286
311
|
|
|
287
|
-
return date.
|
|
312
|
+
return ensureTemporal(date).toLocaleString('sk', {
|
|
288
313
|
minute: '2-digit',
|
|
289
314
|
});
|
|
290
315
|
};
|
|
291
316
|
|
|
292
|
-
|
|
293
|
-
|
|
317
|
+
interface DaterangePickerArgsCustomCellRenderArgs {
|
|
318
|
+
attributesHtml: string;
|
|
319
|
+
attributes: { [index: string]: string };
|
|
320
|
+
day: DaterangePickerArgsCustomCellRenderDay;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
interface DaterangePickerArgsCustomCellRenderDay {
|
|
324
|
+
date: Temporal.PlainDateTime;
|
|
325
|
+
day: number;
|
|
326
|
+
extraClass?: string;
|
|
327
|
+
time: number;
|
|
328
|
+
tooltip?: string;
|
|
329
|
+
type: 'toMonth' | 'nextMonth' | 'lastMonth';
|
|
330
|
+
valid: boolean;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
interface DateRangePickerOptions {
|
|
334
|
+
autoClose: boolean;
|
|
335
|
+
format: string;
|
|
336
|
+
separator: string;
|
|
337
|
+
language: string; // "auto" in your example, but allow any locale tag
|
|
338
|
+
startOfWeek: 'sunday' | 'monday';
|
|
339
|
+
|
|
340
|
+
getValue: () => string;
|
|
341
|
+
setValue: (s: string, startText?: string, endText?: string) => void;
|
|
342
|
+
|
|
343
|
+
startDate: Temporal.PlainDateTime
|
|
344
|
+
endDate: Temporal.PlainDateTime
|
|
345
|
+
|
|
346
|
+
time: {
|
|
347
|
+
enabled: boolean;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
minDays: number;
|
|
351
|
+
maxDays: number;
|
|
352
|
+
|
|
353
|
+
leftOffset: () => number
|
|
354
|
+
showShortcuts: boolean;
|
|
355
|
+
|
|
356
|
+
// structure is unclear from comments (arrays of numbers/strings/keywords)
|
|
357
|
+
shortcuts: any;
|
|
358
|
+
|
|
359
|
+
// structure unknown
|
|
360
|
+
customShortcuts: any[];
|
|
361
|
+
|
|
362
|
+
calendarPlacement: string; // 'body' in example; leave open
|
|
363
|
+
container: string; // 'body' in example
|
|
364
|
+
|
|
365
|
+
alwaysOpen: boolean;
|
|
366
|
+
singleDate: boolean;
|
|
367
|
+
lookBehind: boolean;
|
|
368
|
+
|
|
369
|
+
// false in example, some libs accept 'week'/'month'. Unknown here.
|
|
370
|
+
batchMode: 'week-range' | 'month-range' | 'week' | 'workweek' | 'weekend' | 'month'
|
|
371
|
+
duration: number;
|
|
372
|
+
stickyMonths: boolean;
|
|
373
|
+
|
|
374
|
+
// attribute bags for day cells are unknown
|
|
375
|
+
dayDivAttrs: any[];
|
|
376
|
+
dayTdAttrs: any[];
|
|
377
|
+
|
|
378
|
+
selectForward: boolean;
|
|
379
|
+
selectBackward: boolean;
|
|
380
|
+
|
|
381
|
+
applyBtnClass: string;
|
|
382
|
+
|
|
383
|
+
// 'auto' in example; some libs allow boolean/number. Keep flexible or crash.
|
|
384
|
+
singleMonth: 'auto' | boolean
|
|
385
|
+
|
|
386
|
+
// Tooltip over range hover
|
|
387
|
+
hoveringTooltip: (
|
|
388
|
+
days: number,
|
|
389
|
+
startTime: Temporal.PlainDateTime,
|
|
390
|
+
hoveringTime: Temporal.PlainDateTime
|
|
391
|
+
) => string;
|
|
392
|
+
|
|
393
|
+
showTopbar: boolean;
|
|
394
|
+
swapTime: boolean;
|
|
395
|
+
showWeekNumbers: boolean;
|
|
396
|
+
|
|
397
|
+
start: Temporal.PlainDateTime
|
|
398
|
+
end: Temporal.PlainDateTime
|
|
399
|
+
startTime: Temporal.PlainDateTime
|
|
400
|
+
endTime: Temporal.PlainDateTime;
|
|
401
|
+
isTouchDevice: boolean
|
|
402
|
+
startWeek: any
|
|
403
|
+
|
|
404
|
+
defaultTime: Temporal.PlainDateTime
|
|
405
|
+
defaultEndTime: Temporal.PlainDateTime
|
|
406
|
+
ensureMonthContinuity: boolean
|
|
407
|
+
|
|
408
|
+
month1: Temporal.PlainDateTime
|
|
409
|
+
month2: Temporal.PlainDateTime
|
|
410
|
+
|
|
411
|
+
// date will be the first day of a week
|
|
412
|
+
getWeekNumber: (date: Temporal.PlainDateTime) => number;
|
|
413
|
+
|
|
414
|
+
// Animations/symbols are null in example; likely function/string but unknown
|
|
415
|
+
customOpenAnimation: any
|
|
416
|
+
customCloseAnimation: any
|
|
417
|
+
customArrowPrevSymbol: any
|
|
418
|
+
customArrowNextSymbol: any
|
|
419
|
+
|
|
420
|
+
displayMode: () => 'modal' | 'below-input';
|
|
421
|
+
beforeShowDay: (d: Temporal.PlainDateTime) => void
|
|
422
|
+
maxDaysTooltip?: (maxDays: number) => string
|
|
423
|
+
hideYearInMonthName: boolean
|
|
424
|
+
extraClass: string
|
|
425
|
+
customTopBar: string | (() => string)
|
|
426
|
+
showCustomValues: boolean
|
|
427
|
+
customValueLabel: string
|
|
428
|
+
customValues: any[]
|
|
429
|
+
getCellHtml?: (args: DaterangePickerArgsCustomCellRenderArgs) => string;
|
|
430
|
+
showDateFilter?: (date: Temporal.PlainDateTime, day: number) => string | number
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
$.fn.dateRangePicker = function (opt: DateRangePickerOptions) {
|
|
434
|
+
if (!opt) {
|
|
435
|
+
opt = {} as any
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
294
439
|
|
|
295
440
|
opt = $.extend(
|
|
296
441
|
true,
|
|
@@ -348,9 +493,9 @@ import './daterangepicker.css';
|
|
|
348
493
|
showTopbar: true,
|
|
349
494
|
swapTime: false,
|
|
350
495
|
showWeekNumbers: false,
|
|
351
|
-
getWeekNumber(date) // date will be the first day of a week
|
|
496
|
+
getWeekNumber(date: Temporal.PlainDateTime) // date will be the first day of a week
|
|
352
497
|
{
|
|
353
|
-
return
|
|
498
|
+
return date.weekOfYear
|
|
354
499
|
},
|
|
355
500
|
customOpenAnimation: null,
|
|
356
501
|
customCloseAnimation: null,
|
|
@@ -360,8 +505,8 @@ import './daterangepicker.css';
|
|
|
360
505
|
opt,
|
|
361
506
|
);
|
|
362
507
|
|
|
363
|
-
opt.start =
|
|
364
|
-
opt.end =
|
|
508
|
+
opt.start = null;
|
|
509
|
+
opt.end = null;
|
|
365
510
|
|
|
366
511
|
opt.startWeek = false;
|
|
367
512
|
|
|
@@ -369,19 +514,31 @@ import './daterangepicker.css';
|
|
|
369
514
|
opt.isTouchDevice = 'ontouchstart' in window || (navigator as any).msMaxTouchPoints;
|
|
370
515
|
|
|
371
516
|
// if it is a touch device, hide hovering tooltip
|
|
372
|
-
if (opt.isTouchDevice) {
|
|
517
|
+
if (opt.isTouchDevice) {
|
|
518
|
+
opt.hoveringTooltip = null;
|
|
519
|
+
}
|
|
373
520
|
|
|
374
521
|
// show one month on mobile devices
|
|
375
|
-
let singleMonth = opt.singleMonth
|
|
376
|
-
if (singleMonth == 'auto') {
|
|
522
|
+
let singleMonth: boolean = (opt.singleMonth ?? 'auto') as any;
|
|
523
|
+
if ((singleMonth as any) == 'auto') {
|
|
524
|
+
singleMonth = ($(window).width() < 480) as any;
|
|
525
|
+
}
|
|
377
526
|
|
|
378
|
-
if (singleMonth) {
|
|
527
|
+
if (singleMonth) {
|
|
528
|
+
opt.stickyMonths = false;
|
|
529
|
+
}
|
|
379
530
|
|
|
380
|
-
if (!opt.showTopbar) {
|
|
531
|
+
if (!opt.showTopbar) {
|
|
532
|
+
opt.autoClose = true;
|
|
533
|
+
}
|
|
381
534
|
|
|
382
|
-
if (opt.startDate && typeof opt.startDate == 'string') {
|
|
535
|
+
if (opt.startDate && typeof opt.startDate == 'string') {
|
|
536
|
+
opt.startDate = DateUtils.getTemporalFromFormat(opt.startDate, opt.format);
|
|
537
|
+
}
|
|
383
538
|
|
|
384
|
-
if (opt.endDate && typeof opt.endDate == 'string') {
|
|
539
|
+
if (opt.endDate && typeof opt.endDate == 'string') {
|
|
540
|
+
opt.endDate = DateUtils.getTemporalFromFormat(opt.endDate, opt.format);
|
|
541
|
+
}
|
|
385
542
|
|
|
386
543
|
const languages = getLanguages();
|
|
387
544
|
let box;
|
|
@@ -409,23 +566,38 @@ import './daterangepicker.css';
|
|
|
409
566
|
open(0);
|
|
410
567
|
}
|
|
411
568
|
|
|
569
|
+
const getStartMs = () => {
|
|
570
|
+
if (opt.start) {
|
|
571
|
+
return opt.start[utcEpochMilliseconds]();
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return 0;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const getEndMs = () => {
|
|
578
|
+
if (opt.end) {
|
|
579
|
+
return opt.end[utcEpochMilliseconds]();
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
return 0;
|
|
583
|
+
}
|
|
584
|
+
|
|
412
585
|
// expose some api
|
|
413
586
|
$(this).data('dateRangePicker', {
|
|
414
587
|
setStart(d1) {
|
|
415
588
|
if (typeof d1 == 'string') {
|
|
416
|
-
d1 = DateUtils.
|
|
589
|
+
d1 = DateUtils.getTemporalFromFormat(d1, opt.format);
|
|
417
590
|
}
|
|
418
591
|
|
|
419
|
-
opt.end = false;
|
|
592
|
+
opt.end = false as any; //TODO: Could be null?
|
|
420
593
|
setSingleDate(d1);
|
|
421
594
|
|
|
422
595
|
return this;
|
|
423
596
|
},
|
|
424
597
|
setEnd(d2, silent) {
|
|
425
|
-
const start =
|
|
426
|
-
start.setTime(opt.start);
|
|
598
|
+
const start = opt.start;
|
|
427
599
|
if (typeof d2 == 'string') {
|
|
428
|
-
d2 = DateUtils.
|
|
600
|
+
d2 = DateUtils.getTemporalFromFormat(d2, opt.format);
|
|
429
601
|
}
|
|
430
602
|
|
|
431
603
|
setDateRange(
|
|
@@ -441,8 +613,8 @@ import './daterangepicker.css';
|
|
|
441
613
|
silent,
|
|
442
614
|
) {
|
|
443
615
|
if (typeof d1 == 'string' && typeof d2 == 'string') {
|
|
444
|
-
d1 = DateUtils.
|
|
445
|
-
d2 = DateUtils.
|
|
616
|
+
d1 = DateUtils.getTemporalFromFormat(d1, opt.format);
|
|
617
|
+
d2 = DateUtils.getTemporalFromFormat(d2, opt.format);
|
|
446
618
|
}
|
|
447
619
|
|
|
448
620
|
setDateRange(
|
|
@@ -539,9 +711,19 @@ import './daterangepicker.css';
|
|
|
539
711
|
// showSelectedInfo();
|
|
540
712
|
|
|
541
713
|
let defaultTopText = '';
|
|
542
|
-
if (opt.singleDate) {
|
|
714
|
+
if (opt.singleDate) {
|
|
715
|
+
defaultTopText = translate('default-single');
|
|
716
|
+
} else if (opt.minDays && opt.maxDays) {
|
|
717
|
+
defaultTopText = translate('default-range');
|
|
718
|
+
} else if (opt.minDays) {
|
|
719
|
+
defaultTopText = translate('default-more');
|
|
720
|
+
} else if (opt.maxDays) {
|
|
721
|
+
defaultTopText = translate('default-less');
|
|
722
|
+
} else {
|
|
723
|
+
defaultTopText = translate('default-default');
|
|
724
|
+
}
|
|
543
725
|
|
|
544
|
-
box.find('.default-top').html(defaultTopText.replace(/%d/, opt.minDays).replace(/%d/, opt.maxDays));
|
|
726
|
+
box.find('.default-top').html(defaultTopText.replace(/%d/, opt.minDays.toString()).replace(/%d/, opt.maxDays.toString()));
|
|
545
727
|
if (singleMonth) {
|
|
546
728
|
box.addClass('single-month');
|
|
547
729
|
} else {
|
|
@@ -647,60 +829,73 @@ import './daterangepicker.css';
|
|
|
647
829
|
|
|
648
830
|
box.find('.apply-btn').click(() => {
|
|
649
831
|
closeDatePicker();
|
|
650
|
-
const dateRange = getDateString(
|
|
832
|
+
const dateRange = getDateString(ensureTemporal(opt.start)) + opt.separator + getDateString(ensureTemporal(opt.end));
|
|
651
833
|
$(self).trigger('datepicker-apply', {
|
|
652
834
|
value: dateRange,
|
|
653
|
-
date1:
|
|
654
|
-
date2:
|
|
835
|
+
date1: ensureTemporal(opt.start),
|
|
836
|
+
date2: ensureTemporal(opt.end),
|
|
655
837
|
});
|
|
656
838
|
});
|
|
657
839
|
|
|
658
840
|
box.find('[custom]').click(function (this: any) {
|
|
659
841
|
const valueName = $(this).attr('custom');
|
|
660
|
-
opt.start =
|
|
661
|
-
opt.end =
|
|
842
|
+
opt.start = null;
|
|
843
|
+
opt.end = null;
|
|
662
844
|
box.find('.day.checked').removeClass('checked');
|
|
663
845
|
opt.setValue.call(selfDom, valueName);
|
|
664
846
|
checkSelectionValid();
|
|
665
847
|
showSelectedInfo(true);
|
|
666
848
|
showSelectedDays();
|
|
667
|
-
if (opt.autoClose) {
|
|
849
|
+
if (opt.autoClose) {
|
|
850
|
+
closeDatePicker();
|
|
851
|
+
}
|
|
668
852
|
});
|
|
669
853
|
|
|
670
854
|
box.find('[shortcut]').click(function (this: any) {
|
|
671
855
|
const shortcut = $(this).attr('shortcut');
|
|
672
|
-
let end =
|
|
673
|
-
let start:
|
|
674
|
-
let dir;
|
|
856
|
+
let end = dateNow();
|
|
857
|
+
let start: Temporal.PlainDateTime = false as any;
|
|
858
|
+
let dir: 1 | -1;
|
|
675
859
|
if (shortcut.includes('day')) {
|
|
676
860
|
const day = parseInt(shortcut.split(',', 2)[1], 10);
|
|
677
|
-
start =
|
|
678
|
-
end =
|
|
861
|
+
start = dateNow().add({ milliseconds: 86400000 * day });
|
|
862
|
+
end = end.add({ milliseconds: 86400000 * (day > 0 ? 1 : -1) });
|
|
679
863
|
} else if (shortcut.includes('week')) {
|
|
680
864
|
dir = shortcut.includes('prev,') ? -1 : 1;
|
|
681
|
-
|
|
682
|
-
|
|
865
|
+
const stopDayISO = opt.startOfWeek === 'monday'
|
|
866
|
+
? (dir === 1 ? 1 : 7) // forward → Monday, backward → Sunday
|
|
867
|
+
: (dir === 1 ? 7 : 6); // forward → Sunday, backward → Saturday
|
|
868
|
+
|
|
869
|
+
end = end.subtract({ days: 1 });
|
|
870
|
+
while (end.dayOfWeek !== stopDayISO) {
|
|
871
|
+
end = end.add({ days: dir });
|
|
872
|
+
}
|
|
683
873
|
|
|
684
|
-
|
|
685
|
-
while (end.getDay() != stopDay) { end = new DateWrapper(end.getTime() + dir * 86400000); }
|
|
686
|
-
start = new DateWrapper(end.getTime() + dir * 86400000 * 6);
|
|
874
|
+
start = end.add({ days: 6 * dir });
|
|
687
875
|
} else if (shortcut.includes('month')) {
|
|
688
876
|
dir = shortcut.includes('prev,') ? -1 : 1;
|
|
689
|
-
if (dir == 1) {
|
|
877
|
+
if (dir == 1) {
|
|
878
|
+
start = nextMonth(end);
|
|
879
|
+
} else {
|
|
880
|
+
start = prevMonth(end);
|
|
881
|
+
}
|
|
690
882
|
|
|
691
|
-
start.
|
|
883
|
+
start = start.with({ day: 1 });
|
|
692
884
|
end = nextMonth(start);
|
|
693
|
-
end.
|
|
694
|
-
end = new DateWrapper(end.getTime() - 86400000);
|
|
885
|
+
end = end.with({ day: 1 }).add({ milliseconds: -86400000 });
|
|
695
886
|
} else if (shortcut.includes('year')) {
|
|
696
887
|
dir = shortcut.includes('prev,') ? -1 : 1;
|
|
697
|
-
start =
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
end.
|
|
888
|
+
start = dateNow().with({
|
|
889
|
+
year: end.year + dir,
|
|
890
|
+
month: 1,
|
|
891
|
+
day: 1
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
end = end.with({
|
|
895
|
+
year: end.year + dir,
|
|
896
|
+
month: 12,
|
|
897
|
+
day: 31
|
|
898
|
+
});
|
|
704
899
|
} else if (shortcut == 'custom') {
|
|
705
900
|
const name = $(this).html();
|
|
706
901
|
if (opt.customShortcuts && opt.customShortcuts.length > 0) {
|
|
@@ -915,9 +1110,9 @@ import './daterangepicker.css';
|
|
|
915
1110
|
|
|
916
1111
|
function getValidValue(date: string, format: string) {
|
|
917
1112
|
try {
|
|
918
|
-
return DateUtils.
|
|
1113
|
+
return DateUtils.getTemporalFromFormat(date, format);
|
|
919
1114
|
} catch (error) {
|
|
920
|
-
return
|
|
1115
|
+
return dateNow();
|
|
921
1116
|
}
|
|
922
1117
|
}
|
|
923
1118
|
|
|
@@ -944,9 +1139,9 @@ import './daterangepicker.css';
|
|
|
944
1139
|
box.find('.month-wrapper').width(calculateCalendarWidth());
|
|
945
1140
|
}
|
|
946
1141
|
|
|
947
|
-
function renderTime(name: 'time1' | 'time2', date:
|
|
948
|
-
box.find(`.${name} input[type=range].hour-range`).val(date.
|
|
949
|
-
box.find(`.${name} input[type=range].minute-range`).val(date.
|
|
1142
|
+
function renderTime(name: 'time1' | 'time2', date: Temporal.PlainDateTime) {
|
|
1143
|
+
box.find(`.${name} input[type=range].hour-range`).val(date.hour);
|
|
1144
|
+
box.find(`.${name} input[type=range].minute-range`).val(date.minute);
|
|
950
1145
|
setTime(
|
|
951
1146
|
name,
|
|
952
1147
|
getHourString(date),
|
|
@@ -954,23 +1149,16 @@ import './daterangepicker.css';
|
|
|
954
1149
|
);
|
|
955
1150
|
}
|
|
956
1151
|
|
|
957
|
-
function changeTime(name: 'start' | 'end', date:
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
opt[name] = new DateWrapper(
|
|
963
|
-
date.getFullYear(),
|
|
964
|
-
date.getMonth(),
|
|
965
|
-
date.getDate(),
|
|
966
|
-
Number((opt[`${name}Time`] as DateWrapper).getHours()),
|
|
967
|
-
Number((opt[`${name}Time`] as DateWrapper).getMinutes()),
|
|
968
|
-
);
|
|
1152
|
+
function changeTime(name: 'start' | 'end', date: Temporal.PlainDateTime) {
|
|
1153
|
+
opt[name] = ensureTemporal(date).with({
|
|
1154
|
+
hour: Number((opt[`${name}Time`] as Temporal.PlainDateTime).hour),
|
|
1155
|
+
minute: Number((opt[`${name}Time`] as Temporal.PlainDateTime).minute),
|
|
1156
|
+
});
|
|
969
1157
|
}
|
|
970
1158
|
|
|
971
1159
|
function swapTime() {
|
|
972
|
-
renderTime('time1', opt.start);
|
|
973
|
-
renderTime('time2', opt.end);
|
|
1160
|
+
renderTime('time1', ensureTemporal(opt.start));
|
|
1161
|
+
renderTime('time2', ensureTemporal(opt.end));
|
|
974
1162
|
}
|
|
975
1163
|
|
|
976
1164
|
function setTime(
|
|
@@ -983,28 +1171,25 @@ import './daterangepicker.css';
|
|
|
983
1171
|
switch (name) {
|
|
984
1172
|
case 'time1':
|
|
985
1173
|
if (opt.start) {
|
|
986
|
-
setRange('start',
|
|
1174
|
+
setRange('start', ensureTemporal(opt.start));
|
|
987
1175
|
}
|
|
988
1176
|
|
|
989
|
-
setRange('startTime',
|
|
1177
|
+
setRange('startTime', ensureTemporal(opt.startTime));
|
|
990
1178
|
break;
|
|
991
1179
|
case 'time2':
|
|
992
1180
|
if (opt.end) {
|
|
993
|
-
setRange('end',
|
|
1181
|
+
setRange('end', ensureTemporal(opt.end));
|
|
994
1182
|
}
|
|
995
1183
|
|
|
996
|
-
setRange('endTime',
|
|
1184
|
+
setRange('endTime', ensureTemporal(opt.endTime));
|
|
997
1185
|
break;
|
|
998
1186
|
}
|
|
999
1187
|
|
|
1000
|
-
function setRange(name: 'start' | 'startTime' | 'end' | 'endTime', timePoint:
|
|
1001
|
-
opt[name] =
|
|
1002
|
-
timePoint
|
|
1003
|
-
timePoint
|
|
1004
|
-
|
|
1005
|
-
Number(hour || getHourString(timePoint)),
|
|
1006
|
-
Number(minute || getMinuteString(timePoint)),
|
|
1007
|
-
);
|
|
1188
|
+
function setRange(name: 'start' | 'startTime' | 'end' | 'endTime', timePoint: Temporal.PlainDateTime) {
|
|
1189
|
+
opt[name] = ensureTemporal(timePoint).with({
|
|
1190
|
+
hour: Number(hour || getHourString(timePoint)),
|
|
1191
|
+
minute: Number(minute || getMinuteString(timePoint)),
|
|
1192
|
+
})
|
|
1008
1193
|
}
|
|
1009
1194
|
checkSelectionValid();
|
|
1010
1195
|
showSelectedInfo();
|
|
@@ -1012,8 +1197,8 @@ import './daterangepicker.css';
|
|
|
1012
1197
|
}
|
|
1013
1198
|
|
|
1014
1199
|
function clearSelection() {
|
|
1015
|
-
opt.start =
|
|
1016
|
-
opt.end =
|
|
1200
|
+
opt.start = null;
|
|
1201
|
+
opt.end = null;
|
|
1017
1202
|
box.find('.day.checked').removeClass('checked');
|
|
1018
1203
|
box.find('.day.last-date-selected').removeClass('last-date-selected');
|
|
1019
1204
|
box.find('.day.first-date-selected').removeClass('first-date-selected');
|
|
@@ -1023,86 +1208,67 @@ import './daterangepicker.css';
|
|
|
1023
1208
|
showSelectedDays();
|
|
1024
1209
|
}
|
|
1025
1210
|
|
|
1026
|
-
function handleStart(
|
|
1027
|
-
let r =
|
|
1028
|
-
const date =
|
|
1211
|
+
function handleStart(d: Temporal.PlainDateTime): Temporal.PlainDateTime {
|
|
1212
|
+
let r = d;
|
|
1213
|
+
const date = ensureTemporal(d);
|
|
1029
1214
|
|
|
1030
1215
|
if (opt.batchMode === 'week-range') {
|
|
1031
|
-
const
|
|
1032
|
-
const
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
0,
|
|
1046
|
-
0,
|
|
1047
|
-
0,
|
|
1048
|
-
);
|
|
1049
|
-
r = startOfWeekDate.getTime();
|
|
1216
|
+
const dow = date.dayOfWeek; // 1..7 (Mon..Sun)
|
|
1217
|
+
const daysBack = opt.startOfWeek === "monday"
|
|
1218
|
+
? (dow === 7 ? 6 : dow - 1) // Mon=0 back, Sun=6 back
|
|
1219
|
+
: (dow % 7); // Sun=0 back, Mon=1 back, ...
|
|
1220
|
+
r = date.with({
|
|
1221
|
+
hour: 0,
|
|
1222
|
+
minute: 0,
|
|
1223
|
+
second: 0,
|
|
1224
|
+
millisecond: 0,
|
|
1225
|
+
microsecond: 0,
|
|
1226
|
+
nanosecond: 0
|
|
1227
|
+
}).subtract({
|
|
1228
|
+
days: daysBack
|
|
1229
|
+
});
|
|
1050
1230
|
} else if (opt.batchMode === 'month-range') {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
0
|
|
1058
|
-
|
|
1059
|
-
0,
|
|
1060
|
-
0,
|
|
1061
|
-
);
|
|
1062
|
-
r = startOfMonth.getTime();
|
|
1231
|
+
r = date.with({
|
|
1232
|
+
day: 1,
|
|
1233
|
+
hour: 0,
|
|
1234
|
+
minute: 0,
|
|
1235
|
+
second: 0,
|
|
1236
|
+
millisecond: 0,
|
|
1237
|
+
microsecond: 0
|
|
1238
|
+
});
|
|
1063
1239
|
}
|
|
1064
1240
|
|
|
1065
1241
|
return r;
|
|
1066
1242
|
}
|
|
1067
1243
|
|
|
1068
|
-
function handleEnd(
|
|
1069
|
-
let r =
|
|
1070
|
-
const date =
|
|
1244
|
+
function handleEnd(d: Temporal.PlainDateTime): Temporal.PlainDateTime {
|
|
1245
|
+
let r = d;
|
|
1246
|
+
const date = ensureTemporal(d);
|
|
1071
1247
|
|
|
1072
1248
|
if (opt.batchMode === 'week-range') {
|
|
1073
|
-
const
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
endOfWeekDate.setHours(
|
|
1087
|
-
23,
|
|
1088
|
-
59,
|
|
1089
|
-
59,
|
|
1090
|
-
999,
|
|
1091
|
-
);
|
|
1092
|
-
r = endOfWeekDate.getTime();
|
|
1249
|
+
const dow = date.dayOfWeek;
|
|
1250
|
+
const diff = opt.startOfWeek === "monday"
|
|
1251
|
+
? (dow === 7 ? 0 : 7 - dow) // ends on Sunday
|
|
1252
|
+
: 6 - (dow % 7); // ends on Saturday
|
|
1253
|
+
|
|
1254
|
+
r = date.add({ days: diff }).with({
|
|
1255
|
+
hour: 23,
|
|
1256
|
+
minute: 59,
|
|
1257
|
+
second: 59,
|
|
1258
|
+
millisecond: 999,
|
|
1259
|
+
microsecond: 0,
|
|
1260
|
+
nanosecond: 0
|
|
1261
|
+
});
|
|
1093
1262
|
} else if (opt.batchMode === 'month-range') {
|
|
1094
|
-
|
|
1095
|
-
date.
|
|
1096
|
-
date.
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
999,
|
|
1104
|
-
);
|
|
1105
|
-
r = endOfMonth.getTime();
|
|
1263
|
+
r = Temporal.PlainDateTime.from({
|
|
1264
|
+
year: date.year,
|
|
1265
|
+
month: date.month
|
|
1266
|
+
}).add({ months: 1 }).subtract({ days: 1 }).with({
|
|
1267
|
+
hour: 23,
|
|
1268
|
+
minute: 59,
|
|
1269
|
+
second: 59,
|
|
1270
|
+
millisecond: 999
|
|
1271
|
+
});
|
|
1106
1272
|
}
|
|
1107
1273
|
|
|
1108
1274
|
return r;
|
|
@@ -1114,123 +1280,98 @@ import './daterangepicker.css';
|
|
|
1114
1280
|
const time = Number(day.attr('time'));
|
|
1115
1281
|
day.addClass('checked');
|
|
1116
1282
|
|
|
1117
|
-
const date =
|
|
1283
|
+
const date = ensureTemporal(time);
|
|
1118
1284
|
|
|
1119
1285
|
if (opt.singleDate) {
|
|
1120
|
-
opt.start =
|
|
1121
|
-
opt.end =
|
|
1286
|
+
opt.start = date;
|
|
1287
|
+
opt.end = null;
|
|
1122
1288
|
} else if (opt.batchMode === 'week') {
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1289
|
+
const dow = date.dayOfWeek; // 1=Mon … 7=Sun
|
|
1290
|
+
|
|
1291
|
+
let start: Temporal.PlainDateTime;
|
|
1292
|
+
let end: Temporal.PlainDateTime;
|
|
1293
|
+
|
|
1294
|
+
if (opt.startOfWeek === "monday") {
|
|
1295
|
+
// ISO weeks: Monday to Sunday
|
|
1296
|
+
const diffToMonday = dow === 7 ? -6 : 1 - dow; // Sunday => go back 6, else back to Monday
|
|
1297
|
+
start = date.add({ days: diffToMonday }).with({
|
|
1298
|
+
hour: 0, minute: 0, second: 0, millisecond: 0,
|
|
1299
|
+
microsecond: 0, nanosecond: 0
|
|
1300
|
+
});
|
|
1301
|
+
end = start.add({ days: 6 }).with({
|
|
1302
|
+
hour: 23, minute: 59, second: 59, millisecond: 999,
|
|
1303
|
+
microsecond: 0, nanosecond: 0
|
|
1304
|
+
});
|
|
1131
1305
|
} else {
|
|
1132
1306
|
// Sunday to Saturday
|
|
1133
|
-
|
|
1134
|
-
|
|
1307
|
+
const diffToSunday = dow % 7 * -1; // dow=7 (Sunday) -> 0 back, dow=1 (Monday) -> -1 back, etc.
|
|
1308
|
+
start = date.add({ days: diffToSunday }).with({
|
|
1309
|
+
hour: 0, minute: 0, second: 0, millisecond: 0,
|
|
1310
|
+
microsecond: 0, nanosecond: 0
|
|
1311
|
+
});
|
|
1312
|
+
end = start.add({ days: 6 }).with({
|
|
1313
|
+
hour: 23, minute: 59, second: 59, millisecond: 999,
|
|
1314
|
+
microsecond: 0, nanosecond: 0
|
|
1315
|
+
});
|
|
1135
1316
|
}
|
|
1136
1317
|
|
|
1137
|
-
start
|
|
1138
|
-
|
|
1139
|
-
0,
|
|
1140
|
-
0,
|
|
1141
|
-
0,
|
|
1142
|
-
);
|
|
1143
|
-
end.setHours(
|
|
1144
|
-
23,
|
|
1145
|
-
59,
|
|
1146
|
-
59,
|
|
1147
|
-
999,
|
|
1148
|
-
);
|
|
1149
|
-
|
|
1150
|
-
opt.start = start.getTime();
|
|
1151
|
-
opt.end = end.getTime();
|
|
1318
|
+
opt.start = start;
|
|
1319
|
+
opt.end = end;
|
|
1152
1320
|
} else if (opt.batchMode === 'workweek') {
|
|
1153
|
-
const
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
const dayOfWeek = date.getDay();
|
|
1157
|
-
const diffToMonday = (dayOfWeek === 0 ? -6 : 1 - dayOfWeek);
|
|
1158
|
-
|
|
1159
|
-
monday.setDate(date.getDate() + diffToMonday);
|
|
1160
|
-
monday.setHours(
|
|
1161
|
-
0,
|
|
1162
|
-
0,
|
|
1163
|
-
0,
|
|
1164
|
-
0,
|
|
1165
|
-
);
|
|
1321
|
+
const dow = date.dayOfWeek; // 1=Mon … 7=Sun
|
|
1322
|
+
const diffToMonday = dow === 7 ? -6 : 1 - dow; // if Sunday, go back 6 days, else back to Monday
|
|
1166
1323
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
59,
|
|
1172
|
-
999,
|
|
1173
|
-
);
|
|
1324
|
+
const monday = date.add({ days: diffToMonday }).with({
|
|
1325
|
+
hour: 0, minute: 0, second: 0, millisecond: 0,
|
|
1326
|
+
microsecond: 0, nanosecond: 0
|
|
1327
|
+
});
|
|
1174
1328
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1329
|
+
const friday = monday.add({ days: 4 }).with({
|
|
1330
|
+
hour: 23, minute: 59, second: 59, millisecond: 999,
|
|
1331
|
+
microsecond: 0, nanosecond: 0
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1334
|
+
opt.start = monday;
|
|
1335
|
+
opt.end = friday;
|
|
1177
1336
|
} else if (opt.batchMode === 'weekend') {
|
|
1178
|
-
const
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
const diffToSaturday = 6 -
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
0,
|
|
1188
|
-
0,
|
|
1189
|
-
0,
|
|
1190
|
-
);
|
|
1337
|
+
const dow = date.dayOfWeek; // 1=Mon … 7=Sun
|
|
1338
|
+
|
|
1339
|
+
// In JS Date: Saturday = 6, Sunday = 0
|
|
1340
|
+
// In Temporal: Saturday = 6, Sunday = 7
|
|
1341
|
+
const diffToSaturday = 6 - dow;
|
|
1342
|
+
const saturday = date.add({ days: diffToSaturday }).with({
|
|
1343
|
+
hour: 0, minute: 0, second: 0, millisecond: 0,
|
|
1344
|
+
microsecond: 0, nanosecond: 0
|
|
1345
|
+
});
|
|
1191
1346
|
|
|
1192
|
-
sunday
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
59,
|
|
1197
|
-
999,
|
|
1198
|
-
);
|
|
1347
|
+
const sunday = saturday.add({ days: 1 }).with({
|
|
1348
|
+
hour: 23, minute: 59, second: 59, millisecond: 999,
|
|
1349
|
+
microsecond: 0, nanosecond: 0
|
|
1350
|
+
});
|
|
1199
1351
|
|
|
1200
|
-
opt.start = saturday
|
|
1201
|
-
opt.end = sunday
|
|
1352
|
+
opt.start = saturday;
|
|
1353
|
+
opt.end = sunday;
|
|
1202
1354
|
} else if (opt.batchMode === 'month') {
|
|
1203
|
-
const startOfMonth =
|
|
1204
|
-
|
|
1205
|
-
date.getMonth(),
|
|
1206
|
-
1,
|
|
1207
|
-
);
|
|
1208
|
-
startOfMonth.setHours(
|
|
1209
|
-
0,
|
|
1210
|
-
0,
|
|
1211
|
-
0,
|
|
1212
|
-
0,
|
|
1213
|
-
);
|
|
1355
|
+
const startOfMonth = Temporal.PlainDate.from({ year: date.year, month: date.month, day: 1 })
|
|
1356
|
+
.toPlainDateTime({ hour: 0, minute: 0, second: 0, millisecond: 0, microsecond: 0, nanosecond: 0 });
|
|
1214
1357
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
59,
|
|
1223
|
-
|
|
1224
|
-
999,
|
|
1225
|
-
);
|
|
1358
|
+
// last day of month: jump to first day of next month, subtract one day
|
|
1359
|
+
const endOfMonthDate = Temporal.PlainYearMonth.from({ year: date.year, month: date.month })
|
|
1360
|
+
.add({ months: 1 })
|
|
1361
|
+
.toPlainDate({ day: 1 })
|
|
1362
|
+
.subtract({ days: 1 });
|
|
1363
|
+
|
|
1364
|
+
const endOfMonth = endOfMonthDate.toPlainDateTime({
|
|
1365
|
+
hour: 23, minute: 59, second: 59, millisecond: 999, microsecond: 0, nanosecond: 0
|
|
1366
|
+
});
|
|
1226
1367
|
|
|
1227
|
-
opt.start = startOfMonth
|
|
1228
|
-
opt.end = endOfMonth
|
|
1368
|
+
opt.start = startOfMonth;
|
|
1369
|
+
opt.end = endOfMonth;
|
|
1229
1370
|
} else if ((opt.start && opt.end) || (!opt.start && !opt.end)) {
|
|
1230
|
-
opt.start = handleStart(
|
|
1231
|
-
opt.end =
|
|
1371
|
+
opt.start = handleStart(date);
|
|
1372
|
+
opt.end = null;
|
|
1232
1373
|
} else if (opt.start) {
|
|
1233
|
-
opt.end = handleEnd(
|
|
1374
|
+
opt.end = handleEnd(date);
|
|
1234
1375
|
if (opt.time?.enabled) {
|
|
1235
1376
|
changeTime('end', opt.end);
|
|
1236
1377
|
}
|
|
@@ -1248,7 +1389,7 @@ import './daterangepicker.css';
|
|
|
1248
1389
|
}
|
|
1249
1390
|
|
|
1250
1391
|
// In case the start is after the end, swap the timestamps
|
|
1251
|
-
if (!opt.singleDate && opt.start && opt.end &&
|
|
1392
|
+
if (!opt.singleDate && opt.start && opt.end && getStartMs() > getEndMs()) {
|
|
1252
1393
|
const tmp = opt.end;
|
|
1253
1394
|
opt.end = handleEnd(opt.start);
|
|
1254
1395
|
opt.start = handleStart(tmp);
|
|
@@ -1257,13 +1398,13 @@ import './daterangepicker.css';
|
|
|
1257
1398
|
}
|
|
1258
1399
|
}
|
|
1259
1400
|
|
|
1260
|
-
opt.start =
|
|
1261
|
-
opt.end =
|
|
1401
|
+
opt.start = ensureTemporal(opt.start);
|
|
1402
|
+
opt.end = ensureTemporal(opt.end);
|
|
1262
1403
|
|
|
1263
1404
|
clearHovering();
|
|
1264
1405
|
if (opt.start && !opt.end) {
|
|
1265
1406
|
$(self).trigger('datepicker-first-date-selected', {
|
|
1266
|
-
date1:
|
|
1407
|
+
date1: opt.start,
|
|
1267
1408
|
});
|
|
1268
1409
|
dayHovering(day);
|
|
1269
1410
|
}
|
|
@@ -1302,41 +1443,61 @@ import './daterangepicker.css';
|
|
|
1302
1443
|
autoclose();
|
|
1303
1444
|
}
|
|
1304
1445
|
|
|
1305
|
-
function isValidTime(
|
|
1306
|
-
|
|
1307
|
-
|
|
1446
|
+
function isValidTime(date: Temporal.PlainDateTime) {
|
|
1447
|
+
if (opt.startDate && compare_day(date, opt.startDate) < 0) {
|
|
1448
|
+
return false;
|
|
1449
|
+
}
|
|
1308
1450
|
|
|
1309
|
-
if (opt.endDate && compare_day(
|
|
1451
|
+
if (opt.endDate && compare_day(date, opt.endDate) > 0) {
|
|
1452
|
+
return false;
|
|
1453
|
+
}
|
|
1310
1454
|
|
|
1311
1455
|
if (opt.start && !opt.end && !opt.singleDate) {
|
|
1312
1456
|
// check maxDays and minDays setting
|
|
1313
|
-
if (opt.maxDays > 0 && countDays(
|
|
1457
|
+
if (opt.maxDays > 0 && countDays(date, opt.start) > opt.maxDays) {
|
|
1458
|
+
return false;
|
|
1459
|
+
}
|
|
1314
1460
|
|
|
1315
|
-
if (opt.minDays > 0 && countDays(
|
|
1461
|
+
if (opt.minDays > 0 && countDays(date, opt.start) < opt.minDays) {
|
|
1462
|
+
return false;
|
|
1463
|
+
}
|
|
1316
1464
|
|
|
1317
1465
|
// check selectForward and selectBackward
|
|
1318
|
-
if (opt.selectForward &&
|
|
1466
|
+
if (opt.selectForward && date < opt.start) {
|
|
1467
|
+
return false;
|
|
1468
|
+
}
|
|
1319
1469
|
|
|
1320
|
-
if (opt.selectBackward &&
|
|
1470
|
+
if (opt.selectBackward && date > opt.start) {
|
|
1471
|
+
return false;
|
|
1472
|
+
}
|
|
1321
1473
|
|
|
1322
1474
|
// check disabled days
|
|
1323
1475
|
if (opt.beforeShowDay && typeof opt.beforeShowDay == 'function') {
|
|
1324
1476
|
let valid = true;
|
|
1325
|
-
let timeTmp =
|
|
1477
|
+
let timeTmp = date;
|
|
1326
1478
|
while (countDays(timeTmp, opt.start) > 1) {
|
|
1327
|
-
const arr = opt.beforeShowDay(
|
|
1479
|
+
const arr = opt.beforeShowDay(timeTmp);
|
|
1328
1480
|
if (!arr[0]) {
|
|
1329
1481
|
valid = false;
|
|
1330
1482
|
break;
|
|
1331
1483
|
}
|
|
1332
1484
|
|
|
1333
|
-
if (Math.abs(timeTmp -
|
|
1485
|
+
if (Math.abs(timeTmp[utcEpochMilliseconds]() - getStartMs()) < 86400000) {
|
|
1486
|
+
break;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
if (timeTmp > opt.start) {
|
|
1490
|
+
timeTmp = timeTmp.subtract({ milliseconds: 86400000 });
|
|
1491
|
+
}
|
|
1334
1492
|
|
|
1335
|
-
if (timeTmp
|
|
1493
|
+
if (timeTmp < opt.start) {
|
|
1494
|
+
timeTmp = timeTmp.add({ milliseconds: 86400000 });
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1336
1497
|
|
|
1337
|
-
|
|
1498
|
+
if (!valid) {
|
|
1499
|
+
return false;
|
|
1338
1500
|
}
|
|
1339
|
-
if (!valid) { return false; }
|
|
1340
1501
|
}
|
|
1341
1502
|
}
|
|
1342
1503
|
|
|
@@ -1348,14 +1509,18 @@ import './daterangepicker.css';
|
|
|
1348
1509
|
if (opt.start && !opt.end) {
|
|
1349
1510
|
box.find('.day.toMonth.valid').each(function (this: any) {
|
|
1350
1511
|
const time = parseInt($(this).attr('time'), 10);
|
|
1351
|
-
if (!isValidTime(time))
|
|
1512
|
+
if (!isValidTime(ensureTemporal(time))) {
|
|
1513
|
+
$(this).addClass('invalid tmp').removeClass('valid');
|
|
1514
|
+
} else {
|
|
1515
|
+
$(this).addClass('valid tmp').removeClass('invalid');
|
|
1516
|
+
}
|
|
1352
1517
|
});
|
|
1353
1518
|
}
|
|
1354
1519
|
|
|
1355
1520
|
return true;
|
|
1356
1521
|
}
|
|
1357
1522
|
|
|
1358
|
-
function dayHovering(day) {
|
|
1523
|
+
function dayHovering(day: JQuery) {
|
|
1359
1524
|
const hoverTime = parseInt(day.attr('time'));
|
|
1360
1525
|
let tooltip = '';
|
|
1361
1526
|
let tooltipClass = '';
|
|
@@ -1381,8 +1546,8 @@ import './daterangepicker.css';
|
|
|
1381
1546
|
if (
|
|
1382
1547
|
(opt.start && !opt.end)
|
|
1383
1548
|
&& (
|
|
1384
|
-
(
|
|
1385
|
-
|| (
|
|
1549
|
+
(getStartMs() < time && hoverTime >= time)
|
|
1550
|
+
|| (getStartMs() > time && hoverTime <= time)
|
|
1386
1551
|
)
|
|
1387
1552
|
) {
|
|
1388
1553
|
$(this).addClass('hovering');
|
|
@@ -1392,7 +1557,8 @@ import './daterangepicker.css';
|
|
|
1392
1557
|
});
|
|
1393
1558
|
|
|
1394
1559
|
if (opt.start && !opt.end) {
|
|
1395
|
-
const
|
|
1560
|
+
const tHoverTime = ensureTemporal(hoverTime);
|
|
1561
|
+
const days = countDays(tHoverTime, opt.start);
|
|
1396
1562
|
if (opt.hoveringTooltip) {
|
|
1397
1563
|
tooltipClass = 'drp-tooltip-normal';
|
|
1398
1564
|
|
|
@@ -1400,7 +1566,7 @@ import './daterangepicker.css';
|
|
|
1400
1566
|
tooltip = opt.hoveringTooltip(
|
|
1401
1567
|
days,
|
|
1402
1568
|
opt.start,
|
|
1403
|
-
|
|
1569
|
+
tHoverTime,
|
|
1404
1570
|
);
|
|
1405
1571
|
} else if (opt.hoveringTooltip === true && days > 1) {
|
|
1406
1572
|
tooltip = `${days} ${translate('days')}`;
|
|
@@ -1411,7 +1577,7 @@ import './daterangepicker.css';
|
|
|
1411
1577
|
} else {
|
|
1412
1578
|
if (opt.maxDaysTooltip != null) {
|
|
1413
1579
|
const time = parseInt(day.attr('time'));
|
|
1414
|
-
if (time >
|
|
1580
|
+
if (opt.start != null && time > getStartMs()) {
|
|
1415
1581
|
tooltip = opt.maxDaysTooltip(opt.maxDays);
|
|
1416
1582
|
tooltipClass = 'drp-tooltip-error';
|
|
1417
1583
|
}
|
|
@@ -1466,19 +1632,23 @@ import './daterangepicker.css';
|
|
|
1466
1632
|
}
|
|
1467
1633
|
|
|
1468
1634
|
function checkSelectionValid() {
|
|
1469
|
-
const days = Math.ceil((
|
|
1635
|
+
const days = Math.ceil((getEndMs() - getStartMs()) / 86400000) + 1;
|
|
1470
1636
|
if (opt.singleDate) { // Validate if only start is there
|
|
1471
|
-
if (opt.start && !opt.end) {
|
|
1637
|
+
if (opt.start && !opt.end) {
|
|
1638
|
+
box.find('.drp_top-bar').removeClass('error').addClass('normal');
|
|
1639
|
+
} else {
|
|
1640
|
+
box.find('.drp_top-bar').removeClass('error').removeClass('normal');
|
|
1641
|
+
}
|
|
1472
1642
|
} else if (opt.maxDays && days > opt.maxDays) {
|
|
1473
|
-
opt.start =
|
|
1474
|
-
opt.end =
|
|
1643
|
+
opt.start = null;
|
|
1644
|
+
opt.end = null;
|
|
1475
1645
|
box.find('.day').removeClass('checked');
|
|
1476
|
-
box.find('.drp_top-bar').removeClass('normal').addClass('error').find('.error-top').html(translate('less-than').replace('%d', opt.maxDays));
|
|
1646
|
+
box.find('.drp_top-bar').removeClass('normal').addClass('error').find('.error-top').html(translate('less-than').replace('%d', opt.maxDays.toString()));
|
|
1477
1647
|
} else if (opt.minDays && days < opt.minDays) {
|
|
1478
|
-
opt.start =
|
|
1479
|
-
opt.end =
|
|
1648
|
+
opt.start = null;
|
|
1649
|
+
opt.end = null;
|
|
1480
1650
|
box.find('.day').removeClass('checked');
|
|
1481
|
-
box.find('.drp_top-bar').removeClass('normal').addClass('error').find('.error-top').html(translate('more-than').replace('%d', opt.minDays));
|
|
1651
|
+
box.find('.drp_top-bar').removeClass('normal').addClass('error').find('.error-top').html(translate('more-than').replace('%d', opt.minDays.toString()));
|
|
1482
1652
|
} else {
|
|
1483
1653
|
if (opt.start || opt.end) { box.find('.drp_top-bar').removeClass('error').addClass('normal'); } else { box.find('.drp_top-bar').removeClass('error').removeClass('normal'); }
|
|
1484
1654
|
}
|
|
@@ -1494,8 +1664,8 @@ import './daterangepicker.css';
|
|
|
1494
1664
|
(opt.start && opt.startDate && compare_day(opt.start, opt.startDate) < 0)
|
|
1495
1665
|
|| (opt.end && opt.endDate && compare_day(opt.end, opt.endDate) > 0)
|
|
1496
1666
|
) {
|
|
1497
|
-
opt.start =
|
|
1498
|
-
opt.end =
|
|
1667
|
+
opt.start = null;
|
|
1668
|
+
opt.end = null;
|
|
1499
1669
|
box.find('.day').removeClass('checked');
|
|
1500
1670
|
}
|
|
1501
1671
|
}
|
|
@@ -1506,45 +1676,45 @@ import './daterangepicker.css';
|
|
|
1506
1676
|
box.find('.end-day').html('...');
|
|
1507
1677
|
box.find('.selected-days').hide();
|
|
1508
1678
|
if (opt.start) {
|
|
1509
|
-
box.find('.start-day').html(getDateString(
|
|
1679
|
+
box.find('.start-day').html(getDateString(opt.start));
|
|
1510
1680
|
}
|
|
1511
1681
|
|
|
1512
1682
|
if (opt.end) {
|
|
1513
|
-
box.find('.end-day').html(getDateString(
|
|
1683
|
+
box.find('.end-day').html(getDateString(opt.end));
|
|
1514
1684
|
}
|
|
1515
1685
|
|
|
1516
1686
|
let dateRange;
|
|
1517
1687
|
if (opt.start && opt.singleDate) {
|
|
1518
1688
|
box.find('.apply-btn').removeClass('disabled');
|
|
1519
|
-
dateRange = getDateString(
|
|
1689
|
+
dateRange = getDateString(opt.start);
|
|
1520
1690
|
opt.setValue.call(
|
|
1521
1691
|
selfDom,
|
|
1522
1692
|
dateRange,
|
|
1523
|
-
getDateString(
|
|
1524
|
-
getDateString(
|
|
1693
|
+
getDateString(opt.start),
|
|
1694
|
+
getDateString(opt.end),
|
|
1525
1695
|
);
|
|
1526
1696
|
|
|
1527
1697
|
if (initiated && !silent) {
|
|
1528
1698
|
$(self).trigger('datepicker-change', {
|
|
1529
1699
|
value: dateRange,
|
|
1530
|
-
date1:
|
|
1700
|
+
date1: opt.start,
|
|
1531
1701
|
});
|
|
1532
1702
|
}
|
|
1533
1703
|
} else if (opt.start && opt.end) {
|
|
1534
1704
|
box.find('.selected-days').show().find('.selected-days-num').html(countDays(opt.end, opt.start));
|
|
1535
1705
|
box.find('.apply-btn').removeClass('disabled');
|
|
1536
|
-
dateRange = getDateString(
|
|
1706
|
+
dateRange = getDateString(opt.start) + opt.separator + getDateString(opt.end);
|
|
1537
1707
|
opt.setValue.call(
|
|
1538
1708
|
selfDom,
|
|
1539
1709
|
dateRange,
|
|
1540
|
-
getDateString(
|
|
1541
|
-
getDateString(
|
|
1710
|
+
getDateString(opt.start),
|
|
1711
|
+
getDateString(opt.end),
|
|
1542
1712
|
);
|
|
1543
1713
|
if (initiated && !silent) {
|
|
1544
1714
|
$(self).trigger('datepicker-change', {
|
|
1545
1715
|
value: dateRange,
|
|
1546
|
-
date1:
|
|
1547
|
-
date2:
|
|
1716
|
+
date1: opt.start,
|
|
1717
|
+
date2: opt.end,
|
|
1548
1718
|
});
|
|
1549
1719
|
}
|
|
1550
1720
|
} else if (forceValid) {
|
|
@@ -1554,16 +1724,16 @@ import './daterangepicker.css';
|
|
|
1554
1724
|
}
|
|
1555
1725
|
}
|
|
1556
1726
|
|
|
1557
|
-
function countDays(start, end) {
|
|
1727
|
+
function countDays(start: Temporal.PlainDateTime, end: Temporal.PlainDateTime) {
|
|
1558
1728
|
return Math.abs(daysFrom1970(start) - daysFrom1970(end)) + 1;
|
|
1559
1729
|
}
|
|
1560
1730
|
|
|
1561
1731
|
function setDateRange(
|
|
1562
|
-
date1
|
|
1563
|
-
date2
|
|
1564
|
-
silent
|
|
1732
|
+
date1: Temporal.PlainDateTime,
|
|
1733
|
+
date2: Temporal.PlainDateTime,
|
|
1734
|
+
silent?: boolean,
|
|
1565
1735
|
) {
|
|
1566
|
-
if (date1
|
|
1736
|
+
if (date1[utcEpochMilliseconds]() > date2[utcEpochMilliseconds]()) {
|
|
1567
1737
|
let tmp = date2;
|
|
1568
1738
|
date2 = date1;
|
|
1569
1739
|
date1 = tmp;
|
|
@@ -1571,9 +1741,13 @@ import './daterangepicker.css';
|
|
|
1571
1741
|
}
|
|
1572
1742
|
|
|
1573
1743
|
let valid = true;
|
|
1574
|
-
if (opt.startDate && compare_day(date1, opt.startDate) < 0) {
|
|
1744
|
+
if (opt.startDate && compare_day(date1, opt.startDate) < 0) {
|
|
1745
|
+
valid = false;
|
|
1746
|
+
}
|
|
1575
1747
|
|
|
1576
|
-
if (opt.endDate && compare_day(date2, opt.endDate) > 0) {
|
|
1748
|
+
if (opt.endDate && compare_day(date2, opt.endDate) > 0) {
|
|
1749
|
+
valid = false;
|
|
1750
|
+
}
|
|
1577
1751
|
|
|
1578
1752
|
if (!valid) {
|
|
1579
1753
|
showMonth(opt.startDate, 'month1');
|
|
@@ -1582,8 +1756,8 @@ import './daterangepicker.css';
|
|
|
1582
1756
|
return;
|
|
1583
1757
|
}
|
|
1584
1758
|
|
|
1585
|
-
opt.start = date1
|
|
1586
|
-
opt.end = date2
|
|
1759
|
+
opt.start = date1;
|
|
1760
|
+
opt.end = date2;
|
|
1587
1761
|
|
|
1588
1762
|
if (opt.time.enabled) {
|
|
1589
1763
|
renderTime('time1', date1);
|
|
@@ -1598,7 +1772,7 @@ import './daterangepicker.css';
|
|
|
1598
1772
|
}
|
|
1599
1773
|
}
|
|
1600
1774
|
|
|
1601
|
-
if (opt.stickyMonths && opt.endDate
|
|
1775
|
+
if (opt.stickyMonths && opt.endDate && compare_month(date2, opt.endDate) > 0) {
|
|
1602
1776
|
date1 = prevMonth(date1);
|
|
1603
1777
|
date2 = prevMonth(date2);
|
|
1604
1778
|
}
|
|
@@ -1657,13 +1831,13 @@ import './daterangepicker.css';
|
|
|
1657
1831
|
let start = opt.start;
|
|
1658
1832
|
let end = opt.end;
|
|
1659
1833
|
if (opt.time.enabled) {
|
|
1660
|
-
time = startOfDay(time)
|
|
1661
|
-
start = startOfDay(start)
|
|
1662
|
-
end = startOfDay(end)
|
|
1834
|
+
time = startOfDay(time)[utcEpochMilliseconds]();
|
|
1835
|
+
start = startOfDay(start);
|
|
1836
|
+
end = startOfDay(end);
|
|
1663
1837
|
}
|
|
1664
1838
|
|
|
1665
1839
|
if (
|
|
1666
|
-
(opt.start && opt.end && end >= time && start <= time)
|
|
1840
|
+
(opt.start && opt.end && end[utcEpochMilliseconds]() >= time && start[utcEpochMilliseconds]() <= time)
|
|
1667
1841
|
|| (opt.start && !opt.end && DateUtils.formatDate(start, 'yyyyMMdd') == DateUtils.formatDate(time, 'yyyyMMdd'))
|
|
1668
1842
|
) {
|
|
1669
1843
|
$(this).addClass('checked');
|
|
@@ -1693,10 +1867,9 @@ import './daterangepicker.css';
|
|
|
1693
1867
|
});
|
|
1694
1868
|
}
|
|
1695
1869
|
|
|
1696
|
-
function showMonth(date:
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
box.find(`.${month} .month-name`).html(`${monthName}${opt.hideYearInMonthName ? '' : ` ${date.getFullYear()}`}`);
|
|
1870
|
+
function showMonth(date: Temporal.PlainDateTime, month: 'month1' | 'month2') {
|
|
1871
|
+
const monthName = nameMonth(date.month);
|
|
1872
|
+
box.find(`.${month} .month-name`).html(`${monthName}${opt.hideYearInMonthName ? '' : ` ${date.year}`}`);
|
|
1700
1873
|
box.find(`.${month} tbody`).html(createMonthHTML(date));
|
|
1701
1874
|
opt[month] = date;
|
|
1702
1875
|
updateSelectableRange();
|
|
@@ -1724,16 +1897,16 @@ import './daterangepicker.css';
|
|
|
1724
1897
|
});
|
|
1725
1898
|
}
|
|
1726
1899
|
|
|
1727
|
-
function showTime(date:
|
|
1900
|
+
function showTime(date: Temporal.PlainDateTime, name: 'time1' | 'time2') {
|
|
1728
1901
|
box.find(`.${name}`).append(getTimeHTML());
|
|
1729
1902
|
renderTime(name, date);
|
|
1730
1903
|
}
|
|
1731
1904
|
|
|
1732
|
-
function nameMonth(m) {
|
|
1733
|
-
return translate('month-name')[m];
|
|
1905
|
+
function nameMonth(m: number) {
|
|
1906
|
+
return translate('month-name')[m - 1];
|
|
1734
1907
|
}
|
|
1735
1908
|
|
|
1736
|
-
function getDateString(d) {
|
|
1909
|
+
function getDateString(d: Temporal.PlainDateTime) {
|
|
1737
1910
|
return DateUtils.formatDate(d, opt.format);
|
|
1738
1911
|
}
|
|
1739
1912
|
|
|
@@ -1779,7 +1952,7 @@ import './daterangepicker.css';
|
|
|
1779
1952
|
showMonth(opt.month2, 'month2');
|
|
1780
1953
|
}
|
|
1781
1954
|
|
|
1782
|
-
function compare_month(m1:
|
|
1955
|
+
function compare_month(m1: Temporal.PlainDateTime, m2: Temporal.PlainDateTime): number {
|
|
1783
1956
|
const p = parseInt(DateUtils.formatDate(m1, 'yyyyMM')) - parseInt(DateUtils.formatDate(m2, 'yyyyMM'));
|
|
1784
1957
|
if (p > 0) { return 1; }
|
|
1785
1958
|
|
|
@@ -1788,7 +1961,7 @@ import './daterangepicker.css';
|
|
|
1788
1961
|
return -1;
|
|
1789
1962
|
}
|
|
1790
1963
|
|
|
1791
|
-
function compare_day(m1:
|
|
1964
|
+
function compare_day(m1: Temporal.PlainDateTime, m2: Temporal.PlainDateTime): number {
|
|
1792
1965
|
const p = parseInt(DateUtils.formatDate(m1, 'yyyyMMdd')) - parseInt(DateUtils.formatDate(m2, 'yyyyMMdd'));
|
|
1793
1966
|
if (p > 0) { return 1; }
|
|
1794
1967
|
|
|
@@ -1797,16 +1970,12 @@ import './daterangepicker.css';
|
|
|
1797
1970
|
return -1;
|
|
1798
1971
|
}
|
|
1799
1972
|
|
|
1800
|
-
function nextMonth(month:
|
|
1801
|
-
|
|
1802
|
-
retVal.setMonth(retVal.getMonth() + 1);
|
|
1803
|
-
return retVal;
|
|
1973
|
+
function nextMonth(month: Temporal.PlainDateTime): Temporal.PlainDateTime {
|
|
1974
|
+
return month.add({ months: 1 });
|
|
1804
1975
|
}
|
|
1805
1976
|
|
|
1806
|
-
function prevMonth(month:
|
|
1807
|
-
|
|
1808
|
-
retVal.setMonth(retVal.getMonth() - 1);
|
|
1809
|
-
return retVal;
|
|
1977
|
+
function prevMonth(month: Temporal.PlainDateTime): Temporal.PlainDateTime {
|
|
1978
|
+
return month.subtract({ months: 1 });
|
|
1810
1979
|
}
|
|
1811
1980
|
|
|
1812
1981
|
function getTimeHTML() {
|
|
@@ -2020,24 +2189,24 @@ import './daterangepicker.css';
|
|
|
2020
2189
|
}
|
|
2021
2190
|
}
|
|
2022
2191
|
|
|
2023
|
-
function isMonthOutOfBounds(
|
|
2024
|
-
const
|
|
2025
|
-
|
|
2026
|
-
date.
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
const monthEnd =
|
|
2031
|
-
date.
|
|
2032
|
-
date.
|
|
2033
|
-
|
|
2034
|
-
);
|
|
2192
|
+
function isMonthOutOfBounds(date: Temporal.PlainDateTime): boolean {
|
|
2193
|
+
const monthStart = date.with({
|
|
2194
|
+
year: date.year,
|
|
2195
|
+
month: date.month,
|
|
2196
|
+
day: 1
|
|
2197
|
+
});
|
|
2198
|
+
|
|
2199
|
+
const monthEnd = date.with({
|
|
2200
|
+
year: date.year,
|
|
2201
|
+
month: date.month,
|
|
2202
|
+
day: 1
|
|
2203
|
+
}).add({ months: 1 }).subtract({ days: 1 });
|
|
2035
2204
|
|
|
2036
|
-
if (opt.startDate && monthEnd
|
|
2205
|
+
if (opt.startDate && monthEnd[utcEpochMilliseconds]() < opt.startDate[utcEpochMilliseconds]()) {
|
|
2037
2206
|
return true;
|
|
2038
2207
|
}
|
|
2039
2208
|
|
|
2040
|
-
if (opt.endDate && monthStart
|
|
2209
|
+
if (opt.endDate && monthStart[utcEpochMilliseconds]() > opt.endDate[utcEpochMilliseconds]()) {
|
|
2041
2210
|
return true;
|
|
2042
2211
|
}
|
|
2043
2212
|
|
|
@@ -2090,80 +2259,89 @@ import './daterangepicker.css';
|
|
|
2090
2259
|
return attrString;
|
|
2091
2260
|
}
|
|
2092
2261
|
|
|
2093
|
-
function daysFrom1970(t) {
|
|
2262
|
+
function daysFrom1970(t: Temporal.PlainDateTime) {
|
|
2094
2263
|
return Math.floor(toLocalTimestamp(t) / 86400000);
|
|
2095
2264
|
}
|
|
2096
2265
|
|
|
2097
|
-
function toLocalTimestamp(t) {
|
|
2098
|
-
if (typeof t == 'object' && t
|
|
2266
|
+
function toLocalTimestamp(t: Temporal.PlainDateTime | string): number {
|
|
2267
|
+
if (typeof t == 'object' && (t as any).getTime) {
|
|
2268
|
+
t = (t as any).getTime();
|
|
2269
|
+
}
|
|
2099
2270
|
|
|
2100
|
-
if (typeof t == 'string' && !t.match(/\d{13}/)) {
|
|
2271
|
+
if (typeof t == 'string' && !t.match(/\d{13}/)) {
|
|
2272
|
+
t = DateUtils.getTemporalFromFormat(t, opt.format)[utcEpochMilliseconds]() as any;
|
|
2273
|
+
}
|
|
2101
2274
|
|
|
2102
|
-
return t;
|
|
2275
|
+
return (t as Temporal.PlainDateTime)[utcEpochMilliseconds]();
|
|
2103
2276
|
}
|
|
2104
2277
|
|
|
2105
|
-
function createMonthHTML(d) {
|
|
2106
|
-
const days = [];
|
|
2107
|
-
d.
|
|
2108
|
-
const lastMonth =
|
|
2109
|
-
const now =
|
|
2278
|
+
function createMonthHTML(d: Temporal.PlainDateTime) {
|
|
2279
|
+
const days: DaterangePickerArgsCustomCellRenderDay[] = [];
|
|
2280
|
+
d = d.with({ day: 1 });
|
|
2281
|
+
const lastMonth = d.subtract({ days: 1 });
|
|
2282
|
+
const now = dateNow();
|
|
2110
2283
|
|
|
2111
|
-
let dayOfWeek = d
|
|
2284
|
+
let dayOfWeek = getJsDateDay(d);
|
|
2112
2285
|
if ((dayOfWeek === 0) && (opt.startOfWeek === 'monday')) {
|
|
2113
2286
|
// add one week
|
|
2114
2287
|
dayOfWeek = 7;
|
|
2115
2288
|
}
|
|
2116
2289
|
|
|
2117
|
-
let today, valid;
|
|
2118
|
-
|
|
2119
2290
|
if (dayOfWeek > 0) {
|
|
2120
2291
|
for (let i: number = dayOfWeek; i > 0; i--) {
|
|
2121
|
-
|
|
2122
|
-
valid = isValidTime(day
|
|
2123
|
-
if (opt.startDate && compare_day(day, opt.startDate) < 0) {
|
|
2124
|
-
|
|
2125
|
-
if (opt.endDate && compare_day(day, opt.endDate) > 0) {
|
|
2292
|
+
let day = d.subtract({ milliseconds: 86400000 * i });
|
|
2293
|
+
let valid = isValidTime(day);
|
|
2294
|
+
if (opt.startDate && compare_day(day, opt.startDate) < 0) {
|
|
2295
|
+
valid = false;
|
|
2296
|
+
} else if (opt.endDate && compare_day(day, opt.endDate) > 0) {
|
|
2297
|
+
valid = false;
|
|
2298
|
+
}
|
|
2126
2299
|
|
|
2127
2300
|
days.push({
|
|
2128
2301
|
date: day,
|
|
2129
2302
|
type: 'lastMonth',
|
|
2130
|
-
day: day.
|
|
2131
|
-
time: day
|
|
2303
|
+
day: day.day,
|
|
2304
|
+
time: day[utcEpochMilliseconds](),
|
|
2132
2305
|
valid,
|
|
2133
2306
|
});
|
|
2134
2307
|
}
|
|
2135
2308
|
}
|
|
2136
2309
|
|
|
2137
|
-
const toMonth = d.
|
|
2310
|
+
const toMonth = d.month;
|
|
2138
2311
|
for (let i: number = 0; i < 40; i++) {
|
|
2139
|
-
today =
|
|
2140
|
-
valid = isValidTime(today
|
|
2141
|
-
if (opt.startDate && compare_day(today, opt.startDate) < 0) {
|
|
2142
|
-
|
|
2143
|
-
if (opt.endDate && compare_day(today, opt.endDate) > 0) {
|
|
2312
|
+
let today = d.add({ milliseconds: (86400000 * i) });
|
|
2313
|
+
let valid = isValidTime(today);
|
|
2314
|
+
if (opt.startDate && compare_day(today, opt.startDate) < 0) {
|
|
2315
|
+
valid = false;
|
|
2316
|
+
} else if (opt.endDate && compare_day(today, opt.endDate) > 0) {
|
|
2317
|
+
valid = false;
|
|
2318
|
+
}
|
|
2144
2319
|
|
|
2145
2320
|
days.push({
|
|
2146
2321
|
date: today,
|
|
2147
|
-
type: today.
|
|
2148
|
-
day: today.
|
|
2149
|
-
time: today
|
|
2322
|
+
type: today.month == toMonth ? 'toMonth' : 'nextMonth',
|
|
2323
|
+
day: today.day,
|
|
2324
|
+
time: today[utcEpochMilliseconds](),
|
|
2150
2325
|
valid,
|
|
2151
2326
|
});
|
|
2152
2327
|
}
|
|
2153
2328
|
const html = [];
|
|
2154
2329
|
for (let week = 0; week < 6; week++) {
|
|
2155
|
-
if (days[week * 7].type == 'nextMonth') {
|
|
2330
|
+
if (days[week * 7].type == 'nextMonth') {
|
|
2331
|
+
break;
|
|
2332
|
+
}
|
|
2156
2333
|
|
|
2157
2334
|
html.push('<tr>');
|
|
2158
2335
|
|
|
2159
2336
|
for (var day: any = 0; day < 7; day++) {
|
|
2160
2337
|
const _day: any = (opt.startOfWeek == 'monday') ? day + 1 : day;
|
|
2161
|
-
today = days[week * 7 + _day];
|
|
2338
|
+
const today = days[week * 7 + _day];
|
|
2162
2339
|
const highlightToday = DateUtils.formatDate(today.time, 'yyyyMMdd') == DateUtils.formatDate(now, 'yyyyMMdd');
|
|
2163
2340
|
today.extraClass = '';
|
|
2164
2341
|
today.tooltip = '';
|
|
2342
|
+
|
|
2165
2343
|
if (today.valid && opt.beforeShowDay && typeof opt.beforeShowDay == 'function') {
|
|
2166
|
-
const _r = opt.beforeShowDay(
|
|
2344
|
+
const _r = opt.beforeShowDay(today.date);
|
|
2167
2345
|
today.valid = _r[0];
|
|
2168
2346
|
today.extraClass = _r[1] || '';
|
|
2169
2347
|
today.tooltip = _r[2] || '';
|
|
@@ -2204,15 +2382,15 @@ import './daterangepicker.css';
|
|
|
2204
2382
|
attributes,
|
|
2205
2383
|
opt.dayDivAttrs,
|
|
2206
2384
|
today,
|
|
2207
|
-
)}>${showDayHTML(today.
|
|
2385
|
+
)}>${showDayHTML(today.date, today.day)}</div>`;
|
|
2208
2386
|
}
|
|
2209
2387
|
|
|
2210
|
-
function showDayHTML(
|
|
2388
|
+
function showDayHTML(date: Temporal.PlainDateTime, day: number): string | number {
|
|
2211
2389
|
if (opt.showDateFilter && typeof opt.showDateFilter == 'function') {
|
|
2212
|
-
return opt.showDateFilter(
|
|
2390
|
+
return opt.showDateFilter(date, day);
|
|
2213
2391
|
}
|
|
2214
2392
|
|
|
2215
|
-
return
|
|
2393
|
+
return day;
|
|
2216
2394
|
}
|
|
2217
2395
|
|
|
2218
2396
|
function getLanguages(): any {
|
|
@@ -2247,29 +2425,29 @@ import './daterangepicker.css';
|
|
|
2247
2425
|
return result;
|
|
2248
2426
|
}
|
|
2249
2427
|
|
|
2250
|
-
function getDefaultTime():
|
|
2251
|
-
let defaultTime = opt.defaultTime ? opt.defaultTime :
|
|
2428
|
+
function getDefaultTime(): Temporal.PlainDateTime {
|
|
2429
|
+
let defaultTime = opt.defaultTime ? opt.defaultTime : dateNow();
|
|
2252
2430
|
|
|
2253
2431
|
if (opt.lookBehind) {
|
|
2254
|
-
if (opt.startDate && compare_month(defaultTime, opt.startDate) < 0) { defaultTime = nextMonth(
|
|
2432
|
+
if (opt.startDate && compare_month(defaultTime, opt.startDate) < 0) { defaultTime = nextMonth(opt.startDate); }
|
|
2255
2433
|
|
|
2256
|
-
if (opt.endDate && compare_month(defaultTime, opt.endDate) > 0) { defaultTime =
|
|
2434
|
+
if (opt.endDate && compare_month(defaultTime, opt.endDate) > 0) { defaultTime = opt.endDate; }
|
|
2257
2435
|
} else {
|
|
2258
|
-
if (opt.startDate && compare_month(defaultTime, opt.startDate) < 0) { defaultTime =
|
|
2436
|
+
if (opt.startDate && compare_month(defaultTime, opt.startDate) < 0) { defaultTime = opt.startDate; }
|
|
2259
2437
|
|
|
2260
|
-
if (opt.endDate && compare_month(nextMonth(defaultTime), opt.endDate) > 0) { defaultTime = prevMonth(
|
|
2438
|
+
if (opt.endDate && compare_month(nextMonth(defaultTime), opt.endDate) > 0) { defaultTime = prevMonth(opt.endDate); }
|
|
2261
2439
|
}
|
|
2262
2440
|
|
|
2263
2441
|
if (opt.singleDate) {
|
|
2264
|
-
if (opt.startDate && compare_month(defaultTime, opt.startDate) < 0) { defaultTime =
|
|
2442
|
+
if (opt.startDate && compare_month(defaultTime, opt.startDate) < 0) { defaultTime = opt.startDate; }
|
|
2265
2443
|
|
|
2266
|
-
if (opt.endDate && compare_month(defaultTime, opt.endDate) > 0) { defaultTime =
|
|
2444
|
+
if (opt.endDate && compare_month(defaultTime, opt.endDate) > 0) { defaultTime = opt.endDate; }
|
|
2267
2445
|
}
|
|
2268
2446
|
|
|
2269
2447
|
return defaultTime;
|
|
2270
2448
|
}
|
|
2271
2449
|
|
|
2272
|
-
function resetMonthsView(time:
|
|
2450
|
+
function resetMonthsView(time: Temporal.PlainDateTime) {
|
|
2273
2451
|
if (!time) {
|
|
2274
2452
|
time = getDefaultTime();
|
|
2275
2453
|
}
|