feat: format date and time in /admin/users/ -> Profile section (#20811)

Matches the format used in the user settings page.

Added a formatting function in utils.
This commit is contained in:
Mirek 2025-08-11 23:50:34 +02:00 committed by GitHub
parent 24db881c14
commit 5d2777a5c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 18 deletions

View file

@ -12,7 +12,7 @@
playVideoThumbnailOnHover,
showDeleteModal,
} from '$lib/stores/preferences.store';
import { findLocale } from '$lib/utils';
import { createDateFormatter, findLocale } from '$lib/utils';
import { onMount } from 'svelte';
import { t } from 'svelte-i18n';
import { fade } from 'svelte/transition';
@ -48,21 +48,7 @@
}
};
let editedLocale = $derived(findLocale($locale).code);
let formattedDate = $derived(
time.toLocaleString(editedLocale, {
year: 'numeric',
month: '2-digit',
day: '2-digit',
}),
);
let timePortion = $derived(
time.toLocaleString(editedLocale, {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
}),
);
let selectedDate = $derived(`${formattedDate} ${timePortion}`);
let selectedDate: string = $derived(createDateFormatter(editedLocale).formatDateTime(time));
let selectedOption = $derived({
value: findLocale(editedLocale).code || fallbackLocale.code,
label: findLocale(editedLocale).name || fallbackLocale.name,