def format_date(val, fmt='%m-%d-%Y'):
"""
Transform the input string to a datetime object
:param val: the input string for date
:param fmt: the input format for the date
"""
date_obj = None
try:
date_obj = datetime.strptime(val, fmt)
except Exception as exc:
log.warning("Problem formatting date: {} - {} due: {}"
.format(val, fmt, exc))
return date_obj
评论列表
文章目录