Added Statistics calculation
Statistics now show calculated values
This commit is contained in:
parent
fe87374e47
commit
fc0f69dacb
2147 changed files with 141321 additions and 39 deletions
59
node_modules/@mui/x-date-pickers/esm/internals/utils/getDefaultReferenceDate.js
generated
vendored
Normal file
59
node_modules/@mui/x-date-pickers/esm/internals/utils/getDefaultReferenceDate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { createIsAfterIgnoreDatePart } from "./time-utils.js";
|
||||
import { mergeDateAndTime, getTodayDate } from "./date-utils.js";
|
||||
export const SECTION_TYPE_GRANULARITY = {
|
||||
year: 1,
|
||||
month: 2,
|
||||
day: 3,
|
||||
hours: 4,
|
||||
minutes: 5,
|
||||
seconds: 6,
|
||||
milliseconds: 7
|
||||
};
|
||||
export const getSectionTypeGranularity = sections => Math.max(...sections.map(section => SECTION_TYPE_GRANULARITY[section.type] ?? 1));
|
||||
const roundDate = (adapter, granularity, date) => {
|
||||
if (granularity === SECTION_TYPE_GRANULARITY.year) {
|
||||
return adapter.startOfYear(date);
|
||||
}
|
||||
if (granularity === SECTION_TYPE_GRANULARITY.month) {
|
||||
return adapter.startOfMonth(date);
|
||||
}
|
||||
if (granularity === SECTION_TYPE_GRANULARITY.day) {
|
||||
return adapter.startOfDay(date);
|
||||
}
|
||||
|
||||
// We don't have startOfHour / startOfMinute / startOfSecond
|
||||
let roundedDate = date;
|
||||
if (granularity < SECTION_TYPE_GRANULARITY.minutes) {
|
||||
roundedDate = adapter.setMinutes(roundedDate, 0);
|
||||
}
|
||||
if (granularity < SECTION_TYPE_GRANULARITY.seconds) {
|
||||
roundedDate = adapter.setSeconds(roundedDate, 0);
|
||||
}
|
||||
if (granularity < SECTION_TYPE_GRANULARITY.milliseconds) {
|
||||
roundedDate = adapter.setMilliseconds(roundedDate, 0);
|
||||
}
|
||||
return roundedDate;
|
||||
};
|
||||
export const getDefaultReferenceDate = ({
|
||||
props,
|
||||
adapter,
|
||||
granularity,
|
||||
timezone,
|
||||
getTodayDate: inGetTodayDate
|
||||
}) => {
|
||||
let referenceDate = inGetTodayDate ? inGetTodayDate() : roundDate(adapter, granularity, getTodayDate(adapter, timezone));
|
||||
if (props.minDate != null && adapter.isAfterDay(props.minDate, referenceDate)) {
|
||||
referenceDate = roundDate(adapter, granularity, props.minDate);
|
||||
}
|
||||
if (props.maxDate != null && adapter.isBeforeDay(props.maxDate, referenceDate)) {
|
||||
referenceDate = roundDate(adapter, granularity, props.maxDate);
|
||||
}
|
||||
const isAfter = createIsAfterIgnoreDatePart(props.disableIgnoringDatePartForTimeValidation ?? false, adapter);
|
||||
if (props.minTime != null && isAfter(props.minTime, referenceDate)) {
|
||||
referenceDate = roundDate(adapter, granularity, props.disableIgnoringDatePartForTimeValidation ? props.minTime : mergeDateAndTime(adapter, referenceDate, props.minTime));
|
||||
}
|
||||
if (props.maxTime != null && isAfter(referenceDate, props.maxTime)) {
|
||||
referenceDate = roundDate(adapter, granularity, props.disableIgnoringDatePartForTimeValidation ? props.maxTime : mergeDateAndTime(adapter, referenceDate, props.maxTime));
|
||||
}
|
||||
return referenceDate;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue