uses the periods that are actually used.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user