Browse Source

Pull request #304888: REPORT-146679 fix: 自定义格式特殊时间格式判断

Merge in DEC/fineui from ~STAN.YANG/fineui-dec:final/11.0 to final/11.0

* commit 'e3899c69626e2aa55040184458906970ad4ab1df':
  REPORT-146679 fix: 自定义格式特殊时间格式判断
master
parent
commit
71fa452dc9
  1. 17
      packages/fineui/src/widget/timeinterval/dateinterval.js
  2. 17
      packages/fineui/src/widget/timeinterval/timeinterval.js

17
packages/fineui/src/widget/timeinterval/dateinterval.js

@ -193,19 +193,22 @@ export class DateInterval extends Single {
}
_check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
// 现在有自定义样式,所以有["%X", "%d", "%Y"]这种不是[year, month, day]的情况,下面取对应的ymd就出错
// 所以先把这个string转成date,再转成默认格式string,只对自定义格式的date做处理
const newSmallDate = this.options.format ? print(parseDateTime(smallDate, this.options.format), "%Y-%X-%d %H:%M:%S") : smallDate;
const newBigDate = this.options.format ? print(parseDateTime(bigDate, this.options.format), "%Y-%X-%d %H:%M:%S") : bigDate;
const smallObj = newSmallDate.match(/\d+/g),
bigObj = newBigDate.match(/\d+/g);
return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._dateCheck(newSmallDate) &&
checkDateLegal(newSmallDate) &&
this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._dateCheck(newBigDate) &&
checkDateLegal(newBigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],

17
packages/fineui/src/widget/timeinterval/timeinterval.js

@ -209,19 +209,22 @@ export class TimeInterval extends Single {
}
_check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g),
bigObj = bigDate.match(/\d+/g);
// 现在有自定义样式,所以有["%X", "%d", "%Y"]这种不是[year, month, day]的情况,下面取对应的ymd就出错
// 所以先把这个string转成date,再转成默认格式string,只对自定义格式的date做处理
const newSmallDate = this.options.format ? print(parseDateTime(smallDate, this.options.format), "%Y-%X-%d %H:%M:%S") : smallDate;
const newBigDate = this.options.format ? print(parseDateTime(bigDate, this.options.format), "%Y-%X-%d %H:%M:%S") : bigDate;
const smallObj = newSmallDate.match(/\d+/g),
bigObj = newBigDate.match(/\d+/g);
return (
this._dateCheck(smallDate) &&
checkDateLegal(smallDate) &&
this._dateCheck(newSmallDate) &&
checkDateLegal(newSmallDate) &&
this._checkVoid({
year: smallObj[0],
month: smallObj[1],
day: smallObj[2],
}) &&
this._dateCheck(bigDate) &&
checkDateLegal(bigDate) &&
this._dateCheck(newBigDate) &&
checkDateLegal(newBigDate) &&
this._checkVoid({
year: bigObj[0],
month: bigObj[1],

Loading…
Cancel
Save