def _parse_date(date):
"""Parse from the user input `date`.
e.g. current year 2016:
input 6-26, 626, ... return 2016626
input 2016-6-26, 2016/6/26, ... retrun 2016626
This fn wouldn't check the date, it only gather the number as a string.
"""
result = ''.join(re.findall('\d', date))
l = len(result)
# User only input month and day, eg 6-1, 6.26, 0626...
if l in (2, 3, 4):
# year = str(datetime.today().year)
year = str(datetime.date.today().year)
return year + result # ?? ex:423--->2016423
# User input full format date, eg 201661, 2016-6-26, 20160626...
if l in (6, 7, 8):
return result
return ''
评论列表
文章目录