mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
fix(core): date formatter timezone issue (#5936)
date seems not hornoring the locale browser's locale when parsing date string like "2024-02-28". fixed by using dayjs instead. Fix incorrect journal title issue
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
const timeFormatter = new Intl.DateTimeFormat(undefined, {
|
const timeFormatter = new Intl.DateTimeFormat(undefined, {
|
||||||
timeStyle: 'short',
|
timeStyle: 'short',
|
||||||
});
|
});
|
||||||
@@ -9,9 +11,9 @@ const dateFormatter = new Intl.DateTimeFormat(undefined, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const timestampToLocalTime = (ts: string | number) => {
|
export const timestampToLocalTime = (ts: string | number) => {
|
||||||
return timeFormatter.format(new Date(ts));
|
return timeFormatter.format(dayjs(ts).toDate());
|
||||||
};
|
};
|
||||||
|
|
||||||
export const timestampToLocalDate = (ts: string | number) => {
|
export const timestampToLocalDate = (ts: string | number) => {
|
||||||
return dateFormatter.format(new Date(ts));
|
return dateFormatter.format(dayjs(ts).toDate());
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user