mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
Merge 944289cccf into a939561e70
This commit is contained in:
commit
885c7b488a
2 changed files with 23 additions and 13 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue