Merge pull request #273 from kylmp/exif-timezone
# Conflicts: # app/tests/assetMetadata.test.ts
This commit is contained in:
@@ -22,6 +22,8 @@ const asset = (): Asset => ({
|
||||
originalMimeType: 'image/heic',
|
||||
exifInfo: {
|
||||
description: 'A nice photo',
|
||||
dateTimeOriginal: '2025-10-18T06:28:54.000Z',
|
||||
timeZone: 'Asia/Singapore',
|
||||
make: 'Canon',
|
||||
model: 'EOS R5',
|
||||
city: 'Paris',
|
||||
@@ -94,6 +96,19 @@ describe('buildAssetMetadata', () => {
|
||||
expect(buildAssetMetadata(photo, share()).exif).toMatchObject({ width, height })
|
||||
})
|
||||
|
||||
it('returns the photo timezone only when both date and timezone are enabled', () => {
|
||||
setConfig({ ipp: { showMetadata: { exif: { dateTimeOriginal: true, timeZone: true } } } })
|
||||
const meta = buildAssetMetadata(asset(), share())
|
||||
expect(meta.exif?.dateTimeOriginal).toBe('2025-10-18T06:28:54.000Z')
|
||||
expect(meta.exif?.timeZone).toBe('Asia/Singapore')
|
||||
|
||||
setConfig({ ipp: { showMetadata: { exif: { dateTimeOriginal: true } } } })
|
||||
expect(buildAssetMetadata(asset(), share()).exif?.timeZone).toBeUndefined()
|
||||
|
||||
setConfig({ ipp: { showMetadata: { exif: { timeZone: true } } } })
|
||||
expect(buildAssetMetadata(asset(), share()).exif).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns description when a description surface is enabled', () => {
|
||||
setConfig({ ipp: { showMetadata: { description: { sidebar: true } } } })
|
||||
const meta = buildAssetMetadata(asset(), share())
|
||||
|
||||
@@ -186,6 +186,7 @@ describe('metadataEnabled shim', () => {
|
||||
const exif = ((config.ipp as Record<string, unknown>).showMetadata as Record<string, unknown>).exif as Record<string, unknown>
|
||||
expect(exif.enabled).toBeUndefined()
|
||||
expect(exif.dateTimeOriginal).toBe(true)
|
||||
expect(exif.timeZone).toBeUndefined()
|
||||
expect(exif.fileName).toBe(true)
|
||||
expect(exif.dimensions).toBe(true)
|
||||
expect(exif.fileSize).toBe(true)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { formatDate } from '../src/client/sidebar'
|
||||
|
||||
describe('sidebar date formatting', () => {
|
||||
const capturedAt = '2025-10-18T06:28:54.000Z'
|
||||
|
||||
it('formats the capture instant in the photo IANA timezone', () => {
|
||||
const formatted = formatDate(capturedAt, 'Asia/Singapore')
|
||||
expect(formatted.date).toBe('Oct 18, 2025')
|
||||
expect(formatted.time).toContain('Sat')
|
||||
expect(formatted.time).toContain('2:28:54 PM')
|
||||
expect(formatted.time).toContain('GMT+08:00')
|
||||
})
|
||||
|
||||
it('supports legacy fixed-offset timezones from Immich', () => {
|
||||
const formatted = formatDate(capturedAt, 'UTC+8')
|
||||
expect(formatted.date).toBe('Oct 18, 2025')
|
||||
expect(formatted.time).toContain('2:28:54 PM')
|
||||
expect(formatted.time).toContain('GMT+08:00')
|
||||
})
|
||||
|
||||
it('retains the original value when the timestamp is invalid', () => {
|
||||
expect(formatDate('not-a-date', 'Asia/Singapore')).toEqual({ date: 'not-a-date', time: '' })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user