From cf1d0e710a2083bf6b8ccee8861532a1b1257632 Mon Sep 17 00:00:00 2001 From: dcshzj <27919917+dcshzj@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:25:42 +0800 Subject: [PATCH] fix: off-by-one error for month number --- src/routes/formsg/formsgSiteAuditLogs.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/routes/formsg/formsgSiteAuditLogs.ts b/src/routes/formsg/formsgSiteAuditLogs.ts index 717dc892b..ad4e69eb1 100644 --- a/src/routes/formsg/formsgSiteAuditLogs.ts +++ b/src/routes/formsg/formsgSiteAuditLogs.ts @@ -81,14 +81,15 @@ export class FormsgSiteAuditLogsRouter { const endDateObject = new Date() endDateObject.setDate(0) - startDate = `${startDateObject.getFullYear()}-${startDateObject - .getMonth() + const startDateMonth = (startDateObject.getMonth() + 1) .toString() - .padStart(2, "0")}-01` - endDate = `${endDateObject.getFullYear()}-${endDateObject - .getMonth() + .padStart(2, "0") + const endDateMonth = (endDateObject.getMonth() + 1) .toString() - .padStart(2, "0")}-${endDateObject.getDate()}` + .padStart(2, "0") + + startDate = `${startDateObject.getFullYear()}-${startDateMonth}-01` + endDate = `${endDateObject.getFullYear()}-${endDateMonth}-${endDateObject.getDate()}` } else { const startDateField = getField(responses, LOGS_TIMEFRAME_START_FIELD) const endDateField = getField(responses, LOGS_TIMEFRAME_END_FIELD)