aboutsummaryrefslogtreecommitdiff
path: root/todo/gui/tasks/duration.py
diff options
context:
space:
mode:
authorJoris2021-10-16 20:09:55 +0200
committerJoris2021-10-16 20:09:56 +0200
commita54b7776320ef5aa02e6ef7378c2a011dc454885 (patch)
tree0cc69107fc3db626ade1b91e70966f9ecff19678 /todo/gui/tasks/duration.py
parent9d8b61da195bf8de14159f1222a693d62ceebacd (diff)
downloadtodo-a54b7776320ef5aa02e6ef7378c2a011dc454885.tar.gz
todo-a54b7776320ef5aa02e6ef7378c2a011dc454885.tar.bz2
todo-a54b7776320ef5aa02e6ef7378c2a011dc454885.zip
Introduce due date
Also: - Remove duration, difficulty and priority, - Translate to french.
Diffstat (limited to 'todo/gui/tasks/duration.py')
-rw-r--r--todo/gui/tasks/duration.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/todo/gui/tasks/duration.py b/todo/gui/tasks/duration.py
deleted file mode 100644
index 81db661..0000000
--- a/todo/gui/tasks/duration.py
+++ /dev/null
@@ -1,50 +0,0 @@
-from PyQt5 import QtGui
-from typing import Optional
-import math
-import re
-
-import todo.gui.color
-
-def format(minutes: int):
- if minutes >= 60 * 24:
- return "" + format_decimal(minutes / 60 / 24) + "d"
- elif minutes >= 60:
- return "" + format_decimal(minutes / 60) + "h"
- elif minutes > 0:
- return "" + str(minutes) + "m"
- else:
- return ""
-
-def format_decimal(d: float) -> str:
- return "{0:.2g}".format(d)
-
-def parse(duration: str) -> Optional[int]:
- duration = duration.strip()
- if duration:
- result = re.match("^(\d+)(\.(\d+))?([mhd])$", duration.strip())
- if result:
- n = int(result.group(1))
- if result.group(3):
- d = int(result.group(3)) * pow(10, -1 * len(result.group(3)))
- else:
- d = 0
- num = n + d
- unit = result.group(4)
- if unit == "m":
- return math.floor(num)
- elif unit == "h":
- return math.floor(num * 60)
- elif unit == "d":
- return math.floor(num * 60 * 24)
- else:
- return None
- else:
- return 0
-
-def color(minutes: int):
- if minutes <= 15:
- return todo.gui.color.short_duration
- elif minutes < 60:
- return todo.gui.color.medium_duration
- else:
- return todo.gui.color.long_duration