Skip to content

Commit 681c215

Browse files
committed
feat: accept optional locale for formatDate
1 parent 160c3d3 commit 681c215

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/utils/date.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export const isValidDate = (dateString?: string | number): boolean => {
77
return !isNaN(date.getTime())
88
}
99

10-
export const formatDate = (date: string) => {
10+
export const formatDate = (date: string, locale: string = "en-US") => {
1111
if (/^\d{4}$/.test(date)) {
1212
return date
1313
}
14-
return new Date(date).toLocaleDateString("en-US", {
14+
return new Date(date).toLocaleDateString(locale, {
1515
month: "long",
1616
day: "numeric",
1717
year: "numeric",

0 commit comments

Comments
 (0)