From 4ba44cdf94f65bbd47fe132c8af5bd7089c0a917 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 28 Jun 2023 12:12:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E5=85=A5=E6=97=B6=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=A0=A1=E9=AA=8C=E5=A4=B1=E8=B4=A54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/apps/supervision/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/apps/supervision/views.py b/server/apps/supervision/views.py index 23ab317..726506a 100644 --- a/server/apps/supervision/views.py +++ b/server/apps/supervision/views.py @@ -608,6 +608,11 @@ class ImpMixin: new_val = val.date() elif isinstance(val, datetime.date): 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: raise ParseError(f'第{ind}行, 日期时间格式错误') return new_val