mitai-jinkendo/frontend/src/utils/photoDisplay.js
Lars 0035d08149
All checks were successful
Deploy Development / deploy (push) Successful in 1m4s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s
feat: enhance photo upload and management features
- 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.
2026-04-19 10:13:22 +02:00

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')
}