Skip to content

Commit f2810a7

Browse files
fix: use timezone date
1 parent 7ac82c7 commit f2810a7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/domain/usecases/HandleScheduledReservationUseCase.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import dayjs from 'dayjs';
2+
import timezone from 'dayjs/plugin/timezone.js';
3+
import utc from 'dayjs/plugin/utc.js';
14
import { NotFoundError } from '../Errors.js';
5+
26
import { Reservation } from '../Reservation.js';
37

8+
dayjs.extend(utc);
9+
dayjs.extend(timezone);
10+
411
const RESERVATION_ACCEPTED_MESSAGE_CONTENT = 'MERCI POUR VOTRE RESERVATION !';
512
const EXTRACT_INFORMATION_REGEXP = /Terrain (?<court>\d+) (?<activity>\w+)\s\w+ le (?<date>\d{2}-\d{2}-\d{4}) à (?<hour>\d{2}:\d{2})/;
613
const EXTRACT_CODE_REGEXP = /<p>(?<code>\d+)<\/p>/;
@@ -45,7 +52,7 @@ export class HandleScheduledReservationUseCase {
4552
code: matchCode.groups.code,
4653
court: match.groups.court,
4754
activity: match.groups.activity,
48-
start: new Date(`${formattedDate}T${match.groups.hour}:00`),
55+
start: dayjs.tz(`${formattedDate}T${match.groups.hour}:00`, 'Europe/Paris'),
4956
};
5057
}
5158

0 commit comments

Comments
 (0)