Skip to content

Fix literal custom decimal separators - #241

Closed
jakezwang wants to merge 1 commit into
EvanHahn:mainfrom
jakezwang:fix-literal-decimal-separators
Closed

jakezwang wants to merge 1 commit into
EvanHahn:mainfrom
jakezwang:fix-literal-decimal-separators

Conversation

@jakezwang

Copy link
Copy Markdown
Contributor

Custom decimal separators currently use replacement-string syntax: humanizeDuration(1250, { decimal: '$$' }) produces 1$25 seconds, and $& becomes a period. Return the separator from a replacement callback so it stays literal, matching the behavior with digit replacements.

Cover replacement tokens in the decimal option and a custom language's decimal separator. Update the history and contributor credits as requested by CONTRIBUTING.md.

Validation: npm test passes on Node 26 and 24, including formatting, lint, type checking, and all 35 tests.

@EvanHahn

Copy link
Copy Markdown
Owner

Thanks. I'll review in the next couple of weeks.

EvanHahn pushed a commit that referenced this pull request Nov 3, 2026
`humanizeDuration(1250, { decimal: '$$' })` becomes `1$25 seconds`
because of a quirk of [String.prototype.replace]. This fixes that.

See [#241].

[#241]: #241
[String.prototype.replace]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
@EvanHahn

EvanHahn commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

I made a couple of manual tweaks and merged this manually in 06b60ce. Thanks for your contribution, it'll be released soon!

@EvanHahn EvanHahn closed this Nov 3, 2026
EvanHahn pushed a commit that referenced this pull request Nov 3, 2026
`humanizeDuration(1250, { decimal: '$$' })` becomes `1$25 seconds`
because of a quirk of [String.prototype.replace]. This fixes that.

See [#241].

[#241]: #241
[String.prototype.replace]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
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