Skip to content

Commit

Permalink
edit formatDate fn to return same date format for both en and bg lang…
Browse files Browse the repository at this point in the history
…uage
  • Loading branch information
viiktorstefanov committed Sep 19, 2024
1 parent 6dd016e commit c3456ad
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/common/util/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ export const formatDate = 'dd MMM yyyy'
export const formatDatetime = 'dd MMM yyyy HH:mm:ss'

export const formatDateString = (dateString: string | Date, language?: string) => {
if (language) {
return Intl.DateTimeFormat(language).format(new Date(dateString))
}
return new Date(dateString).toLocaleDateString()
const date = new Date(dateString)

const day = String(date.getDate()).padStart(2, '0')
const month = String(date.getMonth() + 1).padStart(2, '0')
const year = date.getFullYear()

return `${day}.${month}.${year}`
}

const matchLocale = (language?: string): Locale => {
Expand Down

0 comments on commit c3456ad

Please sign in to comment.