Hide taken at time in photo meta when configured to do so

This commit is contained in:
Sam Becker 2025-01-22 19:39:38 -06:00
parent 59399bd703
commit 4fb92fb05c
3 changed files with 9 additions and 3 deletions

View File

@ -8,11 +8,13 @@ export default function PhotoDate({
className,
dateType = 'takenAt',
timezone,
hideTime,
}: {
photo: Photo
className?: string
dateType?: 'takenAt' | 'createdAt' | 'updatedAt'
timezone: Timezone
hideTime?: boolean
}) {
const date = useMemo(() => {
const date = new Date(dateType === 'takenAt'
@ -45,6 +47,7 @@ export default function PhotoDate({
className,
titleLabel: getTitleLabel(),
timezone,
hideTime,
}} />
);
}

View File

@ -28,6 +28,7 @@ import PhotoLink from './PhotoLink';
import {
SHOULD_PREFETCH_ALL_LINKS,
ALLOW_PUBLIC_DOWNLOADS,
SHOW_TAKEN_AT_TIME,
} from '@/site/config';
import AdminPhotoMenuClient from '@/admin/AdminPhotoMenuClient';
import { RevalidatePhoto } from './InfinitePhotoScroll';
@ -248,8 +249,10 @@ export default function PhotoLarge({
!hasNonDateContent && isUserSignedIn && 'md:pr-7',
)}
// Created at is a naive datetime which
// does not require a timezone
// does not require a timezone and will not
// cause server/client time mismatch
timezone={null}
hideTime={!SHOW_TAKEN_AT_TIME}
/>
<div className={clsx(
'flex gap-1 translate-y-[0.5px]',

View File

@ -55,10 +55,10 @@ export const formatDate = ({
case 'medium':
formatString = !hideTime
? DATE_STRING_FORMAT_MEDIUM
: DATE_STRING_FORMAT_TINY;
: DATE_STRING_FORMAT_SHORT;
placeholderString = !hideTime
? DATE_STRING_FORMAT_MEDIUM_PLACEHOLDER
: DATE_STRING_FORMAT_TINY_PLACEHOLDER;
: DATE_STRING_FORMAT_SHORT_PLACEHOLDER;
break;
}