@fr0st/datetime 7.0.0 → 8.0.1
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/Formats.md +1 -22
- package/README.md +10 -10
- package/dist/frost-datetime.js +238 -238
- package/dist/frost-datetime.js.map +1 -1
- package/dist/frost-datetime.min.js +1 -1
- package/dist/frost-datetime.min.js.map +1 -1
- package/package.json +1 -1
- package/src/date-time.js +182 -182
- package/src/factory.js +4 -4
- package/src/formatter/format.js +13 -13
- package/src/formatter/locale.js +3 -3
- package/src/formatter/parse.js +10 -10
- package/src/formatter/utility.js +5 -5
- package/src/formatter/values.js +10 -10
- package/src/helpers.js +11 -11
package/src/date-time.js
CHANGED
|
@@ -50,7 +50,7 @@ export default class DateTime {
|
|
|
50
50
|
* @param {number} year The year.
|
|
51
51
|
* @param {number} month The month. (1-12)
|
|
52
52
|
* @param {number} date The date.
|
|
53
|
-
* @
|
|
53
|
+
* @returns {number} The day of the year. (1-366)
|
|
54
54
|
*/
|
|
55
55
|
static dayOfYear(year, month, date) {
|
|
56
56
|
return new Array(month - 1)
|
|
@@ -66,7 +66,7 @@ export default class DateTime {
|
|
|
66
66
|
* Gets the number of days in a month for a given year.
|
|
67
67
|
* @param {number} year The year.
|
|
68
68
|
* @param {number} month The month. (1-12)
|
|
69
|
-
* @
|
|
69
|
+
* @returns {number} The number of days in the month.
|
|
70
70
|
*/
|
|
71
71
|
static daysInMonth(year, month) {
|
|
72
72
|
const date = new Date(0);
|
|
@@ -86,7 +86,7 @@ export default class DateTime {
|
|
|
86
86
|
/**
|
|
87
87
|
* Gets the number of days in a given year.
|
|
88
88
|
* @param {number} year The year.
|
|
89
|
-
* @
|
|
89
|
+
* @returns {number} The number of days in the year.
|
|
90
90
|
*/
|
|
91
91
|
static daysInYear(year) {
|
|
92
92
|
return !this.isLeapYear(year) ?
|
|
@@ -101,7 +101,7 @@ export default class DateTime {
|
|
|
101
101
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
102
102
|
* @param {string} [options.timeZone] The time zone to use.
|
|
103
103
|
* @param {string} [options.locale] The locale to use.
|
|
104
|
-
* @
|
|
104
|
+
* @returns {DateTime} A new DateTime instance.
|
|
105
105
|
*/
|
|
106
106
|
static fromArray(dateArray, options = {}) {
|
|
107
107
|
const dateValues = dateArray.slice(0, 3);
|
|
@@ -127,7 +127,7 @@ export default class DateTime {
|
|
|
127
127
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
128
128
|
* @param {string} [options.timeZone] The time zone to use.
|
|
129
129
|
* @param {string} [options.locale] The locale to use.
|
|
130
|
-
* @
|
|
130
|
+
* @returns {DateTime} A new DateTime instance.
|
|
131
131
|
*/
|
|
132
132
|
static fromDate(date, options = {}) {
|
|
133
133
|
return new this(date.getTime(), options);
|
|
@@ -140,9 +140,9 @@ export default class DateTime {
|
|
|
140
140
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
141
141
|
* @param {string} [options.timeZone] The time zone to use.
|
|
142
142
|
* @param {string} [options.locale] The locale to use.
|
|
143
|
-
* @
|
|
143
|
+
* @returns {DateTime} A new DateTime instance.
|
|
144
|
+
* @throws {Error} When the format contains unsupported parsing tokens such as
|
|
144
145
|
* `MMMMM` or `LLLLL`.
|
|
145
|
-
* @return {DateTime} A new DateTime instance.
|
|
146
146
|
*/
|
|
147
147
|
static fromFormat(formatString, dateString, options = {}) {
|
|
148
148
|
const locale = 'locale' in options ?
|
|
@@ -290,7 +290,7 @@ export default class DateTime {
|
|
|
290
290
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
291
291
|
* @param {string} [options.timeZone] The time zone to use.
|
|
292
292
|
* @param {string} [options.locale] The locale to use.
|
|
293
|
-
* @
|
|
293
|
+
* @returns {DateTime} A new DateTime instance.
|
|
294
294
|
*/
|
|
295
295
|
static fromISOString(dateString, options = {}) {
|
|
296
296
|
let date = this.fromFormat(formats.rfc3339_extended, dateString, {
|
|
@@ -314,7 +314,7 @@ export default class DateTime {
|
|
|
314
314
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
315
315
|
* @param {string} [options.timeZone] The time zone to use.
|
|
316
316
|
* @param {string} [options.locale] The locale to use.
|
|
317
|
-
* @
|
|
317
|
+
* @returns {DateTime} A new DateTime instance.
|
|
318
318
|
*/
|
|
319
319
|
static fromTimestamp(timestamp, options = {}) {
|
|
320
320
|
return new this(null, options)
|
|
@@ -323,7 +323,7 @@ export default class DateTime {
|
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
325
|
* Gets the default locale.
|
|
326
|
-
* @
|
|
326
|
+
* @returns {string} The locale.
|
|
327
327
|
*/
|
|
328
328
|
static getDefaultLocale() {
|
|
329
329
|
return config.defaultLocale;
|
|
@@ -331,7 +331,7 @@ export default class DateTime {
|
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
333
|
* Gets the default time zone.
|
|
334
|
-
* @
|
|
334
|
+
* @returns {string} The default time zone.
|
|
335
335
|
*/
|
|
336
336
|
static getDefaultTimeZone() {
|
|
337
337
|
return config.defaultTimeZone;
|
|
@@ -340,7 +340,7 @@ export default class DateTime {
|
|
|
340
340
|
/**
|
|
341
341
|
* Checks whether the year is a leap year.
|
|
342
342
|
* @param {number} year The year.
|
|
343
|
-
* @
|
|
343
|
+
* @returns {boolean} Whether the given year is a leap year.
|
|
344
344
|
*/
|
|
345
345
|
static isLeapYear(year) {
|
|
346
346
|
const date = new Date(0);
|
|
@@ -354,7 +354,7 @@ export default class DateTime {
|
|
|
354
354
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
355
355
|
* @param {string} [options.timeZone] The time zone to use.
|
|
356
356
|
* @param {string} [options.locale] The locale to use.
|
|
357
|
-
* @
|
|
357
|
+
* @returns {DateTime} A new DateTime instance.
|
|
358
358
|
*/
|
|
359
359
|
static now(options = {}) {
|
|
360
360
|
return new this(null, options);
|
|
@@ -473,7 +473,7 @@ export default class DateTime {
|
|
|
473
473
|
|
|
474
474
|
/**
|
|
475
475
|
* Adds a day to the current DateTime.
|
|
476
|
-
* @
|
|
476
|
+
* @returns {DateTime} A new DateTime instance.
|
|
477
477
|
*/
|
|
478
478
|
addDay() {
|
|
479
479
|
return this.addDays(1);
|
|
@@ -482,7 +482,7 @@ export default class DateTime {
|
|
|
482
482
|
/**
|
|
483
483
|
* Adds days to the current DateTime.
|
|
484
484
|
* @param {number} amount The number of days to add.
|
|
485
|
-
* @
|
|
485
|
+
* @returns {DateTime} A new DateTime instance.
|
|
486
486
|
*/
|
|
487
487
|
addDays(amount) {
|
|
488
488
|
return setOffsetTime(
|
|
@@ -496,7 +496,7 @@ export default class DateTime {
|
|
|
496
496
|
|
|
497
497
|
/**
|
|
498
498
|
* Adds an hour to the current DateTime.
|
|
499
|
-
* @
|
|
499
|
+
* @returns {DateTime} A new DateTime instance.
|
|
500
500
|
*/
|
|
501
501
|
addHour() {
|
|
502
502
|
return this.addHours(1);
|
|
@@ -505,7 +505,7 @@ export default class DateTime {
|
|
|
505
505
|
/**
|
|
506
506
|
* Adds hours to the current DateTime.
|
|
507
507
|
* @param {number} amount The number of hours to add.
|
|
508
|
-
* @
|
|
508
|
+
* @returns {DateTime} A new DateTime instance.
|
|
509
509
|
*/
|
|
510
510
|
addHours(amount) {
|
|
511
511
|
return this.withTime(
|
|
@@ -515,7 +515,7 @@ export default class DateTime {
|
|
|
515
515
|
|
|
516
516
|
/**
|
|
517
517
|
* Adds a minute to the current DateTime.
|
|
518
|
-
* @
|
|
518
|
+
* @returns {DateTime} A new DateTime instance.
|
|
519
519
|
*/
|
|
520
520
|
addMinute() {
|
|
521
521
|
return this.addMinutes(1);
|
|
@@ -524,7 +524,7 @@ export default class DateTime {
|
|
|
524
524
|
/**
|
|
525
525
|
* Adds minutes to the current DateTime.
|
|
526
526
|
* @param {number} amount The number of minutes to add.
|
|
527
|
-
* @
|
|
527
|
+
* @returns {DateTime} A new DateTime instance.
|
|
528
528
|
*/
|
|
529
529
|
addMinutes(amount) {
|
|
530
530
|
return this.withTime(
|
|
@@ -534,7 +534,7 @@ export default class DateTime {
|
|
|
534
534
|
|
|
535
535
|
/**
|
|
536
536
|
* Adds a month to the current DateTime.
|
|
537
|
-
* @
|
|
537
|
+
* @returns {DateTime} A new DateTime instance.
|
|
538
538
|
*/
|
|
539
539
|
addMonth() {
|
|
540
540
|
return this.addMonths(1);
|
|
@@ -543,7 +543,7 @@ export default class DateTime {
|
|
|
543
543
|
/**
|
|
544
544
|
* Adds months to the current DateTime.
|
|
545
545
|
* @param {number} amount The number of months to add.
|
|
546
|
-
* @
|
|
546
|
+
* @returns {DateTime} A new DateTime instance.
|
|
547
547
|
*/
|
|
548
548
|
addMonths(amount) {
|
|
549
549
|
return this.withMonth(
|
|
@@ -553,7 +553,7 @@ export default class DateTime {
|
|
|
553
553
|
|
|
554
554
|
/**
|
|
555
555
|
* Adds a second to the current DateTime.
|
|
556
|
-
* @
|
|
556
|
+
* @returns {DateTime} A new DateTime instance.
|
|
557
557
|
*/
|
|
558
558
|
addSecond() {
|
|
559
559
|
return this.addSeconds(1);
|
|
@@ -562,7 +562,7 @@ export default class DateTime {
|
|
|
562
562
|
/**
|
|
563
563
|
* Adds seconds to the current DateTime.
|
|
564
564
|
* @param {number} amount The number of seconds to add.
|
|
565
|
-
* @
|
|
565
|
+
* @returns {DateTime} A new DateTime instance.
|
|
566
566
|
*/
|
|
567
567
|
addSeconds(amount) {
|
|
568
568
|
return this.withTime(
|
|
@@ -572,7 +572,7 @@ export default class DateTime {
|
|
|
572
572
|
|
|
573
573
|
/**
|
|
574
574
|
* Adds a week to the current DateTime.
|
|
575
|
-
* @
|
|
575
|
+
* @returns {DateTime} A new DateTime instance.
|
|
576
576
|
*/
|
|
577
577
|
addWeek() {
|
|
578
578
|
return this.addWeeks(1);
|
|
@@ -581,7 +581,7 @@ export default class DateTime {
|
|
|
581
581
|
/**
|
|
582
582
|
* Adds weeks to the current DateTime.
|
|
583
583
|
* @param {number} amount The number of weeks to add.
|
|
584
|
-
* @
|
|
584
|
+
* @returns {DateTime} A new DateTime instance.
|
|
585
585
|
*/
|
|
586
586
|
addWeeks(amount) {
|
|
587
587
|
return this.withDate(
|
|
@@ -591,7 +591,7 @@ export default class DateTime {
|
|
|
591
591
|
|
|
592
592
|
/**
|
|
593
593
|
* Adds a year to the current DateTime.
|
|
594
|
-
* @
|
|
594
|
+
* @returns {DateTime} A new DateTime instance.
|
|
595
595
|
*/
|
|
596
596
|
addYear() {
|
|
597
597
|
return this.addYears(1);
|
|
@@ -600,7 +600,7 @@ export default class DateTime {
|
|
|
600
600
|
/**
|
|
601
601
|
* Adds years to the current DateTime.
|
|
602
602
|
* @param {number} amount The number of years to add.
|
|
603
|
-
* @
|
|
603
|
+
* @returns {DateTime} A new DateTime instance.
|
|
604
604
|
*/
|
|
605
605
|
addYears(amount) {
|
|
606
606
|
return this.withYear(
|
|
@@ -611,7 +611,7 @@ export default class DateTime {
|
|
|
611
611
|
/**
|
|
612
612
|
* Gets the localized day name for the current date.
|
|
613
613
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of day name to return.
|
|
614
|
-
* @
|
|
614
|
+
* @returns {string} The localized day name.
|
|
615
615
|
*/
|
|
616
616
|
dayName(type = 'long') {
|
|
617
617
|
return formatDay(this.getLocale(), this.getDay(), type);
|
|
@@ -620,7 +620,7 @@ export default class DateTime {
|
|
|
620
620
|
/**
|
|
621
621
|
* Gets the localized day period for the current time.
|
|
622
622
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of day period to return.
|
|
623
|
-
* @
|
|
623
|
+
* @returns {string} The localized day period.
|
|
624
624
|
*/
|
|
625
625
|
dayPeriod(type = 'long') {
|
|
626
626
|
return formatDayPeriod(
|
|
@@ -634,7 +634,7 @@ export default class DateTime {
|
|
|
634
634
|
|
|
635
635
|
/**
|
|
636
636
|
* Gets the number of days in the current month.
|
|
637
|
-
* @
|
|
637
|
+
* @returns {number} The number of days in the current month.
|
|
638
638
|
*/
|
|
639
639
|
daysInMonth() {
|
|
640
640
|
return this.constructor.daysInMonth(
|
|
@@ -645,7 +645,7 @@ export default class DateTime {
|
|
|
645
645
|
|
|
646
646
|
/**
|
|
647
647
|
* Gets the number of days in the current year.
|
|
648
|
-
* @
|
|
648
|
+
* @returns {number} The number of days in the current year.
|
|
649
649
|
*/
|
|
650
650
|
daysInYear() {
|
|
651
651
|
return this.constructor.daysInYear(
|
|
@@ -656,7 +656,7 @@ export default class DateTime {
|
|
|
656
656
|
/**
|
|
657
657
|
* Gets the difference between this and another Date in milliseconds.
|
|
658
658
|
* @param {DateTime} other The date to compare to.
|
|
659
|
-
* @
|
|
659
|
+
* @returns {number} The difference.
|
|
660
660
|
*/
|
|
661
661
|
diff(other) {
|
|
662
662
|
return this - other;
|
|
@@ -666,7 +666,7 @@ export default class DateTime {
|
|
|
666
666
|
* Gets the difference between this and another Date in days.
|
|
667
667
|
* @param {DateTime} other The date to compare to.
|
|
668
668
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
669
|
-
* @
|
|
669
|
+
* @returns {number} The difference.
|
|
670
670
|
*/
|
|
671
671
|
diffInDays(other, { relative = true } = {}) {
|
|
672
672
|
return calculateDiff(this, other, 'day', relative);
|
|
@@ -676,7 +676,7 @@ export default class DateTime {
|
|
|
676
676
|
* Gets the difference between this and another Date in hours.
|
|
677
677
|
* @param {DateTime} other The date to compare to.
|
|
678
678
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
679
|
-
* @
|
|
679
|
+
* @returns {number} The difference.
|
|
680
680
|
*/
|
|
681
681
|
diffInHours(other, { relative = true } = {}) {
|
|
682
682
|
return calculateDiff(this, other, 'hour', relative);
|
|
@@ -686,7 +686,7 @@ export default class DateTime {
|
|
|
686
686
|
* Gets the difference between this and another Date in minutes.
|
|
687
687
|
* @param {DateTime} other The date to compare to.
|
|
688
688
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
689
|
-
* @
|
|
689
|
+
* @returns {number} The difference.
|
|
690
690
|
*/
|
|
691
691
|
diffInMinutes(other, { relative = true } = {}) {
|
|
692
692
|
return calculateDiff(this, other, 'minute', relative);
|
|
@@ -696,7 +696,7 @@ export default class DateTime {
|
|
|
696
696
|
* Gets the difference between this and another Date in months.
|
|
697
697
|
* @param {DateTime} other The date to compare to.
|
|
698
698
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
699
|
-
* @
|
|
699
|
+
* @returns {number} The difference.
|
|
700
700
|
*/
|
|
701
701
|
diffInMonths(other, { relative = true } = {}) {
|
|
702
702
|
return calculateDiff(this, other, 'month', relative);
|
|
@@ -706,7 +706,7 @@ export default class DateTime {
|
|
|
706
706
|
* Gets the difference between this and another Date in seconds.
|
|
707
707
|
* @param {DateTime} other The date to compare to.
|
|
708
708
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
709
|
-
* @
|
|
709
|
+
* @returns {number} The difference.
|
|
710
710
|
*/
|
|
711
711
|
diffInSeconds(other, { relative = true } = {}) {
|
|
712
712
|
return calculateDiff(this, other, 'second', relative);
|
|
@@ -716,7 +716,7 @@ export default class DateTime {
|
|
|
716
716
|
* Gets the difference between this and another Date in weeks.
|
|
717
717
|
* @param {DateTime} other The date to compare to.
|
|
718
718
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
719
|
-
* @
|
|
719
|
+
* @returns {number} The difference.
|
|
720
720
|
*/
|
|
721
721
|
diffInWeeks(other, { relative = true } = {}) {
|
|
722
722
|
return calculateDiff(this, other, 'week', relative);
|
|
@@ -726,7 +726,7 @@ export default class DateTime {
|
|
|
726
726
|
* Gets the difference between this and another Date in years.
|
|
727
727
|
* @param {DateTime} other The date to compare to.
|
|
728
728
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
729
|
-
* @
|
|
729
|
+
* @returns {number} The difference.
|
|
730
730
|
*/
|
|
731
731
|
diffInYears(other, { relative = true } = {}) {
|
|
732
732
|
return calculateDiff(this, other, 'year', relative);
|
|
@@ -734,7 +734,7 @@ export default class DateTime {
|
|
|
734
734
|
|
|
735
735
|
/**
|
|
736
736
|
* Sets the DateTime to the end of the day.
|
|
737
|
-
* @
|
|
737
|
+
* @returns {DateTime} A new DateTime instance.
|
|
738
738
|
*/
|
|
739
739
|
endOfDay() {
|
|
740
740
|
return this.withHours(23, 59, 59, 999);
|
|
@@ -742,7 +742,7 @@ export default class DateTime {
|
|
|
742
742
|
|
|
743
743
|
/**
|
|
744
744
|
* Sets the DateTime to the end of the hour.
|
|
745
|
-
* @
|
|
745
|
+
* @returns {DateTime} A new DateTime instance.
|
|
746
746
|
*/
|
|
747
747
|
endOfHour() {
|
|
748
748
|
return this.withMinutes(59, 59, 999);
|
|
@@ -750,7 +750,7 @@ export default class DateTime {
|
|
|
750
750
|
|
|
751
751
|
/**
|
|
752
752
|
* Sets the DateTime to the end of the minute.
|
|
753
|
-
* @
|
|
753
|
+
* @returns {DateTime} A new DateTime instance.
|
|
754
754
|
*/
|
|
755
755
|
endOfMinute() {
|
|
756
756
|
return this.withSeconds(59, 999);
|
|
@@ -758,7 +758,7 @@ export default class DateTime {
|
|
|
758
758
|
|
|
759
759
|
/**
|
|
760
760
|
* Sets the DateTime to the end of the month.
|
|
761
|
-
* @
|
|
761
|
+
* @returns {DateTime} A new DateTime instance.
|
|
762
762
|
*/
|
|
763
763
|
endOfMonth() {
|
|
764
764
|
return this.withDate(this.daysInMonth())
|
|
@@ -767,7 +767,7 @@ export default class DateTime {
|
|
|
767
767
|
|
|
768
768
|
/**
|
|
769
769
|
* Sets the DateTime to the end of the quarter.
|
|
770
|
-
* @
|
|
770
|
+
* @returns {DateTime} A new DateTime instance.
|
|
771
771
|
*/
|
|
772
772
|
endOfQuarter() {
|
|
773
773
|
const month = this.getQuarter() * 3;
|
|
@@ -777,7 +777,7 @@ export default class DateTime {
|
|
|
777
777
|
|
|
778
778
|
/**
|
|
779
779
|
* Sets the DateTime to the end of the second.
|
|
780
|
-
* @
|
|
780
|
+
* @returns {DateTime} A new DateTime instance.
|
|
781
781
|
*/
|
|
782
782
|
endOfSecond() {
|
|
783
783
|
return this.withMilliseconds(999);
|
|
@@ -785,7 +785,7 @@ export default class DateTime {
|
|
|
785
785
|
|
|
786
786
|
/**
|
|
787
787
|
* Sets the DateTime to the end of the week.
|
|
788
|
-
* @
|
|
788
|
+
* @returns {DateTime} A new DateTime instance.
|
|
789
789
|
*/
|
|
790
790
|
endOfWeek() {
|
|
791
791
|
return this.withWeekDay(7)
|
|
@@ -794,7 +794,7 @@ export default class DateTime {
|
|
|
794
794
|
|
|
795
795
|
/**
|
|
796
796
|
* Sets the DateTime to the end of the year.
|
|
797
|
-
* @
|
|
797
|
+
* @returns {DateTime} A new DateTime instance.
|
|
798
798
|
*/
|
|
799
799
|
endOfYear() {
|
|
800
800
|
return this.withMonth(12, 31)
|
|
@@ -804,7 +804,7 @@ export default class DateTime {
|
|
|
804
804
|
/**
|
|
805
805
|
* Gets the localized era for the current date.
|
|
806
806
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of era to return.
|
|
807
|
-
* @
|
|
807
|
+
* @returns {string} The localized era.
|
|
808
808
|
*/
|
|
809
809
|
era(type = 'long') {
|
|
810
810
|
return formatEra(
|
|
@@ -819,7 +819,7 @@ export default class DateTime {
|
|
|
819
819
|
/**
|
|
820
820
|
* Formats the current date using a format string.
|
|
821
821
|
* @param {string} formatString The format string.
|
|
822
|
-
* @
|
|
822
|
+
* @returns {string} The formatted date string.
|
|
823
823
|
*/
|
|
824
824
|
format(formatString) {
|
|
825
825
|
let match;
|
|
@@ -859,7 +859,7 @@ export default class DateTime {
|
|
|
859
859
|
|
|
860
860
|
/**
|
|
861
861
|
* Gets the date of the month in the current time zone.
|
|
862
|
-
* @
|
|
862
|
+
* @returns {number} The date of the month.
|
|
863
863
|
*/
|
|
864
864
|
getDate() {
|
|
865
865
|
return new Date(getOffsetTime(this)).getUTCDate();
|
|
@@ -867,7 +867,7 @@ export default class DateTime {
|
|
|
867
867
|
|
|
868
868
|
/**
|
|
869
869
|
* Gets the day of the week in the current time zone.
|
|
870
|
-
* @
|
|
870
|
+
* @returns {number} The day of the week. (0 = Sunday, 6 = Saturday)
|
|
871
871
|
*/
|
|
872
872
|
getDay() {
|
|
873
873
|
return new Date(getOffsetTime(this)).getUTCDay();
|
|
@@ -875,7 +875,7 @@ export default class DateTime {
|
|
|
875
875
|
|
|
876
876
|
/**
|
|
877
877
|
* Gets the day of the year in the current time zone.
|
|
878
|
-
* @
|
|
878
|
+
* @returns {number} The day of the year. (1-366)
|
|
879
879
|
*/
|
|
880
880
|
getDayOfYear() {
|
|
881
881
|
return this.constructor.dayOfYear(
|
|
@@ -887,7 +887,7 @@ export default class DateTime {
|
|
|
887
887
|
|
|
888
888
|
/**
|
|
889
889
|
* Gets the hours of the day in the current time zone.
|
|
890
|
-
* @
|
|
890
|
+
* @returns {number} The hours of the day. (0-23)
|
|
891
891
|
*/
|
|
892
892
|
getHours() {
|
|
893
893
|
return new Date(getOffsetTime(this)).getUTCHours();
|
|
@@ -895,7 +895,7 @@ export default class DateTime {
|
|
|
895
895
|
|
|
896
896
|
/**
|
|
897
897
|
* Gets the current locale.
|
|
898
|
-
* @
|
|
898
|
+
* @returns {string} The locale.
|
|
899
899
|
*/
|
|
900
900
|
getLocale() {
|
|
901
901
|
return this._locale;
|
|
@@ -903,7 +903,7 @@ export default class DateTime {
|
|
|
903
903
|
|
|
904
904
|
/**
|
|
905
905
|
* Gets the milliseconds in the current time zone.
|
|
906
|
-
* @
|
|
906
|
+
* @returns {number} The milliseconds.
|
|
907
907
|
*/
|
|
908
908
|
getMilliseconds() {
|
|
909
909
|
return new Date(getOffsetTime(this)).getUTCMilliseconds();
|
|
@@ -911,7 +911,7 @@ export default class DateTime {
|
|
|
911
911
|
|
|
912
912
|
/**
|
|
913
913
|
* Gets the minutes in the current time zone.
|
|
914
|
-
* @
|
|
914
|
+
* @returns {number} The minutes. (0-59)
|
|
915
915
|
*/
|
|
916
916
|
getMinutes() {
|
|
917
917
|
return new Date(getOffsetTime(this)).getUTCMinutes();
|
|
@@ -919,7 +919,7 @@ export default class DateTime {
|
|
|
919
919
|
|
|
920
920
|
/**
|
|
921
921
|
* Gets the month in the current time zone.
|
|
922
|
-
* @
|
|
922
|
+
* @returns {number} The month. (1-12)
|
|
923
923
|
*/
|
|
924
924
|
getMonth() {
|
|
925
925
|
return new Date(getOffsetTime(this)).getUTCMonth() + 1;
|
|
@@ -927,7 +927,7 @@ export default class DateTime {
|
|
|
927
927
|
|
|
928
928
|
/**
|
|
929
929
|
* Gets the quarter of the year in the current time zone.
|
|
930
|
-
* @
|
|
930
|
+
* @returns {number} The quarter of the year. (1-4)
|
|
931
931
|
*/
|
|
932
932
|
getQuarter() {
|
|
933
933
|
return Math.ceil(this.getMonth() / 3);
|
|
@@ -935,7 +935,7 @@ export default class DateTime {
|
|
|
935
935
|
|
|
936
936
|
/**
|
|
937
937
|
* Gets the seconds in the current time zone.
|
|
938
|
-
* @
|
|
938
|
+
* @returns {number} The seconds. (0-59)
|
|
939
939
|
*/
|
|
940
940
|
getSeconds() {
|
|
941
941
|
return new Date(getOffsetTime(this)).getUTCSeconds();
|
|
@@ -943,7 +943,7 @@ export default class DateTime {
|
|
|
943
943
|
|
|
944
944
|
/**
|
|
945
945
|
* Gets the number of milliseconds since the UNIX epoch.
|
|
946
|
-
* @
|
|
946
|
+
* @returns {number} The number of milliseconds since the UNIX epoch.
|
|
947
947
|
*/
|
|
948
948
|
getTime() {
|
|
949
949
|
return this._date.getTime();
|
|
@@ -951,7 +951,7 @@ export default class DateTime {
|
|
|
951
951
|
|
|
952
952
|
/**
|
|
953
953
|
* Gets the number of seconds since the UNIX epoch.
|
|
954
|
-
* @
|
|
954
|
+
* @returns {number} The number of seconds since the UNIX epoch.
|
|
955
955
|
*/
|
|
956
956
|
getTimestamp() {
|
|
957
957
|
return Math.floor(this.getTime() / 1000);
|
|
@@ -959,7 +959,7 @@ export default class DateTime {
|
|
|
959
959
|
|
|
960
960
|
/**
|
|
961
961
|
* Gets the current time zone.
|
|
962
|
-
* @
|
|
962
|
+
* @returns {string} The time zone.
|
|
963
963
|
*/
|
|
964
964
|
getTimeZone() {
|
|
965
965
|
return this._timeZone;
|
|
@@ -967,7 +967,7 @@ export default class DateTime {
|
|
|
967
967
|
|
|
968
968
|
/**
|
|
969
969
|
* Gets the current UTC offset in minutes.
|
|
970
|
-
* @
|
|
970
|
+
* @returns {number} The UTC offset in minutes.
|
|
971
971
|
*/
|
|
972
972
|
getTimeZoneOffset() {
|
|
973
973
|
return this._offset;
|
|
@@ -975,7 +975,7 @@ export default class DateTime {
|
|
|
975
975
|
|
|
976
976
|
/**
|
|
977
977
|
* Gets the local week in the current time zone.
|
|
978
|
-
* @
|
|
978
|
+
* @returns {number} The local week. (1-53)
|
|
979
979
|
*/
|
|
980
980
|
getWeek() {
|
|
981
981
|
const thisWeek = this.startOfDay().withWeekDay(1);
|
|
@@ -989,7 +989,7 @@ export default class DateTime {
|
|
|
989
989
|
|
|
990
990
|
/**
|
|
991
991
|
* Gets the local day of the week in the current time zone.
|
|
992
|
-
* @
|
|
992
|
+
* @returns {number} The local day of the week. (1-7)
|
|
993
993
|
*/
|
|
994
994
|
getWeekDay() {
|
|
995
995
|
return weekDay(
|
|
@@ -1000,7 +1000,7 @@ export default class DateTime {
|
|
|
1000
1000
|
|
|
1001
1001
|
/**
|
|
1002
1002
|
* Gets the week day in month in the current time zone.
|
|
1003
|
-
* @
|
|
1003
|
+
* @returns {number} The week day in month.
|
|
1004
1004
|
*/
|
|
1005
1005
|
getWeekDayInMonth() {
|
|
1006
1006
|
const thisWeek = this.getWeek();
|
|
@@ -1015,7 +1015,7 @@ export default class DateTime {
|
|
|
1015
1015
|
|
|
1016
1016
|
/**
|
|
1017
1017
|
* Gets the week of month in the current time zone.
|
|
1018
|
-
* @
|
|
1018
|
+
* @returns {number} The week of month.
|
|
1019
1019
|
*/
|
|
1020
1020
|
getWeekOfMonth() {
|
|
1021
1021
|
const thisWeek = this.getWeek();
|
|
@@ -1027,7 +1027,7 @@ export default class DateTime {
|
|
|
1027
1027
|
|
|
1028
1028
|
/**
|
|
1029
1029
|
* Gets the week year in the current time zone.
|
|
1030
|
-
* @
|
|
1030
|
+
* @returns {number} The week year.
|
|
1031
1031
|
*/
|
|
1032
1032
|
getWeekYear() {
|
|
1033
1033
|
const minDays = minimumDays(this.getLocale());
|
|
@@ -1036,7 +1036,7 @@ export default class DateTime {
|
|
|
1036
1036
|
|
|
1037
1037
|
/**
|
|
1038
1038
|
* Gets the year in the current time zone.
|
|
1039
|
-
* @
|
|
1039
|
+
* @returns {number} The year.
|
|
1040
1040
|
*/
|
|
1041
1041
|
getYear() {
|
|
1042
1042
|
return new Date(getOffsetTime(this)).getUTCFullYear();
|
|
@@ -1045,7 +1045,7 @@ export default class DateTime {
|
|
|
1045
1045
|
/**
|
|
1046
1046
|
* Gets the difference between this and another Date in human readable form.
|
|
1047
1047
|
* @param {DateTime} other The date to compare to.
|
|
1048
|
-
* @
|
|
1048
|
+
* @returns {string} The difference in human readable form.
|
|
1049
1049
|
*/
|
|
1050
1050
|
humanDiff(other) {
|
|
1051
1051
|
const [amount, unit] = getBiggestDiff(this, other);
|
|
@@ -1055,7 +1055,7 @@ export default class DateTime {
|
|
|
1055
1055
|
/**
|
|
1056
1056
|
* Gets the difference between this and another Date in days in human readable form.
|
|
1057
1057
|
* @param {DateTime} other The date to compare to.
|
|
1058
|
-
* @
|
|
1058
|
+
* @returns {string} The difference in days in human readable form.
|
|
1059
1059
|
*/
|
|
1060
1060
|
humanDiffInDays(other) {
|
|
1061
1061
|
return formatRelative(this.getLocale(), this.diffInDays(other), 'day');
|
|
@@ -1064,7 +1064,7 @@ export default class DateTime {
|
|
|
1064
1064
|
/**
|
|
1065
1065
|
* Gets the difference between this and another Date in hours in human readable form.
|
|
1066
1066
|
* @param {DateTime} other The date to compare to.
|
|
1067
|
-
* @
|
|
1067
|
+
* @returns {string} The difference in hours in human readable form.
|
|
1068
1068
|
*/
|
|
1069
1069
|
humanDiffInHours(other) {
|
|
1070
1070
|
return formatRelative(this.getLocale(), this.diffInHours(other), 'hour');
|
|
@@ -1073,7 +1073,7 @@ export default class DateTime {
|
|
|
1073
1073
|
/**
|
|
1074
1074
|
* Gets the difference between this and another Date in minutes in human readable form.
|
|
1075
1075
|
* @param {DateTime} other The date to compare to.
|
|
1076
|
-
* @
|
|
1076
|
+
* @returns {string} The difference in minutes in human readable form.
|
|
1077
1077
|
*/
|
|
1078
1078
|
humanDiffInMinutes(other) {
|
|
1079
1079
|
return formatRelative(this.getLocale(), this.diffInMinutes(other), 'minute');
|
|
@@ -1082,7 +1082,7 @@ export default class DateTime {
|
|
|
1082
1082
|
/**
|
|
1083
1083
|
* Gets the difference between this and another Date in months in human readable form.
|
|
1084
1084
|
* @param {DateTime} other The date to compare to.
|
|
1085
|
-
* @
|
|
1085
|
+
* @returns {string} The difference in months in human readable form.
|
|
1086
1086
|
*/
|
|
1087
1087
|
humanDiffInMonths(other) {
|
|
1088
1088
|
return formatRelative(this.getLocale(), this.diffInMonths(other), 'month');
|
|
@@ -1091,7 +1091,7 @@ export default class DateTime {
|
|
|
1091
1091
|
/**
|
|
1092
1092
|
* Gets the difference between this and another Date in seconds in human readable form.
|
|
1093
1093
|
* @param {DateTime} other The date to compare to.
|
|
1094
|
-
* @
|
|
1094
|
+
* @returns {string} The difference in seconds in human readable form.
|
|
1095
1095
|
*/
|
|
1096
1096
|
humanDiffInSeconds(other) {
|
|
1097
1097
|
return formatRelative(this.getLocale(), this.diffInSeconds(other), 'second');
|
|
@@ -1100,7 +1100,7 @@ export default class DateTime {
|
|
|
1100
1100
|
/**
|
|
1101
1101
|
* Gets the difference between this and another Date in weeks in human readable form.
|
|
1102
1102
|
* @param {DateTime} other The date to compare to.
|
|
1103
|
-
* @
|
|
1103
|
+
* @returns {string} The difference in weeks in human readable form.
|
|
1104
1104
|
*/
|
|
1105
1105
|
humanDiffInWeeks(other) {
|
|
1106
1106
|
return formatRelative(this.getLocale(), this.diffInWeeks(other), 'week');
|
|
@@ -1109,7 +1109,7 @@ export default class DateTime {
|
|
|
1109
1109
|
/**
|
|
1110
1110
|
* Gets the difference between this and another Date in years in human readable form.
|
|
1111
1111
|
* @param {DateTime} other The date to compare to.
|
|
1112
|
-
* @
|
|
1112
|
+
* @returns {string} The difference in years in human readable form.
|
|
1113
1113
|
*/
|
|
1114
1114
|
humanDiffInYears(other) {
|
|
1115
1115
|
return formatRelative(this.getLocale(), this.diffInYears(other), 'year');
|
|
@@ -1118,7 +1118,7 @@ export default class DateTime {
|
|
|
1118
1118
|
/**
|
|
1119
1119
|
* Checks whether this DateTime is after another date.
|
|
1120
1120
|
* @param {DateTime} other The date to compare to.
|
|
1121
|
-
* @
|
|
1121
|
+
* @returns {boolean} Whether this DateTime is after the other date.
|
|
1122
1122
|
*/
|
|
1123
1123
|
isAfter(other) {
|
|
1124
1124
|
return this.diff(other) > 0;
|
|
@@ -1127,7 +1127,7 @@ export default class DateTime {
|
|
|
1127
1127
|
/**
|
|
1128
1128
|
* Checks whether this DateTime is after another date (comparing by day).
|
|
1129
1129
|
* @param {DateTime} other The date to compare to.
|
|
1130
|
-
* @
|
|
1130
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by day).
|
|
1131
1131
|
*/
|
|
1132
1132
|
isAfterDay(other) {
|
|
1133
1133
|
return this.diffInDays(other) > 0;
|
|
@@ -1136,7 +1136,7 @@ export default class DateTime {
|
|
|
1136
1136
|
/**
|
|
1137
1137
|
* Checks whether this DateTime is after another date (comparing by hour).
|
|
1138
1138
|
* @param {DateTime} other The date to compare to.
|
|
1139
|
-
* @
|
|
1139
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by hour).
|
|
1140
1140
|
*/
|
|
1141
1141
|
isAfterHour(other) {
|
|
1142
1142
|
return this.diffInHours(other) > 0;
|
|
@@ -1145,7 +1145,7 @@ export default class DateTime {
|
|
|
1145
1145
|
/**
|
|
1146
1146
|
* Checks whether this DateTime is after another date (comparing by minute).
|
|
1147
1147
|
* @param {DateTime} other The date to compare to.
|
|
1148
|
-
* @
|
|
1148
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by minute).
|
|
1149
1149
|
*/
|
|
1150
1150
|
isAfterMinute(other) {
|
|
1151
1151
|
return this.diffInMinutes(other) > 0;
|
|
@@ -1154,7 +1154,7 @@ export default class DateTime {
|
|
|
1154
1154
|
/**
|
|
1155
1155
|
* Checks whether this DateTime is after another date (comparing by month).
|
|
1156
1156
|
* @param {DateTime} other The date to compare to.
|
|
1157
|
-
* @
|
|
1157
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by month).
|
|
1158
1158
|
*/
|
|
1159
1159
|
isAfterMonth(other) {
|
|
1160
1160
|
return this.diffInMonths(other) > 0;
|
|
@@ -1163,7 +1163,7 @@ export default class DateTime {
|
|
|
1163
1163
|
/**
|
|
1164
1164
|
* Checks whether this DateTime is after another date (comparing by second).
|
|
1165
1165
|
* @param {DateTime} other The date to compare to.
|
|
1166
|
-
* @
|
|
1166
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by second).
|
|
1167
1167
|
*/
|
|
1168
1168
|
isAfterSecond(other) {
|
|
1169
1169
|
return this.diffInSeconds(other) > 0;
|
|
@@ -1172,7 +1172,7 @@ export default class DateTime {
|
|
|
1172
1172
|
/**
|
|
1173
1173
|
* Checks whether this DateTime is after another date (comparing by week).
|
|
1174
1174
|
* @param {DateTime} other The date to compare to.
|
|
1175
|
-
* @
|
|
1175
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by week).
|
|
1176
1176
|
*/
|
|
1177
1177
|
isAfterWeek(other) {
|
|
1178
1178
|
return this.diffInWeeks(other) > 0;
|
|
@@ -1181,7 +1181,7 @@ export default class DateTime {
|
|
|
1181
1181
|
/**
|
|
1182
1182
|
* Checks whether this DateTime is after another date (comparing by year).
|
|
1183
1183
|
* @param {DateTime} other The date to compare to.
|
|
1184
|
-
* @
|
|
1184
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by year).
|
|
1185
1185
|
*/
|
|
1186
1186
|
isAfterYear(other) {
|
|
1187
1187
|
return this.diffInYears(other) > 0;
|
|
@@ -1190,7 +1190,7 @@ export default class DateTime {
|
|
|
1190
1190
|
/**
|
|
1191
1191
|
* Checks whether this DateTime is before another date.
|
|
1192
1192
|
* @param {DateTime} other The date to compare to.
|
|
1193
|
-
* @
|
|
1193
|
+
* @returns {boolean} Whether this DateTime is before the other date.
|
|
1194
1194
|
*/
|
|
1195
1195
|
isBefore(other) {
|
|
1196
1196
|
return this.diff(other) < 0;
|
|
@@ -1199,7 +1199,7 @@ export default class DateTime {
|
|
|
1199
1199
|
/**
|
|
1200
1200
|
* Checks whether this DateTime is before another date (comparing by day).
|
|
1201
1201
|
* @param {DateTime} other The date to compare to.
|
|
1202
|
-
* @
|
|
1202
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by day).
|
|
1203
1203
|
*/
|
|
1204
1204
|
isBeforeDay(other) {
|
|
1205
1205
|
return this.diffInDays(other) < 0;
|
|
@@ -1208,7 +1208,7 @@ export default class DateTime {
|
|
|
1208
1208
|
/**
|
|
1209
1209
|
* Checks whether this DateTime is before another date (comparing by hour).
|
|
1210
1210
|
* @param {DateTime} other The date to compare to.
|
|
1211
|
-
* @
|
|
1211
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by hour).
|
|
1212
1212
|
*/
|
|
1213
1213
|
isBeforeHour(other) {
|
|
1214
1214
|
return this.diffInHours(other) < 0;
|
|
@@ -1217,7 +1217,7 @@ export default class DateTime {
|
|
|
1217
1217
|
/**
|
|
1218
1218
|
* Checks whether this DateTime is before another date (comparing by minute).
|
|
1219
1219
|
* @param {DateTime} other The date to compare to.
|
|
1220
|
-
* @
|
|
1220
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by minute).
|
|
1221
1221
|
*/
|
|
1222
1222
|
isBeforeMinute(other) {
|
|
1223
1223
|
return this.diffInMinutes(other) < 0;
|
|
@@ -1226,7 +1226,7 @@ export default class DateTime {
|
|
|
1226
1226
|
/**
|
|
1227
1227
|
* Checks whether this DateTime is before another date (comparing by month).
|
|
1228
1228
|
* @param {DateTime} other The date to compare to.
|
|
1229
|
-
* @
|
|
1229
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by month).
|
|
1230
1230
|
*/
|
|
1231
1231
|
isBeforeMonth(other) {
|
|
1232
1232
|
return this.diffInMonths(other) < 0;
|
|
@@ -1235,7 +1235,7 @@ export default class DateTime {
|
|
|
1235
1235
|
/**
|
|
1236
1236
|
* Checks whether this DateTime is before another date (comparing by second).
|
|
1237
1237
|
* @param {DateTime} other The date to compare to.
|
|
1238
|
-
* @
|
|
1238
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by second).
|
|
1239
1239
|
*/
|
|
1240
1240
|
isBeforeSecond(other) {
|
|
1241
1241
|
return this.diffInSeconds(other) < 0;
|
|
@@ -1244,7 +1244,7 @@ export default class DateTime {
|
|
|
1244
1244
|
/**
|
|
1245
1245
|
* Checks whether this DateTime is before another date (comparing by week).
|
|
1246
1246
|
* @param {DateTime} other The date to compare to.
|
|
1247
|
-
* @
|
|
1247
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by week).
|
|
1248
1248
|
*/
|
|
1249
1249
|
isBeforeWeek(other) {
|
|
1250
1250
|
return this.diffInWeeks(other) < 0;
|
|
@@ -1253,7 +1253,7 @@ export default class DateTime {
|
|
|
1253
1253
|
/**
|
|
1254
1254
|
* Checks whether this DateTime is before another date (comparing by year).
|
|
1255
1255
|
* @param {DateTime} other The date to compare to.
|
|
1256
|
-
* @
|
|
1256
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by year).
|
|
1257
1257
|
*/
|
|
1258
1258
|
isBeforeYear(other) {
|
|
1259
1259
|
return this.diffInYears(other) < 0;
|
|
@@ -1263,7 +1263,7 @@ export default class DateTime {
|
|
|
1263
1263
|
* Checks whether this DateTime is between two other dates.
|
|
1264
1264
|
* @param {DateTime} start The first date to compare to.
|
|
1265
1265
|
* @param {DateTime} end The second date to compare to.
|
|
1266
|
-
* @
|
|
1266
|
+
* @returns {boolean} Whether this DateTime is between two other dates.
|
|
1267
1267
|
*/
|
|
1268
1268
|
isBetween(start, end) {
|
|
1269
1269
|
return this.isAfter(start) && this.isBefore(end);
|
|
@@ -1273,7 +1273,7 @@ export default class DateTime {
|
|
|
1273
1273
|
* Checks whether this DateTime is between two other dates (comparing by day).
|
|
1274
1274
|
* @param {DateTime} start The first date to compare to.
|
|
1275
1275
|
* @param {DateTime} end The second date to compare to.
|
|
1276
|
-
* @
|
|
1276
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by day).
|
|
1277
1277
|
*/
|
|
1278
1278
|
isBetweenDay(start, end) {
|
|
1279
1279
|
return this.isAfterDay(start) && this.isBeforeDay(end);
|
|
@@ -1283,7 +1283,7 @@ export default class DateTime {
|
|
|
1283
1283
|
* Checks whether this DateTime is between two other dates (comparing by hour).
|
|
1284
1284
|
* @param {DateTime} start The first date to compare to.
|
|
1285
1285
|
* @param {DateTime} end The second date to compare to.
|
|
1286
|
-
* @
|
|
1286
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by hour).
|
|
1287
1287
|
*/
|
|
1288
1288
|
isBetweenHour(start, end) {
|
|
1289
1289
|
return this.isAfterHour(start) && this.isBeforeHour(end);
|
|
@@ -1293,7 +1293,7 @@ export default class DateTime {
|
|
|
1293
1293
|
* Checks whether this DateTime is between two other dates (comparing by minute).
|
|
1294
1294
|
* @param {DateTime} start The first date to compare to.
|
|
1295
1295
|
* @param {DateTime} end The second date to compare to.
|
|
1296
|
-
* @
|
|
1296
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by minute).
|
|
1297
1297
|
*/
|
|
1298
1298
|
isBetweenMinute(start, end) {
|
|
1299
1299
|
return this.isAfterMinute(start) && this.isBeforeMinute(end);
|
|
@@ -1303,7 +1303,7 @@ export default class DateTime {
|
|
|
1303
1303
|
* Checks whether this DateTime is between two other dates (comparing by month).
|
|
1304
1304
|
* @param {DateTime} start The first date to compare to.
|
|
1305
1305
|
* @param {DateTime} end The second date to compare to.
|
|
1306
|
-
* @
|
|
1306
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by month).
|
|
1307
1307
|
*/
|
|
1308
1308
|
isBetweenMonth(start, end) {
|
|
1309
1309
|
return this.isAfterMonth(start) && this.isBeforeMonth(end);
|
|
@@ -1313,7 +1313,7 @@ export default class DateTime {
|
|
|
1313
1313
|
* Checks whether this DateTime is between two other dates (comparing by second).
|
|
1314
1314
|
* @param {DateTime} start The first date to compare to.
|
|
1315
1315
|
* @param {DateTime} end The second date to compare to.
|
|
1316
|
-
* @
|
|
1316
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by second).
|
|
1317
1317
|
*/
|
|
1318
1318
|
isBetweenSecond(start, end) {
|
|
1319
1319
|
return this.isAfterSecond(start) && this.isBeforeSecond(end);
|
|
@@ -1323,7 +1323,7 @@ export default class DateTime {
|
|
|
1323
1323
|
* Checks whether this DateTime is between two other dates (comparing by week).
|
|
1324
1324
|
* @param {DateTime} start The first date to compare to.
|
|
1325
1325
|
* @param {DateTime} end The second date to compare to.
|
|
1326
|
-
* @
|
|
1326
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by week).
|
|
1327
1327
|
*/
|
|
1328
1328
|
isBetweenWeek(start, end) {
|
|
1329
1329
|
return this.isAfterWeek(start) && this.isBeforeWeek(end);
|
|
@@ -1333,7 +1333,7 @@ export default class DateTime {
|
|
|
1333
1333
|
* Checks whether this DateTime is between two other dates (comparing by year).
|
|
1334
1334
|
* @param {DateTime} start The first date to compare to.
|
|
1335
1335
|
* @param {DateTime} end The second date to compare to.
|
|
1336
|
-
* @
|
|
1336
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by year).
|
|
1337
1337
|
*/
|
|
1338
1338
|
isBetweenYear(start, end) {
|
|
1339
1339
|
return this.isAfterYear(start) && this.isBeforeYear(end);
|
|
@@ -1341,7 +1341,7 @@ export default class DateTime {
|
|
|
1341
1341
|
|
|
1342
1342
|
/**
|
|
1343
1343
|
* Checks whether the DateTime is in daylight saving time.
|
|
1344
|
-
* @
|
|
1344
|
+
* @returns {boolean} Whether the current time is in daylight saving time.
|
|
1345
1345
|
*/
|
|
1346
1346
|
isDst() {
|
|
1347
1347
|
if (!this._dynamicTz) {
|
|
@@ -1361,7 +1361,7 @@ export default class DateTime {
|
|
|
1361
1361
|
|
|
1362
1362
|
/**
|
|
1363
1363
|
* Checks whether the year is a leap year.
|
|
1364
|
-
* @
|
|
1364
|
+
* @returns {boolean} Whether the current year is a leap year.
|
|
1365
1365
|
*/
|
|
1366
1366
|
isLeapYear() {
|
|
1367
1367
|
return this.constructor.isLeapYear(
|
|
@@ -1372,7 +1372,7 @@ export default class DateTime {
|
|
|
1372
1372
|
/**
|
|
1373
1373
|
* Checks whether this DateTime is the same as another date.
|
|
1374
1374
|
* @param {DateTime} other The date to compare to.
|
|
1375
|
-
* @
|
|
1375
|
+
* @returns {boolean} Whether this DateTime is the same as the other date.
|
|
1376
1376
|
*/
|
|
1377
1377
|
isSame(other) {
|
|
1378
1378
|
return this.diff(other) === 0;
|
|
@@ -1381,7 +1381,7 @@ export default class DateTime {
|
|
|
1381
1381
|
/**
|
|
1382
1382
|
* Checks whether this DateTime is the same as another date (comparing by day).
|
|
1383
1383
|
* @param {DateTime} other The date to compare to.
|
|
1384
|
-
* @
|
|
1384
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by day).
|
|
1385
1385
|
*/
|
|
1386
1386
|
isSameDay(other) {
|
|
1387
1387
|
return this.diffInDays(other) === 0;
|
|
@@ -1390,7 +1390,7 @@ export default class DateTime {
|
|
|
1390
1390
|
/**
|
|
1391
1391
|
* Checks whether this DateTime is the same as another date (comparing by hour).
|
|
1392
1392
|
* @param {DateTime} other The date to compare to.
|
|
1393
|
-
* @
|
|
1393
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by hour).
|
|
1394
1394
|
*/
|
|
1395
1395
|
isSameHour(other) {
|
|
1396
1396
|
return this.diffInHours(other) === 0;
|
|
@@ -1399,7 +1399,7 @@ export default class DateTime {
|
|
|
1399
1399
|
/**
|
|
1400
1400
|
* Checks whether this DateTime is the same as another date (comparing by minute).
|
|
1401
1401
|
* @param {DateTime} other The date to compare to.
|
|
1402
|
-
* @
|
|
1402
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by minute).
|
|
1403
1403
|
*/
|
|
1404
1404
|
isSameMinute(other) {
|
|
1405
1405
|
return this.diffInMinutes(other) === 0;
|
|
@@ -1408,7 +1408,7 @@ export default class DateTime {
|
|
|
1408
1408
|
/**
|
|
1409
1409
|
* Checks whether this DateTime is the same as another date (comparing by month).
|
|
1410
1410
|
* @param {DateTime} other The date to compare to.
|
|
1411
|
-
* @
|
|
1411
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by month).
|
|
1412
1412
|
*/
|
|
1413
1413
|
isSameMonth(other) {
|
|
1414
1414
|
return this.diffInMonths(other) === 0;
|
|
@@ -1417,7 +1417,7 @@ export default class DateTime {
|
|
|
1417
1417
|
/**
|
|
1418
1418
|
* Checks whether this DateTime is the same as or after another date.
|
|
1419
1419
|
* @param {DateTime} other The date to compare to.
|
|
1420
|
-
* @
|
|
1420
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date.
|
|
1421
1421
|
*/
|
|
1422
1422
|
isSameOrAfter(other) {
|
|
1423
1423
|
return this.diff(other) >= 0;
|
|
@@ -1426,7 +1426,7 @@ export default class DateTime {
|
|
|
1426
1426
|
/**
|
|
1427
1427
|
* Checks whether this DateTime is the same as or after another date (comparing by day).
|
|
1428
1428
|
* @param {DateTime} other The date to compare to.
|
|
1429
|
-
* @
|
|
1429
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by day).
|
|
1430
1430
|
*/
|
|
1431
1431
|
isSameOrAfterDay(other) {
|
|
1432
1432
|
return this.diffInDays(other) >= 0;
|
|
@@ -1435,7 +1435,7 @@ export default class DateTime {
|
|
|
1435
1435
|
/**
|
|
1436
1436
|
* Checks whether this DateTime is the same as or after another date (comparing by hour).
|
|
1437
1437
|
* @param {DateTime} other The date to compare to.
|
|
1438
|
-
* @
|
|
1438
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by hour).
|
|
1439
1439
|
*/
|
|
1440
1440
|
isSameOrAfterHour(other) {
|
|
1441
1441
|
return this.diffInHours(other) >= 0;
|
|
@@ -1444,7 +1444,7 @@ export default class DateTime {
|
|
|
1444
1444
|
/**
|
|
1445
1445
|
* Checks whether this DateTime is the same as or after another date (comparing by minute).
|
|
1446
1446
|
* @param {DateTime} other The date to compare to.
|
|
1447
|
-
* @
|
|
1447
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by minute).
|
|
1448
1448
|
*/
|
|
1449
1449
|
isSameOrAfterMinute(other) {
|
|
1450
1450
|
return this.diffInMinutes(other) >= 0;
|
|
@@ -1453,7 +1453,7 @@ export default class DateTime {
|
|
|
1453
1453
|
/**
|
|
1454
1454
|
* Checks whether this DateTime is the same as or after another date (comparing by month).
|
|
1455
1455
|
* @param {DateTime} other The date to compare to.
|
|
1456
|
-
* @
|
|
1456
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by month).
|
|
1457
1457
|
*/
|
|
1458
1458
|
isSameOrAfterMonth(other) {
|
|
1459
1459
|
return this.diffInMonths(other) >= 0;
|
|
@@ -1462,7 +1462,7 @@ export default class DateTime {
|
|
|
1462
1462
|
/**
|
|
1463
1463
|
* Checks whether this DateTime is the same as or after another date (comparing by second).
|
|
1464
1464
|
* @param {DateTime} other The date to compare to.
|
|
1465
|
-
* @
|
|
1465
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by second).
|
|
1466
1466
|
*/
|
|
1467
1467
|
isSameOrAfterSecond(other) {
|
|
1468
1468
|
return this.diffInSeconds(other) >= 0;
|
|
@@ -1471,7 +1471,7 @@ export default class DateTime {
|
|
|
1471
1471
|
/**
|
|
1472
1472
|
* Checks whether this DateTime is the same as or after another date (comparing by week).
|
|
1473
1473
|
* @param {DateTime} other The date to compare to.
|
|
1474
|
-
* @
|
|
1474
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by week).
|
|
1475
1475
|
*/
|
|
1476
1476
|
isSameOrAfterWeek(other) {
|
|
1477
1477
|
return this.diffInWeeks(other) >= 0;
|
|
@@ -1480,7 +1480,7 @@ export default class DateTime {
|
|
|
1480
1480
|
/**
|
|
1481
1481
|
* Checks whether this DateTime is the same as or after another date (comparing by year).
|
|
1482
1482
|
* @param {DateTime} other The date to compare to.
|
|
1483
|
-
* @
|
|
1483
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by year).
|
|
1484
1484
|
*/
|
|
1485
1485
|
isSameOrAfterYear(other) {
|
|
1486
1486
|
return this.diffInYears(other) >= 0;
|
|
@@ -1489,7 +1489,7 @@ export default class DateTime {
|
|
|
1489
1489
|
/**
|
|
1490
1490
|
* Checks whether this DateTime is the same as or before another date.
|
|
1491
1491
|
* @param {DateTime} other The date to compare to.
|
|
1492
|
-
* @
|
|
1492
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date.
|
|
1493
1493
|
*/
|
|
1494
1494
|
isSameOrBefore(other) {
|
|
1495
1495
|
return this.diff(other) <= 0;
|
|
@@ -1498,7 +1498,7 @@ export default class DateTime {
|
|
|
1498
1498
|
/**
|
|
1499
1499
|
* Checks whether this DateTime is the same as or before another date (comparing by day).
|
|
1500
1500
|
* @param {DateTime} other The date to compare to.
|
|
1501
|
-
* @
|
|
1501
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by day).
|
|
1502
1502
|
*/
|
|
1503
1503
|
isSameOrBeforeDay(other) {
|
|
1504
1504
|
return this.diffInDays(other) <= 0;
|
|
@@ -1507,7 +1507,7 @@ export default class DateTime {
|
|
|
1507
1507
|
/**
|
|
1508
1508
|
* Checks whether this DateTime is the same as or before another date (comparing by hour).
|
|
1509
1509
|
* @param {DateTime} other The date to compare to.
|
|
1510
|
-
* @
|
|
1510
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by hour).
|
|
1511
1511
|
*/
|
|
1512
1512
|
isSameOrBeforeHour(other) {
|
|
1513
1513
|
return this.diffInHours(other) <= 0;
|
|
@@ -1516,7 +1516,7 @@ export default class DateTime {
|
|
|
1516
1516
|
/**
|
|
1517
1517
|
* Checks whether this DateTime is the same as or before another date (comparing by minute).
|
|
1518
1518
|
* @param {DateTime} other The date to compare to.
|
|
1519
|
-
* @
|
|
1519
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by minute).
|
|
1520
1520
|
*/
|
|
1521
1521
|
isSameOrBeforeMinute(other) {
|
|
1522
1522
|
return this.diffInMinutes(other) <= 0;
|
|
@@ -1525,7 +1525,7 @@ export default class DateTime {
|
|
|
1525
1525
|
/**
|
|
1526
1526
|
* Checks whether this DateTime is the same as or before another date (comparing by month).
|
|
1527
1527
|
* @param {DateTime} other The date to compare to.
|
|
1528
|
-
* @
|
|
1528
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by month).
|
|
1529
1529
|
*/
|
|
1530
1530
|
isSameOrBeforeMonth(other) {
|
|
1531
1531
|
return this.diffInMonths(other) <= 0;
|
|
@@ -1534,7 +1534,7 @@ export default class DateTime {
|
|
|
1534
1534
|
/**
|
|
1535
1535
|
* Checks whether this DateTime is the same as or before another date (comparing by second).
|
|
1536
1536
|
* @param {DateTime} other The date to compare to.
|
|
1537
|
-
* @
|
|
1537
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by second).
|
|
1538
1538
|
*/
|
|
1539
1539
|
isSameOrBeforeSecond(other) {
|
|
1540
1540
|
return this.diffInSeconds(other) <= 0;
|
|
@@ -1543,7 +1543,7 @@ export default class DateTime {
|
|
|
1543
1543
|
/**
|
|
1544
1544
|
* Checks whether this DateTime is the same as or before another date (comparing by week).
|
|
1545
1545
|
* @param {DateTime} other The date to compare to.
|
|
1546
|
-
* @
|
|
1546
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by week).
|
|
1547
1547
|
*/
|
|
1548
1548
|
isSameOrBeforeWeek(other) {
|
|
1549
1549
|
return this.diffInWeeks(other) <= 0;
|
|
@@ -1552,7 +1552,7 @@ export default class DateTime {
|
|
|
1552
1552
|
/**
|
|
1553
1553
|
* Checks whether this DateTime is the same as or before another date (comparing by year).
|
|
1554
1554
|
* @param {DateTime} other The date to compare to.
|
|
1555
|
-
* @
|
|
1555
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by year).
|
|
1556
1556
|
*/
|
|
1557
1557
|
isSameOrBeforeYear(other) {
|
|
1558
1558
|
return this.diffInYears(other) <= 0;
|
|
@@ -1561,7 +1561,7 @@ export default class DateTime {
|
|
|
1561
1561
|
/**
|
|
1562
1562
|
* Checks whether this DateTime is the same as another date (comparing by second).
|
|
1563
1563
|
* @param {DateTime} other The date to compare to.
|
|
1564
|
-
* @
|
|
1564
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by second).
|
|
1565
1565
|
*/
|
|
1566
1566
|
isSameSecond(other) {
|
|
1567
1567
|
return this.diffInSeconds(other) === 0;
|
|
@@ -1570,7 +1570,7 @@ export default class DateTime {
|
|
|
1570
1570
|
/**
|
|
1571
1571
|
* Checks whether this DateTime is the same as another date (comparing by week).
|
|
1572
1572
|
* @param {DateTime} other The date to compare to.
|
|
1573
|
-
* @
|
|
1573
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by week).
|
|
1574
1574
|
*/
|
|
1575
1575
|
isSameWeek(other) {
|
|
1576
1576
|
return this.diffInWeeks(other) === 0;
|
|
@@ -1579,7 +1579,7 @@ export default class DateTime {
|
|
|
1579
1579
|
/**
|
|
1580
1580
|
* Checks whether this DateTime is the same as another date (comparing by year).
|
|
1581
1581
|
* @param {DateTime} other The date to compare to.
|
|
1582
|
-
* @
|
|
1582
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by year).
|
|
1583
1583
|
*/
|
|
1584
1584
|
isSameYear(other) {
|
|
1585
1585
|
return this.diffInYears(other) === 0;
|
|
@@ -1588,7 +1588,7 @@ export default class DateTime {
|
|
|
1588
1588
|
/**
|
|
1589
1589
|
* Gets the localized month name for the current date.
|
|
1590
1590
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of month name to return.
|
|
1591
|
-
* @
|
|
1591
|
+
* @returns {string} The localized month name.
|
|
1592
1592
|
*/
|
|
1593
1593
|
monthName(type = 'long') {
|
|
1594
1594
|
return formatMonth(this.getLocale(), this.getMonth(), type);
|
|
@@ -1596,7 +1596,7 @@ export default class DateTime {
|
|
|
1596
1596
|
|
|
1597
1597
|
/**
|
|
1598
1598
|
* Sets the DateTime to the start of the day.
|
|
1599
|
-
* @
|
|
1599
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1600
1600
|
*/
|
|
1601
1601
|
startOfDay() {
|
|
1602
1602
|
return this.withHours(0, 0, 0, 0);
|
|
@@ -1604,7 +1604,7 @@ export default class DateTime {
|
|
|
1604
1604
|
|
|
1605
1605
|
/**
|
|
1606
1606
|
* Sets the DateTime to the start of the hour.
|
|
1607
|
-
* @
|
|
1607
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1608
1608
|
*/
|
|
1609
1609
|
startOfHour() {
|
|
1610
1610
|
return this.withMinutes(0, 0, 0);
|
|
@@ -1612,7 +1612,7 @@ export default class DateTime {
|
|
|
1612
1612
|
|
|
1613
1613
|
/**
|
|
1614
1614
|
* Sets the DateTime to the start of the minute.
|
|
1615
|
-
* @
|
|
1615
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1616
1616
|
*/
|
|
1617
1617
|
startOfMinute() {
|
|
1618
1618
|
return this.withSeconds(0, 0);
|
|
@@ -1620,7 +1620,7 @@ export default class DateTime {
|
|
|
1620
1620
|
|
|
1621
1621
|
/**
|
|
1622
1622
|
* Sets the DateTime to the start of the month.
|
|
1623
|
-
* @
|
|
1623
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1624
1624
|
*/
|
|
1625
1625
|
startOfMonth() {
|
|
1626
1626
|
return this.withDate(1)
|
|
@@ -1629,7 +1629,7 @@ export default class DateTime {
|
|
|
1629
1629
|
|
|
1630
1630
|
/**
|
|
1631
1631
|
* Sets the DateTime to the start of the quarter.
|
|
1632
|
-
* @
|
|
1632
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1633
1633
|
*/
|
|
1634
1634
|
startOfQuarter() {
|
|
1635
1635
|
const month = this.getQuarter() * 3 - 2;
|
|
@@ -1639,7 +1639,7 @@ export default class DateTime {
|
|
|
1639
1639
|
|
|
1640
1640
|
/**
|
|
1641
1641
|
* Sets the DateTime to the start of the second.
|
|
1642
|
-
* @
|
|
1642
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1643
1643
|
*/
|
|
1644
1644
|
startOfSecond() {
|
|
1645
1645
|
return this.withMilliseconds(0);
|
|
@@ -1647,7 +1647,7 @@ export default class DateTime {
|
|
|
1647
1647
|
|
|
1648
1648
|
/**
|
|
1649
1649
|
* Sets the DateTime to the start of the week.
|
|
1650
|
-
* @
|
|
1650
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1651
1651
|
*/
|
|
1652
1652
|
startOfWeek() {
|
|
1653
1653
|
return this.withWeekDay(1)
|
|
@@ -1656,7 +1656,7 @@ export default class DateTime {
|
|
|
1656
1656
|
|
|
1657
1657
|
/**
|
|
1658
1658
|
* Sets the DateTime to the start of the year.
|
|
1659
|
-
* @
|
|
1659
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1660
1660
|
*/
|
|
1661
1661
|
startOfYear() {
|
|
1662
1662
|
return this.withMonth(1, 1)
|
|
@@ -1665,7 +1665,7 @@ export default class DateTime {
|
|
|
1665
1665
|
|
|
1666
1666
|
/**
|
|
1667
1667
|
* Subtracts a day from the current DateTime.
|
|
1668
|
-
* @
|
|
1668
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1669
1669
|
*/
|
|
1670
1670
|
subDay() {
|
|
1671
1671
|
return this.addDays(-1);
|
|
@@ -1674,7 +1674,7 @@ export default class DateTime {
|
|
|
1674
1674
|
/**
|
|
1675
1675
|
* Subtracts days from the current DateTime.
|
|
1676
1676
|
* @param {number} amount The number of days to subtract.
|
|
1677
|
-
* @
|
|
1677
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1678
1678
|
*/
|
|
1679
1679
|
subDays(amount) {
|
|
1680
1680
|
return this.addDays(-amount);
|
|
@@ -1682,7 +1682,7 @@ export default class DateTime {
|
|
|
1682
1682
|
|
|
1683
1683
|
/**
|
|
1684
1684
|
* Subtracts an hour from the current DateTime.
|
|
1685
|
-
* @
|
|
1685
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1686
1686
|
*/
|
|
1687
1687
|
subHour() {
|
|
1688
1688
|
return this.addHours(-1);
|
|
@@ -1691,7 +1691,7 @@ export default class DateTime {
|
|
|
1691
1691
|
/**
|
|
1692
1692
|
* Subtracts hours from the current DateTime.
|
|
1693
1693
|
* @param {number} amount The number of hours to subtract.
|
|
1694
|
-
* @
|
|
1694
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1695
1695
|
*/
|
|
1696
1696
|
subHours(amount) {
|
|
1697
1697
|
return this.addHours(-amount);
|
|
@@ -1699,7 +1699,7 @@ export default class DateTime {
|
|
|
1699
1699
|
|
|
1700
1700
|
/**
|
|
1701
1701
|
* Subtracts a minute from the current DateTime.
|
|
1702
|
-
* @
|
|
1702
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1703
1703
|
*/
|
|
1704
1704
|
subMinute() {
|
|
1705
1705
|
return this.addMinutes(-1);
|
|
@@ -1708,7 +1708,7 @@ export default class DateTime {
|
|
|
1708
1708
|
/**
|
|
1709
1709
|
* Subtracts minutes from the current DateTime.
|
|
1710
1710
|
* @param {number} amount The number of minutes to subtract.
|
|
1711
|
-
* @
|
|
1711
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1712
1712
|
*/
|
|
1713
1713
|
subMinutes(amount) {
|
|
1714
1714
|
return this.addMinutes(-amount);
|
|
@@ -1716,7 +1716,7 @@ export default class DateTime {
|
|
|
1716
1716
|
|
|
1717
1717
|
/**
|
|
1718
1718
|
* Subtracts a month from the current DateTime.
|
|
1719
|
-
* @
|
|
1719
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1720
1720
|
*/
|
|
1721
1721
|
subMonth() {
|
|
1722
1722
|
return this.addMonths(-1);
|
|
@@ -1725,7 +1725,7 @@ export default class DateTime {
|
|
|
1725
1725
|
/**
|
|
1726
1726
|
* Subtracts months from the current DateTime.
|
|
1727
1727
|
* @param {number} amount The number of months to subtract.
|
|
1728
|
-
* @
|
|
1728
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1729
1729
|
*/
|
|
1730
1730
|
subMonths(amount) {
|
|
1731
1731
|
return this.addMonths(-amount);
|
|
@@ -1733,7 +1733,7 @@ export default class DateTime {
|
|
|
1733
1733
|
|
|
1734
1734
|
/**
|
|
1735
1735
|
* Subtracts a second from the current DateTime.
|
|
1736
|
-
* @
|
|
1736
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1737
1737
|
*/
|
|
1738
1738
|
subSecond() {
|
|
1739
1739
|
return this.addSeconds(-1);
|
|
@@ -1742,7 +1742,7 @@ export default class DateTime {
|
|
|
1742
1742
|
/**
|
|
1743
1743
|
* Subtracts seconds from the current DateTime.
|
|
1744
1744
|
* @param {number} amount The number of seconds to subtract.
|
|
1745
|
-
* @
|
|
1745
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1746
1746
|
*/
|
|
1747
1747
|
subSeconds(amount) {
|
|
1748
1748
|
return this.addSeconds(-amount);
|
|
@@ -1750,7 +1750,7 @@ export default class DateTime {
|
|
|
1750
1750
|
|
|
1751
1751
|
/**
|
|
1752
1752
|
* Subtracts a week from the current DateTime.
|
|
1753
|
-
* @
|
|
1753
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1754
1754
|
*/
|
|
1755
1755
|
subWeek() {
|
|
1756
1756
|
return this.addWeeks(-1);
|
|
@@ -1759,7 +1759,7 @@ export default class DateTime {
|
|
|
1759
1759
|
/**
|
|
1760
1760
|
* Subtracts weeks from the current DateTime.
|
|
1761
1761
|
* @param {number} amount The number of weeks to subtract.
|
|
1762
|
-
* @
|
|
1762
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1763
1763
|
*/
|
|
1764
1764
|
subWeeks(amount) {
|
|
1765
1765
|
return this.addWeeks(-amount);
|
|
@@ -1767,7 +1767,7 @@ export default class DateTime {
|
|
|
1767
1767
|
|
|
1768
1768
|
/**
|
|
1769
1769
|
* Subtracts a year from the current DateTime.
|
|
1770
|
-
* @
|
|
1770
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1771
1771
|
*/
|
|
1772
1772
|
subYear() {
|
|
1773
1773
|
return this.addYears(-1);
|
|
@@ -1776,7 +1776,7 @@ export default class DateTime {
|
|
|
1776
1776
|
/**
|
|
1777
1777
|
* Subtracts years from the current DateTime.
|
|
1778
1778
|
* @param {number} amount The number of years to subtract.
|
|
1779
|
-
* @
|
|
1779
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1780
1780
|
*/
|
|
1781
1781
|
subYears(amount) {
|
|
1782
1782
|
return this.addYears(-amount);
|
|
@@ -1785,7 +1785,7 @@ export default class DateTime {
|
|
|
1785
1785
|
/**
|
|
1786
1786
|
* Returns the primitive representation of the DateTime.
|
|
1787
1787
|
* @param {'default'|'number'|'string'} hint The conversion hint.
|
|
1788
|
-
* @
|
|
1788
|
+
* @returns {string|number} A string for default/string coercion or epoch milliseconds for numeric coercion.
|
|
1789
1789
|
*/
|
|
1790
1790
|
[Symbol.toPrimitive](hint) {
|
|
1791
1791
|
return hint === 'number' ?
|
|
@@ -1796,7 +1796,7 @@ export default class DateTime {
|
|
|
1796
1796
|
/**
|
|
1797
1797
|
* Gets the name of the current time zone.
|
|
1798
1798
|
* @param {'long'|'short'} [type='long'] The formatting type.
|
|
1799
|
-
* @
|
|
1799
|
+
* @returns {string} The name of the time zone.
|
|
1800
1800
|
*/
|
|
1801
1801
|
timeZoneName(type = 'long') {
|
|
1802
1802
|
return this._dynamicTz ?
|
|
@@ -1806,7 +1806,7 @@ export default class DateTime {
|
|
|
1806
1806
|
|
|
1807
1807
|
/**
|
|
1808
1808
|
* Formats the current date using "eee MMM dd yyyy".
|
|
1809
|
-
* @
|
|
1809
|
+
* @returns {string} The formatted date string.
|
|
1810
1810
|
*/
|
|
1811
1811
|
toDateString() {
|
|
1812
1812
|
return this.format(formats.date);
|
|
@@ -1814,9 +1814,9 @@ export default class DateTime {
|
|
|
1814
1814
|
|
|
1815
1815
|
/**
|
|
1816
1816
|
* Formats the current date using "yyyy-MM-dd'T'HH:mm:ss.SSSxxx".
|
|
1817
|
-
* @
|
|
1817
|
+
* @returns {string} The formatted date string.
|
|
1818
1818
|
*/
|
|
1819
|
-
|
|
1819
|
+
toIsoString() {
|
|
1820
1820
|
return this
|
|
1821
1821
|
.withLocale('en')
|
|
1822
1822
|
.withTimeZone('UTC')
|
|
@@ -1825,17 +1825,17 @@ export default class DateTime {
|
|
|
1825
1825
|
|
|
1826
1826
|
/**
|
|
1827
1827
|
* Returns the JSON representation of the current date.
|
|
1828
|
-
* @
|
|
1828
|
+
* @returns {string|null} The ISO string for valid dates or null for invalid dates.
|
|
1829
1829
|
*/
|
|
1830
1830
|
toJSON() {
|
|
1831
1831
|
return this.isValid ?
|
|
1832
|
-
this.
|
|
1832
|
+
this.toIsoString() :
|
|
1833
1833
|
null;
|
|
1834
1834
|
}
|
|
1835
1835
|
|
|
1836
1836
|
/**
|
|
1837
1837
|
* Formats the current date using "eee MMM dd yyyy HH:mm:ss xx (VV)".
|
|
1838
|
-
* @
|
|
1838
|
+
* @returns {string} The formatted date string.
|
|
1839
1839
|
*/
|
|
1840
1840
|
toString() {
|
|
1841
1841
|
return this.format(formats.string);
|
|
@@ -1843,7 +1843,7 @@ export default class DateTime {
|
|
|
1843
1843
|
|
|
1844
1844
|
/**
|
|
1845
1845
|
* Formats the current date using "HH:mm:ss xx (VV)".
|
|
1846
|
-
* @
|
|
1846
|
+
* @returns {string} The formatted date string.
|
|
1847
1847
|
*/
|
|
1848
1848
|
toTimeString() {
|
|
1849
1849
|
return this.format(formats.time);
|
|
@@ -1851,7 +1851,7 @@ export default class DateTime {
|
|
|
1851
1851
|
|
|
1852
1852
|
/**
|
|
1853
1853
|
* Formats the current date in the UTC time zone using "eee MMM dd yyyy HH:mm:ss xx (VV)".
|
|
1854
|
-
* @
|
|
1854
|
+
* @returns {string} The formatted date string.
|
|
1855
1855
|
*/
|
|
1856
1856
|
toUTCString() {
|
|
1857
1857
|
return this
|
|
@@ -1862,7 +1862,7 @@ export default class DateTime {
|
|
|
1862
1862
|
|
|
1863
1863
|
/**
|
|
1864
1864
|
* Returns the number of milliseconds since the UNIX epoch.
|
|
1865
|
-
* @
|
|
1865
|
+
* @returns {number} The number of milliseconds since the UNIX epoch.
|
|
1866
1866
|
*/
|
|
1867
1867
|
valueOf() {
|
|
1868
1868
|
return this.getTime();
|
|
@@ -1870,7 +1870,7 @@ export default class DateTime {
|
|
|
1870
1870
|
|
|
1871
1871
|
/**
|
|
1872
1872
|
* Gets the number of weeks in the current year.
|
|
1873
|
-
* @
|
|
1873
|
+
* @returns {number} The number of weeks in the current year.
|
|
1874
1874
|
*/
|
|
1875
1875
|
weeksInYear() {
|
|
1876
1876
|
const minDays = minimumDays(this.getLocale());
|
|
@@ -1880,7 +1880,7 @@ export default class DateTime {
|
|
|
1880
1880
|
/**
|
|
1881
1881
|
* Returns a copy with the date of the month changed in the current time zone.
|
|
1882
1882
|
* @param {number} date The date of the month.
|
|
1883
|
-
* @
|
|
1883
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1884
1884
|
*/
|
|
1885
1885
|
withDate(date) {
|
|
1886
1886
|
return setOffsetTime(
|
|
@@ -1892,7 +1892,7 @@ export default class DateTime {
|
|
|
1892
1892
|
/**
|
|
1893
1893
|
* Returns a copy with the day of the week changed in the current time zone.
|
|
1894
1894
|
* @param {number} day The day of the week. (0 = Sunday, 6 = Saturday)
|
|
1895
|
-
* @
|
|
1895
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1896
1896
|
*/
|
|
1897
1897
|
withDay(day) {
|
|
1898
1898
|
return setOffsetTime(
|
|
@@ -1908,7 +1908,7 @@ export default class DateTime {
|
|
|
1908
1908
|
/**
|
|
1909
1909
|
* Returns a copy with the day of the year changed in the current time zone.
|
|
1910
1910
|
* @param {number} day The day of the year. (1-366)
|
|
1911
|
-
* @
|
|
1911
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1912
1912
|
*/
|
|
1913
1913
|
withDayOfYear(day) {
|
|
1914
1914
|
return setOffsetTime(
|
|
@@ -1926,7 +1926,7 @@ export default class DateTime {
|
|
|
1926
1926
|
* @param {number} [minutes] The minutes. (0-59)
|
|
1927
1927
|
* @param {number} [seconds] The seconds. (0-59)
|
|
1928
1928
|
* @param {number} [milliseconds] The milliseconds.
|
|
1929
|
-
* @
|
|
1929
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1930
1930
|
*/
|
|
1931
1931
|
withHours(...args) {
|
|
1932
1932
|
return setOffsetTime(
|
|
@@ -1938,7 +1938,7 @@ export default class DateTime {
|
|
|
1938
1938
|
/**
|
|
1939
1939
|
* Returns a copy with a different locale.
|
|
1940
1940
|
* @param {string} locale The locale to use.
|
|
1941
|
-
* @
|
|
1941
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1942
1942
|
*/
|
|
1943
1943
|
withLocale(locale) {
|
|
1944
1944
|
return new this.constructor(this.getTime(), {
|
|
@@ -1950,7 +1950,7 @@ export default class DateTime {
|
|
|
1950
1950
|
/**
|
|
1951
1951
|
* Returns a copy with the milliseconds changed in the current time zone.
|
|
1952
1952
|
* @param {number} milliseconds The milliseconds.
|
|
1953
|
-
* @
|
|
1953
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1954
1954
|
*/
|
|
1955
1955
|
withMilliseconds(milliseconds) {
|
|
1956
1956
|
return setOffsetTime(
|
|
@@ -1964,7 +1964,7 @@ export default class DateTime {
|
|
|
1964
1964
|
* @param {number} minutes The minutes. (0-59)
|
|
1965
1965
|
* @param {number} [seconds] The seconds. (0-59)
|
|
1966
1966
|
* @param {number} [milliseconds] The milliseconds.
|
|
1967
|
-
* @
|
|
1967
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1968
1968
|
*/
|
|
1969
1969
|
withMinutes(...args) {
|
|
1970
1970
|
return setOffsetTime(
|
|
@@ -1977,7 +1977,7 @@ export default class DateTime {
|
|
|
1977
1977
|
* Returns a copy with the month changed in the current time zone.
|
|
1978
1978
|
* @param {number} month The month. (1-12)
|
|
1979
1979
|
* @param {number|null} [date] The date of the month.
|
|
1980
|
-
* @
|
|
1980
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1981
1981
|
*/
|
|
1982
1982
|
withMonth(month, date = null) {
|
|
1983
1983
|
if (date === null) {
|
|
@@ -2006,7 +2006,7 @@ export default class DateTime {
|
|
|
2006
2006
|
/**
|
|
2007
2007
|
* Returns a copy with the quarter of the year changed in the current time zone.
|
|
2008
2008
|
* @param {number} quarter The quarter of the year. (1-4)
|
|
2009
|
-
* @
|
|
2009
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2010
2010
|
*/
|
|
2011
2011
|
withQuarter(quarter) {
|
|
2012
2012
|
return setOffsetTime(
|
|
@@ -2022,7 +2022,7 @@ export default class DateTime {
|
|
|
2022
2022
|
* Returns a copy with the seconds changed in the current time zone.
|
|
2023
2023
|
* @param {number} seconds The seconds. (0-59)
|
|
2024
2024
|
* @param {number} [milliseconds] The milliseconds.
|
|
2025
|
-
* @
|
|
2025
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2026
2026
|
*/
|
|
2027
2027
|
withSeconds(...args) {
|
|
2028
2028
|
return setOffsetTime(
|
|
@@ -2034,7 +2034,7 @@ export default class DateTime {
|
|
|
2034
2034
|
/**
|
|
2035
2035
|
* Returns a copy with a different epoch-millisecond value.
|
|
2036
2036
|
* @param {number} time The number of milliseconds since the UNIX epoch.
|
|
2037
|
-
* @
|
|
2037
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2038
2038
|
*/
|
|
2039
2039
|
withTime(time) {
|
|
2040
2040
|
return new this.constructor(time, {
|
|
@@ -2046,7 +2046,7 @@ export default class DateTime {
|
|
|
2046
2046
|
/**
|
|
2047
2047
|
* Returns a copy with a different number of seconds since the UNIX epoch.
|
|
2048
2048
|
* @param {number} timestamp The number of seconds since the UNIX epoch.
|
|
2049
|
-
* @
|
|
2049
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2050
2050
|
*/
|
|
2051
2051
|
withTimestamp(timestamp) {
|
|
2052
2052
|
return this.withTime(timestamp * 1000);
|
|
@@ -2055,7 +2055,7 @@ export default class DateTime {
|
|
|
2055
2055
|
/**
|
|
2056
2056
|
* Returns a copy in a different time zone.
|
|
2057
2057
|
* @param {string} timeZone The time zone to use.
|
|
2058
|
-
* @
|
|
2058
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2059
2059
|
*/
|
|
2060
2060
|
withTimeZone(timeZone) {
|
|
2061
2061
|
return new this.constructor(this.getTime(), {
|
|
@@ -2067,7 +2067,7 @@ export default class DateTime {
|
|
|
2067
2067
|
/**
|
|
2068
2068
|
* Returns a copy with a fixed numeric UTC offset.
|
|
2069
2069
|
* @param {number} offset The UTC offset in minutes.
|
|
2070
|
-
* @
|
|
2070
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2071
2071
|
*/
|
|
2072
2072
|
withTimeZoneOffset(offset) {
|
|
2073
2073
|
return new this.constructor(this.getTime(), {
|
|
@@ -2080,7 +2080,7 @@ export default class DateTime {
|
|
|
2080
2080
|
* Returns a copy with the local week changed in the current time zone.
|
|
2081
2081
|
* @param {number} week The local week.
|
|
2082
2082
|
* @param {number|null} [day] The local day of the week. (1-7)
|
|
2083
|
-
* @
|
|
2083
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2084
2084
|
*/
|
|
2085
2085
|
withWeek(week, day = null) {
|
|
2086
2086
|
if (day === null) {
|
|
@@ -2094,7 +2094,7 @@ export default class DateTime {
|
|
|
2094
2094
|
/**
|
|
2095
2095
|
* Returns a copy with the local day of the week changed in the current time zone.
|
|
2096
2096
|
* @param {number} day The local day of the week. (1-7)
|
|
2097
|
-
* @
|
|
2097
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2098
2098
|
*/
|
|
2099
2099
|
withWeekDay(day) {
|
|
2100
2100
|
return setOffsetTime(
|
|
@@ -2110,7 +2110,7 @@ export default class DateTime {
|
|
|
2110
2110
|
/**
|
|
2111
2111
|
* Returns a copy with the week day in month changed in the current time zone.
|
|
2112
2112
|
* @param {number} week The week day in month.
|
|
2113
|
-
* @
|
|
2113
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2114
2114
|
*/
|
|
2115
2115
|
withWeekDayInMonth(week) {
|
|
2116
2116
|
return this.withDate(
|
|
@@ -2125,7 +2125,7 @@ export default class DateTime {
|
|
|
2125
2125
|
/**
|
|
2126
2126
|
* Returns a copy with the week of month changed in the current time zone.
|
|
2127
2127
|
* @param {number} week The week of month.
|
|
2128
|
-
* @
|
|
2128
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2129
2129
|
*/
|
|
2130
2130
|
withWeekOfMonth(week) {
|
|
2131
2131
|
return this.withDate(
|
|
@@ -2142,7 +2142,7 @@ export default class DateTime {
|
|
|
2142
2142
|
* @param {number} year The local week year.
|
|
2143
2143
|
* @param {number|null} [week] The local week.
|
|
2144
2144
|
* @param {number|null} [day] The local day of the week. (1-7)
|
|
2145
|
-
* @
|
|
2145
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2146
2146
|
*/
|
|
2147
2147
|
withWeekYear(year, week = null, day = null) {
|
|
2148
2148
|
const minDays = minimumDays(this.getLocale());
|
|
@@ -2170,7 +2170,7 @@ export default class DateTime {
|
|
|
2170
2170
|
* @param {number} year The year.
|
|
2171
2171
|
* @param {number|null} [month] The month. (1-12)
|
|
2172
2172
|
* @param {number|null} [date] The date of the month.
|
|
2173
|
-
* @
|
|
2173
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2174
2174
|
*/
|
|
2175
2175
|
withYear(year, month = null, date = null) {
|
|
2176
2176
|
if (month === null) {
|