@trackunit/date-and-time-utils 0.0.52 → 0.0.53
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/index.cjs.js +11 -1
- package/index.esm.js +11 -2
- package/package.json +1 -1
- package/src/DateAndTimeUtils.d.ts +5 -0
package/index.cjs.js
CHANGED
|
@@ -52,8 +52,9 @@ const getHourCycle = (locale) => {
|
|
|
52
52
|
}
|
|
53
53
|
// Some browser e.g. apparently the latest chrome have a cycle defined here,
|
|
54
54
|
// but not in intl.hourCycle
|
|
55
|
+
const hourCycles =
|
|
55
56
|
// @ts-ignore
|
|
56
|
-
|
|
57
|
+
intl.hourCycles || (typeof intl.getHourCycles === "function" && intl.getHourCycles());
|
|
57
58
|
if (Array.isArray(hourCycles) && hourCycles[0]) {
|
|
58
59
|
return hourCycles[0];
|
|
59
60
|
}
|
|
@@ -1606,6 +1607,14 @@ const startOfWeek = (date, weekStartsOn) => {
|
|
|
1606
1607
|
const diff = (dayOfWeek - weekStartsOn + 7) % 7;
|
|
1607
1608
|
return date.subtract({ days: diff });
|
|
1608
1609
|
};
|
|
1610
|
+
/**
|
|
1611
|
+
*
|
|
1612
|
+
* @param date - The date to check if it is valid.
|
|
1613
|
+
*/
|
|
1614
|
+
const isValidDate = (date) => {
|
|
1615
|
+
const isDate = new Date(date).getTime();
|
|
1616
|
+
return !isNaN(isDate);
|
|
1617
|
+
};
|
|
1609
1618
|
|
|
1610
1619
|
exports.addDaysUtil = addDaysUtil;
|
|
1611
1620
|
exports.addHoursUtil = addHoursUtil;
|
|
@@ -1648,6 +1657,7 @@ exports.isSameMonthUtil = isSameMonthUtil;
|
|
|
1648
1657
|
exports.isSameWeekUtil = isSameWeekUtil;
|
|
1649
1658
|
exports.isSameYearUtil = isSameYearUtil;
|
|
1650
1659
|
exports.isTodayUtil = isTodayUtil;
|
|
1660
|
+
exports.isValidDate = isValidDate;
|
|
1651
1661
|
exports.monthNameUtil = monthNameUtil;
|
|
1652
1662
|
exports.monthsUtil = monthsUtil;
|
|
1653
1663
|
exports.startOfDayUtil = startOfDayUtil;
|
package/index.esm.js
CHANGED
|
@@ -50,8 +50,9 @@ const getHourCycle = (locale) => {
|
|
|
50
50
|
}
|
|
51
51
|
// Some browser e.g. apparently the latest chrome have a cycle defined here,
|
|
52
52
|
// but not in intl.hourCycle
|
|
53
|
+
const hourCycles =
|
|
53
54
|
// @ts-ignore
|
|
54
|
-
|
|
55
|
+
intl.hourCycles || (typeof intl.getHourCycles === "function" && intl.getHourCycles());
|
|
55
56
|
if (Array.isArray(hourCycles) && hourCycles[0]) {
|
|
56
57
|
return hourCycles[0];
|
|
57
58
|
}
|
|
@@ -1604,5 +1605,13 @@ const startOfWeek = (date, weekStartsOn) => {
|
|
|
1604
1605
|
const diff = (dayOfWeek - weekStartsOn + 7) % 7;
|
|
1605
1606
|
return date.subtract({ days: diff });
|
|
1606
1607
|
};
|
|
1608
|
+
/**
|
|
1609
|
+
*
|
|
1610
|
+
* @param date - The date to check if it is valid.
|
|
1611
|
+
*/
|
|
1612
|
+
const isValidDate = (date) => {
|
|
1613
|
+
const isDate = new Date(date).getTime();
|
|
1614
|
+
return !isNaN(isDate);
|
|
1615
|
+
};
|
|
1607
1616
|
|
|
1608
|
-
export { addDaysUtil, addHoursUtil, addMinutesUtil, addMonthsUtil, addWeeksUtil, addYearsUtil, convertHoursUtil, convertMillisecondsUtil, convertMinutesUtil, convertSecondsUtil, dayNameUtil, daysUtil, differenceInDaysUtil, differenceInHoursUtil, differenceInMinutesUtil, differenceInMonthsUtil, differenceInSecondsUtil, differenceInWeeksUtil, differenceInYearsUtil, endOfDayUtil, endOfHourUtil, endOfMinuteUtil, endOfMonthUtil, endOfWeekUtil, formatDateUtil, formatRangeUtil, getDurationFormat, getHourCycle, getTimeZone, getTimeZoneOffset, getUTCFromTimeZonedUtil, getWeekUtil, isBetweenUtil, isEqualUtil, isFutureUtil, isPastUtil, isSameDayUtil, isSameMonthUtil, isSameWeekUtil, isSameYearUtil, isTodayUtil, monthNameUtil, monthsUtil, startOfDayUtil, startOfHourUtil, startOfMinuteUtil, startOfMonthUtil, startOfWeekUtil, subtractDaysUtil, subtractHoursUtil, subtractMinutesUtil, subtractMonthsUtil, subtractWeeksUtil, subtractYearsUtil, timeSinceAuto, timeSinceInDays, timeSinceInHours, timeSinceInMinutes, timeSinceInMonths, timeSinceInSeconds, timeSinceInYears, timeZonesAvailable, toDateUtil, toDuration, toInstantUtil, toTemporalUtil, toZonedDateTimeUtil };
|
|
1617
|
+
export { addDaysUtil, addHoursUtil, addMinutesUtil, addMonthsUtil, addWeeksUtil, addYearsUtil, convertHoursUtil, convertMillisecondsUtil, convertMinutesUtil, convertSecondsUtil, dayNameUtil, daysUtil, differenceInDaysUtil, differenceInHoursUtil, differenceInMinutesUtil, differenceInMonthsUtil, differenceInSecondsUtil, differenceInWeeksUtil, differenceInYearsUtil, endOfDayUtil, endOfHourUtil, endOfMinuteUtil, endOfMonthUtil, endOfWeekUtil, formatDateUtil, formatRangeUtil, getDurationFormat, getHourCycle, getTimeZone, getTimeZoneOffset, getUTCFromTimeZonedUtil, getWeekUtil, isBetweenUtil, isEqualUtil, isFutureUtil, isPastUtil, isSameDayUtil, isSameMonthUtil, isSameWeekUtil, isSameYearUtil, isTodayUtil, isValidDate, monthNameUtil, monthsUtil, startOfDayUtil, startOfHourUtil, startOfMinuteUtil, startOfMonthUtil, startOfWeekUtil, subtractDaysUtil, subtractHoursUtil, subtractMinutesUtil, subtractMonthsUtil, subtractWeeksUtil, subtractYearsUtil, timeSinceAuto, timeSinceInDays, timeSinceInHours, timeSinceInMinutes, timeSinceInMonths, timeSinceInSeconds, timeSinceInYears, timeZonesAvailable, toDateUtil, toDuration, toInstantUtil, toTemporalUtil, toZonedDateTimeUtil };
|
package/package.json
CHANGED
|
@@ -1019,4 +1019,9 @@ export declare const convertMinutesUtil: (minutes: number, unit: Extract<Tempora
|
|
|
1019
1019
|
* //=> 48
|
|
1020
1020
|
*/
|
|
1021
1021
|
export declare const convertHoursUtil: (hours: number, unit: Extract<Temporal.TimeUnit, "hour" | "minute" | "second" | "millisecond">) => number;
|
|
1022
|
+
/**
|
|
1023
|
+
*
|
|
1024
|
+
* @param date - The date to check if it is valid.
|
|
1025
|
+
*/
|
|
1026
|
+
export declare const isValidDate: (date: Date | string | number) => boolean;
|
|
1022
1027
|
export {};
|