Skip to content

fix(fr): roll the end of an overnight time range into the next day - #669

Open
youdie006 wants to merge 1 commit into
wanasit:masterfrom
youdie006:fix/fr-overnight-range
Open

youdie006 wants to merge 1 commit into
wanasit:masterfrom
youdie006:fix/fr-overnight-range

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

Follow-up to #668. A French overnight range written with h ends before it starts:

chrono.fr.parse("22h00 - 02h00", new Date(2024, 0, 15, 12))
// start 2024-01-15 22:00, end 2024-01-15 02:00

22h à 2h, 22h - 2h and de 22h à 2h do the same on every date. 22:00 - 02:00 goes through the shared AbstractTimeExpressionParser and already ends on the 16th. FRSpecificTimeExpressionParser builds the end from a clone of the start and has no next-day roll; this adds the same addDurationAsImplied({ day: 1 }) the shared parser uses, when the end is earlier than the start and its day is not certain.

The two new cases next to 13h-15h in test/fr/fr_time_exp.test.ts (one on a month's last day) fail on master; always adding a day fails 13h-15h, and adding two days fails the new cases. npm run test (753 tests), prettier --check src test and npm run build pass.

Written with AI assistance (Claude); I have reviewed the change.

FRSpecificTimeExpressionParser built the end of "22h00 - 02h00" on the
start's day, so the range ended before it began. Move the end to the next
day when it is earlier than the start, as the shared time expression
parser does.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.133% (+0.001%) from 93.132% — youdie006:fix/fr-overnight-range into wanasit:master

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants