2025-01-12 15:40:21 -05:00

21 lines
537 B
TypeScript

import { ExifDateTime } from 'exiftool-vendored';
import type { ImageMetadata } from '@hk/photographer-toolbox/types';
import { ImageMetadataMod } from '../src/types.ts';
export function convertDate(data: ImageMetadata): ImageMetadataMod {
const dateKeys = [
'DateTimeOriginal',
'FileModifyDate',
'ModifyDate',
'CreateDate',
'dateCreated',
'dateModified'
];
for (const key of dateKeys) {
if (data[key] && typeof data[key] !== 'string') {
data[key] = (data[key] as ExifDateTime).toISOString();
}
}
return data;
}