mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 15:36:33 +00:00
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:
@@ -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' })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user