Skip to content

Add option to trim leading zeros in hours description#379

Merged
bradymholt merged 4 commits intobradymholt:mainfrom
APimenta4:feat/add-option-trim-leading-zeros-in-hours
Mar 18, 2026
Merged

Add option to trim leading zeros in hours description#379
bradymholt merged 4 commits intobradymholt:mainfrom
APimenta4:feat/add-option-trim-leading-zeros-in-hours

Conversation

@APimenta4
Copy link
Copy Markdown
Contributor

Adds a new trimHoursLeadingZero option. Addresses #254 and #217

As discussed in #254 (comment), I agree with you and think creating a new option and exposing it to the user is more transparent and consistent than enforcing a specific style

Also updated import chai = require("chai"); on i18n.ts to newest syntax to support running tests on node >20

Signed-off-by: AFONSO PIMENTA <afonsocpimenta04@gmail.com>
Signed-off-by: AFONSO PIMENTA <afonsocpimenta04@gmail.com>
Signed-off-by: AFONSO PIMENTA <afonsocpimenta04@gmail.com>
@APimenta4 APimenta4 force-pushed the feat/add-option-trim-leading-zeros-in-hours branch from bc4305e to d8e4b01 Compare March 18, 2026 03:55
@bradymholt bradymholt requested a review from Copilot March 18, 2026 17:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new formatting option to control whether hour values are zero-padded in generated time strings, addressing reported issues where 12-hour clock output included a leading zero.

Changes:

  • Introduces a new trimHoursLeadingZero option on the public Options interface.
  • Updates ExpressionDescriptor.formatTime to optionally render hours without zero-padding.
  • Updates documentation and adds/adjusts tests (including a Chai import update for Node >20 compatibility).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/i18n.ts Updates Chai import style to align with other tests / Node >20 compatibility.
test/cronstrue.ts Adds test cases validating trimHoursLeadingZero behavior in both 12h and 24h modes.
src/options.ts Exposes the new trimHoursLeadingZero option in the public Options interface.
src/expressionDescriptor.ts Implements the new option in time formatting output.
README.md Documents the new option and its default/behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/expressionDescriptor.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bradymholt
Copy link
Copy Markdown
Owner

Thanks!

@bradymholt bradymholt merged commit a10a2a1 into bradymholt:main Mar 18, 2026
@github-actions
Copy link
Copy Markdown

The changes in this PR were just released in v3.14.0 🎉.

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.

3 participants