mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-05 20:51:13 -07:00
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.
This commit is contained in:
parent
b3e8ca6950
commit
f88c5ad818
1 changed files with 12 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { Pipe, PipeTransform } from "@angular/core";
|
import { Pipe, PipeTransform } from "@angular/core";
|
||||||
import { FormatPipe } from 'ngx-date-fns';
|
import { FormatPipe } from 'ngx-date-fns';
|
||||||
|
import { parseISO, format } from 'date-fns';
|
||||||
|
|
||||||
@Pipe({
|
@Pipe({
|
||||||
name: "ombiDate",
|
name: "ombiDate",
|
||||||
|
@ -10,8 +11,16 @@ export class OmbiDatePipe implements PipeTransform {
|
||||||
private FormatPipe: FormatPipe,
|
private FormatPipe: FormatPipe,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public transform(value: string, format: string ) {
|
public transform(value: string, formatStr: string ) {
|
||||||
const date = new Date(value);
|
if (!value) {
|
||||||
return this.FormatPipe.transform(date, format);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue