uses the periods that are actually used.

This commit is contained in:
2024-12-12 09:49:52 -08:00
parent ef7c127cd5
commit b7826ad6ce
3 changed files with 54 additions and 3 deletions

View File

@@ -267,6 +267,51 @@ const getLastMonthPeriods = (date) => {
return [currentPeriod, previousYearPeriod];
};
const getMonthToDatePeriods = () => {
date = new Date();
// Get the first day of the current month
const firstDayOfCurrentMonth = new Date(date.getFullYear(), date.getMonth(), 1);
// Get the same period for the previous year
const firstDayOfPreviousYearMonth = new Date(firstDayOfCurrentMonth.getFullYear() - 1, firstDayOfCurrentMonth.getMonth(), 1);
// Create period objects
const currentPeriod = {
start: formatDateMMDDYYYY(firstDayOfCurrentMonth),
end: formatDateMMDDYYYY(date)
};
const previousYearPeriod = {
start: formatDateMMDDYYYY(firstDayOfPreviousYearMonth),
end: formatDateMMDDYYYY(new Date(firstDayOfPreviousYearMonth.getFullYear(), firstDayOfPreviousYearMonth.getMonth(), date.getDate()))
};
return [currentPeriod, previousYearPeriod];
};
const getYearToDatePeriods = () => {
date = new Date();
// Get the first day of the current month
const firstDayOfCurrentMonth = new Date(date.getFullYear(), 0, 1);
// Get the same period for the previous year
const firstDayOfPreviousYearMonth = new Date(firstDayOfCurrentMonth.getFullYear() - 1, 0, 1);
// Create period objects
const currentPeriod = {
start: formatDateMMDDYYYY(firstDayOfCurrentMonth),
end: formatDateMMDDYYYY(date)
};
const previousYearPeriod = {
start: formatDateMMDDYYYY(firstDayOfPreviousYearMonth),
end: formatDateMMDDYYYY(new Date(firstDayOfPreviousYearMonth.getFullYear(), firstDayOfPreviousYearMonth.getMonth(), date.getDate()))
};
return [currentPeriod, previousYearPeriod];
}
initMultiDatepicker = function(elem, startingValue) {
const modalParent = elem.closest('#modal-content');
if (modalParent) {

File diff suppressed because one or more lines are too long