diff --git a/client/src/components/PDF/TripPDF.test.ts b/client/src/components/PDF/TripPDF.test.ts index 3250eabbf..ef3154e75 100644 --- a/client/src/components/PDF/TripPDF.test.ts +++ b/client/src/components/PDF/TripPDF.test.ts @@ -751,6 +751,19 @@ describe('downloadTripPDF remaining branches', () => { expect(html).not.toContain('16:45') }) + it('FE-W5PDF-035: the overview lists a day of bookings by the clock, also in 12h', async () => { + const booking = (id: number, title: string, time: string) => ({ + id, title, type: 'tour', day_id: 10, reservation_time: `2025-06-01T${time}`, + }) + await downloadTripPDF(at('14:30', { + timeFormat: '12h', + reservations: [booking(701, 'Afternoon tour', '13:00'), booking(702, 'Late morning tour', '10:00'), booking(703, 'Morning tour', '09:30')], + }) as never) + const doc = new DOMParser().parseFromString(srcdoc(), 'text/html') + const titles = [...doc.querySelectorAll('.ledger .ledger-title')].map(el => el.textContent) + expect(titles).toEqual(['Morning tour', 'Late morning tour', 'Afternoon tour']) + }) + it('FE-W5PDF-032: a 24h reader gets the same times without a meridiem', async () => { await downloadTripPDF(at('14:30', { timeFormat: '24h' }) as never) const html = srcdoc() diff --git a/client/src/components/PDF/TripPDF.tsx b/client/src/components/PDF/TripPDF.tsx index 1b0d32fa5..9a2a7dab2 100644 --- a/client/src/components/PDF/TripPDF.tsx +++ b/client/src/components/PDF/TripPDF.tsx @@ -369,10 +369,12 @@ export async function downloadTripPDF({ trip, days, places, assignments: allStor .filter(r => r.type !== 'hotel' && r.day_id != null && dayNumberOf.has(r.day_id)) .map((r: PdfBooking) => { const day = dayNumberOf.get(r.day_id ?? -1) - const time = fmtTime(splitReservationDateTime(day ? getDisplayTimeForDay(r, day.id) : null).time) + // Sorted on the stored 24h clock: the printed 12h one puts 1:00 PM before 9:30 AM. + const clock = splitReservationDateTime(day ? getDisplayTimeForDay(r, day.id) : null).time + const time = fmtTime(clock) return { order: orderOf(r.day_id), - minute: time, + minute: clock || '', icon: bookingIcon(r.type, 13), tint: hexColour(bookingTint(r.type), '#6b6b75'), title: r.title || '',