fix(client): 🐛 attempt to fix the one-off date issue

use utc functions from dayjs to correspond to the same date on the server
This commit is contained in:
Amruth Pillai
2022-07-31 02:13:08 -08:00
parent 1c19062c63
commit 5197f954c0
14 changed files with 33 additions and 25 deletions

View File

@ -19,7 +19,7 @@ export const dateFormatOptions: string[] = [
'YYYY',
];
export const getRelativeTime = (timestamp: dayjs.ConfigType): string => dayjs(timestamp).toNow(true);
export const getRelativeTime = (timestamp: dayjs.ConfigType): string => dayjs(timestamp).utc().toNow(true);
export const formatDateString = (date: string | DateRange, formatStr: string): string | null => {
const presentString = i18n?.t<string>('common.date.present') ?? '';
@ -28,9 +28,9 @@ export const formatDateString = (date: string | DateRange, formatStr: string): s
// If `date` is a string
if (isString(date)) {
if (!dayjs(date).isValid()) return null;
if (!dayjs(date).utc().utc().isValid()) return null;
return dayjs(date).format(formatStr);
return dayjs(date).utc().format(formatStr);
}
// If `date` is a DateRange