Browse Source

Pull request #1542: KERNEL-5172 部分情况下时间format有问题

Merge in VISUAL/fineui from ~TELLER/fineui:master to master

* commit '7b8c0dca8391b94cd18f74e550e49b14001b76fe':
  fix: 部分情况下时间format有问题
es6
Teller 4 years ago
parent
commit
010ab23cbd
  1. 8
      src/core/__test__/base.test.js
  2. 4
      src/core/base.js

8
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.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 }); 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);
});
}); });

4
src/core/base.js

@ -1132,6 +1132,7 @@ if (!_global.BI) {
case "%M": case "%M":
min = parseInt(a[i], 10); min = parseInt(a[i], 10);
break;
case "%S": case "%S":
sec = parseInt(a[i], 10); sec = parseInt(a[i], 10);
break; break;
@ -1191,6 +1192,9 @@ if (!_global.BI) {
if (y == 0) { if (y == 0) {
y = today.getFullYear(); y = today.getFullYear();
} }
if (m === -1) {
m = today.getMonth();
}
if (m != -1 && d != 0) { if (m != -1 && d != 0) {
return BI.getDate(y, m, d, hr, min, sec); return BI.getDate(y, m, d, hr, min, sec);
} }

Loading…
Cancel
Save