Mercurial > getan > getan
comparison getan/template.py @ 511:31ea48bf8a7c
human_time calculates up to 59 minutes, not 60.
* Porting the human_time function from Python2 to Python3.
Minutes and hours must be integer.
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Tue, 06 Nov 2018 13:01:08 +0100 |
parents | 59d9c5840273 |
children | a59622c06936 |
comparison
equal
deleted
inserted
replaced
510:8c7a00a984da | 511:31ea48bf8a7c |
---|---|
21 | 21 |
22 def human_time(delta): | 22 def human_time(delta): |
23 days = delta.days | 23 days = delta.days |
24 seconds = days * 3600 * 24 | 24 seconds = days * 3600 * 24 |
25 s = seconds + delta.seconds | 25 s = seconds + delta.seconds |
26 h = s / 3600 | 26 h = s // 3600 |
27 m = (s % 3600) / 60 | 27 m = (s % 3600) // 60 |
28 if (s % 60) >= 30: | 28 if (s % 60) >= 30: |
29 m += 1 | 29 m += 1 |
30 if m == 60: | 30 if m == 60: |
31 m = 0 | 31 m = 0 |
32 h += 1 | 32 h += 1 |