metadata: refactor date calls
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/672/head
parent
e7cd6d0e60
commit
d7de507669
|
@ -38,6 +38,7 @@
|
||||||
"@nextcloud/webpack-vue-config": "^5.5.1",
|
"@nextcloud/webpack-vue-config": "^5.5.1",
|
||||||
"@playwright/test": "^1.33.0",
|
"@playwright/test": "^1.33.0",
|
||||||
"@types/hammerjs": "^2.0.41",
|
"@types/hammerjs": "^2.0.41",
|
||||||
|
"@types/luxon": "^3.3.0",
|
||||||
"@types/url-parse": "^1.4.8",
|
"@types/url-parse": "^1.4.8",
|
||||||
"@types/videojs-contrib-quality-levels": "^2.0.1",
|
"@types/videojs-contrib-quality-levels": "^2.0.1",
|
||||||
"playwright": "^1.33.0",
|
"playwright": "^1.33.0",
|
||||||
|
@ -2427,6 +2428,12 @@
|
||||||
"@types/geojson": "*"
|
"@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": {
|
"node_modules/@types/mdast": {
|
||||||
"version": "3.0.10",
|
"version": "3.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",
|
||||||
|
@ -13259,6 +13266,12 @@
|
||||||
"@types/geojson": "*"
|
"@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": {
|
"@types/mdast": {
|
||||||
"version": "3.0.10",
|
"version": "3.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.10.tgz",
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"@nextcloud/webpack-vue-config": "^5.5.1",
|
"@nextcloud/webpack-vue-config": "^5.5.1",
|
||||||
"@playwright/test": "^1.33.0",
|
"@playwright/test": "^1.33.0",
|
||||||
"@types/hammerjs": "^2.0.41",
|
"@types/hammerjs": "^2.0.41",
|
||||||
|
"@types/luxon": "^3.3.0",
|
||||||
"@types/url-parse": "^1.4.8",
|
"@types/url-parse": "^1.4.8",
|
||||||
"@types/videojs-contrib-quality-levels": "^2.0.1",
|
"@types/videojs-contrib-quality-levels": "^2.0.1",
|
||||||
"playwright": "^1.33.0",
|
"playwright": "^1.33.0",
|
||||||
|
|
|
@ -174,17 +174,23 @@ export default defineComponent({
|
||||||
// The fallback to datetaken can be eventually removed
|
// The fallback to datetaken can be eventually removed
|
||||||
// and then this can be discarded
|
// and then this can be discarded
|
||||||
if (this.exif.DateTimeEpoch) {
|
if (this.exif.DateTimeEpoch) {
|
||||||
const tzOffset: string = this.exif['OffsetTimeOriginal'] || this.exif['OffsetTime']; // e.g. -05:00
|
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 tzId: string = this.exif.LocationTZID; // e.g. America/New_York
|
||||||
|
|
||||||
// Use timezone offset if available, otherwise use tzId
|
let dateWithTz: DateTime | undefined = undefined;
|
||||||
let dateWithTz = date.setZone('UTC' + tzOffset);
|
|
||||||
if (!dateWithTz.isValid) {
|
// Use timezone offset if available
|
||||||
dateWithTz = date.setZone(tzId); // Fall back to tzId
|
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
|
// Use the timezone only if the date is valid
|
||||||
if (dateWithTz.isValid) {
|
if (dateWithTz?.isValid) {
|
||||||
date = dateWithTz;
|
date = dateWithTz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue