Skip to content

Commit 2f8b6d4

Browse files
Fix bug where appointments would end up one day prior (#67)
1 parent f165d55 commit 2f8b6d4

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

app/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = {
3838
daysBeforeToday: 12,
3939
historicPeriodCount: 1, // Number of historic periods to generate
4040

41-
simulatedTime: '11:30', // 24h format
41+
simulatedTime: '10:30', // 24h format
4242
},
4343
reading: {
4444
blindReading: 'true', // Enable blind reading

app/lib/generators/clinic-generator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const generateTimeSlots = (date, sessionTimes, clinicType) => {
4343
const isToday = clinicDate.isSame(today)
4444

4545
const slots = []
46-
const startTime = new Date(`${date.toISOString().split('T')[0]}T${sessionTimes.startTime}`)
47-
const endTime = new Date(`${date.toISOString().split('T')[0]}T${sessionTimes.endTime}`)
48-
46+
const dateStr = dayjs(date).format('YYYY-MM-DD')
47+
const startTime = dayjs(`${dateStr}T${sessionTimes.startTime}`).toDate()
48+
const endTime = dayjs(`${dateStr}T${sessionTimes.endTime}`).toDate()
4949
const currentTime = new Date(startTime)
5050

5151
// Calculate how many slots should be double-booked

app/lib/utils/clinics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const config = require('../../config')
99
* @param {Array} clinics - Array of all clinics
1010
*/
1111
const getTodaysClinics = (clinics) => {
12-
const today = new Date().toISOString().split('T')[0]
13-
return clinics.filter(c => c.date === today)
12+
const today = dayjs().startOf('day')
13+
return clinics.filter(c => dayjs(c.date).isSame(today, 'day'))
1414
}
1515

1616
/**

0 commit comments

Comments
 (0)