From f2810a7b29eee7d469af1df42f41ca05154e958b Mon Sep 17 00:00:00 2001 From: Vincent Hardouin Date: Fri, 11 Oct 2024 22:17:07 +0200 Subject: [PATCH] fix: use timezone date --- src/domain/usecases/HandleScheduledReservationUseCase.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/domain/usecases/HandleScheduledReservationUseCase.js b/src/domain/usecases/HandleScheduledReservationUseCase.js index e1b331a..7e845f8 100644 --- a/src/domain/usecases/HandleScheduledReservationUseCase.js +++ b/src/domain/usecases/HandleScheduledReservationUseCase.js @@ -1,6 +1,13 @@ +import dayjs from 'dayjs'; +import timezone from 'dayjs/plugin/timezone.js'; +import utc from 'dayjs/plugin/utc.js'; import { NotFoundError } from '../Errors.js'; + import { Reservation } from '../Reservation.js'; +dayjs.extend(utc); +dayjs.extend(timezone); + const RESERVATION_ACCEPTED_MESSAGE_CONTENT = 'MERCI POUR VOTRE RESERVATION !'; const EXTRACT_INFORMATION_REGEXP = /Terrain (?\d+) (?\w+)\s\w+ le (?\d{2}-\d{2}-\d{4}) à (?\d{2}:\d{2})/; const EXTRACT_CODE_REGEXP = /

(?\d+)<\/p>/; @@ -45,7 +52,7 @@ export class HandleScheduledReservationUseCase { code: matchCode.groups.code, court: match.groups.court, activity: match.groups.activity, - start: new Date(`${formattedDate}T${match.groups.hour}:00`), + start: dayjs.tz(`${formattedDate}T${match.groups.hour}:00`, 'Europe/Paris'), }; }