mirror of
https://github.com/MidnightCommander/mc
synced 2025-02-22 18:24:23 +03:00
vfs: torrent - fix date/time handling
Especially with overflow d/t; esp on w32. Closes MidnightCommander/mc#213 . Signed-off-by: Oleg Broytman <phd@phdru.name> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
parent
621c303df1
commit
bc213f6ffb
19
src/vfs/extfs/helpers/torrent.in
Normal file → Executable file
19
src/vfs/extfs/helpers/torrent.in
Normal file → Executable file
@ -425,18 +425,23 @@ def decode_torrent():
|
||||
|
||||
def decode_datetime_asc(dt):
|
||||
try:
|
||||
return asctime(localtime(float(dt)))
|
||||
except ValueError:
|
||||
lt = localtime(float(dt))
|
||||
Y = lt[0]
|
||||
if Y > 9999:
|
||||
raise ValueError
|
||||
except (OSError, ValueError):
|
||||
return datetime.max.ctime()
|
||||
else:
|
||||
return asctime(lt)
|
||||
|
||||
|
||||
def decode_datetime(dt):
|
||||
try:
|
||||
Y, m, d, H, M = localtime(float(dt))[0:5]
|
||||
except ValueError:
|
||||
return datetime.max.ctime()
|
||||
if Y > 9999:
|
||||
Y = 9999
|
||||
Y, m, d, H, M = localtime(float(dt))[:5]
|
||||
if Y > 9999:
|
||||
raise ValueError
|
||||
except (OSError, ValueError):
|
||||
Y, m, d, H, M = datetime.max.timetuple()[:5]
|
||||
return "%02d-%02d-%d %02d:%02d" % (m, d, Y, H, M)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user