metadata: fix display of mtime (fix #666)

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/672/head
Varun Patil 2023-05-27 17:10:20 -07:00
parent d7de507669
commit 7b027a1fe9
2 changed files with 15 additions and 8 deletions

View File

@ -202,14 +202,15 @@ class Exif
}
// Fall back to modification time
try {
$parseTz = new \DateTimeZone(getenv('TZ')); // debian
} catch (\Error $e) {
$parseTz = new \DateTimeZone('UTC');
}
$dt = new \DateTime('@'.$file->getMtime());
$dt = new \DateTime('@'.$file->getMtime(), $parseTz);
$dt->setTimezone($parseTz);
// Set timezone to system timezone
$tz = getenv('TZ') ?: date_default_timezone_get();
try {
$dt->setTimezone(new \DateTimeZone($tz));
} catch (\Exception $e) {
throw new \Error("FATAL: system timezone is invalid (TZ): $tz");
}
return self::forgetTimezone($dt);
}

View File

@ -179,8 +179,14 @@ export default defineComponent({
let dateWithTz: DateTime | undefined = undefined;
// If no timezone info is available, we will show the local time only
// In this case, everything happens in UTC
if (!tzOffset && !tzId) {
dateWithTz = date.setZone('UTC');
}
// Use timezone offset if available
if (tzOffset) {
if (!dateWithTz?.isValid && tzOffset) {
dateWithTz = date.setZone('UTC' + tzOffset);
}