Skip to content

Commit

Permalink
chore: update the getNextQuarter to use mock date
Browse files Browse the repository at this point in the history
  • Loading branch information
AntBush authored and ccbc-service-account committed Nov 15, 2024
1 parent 40de714 commit 47b75eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/backend/lib/communityReportsDueDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const limiter = RateLimit({

const communityReportDueDate = Router();

function getNextQuarterStartDate(): Date {
const today = new Date();
today.setHours(0, 0, 0, 0);
function getNextQuarterStartDate(today: Date): Date {
const currentYear = today.getFullYear();
// Define quarter start months: March, June, September, December
const quarterStartMonths = [2, 5, 8, 11]; // 0-based: 2=March, 5=June, 8=September, 11=December
Expand Down Expand Up @@ -67,10 +65,12 @@ const processCommunityReportsDueDates = async (req, res) => {
if (isEnabledTimeMachine) {
const mockedDate = req.cookies['mocks.mocked_date'];
today = mockedDate ? new Date(mockedDate) : new Date();
today.setUTCHours(0, 0, 0, 0);
} else {
today = new Date();
today.setUTCHours(0, 0, 0, 0);
}
const nextQuarterDate = getNextQuarterStartDate();
const nextQuarterDate = getNextQuarterStartDate(today);

// Function to check if a given due date string is within 30 to 31 days from today.
const isWithin30To31Days = (dueDate: Date) => {
Expand Down

0 comments on commit 47b75eb

Please sign in to comment.