mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-04-27 01:11:21 +02:00
Kludge around for month names when running with non-English locale. Hoping to
fix reported problems with mediaminer and fictionalley. "time data 'July 15, 2005' does not match format %B %d, %Y"
This commit is contained in:
parent
45382ad424
commit
5162cb4ddb
1 changed files with 22 additions and 1 deletions
|
|
@ -228,8 +228,29 @@ class BaseSiteAdapter(Configurable):
|
|||
def getChapterText(self, url):
|
||||
"Needs to be overriden in each adapter class."
|
||||
pass
|
||||
|
||||
|
||||
fullmon = {"January":"01", "February":"02", "March":"03", "April":"04", "May":"05",
|
||||
"June":"06","July":"07", "August":"08", "September":"09", "October":"10",
|
||||
"November":"11", "December":"12" }
|
||||
|
||||
def makeDate(string,format):
|
||||
# Surprise! Abstracting this turned out to be more useful than
|
||||
# just saving bytes.
|
||||
|
||||
# fudge english month names for people who's locale is set to
|
||||
# non-english. All our current sites date in english, even if
|
||||
# there's non-english content.
|
||||
do_abbrev = "%b" in format
|
||||
|
||||
if "%B" in format or do_abbrev:
|
||||
format = format.replace("%B","%m")
|
||||
for (name,num) in fullmon.items():
|
||||
if do_abbrev:
|
||||
name = name[:3] # first three for abbrev
|
||||
if name in string:
|
||||
string = string.replace(name,num)
|
||||
break
|
||||
|
||||
return datetime.datetime.strptime(string,format)
|
||||
|
||||
acceptable_attributes = ['href','name']
|
||||
|
|
|
|||
Loading…
Reference in a new issue