mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(web): Localize dates and numbers (#1056)
This commit is contained in:
@@ -86,19 +86,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
const getDateRange = () => {
|
||||
const startDate = new Date(album.assets[0].createdAt);
|
||||
const endDate = new Date(album.assets[album.assetCount - 1].createdAt);
|
||||
|
||||
const timeFormatOption: Intl.DateTimeFormatOptions = {
|
||||
const locale = navigator.languages;
|
||||
const albumDateFormat: Intl.DateTimeFormatOptions = {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric'
|
||||
};
|
||||
|
||||
const startDateString = startDate.toLocaleDateString('us-EN', timeFormatOption);
|
||||
const endDateString = endDate.toLocaleDateString('us-EN', timeFormatOption);
|
||||
return `${startDateString} - ${endDateString}`;
|
||||
const getDateRange = () => {
|
||||
const startDate = new Date(album.assets[0].createdAt);
|
||||
const endDate = new Date(album.assets[album.assetCount - 1].createdAt);
|
||||
|
||||
const startDateString = startDate.toLocaleDateString(locale, albumDateFormat);
|
||||
const endDateString = endDate.toLocaleDateString(locale, albumDateFormat);
|
||||
|
||||
// If the start and end date are the same, only show one date
|
||||
return startDateString === endDateString ? startDateString : `${startDateString} - ${endDateString}`;
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
|
||||
Reference in New Issue
Block a user