- Added `taken_at` timestamp to the photos table for improved photo metadata. - Updated the photo upload API to support optional EXIF data extraction and file last modified timestamp. - Enhanced the photo upload process to allow skipping EXIF data, defaulting to today's date if no other date is provided. - Improved the photo display in various components to utilize a unified caption format. - Refactored photo sorting and grouping logic for better organization in the UI.
26 lines
895 B
JavaScript
26 lines
895 B
JavaScript
import dayjs from 'dayjs'
|
|
|
|
/** Monatsschlüssel YYYY-MM für Gruppierung (EXIF-Zeit bevorzugt). */
|
|
export function photoMonthKey(p) {
|
|
if (p.taken_at) return p.taken_at.slice(0, 7)
|
|
if (p.date) {
|
|
return typeof p.date === 'string' ? p.date.slice(0, 7) : dayjs(p.date).format('YYYY-MM')
|
|
}
|
|
return (p.created || '').slice(0, 7) || '0000-00'
|
|
}
|
|
|
|
/** Sortierung: ISO-Zeit oder Datum. */
|
|
export function photoSortKey(p) {
|
|
if (p.taken_at) return p.taken_at
|
|
const d = p.date || p.created || ''
|
|
return typeof d === 'string' ? d.slice(0, 10) : dayjs(d).format('YYYY-MM-DD')
|
|
}
|
|
|
|
/** Badge / Untertitel: mit Uhrzeit wenn EXIF vorhanden. */
|
|
export function formatPhotoCaption(p) {
|
|
if (p.taken_at) return dayjs(p.taken_at).format('DD.MM.YYYY HH:mm')
|
|
const raw = p.date || p.created
|
|
if (!raw) return ''
|
|
return typeof raw === 'string' ? raw.slice(0, 10) : dayjs(raw).format('DD.MM.YYYY')
|
|
}
|