This commit is contained in:
Rust 2026-08-13 13:56:04 +09:00 committed by GitHub
commit 885c7b488a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 13 deletions

View file

@ -3,18 +3,35 @@
import AssetChangeDateModal from '$lib/modals/AssetChangeDateModal.svelte';
import { locale } from '$lib/stores/preferences.store';
import { fromISODateTime, fromISODateTimeUTC, toTimelineAsset } from '$lib/utils/timeline-util';
import { getModernOffsetForZoneAndDate } from '$lib/modals/timezone-utils';
import { type AssetResponseDto } from '@immich/sdk';
import { Icon, modalManager } from '@immich/ui';
import { mdiCalendar, mdiPencil } from '@mdi/js';
import { t } from 'svelte-i18n';
import { onMount } from 'svelte';
import { websocketEvents } from '$lib/stores/websocket';
type Props = {
asset: AssetResponseDto;
};
const { asset }: Props = $props();
onMount(() => {
return websocketEvents.on('on_asset_update', (assetUpdate) => {
if (assetUpdate.id === asset.id) {
asset = assetUpdate;
}
});
});
let { asset: initialAsset }: Props = $props();
let asset: AssetResponseDto = $state(initialAsset);
const timeZone = $derived(asset.exifInfo?.timeZone ?? undefined);
const modernOffset = $derived(
timeZone && asset.exifInfo?.dateTimeOriginal
? getModernOffsetForZoneAndDate(timeZone, asset.exifInfo.dateTimeOriginal).offsetFormat
: undefined,
);
const dateTime = $derived(
timeZone && asset.exifInfo?.dateTimeOriginal
? fromISODateTime(asset.exifInfo.dateTimeOriginal, timeZone)
@ -59,11 +76,13 @@
hour: 'numeric',
minute: '2-digit',
second: '2-digit',
timeZoneName: timeZone ? 'longOffset' : undefined,
},
{ locale: $locale },
)}
</p>
{#if modernOffset}
GMT{modernOffset}
{/if}
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
import { DateTime, Duration } from 'luxon';
import { DateTime } from 'luxon';
export type ZoneOption = {
/**
@ -136,16 +136,7 @@ export function getPreferredTimeZone(
}
export function toDatetime(selectedDate: string, selectedZone: ZoneOption) {
const dtComponents = DateTime.fromISO(selectedDate, { zone: 'utc' });
// Determine the modern, DST-aware offset for the selected IANA zone
const { offsetMinutes } = getModernOffsetForZoneAndDate(selectedZone.value, selectedDate);
// Construct the final ISO string with a fixed-offset zone.
const fixedOffsetZone = `UTC${offsetMinutes >= 0 ? '+' : ''}${Duration.fromObject({ minutes: offsetMinutes }).toFormat('hh:mm')}`;
// Create a DateTime object in this fixed-offset zone, preserving the local time.
return DateTime.fromObject(dtComponents.toObject(), { zone: fixedOffsetZone });
return DateTime.fromISO(selectedDate, { zone: selectedZone.value });
}
export function toIsoDate(selectedDate: string, selectedZone: ZoneOption) {