Skip to content

Commit

Permalink
front: drop isUTC argument in dateTimeFormatting()
Browse files Browse the repository at this point in the history
This is unused and dangerous.

Signed-off-by: Simon Ser <[email protected]>
  • Loading branch information
emersion committed Nov 25, 2024
1 parent b4dd722 commit 3dfed13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions front/src/applications/stdcm/utils/formatStdcmConf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export const checkStdcmConf = (
setFailure({
name: t('operationalStudies/manageTrainSchedule:errorMessages.trainScheduleTitle'),
message: t('operationalStudies/manageTrainSchedule:errorMessages.originTimeOutsideWindow', {
low: dateTimeFormatting(searchDatetimeWindow.begin, false, false),
high: dateTimeFormatting(searchDatetimeWindow.end, false, false),
low: dateTimeFormatting(searchDatetimeWindow.begin, false),
high: dateTimeFormatting(searchDatetimeWindow.end, false),
}),
})
);
Expand Down
10 changes: 2 additions & 8 deletions front/src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ export function formatIsoDate(date: Date) {
return date.toISOString().substring(0, 10);
}

export function dateTimeFormatting(
date: Date,
withoutTime: boolean = false,
isUTC: boolean = true
) {
export function dateTimeFormatting(date: Date, withoutTime: boolean = false) {
let locale;
switch (i18n.language) {
case 'fr':
Expand All @@ -61,10 +57,8 @@ export function dateTimeFormatting(
default:
locale = 'en';
}
// Force interpreting the date in UTC
const dateToUTC = dayjs(date).utc(isUTC);
const dateFormat = withoutTime ? 'D MMM YYYY' : 'D MMM YYYY HH:mm';
return dateToUTC.locale(locale).tz(userTimeZone).format(dateFormat).replace(/\./gi, '');
return dayjs(date).locale(locale).tz(userTimeZone).format(dateFormat).replace(/\./gi, '');
}

/**
Expand Down

0 comments on commit 3dfed13

Please sign in to comment.