我需要将这些字符串转换为开始和结束日期。
'Friday, December 7, 2018 at 7 PM - 11 PM' --> 2018-12-07 19:00:00 & 2018-12-07 23:00:00
'Nov 19 at 12 PM - Dec 3 at 12 AM' --> 2018-11-20 00:00:00 & 2018-12-03 12:00:00
'Tomorrow at 12:30 PM - 2 PM' --> 2018-11-21 12:30:00 & 2018-11-22 02:00:00
'Tomorrow at 9:16 PM - 1:16 AM' --> etc.
'Dec 7 at 5 PM - Dec 8 at 4 AM'
'Friday, December 7, 2018 at 8 PM - 12 AM'
'Wednesday, January 24, 2018 at 3:30 PM - 4:30 PM'
使用timestring
,我可以将字符串转换为日期格式,但是此代码仅返回开始日期。
import timestring
date_string = 'Friday, December 7, 2018 at 7 PM - 11 PM'
datefrom = timestring.Date(date_string).date
print(datefrom) # -> 2018-12-07 19:00:00
我还需要开始和结束时间,有什么解决办法吗?