refactor: take format as optional argument

This commit is contained in:
Hussain Nagaria
2024-04-16 22:02:56 +05:30
parent 4ec57349f8
commit 5b120ad248

View File

@@ -324,11 +324,15 @@ export function getSidebarLinks() {
] ]
} }
export function getFormattedDateRange(startDate, endDate) { export function getFormattedDateRange(
startDate,
endDate,
format = 'DD MMM YYYY'
) {
if (startDate === endDate) { 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( return `${dayjs(startDate).format(format)} - ${dayjs(endDate).format(
'DD MMM YYYY' format
)}` )}`
} }