Skip to content

Commit

Permalink
update default nits
Browse files Browse the repository at this point in the history
  • Loading branch information
angelathe committed Dec 20, 2024
1 parent d60ef8f commit 59168ec
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions containers/ecr-viewer/src/app/view-data/utils/date-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;
}

Expand All @@ -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:
Expand Down

0 comments on commit 59168ec

Please sign in to comment.