Skip to content

Commit 68b1c7a

Browse files
committed
chore: refactor date format, use locale
1 parent 539e7d1 commit 68b1c7a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/EventCard.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React from "react"
2+
import { useRouter } from "next/router"
23
import { useTranslation } from "react-i18next"
34
import { BsCalendar3 } from "react-icons/bs"
45
import { Box, Flex, Heading, Icon } from "@chakra-ui/react"
56
import { Image } from "@chakra-ui/react"
67

7-
import { formatDateRange } from "@/lib/utils/date"
8-
98
import { ButtonLink } from "./Buttons"
109
import Text from "./OldText"
1110

@@ -38,8 +37,13 @@ const EventCard = ({
3837
endDate,
3938
startDate,
4039
}: EventCardProps) => {
40+
const { locale } = useRouter()
4141
const { t } = useTranslation("page-community")
42-
const formatedDate = formatDateRange(startDate, endDate)
42+
const formatedDate = new Intl.DateTimeFormat(locale, {
43+
day: "2-digit",
44+
month: "short",
45+
}).formatRange(new Date(startDate), new Date(endDate))
46+
4347
return (
4448
<Box
4549
className={className}

src/components/UpcomingEventsList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const UpcomingEventsList = () => {
7272
const groupedEvents = _.groupBy(formattedEvents, ({ startDate }) => {
7373
// .replace(/-/g, "/") ==> Fixes Safari Invalid date
7474
const start = new Date(startDate.replace(/-/g, "/"))
75-
const formatYearMonth = new Intl.DateTimeFormat(undefined, {
75+
const formatYearMonth = new Intl.DateTimeFormat(locale, {
7676
month: "short",
7777
year: "numeric",
7878
}).format(start)

0 commit comments

Comments
 (0)