From fd4357cf231cb2dcf44481aa8104419a23f80645 Mon Sep 17 00:00:00 2001 From: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Date: Sat, 27 May 2023 23:24:07 +0200 Subject: [PATCH] fix(server): exif time extraction (#2583) --- .../src/processors/metadata-extraction.processor.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/apps/microservices/src/processors/metadata-extraction.processor.ts b/server/apps/microservices/src/processors/metadata-extraction.processor.ts index 6f2f8ec5e9..af8767a35b 100644 --- a/server/apps/microservices/src/processors/metadata-extraction.processor.ts +++ b/server/apps/microservices/src/processors/metadata-extraction.processor.ts @@ -115,12 +115,12 @@ export class MetadataExtractionProcessor { }) : {}; - const exifToDate = (exifDate: string | ExifDateTime | undefined) => { + const exifToDate = (exifDate: string | Date | ExifDateTime | undefined) => { if (!exifDate) { return null; } - const date = typeof exifDate === 'string' ? new Date(exifDate) : exifDate.toDate(); + const date = exifDate instanceof ExifDateTime ? exifDate.toDate() : new Date(exifDate); if (isNaN(date.valueOf())) { return null; } @@ -128,10 +128,9 @@ export class MetadataExtractionProcessor { return date; }; - const exifTimeZone = (exifDate: string | ExifDateTime | undefined) => { - if (!exifDate) return null; - - if (typeof exifDate === 'string') { + const exifTimeZone = (exifDate: string | Date | ExifDateTime | undefined) => { + const isExifDate = exifDate instanceof ExifDateTime; + if (!isExifDate) { return null; }