Skip to content

Commit

Permalink
fix: use timezone date
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentHardouin committed Oct 11, 2024
1 parent 7ac82c7 commit f2810a7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/domain/usecases/HandleScheduledReservationUseCase.js
Original file line number Diff line number Diff line change
@@ -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 (?<court>\d+) (?<activity>\w+)\s\w+ le (?<date>\d{2}-\d{2}-\d{4}) à (?<hour>\d{2}:\d{2})/;
const EXTRACT_CODE_REGEXP = /<p>(?<code>\d+)<\/p>/;
Expand Down Expand Up @@ -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'),
};
}

Expand Down

0 comments on commit f2810a7

Please sign in to comment.