feat(cron): cron expression explainer with next-run preview#86
Merged
Conversation
New tool under Convert: paste a cron line, get a plain-language description plus the next fire times. Everything runs client-side. - src/lib/cron.ts: analyzeCron() wraps cronstrue (human description, with built-in zh_CN locale) and cron-parser v5 (CronExpressionParser.parse -> next fire times). Requires BOTH to accept the expression before calling it valid, so the description and the run list never disagree. - The generated sentence follows the app language (en / zh_CN); static UI labels are normal i18n keys in both locales. - Next runs are computed in a selectable IANA timezone (defaults to the user's local TZ); each row shows both the TZ-local time and the absolute ISO instant, so "next run" is never ambiguous. - Quick presets, a 5-field breakdown, and an inline error branch for malformed input. - Registered in router + tools.ts (Convert, CalendarClock icon). Tests: 13 unit tests cover steps/ranges/lists, @daily macro, dow-vs-dom, TZ offsets, and invalid/out-of-range input. Verified: typecheck/lint/build clean, 224 tests green, and headless-Chrome (en + zh_CN) confirmed the descriptions, next-run rows, preset switching, and the invalid-input branch -- no raw i18n keys, zero page errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The initial cron commit landed the page, lib, route and registry but the i18n catalog edits only partially applied (zh pages.cron made it; en tools.cron/pages.cron and zh tools.cron did not), so the tool name and labels rendered as raw keys. This adds the three missing blocks. - en.json: tools.cron + pages.cron (description, expression, meaning, enterHint, invalid, timezone, nextRuns, fields.*, presets.*) - zh-CN.json: tools.cron - Verified: both catalogs parse, all four cron key-groups present, the image-editor blocks are untouched (184 keys, 0 deletions in the diff), typecheck/lint/build clean, 224 tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The earlier i18n commits' zh tools.cron edit silently failed to apply, so the Cron tool's sidebar/home name fell back to its raw key in the Chinese locale. Insert it (description mirrors the en entry). All four cron key-groups (en/zh x tools/pages) are now present; image-editor catalog untouched (0 deletions), typecheck/lint/build clean, 224 tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
A new Cron tool under Convert: paste a cron expression → get a plain-language description and a preview of the next fire times. Fully client-side, no network.
How
src/lib/cron.ts—analyzeCron()wraps two pure-JS libraries:cronstruefor the human sentence (has a built-inzh_CNlocale).cron-parserv5 (CronExpressionParser.parse→.next().toDate()) for upcoming run times.zh_CN); static UI labels are normal i18n keys in both locales.router.tsx+tools.ts(Convert category,CalendarClockicon).Tests / verification
*/15), ranges (1-5), lists, the@dailymacro, day-of-week vs day-of-month, TZ offsets (Asia/Shanghaimidnight = 16:00 UTC prior day), and invalid / out-of-range input.pnpm typecheck/pnpm lint/pnpm buildclean; 224 tests green.en→ "Every 15 minutes…",zh_CN→ Chinese description with no English leak; 6 next-run rows; the invalid-input branch — no raw i18n keys, zero page errors.🤖 Generated with Claude Code