Skip to content

Commit

Permalink
Remove tilde prefix from unitCount output (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnellebalane committed Feb 12, 2020
1 parent 4e3c6a6 commit 737628f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -117,7 +117,7 @@ module.exports = (milliseconds, options = {}) => {
}

if (typeof options.unitCount === 'number') {
return '~' + result.slice(0, Math.max(options.unitCount, 1)).join(' ');
return result.slice(0, Math.max(options.unitCount, 1)).join(' ');
}

return options.colonNotation ? result.join('') : result.join(' ');
Expand Down
26 changes: 13 additions & 13 deletions test.js
Expand Up @@ -26,13 +26,13 @@ test('have a compact option', t => {
});

test('have a unitCount option', t => {
t.is(prettyMilliseconds(1000 * 60, {unitCount: 0}), '~1m');
t.is(prettyMilliseconds(1000 * 60, {unitCount: 1}), '~1m');
t.is(prettyMilliseconds(1000 * 60 * 67, {unitCount: 1}), '~1h');
t.is(prettyMilliseconds(1000 * 60 * 67, {unitCount: 2}), '~1h 7m');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {unitCount: 1}), '~1y');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {unitCount: 2}), '~1y 154d');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {unitCount: 3}), '~1y 154d 6h');
t.is(prettyMilliseconds(1000 * 60, {unitCount: 0}), '1m');
t.is(prettyMilliseconds(1000 * 60, {unitCount: 1}), '1m');
t.is(prettyMilliseconds(1000 * 60 * 67, {unitCount: 1}), '1h');
t.is(prettyMilliseconds(1000 * 60 * 67, {unitCount: 2}), '1h 7m');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {unitCount: 1}), '1y');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {unitCount: 2}), '1y 154d');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {unitCount: 3}), '1y 154d 6h');
});

test('have a secondsDecimalDigits option', t => {
Expand Down Expand Up @@ -113,12 +113,12 @@ test('work with verbose and compact options', t => {
});

test('work with verbose and unitCount options', t => {
t.is(prettyMilliseconds(1000 * 60, {verbose: true, unitCount: 1}), '~1 minute');
t.is(prettyMilliseconds(1000 * 60 * 67, {verbose: true, unitCount: 1}), '~1 hour');
t.is(prettyMilliseconds(1000 * 60 * 67, {verbose: true, unitCount: 2}), '~1 hour 7 minutes');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {verbose: true, unitCount: 1}), '~1 year');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {verbose: true, unitCount: 2}), '~1 year 154 days');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {verbose: true, unitCount: 3}), '~1 year 154 days 6 hours');
t.is(prettyMilliseconds(1000 * 60, {verbose: true, unitCount: 1}), '1 minute');
t.is(prettyMilliseconds(1000 * 60 * 67, {verbose: true, unitCount: 1}), '1 hour');
t.is(prettyMilliseconds(1000 * 60 * 67, {verbose: true, unitCount: 2}), '1 hour 7 minutes');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {verbose: true, unitCount: 1}), '1 year');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {verbose: true, unitCount: 2}), '1 year 154 days');
t.is(prettyMilliseconds(1000 * 60 * 67 * 24 * 465, {verbose: true, unitCount: 3}), '1 year 154 days 6 hours');
});

test('work with verbose and secondsDecimalDigits options', t => {
Expand Down

0 comments on commit 737628f

Please sign in to comment.