fix: timestamp handling for database backup in Web UI#27359
Open
AfonsoMendoncaRibeiro wants to merge 1 commit intoimmich-app:mainfrom
Open
fix: timestamp handling for database backup in Web UI#27359AfonsoMendoncaRibeiro wants to merge 1 commit intoimmich-app:mainfrom
AfonsoMendoncaRibeiro wants to merge 1 commit intoimmich-app:mainfrom
Conversation
…eb UI Frontend parsed backup timestamps as UTC, but they were in the server's local timezone, causing wrong relative times. Add `timezone` field to DatabaseBackupDto to expose server timezone. Update frontend to parse timestamps using this timezone. Convert timestamps to user's local timezone before rendering. Fallback to browser timezone if server timezone is missing. Ensures correct relative time display in Web UI.
|
Label error. Requires exactly 1 of: changelog:.*. Found: 🖥️web, 🗄️server. A maintainer will add the required label. |
| @@ -283,6 +281,7 @@ export class DatabaseBackupService { | |||
| async listBackups(): Promise<DatabaseBackupListResponseDto> { | |||
| const backupsFolder = StorageCore.getBaseFolder(StorageFolder.Backups); | |||
| const files = await this.storageRepository.readdir(backupsFolder); | |||
| const timezone = DateTime.local().zoneName; | |||
Member
There was a problem hiding this comment.
I assume this will get the timezone set from the TZ variable?
There was a problem hiding this comment.
Exactly, your assumption is correct.
There was a problem hiding this comment.
I can also add a short comment in the code if you'd like, to make that behavior clearer.
| @@ -16,6 +16,8 @@ | |||
| expectedVersion: string; | |||
| }; | |||
|
|
|||
| type BackupWithTimezone = DatabaseBackupDto & { timezone?: string }; | |||
Member
There was a problem hiding this comment.
Why do you need a custom type here? Can you run make open-api to generate the correct type from your changes on the server?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backup timestamps embedded in filenames are server-local times, but the Web UI previously parsed them as UTC, causing incorrect relative times for users in different timezones.
The changes in this PR add an optional 'timezone' field to 'DatabaseBackupDto' and populate it from the server timezone when listing backups.
On the frontend, backup timestamps are now parsed using the server timezone and then converted to the user's local timezone before rendering relative time.
This keeps API compatibility (since it is an optional field) while fixing relative-time display across timezones.
I also included UI test coverage for non-UTC timezone parsing and user-local relative rendering.
Fixes #26502
How Has This Been Tested?
Reproduction steps:
pnpm --filter immich-web test -- src/lib/components/maintenance/MaintenanceBackupEntry.spec.ts
Screenshots (if appropriate)
Checklist:
src/services/uses repositories implementations for database calls, filesystem operations, etc.src/repositories/is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services/)Please describe to which degree, if any, an LLM was used in creating this pull request.
I used an LLM only for initial project understanding and navigation guidance (Immich overview, codebase orientation, and Svelte/TypeScript concepts). The implementation and final changes were done by me.
...