1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-27 13:48:52 +02:00

[GH-1080] Use current locale for date range (#1575)

This uses the currently configured locale to compute the value of date
range table aggregations. Previously, it would fall back to the browser
locale (or English) and ignore the locale configured in Focalboard
itself.

Relates to: #1080

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Johannes Marbach 2021-10-18 21:17:08 +02:00 committed by GitHub
parent 85ffb63b91
commit 14634fd4e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,7 +282,7 @@ function getTimestampsFromPropertyValue(value: number | string | string[]): numb
return []
}
function dateRange(cards: readonly Card[], property: IPropertyTemplate): string {
function dateRange(cards: readonly Card[], property: IPropertyTemplate, intl: IntlShape): string {
const resultEarliest = earliestEpoch(cards, property)
if (resultEarliest === Number.POSITIVE_INFINITY) {
return ''
@ -291,7 +291,7 @@ function dateRange(cards: readonly Card[], property: IPropertyTemplate): string
if (resultLatest === Number.NEGATIVE_INFINITY) {
return ''
}
return moment.duration(resultLatest - resultEarliest, 'milliseconds').humanize()
return moment.duration(resultLatest - resultEarliest, 'milliseconds').locale(intl.locale.toLowerCase()).humanize()
}
const Calculations: Record<string, (cards: readonly Card[], property: IPropertyTemplate, intl: IntlShape) => string> = {