Skip to content

Commit

Permalink
Removed month and year from default units
Browse files Browse the repository at this point in the history
See [#185](#185).

Closes [#177](#177).
  • Loading branch information
morrme authored and EvanHahn committed Jul 16, 2020
1 parent ce76bd7 commit e8c6c67
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ humanizeDuration(260040000, { spacer: "" }); // '3days, 14minutes'
Number representing the maximum number of units to display for the duration.

```js
humanizeDuration(1000000000000); // '31 years, 8 months, 1 week, 19 hours, 46 minutes, 40 seconds'
humanizeDuration(1000000000000, { largest: 2 }); // '31 years, 8 month'
humanizeDuration(10000000000); // '16 weeks, 3 days, 17 hours, 46 minutes, 40 seconds'
humanizeDuration(10000000000, { largest: 2 }); // '16 weeks, 3 days'
```

**units**
Expand Down Expand Up @@ -147,7 +147,7 @@ humanizeDuration(400, {
w: 7,
d: 1,
},
}); // '1 year, 1 month, 5 days'
}); // '57 weeks, 1 day'
```

**Combined example**
Expand Down
2 changes: 1 addition & 1 deletion humanize-duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@
spacer: " ",
conjunction: "",
serialComma: true,
units: ["y", "mo", "w", "d", "h", "m", "s"],
units: ["w", "d", "h", "m", "s"],
languages: {},
round: false,
unitMeasures: {
Expand Down
6 changes: 3 additions & 3 deletions test/humanizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ describe("humanizer", function () {
it('can do rounding with the "largest" option', function () {
const h = humanizer({ round: true });

assert.strictEqual(h(3692131200000, { largest: 1 }), "117 years");
assert.strictEqual(h(3692131200000, { largest: 2 }), "117 years");
assert.strictEqual(h(3692131200000, { largest: 1 }), "6105 weeks");
assert.strictEqual(h(3692131200000, { largest: 2 }), "6104 weeks, 5 days");
assert.strictEqual(
h(3692131200001, { largest: 100 }),
"116 years, 11 months, 4 weeks, 1 day, 4 hours, 30 minutes"
"6104 weeks, 5 days"
);
assert.strictEqual(h(2838550, { largest: 3 }), "47 minutes, 19 seconds");
});
Expand Down

0 comments on commit e8c6c67

Please sign in to comment.