@dereekb/util 10.1.10 → 10.1.12
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/fetch/CHANGELOG.md +8 -0
- package/fetch/package.json +1 -1
- package/index.cjs.js +299 -188
- package/index.esm.js +4101 -3978
- package/package.json +1 -1
- package/src/lib/date/hour.d.ts +57 -0
- package/src/lib/iterable/iterable.d.ts +26 -0
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +1 -1
package/fetch/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [10.1.12](https://github.com/dereekb/dbx-components/compare/v10.1.11-dev...v10.1.12) (2024-04-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [10.1.11](https://github.com/dereekb/dbx-components/compare/v10.1.10-dev...v10.1.11) (2024-04-27)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [10.1.10](https://github.com/dereekb/dbx-components/compare/v10.1.9-dev...v10.1.10) (2024-04-12)
|
|
6
14
|
|
|
7
15
|
|
package/fetch/package.json
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1972,6 +1972,15 @@ function asIterable(values, treatStringAsIterable) {
|
|
|
1972
1972
|
}
|
|
1973
1973
|
return iterable;
|
|
1974
1974
|
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Converts the input IterableOrValue value to an array.
|
|
1977
|
+
*
|
|
1978
|
+
* By default will treat strings as a non-iterable value, using the string as a single value.
|
|
1979
|
+
*
|
|
1980
|
+
* @param values
|
|
1981
|
+
* @param treatStringAsIterable
|
|
1982
|
+
* @returns
|
|
1983
|
+
*/
|
|
1975
1984
|
function iterableToArray(values, treatStringAsIterable) {
|
|
1976
1985
|
let iterable;
|
|
1977
1986
|
if (treatStringAsIterable && typeof values === 'string') {
|
|
@@ -1983,6 +1992,25 @@ function iterableToArray(values, treatStringAsIterable) {
|
|
|
1983
1992
|
}
|
|
1984
1993
|
return iterable;
|
|
1985
1994
|
}
|
|
1995
|
+
/**
|
|
1996
|
+
* Converts the input IterableOrValue value to a Set.
|
|
1997
|
+
*
|
|
1998
|
+
* By default will treat strings as a non-iterable value, using the string as a single value.
|
|
1999
|
+
*
|
|
2000
|
+
* @param values
|
|
2001
|
+
* @param treatStringAsIterable
|
|
2002
|
+
* @returns
|
|
2003
|
+
*/
|
|
2004
|
+
function iterableToSet(values, treatStringAsIterable = false) {
|
|
2005
|
+
return new Set(iterableToArray(values, treatStringAsIterable));
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Converts the input IterableOrValue value to a Map using the input readKey function.
|
|
2009
|
+
*
|
|
2010
|
+
* @param values
|
|
2011
|
+
* @param readKey
|
|
2012
|
+
* @returns
|
|
2013
|
+
*/
|
|
1986
2014
|
function iterableToMap(values, readKey) {
|
|
1987
2015
|
const map = new Map(iterableToArray(values).map(value => [readKey(value), value]));
|
|
1988
2016
|
return map;
|
|
@@ -9457,6 +9485,265 @@ function compareEqualityWithValueFromItemsFunctionFactory(readValues) {
|
|
|
9457
9485
|
return fn;
|
|
9458
9486
|
}
|
|
9459
9487
|
|
|
9488
|
+
/**
|
|
9489
|
+
* TODO: Need to improve to support negative years.
|
|
9490
|
+
*/
|
|
9491
|
+
const ISO_8601_DATE_STRING_REGEX = /(\d{4,})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})(Z|[+-](\d{2})\:(\d{2}))?/;
|
|
9492
|
+
function isISO8601DateString(input) {
|
|
9493
|
+
return ISO_8601_DATE_STRING_REGEX.test(input);
|
|
9494
|
+
}
|
|
9495
|
+
/**
|
|
9496
|
+
* Match examples:
|
|
9497
|
+
*
|
|
9498
|
+
* Sat, 03 Feb 2001 04:05:06 GMT
|
|
9499
|
+
* Tue, 14 Mar 2023 12:34:56 UTC
|
|
9500
|
+
* Wed, 25 May 2024 20:45:07 EST
|
|
9501
|
+
*/
|
|
9502
|
+
const UTC_DATE_STRING_REGEX = /^([a-zA-Z]{3}, [0-9]{2} [a-zA-Z]{3} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3})$/;
|
|
9503
|
+
function isUTCDateString(input) {
|
|
9504
|
+
return UTC_DATE_STRING_REGEX.test(input);
|
|
9505
|
+
}
|
|
9506
|
+
/**
|
|
9507
|
+
* Returns true only if the inputs have the same timezone, or both do not have a timezone set.
|
|
9508
|
+
*
|
|
9509
|
+
* @param a
|
|
9510
|
+
* @param b
|
|
9511
|
+
* @returns
|
|
9512
|
+
*/
|
|
9513
|
+
function hasSameTimezone(a, b) {
|
|
9514
|
+
const tzA = a === null || a === void 0 ? void 0 : a.timezone;
|
|
9515
|
+
const tzB = b === null || b === void 0 ? void 0 : b.timezone;
|
|
9516
|
+
return valuesAreBothNullishOrEquivalent(tzA, tzB);
|
|
9517
|
+
}
|
|
9518
|
+
/**
|
|
9519
|
+
* Constant for the UTC timezone string, "UTC".
|
|
9520
|
+
*/
|
|
9521
|
+
const UTC_TIMEZONE_STRING = 'UTC';
|
|
9522
|
+
function isConsideredUtcTimezoneString(timezone) {
|
|
9523
|
+
return timezone == null || timezone === UTC_TIMEZONE_STRING;
|
|
9524
|
+
}
|
|
9525
|
+
/**
|
|
9526
|
+
* Regex for an ISO8601DayString.
|
|
9527
|
+
*/
|
|
9528
|
+
const ISO8601_DAY_STRING_REGEX = /^\d{4,}-\d{2}-\d{2}$/;
|
|
9529
|
+
/**
|
|
9530
|
+
* Regex for a string that starts as an ISO8601DayString.
|
|
9531
|
+
*/
|
|
9532
|
+
const ISO8601_DAY_STRING_START_REGEX = /^\d{4,}-\d{2}-\d{2}/;
|
|
9533
|
+
/**
|
|
9534
|
+
* Returns the start of the input date's UTC time in UTC.
|
|
9535
|
+
*
|
|
9536
|
+
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 returns 2022-01-02
|
|
9537
|
+
*
|
|
9538
|
+
* @param date
|
|
9539
|
+
* @returns
|
|
9540
|
+
*/
|
|
9541
|
+
function startOfDayForUTCDateInUTC(date) {
|
|
9542
|
+
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
|
|
9543
|
+
}
|
|
9544
|
+
/**
|
|
9545
|
+
* Returns the system's date in UTC.
|
|
9546
|
+
*
|
|
9547
|
+
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 (10PM Jan 1st CST) returns 2022-01-01
|
|
9548
|
+
*
|
|
9549
|
+
* @param date
|
|
9550
|
+
* @returns
|
|
9551
|
+
*/
|
|
9552
|
+
function startOfDayForSystemDateInUTC(date) {
|
|
9553
|
+
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
9554
|
+
}
|
|
9555
|
+
/**
|
|
9556
|
+
* Parses a ISO8601DayString to a Date.
|
|
9557
|
+
*
|
|
9558
|
+
* @param inputDateString
|
|
9559
|
+
* @returns
|
|
9560
|
+
*/
|
|
9561
|
+
function parseISO8601DayStringToUTCDate(inputDateString) {
|
|
9562
|
+
const [yearString, monthString, dateString] = inputDateString.split('-');
|
|
9563
|
+
return new Date(Date.UTC(Number(yearString), Number(monthString) - 1, Number(dateString)));
|
|
9564
|
+
}
|
|
9565
|
+
/**
|
|
9566
|
+
* Returns true if the input date is strictly a
|
|
9567
|
+
* @param input
|
|
9568
|
+
* @returns
|
|
9569
|
+
*/
|
|
9570
|
+
function isISO8601DayString(input) {
|
|
9571
|
+
return ISO8601_DAY_STRING_REGEX.test(input);
|
|
9572
|
+
}
|
|
9573
|
+
function isISO8601DayStringStart(input) {
|
|
9574
|
+
return ISO8601_DAY_STRING_START_REGEX.test(input);
|
|
9575
|
+
}
|
|
9576
|
+
/**
|
|
9577
|
+
* Regex for a MonthDaySlashDate.
|
|
9578
|
+
*/
|
|
9579
|
+
const MONTH_DAY_SLASH_DATE_STRING_REGEX = /^\d{1,2}\/\d{1,2}\/\d+$/;
|
|
9580
|
+
function isMonthDaySlashDate(input) {
|
|
9581
|
+
return MONTH_DAY_SLASH_DATE_STRING_REGEX.test(input);
|
|
9582
|
+
}
|
|
9583
|
+
/**
|
|
9584
|
+
* Converts the input MonthDaySlashDate to an ISO8601DayString.
|
|
9585
|
+
*
|
|
9586
|
+
* @param slashDate
|
|
9587
|
+
* @returns
|
|
9588
|
+
*/
|
|
9589
|
+
function monthDaySlashDateToDateString(slashDate) {
|
|
9590
|
+
let [month, day, year] = slashDate.split('/');
|
|
9591
|
+
if (month.length === 1) {
|
|
9592
|
+
month = `0${month}`;
|
|
9593
|
+
}
|
|
9594
|
+
if (day.length === 1) {
|
|
9595
|
+
day = `0${day}`;
|
|
9596
|
+
}
|
|
9597
|
+
if (year.length === 2) {
|
|
9598
|
+
year = `20${year}`;
|
|
9599
|
+
}
|
|
9600
|
+
const result = `${year}-${month}-${day}`;
|
|
9601
|
+
return result;
|
|
9602
|
+
}
|
|
9603
|
+
const HOURS_IN_DAY = 24;
|
|
9604
|
+
const SECONDS_IN_MINUTE = 60;
|
|
9605
|
+
const MINUTES_IN_DAY = 1440;
|
|
9606
|
+
const MINUTES_IN_HOUR = 60;
|
|
9607
|
+
const MS_IN_SECOND = 1000;
|
|
9608
|
+
const MS_IN_MINUTE = MS_IN_SECOND * 60;
|
|
9609
|
+
const MS_IN_HOUR = MS_IN_MINUTE * 60;
|
|
9610
|
+
const MS_IN_DAY = MS_IN_HOUR * HOURS_IN_DAY;
|
|
9611
|
+
/**
|
|
9612
|
+
* Retrieves the MonthOfYear value from the input Date.
|
|
9613
|
+
*
|
|
9614
|
+
* @param date
|
|
9615
|
+
* @returns
|
|
9616
|
+
*/
|
|
9617
|
+
function monthOfYearFromDate(date) {
|
|
9618
|
+
return monthOfYearFromDateMonth(date.getMonth());
|
|
9619
|
+
}
|
|
9620
|
+
function monthOfYearFromDateMonth(dateMonth) {
|
|
9621
|
+
return dateMonth + 1;
|
|
9622
|
+
}
|
|
9623
|
+
function makeDateMonthForMonthOfYear(monthOfYear) {
|
|
9624
|
+
return monthOfYear - 1;
|
|
9625
|
+
}
|
|
9626
|
+
/**
|
|
9627
|
+
* Returns true if the value is a date.
|
|
9628
|
+
*
|
|
9629
|
+
* @param value
|
|
9630
|
+
* @returns
|
|
9631
|
+
*/
|
|
9632
|
+
function isDate(value) {
|
|
9633
|
+
return value instanceof Date || typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]';
|
|
9634
|
+
}
|
|
9635
|
+
|
|
9636
|
+
const FRACTIONAL_HOURS_PRECISION_FUNCTION = cutValueToPrecisionFunction(3);
|
|
9637
|
+
/**
|
|
9638
|
+
* Converts the number of minnutes to a fractional hour.
|
|
9639
|
+
*
|
|
9640
|
+
* Minutes are rounded down.
|
|
9641
|
+
*/
|
|
9642
|
+
function minutesToFractionalHours(minutes) {
|
|
9643
|
+
return FRACTIONAL_HOURS_PRECISION_FUNCTION(Math.floor(minutes) / MINUTES_IN_HOUR);
|
|
9644
|
+
}
|
|
9645
|
+
/**
|
|
9646
|
+
* Converts the fractional hour to a minute.
|
|
9647
|
+
*/
|
|
9648
|
+
function fractionalHoursToMinutes(hours) {
|
|
9649
|
+
return Math.round(hours * MINUTES_IN_HOUR);
|
|
9650
|
+
}
|
|
9651
|
+
/**
|
|
9652
|
+
* Rounds the input hour to the nearest FractionalHour.
|
|
9653
|
+
*
|
|
9654
|
+
* @param hour
|
|
9655
|
+
* @returns
|
|
9656
|
+
*/
|
|
9657
|
+
function hourToFractionalHour(hour) {
|
|
9658
|
+
return minutesToFractionalHours(fractionalHoursToMinutes(hour));
|
|
9659
|
+
}
|
|
9660
|
+
function computeNextFractionalHour(input, change) {
|
|
9661
|
+
let result = input;
|
|
9662
|
+
if (change.minutes) {
|
|
9663
|
+
result += minutesToFractionalHours(change.minutes);
|
|
9664
|
+
}
|
|
9665
|
+
if (change.hours) {
|
|
9666
|
+
result += hourToFractionalHour(change.hours);
|
|
9667
|
+
}
|
|
9668
|
+
return result;
|
|
9669
|
+
}
|
|
9670
|
+
/**
|
|
9671
|
+
* Converts the input number of minutes to the equivalent in hours and minutes.
|
|
9672
|
+
*
|
|
9673
|
+
* @param inputMinutes
|
|
9674
|
+
* @returns
|
|
9675
|
+
*/
|
|
9676
|
+
function minutesToHoursAndMinutes(inputMinutes) {
|
|
9677
|
+
const hour = Math.floor(inputMinutes / 60);
|
|
9678
|
+
const minute = inputMinutes % 60;
|
|
9679
|
+
return {
|
|
9680
|
+
hour,
|
|
9681
|
+
minute
|
|
9682
|
+
};
|
|
9683
|
+
}
|
|
9684
|
+
/**
|
|
9685
|
+
* Reads the hour and minutes of the Date.
|
|
9686
|
+
*
|
|
9687
|
+
* @param date
|
|
9688
|
+
* @returns
|
|
9689
|
+
*/
|
|
9690
|
+
function dateToHoursAndMinutes(date) {
|
|
9691
|
+
const hour = date.getHours();
|
|
9692
|
+
const minute = date.getMinutes();
|
|
9693
|
+
return {
|
|
9694
|
+
hour,
|
|
9695
|
+
minute
|
|
9696
|
+
};
|
|
9697
|
+
}
|
|
9698
|
+
/**
|
|
9699
|
+
* Converts the input hours and minutes to a MinuteOfDay.
|
|
9700
|
+
*
|
|
9701
|
+
* @param hour
|
|
9702
|
+
* @param minute
|
|
9703
|
+
* @returns
|
|
9704
|
+
*/
|
|
9705
|
+
function toMinuteOfDay(hour, minute) {
|
|
9706
|
+
return asMinuteOfDay(hour * 60 + minute);
|
|
9707
|
+
}
|
|
9708
|
+
/**
|
|
9709
|
+
* Creates a new date from the minute of the day.
|
|
9710
|
+
*
|
|
9711
|
+
* @param minuteOfDay
|
|
9712
|
+
* @param day
|
|
9713
|
+
* @returns
|
|
9714
|
+
*/
|
|
9715
|
+
function dateFromMinuteOfDay(minuteOfDay, day) {
|
|
9716
|
+
const date = day || new Date();
|
|
9717
|
+
const {
|
|
9718
|
+
hour,
|
|
9719
|
+
minute
|
|
9720
|
+
} = minutesToHoursAndMinutes(asMinuteOfDay(minuteOfDay));
|
|
9721
|
+
date.setHours(hour, minute, 0, 0);
|
|
9722
|
+
return date;
|
|
9723
|
+
}
|
|
9724
|
+
/**
|
|
9725
|
+
* Converts a Date to a MinuteOfDay.
|
|
9726
|
+
*
|
|
9727
|
+
* @param date
|
|
9728
|
+
* @returns
|
|
9729
|
+
*/
|
|
9730
|
+
function dateToMinuteOfDay(date) {
|
|
9731
|
+
const {
|
|
9732
|
+
hour,
|
|
9733
|
+
minute
|
|
9734
|
+
} = dateToHoursAndMinutes(date);
|
|
9735
|
+
return toMinuteOfDay(hour, minute);
|
|
9736
|
+
}
|
|
9737
|
+
/**
|
|
9738
|
+
* Converts the input minutes to a MinuteOfDay.
|
|
9739
|
+
*
|
|
9740
|
+
* @param minutes
|
|
9741
|
+
* @returns
|
|
9742
|
+
*/
|
|
9743
|
+
function asMinuteOfDay(minutes) {
|
|
9744
|
+
return Math.max(0, minutes % MINUTES_IN_DAY);
|
|
9745
|
+
}
|
|
9746
|
+
|
|
9460
9747
|
/**
|
|
9461
9748
|
* Creates a CronExpression for the input number of minutes.
|
|
9462
9749
|
*
|
|
@@ -9468,13 +9755,13 @@ function compareEqualityWithValueFromItemsFunctionFactory(readValues) {
|
|
|
9468
9755
|
* @returns
|
|
9469
9756
|
*/
|
|
9470
9757
|
function cronExpressionRepeatingEveryNMinutes(inputMinutes) {
|
|
9471
|
-
let minutes;
|
|
9472
|
-
let hours;
|
|
9473
9758
|
let expression;
|
|
9474
9759
|
if (inputMinutes >= 60) {
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9760
|
+
const {
|
|
9761
|
+
hour,
|
|
9762
|
+
minute
|
|
9763
|
+
} = minutesToHoursAndMinutes(inputMinutes);
|
|
9764
|
+
expression = `${minute} */${hour} * * *`; // every nth hour at the given minute
|
|
9478
9765
|
} else {
|
|
9479
9766
|
expression = `*/${inputMinutes} * * * *`; // every nth minute
|
|
9480
9767
|
}
|
|
@@ -13544,154 +13831,6 @@ function randomBoolean(chance = 50) {
|
|
|
13544
13831
|
})();
|
|
13545
13832
|
}
|
|
13546
13833
|
|
|
13547
|
-
/**
|
|
13548
|
-
* TODO: Need to improve to support negative years.
|
|
13549
|
-
*/
|
|
13550
|
-
const ISO_8601_DATE_STRING_REGEX = /(\d{4,})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})(Z|[+-](\d{2})\:(\d{2}))?/;
|
|
13551
|
-
function isISO8601DateString(input) {
|
|
13552
|
-
return ISO_8601_DATE_STRING_REGEX.test(input);
|
|
13553
|
-
}
|
|
13554
|
-
/**
|
|
13555
|
-
* Match examples:
|
|
13556
|
-
*
|
|
13557
|
-
* Sat, 03 Feb 2001 04:05:06 GMT
|
|
13558
|
-
* Tue, 14 Mar 2023 12:34:56 UTC
|
|
13559
|
-
* Wed, 25 May 2024 20:45:07 EST
|
|
13560
|
-
*/
|
|
13561
|
-
const UTC_DATE_STRING_REGEX = /^([a-zA-Z]{3}, [0-9]{2} [a-zA-Z]{3} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3})$/;
|
|
13562
|
-
function isUTCDateString(input) {
|
|
13563
|
-
return UTC_DATE_STRING_REGEX.test(input);
|
|
13564
|
-
}
|
|
13565
|
-
/**
|
|
13566
|
-
* Returns true only if the inputs have the same timezone, or both do not have a timezone set.
|
|
13567
|
-
*
|
|
13568
|
-
* @param a
|
|
13569
|
-
* @param b
|
|
13570
|
-
* @returns
|
|
13571
|
-
*/
|
|
13572
|
-
function hasSameTimezone(a, b) {
|
|
13573
|
-
const tzA = a === null || a === void 0 ? void 0 : a.timezone;
|
|
13574
|
-
const tzB = b === null || b === void 0 ? void 0 : b.timezone;
|
|
13575
|
-
return valuesAreBothNullishOrEquivalent(tzA, tzB);
|
|
13576
|
-
}
|
|
13577
|
-
/**
|
|
13578
|
-
* Constant for the UTC timezone string, "UTC".
|
|
13579
|
-
*/
|
|
13580
|
-
const UTC_TIMEZONE_STRING = 'UTC';
|
|
13581
|
-
function isConsideredUtcTimezoneString(timezone) {
|
|
13582
|
-
return timezone == null || timezone === UTC_TIMEZONE_STRING;
|
|
13583
|
-
}
|
|
13584
|
-
/**
|
|
13585
|
-
* Regex for an ISO8601DayString.
|
|
13586
|
-
*/
|
|
13587
|
-
const ISO8601_DAY_STRING_REGEX = /^\d{4,}-\d{2}-\d{2}$/;
|
|
13588
|
-
/**
|
|
13589
|
-
* Regex for a string that starts as an ISO8601DayString.
|
|
13590
|
-
*/
|
|
13591
|
-
const ISO8601_DAY_STRING_START_REGEX = /^\d{4,}-\d{2}-\d{2}/;
|
|
13592
|
-
/**
|
|
13593
|
-
* Returns the start of the input date's UTC time in UTC.
|
|
13594
|
-
*
|
|
13595
|
-
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 returns 2022-01-02
|
|
13596
|
-
*
|
|
13597
|
-
* @param date
|
|
13598
|
-
* @returns
|
|
13599
|
-
*/
|
|
13600
|
-
function startOfDayForUTCDateInUTC(date) {
|
|
13601
|
-
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
|
|
13602
|
-
}
|
|
13603
|
-
/**
|
|
13604
|
-
* Returns the system's date in UTC.
|
|
13605
|
-
*
|
|
13606
|
-
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 (10PM Jan 1st CST) returns 2022-01-01
|
|
13607
|
-
*
|
|
13608
|
-
* @param date
|
|
13609
|
-
* @returns
|
|
13610
|
-
*/
|
|
13611
|
-
function startOfDayForSystemDateInUTC(date) {
|
|
13612
|
-
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
13613
|
-
}
|
|
13614
|
-
/**
|
|
13615
|
-
* Parses a ISO8601DayString to a Date.
|
|
13616
|
-
*
|
|
13617
|
-
* @param inputDateString
|
|
13618
|
-
* @returns
|
|
13619
|
-
*/
|
|
13620
|
-
function parseISO8601DayStringToUTCDate(inputDateString) {
|
|
13621
|
-
const [yearString, monthString, dateString] = inputDateString.split('-');
|
|
13622
|
-
return new Date(Date.UTC(Number(yearString), Number(monthString) - 1, Number(dateString)));
|
|
13623
|
-
}
|
|
13624
|
-
/**
|
|
13625
|
-
* Returns true if the input date is strictly a
|
|
13626
|
-
* @param input
|
|
13627
|
-
* @returns
|
|
13628
|
-
*/
|
|
13629
|
-
function isISO8601DayString(input) {
|
|
13630
|
-
return ISO8601_DAY_STRING_REGEX.test(input);
|
|
13631
|
-
}
|
|
13632
|
-
function isISO8601DayStringStart(input) {
|
|
13633
|
-
return ISO8601_DAY_STRING_START_REGEX.test(input);
|
|
13634
|
-
}
|
|
13635
|
-
/**
|
|
13636
|
-
* Regex for a MonthDaySlashDate.
|
|
13637
|
-
*/
|
|
13638
|
-
const MONTH_DAY_SLASH_DATE_STRING_REGEX = /^\d{1,2}\/\d{1,2}\/\d+$/;
|
|
13639
|
-
function isMonthDaySlashDate(input) {
|
|
13640
|
-
return MONTH_DAY_SLASH_DATE_STRING_REGEX.test(input);
|
|
13641
|
-
}
|
|
13642
|
-
/**
|
|
13643
|
-
* Converts the input MonthDaySlashDate to an ISO8601DayString.
|
|
13644
|
-
*
|
|
13645
|
-
* @param slashDate
|
|
13646
|
-
* @returns
|
|
13647
|
-
*/
|
|
13648
|
-
function monthDaySlashDateToDateString(slashDate) {
|
|
13649
|
-
let [month, day, year] = slashDate.split('/');
|
|
13650
|
-
if (month.length === 1) {
|
|
13651
|
-
month = `0${month}`;
|
|
13652
|
-
}
|
|
13653
|
-
if (day.length === 1) {
|
|
13654
|
-
day = `0${day}`;
|
|
13655
|
-
}
|
|
13656
|
-
if (year.length === 2) {
|
|
13657
|
-
year = `20${year}`;
|
|
13658
|
-
}
|
|
13659
|
-
const result = `${year}-${month}-${day}`;
|
|
13660
|
-
return result;
|
|
13661
|
-
}
|
|
13662
|
-
const HOURS_IN_DAY = 24;
|
|
13663
|
-
const SECONDS_IN_MINUTE = 60;
|
|
13664
|
-
const MINUTES_IN_DAY = 1440;
|
|
13665
|
-
const MINUTES_IN_HOUR = 60;
|
|
13666
|
-
const MS_IN_SECOND = 1000;
|
|
13667
|
-
const MS_IN_MINUTE = MS_IN_SECOND * 60;
|
|
13668
|
-
const MS_IN_HOUR = MS_IN_MINUTE * 60;
|
|
13669
|
-
const MS_IN_DAY = MS_IN_HOUR * HOURS_IN_DAY;
|
|
13670
|
-
/**
|
|
13671
|
-
* Retrieves the MonthOfYear value from the input Date.
|
|
13672
|
-
*
|
|
13673
|
-
* @param date
|
|
13674
|
-
* @returns
|
|
13675
|
-
*/
|
|
13676
|
-
function monthOfYearFromDate(date) {
|
|
13677
|
-
return monthOfYearFromDateMonth(date.getMonth());
|
|
13678
|
-
}
|
|
13679
|
-
function monthOfYearFromDateMonth(dateMonth) {
|
|
13680
|
-
return dateMonth + 1;
|
|
13681
|
-
}
|
|
13682
|
-
function makeDateMonthForMonthOfYear(monthOfYear) {
|
|
13683
|
-
return monthOfYear - 1;
|
|
13684
|
-
}
|
|
13685
|
-
/**
|
|
13686
|
-
* Returns true if the value is a date.
|
|
13687
|
-
*
|
|
13688
|
-
* @param value
|
|
13689
|
-
* @returns
|
|
13690
|
-
*/
|
|
13691
|
-
function isDate(value) {
|
|
13692
|
-
return value instanceof Date || typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]';
|
|
13693
|
-
}
|
|
13694
|
-
|
|
13695
13834
|
/**
|
|
13696
13835
|
* Returns the day of the week for the input day.
|
|
13697
13836
|
*
|
|
@@ -13849,41 +13988,6 @@ function getNextDay(day, days = 1) {
|
|
|
13849
13988
|
return result;
|
|
13850
13989
|
}
|
|
13851
13990
|
|
|
13852
|
-
const FRACTIONAL_HOURS_PRECISION_FUNCTION = cutValueToPrecisionFunction(3);
|
|
13853
|
-
/**
|
|
13854
|
-
* Converts the number of minnutes to a fractional hour.
|
|
13855
|
-
*
|
|
13856
|
-
* Minutes are rounded down.
|
|
13857
|
-
*/
|
|
13858
|
-
function minutesToFractionalHours(minutes) {
|
|
13859
|
-
return FRACTIONAL_HOURS_PRECISION_FUNCTION(Math.floor(minutes) / MINUTES_IN_HOUR);
|
|
13860
|
-
}
|
|
13861
|
-
/**
|
|
13862
|
-
* Converts the fractional hour to a minute.
|
|
13863
|
-
*/
|
|
13864
|
-
function fractionalHoursToMinutes(hours) {
|
|
13865
|
-
return Math.round(hours * MINUTES_IN_HOUR);
|
|
13866
|
-
}
|
|
13867
|
-
/**
|
|
13868
|
-
* Rounds the input hour to the nearest FractionalHour.
|
|
13869
|
-
*
|
|
13870
|
-
* @param hour
|
|
13871
|
-
* @returns
|
|
13872
|
-
*/
|
|
13873
|
-
function hourToFractionalHour(hour) {
|
|
13874
|
-
return minutesToFractionalHours(fractionalHoursToMinutes(hour));
|
|
13875
|
-
}
|
|
13876
|
-
function computeNextFractionalHour(input, change) {
|
|
13877
|
-
let result = input;
|
|
13878
|
-
if (change.minutes) {
|
|
13879
|
-
result += minutesToFractionalHours(change.minutes);
|
|
13880
|
-
}
|
|
13881
|
-
if (change.hours) {
|
|
13882
|
-
result += hourToFractionalHour(change.hours);
|
|
13883
|
-
}
|
|
13884
|
-
return result;
|
|
13885
|
-
}
|
|
13886
|
-
|
|
13887
13991
|
function timePeriodCounter(timePeriodLength, lastTimePeriodStart) {
|
|
13888
13992
|
function reset(inputStart) {
|
|
13889
13993
|
const start = inputStart !== null && inputStart !== void 0 ? inputStart : new Date();
|
|
@@ -14376,6 +14480,7 @@ exports.asDecisionFunction = asDecisionFunction;
|
|
|
14376
14480
|
exports.asGetter = asGetter;
|
|
14377
14481
|
exports.asIndexRangeCheckFunctionConfig = asIndexRangeCheckFunctionConfig;
|
|
14378
14482
|
exports.asIterable = asIterable;
|
|
14483
|
+
exports.asMinuteOfDay = asMinuteOfDay;
|
|
14379
14484
|
exports.asNumber = asNumber;
|
|
14380
14485
|
exports.asObjectCopyFactory = asObjectCopyFactory;
|
|
14381
14486
|
exports.asPromise = asPromise;
|
|
@@ -14444,6 +14549,9 @@ exports.cutValueToInteger = cutValueToInteger;
|
|
|
14444
14549
|
exports.cutValueToPrecision = cutValueToPrecision;
|
|
14445
14550
|
exports.cutValueToPrecisionFunction = cutValueToPrecisionFunction;
|
|
14446
14551
|
exports.dateFromLogicalDate = dateFromLogicalDate;
|
|
14552
|
+
exports.dateFromMinuteOfDay = dateFromMinuteOfDay;
|
|
14553
|
+
exports.dateToHoursAndMinutes = dateToHoursAndMinutes;
|
|
14554
|
+
exports.dateToMinuteOfDay = dateToMinuteOfDay;
|
|
14447
14555
|
exports.dayOfWeek = dayOfWeek;
|
|
14448
14556
|
exports.daysOfWeekArray = daysOfWeekArray;
|
|
14449
14557
|
exports.daysOfWeekFromEnabledDays = daysOfWeekFromEnabledDays;
|
|
@@ -14669,6 +14777,7 @@ exports.isolateWebsitePathFunction = isolateWebsitePathFunction;
|
|
|
14669
14777
|
exports.itemCountForBatchIndex = itemCountForBatchIndex;
|
|
14670
14778
|
exports.iterableToArray = iterableToArray;
|
|
14671
14779
|
exports.iterableToMap = iterableToMap;
|
|
14780
|
+
exports.iterableToSet = iterableToSet;
|
|
14672
14781
|
exports.iterablesAreSetEquivalent = iterablesAreSetEquivalent;
|
|
14673
14782
|
exports.iterate = iterate;
|
|
14674
14783
|
exports.iterateFilteredPages = iterateFilteredPages;
|
|
@@ -14767,6 +14876,7 @@ exports.minAndMaxIndexFunction = minAndMaxIndexFunction;
|
|
|
14767
14876
|
exports.minAndMaxIndexItemsFunction = minAndMaxIndexItemsFunction;
|
|
14768
14877
|
exports.minAndMaxNumber = minAndMaxNumber;
|
|
14769
14878
|
exports.minutesToFractionalHours = minutesToFractionalHours;
|
|
14879
|
+
exports.minutesToHoursAndMinutes = minutesToHoursAndMinutes;
|
|
14770
14880
|
exports.modelFieldConversions = modelFieldConversions;
|
|
14771
14881
|
exports.modelFieldMapFunction = modelFieldMapFunction;
|
|
14772
14882
|
exports.modelFieldMapFunctions = modelFieldMapFunctions;
|
|
@@ -14985,6 +15095,7 @@ exports.timePeriodCounter = timePeriodCounter;
|
|
|
14985
15095
|
exports.timer = timer;
|
|
14986
15096
|
exports.toAbsoluteSlashPathStartType = toAbsoluteSlashPathStartType;
|
|
14987
15097
|
exports.toCaseInsensitiveStringArray = toCaseInsensitiveStringArray;
|
|
15098
|
+
exports.toMinuteOfDay = toMinuteOfDay;
|
|
14988
15099
|
exports.toModelFieldConversions = toModelFieldConversions;
|
|
14989
15100
|
exports.toModelMapFunctions = toModelMapFunctions;
|
|
14990
15101
|
exports.toReadableError = toReadableError;
|