Skip to content

Commit

Permalink
Fix(torrent vfs): Fix date/time handling
Browse files Browse the repository at this point in the history
Especially with overflow d/t; esp on w32.
  • Loading branch information
phdru committed Feb 16, 2025
1 parent ee8b381 commit ee4485f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/vfs/extfs/helpers/torrent.in
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit ee4485f

Please sign in to comment.