Browse Source

Merge pull request #3771 in VISUAL/fineui from DEC/fineui:release/11.0 to master

* commit '51fc78227fd3aaa9a0ccd5e283303a7ea71c0b58':
  REPORT-146679 fix: 自定义格式特殊时间格式判断
  REPORT-146679 fix: 自定义格式时check判断
master
Aeolus.Zhang-张敬峥 4 days ago
parent
commit
afa712fc93
  1. 20
      packages/fineui/src/widget/timeinterval/dateinterval.js
  2. 20
      packages/fineui/src/widget/timeinterval/timeinterval.js

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

@ -181,7 +181,8 @@ export class DateInterval extends Single {
print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date || print(parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date || print(parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date || print(parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date print(parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date ||
print(parseDateTime(date, this.options.format), this.options.format) === date
); );
} }
@ -192,19 +193,22 @@ export class DateInterval extends Single {
} }
_check(smallDate, bigDate) { _check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g), // 现在有自定义样式,所以有["%X", "%d", "%Y"]这种不是[year, month, day]的情况,下面取对应的ymd就出错
bigObj = bigDate.match(/\d+/g); // 所以先把这个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 ( return (
this._dateCheck(smallDate) && this._dateCheck(newSmallDate) &&
checkDateLegal(smallDate) && checkDateLegal(newSmallDate) &&
this._checkVoid({ this._checkVoid({
year: smallObj[0], year: smallObj[0],
month: smallObj[1], month: smallObj[1],
day: smallObj[2], day: smallObj[2],
}) && }) &&
this._dateCheck(bigDate) && this._dateCheck(newBigDate) &&
checkDateLegal(bigDate) && checkDateLegal(newBigDate) &&
this._checkVoid({ this._checkVoid({
year: bigObj[0], year: bigObj[0],
month: bigObj[1], month: bigObj[1],

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

@ -197,7 +197,8 @@ export class TimeInterval extends Single {
print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date || print(parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date || print(parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date || print(parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date print(parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date ||
print(parseDateTime(date, this.options.format), this.options.format) === date
); );
} }
@ -208,19 +209,22 @@ export class TimeInterval extends Single {
} }
_check(smallDate, bigDate) { _check(smallDate, bigDate) {
const smallObj = smallDate.match(/\d+/g), // 现在有自定义样式,所以有["%X", "%d", "%Y"]这种不是[year, month, day]的情况,下面取对应的ymd就出错
bigObj = bigDate.match(/\d+/g); // 所以先把这个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 ( return (
this._dateCheck(smallDate) && this._dateCheck(newSmallDate) &&
checkDateLegal(smallDate) && checkDateLegal(newSmallDate) &&
this._checkVoid({ this._checkVoid({
year: smallObj[0], year: smallObj[0],
month: smallObj[1], month: smallObj[1],
day: smallObj[2], day: smallObj[2],
}) && }) &&
this._dateCheck(bigDate) && this._dateCheck(newBigDate) &&
checkDateLegal(bigDate) && checkDateLegal(newBigDate) &&
this._checkVoid({ this._checkVoid({
year: bigObj[0], year: bigObj[0],
month: bigObj[1], month: bigObj[1],

Loading…
Cancel
Save