Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function parse(str = '', format = 'ms') {

String(str)
.replace(new RegExp(`(\\d)[${parse.unit.placeholder}${parse.unit.group}](\\d)`, 'g'), '$1$2') // clean up group separators / placeholders
.replace(parse.unit.decimal, '.') // normalize decimal separator
.replaceAll(parse.unit.decimal, '.') // normalize decimal separator
.replace(durationRE, (_, n, units) => {
Comment on lines +19 to 20
// if no units, find next smallest units or fall back to format value
// eg. 1h30 -> 1h30m
Expand Down
3 changes: 3 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,8 @@ t('locale separators', t => {
t.equal(parse('30.000,65 seconds'), 30000650)
t.equal(parse('30 000,65 seconds'), 30000650)
t.equal(parse('30_000,65 seconds'), 30000650)
// every component's decimal separator must be normalized, not just the first
t.equal(parse('1,5 s 1,5 s'), 3000)
t.equal(parse('2,5h 3,5h'), 21600000)
t.end()
})
Loading