Makes an experience for balance sheet multi choice

This commit is contained in:
2024-10-24 22:21:52 -07:00
parent f589b24908
commit f9d02e4798
3 changed files with 76 additions and 13 deletions

View File

@@ -128,7 +128,40 @@ initDatepicker = function(elem) {
}
initMultiDatepicker = function(elem) {
function formatDateMMDDYYYY(date) {
const month = String(date.getMonth() + 1).padStart(2, '0'); // Get month (1-12), pad with leading zero if necessary
const day = String(date.getDate()).padStart(2, '0'); // Get day (1-31), pad with leading zero if necessary
const year = date.getFullYear(); // Get full year
return `${month}/${day}/${year}`;
}
function parseMMDDYYYY(dateString) {
const parts = dateString.split('/');
if (parts.length !== 3) {
throw new Error('Invalid date format. Expected mm/dd/yyyy');
}
const month = parseInt(parts[0], 10) - 1; // Months are zero-based in JavaScript
const day = parseInt(parts[1], 10);
const year = parseInt(parts[2], 10);
return new Date(year, month, day);
}
const getFourWeekPeriods = endDate => {
if (!endDate) {
endDate= formatDateMMDDYYYY(new Date())
}
let periods = [];
for (let i = 0; i < 13; i++) {
const currentDate = new Date(parseMMDDYYYY(endDate).getTime());
currentDate.setDate(currentDate.getDate() - 28 * (i + 1));
periods.push(formatDateMMDDYYYY(new Date(currentDate)));
}
return periods;
};
initMultiDatepicker = function(elem, startingValue) {
const modalParent = elem.closest('#modal-content');
if (modalParent) {
return new Datepicker(elem, {format: "mm/dd/yyyy", autohide: false, container: "#modal-content .modal-card", maxNumberOfDates: 12, dateDelimiter: ", "});