mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
fix(trips): keep the trip length across a DST change when the phone moves the start
The phone sheet added the old length with a local setDate on a UTC midnight date, so in zones east of UTC a range crossing the start of summer time came out one day short. It now counts UTC calendar days like the desktop dialog.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-COMP-TRIPFORMMODEL-001 to -006: the trip form checks the dialog and the phone sheet share.
|
||||
// FE-COMP-TRIPFORMMODEL-001 to -007: the trip form checks the dialog and the phone sheet share.
|
||||
import { MAX_TRIP_DAYS, addIsoDays } from '@trek/shared';
|
||||
|
||||
import { endDateForNewStart, tripFormError } from './tripFormModel';
|
||||
@@ -52,4 +52,16 @@ describe('endDateForNewStart', () => {
|
||||
expect(endDateForNewStart('2026-05-08', '2026-05-03', '2026-05-05')).toBe('2026-05-05');
|
||||
expect(endDateForNewStart('2026-05-01', '2026-05-08', '')).toBe('2026-05-08');
|
||||
});
|
||||
|
||||
it('FE-COMP-TRIPFORMMODEL-007: the kept length counts calendar days across a DST change', () => {
|
||||
const runnerTimeZone = process.env.TZ;
|
||||
process.env.TZ = 'Europe/Berlin';
|
||||
try {
|
||||
// Summer time starts on 2026-03-29 in Berlin.
|
||||
expect(endDateForNewStart('2026-03-20', '2026-03-25', '2026-03-27')).toBe('2026-04-01');
|
||||
} finally {
|
||||
if (runnerTimeZone === undefined) delete process.env.TZ;
|
||||
else process.env.TZ = runnerTimeZone;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user