Skip to content

Commit 47bdabb

Browse files
Merge pull request #147 from felixge/l-mask-bug
Fix Rounding Issue with L Mask
2 parents 79e69e7 + 488a0d6 commit 47bdabb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/dateformat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
s: () => s(),
8989
ss: () => pad(s()),
9090
l: () => pad(L(), 3),
91-
L: () => pad(Math.round(L() / 10)),
91+
L: () => pad(Math.floor(L() / 10)),
9292
t: () =>
9393
H() < 12
9494
? dateFormat.i18n.timeNames[0]

test/test_mask-l_.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe("Mask: 'L'", function () {
55
it("should format '2020-10-10T08:48:02.436' as '44'", function (done) {
66
var date = new Date("2020-10-10T08:48:02.436");
77
var d = dateFormat(date, "L");
8-
assert.strictEqual(d, "44");
8+
assert.strictEqual(d, "43");
99
done();
1010
});
1111

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

2525
it("should format '2002-12-25T19:35:55.655' as '66'", function (done) {
2626
var d = dateFormat("2002-12-25T19:35:55.655", "L");
27-
assert.strictEqual(d, "66");
27+
assert.strictEqual(d, "65");
28+
done();
29+
});
30+
31+
it("should format '2126-07-23T03:15:25.999' as '99'", function (done) {
32+
var d = dateFormat("2126-07-23T03:15:25.999", "L");
33+
assert.strictEqual(d, "99");
2834
done();
2935
});
3036
});

0 commit comments

Comments
 (0)