Repository navigation
Make typing dates and times easier: parsers and refusals (#200, 1/3) - #215
Open
NinjaLikesCheez wants to merge 3 commits into
Open
NinjaLikesCheez wants to merge 3 commits into
NinjaLikesCheez wants to merge 3 commits into
Conversation
First of a stack for #200. Adds the shared pieces every time input will use: - core/when.ts reads more forms: "in 30 minutes", ordinals ("14th oct", "the 3rd"), noon/midnight, tonight/evening ("tonight 8" is 20:00), and "next fri" as Friday of next week. Vague words (morning, next week) are refused. readWhen says why it refused. - core/how-long.ts reads a duration or an end ("until 17:00"). - core/time-help.ts gives one refusal message per kind of input: the field, the reason and examples that work. /schedule and /admin parking use it now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Saves each caller (how long, /admin parking until, the coming suggestions) mapping it themselves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
Contributor
|
Merged |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First PR of the stack for #200 (spec: #200 (comment)). Merges first; PR 2 (live autocomplete preview) and PR 3 (every input on the shared pieces, consistent form text) stack on it.
What changes
More ways to type a moment (
src/core/when.ts). This works everywhereparseWhenis used today (/schedule,/admin→ Parking):in 30 minutes,in 2 hours,in 3 days(likenow+…).infollowed by anything other than a duration is read as before (in oct 14).14th oct,oct 1st,22nd of october. On its own,the 3rdis the next 3rd: this month's if it's still to come, otherwise the next month that has that day.noon/midday(12:00) andmidnight(00:00 at the end of its day, sofri midnightis Sat 00:00).tonight,this evening,fri evening,sat night: 19:00, or the time given read as an evening time (tonight 8is 20:00). A time outside 17:00–23:59 is refused (tonight 9am,tonight 2), not guessed.next friis Friday of next week (weeks start on Monday).fri/this friis the coming one.nextbefore anything but a weekday is refused.morning,afternoon,next week,this weekend,later) are refused as too vague.31 feb: "there's no 31 Feb 2027").29 febis read like any date, this year's or next year's, so it works when that year is a leap year and is otherwise refused.parseTimeOfDayalso takesnoon,middayandmidnight(00:00). This covers poll reminders, the attendance totals time and the parking reset (includingresetAtin the spots file).Why it refused (
readWhen):empty,unclear,past(with what it understood),before-start(not after a later reference, such as Until before From),no-such-date(31 Feb 2027),vague,not-evening.parseWhenis now a thin wrapper around it.How long (
src/core/how-long.ts, new):readHowLongreads either a duration (45m,for 2 hours) or an end (until 17:00,till 5pm,to fri,17:00), after a start. The duration is tried first, so2his never a time. Nothing calls it yet: PR 3 moves/park for,/adminparkingforand the poll duration onto it.One refusal message (
src/core/time-help.ts, new): the field, the reason when it's known, and examples that work. For example:It now replaces the hand-written messages for
/scheduleWhen, Remind every day at and Totals so far at, and for/admin→ Parking From, Until (that isn't after it startswhen Until falls before a later From) and Reset.Docs:
docs/architecture.md(When) anddocs/commands.md(/schedule). The changelog has an Added entry and a Changed entry fornext fri.Review
Only
src/core/when.ts, plus two newcore/files. Nothing on the rule 14 list is touched, but it'score/code every time input depends on, so a careful human review is welcome.Testing
just checkpasses: 3,147 tests, coverage thresholds met (when.ts99.5% of lines).tests/core/how-long.test.ts,tests/core/time-help.test.ts, and new cases intests/core/when.test.tsfor every form above, every refusal reason, leap years, month rollovers and next week from a Sunday.schedules,admin/parkingandparking-panel. Two tests usedmidnightas an invalid reset and now useteatime.Part of #200.
🤖 Generated with Claude Code