mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2737 (Metadata retrieval error: "year out of range")
This commit is contained in:
parent
3850f64c06
commit
a625a9f6ea
@ -308,14 +308,25 @@ def walk(dir):
|
||||
yield os.path.join(record[0], f)
|
||||
|
||||
def strftime(fmt, t=None):
|
||||
''' A version of strtime that returns unicode strings. '''
|
||||
''' A version of strtime that returns unicode strings and tries to handle dates
|
||||
before 1900 '''
|
||||
if t is None:
|
||||
t = time.localtime()
|
||||
early_year = t[0] < 1900
|
||||
if early_year:
|
||||
fmt = fmt.replace('%Y', '_early year hack##')
|
||||
t = list(t)
|
||||
orig_year = t[0]
|
||||
t[0] = 1900
|
||||
ans = None
|
||||
if iswindows:
|
||||
if isinstance(fmt, unicode):
|
||||
fmt = fmt.encode('mbcs')
|
||||
return plugins['winutil'][0].strftime(fmt, t)
|
||||
return time.strftime(fmt, t).decode(preferred_encoding, 'replace')
|
||||
ans = plugins['winutil'][0].strftime(fmt, t)
|
||||
ans = time.strftime(fmt, t).decode(preferred_encoding, 'replace')
|
||||
if early_year:
|
||||
ans = ans.replace('_early year hack##', str(orig_year))
|
||||
return ans
|
||||
|
||||
def my_unichr(num):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user