Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pt-BR hour format #984

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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)

Check warning on line 150 in packages/legacy/core/App/utils/helpers.ts

View check run for this annotation

Codecov / codecov/patch

packages/legacy/core/App/utils/helpers.ts#L150

Added line #L150 was not covered by tests
}
}

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)

Check warning on line 158 in packages/legacy/core/App/utils/helpers.ts

View check run for this annotation

Codecov / codecov/patch

packages/legacy/core/App/utils/helpers.ts#L158

Added line #L158 was not covered by tests
}

if (format) {
Expand All @@ -179,7 +180,7 @@
? `${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