metadata: refactor date calls

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/672/head
Varun Patil 2023-05-27 16:39:20 -07:00
parent e7cd6d0e60
commit d7de507669
3 changed files with 27 additions and 7 deletions

13
package-lock.json generated
View File

@ -38,6 +38,7 @@
"@nextcloud/webpack-vue-config": "^5.5.1",
"@playwright/test": "^1.33.0",
"@types/hammerjs": "^2.0.41",
"@types/luxon": "^3.3.0",
"@types/url-parse": "^1.4.8",
"@types/videojs-contrib-quality-levels": "^2.0.1",
"playwright": "^1.33.0",
@ -2427,6 +2428,12 @@
"@types/geojson": "*"
}
},
"node_modules/@types/luxon": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==",
"dev": true
},
"node_modules/@types/mdast": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",
@ -13259,6 +13266,12 @@
"@types/geojson": "*"
}
},
"@types/luxon": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==",
"dev": true
},
"@types/mdast": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",

View File

@ -66,6 +66,7 @@
"@nextcloud/webpack-vue-config": "^5.5.1",
"@playwright/test": "^1.33.0",
"@types/hammerjs": "^2.0.41",
"@types/luxon": "^3.3.0",
"@types/url-parse": "^1.4.8",
"@types/videojs-contrib-quality-levels": "^2.0.1",
"playwright": "^1.33.0",

View File

@ -174,17 +174,23 @@ export default defineComponent({
// The fallback to datetaken can be eventually removed
// and then this can be discarded
if (this.exif.DateTimeEpoch) {
const tzOffset: string = this.exif['OffsetTimeOriginal'] || this.exif['OffsetTime']; // e.g. -05:00
const tzId: string = this.exif['LocationTZID']; // e.g. America/New_York
const tzOffset: string = this.exif.OffsetTimeOriginal || this.exif.OffsetTime; // e.g. -05:00
const tzId: string = this.exif.LocationTZID; // e.g. America/New_York
// Use timezone offset if available, otherwise use tzId
let dateWithTz = date.setZone('UTC' + tzOffset);
if (!dateWithTz.isValid) {
dateWithTz = date.setZone(tzId); // Fall back to tzId
let dateWithTz: DateTime | undefined = undefined;
// Use timezone offset if available
if (tzOffset) {
dateWithTz = date.setZone('UTC' + tzOffset);
}
// Fall back to tzId
if (!dateWithTz?.isValid && tzId) {
dateWithTz = date.setZone(tzId);
}
// Use the timezone only if the date is valid
if (dateWithTz.isValid) {
if (dateWithTz?.isValid) {
date = dateWithTz;
}
}