Skip to content

Commit

Permalink
feat: add pt-BR hour format (#984)
Browse files Browse the repository at this point in the history
Signed-off-by: Caroline Lucas Calheirani <[email protected]>
  • Loading branch information
CarolineLCa authored Oct 3, 2023
1 parent 1ca8bbd commit 05fbe8b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/legacy/core/App/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ export function formatTime(
const now = new Date()
const sameYear = time.getFullYear() === now.getFullYear()
const sameDay = time.getDate() === now.getDate() && time.getMonth() === now.getMonth() && sameYear
const isNonEnglish = i18n.resolvedLanguage === 'fr' || i18n.resolvedLanguage === 'pt-BR'

const isPortuguese = i18n.resolvedLanguage === 'pt-BR'
const isNonEnglish = i18n.resolvedLanguage === 'fr' || isPortuguese
const hoursFormat = isPortuguese ? 'HH:mm' : 'h:mm a'
// for the shortened approach eg. in chat bubbles
if (chatFormat) {
if (lessThanAMinuteAgo) {
Expand All @@ -146,15 +147,15 @@ export function formatTime(
return minutesAgo === 1 ? `1 ${i18n.t('Date.MinuteAgo')}` : `${minutesAgo} ${i18n.t('Date.MinutesAgo')}`
}
if (sameDay) {
return momentTime.format('h:mm a')
return momentTime.format(hoursFormat)
}
}

let formatString = i18n.t('Date.ShortFormat')
let formattedTime = ''
// if sameDay and abbreviated
if (sameDay && trim) {
return momentTime.format('h:mm a')
return momentTime.format(hoursFormat)
}

if (format) {
Expand All @@ -179,7 +180,7 @@ export function formatTime(
? `${momentTime.format(formatString)} ${momentTime.format('YYYY')}`
: `${momentTime.format(formatString)}, ${momentTime.format('YYYY')}`
if (includeHour) {
formattedTime = `${formattedTime}, ${momentTime.format('h:mm a')}`
formattedTime = `${formattedTime}, ${momentTime.format(hoursFormat)}`
}
}

Expand Down

0 comments on commit 05fbe8b

Please sign in to comment.