From f88c5ad818fadea7064e7dfbe46f07eae855109a Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 14 May 2025 22:09:46 +0100 Subject: [PATCH] fix(ui): correct timezone handling in OmbiDatePipe - Replace native Date constructor with date-fns parseISO for proper UTC parsing - Use date-fns format function for consistent timezone conversion - Add null check for input value - Fix issue where request times were showing incorrect timezone offset This fixes GitHub issue #5102 where request times were showing different times than the host machine. --- src/Ombi/ClientApp/src/app/pipes/OmbiDatePipe.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/pipes/OmbiDatePipe.ts b/src/Ombi/ClientApp/src/app/pipes/OmbiDatePipe.ts index d7e902242..5c0cc5c3b 100644 --- a/src/Ombi/ClientApp/src/app/pipes/OmbiDatePipe.ts +++ b/src/Ombi/ClientApp/src/app/pipes/OmbiDatePipe.ts @@ -1,5 +1,6 @@ import { Pipe, PipeTransform } from "@angular/core"; import { FormatPipe } from 'ngx-date-fns'; +import { parseISO, format } from 'date-fns'; @Pipe({ name: "ombiDate", @@ -10,8 +11,16 @@ export class OmbiDatePipe implements PipeTransform { private FormatPipe: FormatPipe, ) {} - public transform(value: string, format: string ) { - const date = new Date(value); - return this.FormatPipe.transform(date, format); + public transform(value: string, formatStr: string ) { + if (!value) { + return ''; + } + + // Parse the ISO string as UTC + const utcDate = parseISO(value); + + // Format the date using date-fns format function + // This will automatically handle the UTC to local conversion + return format(utcDate, formatStr); } }