mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(web): shared link date range (#15802)
This commit is contained in:
parent
844eed8707
commit
c016b65ef2
3 changed files with 57 additions and 25 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { dateFormats } from '$lib/constants';
|
||||
import { locale } from '$lib/stores/preferences.store';
|
||||
import { DateTime, Duration } from 'luxon';
|
||||
import { get } from 'svelte/store';
|
||||
|
|
@ -51,3 +52,28 @@ export const getShortDateRange = (startDate: string | Date, endDate: string | Da
|
|||
return `${startDateLocalized} - ${endDateLocalized}`;
|
||||
}
|
||||
};
|
||||
|
||||
const formatDate = (date?: string) => {
|
||||
if (!date) {
|
||||
return;
|
||||
}
|
||||
|
||||
// without timezone
|
||||
const localDate = date.replace(/Z$/, '').replace(/\+.+$/, '');
|
||||
return localDate ? new Date(localDate).toLocaleDateString(get(locale), dateFormats.album) : undefined;
|
||||
};
|
||||
|
||||
export const getAlbumDateRange = (album: { startDate?: string; endDate?: string }) => {
|
||||
const start = formatDate(album.startDate);
|
||||
const end = formatDate(album.endDate);
|
||||
|
||||
if (start && end && start !== end) {
|
||||
return `${start} - ${end}`;
|
||||
}
|
||||
|
||||
if (start) {
|
||||
return start;
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue