mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Improve ftime() to format dates higher than 11 weeks.
This commit is contained in:
parent
0d429837b6
commit
95bf260518
1 changed files with 5 additions and 3 deletions
|
@ -284,7 +284,7 @@ def ftime(seconds):
|
||||||
Formats a string to show time in a human readable form
|
Formats a string to show time in a human readable form
|
||||||
|
|
||||||
:param seconds: int, the number of seconds
|
:param seconds: int, the number of seconds
|
||||||
:returns: a formatted time string, will return 'unknown' for values greater than 10 weeks and 'Infinity' if seconds == 0
|
:returns: a formatted time string, will return 'Infinity' if seconds == 0
|
||||||
:rtype: string
|
:rtype: string
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
@ -311,9 +311,11 @@ def ftime(seconds):
|
||||||
return '%dd %dh' % (days, hours)
|
return '%dd %dh' % (days, hours)
|
||||||
weeks = days / 7
|
weeks = days / 7
|
||||||
days = days % 7
|
days = days % 7
|
||||||
if weeks < 10:
|
if weeks < 52:
|
||||||
return '%dw %dd' % (weeks, days)
|
return '%dw %dd' % (weeks, days)
|
||||||
return 'unknown'
|
years = weeks / 52
|
||||||
|
weeks = weeks % 52
|
||||||
|
return '%dy %dw' % (years, weeks)
|
||||||
|
|
||||||
def fdate(seconds):
|
def fdate(seconds):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue