mirror of
https://github.com/immich-app/immich.git
synced 2026-02-11 19:38:54 +03:00
fix: time zone upserts
This commit is contained in:
@@ -1766,13 +1766,14 @@ describe(MetadataService.name, () => {
|
||||
const asset = factory.jobAssets.sidecarWrite();
|
||||
const description = 'this is a description';
|
||||
const gps = 12;
|
||||
const date = '2023-11-22T04:56:12.196Z';
|
||||
const date = '2023-11-22T04:56:12.196-06:00';
|
||||
|
||||
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([
|
||||
'description',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'dateTimeOriginal',
|
||||
'timeZone',
|
||||
]);
|
||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
||||
await expect(
|
||||
@@ -1786,12 +1787,14 @@ describe(MetadataService.name, () => {
|
||||
ImageDescription: description,
|
||||
GPSLatitude: gps,
|
||||
GPSLongitude: gps,
|
||||
TimeZone: '-06:00',
|
||||
});
|
||||
expect(mocks.asset.unlockProperties).toHaveBeenCalledWith(asset.id, [
|
||||
'description',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'dateTimeOriginal',
|
||||
'timeZone',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -431,27 +431,33 @@ export class MetadataService extends BaseService {
|
||||
const { sidecarFile } = getAssetFiles(asset.files);
|
||||
const sidecarPath = sidecarFile?.path || `${asset.originalPath}.xmp`;
|
||||
|
||||
const { description, dateTimeOriginal, latitude, longitude, rating, tags } = _.pick(
|
||||
const { description, dateTimeOriginal, latitude, longitude, rating, tags, timeZone } = _.pick(
|
||||
{
|
||||
description: asset.exifInfo.description,
|
||||
dateTimeOriginal: asset.exifInfo.dateTimeOriginal,
|
||||
dateTimeOriginal: asset.exifInfo.dateTimeOriginal as string | null,
|
||||
latitude: asset.exifInfo.latitude,
|
||||
longitude: asset.exifInfo.longitude,
|
||||
rating: asset.exifInfo.rating,
|
||||
tags: asset.exifInfo.tags,
|
||||
timeZone: asset.exifInfo.timeZone,
|
||||
},
|
||||
lockedProperties,
|
||||
);
|
||||
|
||||
const tzOffset = timeZone ? DateTime.now().setZone(timeZone).toFormat('ZZ') : undefined;
|
||||
|
||||
const exif = _.omitBy(
|
||||
<Tags>{
|
||||
Description: description,
|
||||
ImageDescription: description,
|
||||
DateTimeOriginal: dateTimeOriginal ? String(dateTimeOriginal) : undefined,
|
||||
DateTimeOriginal: dateTimeOriginal
|
||||
? DateTime.fromISO(dateTimeOriginal, { zone: 'UTC' }).setZone(tzOffset, { keepLocalTime: true }).toISO()
|
||||
: undefined,
|
||||
GPSLatitude: latitude,
|
||||
GPSLongitude: longitude,
|
||||
Rating: rating,
|
||||
TagsList: tags?.length ? tags : undefined,
|
||||
TimeZone: tzOffset,
|
||||
},
|
||||
_.isUndefined,
|
||||
);
|
||||
|
||||
@@ -361,6 +361,7 @@ const assetSidecarWriteFactory = () => {
|
||||
latitude: 12,
|
||||
longitude: 12,
|
||||
dateTimeOriginal: '2023-11-22T04:56:12.196Z',
|
||||
timeZone: 'UTC-6',
|
||||
} as unknown as Exif,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user