Skip to content

Commit

Permalink
fix(NcDateTime): Respect language
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Apr 22, 2024
1 parent 8dbc23e commit 846ebea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/composables/useFormatDateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

import { getCanonicalLocale } from '@nextcloud/l10n'
import { getCanonicalLocale, getLanguage } from '@nextcloud/l10n'
import { computed, onUnmounted, ref, onMounted, watch, unref, type Ref } from 'vue'
import { t } from '../l10n.js'

Expand Down Expand Up @@ -48,7 +48,7 @@ interface FormatDateOptions {
type MaybeRef<T> = T | Ref<T>

/**
* Composable for formatting time stamps using current users locale
* Composable for formatting time stamps using current users locale and language
*
* @param {Date | number | import('vue').Ref<Date> | import('vue').Ref<number>} timestamp Current timestamp
* @param {object} opts Optional options
Expand Down Expand Up @@ -87,7 +87,7 @@ export function useFormatDateTime(
/** Time string formatted for main text */
const formattedTime = computed<string>(() => {
if (wrappedOptions.value.relativeTime !== false) {
const formatter = new Intl.RelativeTimeFormat(getCanonicalLocale(), { numeric: 'auto', style: wrappedOptions.value.relativeTime })
const formatter = new Intl.RelativeTimeFormat(getLanguage(), { numeric: 'auto', style: wrappedOptions.value.relativeTime })

const diff = date.value.getTime() - currentTime.value
const seconds = diff / 1000
Expand Down

0 comments on commit 846ebea

Please sign in to comment.