fix: 导入时日期校验失败4

This commit is contained in:
caoqianming 2023-06-28 12:12:39 +08:00
parent a6c3e0fd48
commit 4ba44cdf94
1 changed files with 5 additions and 0 deletions

View File

@ -608,6 +608,11 @@ class ImpMixin:
new_val = val.date() new_val = val.date()
elif isinstance(val, datetime.date): elif isinstance(val, datetime.date):
new_val = val new_val = val
elif isinstance(val, str):
try:
new_val = datetime.datetime.strptime(val, '%Y-%m-%d').date()
except ValueError:
raise ParseError(f'{ind}行, 日期时间格式错误')
else: else:
raise ParseError(f'{ind}行, 日期时间格式错误') raise ParseError(f'{ind}行, 日期时间格式错误')
return new_val return new_val