mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-01-05 23:56:08 +01:00
Add some code to handle 24 hr clocks w/o changing adapters.
This commit is contained in:
parent
f531a6293b
commit
8d2f9198c2
1 changed files with 13 additions and 2 deletions
|
|
@ -620,8 +620,19 @@ def makeDate(string,dateform):
|
|||
add_hours = True
|
||||
string = string.replace(u"AM",u"").replace(u"PM",u"").replace(u"am",u"").replace(u"pm",u"")
|
||||
|
||||
# date = datetime.strptime(string.encode('utf-8'),dateform.encode('utf-8'))
|
||||
date = datetime.strptime(string, dateform)
|
||||
dateform = dateform.strip()
|
||||
string = string.strip()
|
||||
try:
|
||||
date = datetime.strptime(string, dateform)
|
||||
except ValueError:
|
||||
## If parse fails and looking for 01-12 hours, try 01-24 hours too.
|
||||
## A moderately cheesy way to support 12 and 24 hour clocks.
|
||||
if u"%I" in dateform:
|
||||
dateform = dateform.replace(u"%I",u"%H")
|
||||
date = datetime.strptime(string, dateform)
|
||||
add_hours = False
|
||||
else:
|
||||
raise
|
||||
|
||||
if add_hours:
|
||||
date += timedelta(hours=12)
|
||||
|
|
|
|||
Loading…
Reference in a new issue