: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param date - The date that should be before the other one to return true
* @param dateToCompare - The date to compare with
* @returns The first date is before the second date
* // Is 10 July 1989 before 11 February 1987?
* const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
function isBefore(date, dateToCompare) {
const _date = toDate(date);
const _dateToCompare = toDate(dateToCompare);
return +_date < +_dateToCompare;
* @category Common Helpers
* @summary Are the given dates equal?
* Are the given dates equal?
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param dateLeft - The first date to compare
* @param dateRight - The second date to compare
* @returns The dates are equal
* // Are 2 July 2014 06:30:45.000 and 2 July 2014 06:30:45.500 equal?
* const result = isEqual(
* new Date(2014, 6, 2, 6, 30, 45, 0),
* new Date(2014, 6, 2, 6, 30, 45, 500)
function isEqual(leftDate, rightDate) {
const _dateLeft = toDate(leftDate);
const _dateRight = toDate(rightDate);
return +_dateLeft === +_dateRight;
* @category Month Helpers
* @summary Set the month to the given date.
* Set the month to the given date.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param date - The date to be changed
* @param month - The month index to set (0-11)
* @returns The new date with the month set
* // Set February to 1 September 2014:
* const result = setMonth(new Date(2014, 8, 1), 1)
* //=> Sat Feb 01 2014 00:00:00
function setMonth(date, month) {
const _date = toDate(date);
const year = _date.getFullYear();
const day = _date.getDate();
const dateWithDesiredMonth = constructFrom(date, 0);
dateWithDesiredMonth.setFullYear(year, month, 15);
dateWithDesiredMonth.setHours(0, 0, 0, 0);
const daysInMonth = getDaysInMonth(dateWithDesiredMonth);
// Set the last day of the new month
// if the original date was the last day of the longer month
_date.setMonth(month, Math.min(day, daysInMonth));
* @category Common Helpers
* @summary Set date values to a given date.
* Set date values to a given date.
* Sets time values to date from object `values`.
* A value is not set if it is undefined or null or doesn't exist in `values`.
* Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts
* to use native `Date#setX` methods. If you use this function, you may not want to include the
* other `setX` functions that date-fns provides if you are concerned about the bundle size.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param date - The date to be changed
* @param values - The date values to be set
* @returns The new date with options set
* // Transform 1 September 2014 into 20 October 2015 in a single line:
* const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })
* //=> Tue Oct 20 2015 00:00:00
* // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:
* const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })
* //=> Mon Sep 01 2014 12:23:45
function set(date, values) {
let _date = toDate(date);
// Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
return constructFrom(date, NaN);
if (values.year != null) {
_date.setFullYear(values.year);
if (values.month != null) {
_date = setMonth(_date, values.month);
if (values.date != null) {
_date.setDate(values.date);
if (values.hours != null) {
_date.setHours(values.hours);
if (values.minutes != null) {
_date.setMinutes(values.minutes);
if (values.seconds != null) {
_date.setSeconds(values.seconds);
if (values.milliseconds != null) {
_date.setMilliseconds(values.milliseconds);
* @summary Set the year to the given date.
* Set the year to the given date.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param date - The date to be changed
* @param year - The year of the new date
* @returns The new date with the year set
* // Set year 2013 to 1 September 2014:
* const result = setYear(new Date(2014, 8, 1), 2013)
* //=> Sun Sep 01 2013 00:00:00
function setYear(date, year) {
const _date = toDate(date);
// Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
return constructFrom(date, NaN);
* @summary Return the start of today.
* Return the start of today.
* @returns The start of today
* // If today is 6 October 2014:
* const result = startOfToday()
* //=> Mon Oct 6 2014 00:00:00
function startOfToday() {
return startOfDay(Date.now());
* @category Month Helpers
* @summary Subtract the specified number of months from the given date.
* Subtract the specified number of months from the given date.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param date - The date to be changed
* @param amount - The amount of months to be subtracted.
* @returns The new date with the months subtracted
* // Subtract 5 months from 1 February 2015:
* const result = subMonths(new Date(2015, 1, 1), 5)
* //=> Mon Sep 01 2014 00:00:00
function subMonths(date, amount) {
return addMonths(date, -amount);
* @summary Subtract the specified number of years from the given date.
* Subtract the specified number of years from the given date.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param date - The date to be changed
* @param amount - The amount of years to be subtracted.
* @returns The new date with the years subtracted
* // Subtract 5 years from 1 September 2014:
* const result = subYears(new Date(2014, 8, 1), 5)
* //=> Tue Sep 01 2009 00:00:00
function subYears(date, amount) {
return addYears(date, -amount);
Month[Month["JANUARY"] = 0] = "JANUARY";
Month[Month["FEBRUARY"] = 1] = "FEBRUARY";
Month[Month["MARCH"] = 2] = "MARCH";
Month[Month["APRIL"] = 3] = "APRIL";
Month[Month["MAY"] = 4] = "MAY";
Month[Month["JUNE"] = 5] = "JUNE";
Month[Month["JULY"] = 6] = "JULY";
Month[Month["AUGUST"] = 7] = "AUGUST";
Month[Month["SEPTEMBER"] = 8] = "SEPTEMBER";
Month[Month["OCTOBER"] = 9] = "OCTOBER";
Month[Month["NOVEMBER"] = 10] = "NOVEMBER";
Month[Month["DECEMBER"] = 11] = "DECEMBER";
})(Month || (Month = {}));
Day[Day["SUNDAY"] = 0] = "SUNDAY";
Day[Day["MONDAY"] = 1] = "MONDAY";
Day[Day["TUESDAY"] = 2] = "TUESDAY";
Day[Day["WEDNESDAY"] = 3] = "WEDNESDAY";
Day[Day["THURSDAY"] = 4] = "THURSDAY";
Day[Day["FRIDAY"] = 5] = "FRIDAY";
Day[Day["SATURDAY"] = 6] = "SATURDAY";
var inRange = function (date, min, max) {
return (isEqual(date, min) || isAfter(date, min)) && (isEqual(date, max) || isBefore(date, max));
var index_es_clearTime = function (date) { return set(date, { hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }); };
var useLilius = function (_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.weekStartsOn, weekStartsOn = _c === void 0 ? Day.SUNDAY : _c, _d = _b.viewing, initialViewing = _d === void 0 ? new Date() : _d, _e = _b.selected, initialSelected = _e === void 0 ? [] : _e, _f = _b.numberOfMonths, numberOfMonths = _f === void 0 ? 1 : _f;
var _g = (0,external_React_.useState)(initialViewing), viewing = _g[0], setViewing = _g[1];
var viewToday = (0,external_React_.useCallback)(function () { return setViewing(startOfToday()); }, [setViewing]);
var viewMonth = (0,external_React_.useCallback)(function (month) { return setViewing(function (v) { return setMonth(v, month); }); }, []);
var viewPreviousMonth = (0,external_React_.useCallback)(function () { return setViewing(function (v) { return subMonths(v, 1); }); }, []);
var viewNextMonth = (0,external_React_.useCallback)(function () { return setViewing(function (v) { return addMonths(v, 1); }); }, []);
var viewYear = (0,external_React_.useCallback)(function (year) { return setViewing(function (v) { return setYear(v, year); }); }, []);
var viewPreviousYear = (0,external_React_.useCallback)(function () { return setViewing(function (v) { return subYears(v, 1); }); }, []);
var viewNextYear = (0,external_React_.useCallback)(function () { return setViewing(function (v) { return addYears(v, 1); }); }, []);
var _h = (0,external_React_.useState)(initialSelected.map(index_es_clearTime)), selected = _h[0], setSelected = _h[1];
var clearSelected = function () { return setSelected([]); };
var isSelected = (0,external_React_.useCallback)(function (date) { return selected.findIndex(function (s) { return isEqual(s, date); }) > -1; }, [selected]);
var select = (0,external_React_.useCallback)(function (date, replaceExisting) {
setSelected(Array.isArray(date) ? date : [date]);
setSelected(function (selectedItems) { return selectedItems.concat(Array.isArray(date) ? date : [date]); });
var deselect = (0,external_React_.useCallback)(function (date) {
return setSelected(function (selectedItems) {
return Array.isArray(date)
? selectedItems.filter(function (s) { return !date.map(function (d) { return d.getTime(); }).includes(s.getTime()); })
: selectedItems.filter(function (s) { return !isEqual(s, date); });
var toggle = (0,external_React_.useCallback)(function (date, replaceExisting) { return (isSelected(date) ? deselect(date) : select(date, replaceExisting)); }, [deselect, isSelected, select]);
var selectRange = (0,external_React_.useCallback)(function (start, end, replaceExisting) {
setSelected(eachDayOfInterval({ start: start, end: end }));
setSelected(function (selectedItems) { return selectedItems.concat(eachDayOfInterval({ start: start, end: end })); });
var deselectRange = (0,external_React_.useCallback)(function (start, end) {
setSelected(function (selectedItems) {
return selectedItems.filter(function (s) {
return !eachDayOfInterval({ start: start, end: end })
.map(function (d) { return d.getTime(); })
var calendar = (0,external_React_.useMemo)(function () {
return eachMonthOfInterval({
start: startOfMonth(viewing),
end: endOfMonth(addMonths(viewing, numberOfMonths - 1)),
}).map(function (month) {
return eachWeekOfInterval({
start: startOfMonth(month),
}, { weekStartsOn: weekStartsOn }).map(function (week) {
return eachDayOfInterval({
start: startOfWeek(week, { weekStartsOn: weekStartsOn }),
end: endOfWeek(week, { weekStartsOn: weekStartsOn }),
}, [viewing, weekStartsOn, numberOfMonths]);
clearTime: index_es_clearTime,
viewPreviousMonth: viewPreviousMonth,
viewNextMonth: viewNextMonth,
viewPreviousYear: viewPreviousYear,
viewNextYear: viewNextYear,
setSelected: setSelected,
clearSelected: clearSelected,
selectRange: selectRange,
deselectRange: deselectRange,
;// CONCATENATED MODULE: ./node_modules/date-fns/toDate.mjs
* @category Common Helpers
* @summary Convert the given argument to an instance of Date.
* Convert the given argument to an instance of Date.
* If the argument is an instance of Date, the function returns its clone.
* If the argument is a number, it is treated as a timestamp.
* If the argument is none of the above, the function returns Invalid Date.
* **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param argument - The value to convert
* @returns The parsed date in the local time zone
* const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
* //=> Tue Feb 11 2014 11:30:30
* // Convert the timestamp to date:
* const result = toDate(1392098430000)
* //=> Tue Feb 11 2014 11:30:30
function toDate_toDate(argument) {
const argStr = Object.prototype.toString.call(argument);
argument instanceof Date ||
(typeof argument === "object" && argStr === "[object Date]")
// Prevent the date to lose the milliseconds when passed to new Date() in IE10
return new argument.constructor(+argument);
typeof argument === "number" ||
argStr === "[object Number]" ||
typeof argument === "string" ||
argStr === "[object String]"
// TODO: Can we get rid of as?
return new Date(argument);
// TODO: Can we get rid of as?
// Fallback for modularized imports:
/* harmony default export */ const date_fns_toDate = ((/* unused pure expression or super */ null && (toDate_toDate)));
;// CONCATENATED MODULE: ./node_modules/date-fns/startOfDay.mjs
* @summary Return the start of a day for the given date.
* Return the start of a day for the given date.
* The result will be in the local timezone.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param date - The original date
* @returns The start of a day
* // The start of a day for 2 September 2014 11:55:00:
* const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
* //=> Tue Sep 02 2014 00:00:00
function startOfDay_startOfDay(date) {
const _date = toDate_toDate(date);
_date.setHours(0, 0, 0, 0);
// Fallback for modularized imports:
/* harmony default export */ const date_fns_startOfDay = ((/* unused pure expression or super */ null && (startOfDay_startOfDay)));
;// CONCATENATED MODULE: ./node_modules/date-fns/constructFrom.mjs
* @category Generic Helpers
* @summary Constructs a date using the reference date and the value
* The function constructs a new date using the constructor from the reference
* date and the given value. It helps to build generic functions that accept
* It defaults to `Date` if the passed reference date is a number or a string.
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @param date - The reference date to take constructor from
* @param value - The value to create the date
* @returns Date initialized using the given date and value
* import { constructFrom } from 'date-fns'
* // A function that clones a date preserving the original type
* function cloneDate<DateType extends Date(date: DateType): DateType {
* date, // Use contrustor from the given date
* date.getTime() // Use the date value to create a new date
function constructFrom_constructFrom(date, value) {
if (date instanceof Date) {
return new date.constructor(value);