mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Show a report for total users chart
This commit is contained in:
parent
794938db72
commit
4d064adf1b
5397 changed files with 313100 additions and 365 deletions
60
node_modules/date-fns/setDay.js
generated
vendored
Normal file
60
node_modules/date-fns/setDay.js
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
import { getDefaultOptions } from "./_lib/defaultOptions.js";
|
||||
import { addDays } from "./addDays.js";
|
||||
import { toDate } from "./toDate.js";
|
||||
|
||||
/**
|
||||
* The {@link setDay} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name setDay
|
||||
* @category Weekday Helpers
|
||||
* @summary Set the day of the week to the given date.
|
||||
*
|
||||
* @description
|
||||
* Set the day of the week 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).
|
||||
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
||||
*
|
||||
* @param date - The date to be changed
|
||||
* @param day - The day of the week of the new date
|
||||
* @param options - An object with options.
|
||||
*
|
||||
* @returns The new date with the day of the week set
|
||||
*
|
||||
* @example
|
||||
* // Set week day to Sunday, with the default weekStartsOn of Sunday:
|
||||
* const result = setDay(new Date(2014, 8, 1), 0)
|
||||
* //=> Sun Aug 31 2014 00:00:00
|
||||
*
|
||||
* @example
|
||||
* // Set week day to Sunday, with a weekStartsOn of Monday:
|
||||
* const result = setDay(new Date(2014, 8, 1), 0, { weekStartsOn: 1 })
|
||||
* //=> Sun Sep 07 2014 00:00:00
|
||||
*/
|
||||
export function setDay(date, day, options) {
|
||||
const defaultOptions = getDefaultOptions();
|
||||
const weekStartsOn =
|
||||
options?.weekStartsOn ??
|
||||
options?.locale?.options?.weekStartsOn ??
|
||||
defaultOptions.weekStartsOn ??
|
||||
defaultOptions.locale?.options?.weekStartsOn ??
|
||||
0;
|
||||
|
||||
const date_ = toDate(date, options?.in);
|
||||
const currentDay = date_.getDay();
|
||||
|
||||
const remainder = day % 7;
|
||||
const dayIndex = (remainder + 7) % 7;
|
||||
|
||||
const delta = 7 - weekStartsOn;
|
||||
const diff =
|
||||
day < 0 || day > 6
|
||||
? day - ((currentDay + delta) % 7)
|
||||
: ((dayIndex + delta) % 7) - ((currentDay + delta) % 7);
|
||||
return addDays(date_, diff, options);
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default setDay;
|
Loading…
Add table
Add a link
Reference in a new issue