mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
feat(web): select the EXIF timezone (if it exists) in dropdown (#12495)
This commit is contained in:
parent
9323b69c61
commit
8c3c3357fe
2 changed files with 6 additions and 2 deletions
|
@ -331,8 +331,10 @@
|
||||||
locale: $locale,
|
locale: $locale,
|
||||||
})
|
})
|
||||||
: DateTime.now()}
|
: DateTime.now()}
|
||||||
|
{@const assetTimeZoneOriginal = asset.exifInfo?.timeZone ?? ''}
|
||||||
<ChangeDate
|
<ChangeDate
|
||||||
initialDate={assetDateTimeOriginal}
|
initialDate={assetDateTimeOriginal}
|
||||||
|
initialTimeZone={assetTimeZoneOriginal}
|
||||||
on:confirm={({ detail: date }) => handleConfirmChangeDate(date)}
|
on:confirm={({ detail: date }) => handleConfirmChangeDate(date)}
|
||||||
on:cancel={() => (isShowChangeDate = false)}
|
on:cancel={() => (isShowChangeDate = false)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
|
||||||
export let initialDate: DateTime = DateTime.now();
|
export let initialDate: DateTime = DateTime.now();
|
||||||
|
export let initialTimeZone: string = '';
|
||||||
|
|
||||||
type ZoneOption = {
|
type ZoneOption = {
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +77,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the time zone to select for a given time, date, and offset (e.g. +02:00).
|
* If the time zone is not given, find the timezone to select for a given time, date, and offset (e.g. +02:00).
|
||||||
*
|
*
|
||||||
* This is done so that the list shown to the user includes more helpful names like "Europe/Berlin (+02:00)"
|
* This is done so that the list shown to the user includes more helpful names like "Europe/Berlin (+02:00)"
|
||||||
* instead of just the raw offset or something like "UTC+02:00".
|
* instead of just the raw offset or something like "UTC+02:00".
|
||||||
|
@ -97,6 +98,7 @@
|
||||||
) {
|
) {
|
||||||
const offset = date.offset;
|
const offset = date.offset;
|
||||||
const previousSelection = timezones.find((item) => item.value === selectedOption?.value);
|
const previousSelection = timezones.find((item) => item.value === selectedOption?.value);
|
||||||
|
const fromInitialTimeZone = timezones.find((item) => item.value === initialTimeZone);
|
||||||
const sameAsUserTimeZone = timezones.find((item) => item.offsetMinutes === offset && item.value === userTimeZone);
|
const sameAsUserTimeZone = timezones.find((item) => item.offsetMinutes === offset && item.value === userTimeZone);
|
||||||
const firstWithSameOffset = timezones.find((item) => item.offsetMinutes === offset);
|
const firstWithSameOffset = timezones.find((item) => item.offsetMinutes === offset);
|
||||||
const utcFallback = {
|
const utcFallback = {
|
||||||
|
@ -105,7 +107,7 @@
|
||||||
value: 'UTC',
|
value: 'UTC',
|
||||||
valid: true,
|
valid: true,
|
||||||
};
|
};
|
||||||
return previousSelection ?? sameAsUserTimeZone ?? firstWithSameOffset ?? utcFallback;
|
return previousSelection ?? fromInitialTimeZone ?? sameAsUserTimeZone ?? firstWithSameOffset ?? utcFallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortTwoZones(zoneA: ZoneOption, zoneB: ZoneOption) {
|
function sortTwoZones(zoneA: ZoneOption, zoneB: ZoneOption) {
|
||||||
|
|
Loading…
Reference in a new issue