fix(reservations): honour the 24h time setting (#1725)

The 12h/24h rules lived in three copies and two of them ignored the setting.
They are one function now. splitReservationDateTime also truncated the
meridiem instead of converting it, so 3:00 PM became 3:00 — three in the
morning. Values already stored that way normalise when a form renders the
field, without changing the payload or the stored format.
This commit is contained in:
Maurice
2026-07-29 14:37:28 +02:00
committed by Maurice
parent 9ab9665e99
commit aaef3e3e76
7 changed files with 292 additions and 47 deletions
+12
View File
@@ -220,4 +220,16 @@ describe('splitReservationDateTime', () => {
it('returns nulls for unrecognized string', () => {
expect(splitReservationDateTime('garbage')).toEqual({ date: null, time: null })
})
// #1725 — slicing the time part to five characters used to swallow the meridiem,
// so an afternoon booking came back as a morning one.
it('converts a meridiem time part instead of cutting it off', () => {
expect(splitReservationDateTime('2026-08-01T3:00 PM')).toEqual({ date: '2026-08-01', time: '15:00' })
expect(splitReservationDateTime('2026-08-01T12:30 am')).toEqual({ date: '2026-08-01', time: '00:30' })
})
it('converts a bare meridiem time', () => {
expect(splitReservationDateTime('3:00 PM')).toEqual({ date: null, time: '15:00' })
expect(splitReservationDateTime('3 PM')).toEqual({ date: null, time: '15:00' })
})
})