diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-02-24 23:30:23 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:21:00 +0100 |
commit | 9e28c97dc9ff874d1a8cb6f6cb1fa708a86ddf0f (patch) | |
tree | 26f0daf8d47183130713be5dfc52b8e788e21dc4 /ishtar_common/utils.py | |
parent | 84cf613b154c67340de9fc1e6b3a457868eebc1b (diff) | |
download | Ishtar-9e28c97dc9ff874d1a8cb6f6cb1fa708a86ddf0f.tar.bz2 Ishtar-9e28c97dc9ff874d1a8cb6f6cb1fa708a86ddf0f.zip |
Geodata redesign: context record, base find migration
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index fc302166b..a7e07ebde 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -2335,3 +2335,21 @@ def create_osm_town(rel_id, name, numero_insee=None): town.center = town.limit.centroid town.save() return town + + +def get_percent(current, total): + return f"{(current + 1) / total * 100:.1f}".rjust(4, "0") + "%" + + +def get_log_time(): + return datetime.datetime.now().isoformat().split(".")[0] + + +def get_eta(current, total, base_time, current_time): + if current < 5: + return "-" + elapsed_time = current_time - base_time + eta = elapsed_time.seconds / current * (total - current) + if eta < 1: + return "-" + return f"{int(eta // 3600):02d}:{int(eta % 3600 // 60):02d}:{int(eta % 60):02d}" |