Ver código fonte

fix: Handle invalid date parsing (#10614)

version-14
Suraj Shetty 5 anos atrás
committed by GitHub
pai
commit
dde11a50e9
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: 4AEE18F83AFDEB23
1 arquivos alterados com 7 adições e 2 exclusões
  1. +7
    -2
      frappe/utils/data.py

+ 7
- 2
frappe/utils/data.py Ver arquivo

@@ -5,6 +5,7 @@ from __future__ import unicode_literals


# IMPORTANT: only import safe functions as this module will be included in jinja environment # IMPORTANT: only import safe functions as this module will be included in jinja environment
import frappe import frappe
from dateutil.parser._parser import ParserError
import subprocess import subprocess
import operator import operator
import re, datetime, math, time import re, datetime, math, time
@@ -43,8 +44,12 @@ def getdate(string_date=None):


if is_invalid_date_string(string_date): if is_invalid_date_string(string_date):
return None return None

return parser.parse(string_date).date()
try:
return parser.parse(string_date).date()
except ParserError:
frappe.throw(frappe._('{} is not a valid date string.').format(
frappe.bold(string_date)
), title=frappe._('Invalid Date'))


def get_datetime(datetime_str=None): def get_datetime(datetime_str=None):
if not datetime_str: if not datetime_str:


Carregando…
Cancelar
Salvar