@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/dist/frost-datetime.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @template T
|
|
22
22
|
* @param {string} key The key for the values.
|
|
23
23
|
* @param {() => T} callback The callback to generate the values.
|
|
24
|
-
* @
|
|
24
|
+
* @returns {T} The cached value.
|
|
25
25
|
*/
|
|
26
26
|
function getData(key, callback) {
|
|
27
27
|
if (!data.has(key)) {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
/**
|
|
34
34
|
* Creates a date formatter for a time zone.
|
|
35
35
|
* @param {string} timeZone The time zone.
|
|
36
|
-
* @
|
|
36
|
+
* @returns {Intl.DateTimeFormat} The formatter instance.
|
|
37
37
|
*/
|
|
38
38
|
function getDateFormatter(timeZone) {
|
|
39
39
|
return getData(
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
/**
|
|
56
56
|
* Creates a relative-time formatter for a locale.
|
|
57
57
|
* @param {string} locale The locale.
|
|
58
|
-
* @
|
|
58
|
+
* @returns {Intl.RelativeTimeFormat|null} The formatter instance, or null when unsupported.
|
|
59
59
|
*/
|
|
60
60
|
function getRelativeFormatter(locale) {
|
|
61
61
|
if (!('RelativeTimeFormat' in Intl)) {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
* Creates a formatter for a locale.
|
|
75
75
|
* @param {string} locale The locale.
|
|
76
76
|
* @param {Intl.DateTimeFormatOptions} options The options for the formatter.
|
|
77
|
-
* @
|
|
77
|
+
* @returns {Intl.DateTimeFormat} The formatter instance.
|
|
78
78
|
*/
|
|
79
79
|
function makeFormatter(locale, options) {
|
|
80
80
|
return new Intl.DateTimeFormat(locale, {
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
/**
|
|
151
151
|
* Escapes a string for safe use inside a RegExp source.
|
|
152
152
|
* @param {string} value The string to escape.
|
|
153
|
-
* @
|
|
153
|
+
* @returns {string} The escaped string.
|
|
154
154
|
*/
|
|
155
155
|
function escapeRegExp(value) {
|
|
156
156
|
return value.replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&');
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
/**
|
|
160
160
|
* Gets a stable day number from a DateTime's local calendar fields.
|
|
161
161
|
* @param {DateTime} date The DateTime.
|
|
162
|
-
* @
|
|
162
|
+
* @returns {number} The local calendar day number.
|
|
163
163
|
*/
|
|
164
164
|
function calendarDay(date) {
|
|
165
165
|
const calendarDate = new Date(0);
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
* @param {DateTime} other The DateTime to compare to.
|
|
175
175
|
* @param {'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second'} timeUnit The time unit to compare in.
|
|
176
176
|
* @param {boolean} [relative=true] Whether to use relative boundaries when calculating the difference.
|
|
177
|
-
* @
|
|
177
|
+
* @returns {number} The difference between the dates in the given time unit.
|
|
178
178
|
*/
|
|
179
179
|
function calculateDiff(date, other, timeUnit, relative = true) {
|
|
180
180
|
other = other.withTimeZone(date.getTimeZone());
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
* Gets the RegExp for a list of string values.
|
|
287
287
|
* Longer values are matched first to avoid prefix collisions.
|
|
288
288
|
* @param {string[]} values The values to include in the RegExp.
|
|
289
|
-
* @
|
|
289
|
+
* @returns {string} The values RegExp.
|
|
290
290
|
*/
|
|
291
291
|
function valuesRegExp(values) {
|
|
292
292
|
return values.slice()
|
|
@@ -301,7 +301,7 @@
|
|
|
301
301
|
* @param {number} amount The amount to compensate.
|
|
302
302
|
* @param {boolean} [compensate=true] Whether to compensate the amount.
|
|
303
303
|
* @param {number} [compensation=1] The compensation offset.
|
|
304
|
-
* @
|
|
304
|
+
* @returns {number} The compensated amount.
|
|
305
305
|
*/
|
|
306
306
|
function compensateDiff(date, other, amount, compensate = true, compensation = 1) {
|
|
307
307
|
if (amount > 0) {
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
* Gets the biggest difference between two dates.
|
|
325
325
|
* @param {DateTime} date The DateTime.
|
|
326
326
|
* @param {DateTime} [other] The DateTime to compare to.
|
|
327
|
-
* @
|
|
327
|
+
* @returns {[number, string]} The biggest difference (amount and time unit).
|
|
328
328
|
*/
|
|
329
329
|
function getBiggestDiff(date, other) {
|
|
330
330
|
let lastResult;
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
/**
|
|
356
356
|
* Gets the offset for a DateTime.
|
|
357
357
|
* @param {DateTime} date The DateTime.
|
|
358
|
-
* @
|
|
358
|
+
* @returns {number} The offset.
|
|
359
359
|
*/
|
|
360
360
|
function getOffset(date) {
|
|
361
361
|
const timeZone = date.getTimeZone();
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
/**
|
|
395
395
|
* Gets the number of milliseconds since the UNIX epoch (offset to timeZone).
|
|
396
396
|
* @param {DateTime} date The DateTime.
|
|
397
|
-
* @
|
|
397
|
+
* @returns {number} The number of milliseconds since the UNIX epoch (offset to timeZone).
|
|
398
398
|
*/
|
|
399
399
|
function getOffsetTime(date) {
|
|
400
400
|
return date.getTime() - (date.getTimeZoneOffset() * 60000);
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
/**
|
|
418
418
|
* Parses a supported unzoned ISO string as a neutral wall-clock timestamp.
|
|
419
419
|
* @param {string} dateString The date string to parse.
|
|
420
|
-
* @
|
|
420
|
+
* @returns {number|null} The timestamp, or null if the shape is not supported.
|
|
421
421
|
*/
|
|
422
422
|
function parseLocalTimestamp(dateString) {
|
|
423
423
|
const match =
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* Generates methods for parsing a date.
|
|
449
|
-
* @
|
|
449
|
+
* @returns {Record<string, {get: Function, set: Function}>} An object containing date parsing methods.
|
|
450
450
|
*/
|
|
451
451
|
function parseFactory() {
|
|
452
452
|
let isPM = false;
|
|
@@ -552,7 +552,7 @@
|
|
|
552
552
|
* @param {DateTime} date The DateTime.
|
|
553
553
|
* @param {number} time The number of milliseconds since the UNIX epoch (offset to timeZone).
|
|
554
554
|
* @param {number} [direction=1] The direction to resolve a gap.
|
|
555
|
-
* @
|
|
555
|
+
* @returns {DateTime} A new DateTime instance.
|
|
556
556
|
*/
|
|
557
557
|
function setOffsetTime(date, time, direction = 1) {
|
|
558
558
|
const newDate = date.withTime(
|
|
@@ -591,8 +591,8 @@
|
|
|
591
591
|
/**
|
|
592
592
|
* Gets cached localized day-period labels.
|
|
593
593
|
* @param {string} locale The locale.
|
|
594
|
-
* @param {string} [type=long] The formatting type.
|
|
595
|
-
* @
|
|
594
|
+
* @param {string} [type='long'] The formatting type.
|
|
595
|
+
* @returns {string[]} The localized day-period labels.
|
|
596
596
|
*/
|
|
597
597
|
function getDayPeriods(locale, type = 'long') {
|
|
598
598
|
return getData(
|
|
@@ -612,9 +612,9 @@
|
|
|
612
612
|
/**
|
|
613
613
|
* Gets cached localized weekday labels.
|
|
614
614
|
* @param {string} locale The locale.
|
|
615
|
-
* @param {string} [type=long] The formatting type.
|
|
615
|
+
* @param {string} [type='long'] The formatting type.
|
|
616
616
|
* @param {boolean} [standalone=true] Whether the values are standalone.
|
|
617
|
-
* @
|
|
617
|
+
* @returns {string[]} The localized weekday labels.
|
|
618
618
|
*/
|
|
619
619
|
function getDays(locale, type = 'long', standalone = true) {
|
|
620
620
|
return getData(
|
|
@@ -643,8 +643,8 @@
|
|
|
643
643
|
/**
|
|
644
644
|
* Gets cached localized era labels.
|
|
645
645
|
* @param {string} locale The locale.
|
|
646
|
-
* @param {string} [type=long] The formatting type.
|
|
647
|
-
* @
|
|
646
|
+
* @param {string} [type='long'] The formatting type.
|
|
647
|
+
* @returns {string[]} The localized era labels.
|
|
648
648
|
*/
|
|
649
649
|
function getEras(locale, type = 'long') {
|
|
650
650
|
return getData(
|
|
@@ -664,9 +664,9 @@
|
|
|
664
664
|
/**
|
|
665
665
|
* Gets cached localized month labels.
|
|
666
666
|
* @param {string} locale The locale.
|
|
667
|
-
* @param {string} [type=long] The formatting type.
|
|
667
|
+
* @param {string} [type='long'] The formatting type.
|
|
668
668
|
* @param {boolean} [standalone=true] Whether the values are standalone.
|
|
669
|
-
* @
|
|
669
|
+
* @returns {string[]} The localized month labels.
|
|
670
670
|
*/
|
|
671
671
|
function getMonths(locale, type = 'long', standalone = true) {
|
|
672
672
|
return getData(
|
|
@@ -695,7 +695,7 @@
|
|
|
695
695
|
/**
|
|
696
696
|
* Gets cached localized digit glyphs.
|
|
697
697
|
* @param {string} locale The locale.
|
|
698
|
-
* @
|
|
698
|
+
* @returns {string[]} The localized digit glyphs.
|
|
699
699
|
*/
|
|
700
700
|
function getNumbers(locale) {
|
|
701
701
|
return getData(
|
|
@@ -714,7 +714,7 @@
|
|
|
714
714
|
* Gets the RegExp for the number values.
|
|
715
715
|
* @param {string} locale The locale.
|
|
716
716
|
* @param {number|null} [length=null] The exact number of digits to match.
|
|
717
|
-
* @
|
|
717
|
+
* @returns {string} The number values RegExp.
|
|
718
718
|
*/
|
|
719
719
|
function numberRegExp(locale, length = null) {
|
|
720
720
|
const quantifier = length === null ?
|
|
@@ -727,9 +727,9 @@
|
|
|
727
727
|
* Formats a day as a locale string.
|
|
728
728
|
* @param {string} locale The locale.
|
|
729
729
|
* @param {number} day The day to format (0-6).
|
|
730
|
-
* @param {string} [type=long] The formatting type.
|
|
730
|
+
* @param {string} [type='long'] The formatting type.
|
|
731
731
|
* @param {boolean} [standalone=true] Whether the value is standalone.
|
|
732
|
-
* @
|
|
732
|
+
* @returns {string} The formatted string.
|
|
733
733
|
*/
|
|
734
734
|
function formatDay(locale, day, type = 'long', standalone = true) {
|
|
735
735
|
return getDays(locale, type, standalone)[day];
|
|
@@ -738,8 +738,8 @@
|
|
|
738
738
|
* Formats a day period as a locale string.
|
|
739
739
|
* @param {string} locale The locale.
|
|
740
740
|
* @param {number} period The day-period index to format. (0-1)
|
|
741
|
-
* @param {string} [type=long] The formatting type.
|
|
742
|
-
* @
|
|
741
|
+
* @param {string} [type='long'] The formatting type.
|
|
742
|
+
* @returns {string} The formatted string.
|
|
743
743
|
*/
|
|
744
744
|
function formatDayPeriod(locale, period, type = 'long') {
|
|
745
745
|
return getDayPeriods(locale, type)[period];
|
|
@@ -748,8 +748,8 @@
|
|
|
748
748
|
* Formats an era as a locale string.
|
|
749
749
|
* @param {string} locale The locale.
|
|
750
750
|
* @param {number} era The era index to format. (0-1)
|
|
751
|
-
* @param {string} [type=long] The formatting type.
|
|
752
|
-
* @
|
|
751
|
+
* @param {string} [type='long'] The formatting type.
|
|
752
|
+
* @returns {string} The formatted string.
|
|
753
753
|
*/
|
|
754
754
|
function formatEra(locale, era, type = 'long') {
|
|
755
755
|
return getEras(locale, type)[era];
|
|
@@ -758,9 +758,9 @@
|
|
|
758
758
|
* Formats a month as a locale string.
|
|
759
759
|
* @param {string} locale The locale.
|
|
760
760
|
* @param {number} month The month to format (1-12).
|
|
761
|
-
* @param {string} [type=long] The formatting type.
|
|
761
|
+
* @param {string} [type='long'] The formatting type.
|
|
762
762
|
* @param {boolean} [standalone=true] Whether the value is standalone.
|
|
763
|
-
* @
|
|
763
|
+
* @returns {string} The formatted string.
|
|
764
764
|
*/
|
|
765
765
|
function formatMonth(locale, month, type = 'long', standalone = true) {
|
|
766
766
|
return getMonths(locale, type, standalone)[month - 1];
|
|
@@ -770,7 +770,7 @@
|
|
|
770
770
|
* @param {string} locale The locale.
|
|
771
771
|
* @param {number} number The number to format.
|
|
772
772
|
* @param {number} [padding=0] The amount of padding to use.
|
|
773
|
-
* @
|
|
773
|
+
* @returns {string} The formatted string.
|
|
774
774
|
*/
|
|
775
775
|
function formatNumber(locale, number, padding = 0) {
|
|
776
776
|
const numbers = getNumbers(locale);
|
|
@@ -784,7 +784,7 @@
|
|
|
784
784
|
* @param {boolean} [useColon=true] Whether to use a colon separator.
|
|
785
785
|
* @param {boolean} [optionalMinutes=false] Whether minutes are optional.
|
|
786
786
|
* @param {boolean} [includeSeconds=true] Whether seconds are included.
|
|
787
|
-
* @
|
|
787
|
+
* @returns {string} The formatted offset string.
|
|
788
788
|
*/
|
|
789
789
|
function formatOffset(offset, useColon = true, optionalMinutes = false, includeSeconds = true) {
|
|
790
790
|
const absoluteSeconds = Math.abs(offset * 60);
|
|
@@ -818,7 +818,7 @@
|
|
|
818
818
|
* @param {string} locale The locale.
|
|
819
819
|
* @param {number} amount The amount of duration.
|
|
820
820
|
* @param {string} unit The time unit.
|
|
821
|
-
* @
|
|
821
|
+
* @returns {string} The relative duration.
|
|
822
822
|
*/
|
|
823
823
|
function formatRelative(locale, amount, unit) {
|
|
824
824
|
const relativeFormatter = getRelativeFormatter(locale);
|
|
@@ -834,8 +834,8 @@
|
|
|
834
834
|
* @param {string} locale The locale.
|
|
835
835
|
* @param {number} timestamp The timestamp to use.
|
|
836
836
|
* @param {string} timeZone The time zone to format.
|
|
837
|
-
* @param {string} [type=long] The formatting type.
|
|
838
|
-
* @
|
|
837
|
+
* @param {string} [type='long'] The formatting type.
|
|
838
|
+
* @returns {string} The formatted string.
|
|
839
839
|
*/
|
|
840
840
|
function formatTimeZoneName(locale, timestamp, timeZone, type = 'long') {
|
|
841
841
|
return makeFormatter(locale, { second: 'numeric', timeZone, timeZoneName: type })
|
|
@@ -852,7 +852,7 @@
|
|
|
852
852
|
* @param {object} data The generated locale data.
|
|
853
853
|
* @param {string[]} candidates The locale candidates.
|
|
854
854
|
* @param {number} fallback The fallback value.
|
|
855
|
-
* @
|
|
855
|
+
* @returns {number} The locale value.
|
|
856
856
|
*/
|
|
857
857
|
function generatedValue(data, candidates, fallback) {
|
|
858
858
|
for (const candidate of candidates) {
|
|
@@ -869,7 +869,7 @@
|
|
|
869
869
|
/**
|
|
870
870
|
* Gets generated-data candidates for a locale.
|
|
871
871
|
* @param {Intl.Locale} locale The locale.
|
|
872
|
-
* @
|
|
872
|
+
* @returns {string[]} The locale candidates.
|
|
873
873
|
*/
|
|
874
874
|
function localeCandidates(locale) {
|
|
875
875
|
const localeName = locale.toString().split('-x-', 1)[0];
|
|
@@ -894,7 +894,7 @@
|
|
|
894
894
|
/**
|
|
895
895
|
* Gets week information for a locale.
|
|
896
896
|
* @param {string} locale The locale.
|
|
897
|
-
* @
|
|
897
|
+
* @returns {{firstDay: number, minimalDays: number}} The week information.
|
|
898
898
|
*/
|
|
899
899
|
function getWeekInfo(locale) {
|
|
900
900
|
return getData(
|
|
@@ -928,7 +928,7 @@
|
|
|
928
928
|
/**
|
|
929
929
|
* Decodes a quoted ICU format literal.
|
|
930
930
|
* @param {string} literal The literal to decode.
|
|
931
|
-
* @
|
|
931
|
+
* @returns {string} The decoded literal.
|
|
932
932
|
*/
|
|
933
933
|
function decodeLiteral(literal) {
|
|
934
934
|
return literal === `''` ?
|
|
@@ -938,7 +938,7 @@
|
|
|
938
938
|
/**
|
|
939
939
|
* Gets the formatting type from the component token length.
|
|
940
940
|
* @param {number} length The component token length.
|
|
941
|
-
* @
|
|
941
|
+
* @returns {string} The formatting type.
|
|
942
942
|
*/
|
|
943
943
|
function getType(length) {
|
|
944
944
|
switch (length) {
|
|
@@ -957,7 +957,7 @@
|
|
|
957
957
|
* @param {number} length The token length.
|
|
958
958
|
* @param {string} locale The parsing locale.
|
|
959
959
|
* @param {boolean} previousNumeric Whether the previous token was an adjacent numeric token.
|
|
960
|
-
* @
|
|
960
|
+
* @returns {{numeric: boolean, source: string}} The token RegExp data.
|
|
961
961
|
*/
|
|
962
962
|
function getTokenRegExp(source, nextSource, length, locale, previousNumeric) {
|
|
963
963
|
const numberSource = numberRegExp(locale);
|
|
@@ -974,7 +974,7 @@
|
|
|
974
974
|
/**
|
|
975
975
|
* Gets the locale's minimum days in the first week of the year.
|
|
976
976
|
* @param {string} locale The locale.
|
|
977
|
-
* @
|
|
977
|
+
* @returns {number} The minimum day count.
|
|
978
978
|
*/
|
|
979
979
|
function minimumDays(locale) {
|
|
980
980
|
return getWeekInfo(locale).minimalDays;
|
|
@@ -983,7 +983,7 @@
|
|
|
983
983
|
* Converts a Sunday-based day-of-week value to the locale's week numbering.
|
|
984
984
|
* @param {string} locale The locale.
|
|
985
985
|
* @param {number} day The day of the week. (0 = Sunday, 6 = Saturday)
|
|
986
|
-
* @
|
|
986
|
+
* @returns {number} The local day of the week.
|
|
987
987
|
*/
|
|
988
988
|
function weekDay(locale, day) {
|
|
989
989
|
return (7 + parseInt(day, 10) - (getWeekInfo(locale).firstDay % 7)) % 7 + 1;
|
|
@@ -993,9 +993,9 @@
|
|
|
993
993
|
* Parses a day from a locale string.
|
|
994
994
|
* @param {string} locale The locale.
|
|
995
995
|
* @param {string} value The value to parse.
|
|
996
|
-
* @param {string} [type=long] The formatting type.
|
|
996
|
+
* @param {string} [type='long'] The formatting type.
|
|
997
997
|
* @param {boolean} [standalone=true] Whether the value is standalone.
|
|
998
|
-
* @
|
|
998
|
+
* @returns {number} The local day of the week (1-7).
|
|
999
999
|
*/
|
|
1000
1000
|
function parseDay(locale, value, type = 'long', standalone = true) {
|
|
1001
1001
|
const day = getDays(locale, type, standalone).indexOf(value);
|
|
@@ -1008,8 +1008,8 @@
|
|
|
1008
1008
|
* Parses a day period from a locale string.
|
|
1009
1009
|
* @param {string} locale The locale.
|
|
1010
1010
|
* @param {string} value The value to parse.
|
|
1011
|
-
* @param {string} [type=long] The formatting type.
|
|
1012
|
-
* @
|
|
1011
|
+
* @param {string} [type='long'] The formatting type.
|
|
1012
|
+
* @returns {number} The day period (0-1).
|
|
1013
1013
|
*/
|
|
1014
1014
|
function parseDayPeriod(locale, value, type = 'long') {
|
|
1015
1015
|
return getDayPeriods(locale, type).indexOf(value);
|
|
@@ -1018,8 +1018,8 @@
|
|
|
1018
1018
|
* Parses an era from a locale string.
|
|
1019
1019
|
* @param {string} locale The locale.
|
|
1020
1020
|
* @param {string} value The value to parse.
|
|
1021
|
-
* @param {string} [type=long] The formatting type.
|
|
1022
|
-
* @
|
|
1021
|
+
* @param {string} [type='long'] The formatting type.
|
|
1022
|
+
* @returns {number} The era (0-1).
|
|
1023
1023
|
*/
|
|
1024
1024
|
function parseEra(locale, value, type = 'long') {
|
|
1025
1025
|
return getEras(locale, type).indexOf(value);
|
|
@@ -1028,9 +1028,9 @@
|
|
|
1028
1028
|
* Parses a month from a locale string.
|
|
1029
1029
|
* @param {string} locale The locale.
|
|
1030
1030
|
* @param {string} value The value to parse.
|
|
1031
|
-
* @param {string} [type=long] The formatting type.
|
|
1031
|
+
* @param {string} [type='long'] The formatting type.
|
|
1032
1032
|
* @param {boolean} [standalone=true] Whether the value is standalone.
|
|
1033
|
-
* @
|
|
1033
|
+
* @returns {number} The month number (1-12).
|
|
1034
1034
|
*/
|
|
1035
1035
|
function parseMonth(locale, value, type = 'long', standalone = true) {
|
|
1036
1036
|
return getMonths(locale, type, standalone).indexOf(value) + 1;
|
|
@@ -1039,7 +1039,7 @@
|
|
|
1039
1039
|
* Parses locale digits into an ASCII digit string.
|
|
1040
1040
|
* @param {string} locale The locale.
|
|
1041
1041
|
* @param {string} value The value to parse.
|
|
1042
|
-
* @
|
|
1042
|
+
* @returns {string} The parsed ASCII digit string.
|
|
1043
1043
|
*/
|
|
1044
1044
|
function parseNumberString(locale, value) {
|
|
1045
1045
|
const numbers = getNumbers(locale);
|
|
@@ -1049,7 +1049,7 @@
|
|
|
1049
1049
|
* Parses a number from a locale number string.
|
|
1050
1050
|
* @param {string} locale The locale.
|
|
1051
1051
|
* @param {string} value The value to parse.
|
|
1052
|
-
* @
|
|
1052
|
+
* @returns {number} The parsed number.
|
|
1053
1053
|
*/
|
|
1054
1054
|
function parseNumber(locale, value) {
|
|
1055
1055
|
return parseInt(
|
|
@@ -1723,7 +1723,7 @@
|
|
|
1723
1723
|
* @param {number} year The year.
|
|
1724
1724
|
* @param {number} month The month. (1-12)
|
|
1725
1725
|
* @param {number} date The date.
|
|
1726
|
-
* @
|
|
1726
|
+
* @returns {number} The day of the year. (1-366)
|
|
1727
1727
|
*/
|
|
1728
1728
|
static dayOfYear(year, month, date) {
|
|
1729
1729
|
return new Array(month - 1)
|
|
@@ -1739,7 +1739,7 @@
|
|
|
1739
1739
|
* Gets the number of days in a month for a given year.
|
|
1740
1740
|
* @param {number} year The year.
|
|
1741
1741
|
* @param {number} month The month. (1-12)
|
|
1742
|
-
* @
|
|
1742
|
+
* @returns {number} The number of days in the month.
|
|
1743
1743
|
*/
|
|
1744
1744
|
static daysInMonth(year, month) {
|
|
1745
1745
|
const date = new Date(0);
|
|
@@ -1759,7 +1759,7 @@
|
|
|
1759
1759
|
/**
|
|
1760
1760
|
* Gets the number of days in a given year.
|
|
1761
1761
|
* @param {number} year The year.
|
|
1762
|
-
* @
|
|
1762
|
+
* @returns {number} The number of days in the year.
|
|
1763
1763
|
*/
|
|
1764
1764
|
static daysInYear(year) {
|
|
1765
1765
|
return !this.isLeapYear(year) ?
|
|
@@ -1774,7 +1774,7 @@
|
|
|
1774
1774
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
1775
1775
|
* @param {string} [options.timeZone] The time zone to use.
|
|
1776
1776
|
* @param {string} [options.locale] The locale to use.
|
|
1777
|
-
* @
|
|
1777
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1778
1778
|
*/
|
|
1779
1779
|
static fromArray(dateArray, options = {}) {
|
|
1780
1780
|
const dateValues = dateArray.slice(0, 3);
|
|
@@ -1800,7 +1800,7 @@
|
|
|
1800
1800
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
1801
1801
|
* @param {string} [options.timeZone] The time zone to use.
|
|
1802
1802
|
* @param {string} [options.locale] The locale to use.
|
|
1803
|
-
* @
|
|
1803
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1804
1804
|
*/
|
|
1805
1805
|
static fromDate(date, options = {}) {
|
|
1806
1806
|
return new this(date.getTime(), options);
|
|
@@ -1813,9 +1813,9 @@
|
|
|
1813
1813
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
1814
1814
|
* @param {string} [options.timeZone] The time zone to use.
|
|
1815
1815
|
* @param {string} [options.locale] The locale to use.
|
|
1816
|
-
* @
|
|
1816
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1817
|
+
* @throws {Error} When the format contains unsupported parsing tokens such as
|
|
1817
1818
|
* `MMMMM` or `LLLLL`.
|
|
1818
|
-
* @return {DateTime} A new DateTime instance.
|
|
1819
1819
|
*/
|
|
1820
1820
|
static fromFormat(formatString, dateString, options = {}) {
|
|
1821
1821
|
const locale = 'locale' in options ?
|
|
@@ -1963,7 +1963,7 @@
|
|
|
1963
1963
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
1964
1964
|
* @param {string} [options.timeZone] The time zone to use.
|
|
1965
1965
|
* @param {string} [options.locale] The locale to use.
|
|
1966
|
-
* @
|
|
1966
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1967
1967
|
*/
|
|
1968
1968
|
static fromISOString(dateString, options = {}) {
|
|
1969
1969
|
let date = this.fromFormat(formats.rfc3339_extended, dateString, {
|
|
@@ -1987,7 +1987,7 @@
|
|
|
1987
1987
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
1988
1988
|
* @param {string} [options.timeZone] The time zone to use.
|
|
1989
1989
|
* @param {string} [options.locale] The locale to use.
|
|
1990
|
-
* @
|
|
1990
|
+
* @returns {DateTime} A new DateTime instance.
|
|
1991
1991
|
*/
|
|
1992
1992
|
static fromTimestamp(timestamp, options = {}) {
|
|
1993
1993
|
return new this(null, options)
|
|
@@ -1996,7 +1996,7 @@
|
|
|
1996
1996
|
|
|
1997
1997
|
/**
|
|
1998
1998
|
* Gets the default locale.
|
|
1999
|
-
* @
|
|
1999
|
+
* @returns {string} The locale.
|
|
2000
2000
|
*/
|
|
2001
2001
|
static getDefaultLocale() {
|
|
2002
2002
|
return config.defaultLocale;
|
|
@@ -2004,7 +2004,7 @@
|
|
|
2004
2004
|
|
|
2005
2005
|
/**
|
|
2006
2006
|
* Gets the default time zone.
|
|
2007
|
-
* @
|
|
2007
|
+
* @returns {string} The default time zone.
|
|
2008
2008
|
*/
|
|
2009
2009
|
static getDefaultTimeZone() {
|
|
2010
2010
|
return config.defaultTimeZone;
|
|
@@ -2013,7 +2013,7 @@
|
|
|
2013
2013
|
/**
|
|
2014
2014
|
* Checks whether the year is a leap year.
|
|
2015
2015
|
* @param {number} year The year.
|
|
2016
|
-
* @
|
|
2016
|
+
* @returns {boolean} Whether the given year is a leap year.
|
|
2017
2017
|
*/
|
|
2018
2018
|
static isLeapYear(year) {
|
|
2019
2019
|
const date = new Date(0);
|
|
@@ -2027,7 +2027,7 @@
|
|
|
2027
2027
|
* @param {DateTimeOptions} [options={}] Options for the new DateTime.
|
|
2028
2028
|
* @param {string} [options.timeZone] The time zone to use.
|
|
2029
2029
|
* @param {string} [options.locale] The locale to use.
|
|
2030
|
-
* @
|
|
2030
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2031
2031
|
*/
|
|
2032
2032
|
static now(options = {}) {
|
|
2033
2033
|
return new this(null, options);
|
|
@@ -2146,7 +2146,7 @@
|
|
|
2146
2146
|
|
|
2147
2147
|
/**
|
|
2148
2148
|
* Adds a day to the current DateTime.
|
|
2149
|
-
* @
|
|
2149
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2150
2150
|
*/
|
|
2151
2151
|
addDay() {
|
|
2152
2152
|
return this.addDays(1);
|
|
@@ -2155,7 +2155,7 @@
|
|
|
2155
2155
|
/**
|
|
2156
2156
|
* Adds days to the current DateTime.
|
|
2157
2157
|
* @param {number} amount The number of days to add.
|
|
2158
|
-
* @
|
|
2158
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2159
2159
|
*/
|
|
2160
2160
|
addDays(amount) {
|
|
2161
2161
|
return setOffsetTime(
|
|
@@ -2169,7 +2169,7 @@
|
|
|
2169
2169
|
|
|
2170
2170
|
/**
|
|
2171
2171
|
* Adds an hour to the current DateTime.
|
|
2172
|
-
* @
|
|
2172
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2173
2173
|
*/
|
|
2174
2174
|
addHour() {
|
|
2175
2175
|
return this.addHours(1);
|
|
@@ -2178,7 +2178,7 @@
|
|
|
2178
2178
|
/**
|
|
2179
2179
|
* Adds hours to the current DateTime.
|
|
2180
2180
|
* @param {number} amount The number of hours to add.
|
|
2181
|
-
* @
|
|
2181
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2182
2182
|
*/
|
|
2183
2183
|
addHours(amount) {
|
|
2184
2184
|
return this.withTime(
|
|
@@ -2188,7 +2188,7 @@
|
|
|
2188
2188
|
|
|
2189
2189
|
/**
|
|
2190
2190
|
* Adds a minute to the current DateTime.
|
|
2191
|
-
* @
|
|
2191
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2192
2192
|
*/
|
|
2193
2193
|
addMinute() {
|
|
2194
2194
|
return this.addMinutes(1);
|
|
@@ -2197,7 +2197,7 @@
|
|
|
2197
2197
|
/**
|
|
2198
2198
|
* Adds minutes to the current DateTime.
|
|
2199
2199
|
* @param {number} amount The number of minutes to add.
|
|
2200
|
-
* @
|
|
2200
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2201
2201
|
*/
|
|
2202
2202
|
addMinutes(amount) {
|
|
2203
2203
|
return this.withTime(
|
|
@@ -2207,7 +2207,7 @@
|
|
|
2207
2207
|
|
|
2208
2208
|
/**
|
|
2209
2209
|
* Adds a month to the current DateTime.
|
|
2210
|
-
* @
|
|
2210
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2211
2211
|
*/
|
|
2212
2212
|
addMonth() {
|
|
2213
2213
|
return this.addMonths(1);
|
|
@@ -2216,7 +2216,7 @@
|
|
|
2216
2216
|
/**
|
|
2217
2217
|
* Adds months to the current DateTime.
|
|
2218
2218
|
* @param {number} amount The number of months to add.
|
|
2219
|
-
* @
|
|
2219
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2220
2220
|
*/
|
|
2221
2221
|
addMonths(amount) {
|
|
2222
2222
|
return this.withMonth(
|
|
@@ -2226,7 +2226,7 @@
|
|
|
2226
2226
|
|
|
2227
2227
|
/**
|
|
2228
2228
|
* Adds a second to the current DateTime.
|
|
2229
|
-
* @
|
|
2229
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2230
2230
|
*/
|
|
2231
2231
|
addSecond() {
|
|
2232
2232
|
return this.addSeconds(1);
|
|
@@ -2235,7 +2235,7 @@
|
|
|
2235
2235
|
/**
|
|
2236
2236
|
* Adds seconds to the current DateTime.
|
|
2237
2237
|
* @param {number} amount The number of seconds to add.
|
|
2238
|
-
* @
|
|
2238
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2239
2239
|
*/
|
|
2240
2240
|
addSeconds(amount) {
|
|
2241
2241
|
return this.withTime(
|
|
@@ -2245,7 +2245,7 @@
|
|
|
2245
2245
|
|
|
2246
2246
|
/**
|
|
2247
2247
|
* Adds a week to the current DateTime.
|
|
2248
|
-
* @
|
|
2248
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2249
2249
|
*/
|
|
2250
2250
|
addWeek() {
|
|
2251
2251
|
return this.addWeeks(1);
|
|
@@ -2254,7 +2254,7 @@
|
|
|
2254
2254
|
/**
|
|
2255
2255
|
* Adds weeks to the current DateTime.
|
|
2256
2256
|
* @param {number} amount The number of weeks to add.
|
|
2257
|
-
* @
|
|
2257
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2258
2258
|
*/
|
|
2259
2259
|
addWeeks(amount) {
|
|
2260
2260
|
return this.withDate(
|
|
@@ -2264,7 +2264,7 @@
|
|
|
2264
2264
|
|
|
2265
2265
|
/**
|
|
2266
2266
|
* Adds a year to the current DateTime.
|
|
2267
|
-
* @
|
|
2267
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2268
2268
|
*/
|
|
2269
2269
|
addYear() {
|
|
2270
2270
|
return this.addYears(1);
|
|
@@ -2273,7 +2273,7 @@
|
|
|
2273
2273
|
/**
|
|
2274
2274
|
* Adds years to the current DateTime.
|
|
2275
2275
|
* @param {number} amount The number of years to add.
|
|
2276
|
-
* @
|
|
2276
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2277
2277
|
*/
|
|
2278
2278
|
addYears(amount) {
|
|
2279
2279
|
return this.withYear(
|
|
@@ -2284,7 +2284,7 @@
|
|
|
2284
2284
|
/**
|
|
2285
2285
|
* Gets the localized day name for the current date.
|
|
2286
2286
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of day name to return.
|
|
2287
|
-
* @
|
|
2287
|
+
* @returns {string} The localized day name.
|
|
2288
2288
|
*/
|
|
2289
2289
|
dayName(type = 'long') {
|
|
2290
2290
|
return formatDay(this.getLocale(), this.getDay(), type);
|
|
@@ -2293,7 +2293,7 @@
|
|
|
2293
2293
|
/**
|
|
2294
2294
|
* Gets the localized day period for the current time.
|
|
2295
2295
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of day period to return.
|
|
2296
|
-
* @
|
|
2296
|
+
* @returns {string} The localized day period.
|
|
2297
2297
|
*/
|
|
2298
2298
|
dayPeriod(type = 'long') {
|
|
2299
2299
|
return formatDayPeriod(
|
|
@@ -2307,7 +2307,7 @@
|
|
|
2307
2307
|
|
|
2308
2308
|
/**
|
|
2309
2309
|
* Gets the number of days in the current month.
|
|
2310
|
-
* @
|
|
2310
|
+
* @returns {number} The number of days in the current month.
|
|
2311
2311
|
*/
|
|
2312
2312
|
daysInMonth() {
|
|
2313
2313
|
return this.constructor.daysInMonth(
|
|
@@ -2318,7 +2318,7 @@
|
|
|
2318
2318
|
|
|
2319
2319
|
/**
|
|
2320
2320
|
* Gets the number of days in the current year.
|
|
2321
|
-
* @
|
|
2321
|
+
* @returns {number} The number of days in the current year.
|
|
2322
2322
|
*/
|
|
2323
2323
|
daysInYear() {
|
|
2324
2324
|
return this.constructor.daysInYear(
|
|
@@ -2329,7 +2329,7 @@
|
|
|
2329
2329
|
/**
|
|
2330
2330
|
* Gets the difference between this and another Date in milliseconds.
|
|
2331
2331
|
* @param {DateTime} other The date to compare to.
|
|
2332
|
-
* @
|
|
2332
|
+
* @returns {number} The difference.
|
|
2333
2333
|
*/
|
|
2334
2334
|
diff(other) {
|
|
2335
2335
|
return this - other;
|
|
@@ -2339,7 +2339,7 @@
|
|
|
2339
2339
|
* Gets the difference between this and another Date in days.
|
|
2340
2340
|
* @param {DateTime} other The date to compare to.
|
|
2341
2341
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
2342
|
-
* @
|
|
2342
|
+
* @returns {number} The difference.
|
|
2343
2343
|
*/
|
|
2344
2344
|
diffInDays(other, { relative = true } = {}) {
|
|
2345
2345
|
return calculateDiff(this, other, 'day', relative);
|
|
@@ -2349,7 +2349,7 @@
|
|
|
2349
2349
|
* Gets the difference between this and another Date in hours.
|
|
2350
2350
|
* @param {DateTime} other The date to compare to.
|
|
2351
2351
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
2352
|
-
* @
|
|
2352
|
+
* @returns {number} The difference.
|
|
2353
2353
|
*/
|
|
2354
2354
|
diffInHours(other, { relative = true } = {}) {
|
|
2355
2355
|
return calculateDiff(this, other, 'hour', relative);
|
|
@@ -2359,7 +2359,7 @@
|
|
|
2359
2359
|
* Gets the difference between this and another Date in minutes.
|
|
2360
2360
|
* @param {DateTime} other The date to compare to.
|
|
2361
2361
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
2362
|
-
* @
|
|
2362
|
+
* @returns {number} The difference.
|
|
2363
2363
|
*/
|
|
2364
2364
|
diffInMinutes(other, { relative = true } = {}) {
|
|
2365
2365
|
return calculateDiff(this, other, 'minute', relative);
|
|
@@ -2369,7 +2369,7 @@
|
|
|
2369
2369
|
* Gets the difference between this and another Date in months.
|
|
2370
2370
|
* @param {DateTime} other The date to compare to.
|
|
2371
2371
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
2372
|
-
* @
|
|
2372
|
+
* @returns {number} The difference.
|
|
2373
2373
|
*/
|
|
2374
2374
|
diffInMonths(other, { relative = true } = {}) {
|
|
2375
2375
|
return calculateDiff(this, other, 'month', relative);
|
|
@@ -2379,7 +2379,7 @@
|
|
|
2379
2379
|
* Gets the difference between this and another Date in seconds.
|
|
2380
2380
|
* @param {DateTime} other The date to compare to.
|
|
2381
2381
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
2382
|
-
* @
|
|
2382
|
+
* @returns {number} The difference.
|
|
2383
2383
|
*/
|
|
2384
2384
|
diffInSeconds(other, { relative = true } = {}) {
|
|
2385
2385
|
return calculateDiff(this, other, 'second', relative);
|
|
@@ -2389,7 +2389,7 @@
|
|
|
2389
2389
|
* Gets the difference between this and another Date in weeks.
|
|
2390
2390
|
* @param {DateTime} other The date to compare to.
|
|
2391
2391
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
2392
|
-
* @
|
|
2392
|
+
* @returns {number} The difference.
|
|
2393
2393
|
*/
|
|
2394
2394
|
diffInWeeks(other, { relative = true } = {}) {
|
|
2395
2395
|
return calculateDiff(this, other, 'week', relative);
|
|
@@ -2399,7 +2399,7 @@
|
|
|
2399
2399
|
* Gets the difference between this and another Date in years.
|
|
2400
2400
|
* @param {DateTime} other The date to compare to.
|
|
2401
2401
|
* @param {{relative?: boolean}} [options] Options for comparing the dates.
|
|
2402
|
-
* @
|
|
2402
|
+
* @returns {number} The difference.
|
|
2403
2403
|
*/
|
|
2404
2404
|
diffInYears(other, { relative = true } = {}) {
|
|
2405
2405
|
return calculateDiff(this, other, 'year', relative);
|
|
@@ -2407,7 +2407,7 @@
|
|
|
2407
2407
|
|
|
2408
2408
|
/**
|
|
2409
2409
|
* Sets the DateTime to the end of the day.
|
|
2410
|
-
* @
|
|
2410
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2411
2411
|
*/
|
|
2412
2412
|
endOfDay() {
|
|
2413
2413
|
return this.withHours(23, 59, 59, 999);
|
|
@@ -2415,7 +2415,7 @@
|
|
|
2415
2415
|
|
|
2416
2416
|
/**
|
|
2417
2417
|
* Sets the DateTime to the end of the hour.
|
|
2418
|
-
* @
|
|
2418
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2419
2419
|
*/
|
|
2420
2420
|
endOfHour() {
|
|
2421
2421
|
return this.withMinutes(59, 59, 999);
|
|
@@ -2423,7 +2423,7 @@
|
|
|
2423
2423
|
|
|
2424
2424
|
/**
|
|
2425
2425
|
* Sets the DateTime to the end of the minute.
|
|
2426
|
-
* @
|
|
2426
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2427
2427
|
*/
|
|
2428
2428
|
endOfMinute() {
|
|
2429
2429
|
return this.withSeconds(59, 999);
|
|
@@ -2431,7 +2431,7 @@
|
|
|
2431
2431
|
|
|
2432
2432
|
/**
|
|
2433
2433
|
* Sets the DateTime to the end of the month.
|
|
2434
|
-
* @
|
|
2434
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2435
2435
|
*/
|
|
2436
2436
|
endOfMonth() {
|
|
2437
2437
|
return this.withDate(this.daysInMonth())
|
|
@@ -2440,7 +2440,7 @@
|
|
|
2440
2440
|
|
|
2441
2441
|
/**
|
|
2442
2442
|
* Sets the DateTime to the end of the quarter.
|
|
2443
|
-
* @
|
|
2443
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2444
2444
|
*/
|
|
2445
2445
|
endOfQuarter() {
|
|
2446
2446
|
const month = this.getQuarter() * 3;
|
|
@@ -2450,7 +2450,7 @@
|
|
|
2450
2450
|
|
|
2451
2451
|
/**
|
|
2452
2452
|
* Sets the DateTime to the end of the second.
|
|
2453
|
-
* @
|
|
2453
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2454
2454
|
*/
|
|
2455
2455
|
endOfSecond() {
|
|
2456
2456
|
return this.withMilliseconds(999);
|
|
@@ -2458,7 +2458,7 @@
|
|
|
2458
2458
|
|
|
2459
2459
|
/**
|
|
2460
2460
|
* Sets the DateTime to the end of the week.
|
|
2461
|
-
* @
|
|
2461
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2462
2462
|
*/
|
|
2463
2463
|
endOfWeek() {
|
|
2464
2464
|
return this.withWeekDay(7)
|
|
@@ -2467,7 +2467,7 @@
|
|
|
2467
2467
|
|
|
2468
2468
|
/**
|
|
2469
2469
|
* Sets the DateTime to the end of the year.
|
|
2470
|
-
* @
|
|
2470
|
+
* @returns {DateTime} A new DateTime instance.
|
|
2471
2471
|
*/
|
|
2472
2472
|
endOfYear() {
|
|
2473
2473
|
return this.withMonth(12, 31)
|
|
@@ -2477,7 +2477,7 @@
|
|
|
2477
2477
|
/**
|
|
2478
2478
|
* Gets the localized era for the current date.
|
|
2479
2479
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of era to return.
|
|
2480
|
-
* @
|
|
2480
|
+
* @returns {string} The localized era.
|
|
2481
2481
|
*/
|
|
2482
2482
|
era(type = 'long') {
|
|
2483
2483
|
return formatEra(
|
|
@@ -2492,7 +2492,7 @@
|
|
|
2492
2492
|
/**
|
|
2493
2493
|
* Formats the current date using a format string.
|
|
2494
2494
|
* @param {string} formatString The format string.
|
|
2495
|
-
* @
|
|
2495
|
+
* @returns {string} The formatted date string.
|
|
2496
2496
|
*/
|
|
2497
2497
|
format(formatString) {
|
|
2498
2498
|
let match;
|
|
@@ -2532,7 +2532,7 @@
|
|
|
2532
2532
|
|
|
2533
2533
|
/**
|
|
2534
2534
|
* Gets the date of the month in the current time zone.
|
|
2535
|
-
* @
|
|
2535
|
+
* @returns {number} The date of the month.
|
|
2536
2536
|
*/
|
|
2537
2537
|
getDate() {
|
|
2538
2538
|
return new Date(getOffsetTime(this)).getUTCDate();
|
|
@@ -2540,7 +2540,7 @@
|
|
|
2540
2540
|
|
|
2541
2541
|
/**
|
|
2542
2542
|
* Gets the day of the week in the current time zone.
|
|
2543
|
-
* @
|
|
2543
|
+
* @returns {number} The day of the week. (0 = Sunday, 6 = Saturday)
|
|
2544
2544
|
*/
|
|
2545
2545
|
getDay() {
|
|
2546
2546
|
return new Date(getOffsetTime(this)).getUTCDay();
|
|
@@ -2548,7 +2548,7 @@
|
|
|
2548
2548
|
|
|
2549
2549
|
/**
|
|
2550
2550
|
* Gets the day of the year in the current time zone.
|
|
2551
|
-
* @
|
|
2551
|
+
* @returns {number} The day of the year. (1-366)
|
|
2552
2552
|
*/
|
|
2553
2553
|
getDayOfYear() {
|
|
2554
2554
|
return this.constructor.dayOfYear(
|
|
@@ -2560,7 +2560,7 @@
|
|
|
2560
2560
|
|
|
2561
2561
|
/**
|
|
2562
2562
|
* Gets the hours of the day in the current time zone.
|
|
2563
|
-
* @
|
|
2563
|
+
* @returns {number} The hours of the day. (0-23)
|
|
2564
2564
|
*/
|
|
2565
2565
|
getHours() {
|
|
2566
2566
|
return new Date(getOffsetTime(this)).getUTCHours();
|
|
@@ -2568,7 +2568,7 @@
|
|
|
2568
2568
|
|
|
2569
2569
|
/**
|
|
2570
2570
|
* Gets the current locale.
|
|
2571
|
-
* @
|
|
2571
|
+
* @returns {string} The locale.
|
|
2572
2572
|
*/
|
|
2573
2573
|
getLocale() {
|
|
2574
2574
|
return this._locale;
|
|
@@ -2576,7 +2576,7 @@
|
|
|
2576
2576
|
|
|
2577
2577
|
/**
|
|
2578
2578
|
* Gets the milliseconds in the current time zone.
|
|
2579
|
-
* @
|
|
2579
|
+
* @returns {number} The milliseconds.
|
|
2580
2580
|
*/
|
|
2581
2581
|
getMilliseconds() {
|
|
2582
2582
|
return new Date(getOffsetTime(this)).getUTCMilliseconds();
|
|
@@ -2584,7 +2584,7 @@
|
|
|
2584
2584
|
|
|
2585
2585
|
/**
|
|
2586
2586
|
* Gets the minutes in the current time zone.
|
|
2587
|
-
* @
|
|
2587
|
+
* @returns {number} The minutes. (0-59)
|
|
2588
2588
|
*/
|
|
2589
2589
|
getMinutes() {
|
|
2590
2590
|
return new Date(getOffsetTime(this)).getUTCMinutes();
|
|
@@ -2592,7 +2592,7 @@
|
|
|
2592
2592
|
|
|
2593
2593
|
/**
|
|
2594
2594
|
* Gets the month in the current time zone.
|
|
2595
|
-
* @
|
|
2595
|
+
* @returns {number} The month. (1-12)
|
|
2596
2596
|
*/
|
|
2597
2597
|
getMonth() {
|
|
2598
2598
|
return new Date(getOffsetTime(this)).getUTCMonth() + 1;
|
|
@@ -2600,7 +2600,7 @@
|
|
|
2600
2600
|
|
|
2601
2601
|
/**
|
|
2602
2602
|
* Gets the quarter of the year in the current time zone.
|
|
2603
|
-
* @
|
|
2603
|
+
* @returns {number} The quarter of the year. (1-4)
|
|
2604
2604
|
*/
|
|
2605
2605
|
getQuarter() {
|
|
2606
2606
|
return Math.ceil(this.getMonth() / 3);
|
|
@@ -2608,7 +2608,7 @@
|
|
|
2608
2608
|
|
|
2609
2609
|
/**
|
|
2610
2610
|
* Gets the seconds in the current time zone.
|
|
2611
|
-
* @
|
|
2611
|
+
* @returns {number} The seconds. (0-59)
|
|
2612
2612
|
*/
|
|
2613
2613
|
getSeconds() {
|
|
2614
2614
|
return new Date(getOffsetTime(this)).getUTCSeconds();
|
|
@@ -2616,7 +2616,7 @@
|
|
|
2616
2616
|
|
|
2617
2617
|
/**
|
|
2618
2618
|
* Gets the number of milliseconds since the UNIX epoch.
|
|
2619
|
-
* @
|
|
2619
|
+
* @returns {number} The number of milliseconds since the UNIX epoch.
|
|
2620
2620
|
*/
|
|
2621
2621
|
getTime() {
|
|
2622
2622
|
return this._date.getTime();
|
|
@@ -2624,7 +2624,7 @@
|
|
|
2624
2624
|
|
|
2625
2625
|
/**
|
|
2626
2626
|
* Gets the number of seconds since the UNIX epoch.
|
|
2627
|
-
* @
|
|
2627
|
+
* @returns {number} The number of seconds since the UNIX epoch.
|
|
2628
2628
|
*/
|
|
2629
2629
|
getTimestamp() {
|
|
2630
2630
|
return Math.floor(this.getTime() / 1000);
|
|
@@ -2632,7 +2632,7 @@
|
|
|
2632
2632
|
|
|
2633
2633
|
/**
|
|
2634
2634
|
* Gets the current time zone.
|
|
2635
|
-
* @
|
|
2635
|
+
* @returns {string} The time zone.
|
|
2636
2636
|
*/
|
|
2637
2637
|
getTimeZone() {
|
|
2638
2638
|
return this._timeZone;
|
|
@@ -2640,7 +2640,7 @@
|
|
|
2640
2640
|
|
|
2641
2641
|
/**
|
|
2642
2642
|
* Gets the current UTC offset in minutes.
|
|
2643
|
-
* @
|
|
2643
|
+
* @returns {number} The UTC offset in minutes.
|
|
2644
2644
|
*/
|
|
2645
2645
|
getTimeZoneOffset() {
|
|
2646
2646
|
return this._offset;
|
|
@@ -2648,7 +2648,7 @@
|
|
|
2648
2648
|
|
|
2649
2649
|
/**
|
|
2650
2650
|
* Gets the local week in the current time zone.
|
|
2651
|
-
* @
|
|
2651
|
+
* @returns {number} The local week. (1-53)
|
|
2652
2652
|
*/
|
|
2653
2653
|
getWeek() {
|
|
2654
2654
|
const thisWeek = this.startOfDay().withWeekDay(1);
|
|
@@ -2662,7 +2662,7 @@
|
|
|
2662
2662
|
|
|
2663
2663
|
/**
|
|
2664
2664
|
* Gets the local day of the week in the current time zone.
|
|
2665
|
-
* @
|
|
2665
|
+
* @returns {number} The local day of the week. (1-7)
|
|
2666
2666
|
*/
|
|
2667
2667
|
getWeekDay() {
|
|
2668
2668
|
return weekDay(
|
|
@@ -2673,7 +2673,7 @@
|
|
|
2673
2673
|
|
|
2674
2674
|
/**
|
|
2675
2675
|
* Gets the week day in month in the current time zone.
|
|
2676
|
-
* @
|
|
2676
|
+
* @returns {number} The week day in month.
|
|
2677
2677
|
*/
|
|
2678
2678
|
getWeekDayInMonth() {
|
|
2679
2679
|
const thisWeek = this.getWeek();
|
|
@@ -2688,7 +2688,7 @@
|
|
|
2688
2688
|
|
|
2689
2689
|
/**
|
|
2690
2690
|
* Gets the week of month in the current time zone.
|
|
2691
|
-
* @
|
|
2691
|
+
* @returns {number} The week of month.
|
|
2692
2692
|
*/
|
|
2693
2693
|
getWeekOfMonth() {
|
|
2694
2694
|
const thisWeek = this.getWeek();
|
|
@@ -2700,7 +2700,7 @@
|
|
|
2700
2700
|
|
|
2701
2701
|
/**
|
|
2702
2702
|
* Gets the week year in the current time zone.
|
|
2703
|
-
* @
|
|
2703
|
+
* @returns {number} The week year.
|
|
2704
2704
|
*/
|
|
2705
2705
|
getWeekYear() {
|
|
2706
2706
|
const minDays = minimumDays(this.getLocale());
|
|
@@ -2709,7 +2709,7 @@
|
|
|
2709
2709
|
|
|
2710
2710
|
/**
|
|
2711
2711
|
* Gets the year in the current time zone.
|
|
2712
|
-
* @
|
|
2712
|
+
* @returns {number} The year.
|
|
2713
2713
|
*/
|
|
2714
2714
|
getYear() {
|
|
2715
2715
|
return new Date(getOffsetTime(this)).getUTCFullYear();
|
|
@@ -2718,7 +2718,7 @@
|
|
|
2718
2718
|
/**
|
|
2719
2719
|
* Gets the difference between this and another Date in human readable form.
|
|
2720
2720
|
* @param {DateTime} other The date to compare to.
|
|
2721
|
-
* @
|
|
2721
|
+
* @returns {string} The difference in human readable form.
|
|
2722
2722
|
*/
|
|
2723
2723
|
humanDiff(other) {
|
|
2724
2724
|
const [amount, unit] = getBiggestDiff(this, other);
|
|
@@ -2728,7 +2728,7 @@
|
|
|
2728
2728
|
/**
|
|
2729
2729
|
* Gets the difference between this and another Date in days in human readable form.
|
|
2730
2730
|
* @param {DateTime} other The date to compare to.
|
|
2731
|
-
* @
|
|
2731
|
+
* @returns {string} The difference in days in human readable form.
|
|
2732
2732
|
*/
|
|
2733
2733
|
humanDiffInDays(other) {
|
|
2734
2734
|
return formatRelative(this.getLocale(), this.diffInDays(other), 'day');
|
|
@@ -2737,7 +2737,7 @@
|
|
|
2737
2737
|
/**
|
|
2738
2738
|
* Gets the difference between this and another Date in hours in human readable form.
|
|
2739
2739
|
* @param {DateTime} other The date to compare to.
|
|
2740
|
-
* @
|
|
2740
|
+
* @returns {string} The difference in hours in human readable form.
|
|
2741
2741
|
*/
|
|
2742
2742
|
humanDiffInHours(other) {
|
|
2743
2743
|
return formatRelative(this.getLocale(), this.diffInHours(other), 'hour');
|
|
@@ -2746,7 +2746,7 @@
|
|
|
2746
2746
|
/**
|
|
2747
2747
|
* Gets the difference between this and another Date in minutes in human readable form.
|
|
2748
2748
|
* @param {DateTime} other The date to compare to.
|
|
2749
|
-
* @
|
|
2749
|
+
* @returns {string} The difference in minutes in human readable form.
|
|
2750
2750
|
*/
|
|
2751
2751
|
humanDiffInMinutes(other) {
|
|
2752
2752
|
return formatRelative(this.getLocale(), this.diffInMinutes(other), 'minute');
|
|
@@ -2755,7 +2755,7 @@
|
|
|
2755
2755
|
/**
|
|
2756
2756
|
* Gets the difference between this and another Date in months in human readable form.
|
|
2757
2757
|
* @param {DateTime} other The date to compare to.
|
|
2758
|
-
* @
|
|
2758
|
+
* @returns {string} The difference in months in human readable form.
|
|
2759
2759
|
*/
|
|
2760
2760
|
humanDiffInMonths(other) {
|
|
2761
2761
|
return formatRelative(this.getLocale(), this.diffInMonths(other), 'month');
|
|
@@ -2764,7 +2764,7 @@
|
|
|
2764
2764
|
/**
|
|
2765
2765
|
* Gets the difference between this and another Date in seconds in human readable form.
|
|
2766
2766
|
* @param {DateTime} other The date to compare to.
|
|
2767
|
-
* @
|
|
2767
|
+
* @returns {string} The difference in seconds in human readable form.
|
|
2768
2768
|
*/
|
|
2769
2769
|
humanDiffInSeconds(other) {
|
|
2770
2770
|
return formatRelative(this.getLocale(), this.diffInSeconds(other), 'second');
|
|
@@ -2773,7 +2773,7 @@
|
|
|
2773
2773
|
/**
|
|
2774
2774
|
* Gets the difference between this and another Date in weeks in human readable form.
|
|
2775
2775
|
* @param {DateTime} other The date to compare to.
|
|
2776
|
-
* @
|
|
2776
|
+
* @returns {string} The difference in weeks in human readable form.
|
|
2777
2777
|
*/
|
|
2778
2778
|
humanDiffInWeeks(other) {
|
|
2779
2779
|
return formatRelative(this.getLocale(), this.diffInWeeks(other), 'week');
|
|
@@ -2782,7 +2782,7 @@
|
|
|
2782
2782
|
/**
|
|
2783
2783
|
* Gets the difference between this and another Date in years in human readable form.
|
|
2784
2784
|
* @param {DateTime} other The date to compare to.
|
|
2785
|
-
* @
|
|
2785
|
+
* @returns {string} The difference in years in human readable form.
|
|
2786
2786
|
*/
|
|
2787
2787
|
humanDiffInYears(other) {
|
|
2788
2788
|
return formatRelative(this.getLocale(), this.diffInYears(other), 'year');
|
|
@@ -2791,7 +2791,7 @@
|
|
|
2791
2791
|
/**
|
|
2792
2792
|
* Checks whether this DateTime is after another date.
|
|
2793
2793
|
* @param {DateTime} other The date to compare to.
|
|
2794
|
-
* @
|
|
2794
|
+
* @returns {boolean} Whether this DateTime is after the other date.
|
|
2795
2795
|
*/
|
|
2796
2796
|
isAfter(other) {
|
|
2797
2797
|
return this.diff(other) > 0;
|
|
@@ -2800,7 +2800,7 @@
|
|
|
2800
2800
|
/**
|
|
2801
2801
|
* Checks whether this DateTime is after another date (comparing by day).
|
|
2802
2802
|
* @param {DateTime} other The date to compare to.
|
|
2803
|
-
* @
|
|
2803
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by day).
|
|
2804
2804
|
*/
|
|
2805
2805
|
isAfterDay(other) {
|
|
2806
2806
|
return this.diffInDays(other) > 0;
|
|
@@ -2809,7 +2809,7 @@
|
|
|
2809
2809
|
/**
|
|
2810
2810
|
* Checks whether this DateTime is after another date (comparing by hour).
|
|
2811
2811
|
* @param {DateTime} other The date to compare to.
|
|
2812
|
-
* @
|
|
2812
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by hour).
|
|
2813
2813
|
*/
|
|
2814
2814
|
isAfterHour(other) {
|
|
2815
2815
|
return this.diffInHours(other) > 0;
|
|
@@ -2818,7 +2818,7 @@
|
|
|
2818
2818
|
/**
|
|
2819
2819
|
* Checks whether this DateTime is after another date (comparing by minute).
|
|
2820
2820
|
* @param {DateTime} other The date to compare to.
|
|
2821
|
-
* @
|
|
2821
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by minute).
|
|
2822
2822
|
*/
|
|
2823
2823
|
isAfterMinute(other) {
|
|
2824
2824
|
return this.diffInMinutes(other) > 0;
|
|
@@ -2827,7 +2827,7 @@
|
|
|
2827
2827
|
/**
|
|
2828
2828
|
* Checks whether this DateTime is after another date (comparing by month).
|
|
2829
2829
|
* @param {DateTime} other The date to compare to.
|
|
2830
|
-
* @
|
|
2830
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by month).
|
|
2831
2831
|
*/
|
|
2832
2832
|
isAfterMonth(other) {
|
|
2833
2833
|
return this.diffInMonths(other) > 0;
|
|
@@ -2836,7 +2836,7 @@
|
|
|
2836
2836
|
/**
|
|
2837
2837
|
* Checks whether this DateTime is after another date (comparing by second).
|
|
2838
2838
|
* @param {DateTime} other The date to compare to.
|
|
2839
|
-
* @
|
|
2839
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by second).
|
|
2840
2840
|
*/
|
|
2841
2841
|
isAfterSecond(other) {
|
|
2842
2842
|
return this.diffInSeconds(other) > 0;
|
|
@@ -2845,7 +2845,7 @@
|
|
|
2845
2845
|
/**
|
|
2846
2846
|
* Checks whether this DateTime is after another date (comparing by week).
|
|
2847
2847
|
* @param {DateTime} other The date to compare to.
|
|
2848
|
-
* @
|
|
2848
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by week).
|
|
2849
2849
|
*/
|
|
2850
2850
|
isAfterWeek(other) {
|
|
2851
2851
|
return this.diffInWeeks(other) > 0;
|
|
@@ -2854,7 +2854,7 @@
|
|
|
2854
2854
|
/**
|
|
2855
2855
|
* Checks whether this DateTime is after another date (comparing by year).
|
|
2856
2856
|
* @param {DateTime} other The date to compare to.
|
|
2857
|
-
* @
|
|
2857
|
+
* @returns {boolean} Whether this DateTime is after the other date (comparing by year).
|
|
2858
2858
|
*/
|
|
2859
2859
|
isAfterYear(other) {
|
|
2860
2860
|
return this.diffInYears(other) > 0;
|
|
@@ -2863,7 +2863,7 @@
|
|
|
2863
2863
|
/**
|
|
2864
2864
|
* Checks whether this DateTime is before another date.
|
|
2865
2865
|
* @param {DateTime} other The date to compare to.
|
|
2866
|
-
* @
|
|
2866
|
+
* @returns {boolean} Whether this DateTime is before the other date.
|
|
2867
2867
|
*/
|
|
2868
2868
|
isBefore(other) {
|
|
2869
2869
|
return this.diff(other) < 0;
|
|
@@ -2872,7 +2872,7 @@
|
|
|
2872
2872
|
/**
|
|
2873
2873
|
* Checks whether this DateTime is before another date (comparing by day).
|
|
2874
2874
|
* @param {DateTime} other The date to compare to.
|
|
2875
|
-
* @
|
|
2875
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by day).
|
|
2876
2876
|
*/
|
|
2877
2877
|
isBeforeDay(other) {
|
|
2878
2878
|
return this.diffInDays(other) < 0;
|
|
@@ -2881,7 +2881,7 @@
|
|
|
2881
2881
|
/**
|
|
2882
2882
|
* Checks whether this DateTime is before another date (comparing by hour).
|
|
2883
2883
|
* @param {DateTime} other The date to compare to.
|
|
2884
|
-
* @
|
|
2884
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by hour).
|
|
2885
2885
|
*/
|
|
2886
2886
|
isBeforeHour(other) {
|
|
2887
2887
|
return this.diffInHours(other) < 0;
|
|
@@ -2890,7 +2890,7 @@
|
|
|
2890
2890
|
/**
|
|
2891
2891
|
* Checks whether this DateTime is before another date (comparing by minute).
|
|
2892
2892
|
* @param {DateTime} other The date to compare to.
|
|
2893
|
-
* @
|
|
2893
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by minute).
|
|
2894
2894
|
*/
|
|
2895
2895
|
isBeforeMinute(other) {
|
|
2896
2896
|
return this.diffInMinutes(other) < 0;
|
|
@@ -2899,7 +2899,7 @@
|
|
|
2899
2899
|
/**
|
|
2900
2900
|
* Checks whether this DateTime is before another date (comparing by month).
|
|
2901
2901
|
* @param {DateTime} other The date to compare to.
|
|
2902
|
-
* @
|
|
2902
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by month).
|
|
2903
2903
|
*/
|
|
2904
2904
|
isBeforeMonth(other) {
|
|
2905
2905
|
return this.diffInMonths(other) < 0;
|
|
@@ -2908,7 +2908,7 @@
|
|
|
2908
2908
|
/**
|
|
2909
2909
|
* Checks whether this DateTime is before another date (comparing by second).
|
|
2910
2910
|
* @param {DateTime} other The date to compare to.
|
|
2911
|
-
* @
|
|
2911
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by second).
|
|
2912
2912
|
*/
|
|
2913
2913
|
isBeforeSecond(other) {
|
|
2914
2914
|
return this.diffInSeconds(other) < 0;
|
|
@@ -2917,7 +2917,7 @@
|
|
|
2917
2917
|
/**
|
|
2918
2918
|
* Checks whether this DateTime is before another date (comparing by week).
|
|
2919
2919
|
* @param {DateTime} other The date to compare to.
|
|
2920
|
-
* @
|
|
2920
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by week).
|
|
2921
2921
|
*/
|
|
2922
2922
|
isBeforeWeek(other) {
|
|
2923
2923
|
return this.diffInWeeks(other) < 0;
|
|
@@ -2926,7 +2926,7 @@
|
|
|
2926
2926
|
/**
|
|
2927
2927
|
* Checks whether this DateTime is before another date (comparing by year).
|
|
2928
2928
|
* @param {DateTime} other The date to compare to.
|
|
2929
|
-
* @
|
|
2929
|
+
* @returns {boolean} Whether this DateTime is before the other date (comparing by year).
|
|
2930
2930
|
*/
|
|
2931
2931
|
isBeforeYear(other) {
|
|
2932
2932
|
return this.diffInYears(other) < 0;
|
|
@@ -2936,7 +2936,7 @@
|
|
|
2936
2936
|
* Checks whether this DateTime is between two other dates.
|
|
2937
2937
|
* @param {DateTime} start The first date to compare to.
|
|
2938
2938
|
* @param {DateTime} end The second date to compare to.
|
|
2939
|
-
* @
|
|
2939
|
+
* @returns {boolean} Whether this DateTime is between two other dates.
|
|
2940
2940
|
*/
|
|
2941
2941
|
isBetween(start, end) {
|
|
2942
2942
|
return this.isAfter(start) && this.isBefore(end);
|
|
@@ -2946,7 +2946,7 @@
|
|
|
2946
2946
|
* Checks whether this DateTime is between two other dates (comparing by day).
|
|
2947
2947
|
* @param {DateTime} start The first date to compare to.
|
|
2948
2948
|
* @param {DateTime} end The second date to compare to.
|
|
2949
|
-
* @
|
|
2949
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by day).
|
|
2950
2950
|
*/
|
|
2951
2951
|
isBetweenDay(start, end) {
|
|
2952
2952
|
return this.isAfterDay(start) && this.isBeforeDay(end);
|
|
@@ -2956,7 +2956,7 @@
|
|
|
2956
2956
|
* Checks whether this DateTime is between two other dates (comparing by hour).
|
|
2957
2957
|
* @param {DateTime} start The first date to compare to.
|
|
2958
2958
|
* @param {DateTime} end The second date to compare to.
|
|
2959
|
-
* @
|
|
2959
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by hour).
|
|
2960
2960
|
*/
|
|
2961
2961
|
isBetweenHour(start, end) {
|
|
2962
2962
|
return this.isAfterHour(start) && this.isBeforeHour(end);
|
|
@@ -2966,7 +2966,7 @@
|
|
|
2966
2966
|
* Checks whether this DateTime is between two other dates (comparing by minute).
|
|
2967
2967
|
* @param {DateTime} start The first date to compare to.
|
|
2968
2968
|
* @param {DateTime} end The second date to compare to.
|
|
2969
|
-
* @
|
|
2969
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by minute).
|
|
2970
2970
|
*/
|
|
2971
2971
|
isBetweenMinute(start, end) {
|
|
2972
2972
|
return this.isAfterMinute(start) && this.isBeforeMinute(end);
|
|
@@ -2976,7 +2976,7 @@
|
|
|
2976
2976
|
* Checks whether this DateTime is between two other dates (comparing by month).
|
|
2977
2977
|
* @param {DateTime} start The first date to compare to.
|
|
2978
2978
|
* @param {DateTime} end The second date to compare to.
|
|
2979
|
-
* @
|
|
2979
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by month).
|
|
2980
2980
|
*/
|
|
2981
2981
|
isBetweenMonth(start, end) {
|
|
2982
2982
|
return this.isAfterMonth(start) && this.isBeforeMonth(end);
|
|
@@ -2986,7 +2986,7 @@
|
|
|
2986
2986
|
* Checks whether this DateTime is between two other dates (comparing by second).
|
|
2987
2987
|
* @param {DateTime} start The first date to compare to.
|
|
2988
2988
|
* @param {DateTime} end The second date to compare to.
|
|
2989
|
-
* @
|
|
2989
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by second).
|
|
2990
2990
|
*/
|
|
2991
2991
|
isBetweenSecond(start, end) {
|
|
2992
2992
|
return this.isAfterSecond(start) && this.isBeforeSecond(end);
|
|
@@ -2996,7 +2996,7 @@
|
|
|
2996
2996
|
* Checks whether this DateTime is between two other dates (comparing by week).
|
|
2997
2997
|
* @param {DateTime} start The first date to compare to.
|
|
2998
2998
|
* @param {DateTime} end The second date to compare to.
|
|
2999
|
-
* @
|
|
2999
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by week).
|
|
3000
3000
|
*/
|
|
3001
3001
|
isBetweenWeek(start, end) {
|
|
3002
3002
|
return this.isAfterWeek(start) && this.isBeforeWeek(end);
|
|
@@ -3006,7 +3006,7 @@
|
|
|
3006
3006
|
* Checks whether this DateTime is between two other dates (comparing by year).
|
|
3007
3007
|
* @param {DateTime} start The first date to compare to.
|
|
3008
3008
|
* @param {DateTime} end The second date to compare to.
|
|
3009
|
-
* @
|
|
3009
|
+
* @returns {boolean} Whether this DateTime is between two other dates (comparing by year).
|
|
3010
3010
|
*/
|
|
3011
3011
|
isBetweenYear(start, end) {
|
|
3012
3012
|
return this.isAfterYear(start) && this.isBeforeYear(end);
|
|
@@ -3014,7 +3014,7 @@
|
|
|
3014
3014
|
|
|
3015
3015
|
/**
|
|
3016
3016
|
* Checks whether the DateTime is in daylight saving time.
|
|
3017
|
-
* @
|
|
3017
|
+
* @returns {boolean} Whether the current time is in daylight saving time.
|
|
3018
3018
|
*/
|
|
3019
3019
|
isDst() {
|
|
3020
3020
|
if (!this._dynamicTz) {
|
|
@@ -3034,7 +3034,7 @@
|
|
|
3034
3034
|
|
|
3035
3035
|
/**
|
|
3036
3036
|
* Checks whether the year is a leap year.
|
|
3037
|
-
* @
|
|
3037
|
+
* @returns {boolean} Whether the current year is a leap year.
|
|
3038
3038
|
*/
|
|
3039
3039
|
isLeapYear() {
|
|
3040
3040
|
return this.constructor.isLeapYear(
|
|
@@ -3045,7 +3045,7 @@
|
|
|
3045
3045
|
/**
|
|
3046
3046
|
* Checks whether this DateTime is the same as another date.
|
|
3047
3047
|
* @param {DateTime} other The date to compare to.
|
|
3048
|
-
* @
|
|
3048
|
+
* @returns {boolean} Whether this DateTime is the same as the other date.
|
|
3049
3049
|
*/
|
|
3050
3050
|
isSame(other) {
|
|
3051
3051
|
return this.diff(other) === 0;
|
|
@@ -3054,7 +3054,7 @@
|
|
|
3054
3054
|
/**
|
|
3055
3055
|
* Checks whether this DateTime is the same as another date (comparing by day).
|
|
3056
3056
|
* @param {DateTime} other The date to compare to.
|
|
3057
|
-
* @
|
|
3057
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by day).
|
|
3058
3058
|
*/
|
|
3059
3059
|
isSameDay(other) {
|
|
3060
3060
|
return this.diffInDays(other) === 0;
|
|
@@ -3063,7 +3063,7 @@
|
|
|
3063
3063
|
/**
|
|
3064
3064
|
* Checks whether this DateTime is the same as another date (comparing by hour).
|
|
3065
3065
|
* @param {DateTime} other The date to compare to.
|
|
3066
|
-
* @
|
|
3066
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by hour).
|
|
3067
3067
|
*/
|
|
3068
3068
|
isSameHour(other) {
|
|
3069
3069
|
return this.diffInHours(other) === 0;
|
|
@@ -3072,7 +3072,7 @@
|
|
|
3072
3072
|
/**
|
|
3073
3073
|
* Checks whether this DateTime is the same as another date (comparing by minute).
|
|
3074
3074
|
* @param {DateTime} other The date to compare to.
|
|
3075
|
-
* @
|
|
3075
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by minute).
|
|
3076
3076
|
*/
|
|
3077
3077
|
isSameMinute(other) {
|
|
3078
3078
|
return this.diffInMinutes(other) === 0;
|
|
@@ -3081,7 +3081,7 @@
|
|
|
3081
3081
|
/**
|
|
3082
3082
|
* Checks whether this DateTime is the same as another date (comparing by month).
|
|
3083
3083
|
* @param {DateTime} other The date to compare to.
|
|
3084
|
-
* @
|
|
3084
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by month).
|
|
3085
3085
|
*/
|
|
3086
3086
|
isSameMonth(other) {
|
|
3087
3087
|
return this.diffInMonths(other) === 0;
|
|
@@ -3090,7 +3090,7 @@
|
|
|
3090
3090
|
/**
|
|
3091
3091
|
* Checks whether this DateTime is the same as or after another date.
|
|
3092
3092
|
* @param {DateTime} other The date to compare to.
|
|
3093
|
-
* @
|
|
3093
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date.
|
|
3094
3094
|
*/
|
|
3095
3095
|
isSameOrAfter(other) {
|
|
3096
3096
|
return this.diff(other) >= 0;
|
|
@@ -3099,7 +3099,7 @@
|
|
|
3099
3099
|
/**
|
|
3100
3100
|
* Checks whether this DateTime is the same as or after another date (comparing by day).
|
|
3101
3101
|
* @param {DateTime} other The date to compare to.
|
|
3102
|
-
* @
|
|
3102
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by day).
|
|
3103
3103
|
*/
|
|
3104
3104
|
isSameOrAfterDay(other) {
|
|
3105
3105
|
return this.diffInDays(other) >= 0;
|
|
@@ -3108,7 +3108,7 @@
|
|
|
3108
3108
|
/**
|
|
3109
3109
|
* Checks whether this DateTime is the same as or after another date (comparing by hour).
|
|
3110
3110
|
* @param {DateTime} other The date to compare to.
|
|
3111
|
-
* @
|
|
3111
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by hour).
|
|
3112
3112
|
*/
|
|
3113
3113
|
isSameOrAfterHour(other) {
|
|
3114
3114
|
return this.diffInHours(other) >= 0;
|
|
@@ -3117,7 +3117,7 @@
|
|
|
3117
3117
|
/**
|
|
3118
3118
|
* Checks whether this DateTime is the same as or after another date (comparing by minute).
|
|
3119
3119
|
* @param {DateTime} other The date to compare to.
|
|
3120
|
-
* @
|
|
3120
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by minute).
|
|
3121
3121
|
*/
|
|
3122
3122
|
isSameOrAfterMinute(other) {
|
|
3123
3123
|
return this.diffInMinutes(other) >= 0;
|
|
@@ -3126,7 +3126,7 @@
|
|
|
3126
3126
|
/**
|
|
3127
3127
|
* Checks whether this DateTime is the same as or after another date (comparing by month).
|
|
3128
3128
|
* @param {DateTime} other The date to compare to.
|
|
3129
|
-
* @
|
|
3129
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by month).
|
|
3130
3130
|
*/
|
|
3131
3131
|
isSameOrAfterMonth(other) {
|
|
3132
3132
|
return this.diffInMonths(other) >= 0;
|
|
@@ -3135,7 +3135,7 @@
|
|
|
3135
3135
|
/**
|
|
3136
3136
|
* Checks whether this DateTime is the same as or after another date (comparing by second).
|
|
3137
3137
|
* @param {DateTime} other The date to compare to.
|
|
3138
|
-
* @
|
|
3138
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by second).
|
|
3139
3139
|
*/
|
|
3140
3140
|
isSameOrAfterSecond(other) {
|
|
3141
3141
|
return this.diffInSeconds(other) >= 0;
|
|
@@ -3144,7 +3144,7 @@
|
|
|
3144
3144
|
/**
|
|
3145
3145
|
* Checks whether this DateTime is the same as or after another date (comparing by week).
|
|
3146
3146
|
* @param {DateTime} other The date to compare to.
|
|
3147
|
-
* @
|
|
3147
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by week).
|
|
3148
3148
|
*/
|
|
3149
3149
|
isSameOrAfterWeek(other) {
|
|
3150
3150
|
return this.diffInWeeks(other) >= 0;
|
|
@@ -3153,7 +3153,7 @@
|
|
|
3153
3153
|
/**
|
|
3154
3154
|
* Checks whether this DateTime is the same as or after another date (comparing by year).
|
|
3155
3155
|
* @param {DateTime} other The date to compare to.
|
|
3156
|
-
* @
|
|
3156
|
+
* @returns {boolean} Whether this DateTime is the same as or after the other date (comparing by year).
|
|
3157
3157
|
*/
|
|
3158
3158
|
isSameOrAfterYear(other) {
|
|
3159
3159
|
return this.diffInYears(other) >= 0;
|
|
@@ -3162,7 +3162,7 @@
|
|
|
3162
3162
|
/**
|
|
3163
3163
|
* Checks whether this DateTime is the same as or before another date.
|
|
3164
3164
|
* @param {DateTime} other The date to compare to.
|
|
3165
|
-
* @
|
|
3165
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date.
|
|
3166
3166
|
*/
|
|
3167
3167
|
isSameOrBefore(other) {
|
|
3168
3168
|
return this.diff(other) <= 0;
|
|
@@ -3171,7 +3171,7 @@
|
|
|
3171
3171
|
/**
|
|
3172
3172
|
* Checks whether this DateTime is the same as or before another date (comparing by day).
|
|
3173
3173
|
* @param {DateTime} other The date to compare to.
|
|
3174
|
-
* @
|
|
3174
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by day).
|
|
3175
3175
|
*/
|
|
3176
3176
|
isSameOrBeforeDay(other) {
|
|
3177
3177
|
return this.diffInDays(other) <= 0;
|
|
@@ -3180,7 +3180,7 @@
|
|
|
3180
3180
|
/**
|
|
3181
3181
|
* Checks whether this DateTime is the same as or before another date (comparing by hour).
|
|
3182
3182
|
* @param {DateTime} other The date to compare to.
|
|
3183
|
-
* @
|
|
3183
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by hour).
|
|
3184
3184
|
*/
|
|
3185
3185
|
isSameOrBeforeHour(other) {
|
|
3186
3186
|
return this.diffInHours(other) <= 0;
|
|
@@ -3189,7 +3189,7 @@
|
|
|
3189
3189
|
/**
|
|
3190
3190
|
* Checks whether this DateTime is the same as or before another date (comparing by minute).
|
|
3191
3191
|
* @param {DateTime} other The date to compare to.
|
|
3192
|
-
* @
|
|
3192
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by minute).
|
|
3193
3193
|
*/
|
|
3194
3194
|
isSameOrBeforeMinute(other) {
|
|
3195
3195
|
return this.diffInMinutes(other) <= 0;
|
|
@@ -3198,7 +3198,7 @@
|
|
|
3198
3198
|
/**
|
|
3199
3199
|
* Checks whether this DateTime is the same as or before another date (comparing by month).
|
|
3200
3200
|
* @param {DateTime} other The date to compare to.
|
|
3201
|
-
* @
|
|
3201
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by month).
|
|
3202
3202
|
*/
|
|
3203
3203
|
isSameOrBeforeMonth(other) {
|
|
3204
3204
|
return this.diffInMonths(other) <= 0;
|
|
@@ -3207,7 +3207,7 @@
|
|
|
3207
3207
|
/**
|
|
3208
3208
|
* Checks whether this DateTime is the same as or before another date (comparing by second).
|
|
3209
3209
|
* @param {DateTime} other The date to compare to.
|
|
3210
|
-
* @
|
|
3210
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by second).
|
|
3211
3211
|
*/
|
|
3212
3212
|
isSameOrBeforeSecond(other) {
|
|
3213
3213
|
return this.diffInSeconds(other) <= 0;
|
|
@@ -3216,7 +3216,7 @@
|
|
|
3216
3216
|
/**
|
|
3217
3217
|
* Checks whether this DateTime is the same as or before another date (comparing by week).
|
|
3218
3218
|
* @param {DateTime} other The date to compare to.
|
|
3219
|
-
* @
|
|
3219
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by week).
|
|
3220
3220
|
*/
|
|
3221
3221
|
isSameOrBeforeWeek(other) {
|
|
3222
3222
|
return this.diffInWeeks(other) <= 0;
|
|
@@ -3225,7 +3225,7 @@
|
|
|
3225
3225
|
/**
|
|
3226
3226
|
* Checks whether this DateTime is the same as or before another date (comparing by year).
|
|
3227
3227
|
* @param {DateTime} other The date to compare to.
|
|
3228
|
-
* @
|
|
3228
|
+
* @returns {boolean} Whether this DateTime is the same as or before the other date (comparing by year).
|
|
3229
3229
|
*/
|
|
3230
3230
|
isSameOrBeforeYear(other) {
|
|
3231
3231
|
return this.diffInYears(other) <= 0;
|
|
@@ -3234,7 +3234,7 @@
|
|
|
3234
3234
|
/**
|
|
3235
3235
|
* Checks whether this DateTime is the same as another date (comparing by second).
|
|
3236
3236
|
* @param {DateTime} other The date to compare to.
|
|
3237
|
-
* @
|
|
3237
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by second).
|
|
3238
3238
|
*/
|
|
3239
3239
|
isSameSecond(other) {
|
|
3240
3240
|
return this.diffInSeconds(other) === 0;
|
|
@@ -3243,7 +3243,7 @@
|
|
|
3243
3243
|
/**
|
|
3244
3244
|
* Checks whether this DateTime is the same as another date (comparing by week).
|
|
3245
3245
|
* @param {DateTime} other The date to compare to.
|
|
3246
|
-
* @
|
|
3246
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by week).
|
|
3247
3247
|
*/
|
|
3248
3248
|
isSameWeek(other) {
|
|
3249
3249
|
return this.diffInWeeks(other) === 0;
|
|
@@ -3252,7 +3252,7 @@
|
|
|
3252
3252
|
/**
|
|
3253
3253
|
* Checks whether this DateTime is the same as another date (comparing by year).
|
|
3254
3254
|
* @param {DateTime} other The date to compare to.
|
|
3255
|
-
* @
|
|
3255
|
+
* @returns {boolean} Whether this DateTime is the same as the other date (comparing by year).
|
|
3256
3256
|
*/
|
|
3257
3257
|
isSameYear(other) {
|
|
3258
3258
|
return this.diffInYears(other) === 0;
|
|
@@ -3261,7 +3261,7 @@
|
|
|
3261
3261
|
/**
|
|
3262
3262
|
* Gets the localized month name for the current date.
|
|
3263
3263
|
* @param {'long'|'short'|'narrow'} [type='long'] The type of month name to return.
|
|
3264
|
-
* @
|
|
3264
|
+
* @returns {string} The localized month name.
|
|
3265
3265
|
*/
|
|
3266
3266
|
monthName(type = 'long') {
|
|
3267
3267
|
return formatMonth(this.getLocale(), this.getMonth(), type);
|
|
@@ -3269,7 +3269,7 @@
|
|
|
3269
3269
|
|
|
3270
3270
|
/**
|
|
3271
3271
|
* Sets the DateTime to the start of the day.
|
|
3272
|
-
* @
|
|
3272
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3273
3273
|
*/
|
|
3274
3274
|
startOfDay() {
|
|
3275
3275
|
return this.withHours(0, 0, 0, 0);
|
|
@@ -3277,7 +3277,7 @@
|
|
|
3277
3277
|
|
|
3278
3278
|
/**
|
|
3279
3279
|
* Sets the DateTime to the start of the hour.
|
|
3280
|
-
* @
|
|
3280
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3281
3281
|
*/
|
|
3282
3282
|
startOfHour() {
|
|
3283
3283
|
return this.withMinutes(0, 0, 0);
|
|
@@ -3285,7 +3285,7 @@
|
|
|
3285
3285
|
|
|
3286
3286
|
/**
|
|
3287
3287
|
* Sets the DateTime to the start of the minute.
|
|
3288
|
-
* @
|
|
3288
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3289
3289
|
*/
|
|
3290
3290
|
startOfMinute() {
|
|
3291
3291
|
return this.withSeconds(0, 0);
|
|
@@ -3293,7 +3293,7 @@
|
|
|
3293
3293
|
|
|
3294
3294
|
/**
|
|
3295
3295
|
* Sets the DateTime to the start of the month.
|
|
3296
|
-
* @
|
|
3296
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3297
3297
|
*/
|
|
3298
3298
|
startOfMonth() {
|
|
3299
3299
|
return this.withDate(1)
|
|
@@ -3302,7 +3302,7 @@
|
|
|
3302
3302
|
|
|
3303
3303
|
/**
|
|
3304
3304
|
* Sets the DateTime to the start of the quarter.
|
|
3305
|
-
* @
|
|
3305
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3306
3306
|
*/
|
|
3307
3307
|
startOfQuarter() {
|
|
3308
3308
|
const month = this.getQuarter() * 3 - 2;
|
|
@@ -3312,7 +3312,7 @@
|
|
|
3312
3312
|
|
|
3313
3313
|
/**
|
|
3314
3314
|
* Sets the DateTime to the start of the second.
|
|
3315
|
-
* @
|
|
3315
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3316
3316
|
*/
|
|
3317
3317
|
startOfSecond() {
|
|
3318
3318
|
return this.withMilliseconds(0);
|
|
@@ -3320,7 +3320,7 @@
|
|
|
3320
3320
|
|
|
3321
3321
|
/**
|
|
3322
3322
|
* Sets the DateTime to the start of the week.
|
|
3323
|
-
* @
|
|
3323
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3324
3324
|
*/
|
|
3325
3325
|
startOfWeek() {
|
|
3326
3326
|
return this.withWeekDay(1)
|
|
@@ -3329,7 +3329,7 @@
|
|
|
3329
3329
|
|
|
3330
3330
|
/**
|
|
3331
3331
|
* Sets the DateTime to the start of the year.
|
|
3332
|
-
* @
|
|
3332
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3333
3333
|
*/
|
|
3334
3334
|
startOfYear() {
|
|
3335
3335
|
return this.withMonth(1, 1)
|
|
@@ -3338,7 +3338,7 @@
|
|
|
3338
3338
|
|
|
3339
3339
|
/**
|
|
3340
3340
|
* Subtracts a day from the current DateTime.
|
|
3341
|
-
* @
|
|
3341
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3342
3342
|
*/
|
|
3343
3343
|
subDay() {
|
|
3344
3344
|
return this.addDays(-1);
|
|
@@ -3347,7 +3347,7 @@
|
|
|
3347
3347
|
/**
|
|
3348
3348
|
* Subtracts days from the current DateTime.
|
|
3349
3349
|
* @param {number} amount The number of days to subtract.
|
|
3350
|
-
* @
|
|
3350
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3351
3351
|
*/
|
|
3352
3352
|
subDays(amount) {
|
|
3353
3353
|
return this.addDays(-amount);
|
|
@@ -3355,7 +3355,7 @@
|
|
|
3355
3355
|
|
|
3356
3356
|
/**
|
|
3357
3357
|
* Subtracts an hour from the current DateTime.
|
|
3358
|
-
* @
|
|
3358
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3359
3359
|
*/
|
|
3360
3360
|
subHour() {
|
|
3361
3361
|
return this.addHours(-1);
|
|
@@ -3364,7 +3364,7 @@
|
|
|
3364
3364
|
/**
|
|
3365
3365
|
* Subtracts hours from the current DateTime.
|
|
3366
3366
|
* @param {number} amount The number of hours to subtract.
|
|
3367
|
-
* @
|
|
3367
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3368
3368
|
*/
|
|
3369
3369
|
subHours(amount) {
|
|
3370
3370
|
return this.addHours(-amount);
|
|
@@ -3372,7 +3372,7 @@
|
|
|
3372
3372
|
|
|
3373
3373
|
/**
|
|
3374
3374
|
* Subtracts a minute from the current DateTime.
|
|
3375
|
-
* @
|
|
3375
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3376
3376
|
*/
|
|
3377
3377
|
subMinute() {
|
|
3378
3378
|
return this.addMinutes(-1);
|
|
@@ -3381,7 +3381,7 @@
|
|
|
3381
3381
|
/**
|
|
3382
3382
|
* Subtracts minutes from the current DateTime.
|
|
3383
3383
|
* @param {number} amount The number of minutes to subtract.
|
|
3384
|
-
* @
|
|
3384
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3385
3385
|
*/
|
|
3386
3386
|
subMinutes(amount) {
|
|
3387
3387
|
return this.addMinutes(-amount);
|
|
@@ -3389,7 +3389,7 @@
|
|
|
3389
3389
|
|
|
3390
3390
|
/**
|
|
3391
3391
|
* Subtracts a month from the current DateTime.
|
|
3392
|
-
* @
|
|
3392
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3393
3393
|
*/
|
|
3394
3394
|
subMonth() {
|
|
3395
3395
|
return this.addMonths(-1);
|
|
@@ -3398,7 +3398,7 @@
|
|
|
3398
3398
|
/**
|
|
3399
3399
|
* Subtracts months from the current DateTime.
|
|
3400
3400
|
* @param {number} amount The number of months to subtract.
|
|
3401
|
-
* @
|
|
3401
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3402
3402
|
*/
|
|
3403
3403
|
subMonths(amount) {
|
|
3404
3404
|
return this.addMonths(-amount);
|
|
@@ -3406,7 +3406,7 @@
|
|
|
3406
3406
|
|
|
3407
3407
|
/**
|
|
3408
3408
|
* Subtracts a second from the current DateTime.
|
|
3409
|
-
* @
|
|
3409
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3410
3410
|
*/
|
|
3411
3411
|
subSecond() {
|
|
3412
3412
|
return this.addSeconds(-1);
|
|
@@ -3415,7 +3415,7 @@
|
|
|
3415
3415
|
/**
|
|
3416
3416
|
* Subtracts seconds from the current DateTime.
|
|
3417
3417
|
* @param {number} amount The number of seconds to subtract.
|
|
3418
|
-
* @
|
|
3418
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3419
3419
|
*/
|
|
3420
3420
|
subSeconds(amount) {
|
|
3421
3421
|
return this.addSeconds(-amount);
|
|
@@ -3423,7 +3423,7 @@
|
|
|
3423
3423
|
|
|
3424
3424
|
/**
|
|
3425
3425
|
* Subtracts a week from the current DateTime.
|
|
3426
|
-
* @
|
|
3426
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3427
3427
|
*/
|
|
3428
3428
|
subWeek() {
|
|
3429
3429
|
return this.addWeeks(-1);
|
|
@@ -3432,7 +3432,7 @@
|
|
|
3432
3432
|
/**
|
|
3433
3433
|
* Subtracts weeks from the current DateTime.
|
|
3434
3434
|
* @param {number} amount The number of weeks to subtract.
|
|
3435
|
-
* @
|
|
3435
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3436
3436
|
*/
|
|
3437
3437
|
subWeeks(amount) {
|
|
3438
3438
|
return this.addWeeks(-amount);
|
|
@@ -3440,7 +3440,7 @@
|
|
|
3440
3440
|
|
|
3441
3441
|
/**
|
|
3442
3442
|
* Subtracts a year from the current DateTime.
|
|
3443
|
-
* @
|
|
3443
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3444
3444
|
*/
|
|
3445
3445
|
subYear() {
|
|
3446
3446
|
return this.addYears(-1);
|
|
@@ -3449,7 +3449,7 @@
|
|
|
3449
3449
|
/**
|
|
3450
3450
|
* Subtracts years from the current DateTime.
|
|
3451
3451
|
* @param {number} amount The number of years to subtract.
|
|
3452
|
-
* @
|
|
3452
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3453
3453
|
*/
|
|
3454
3454
|
subYears(amount) {
|
|
3455
3455
|
return this.addYears(-amount);
|
|
@@ -3458,7 +3458,7 @@
|
|
|
3458
3458
|
/**
|
|
3459
3459
|
* Returns the primitive representation of the DateTime.
|
|
3460
3460
|
* @param {'default'|'number'|'string'} hint The conversion hint.
|
|
3461
|
-
* @
|
|
3461
|
+
* @returns {string|number} A string for default/string coercion or epoch milliseconds for numeric coercion.
|
|
3462
3462
|
*/
|
|
3463
3463
|
[Symbol.toPrimitive](hint) {
|
|
3464
3464
|
return hint === 'number' ?
|
|
@@ -3469,7 +3469,7 @@
|
|
|
3469
3469
|
/**
|
|
3470
3470
|
* Gets the name of the current time zone.
|
|
3471
3471
|
* @param {'long'|'short'} [type='long'] The formatting type.
|
|
3472
|
-
* @
|
|
3472
|
+
* @returns {string} The name of the time zone.
|
|
3473
3473
|
*/
|
|
3474
3474
|
timeZoneName(type = 'long') {
|
|
3475
3475
|
return this._dynamicTz ?
|
|
@@ -3479,7 +3479,7 @@
|
|
|
3479
3479
|
|
|
3480
3480
|
/**
|
|
3481
3481
|
* Formats the current date using "eee MMM dd yyyy".
|
|
3482
|
-
* @
|
|
3482
|
+
* @returns {string} The formatted date string.
|
|
3483
3483
|
*/
|
|
3484
3484
|
toDateString() {
|
|
3485
3485
|
return this.format(formats.date);
|
|
@@ -3487,9 +3487,9 @@
|
|
|
3487
3487
|
|
|
3488
3488
|
/**
|
|
3489
3489
|
* Formats the current date using "yyyy-MM-dd'T'HH:mm:ss.SSSxxx".
|
|
3490
|
-
* @
|
|
3490
|
+
* @returns {string} The formatted date string.
|
|
3491
3491
|
*/
|
|
3492
|
-
|
|
3492
|
+
toIsoString() {
|
|
3493
3493
|
return this
|
|
3494
3494
|
.withLocale('en')
|
|
3495
3495
|
.withTimeZone('UTC')
|
|
@@ -3498,17 +3498,17 @@
|
|
|
3498
3498
|
|
|
3499
3499
|
/**
|
|
3500
3500
|
* Returns the JSON representation of the current date.
|
|
3501
|
-
* @
|
|
3501
|
+
* @returns {string|null} The ISO string for valid dates or null for invalid dates.
|
|
3502
3502
|
*/
|
|
3503
3503
|
toJSON() {
|
|
3504
3504
|
return this.isValid ?
|
|
3505
|
-
this.
|
|
3505
|
+
this.toIsoString() :
|
|
3506
3506
|
null;
|
|
3507
3507
|
}
|
|
3508
3508
|
|
|
3509
3509
|
/**
|
|
3510
3510
|
* Formats the current date using "eee MMM dd yyyy HH:mm:ss xx (VV)".
|
|
3511
|
-
* @
|
|
3511
|
+
* @returns {string} The formatted date string.
|
|
3512
3512
|
*/
|
|
3513
3513
|
toString() {
|
|
3514
3514
|
return this.format(formats.string);
|
|
@@ -3516,7 +3516,7 @@
|
|
|
3516
3516
|
|
|
3517
3517
|
/**
|
|
3518
3518
|
* Formats the current date using "HH:mm:ss xx (VV)".
|
|
3519
|
-
* @
|
|
3519
|
+
* @returns {string} The formatted date string.
|
|
3520
3520
|
*/
|
|
3521
3521
|
toTimeString() {
|
|
3522
3522
|
return this.format(formats.time);
|
|
@@ -3524,7 +3524,7 @@
|
|
|
3524
3524
|
|
|
3525
3525
|
/**
|
|
3526
3526
|
* Formats the current date in the UTC time zone using "eee MMM dd yyyy HH:mm:ss xx (VV)".
|
|
3527
|
-
* @
|
|
3527
|
+
* @returns {string} The formatted date string.
|
|
3528
3528
|
*/
|
|
3529
3529
|
toUTCString() {
|
|
3530
3530
|
return this
|
|
@@ -3535,7 +3535,7 @@
|
|
|
3535
3535
|
|
|
3536
3536
|
/**
|
|
3537
3537
|
* Returns the number of milliseconds since the UNIX epoch.
|
|
3538
|
-
* @
|
|
3538
|
+
* @returns {number} The number of milliseconds since the UNIX epoch.
|
|
3539
3539
|
*/
|
|
3540
3540
|
valueOf() {
|
|
3541
3541
|
return this.getTime();
|
|
@@ -3543,7 +3543,7 @@
|
|
|
3543
3543
|
|
|
3544
3544
|
/**
|
|
3545
3545
|
* Gets the number of weeks in the current year.
|
|
3546
|
-
* @
|
|
3546
|
+
* @returns {number} The number of weeks in the current year.
|
|
3547
3547
|
*/
|
|
3548
3548
|
weeksInYear() {
|
|
3549
3549
|
const minDays = minimumDays(this.getLocale());
|
|
@@ -3553,7 +3553,7 @@
|
|
|
3553
3553
|
/**
|
|
3554
3554
|
* Returns a copy with the date of the month changed in the current time zone.
|
|
3555
3555
|
* @param {number} date The date of the month.
|
|
3556
|
-
* @
|
|
3556
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3557
3557
|
*/
|
|
3558
3558
|
withDate(date) {
|
|
3559
3559
|
return setOffsetTime(
|
|
@@ -3565,7 +3565,7 @@
|
|
|
3565
3565
|
/**
|
|
3566
3566
|
* Returns a copy with the day of the week changed in the current time zone.
|
|
3567
3567
|
* @param {number} day The day of the week. (0 = Sunday, 6 = Saturday)
|
|
3568
|
-
* @
|
|
3568
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3569
3569
|
*/
|
|
3570
3570
|
withDay(day) {
|
|
3571
3571
|
return setOffsetTime(
|
|
@@ -3581,7 +3581,7 @@
|
|
|
3581
3581
|
/**
|
|
3582
3582
|
* Returns a copy with the day of the year changed in the current time zone.
|
|
3583
3583
|
* @param {number} day The day of the year. (1-366)
|
|
3584
|
-
* @
|
|
3584
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3585
3585
|
*/
|
|
3586
3586
|
withDayOfYear(day) {
|
|
3587
3587
|
return setOffsetTime(
|
|
@@ -3599,7 +3599,7 @@
|
|
|
3599
3599
|
* @param {number} [minutes] The minutes. (0-59)
|
|
3600
3600
|
* @param {number} [seconds] The seconds. (0-59)
|
|
3601
3601
|
* @param {number} [milliseconds] The milliseconds.
|
|
3602
|
-
* @
|
|
3602
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3603
3603
|
*/
|
|
3604
3604
|
withHours(...args) {
|
|
3605
3605
|
return setOffsetTime(
|
|
@@ -3611,7 +3611,7 @@
|
|
|
3611
3611
|
/**
|
|
3612
3612
|
* Returns a copy with a different locale.
|
|
3613
3613
|
* @param {string} locale The locale to use.
|
|
3614
|
-
* @
|
|
3614
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3615
3615
|
*/
|
|
3616
3616
|
withLocale(locale) {
|
|
3617
3617
|
return new this.constructor(this.getTime(), {
|
|
@@ -3623,7 +3623,7 @@
|
|
|
3623
3623
|
/**
|
|
3624
3624
|
* Returns a copy with the milliseconds changed in the current time zone.
|
|
3625
3625
|
* @param {number} milliseconds The milliseconds.
|
|
3626
|
-
* @
|
|
3626
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3627
3627
|
*/
|
|
3628
3628
|
withMilliseconds(milliseconds) {
|
|
3629
3629
|
return setOffsetTime(
|
|
@@ -3637,7 +3637,7 @@
|
|
|
3637
3637
|
* @param {number} minutes The minutes. (0-59)
|
|
3638
3638
|
* @param {number} [seconds] The seconds. (0-59)
|
|
3639
3639
|
* @param {number} [milliseconds] The milliseconds.
|
|
3640
|
-
* @
|
|
3640
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3641
3641
|
*/
|
|
3642
3642
|
withMinutes(...args) {
|
|
3643
3643
|
return setOffsetTime(
|
|
@@ -3650,7 +3650,7 @@
|
|
|
3650
3650
|
* Returns a copy with the month changed in the current time zone.
|
|
3651
3651
|
* @param {number} month The month. (1-12)
|
|
3652
3652
|
* @param {number|null} [date] The date of the month.
|
|
3653
|
-
* @
|
|
3653
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3654
3654
|
*/
|
|
3655
3655
|
withMonth(month, date = null) {
|
|
3656
3656
|
if (date === null) {
|
|
@@ -3679,7 +3679,7 @@
|
|
|
3679
3679
|
/**
|
|
3680
3680
|
* Returns a copy with the quarter of the year changed in the current time zone.
|
|
3681
3681
|
* @param {number} quarter The quarter of the year. (1-4)
|
|
3682
|
-
* @
|
|
3682
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3683
3683
|
*/
|
|
3684
3684
|
withQuarter(quarter) {
|
|
3685
3685
|
return setOffsetTime(
|
|
@@ -3695,7 +3695,7 @@
|
|
|
3695
3695
|
* Returns a copy with the seconds changed in the current time zone.
|
|
3696
3696
|
* @param {number} seconds The seconds. (0-59)
|
|
3697
3697
|
* @param {number} [milliseconds] The milliseconds.
|
|
3698
|
-
* @
|
|
3698
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3699
3699
|
*/
|
|
3700
3700
|
withSeconds(...args) {
|
|
3701
3701
|
return setOffsetTime(
|
|
@@ -3707,7 +3707,7 @@
|
|
|
3707
3707
|
/**
|
|
3708
3708
|
* Returns a copy with a different epoch-millisecond value.
|
|
3709
3709
|
* @param {number} time The number of milliseconds since the UNIX epoch.
|
|
3710
|
-
* @
|
|
3710
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3711
3711
|
*/
|
|
3712
3712
|
withTime(time) {
|
|
3713
3713
|
return new this.constructor(time, {
|
|
@@ -3719,7 +3719,7 @@
|
|
|
3719
3719
|
/**
|
|
3720
3720
|
* Returns a copy with a different number of seconds since the UNIX epoch.
|
|
3721
3721
|
* @param {number} timestamp The number of seconds since the UNIX epoch.
|
|
3722
|
-
* @
|
|
3722
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3723
3723
|
*/
|
|
3724
3724
|
withTimestamp(timestamp) {
|
|
3725
3725
|
return this.withTime(timestamp * 1000);
|
|
@@ -3728,7 +3728,7 @@
|
|
|
3728
3728
|
/**
|
|
3729
3729
|
* Returns a copy in a different time zone.
|
|
3730
3730
|
* @param {string} timeZone The time zone to use.
|
|
3731
|
-
* @
|
|
3731
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3732
3732
|
*/
|
|
3733
3733
|
withTimeZone(timeZone) {
|
|
3734
3734
|
return new this.constructor(this.getTime(), {
|
|
@@ -3740,7 +3740,7 @@
|
|
|
3740
3740
|
/**
|
|
3741
3741
|
* Returns a copy with a fixed numeric UTC offset.
|
|
3742
3742
|
* @param {number} offset The UTC offset in minutes.
|
|
3743
|
-
* @
|
|
3743
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3744
3744
|
*/
|
|
3745
3745
|
withTimeZoneOffset(offset) {
|
|
3746
3746
|
return new this.constructor(this.getTime(), {
|
|
@@ -3753,7 +3753,7 @@
|
|
|
3753
3753
|
* Returns a copy with the local week changed in the current time zone.
|
|
3754
3754
|
* @param {number} week The local week.
|
|
3755
3755
|
* @param {number|null} [day] The local day of the week. (1-7)
|
|
3756
|
-
* @
|
|
3756
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3757
3757
|
*/
|
|
3758
3758
|
withWeek(week, day = null) {
|
|
3759
3759
|
if (day === null) {
|
|
@@ -3767,7 +3767,7 @@
|
|
|
3767
3767
|
/**
|
|
3768
3768
|
* Returns a copy with the local day of the week changed in the current time zone.
|
|
3769
3769
|
* @param {number} day The local day of the week. (1-7)
|
|
3770
|
-
* @
|
|
3770
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3771
3771
|
*/
|
|
3772
3772
|
withWeekDay(day) {
|
|
3773
3773
|
return setOffsetTime(
|
|
@@ -3783,7 +3783,7 @@
|
|
|
3783
3783
|
/**
|
|
3784
3784
|
* Returns a copy with the week day in month changed in the current time zone.
|
|
3785
3785
|
* @param {number} week The week day in month.
|
|
3786
|
-
* @
|
|
3786
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3787
3787
|
*/
|
|
3788
3788
|
withWeekDayInMonth(week) {
|
|
3789
3789
|
return this.withDate(
|
|
@@ -3798,7 +3798,7 @@
|
|
|
3798
3798
|
/**
|
|
3799
3799
|
* Returns a copy with the week of month changed in the current time zone.
|
|
3800
3800
|
* @param {number} week The week of month.
|
|
3801
|
-
* @
|
|
3801
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3802
3802
|
*/
|
|
3803
3803
|
withWeekOfMonth(week) {
|
|
3804
3804
|
return this.withDate(
|
|
@@ -3815,7 +3815,7 @@
|
|
|
3815
3815
|
* @param {number} year The local week year.
|
|
3816
3816
|
* @param {number|null} [week] The local week.
|
|
3817
3817
|
* @param {number|null} [day] The local day of the week. (1-7)
|
|
3818
|
-
* @
|
|
3818
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3819
3819
|
*/
|
|
3820
3820
|
withWeekYear(year, week = null, day = null) {
|
|
3821
3821
|
const minDays = minimumDays(this.getLocale());
|
|
@@ -3843,7 +3843,7 @@
|
|
|
3843
3843
|
* @param {number} year The year.
|
|
3844
3844
|
* @param {number|null} [month] The month. (1-12)
|
|
3845
3845
|
* @param {number|null} [date] The date of the month.
|
|
3846
|
-
* @
|
|
3846
|
+
* @returns {DateTime} A new DateTime instance.
|
|
3847
3847
|
*/
|
|
3848
3848
|
withYear(year, month = null, date = null) {
|
|
3849
3849
|
if (month === null) {
|