date issue fixed4
This commit is contained in:
@@ -52,10 +52,19 @@ export function toUTCDate(date: Date): Date {
|
|||||||
* and formats it as local yyyy-MM-dd string for UI use.
|
* and formats it as local yyyy-MM-dd string for UI use.
|
||||||
*/
|
*/
|
||||||
export function formatUTCDateStringToLocal(dateStr: string): string {
|
export function formatUTCDateStringToLocal(dateStr: string): string {
|
||||||
const date = new Date(dateStr); // parsed as UTC
|
const date = new Date(dateStr); // still UTC
|
||||||
return formatLocalDate(date);
|
|
||||||
|
// Create a local Date object with same year, month, day from UTC
|
||||||
|
const localDate = new Date(
|
||||||
|
date.getUTCFullYear(),
|
||||||
|
date.getUTCMonth(),
|
||||||
|
date.getUTCDate()
|
||||||
|
);
|
||||||
|
|
||||||
|
return formatLocalDate(localDate); // now safely in local time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure any date (Date|string) is formatted to ISO string for consistent backend storage.
|
* Ensure any date (Date|string) is formatted to ISO string for consistent backend storage.
|
||||||
* If it's already a string, pass through. If it's a Date, convert to ISO.
|
* If it's already a string, pass through. If it's a Date, convert to ISO.
|
||||||
|
|||||||
Reference in New Issue
Block a user