Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: components.js
_date.setFullYear(
[52000] Fix | Delete
endOfDesiredMonth.getFullYear(),
[52001] Fix | Delete
endOfDesiredMonth.getMonth(),
[52002] Fix | Delete
dayOfMonth,
[52003] Fix | Delete
);
[52004] Fix | Delete
return _date;
[52005] Fix | Delete
}
[52006] Fix | Delete
}
[52007] Fix | Delete
[52008] Fix | Delete
let index_es_defaultOptions = {};
[52009] Fix | Delete
[52010] Fix | Delete
function getDefaultOptions() {
[52011] Fix | Delete
return index_es_defaultOptions;
[52012] Fix | Delete
}
[52013] Fix | Delete
[52014] Fix | Delete
/**
[52015] Fix | Delete
* The {@link startOfWeek} function options.
[52016] Fix | Delete
*/
[52017] Fix | Delete
[52018] Fix | Delete
/**
[52019] Fix | Delete
* @name startOfWeek
[52020] Fix | Delete
* @category Week Helpers
[52021] Fix | Delete
* @summary Return the start of a week for the given date.
[52022] Fix | Delete
*
[52023] Fix | Delete
* @description
[52024] Fix | Delete
* Return the start of a week for the given date.
[52025] Fix | Delete
* The result will be in the local timezone.
[52026] Fix | Delete
*
[52027] Fix | Delete
* @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).
[52028] Fix | Delete
*
[52029] Fix | Delete
* @param date - The original date
[52030] Fix | Delete
* @param options - An object with options
[52031] Fix | Delete
*
[52032] Fix | Delete
* @returns The start of a week
[52033] Fix | Delete
*
[52034] Fix | Delete
* @example
[52035] Fix | Delete
* // The start of a week for 2 September 2014 11:55:00:
[52036] Fix | Delete
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
[52037] Fix | Delete
* //=> Sun Aug 31 2014 00:00:00
[52038] Fix | Delete
*
[52039] Fix | Delete
* @example
[52040] Fix | Delete
* // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
[52041] Fix | Delete
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
[52042] Fix | Delete
* //=> Mon Sep 01 2014 00:00:00
[52043] Fix | Delete
*/
[52044] Fix | Delete
function startOfWeek(date, options) {
[52045] Fix | Delete
const defaultOptions = getDefaultOptions();
[52046] Fix | Delete
const weekStartsOn =
[52047] Fix | Delete
options?.weekStartsOn ??
[52048] Fix | Delete
options?.locale?.options?.weekStartsOn ??
[52049] Fix | Delete
defaultOptions.weekStartsOn ??
[52050] Fix | Delete
defaultOptions.locale?.options?.weekStartsOn ??
[52051] Fix | Delete
0;
[52052] Fix | Delete
[52053] Fix | Delete
const _date = toDate(date);
[52054] Fix | Delete
const day = _date.getDay();
[52055] Fix | Delete
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
[52056] Fix | Delete
[52057] Fix | Delete
_date.setDate(_date.getDate() - diff);
[52058] Fix | Delete
_date.setHours(0, 0, 0, 0);
[52059] Fix | Delete
return _date;
[52060] Fix | Delete
}
[52061] Fix | Delete
[52062] Fix | Delete
/**
[52063] Fix | Delete
* @name startOfDay
[52064] Fix | Delete
* @category Day Helpers
[52065] Fix | Delete
* @summary Return the start of a day for the given date.
[52066] Fix | Delete
*
[52067] Fix | Delete
* @description
[52068] Fix | Delete
* Return the start of a day for the given date.
[52069] Fix | Delete
* The result will be in the local timezone.
[52070] Fix | Delete
*
[52071] Fix | Delete
* @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).
[52072] Fix | Delete
*
[52073] Fix | Delete
* @param date - The original date
[52074] Fix | Delete
*
[52075] Fix | Delete
* @returns The start of a day
[52076] Fix | Delete
*
[52077] Fix | Delete
* @example
[52078] Fix | Delete
* // The start of a day for 2 September 2014 11:55:00:
[52079] Fix | Delete
* const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
[52080] Fix | Delete
* //=> Tue Sep 02 2014 00:00:00
[52081] Fix | Delete
*/
[52082] Fix | Delete
function startOfDay(date) {
[52083] Fix | Delete
const _date = toDate(date);
[52084] Fix | Delete
_date.setHours(0, 0, 0, 0);
[52085] Fix | Delete
return _date;
[52086] Fix | Delete
}
[52087] Fix | Delete
[52088] Fix | Delete
/**
[52089] Fix | Delete
* @name addWeeks
[52090] Fix | Delete
* @category Week Helpers
[52091] Fix | Delete
* @summary Add the specified number of weeks to the given date.
[52092] Fix | Delete
*
[52093] Fix | Delete
* @description
[52094] Fix | Delete
* Add the specified number of week to the given date.
[52095] Fix | Delete
*
[52096] Fix | Delete
* @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).
[52097] Fix | Delete
*
[52098] Fix | Delete
* @param date - The date to be changed
[52099] Fix | Delete
* @param amount - The amount of weeks to be added.
[52100] Fix | Delete
*
[52101] Fix | Delete
* @returns The new date with the weeks added
[52102] Fix | Delete
*
[52103] Fix | Delete
* @example
[52104] Fix | Delete
* // Add 4 weeks to 1 September 2014:
[52105] Fix | Delete
* const result = addWeeks(new Date(2014, 8, 1), 4)
[52106] Fix | Delete
* //=> Mon Sep 29 2014 00:00:00
[52107] Fix | Delete
*/
[52108] Fix | Delete
function addWeeks(date, amount) {
[52109] Fix | Delete
const days = amount * 7;
[52110] Fix | Delete
return addDays(date, days);
[52111] Fix | Delete
}
[52112] Fix | Delete
[52113] Fix | Delete
/**
[52114] Fix | Delete
* @name addYears
[52115] Fix | Delete
* @category Year Helpers
[52116] Fix | Delete
* @summary Add the specified number of years to the given date.
[52117] Fix | Delete
*
[52118] Fix | Delete
* @description
[52119] Fix | Delete
* Add the specified number of years to the given date.
[52120] Fix | Delete
*
[52121] Fix | Delete
* @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).
[52122] Fix | Delete
*
[52123] Fix | Delete
* @param date - The date to be changed
[52124] Fix | Delete
* @param amount - The amount of years to be added.
[52125] Fix | Delete
*
[52126] Fix | Delete
* @returns The new date with the years added
[52127] Fix | Delete
*
[52128] Fix | Delete
* @example
[52129] Fix | Delete
* // Add 5 years to 1 September 2014:
[52130] Fix | Delete
* const result = addYears(new Date(2014, 8, 1), 5)
[52131] Fix | Delete
* //=> Sun Sep 01 2019 00:00:00
[52132] Fix | Delete
*/
[52133] Fix | Delete
function addYears(date, amount) {
[52134] Fix | Delete
return addMonths(date, amount * 12);
[52135] Fix | Delete
}
[52136] Fix | Delete
[52137] Fix | Delete
/**
[52138] Fix | Delete
* @name endOfMonth
[52139] Fix | Delete
* @category Month Helpers
[52140] Fix | Delete
* @summary Return the end of a month for the given date.
[52141] Fix | Delete
*
[52142] Fix | Delete
* @description
[52143] Fix | Delete
* Return the end of a month for the given date.
[52144] Fix | Delete
* The result will be in the local timezone.
[52145] Fix | Delete
*
[52146] Fix | Delete
* @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).
[52147] Fix | Delete
*
[52148] Fix | Delete
* @param date - The original date
[52149] Fix | Delete
*
[52150] Fix | Delete
* @returns The end of a month
[52151] Fix | Delete
*
[52152] Fix | Delete
* @example
[52153] Fix | Delete
* // The end of a month for 2 September 2014 11:55:00:
[52154] Fix | Delete
* const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
[52155] Fix | Delete
* //=> Tue Sep 30 2014 23:59:59.999
[52156] Fix | Delete
*/
[52157] Fix | Delete
function endOfMonth(date) {
[52158] Fix | Delete
const _date = toDate(date);
[52159] Fix | Delete
const month = _date.getMonth();
[52160] Fix | Delete
_date.setFullYear(_date.getFullYear(), month + 1, 0);
[52161] Fix | Delete
_date.setHours(23, 59, 59, 999);
[52162] Fix | Delete
return _date;
[52163] Fix | Delete
}
[52164] Fix | Delete
[52165] Fix | Delete
/**
[52166] Fix | Delete
* The {@link eachDayOfInterval} function options.
[52167] Fix | Delete
*/
[52168] Fix | Delete
[52169] Fix | Delete
/**
[52170] Fix | Delete
* @name eachDayOfInterval
[52171] Fix | Delete
* @category Interval Helpers
[52172] Fix | Delete
* @summary Return the array of dates within the specified time interval.
[52173] Fix | Delete
*
[52174] Fix | Delete
* @description
[52175] Fix | Delete
* Return the array of dates within the specified time interval.
[52176] Fix | Delete
*
[52177] Fix | Delete
* @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).
[52178] Fix | Delete
*
[52179] Fix | Delete
* @param interval - The interval.
[52180] Fix | Delete
* @param options - An object with options.
[52181] Fix | Delete
*
[52182] Fix | Delete
* @returns The array with starts of days from the day of the interval start to the day of the interval end
[52183] Fix | Delete
*
[52184] Fix | Delete
* @example
[52185] Fix | Delete
* // Each day between 6 October 2014 and 10 October 2014:
[52186] Fix | Delete
* const result = eachDayOfInterval({
[52187] Fix | Delete
* start: new Date(2014, 9, 6),
[52188] Fix | Delete
* end: new Date(2014, 9, 10)
[52189] Fix | Delete
* })
[52190] Fix | Delete
* //=> [
[52191] Fix | Delete
* // Mon Oct 06 2014 00:00:00,
[52192] Fix | Delete
* // Tue Oct 07 2014 00:00:00,
[52193] Fix | Delete
* // Wed Oct 08 2014 00:00:00,
[52194] Fix | Delete
* // Thu Oct 09 2014 00:00:00,
[52195] Fix | Delete
* // Fri Oct 10 2014 00:00:00
[52196] Fix | Delete
* // ]
[52197] Fix | Delete
*/
[52198] Fix | Delete
function eachDayOfInterval(interval, options) {
[52199] Fix | Delete
const startDate = toDate(interval.start);
[52200] Fix | Delete
const endDate = toDate(interval.end);
[52201] Fix | Delete
[52202] Fix | Delete
let reversed = +startDate > +endDate;
[52203] Fix | Delete
const endTime = reversed ? +startDate : +endDate;
[52204] Fix | Delete
const currentDate = reversed ? endDate : startDate;
[52205] Fix | Delete
currentDate.setHours(0, 0, 0, 0);
[52206] Fix | Delete
[52207] Fix | Delete
let step = options?.step ?? 1;
[52208] Fix | Delete
if (!step) return [];
[52209] Fix | Delete
if (step < 0) {
[52210] Fix | Delete
step = -step;
[52211] Fix | Delete
reversed = !reversed;
[52212] Fix | Delete
}
[52213] Fix | Delete
[52214] Fix | Delete
const dates = [];
[52215] Fix | Delete
[52216] Fix | Delete
while (+currentDate <= endTime) {
[52217] Fix | Delete
dates.push(toDate(currentDate));
[52218] Fix | Delete
currentDate.setDate(currentDate.getDate() + step);
[52219] Fix | Delete
currentDate.setHours(0, 0, 0, 0);
[52220] Fix | Delete
}
[52221] Fix | Delete
[52222] Fix | Delete
return reversed ? dates.reverse() : dates;
[52223] Fix | Delete
}
[52224] Fix | Delete
[52225] Fix | Delete
/**
[52226] Fix | Delete
* The {@link eachMonthOfInterval} function options.
[52227] Fix | Delete
*/
[52228] Fix | Delete
[52229] Fix | Delete
/**
[52230] Fix | Delete
* @name eachMonthOfInterval
[52231] Fix | Delete
* @category Interval Helpers
[52232] Fix | Delete
* @summary Return the array of months within the specified time interval.
[52233] Fix | Delete
*
[52234] Fix | Delete
* @description
[52235] Fix | Delete
* Return the array of months within the specified time interval.
[52236] Fix | Delete
*
[52237] Fix | Delete
* @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).
[52238] Fix | Delete
*
[52239] Fix | Delete
* @param interval - The interval
[52240] Fix | Delete
*
[52241] Fix | Delete
* @returns The array with starts of months from the month of the interval start to the month of the interval end
[52242] Fix | Delete
*
[52243] Fix | Delete
* @example
[52244] Fix | Delete
* // Each month between 6 February 2014 and 10 August 2014:
[52245] Fix | Delete
* const result = eachMonthOfInterval({
[52246] Fix | Delete
* start: new Date(2014, 1, 6),
[52247] Fix | Delete
* end: new Date(2014, 7, 10)
[52248] Fix | Delete
* })
[52249] Fix | Delete
* //=> [
[52250] Fix | Delete
* // Sat Feb 01 2014 00:00:00,
[52251] Fix | Delete
* // Sat Mar 01 2014 00:00:00,
[52252] Fix | Delete
* // Tue Apr 01 2014 00:00:00,
[52253] Fix | Delete
* // Thu May 01 2014 00:00:00,
[52254] Fix | Delete
* // Sun Jun 01 2014 00:00:00,
[52255] Fix | Delete
* // Tue Jul 01 2014 00:00:00,
[52256] Fix | Delete
* // Fri Aug 01 2014 00:00:00
[52257] Fix | Delete
* // ]
[52258] Fix | Delete
*/
[52259] Fix | Delete
function eachMonthOfInterval(interval, options) {
[52260] Fix | Delete
const startDate = toDate(interval.start);
[52261] Fix | Delete
const endDate = toDate(interval.end);
[52262] Fix | Delete
[52263] Fix | Delete
let reversed = +startDate > +endDate;
[52264] Fix | Delete
const endTime = reversed ? +startDate : +endDate;
[52265] Fix | Delete
const currentDate = reversed ? endDate : startDate;
[52266] Fix | Delete
currentDate.setHours(0, 0, 0, 0);
[52267] Fix | Delete
currentDate.setDate(1);
[52268] Fix | Delete
[52269] Fix | Delete
let step = options?.step ?? 1;
[52270] Fix | Delete
if (!step) return [];
[52271] Fix | Delete
if (step < 0) {
[52272] Fix | Delete
step = -step;
[52273] Fix | Delete
reversed = !reversed;
[52274] Fix | Delete
}
[52275] Fix | Delete
[52276] Fix | Delete
const dates = [];
[52277] Fix | Delete
[52278] Fix | Delete
while (+currentDate <= endTime) {
[52279] Fix | Delete
dates.push(toDate(currentDate));
[52280] Fix | Delete
currentDate.setMonth(currentDate.getMonth() + step);
[52281] Fix | Delete
}
[52282] Fix | Delete
[52283] Fix | Delete
return reversed ? dates.reverse() : dates;
[52284] Fix | Delete
}
[52285] Fix | Delete
[52286] Fix | Delete
/**
[52287] Fix | Delete
* The {@link eachWeekOfInterval} function options.
[52288] Fix | Delete
*/
[52289] Fix | Delete
[52290] Fix | Delete
/**
[52291] Fix | Delete
* @name eachWeekOfInterval
[52292] Fix | Delete
* @category Interval Helpers
[52293] Fix | Delete
* @summary Return the array of weeks within the specified time interval.
[52294] Fix | Delete
*
[52295] Fix | Delete
* @description
[52296] Fix | Delete
* Return the array of weeks within the specified time interval.
[52297] Fix | Delete
*
[52298] Fix | Delete
* @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).
[52299] Fix | Delete
*
[52300] Fix | Delete
* @param interval - The interval.
[52301] Fix | Delete
* @param options - An object with options.
[52302] Fix | Delete
*
[52303] Fix | Delete
* @returns The array with starts of weeks from the week of the interval start to the week of the interval end
[52304] Fix | Delete
*
[52305] Fix | Delete
* @example
[52306] Fix | Delete
* // Each week within interval 6 October 2014 - 23 November 2014:
[52307] Fix | Delete
* const result = eachWeekOfInterval({
[52308] Fix | Delete
* start: new Date(2014, 9, 6),
[52309] Fix | Delete
* end: new Date(2014, 10, 23)
[52310] Fix | Delete
* })
[52311] Fix | Delete
* //=> [
[52312] Fix | Delete
* // Sun Oct 05 2014 00:00:00,
[52313] Fix | Delete
* // Sun Oct 12 2014 00:00:00,
[52314] Fix | Delete
* // Sun Oct 19 2014 00:00:00,
[52315] Fix | Delete
* // Sun Oct 26 2014 00:00:00,
[52316] Fix | Delete
* // Sun Nov 02 2014 00:00:00,
[52317] Fix | Delete
* // Sun Nov 09 2014 00:00:00,
[52318] Fix | Delete
* // Sun Nov 16 2014 00:00:00,
[52319] Fix | Delete
* // Sun Nov 23 2014 00:00:00
[52320] Fix | Delete
* // ]
[52321] Fix | Delete
*/
[52322] Fix | Delete
function eachWeekOfInterval(interval, options) {
[52323] Fix | Delete
const startDate = toDate(interval.start);
[52324] Fix | Delete
const endDate = toDate(interval.end);
[52325] Fix | Delete
[52326] Fix | Delete
let reversed = +startDate > +endDate;
[52327] Fix | Delete
const startDateWeek = reversed
[52328] Fix | Delete
? startOfWeek(endDate, options)
[52329] Fix | Delete
: startOfWeek(startDate, options);
[52330] Fix | Delete
const endDateWeek = reversed
[52331] Fix | Delete
? startOfWeek(startDate, options)
[52332] Fix | Delete
: startOfWeek(endDate, options);
[52333] Fix | Delete
[52334] Fix | Delete
// Some timezones switch DST at midnight, making start of day unreliable in these timezones, 3pm is a safe bet
[52335] Fix | Delete
startDateWeek.setHours(15);
[52336] Fix | Delete
endDateWeek.setHours(15);
[52337] Fix | Delete
[52338] Fix | Delete
const endTime = +endDateWeek.getTime();
[52339] Fix | Delete
let currentDate = startDateWeek;
[52340] Fix | Delete
[52341] Fix | Delete
let step = options?.step ?? 1;
[52342] Fix | Delete
if (!step) return [];
[52343] Fix | Delete
if (step < 0) {
[52344] Fix | Delete
step = -step;
[52345] Fix | Delete
reversed = !reversed;
[52346] Fix | Delete
}
[52347] Fix | Delete
[52348] Fix | Delete
const dates = [];
[52349] Fix | Delete
[52350] Fix | Delete
while (+currentDate <= endTime) {
[52351] Fix | Delete
currentDate.setHours(0);
[52352] Fix | Delete
dates.push(toDate(currentDate));
[52353] Fix | Delete
currentDate = addWeeks(currentDate, step);
[52354] Fix | Delete
currentDate.setHours(15);
[52355] Fix | Delete
}
[52356] Fix | Delete
[52357] Fix | Delete
return reversed ? dates.reverse() : dates;
[52358] Fix | Delete
}
[52359] Fix | Delete
[52360] Fix | Delete
/**
[52361] Fix | Delete
* @name startOfMonth
[52362] Fix | Delete
* @category Month Helpers
[52363] Fix | Delete
* @summary Return the start of a month for the given date.
[52364] Fix | Delete
*
[52365] Fix | Delete
* @description
[52366] Fix | Delete
* Return the start of a month for the given date.
[52367] Fix | Delete
* The result will be in the local timezone.
[52368] Fix | Delete
*
[52369] Fix | Delete
* @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).
[52370] Fix | Delete
*
[52371] Fix | Delete
* @param date - The original date
[52372] Fix | Delete
*
[52373] Fix | Delete
* @returns The start of a month
[52374] Fix | Delete
*
[52375] Fix | Delete
* @example
[52376] Fix | Delete
* // The start of a month for 2 September 2014 11:55:00:
[52377] Fix | Delete
* const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
[52378] Fix | Delete
* //=> Mon Sep 01 2014 00:00:00
[52379] Fix | Delete
*/
[52380] Fix | Delete
function startOfMonth(date) {
[52381] Fix | Delete
const _date = toDate(date);
[52382] Fix | Delete
_date.setDate(1);
[52383] Fix | Delete
_date.setHours(0, 0, 0, 0);
[52384] Fix | Delete
return _date;
[52385] Fix | Delete
}
[52386] Fix | Delete
[52387] Fix | Delete
/**
[52388] Fix | Delete
* The {@link endOfWeek} function options.
[52389] Fix | Delete
*/
[52390] Fix | Delete
[52391] Fix | Delete
/**
[52392] Fix | Delete
* @name endOfWeek
[52393] Fix | Delete
* @category Week Helpers
[52394] Fix | Delete
* @summary Return the end of a week for the given date.
[52395] Fix | Delete
*
[52396] Fix | Delete
* @description
[52397] Fix | Delete
* Return the end of a week for the given date.
[52398] Fix | Delete
* The result will be in the local timezone.
[52399] Fix | Delete
*
[52400] Fix | Delete
* @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).
[52401] Fix | Delete
*
[52402] Fix | Delete
* @param date - The original date
[52403] Fix | Delete
* @param options - An object with options
[52404] Fix | Delete
*
[52405] Fix | Delete
* @returns The end of a week
[52406] Fix | Delete
*
[52407] Fix | Delete
* @example
[52408] Fix | Delete
* // The end of a week for 2 September 2014 11:55:00:
[52409] Fix | Delete
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
[52410] Fix | Delete
* //=> Sat Sep 06 2014 23:59:59.999
[52411] Fix | Delete
*
[52412] Fix | Delete
* @example
[52413] Fix | Delete
* // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
[52414] Fix | Delete
* const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
[52415] Fix | Delete
* //=> Sun Sep 07 2014 23:59:59.999
[52416] Fix | Delete
*/
[52417] Fix | Delete
function endOfWeek(date, options) {
[52418] Fix | Delete
const defaultOptions = getDefaultOptions();
[52419] Fix | Delete
const weekStartsOn =
[52420] Fix | Delete
options?.weekStartsOn ??
[52421] Fix | Delete
options?.locale?.options?.weekStartsOn ??
[52422] Fix | Delete
defaultOptions.weekStartsOn ??
[52423] Fix | Delete
defaultOptions.locale?.options?.weekStartsOn ??
[52424] Fix | Delete
0;
[52425] Fix | Delete
[52426] Fix | Delete
const _date = toDate(date);
[52427] Fix | Delete
const day = _date.getDay();
[52428] Fix | Delete
const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
[52429] Fix | Delete
[52430] Fix | Delete
_date.setDate(_date.getDate() + diff);
[52431] Fix | Delete
_date.setHours(23, 59, 59, 999);
[52432] Fix | Delete
return _date;
[52433] Fix | Delete
}
[52434] Fix | Delete
[52435] Fix | Delete
/**
[52436] Fix | Delete
* @name getDaysInMonth
[52437] Fix | Delete
* @category Month Helpers
[52438] Fix | Delete
* @summary Get the number of days in a month of the given date.
[52439] Fix | Delete
*
[52440] Fix | Delete
* @description
[52441] Fix | Delete
* Get the number of days in a month of the given date.
[52442] Fix | Delete
*
[52443] Fix | Delete
* @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).
[52444] Fix | Delete
*
[52445] Fix | Delete
* @param date - The given date
[52446] Fix | Delete
*
[52447] Fix | Delete
* @returns The number of days in a month
[52448] Fix | Delete
*
[52449] Fix | Delete
* @example
[52450] Fix | Delete
* // How many days are in February 2000?
[52451] Fix | Delete
* const result = getDaysInMonth(new Date(2000, 1))
[52452] Fix | Delete
* //=> 29
[52453] Fix | Delete
*/
[52454] Fix | Delete
function getDaysInMonth(date) {
[52455] Fix | Delete
const _date = toDate(date);
[52456] Fix | Delete
const year = _date.getFullYear();
[52457] Fix | Delete
const monthIndex = _date.getMonth();
[52458] Fix | Delete
const lastDayOfMonth = constructFrom(date, 0);
[52459] Fix | Delete
lastDayOfMonth.setFullYear(year, monthIndex + 1, 0);
[52460] Fix | Delete
lastDayOfMonth.setHours(0, 0, 0, 0);
[52461] Fix | Delete
return lastDayOfMonth.getDate();
[52462] Fix | Delete
}
[52463] Fix | Delete
[52464] Fix | Delete
/**
[52465] Fix | Delete
* @name isAfter
[52466] Fix | Delete
* @category Common Helpers
[52467] Fix | Delete
* @summary Is the first date after the second one?
[52468] Fix | Delete
*
[52469] Fix | Delete
* @description
[52470] Fix | Delete
* Is the first date after the second one?
[52471] Fix | Delete
*
[52472] Fix | Delete
* @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).
[52473] Fix | Delete
*
[52474] Fix | Delete
* @param date - The date that should be after the other one to return true
[52475] Fix | Delete
* @param dateToCompare - The date to compare with
[52476] Fix | Delete
*
[52477] Fix | Delete
* @returns The first date is after the second date
[52478] Fix | Delete
*
[52479] Fix | Delete
* @example
[52480] Fix | Delete
* // Is 10 July 1989 after 11 February 1987?
[52481] Fix | Delete
* const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
[52482] Fix | Delete
* //=> true
[52483] Fix | Delete
*/
[52484] Fix | Delete
function isAfter(date, dateToCompare) {
[52485] Fix | Delete
const _date = toDate(date);
[52486] Fix | Delete
const _dateToCompare = toDate(dateToCompare);
[52487] Fix | Delete
return _date.getTime() > _dateToCompare.getTime();
[52488] Fix | Delete
}
[52489] Fix | Delete
[52490] Fix | Delete
/**
[52491] Fix | Delete
* @name isBefore
[52492] Fix | Delete
* @category Common Helpers
[52493] Fix | Delete
* @summary Is the first date before the second one?
[52494] Fix | Delete
*
[52495] Fix | Delete
* @description
[52496] Fix | Delete
* Is the first date before the second one?
[52497] Fix | Delete
*
[52498] Fix | Delete
* @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).
[52499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function