Skip to content

Commit

Permalink
feat(web): select the EXIF timezone (if it exists) in dropdown (#12495)
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Otto authored Sep 9, 2024
1 parent 9323b69 commit 8c3c335
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions web/src/lib/components/asset-viewer/detail-panel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@
locale: $locale,
})
: DateTime.now()}
{@const assetTimeZoneOriginal = asset.exifInfo?.timeZone ?? ''}
<ChangeDate
initialDate={assetDateTimeOriginal}
initialTimeZone={assetTimeZoneOriginal}
on:confirm={({ detail: date }) => handleConfirmChangeDate(date)}
on:cancel={() => (isShowChangeDate = false)}
/>
Expand Down
6 changes: 4 additions & 2 deletions web/src/lib/components/shared-components/change-date.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { t } from 'svelte-i18n';
export let initialDate: DateTime = DateTime.now();
export let initialTimeZone: string = '';
type ZoneOption = {
/**
Expand Down Expand Up @@ -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)"
* instead of just the raw offset or something like "UTC+02:00".
Expand All @@ -97,6 +98,7 @@
) {
const offset = date.offset;
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 firstWithSameOffset = timezones.find((item) => item.offsetMinutes === offset);
const utcFallback = {
Expand All @@ -105,7 +107,7 @@
value: 'UTC',
valid: true,
};
return previousSelection ?? sameAsUserTimeZone ?? firstWithSameOffset ?? utcFallback;
return previousSelection ?? fromInitialTimeZone ?? sameAsUserTimeZone ?? firstWithSameOffset ?? utcFallback;
}
function sortTwoZones(zoneA: ZoneOption, zoneB: ZoneOption) {
Expand Down

0 comments on commit 8c3c335

Please sign in to comment.