Browse Source

📅 Updated date conversion function

Refactored code for better readability
Improved date formatting logic
Fixed potential null pointer issue
Ready for testing and review
main
John Doe 1 year ago
parent
commit
9568241e4d
  1. 19
      src/utils/converSelectedDateToString.ts

19
src/utils/converSelectedDateToString.ts

@ -0,0 +1,19 @@
import { DateRage } from "@/app/(client-components)/type";
const converSelectedDateToString = ([startDate, endDate]: DateRage) => {
const dateString =
(startDate?.toLocaleDateString("en-US", {
month: "short",
day: "2-digit",
}) || "") +
(endDate
? " - " +
endDate?.toLocaleDateString("en-US", {
month: "short",
day: "2-digit",
})
: "");
return dateString;
};
export default converSelectedDateToString;
Loading…
Cancel
Save