Skip to content

Commit 709a441

Browse files
fix: correct implementation of createAppointment
Makes the suggested implementation of `createAppointment` correctly handle appointment creations that cross timezones - e.g. due to Daylight Savings Time. re: https://forum.exercism.org/t/tests-and-suggested-implementation-for-appointment-time-are-wrong/
1 parent 79d0d12 commit 709a441

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

exercises/concept/appointment-time/.meta/exemplar.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
* @returns {Date} the appointment
1010
*/
1111
export function createAppointment(days, now = Date.now()) {
12-
return new Date(now + days * 24 * 3600 * 1000);
12+
const date = new Date(now);
13+
date.setDate(date.getDate() + days);
14+
15+
return date;
1316
}
1417

1518
/**
@@ -73,7 +76,7 @@ export function updateAppointment(timestamp, options) {
7376
export function timeBetween(timestampA, timestampB) {
7477
return Math.round(
7578
(new Date(timestampB).getTime() - new Date(timestampA).getTime()) / 1000,
76-
);
79+
);
7780
}
7881

7982
/**

0 commit comments

Comments
 (0)