mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(web): show full date when hovering over photos date groups (#16561)
* fix(web): Update asset grid date group titles to show full date * Fix formatting
This commit is contained in:
parent
e0a09f2ea0
commit
decc878267
2 changed files with 13 additions and 12 deletions
|
|
@ -4,7 +4,7 @@ import { emptyGeometry, type CommonJustifiedLayout } from '$lib/utils/layout-uti
|
|||
|
||||
import type { AssetResponseDto } from '@immich/sdk';
|
||||
import { groupBy, memoize, sortBy } from 'lodash-es';
|
||||
import { DateTime } from 'luxon';
|
||||
import { DateTime, type LocaleOptions } from 'luxon';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export type DateGroup = {
|
||||
|
|
@ -40,13 +40,6 @@ export const fromLocalDateTime = (localDateTime: string) =>
|
|||
export const fromDateTimeOriginal = (dateTimeOriginal: string, timeZone: string) =>
|
||||
DateTime.fromISO(dateTimeOriginal, { zone: timeZone });
|
||||
|
||||
export const groupDateFormat: Intl.DateTimeFormatOptions = {
|
||||
weekday: 'short',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
};
|
||||
|
||||
export function formatGroupTitle(_date: DateTime): string {
|
||||
if (!_date.isValid) {
|
||||
return _date.toString();
|
||||
|
|
@ -78,14 +71,17 @@ export function formatGroupTitle(_date: DateTime): string {
|
|||
});
|
||||
}
|
||||
|
||||
return date.toLocaleString(groupDateFormat);
|
||||
return getDateLocaleString(date);
|
||||
}
|
||||
|
||||
export const getDateLocaleString = (date: DateTime, opts?: LocaleOptions): string =>
|
||||
date.toLocaleString(DateTime.DATE_MED_WITH_WEEKDAY, opts);
|
||||
|
||||
const formatDateGroupTitle = memoize(formatGroupTitle);
|
||||
|
||||
export function splitBucketIntoDateGroups(bucket: AssetBucket, locale: string | undefined): DateGroup[] {
|
||||
const grouped = groupBy(bucket.assets, (asset) =>
|
||||
fromLocalDateTime(asset.localDateTime).toLocaleString(groupDateFormat, { locale }),
|
||||
getDateLocaleString(fromLocalDateTime(asset.localDateTime), { locale }),
|
||||
);
|
||||
const sorted = sortBy(grouped, (group) => bucket.assets.indexOf(group[0]));
|
||||
return sorted.map((group) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue