From 5b120ad2487aead9e226470725d104b8ab10921c Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Tue, 16 Apr 2024 22:02:56 +0530 Subject: [PATCH] refactor: take format as optional argument --- frontend/src/utils/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 5b5b33cd..8d328dd9 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -324,11 +324,15 @@ export function getSidebarLinks() { ] } -export function getFormattedDateRange(startDate, endDate) { +export function getFormattedDateRange( + startDate, + endDate, + format = 'DD MMM YYYY' +) { if (startDate === endDate) { - return dayjs(startDate).format('DD MMM YYYY') + return dayjs(startDate).format(format) } - return `${dayjs(startDate).format('DD MMM YYYY')} - ${dayjs(endDate).format( - 'DD MMM YYYY' + return `${dayjs(startDate).format(format)} - ${dayjs(endDate).format( + format )}` }