From c1ea39aa14b5fa30eb694192b1c9a43b2aa81a66 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Wed, 10 Dec 2025 17:40:32 -0800 Subject: [PATCH] normalize dates to UTC, remove year to date conversions --- src/shared/api/jellyfin/jellyfin-normalize.ts | 8 ++------ src/shared/api/navidrome/navidrome-normalize.ts | 16 ++++------------ src/shared/api/subsonic/subsonic-normalize.ts | 8 +++++++- src/shared/api/subsonic/subsonic-types.ts | 1 + src/shared/types/domain-types.ts | 1 - 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/shared/api/jellyfin/jellyfin-normalize.ts b/src/shared/api/jellyfin/jellyfin-normalize.ts index 24105b3ac..3baa5a316 100644 --- a/src/shared/api/jellyfin/jellyfin-normalize.ts +++ b/src/shared/api/jellyfin/jellyfin-normalize.ts @@ -256,11 +256,7 @@ const normalizeSong = ( peak: null, playCount: (item.UserData && item.UserData.PlayCount) || 0, playlistItemId: item.PlaylistItemId, - releaseDate: item.PremiereDate - ? new Date(item.PremiereDate).toISOString() - : item.ProductionYear - ? new Date(item.ProductionYear, 0, 1).toISOString() - : null, + releaseDate: item.PremiereDate ? item.PremiereDate : null, releaseYear: item.ProductionYear || null, sampleRate, size, @@ -326,7 +322,7 @@ const normalizeAlbum = ( participants: getPeople(item), playCount: item.UserData?.PlayCount || 0, recordLabels: [], - releaseDate: item.PremiereDate?.split('T')[0] || null, + releaseDate: item.PremiereDate || null, releaseTypes: [], releaseYear: item.ProductionYear || null, size: null, diff --git a/src/shared/api/navidrome/navidrome-normalize.ts b/src/shared/api/navidrome/navidrome-normalize.ts index cd73707a1..f710f311f 100644 --- a/src/shared/api/navidrome/navidrome-normalize.ts +++ b/src/shared/api/navidrome/navidrome-normalize.ts @@ -162,7 +162,7 @@ const normalizeSong = ( comment: item.comment ? item.comment : null, compilation: item.compilation, container: item.suffix, - createdAt: item.createdAt.split('T')[0], + createdAt: item.createdAt, discNumber: item.discNumber, discSubtitle: item.discSubtitle ? item.discSubtitle : null, duration: item.duration * 1000, @@ -287,7 +287,7 @@ const normalizeAlbum = ( albumArtist: item.albumArtist, backdropImageUrl: imageBackdropUrl, comment: item.comment || null, - createdAt: item.createdAt.split('T')[0], + createdAt: item.createdAt, duration: item.duration !== undefined ? item.duration * 1000 : null, explicitStatus: item.explicitStatus === 'e' @@ -308,21 +308,13 @@ const normalizeAlbum = ( id: item.id, imagePlaceholderUrl, imageUrl, - isCompilation: item.compilation, lastPlayedAt: normalizePlayDate(item), mbzId: item.mbzAlbumId || null, name: item.name, - originalDate: item.originalDate - ? new Date(item.originalDate).toISOString() - : item.originalYear - ? new Date(Date.UTC(item.originalYear, 0, 1)).toISOString() - : null, + originalDate: item.originalDate ? new Date(item.originalDate).toISOString() : null, playCount: item.playCount || 0, - releaseDate: (item.releaseDate - ? new Date(item.releaseDate) - : new Date(Date.UTC(item.minYear, 0, 1)) - ).toISOString(), + releaseDate: item.releaseDate ? new Date(item.releaseDate).toISOString() : null, releaseYear: item.minYear || null, size: item.size, songCount: item.songCount, diff --git a/src/shared/api/subsonic/subsonic-normalize.ts b/src/shared/api/subsonic/subsonic-normalize.ts index fbc1e61d9..6e6d577a0 100644 --- a/src/shared/api/subsonic/subsonic-normalize.ts +++ b/src/shared/api/subsonic/subsonic-normalize.ts @@ -280,7 +280,13 @@ const normalizeAlbum = ( participants: getParticipants(item), playCount: null, recordLabels: item.recordLabels?.map((item) => item.name) || [], - releaseDate: item.year ? new Date(Date.UTC(item.year, 0, 1)).toISOString() : null, + releaseDate: item.releaseDate + ? new Date( + item.releaseDate.year, + item.releaseDate.month - 1, + item.releaseDate.day, + ).toISOString() + : null, releaseTypes: item.releaseTypes || [], releaseYear: item.year || null, size: null, diff --git a/src/shared/api/subsonic/subsonic-types.ts b/src/shared/api/subsonic/subsonic-types.ts index 6f6ba9088..fbb5c4983 100644 --- a/src/shared/api/subsonic/subsonic-types.ts +++ b/src/shared/api/subsonic/subsonic-types.ts @@ -164,6 +164,7 @@ const album = z.object({ name: z.string(), parent: z.string(), recordLabels: z.array(recordLabel).optional(), + releaseDate: z.object({ day: z.number(), month: z.number(), year: z.number() }).optional(), releaseTypes: z.array(z.string()).optional(), song: z.array(song), songCount: z.number(), diff --git a/src/shared/types/domain-types.ts b/src/shared/types/domain-types.ts index 1dd39752d..25813c771 100644 --- a/src/shared/types/domain-types.ts +++ b/src/shared/types/domain-types.ts @@ -232,7 +232,6 @@ export type Artist = { createdAt: string; id: string; name: string; - remoteCreatedAt: null | string; updatedAt: string; };