Skip to content

Commit

Permalink
front: ensure correct timezone handling in date fields
Browse files Browse the repository at this point in the history
- add 'Z' to dateTimeFormatting function to enforce UTC timezone interpretation
  • Loading branch information
Caracol3 committed Apr 3, 2024
1 parent 7614d18 commit 43ed182
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion front/src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export function dateTimeFormatting(date: Date, withoutTime: boolean = false) {
default:
dayjs.locale('en-gb');
}
const dateToUTC = dayjs(`${date}Z`); // The 'Z' is to ensure we have an UTC date
const dateFormat = withoutTime ? 'D MMM YYYY' : 'D MMM YYYY HH:mm';
return dayjs.utc(date).tz(dayjs.tz.guess()).format(dateFormat).replace(/\./gi, '');
return dateToUTC.tz(dayjs.tz.guess()).format(dateFormat).replace(/\./gi, '');
}

/** check whether a date is included in the range or not */
Expand Down

0 comments on commit 43ed182

Please sign in to comment.