From 7b8c0dca8391b94cd18f74e550e49b14001b76fe Mon Sep 17 00:00:00 2001 From: iapyang Date: Tue, 13 Oct 2020 10:53:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=83=A8=E5=88=86=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E6=97=B6=E9=97=B4format=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/__test__/base.test.js | 8 ++++++++ src/core/base.js | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/core/__test__/base.test.js b/src/core/__test__/base.test.js index ddc3fd130b..16b16ec251 100644 --- a/src/core/__test__/base.test.js +++ b/src/core/__test__/base.test.js @@ -432,4 +432,12 @@ describe("baseFunctionTest", function () { expect(BI.deepRemove(obj, { d: 3, e: { f: 4 } })).to.eql(true); expect(BI.deepWithout(obj, { d: 3, e: { f: 4 } })).to.eql({ a: 1, b: 2 }); }); + + /** + * test_author_teller + * 只传一个时分秒format的时间进去后,在某些情况下,返回的是当前时间,然而想要的是返回正确的时分秒 + */ + it("parseDateTime", function () { + expect(BI.parseDateTime("14:13:16", "%H:%M:%S").getTime()).to.eql(1602655996000); + }); }); diff --git a/src/core/base.js b/src/core/base.js index ff81b0f550..f8060fff5d 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -1132,6 +1132,7 @@ if (!_global.BI) { case "%M": min = parseInt(a[i], 10); + break; case "%S": sec = parseInt(a[i], 10); break; @@ -1191,6 +1192,9 @@ if (!_global.BI) { if (y == 0) { y = today.getFullYear(); } + if (m === -1) { + m = today.getMonth(); + } if (m != -1 && d != 0) { return BI.getDate(y, m, d, hr, min, sec); }