Skip to content

Commit

Permalink
change remaining valid date checks (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickson-adbe authored Sep 4, 2024
1 parent 484ef50 commit 26fc1e1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions blocks/gmo-program-details/gmo-program-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ async function buildCalendar(dataObj, block, type, mappingArray, period) {

// get end of the view
viewEnd = getTimeBounds(calendarDeliverables, "end", endDateProp);
if (!(isValidDate(viewEnd)) || viewEnd.getFullYear() === 1969) {
if (!(isValidDate(viewEnd)) || viewEnd <= 0) {
viewEnd = new Date(viewStart);
viewEnd.setMonth(viewStart.getMonth() + 1);
}
Expand Down Expand Up @@ -820,9 +820,9 @@ async function buildCalendar(dataObj, block, type, mappingArray, period) {

// find the earliest date- this is how we set the position for the group against the calendar
let earliestStartDate = getTimeBounds(matchedItems, "start", startDateProp);
earliestStartDate = (!(isValidDate(earliestStartDate)) || earliestStartDate.getFullYear() === 1969) ? new Date(viewStart) : earliestStartDate;
earliestStartDate = (!(isValidDate(earliestStartDate)) || earliestStartDate <= 0) ? new Date(viewStart) : earliestStartDate;
let latestEndDate = getTimeBounds(matchedItems, "end", endDateProp);
latestEndDate = (!(isValidDate(latestEndDate)) || latestEndDate.getFullYear() === 1969) ? new Date(viewEnd) : latestEndDate;
latestEndDate = (!(isValidDate(latestEndDate)) || latestEndDate <= 0) ? new Date(viewEnd) : latestEndDate;
const startMonth = (earliestStartDate.getUTCMonth()); // getMonth returns 0-11 but this is desirable
const startDay = (earliestStartDate.getUTCDate() - 1); // if at start of month, we don't want to add any more margin
const endMonth = (latestEndDate.getUTCMonth());
Expand Down

0 comments on commit 26fc1e1

Please sign in to comment.