Skip to content

Commit

Permalink
Merge pull request #147 from felixge/l-mask-bug
Browse files Browse the repository at this point in the history
Fix Rounding Issue with L Mask
  • Loading branch information
chase-manning authored Dec 4, 2020
2 parents 79e69e7 + 488a0d6 commit 47bdabb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dateformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
s: () => s(),
ss: () => pad(s()),
l: () => pad(L(), 3),
L: () => pad(Math.round(L() / 10)),
L: () => pad(Math.floor(L() / 10)),
t: () =>
H() < 12
? dateFormat.i18n.timeNames[0]
Expand Down
10 changes: 8 additions & 2 deletions test/test_mask-l_.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("Mask: 'L'", function () {
it("should format '2020-10-10T08:48:02.436' as '44'", function (done) {
var date = new Date("2020-10-10T08:48:02.436");
var d = dateFormat(date, "L");
assert.strictEqual(d, "44");
assert.strictEqual(d, "43");
done();
});

Expand All @@ -24,7 +24,13 @@ describe("Mask: 'L'", function () {

it("should format '2002-12-25T19:35:55.655' as '66'", function (done) {
var d = dateFormat("2002-12-25T19:35:55.655", "L");
assert.strictEqual(d, "66");
assert.strictEqual(d, "65");
done();
});

it("should format '2126-07-23T03:15:25.999' as '99'", function (done) {
var d = dateFormat("2126-07-23T03:15:25.999", "L");
assert.strictEqual(d, "99");
done();
});
});

0 comments on commit 47bdabb

Please sign in to comment.