summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py18
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}"