Add Cron.format for cron expression conversion - #7097
Conversation
🦋 Changeset detectedLatest commit: e77bc1d The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
This PR introduces a new public API (Cron.format) but does not include a changeset. Please add one before merging.
Reviewed changes
packages/effect/src/Cron.ts: AddedCron.formatand aformatSegmenthelper; renamed theFormatterimport toformatValueto avoid shadowing the new export.packages/effect/test/Cron.test.ts: Added focused tests for compact ranges, non-uniform values, and default/non-default/unrestricted seconds.
⚠️ Missing changeset for new public API
The repository requires a changeset for exported API changes.
Technical details
# Missing changeset for Cron.format
## Affected sites
- `.changeset/` — no changeset file was added for the new `Cron.format` export
## Required outcome
- Add a changeset describing the new `Cron.format` API.
## Suggested approach
- Create `.changeset/<name>.md` with:
```md
---
"effect": minor
---
Add `Cron.format` for converting a `Cron` instance back to a cron expression.
```@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
The prior review feedback has been addressed: the changeset is now present and the
Cron.formatJSDoc uses the repository-standard**Gotchas**heading while documenting both dropped timezone information and the dropped days/weekdaysandrestriction.
Reviewed changes
- Added an
effectpatch changeset describing the newCron.formatAPI in.changeset/warm-clocks-format.md. - Updated the
Cron.formatJSDoc to use**Gotchas**and to warn that formatting loses timezone information and the days/weekdaysandrestriction, so reparsing may not yield an equivalent schedule.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
The new
includeSecondsoption is cleanly integrated: the JSDoc**Details**section explains the default omission behavior, the implementation correctly respects the option, and the added test covers the new path.
Reviewed changes
- Added an
{ includeSeconds?: boolean }option toCron.formatinpackages/effect/src/Cron.ts, forcing a six-field expression whentruewhile keeping the default five-field output for{0}seconds. - Documented the seconds-field behavior in the JSDoc
**Details**section and updated the runnable example to show both call shapes. - Updated the changeset in
.changeset/warm-clocks-format.mdto mention the seconds option. - Added focused test coverage in
packages/effect/test/Cron.test.tsforincludeSeconds: true.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Widening
includeSecondstoboolean | undefinedis a sensible follow-up that lets callers pass through optional values without narrowing, and the change is purely type-level.
Reviewed changes
- Widened
includeSecondstoboolean | undefinedinpackages/effect/src/Cron.tsso callers can explicitly passundefinedwithout a type error.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
Cron.formatwith compact range and step syntax{ includeSeconds: true }to force a six-field expression without changing default outputandrestrictioneffectpatch changesetTesting
nix develop -c pnpm vitest run packages/effect/test/Cron.test.tsnix develop -c pnpm --filter effect checknix develop -c pnpm lintnix develop -c pnpm doctest packages/effect/src/Cron.ts --runnix develop -c pnpm changeset status --since origin/mainCloses EFF-534