From 59168ec0d386df96a572093696eec6e98911369b Mon Sep 17 00:00:00 2001 From: angelathe Date: Fri, 20 Dec 2024 10:44:29 -0800 Subject: [PATCH] update default nits --- .../src/app/view-data/utils/date-utils.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/containers/ecr-viewer/src/app/view-data/utils/date-utils.ts b/containers/ecr-viewer/src/app/view-data/utils/date-utils.ts index 9228ea343..8d2a3e09d 100644 --- a/containers/ecr-viewer/src/app/view-data/utils/date-utils.ts +++ b/containers/ecr-viewer/src/app/view-data/utils/date-utils.ts @@ -42,7 +42,7 @@ export const dateRangeLabels: { [key in DateRangeOptions]: string } = { * @param resetHours - If true, resets the time to the start of the day (00:00:00.000) local time * @returns The updated date */ -function daysAgoDate(refDate: Date, days: number, resetHours: boolean) { +function daysAgoDate(refDate: Date, days: number, resetHours: boolean = true) { const updatedDate = new Date(refDate); // Clone the reference date updatedDate.setDate(refDate.getDate() - days); // Subtract the days @@ -56,15 +56,12 @@ function daysAgoDate(refDate: Date, days: number, resetHours: boolean) { * Calculates the date a specified number of months ago from the given date * @param refDate - The reference date * @param months - The number of months to subtract from the reference date - * @param resetHours - If true, resets the time to the start of the day (00:00:00.000) local time * @returns The updated date */ -function monthsAgoDate(refDate: Date, months: number, resetHours: boolean) { +function monthsAgoDate(refDate: Date, months: number) { const updatedDate = new Date(refDate); updatedDate.setMonth(refDate.getMonth() - months); - if (resetHours) { - updatedDate.setHours(0, 0, 0, 0); - } + updatedDate.setHours(0, 0, 0, 0); return updatedDate; } @@ -89,27 +86,27 @@ export function convertDateOptionToDateRange( }; case DateRangeOptions.Last7Days: return { - startDate: daysAgoDate(currentEndDate, 7, true), + startDate: daysAgoDate(currentEndDate, 7), endDate: currentEndDate, }; case DateRangeOptions.Last30Days: return { - startDate: daysAgoDate(currentEndDate, 30, true), + startDate: daysAgoDate(currentEndDate, 30), endDate: currentEndDate, }; case DateRangeOptions.Last3Months: return { - startDate: monthsAgoDate(currentEndDate, 3, true), + startDate: monthsAgoDate(currentEndDate, 3), endDate: currentEndDate, }; case DateRangeOptions.Last6Months: return { - startDate: monthsAgoDate(currentEndDate, 6, true), + startDate: monthsAgoDate(currentEndDate, 6), endDate: currentEndDate, }; case DateRangeOptions.LastYear: return { - startDate: monthsAgoDate(currentEndDate, 12, true), + startDate: monthsAgoDate(currentEndDate, 12), endDate: currentEndDate, }; default: