diff options
author | Joris | 2020-06-06 17:44:26 +0200 |
---|---|---|
committer | Joris | 2020-06-06 19:54:03 +0200 |
commit | 1595e0de940a86a7810df0e02e43838d97c0d846 (patch) | |
tree | 9701eeec0d98baa9f6044b1911df68e4c8539819 /src/gui/tasks/duration.py | |
parent | 6b9195000eb5404c247288b384d7ca2bacc1ab23 (diff) |
Provide nix build
Diffstat (limited to 'src/gui/tasks/duration.py')
-rw-r--r-- | src/gui/tasks/duration.py | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/gui/tasks/duration.py b/src/gui/tasks/duration.py deleted file mode 100644 index dc948e6..0000000 --- a/src/gui/tasks/duration.py +++ /dev/null @@ -1,50 +0,0 @@ -from PyQt5 import QtGui -from typing import Optional -import math -import re - -import 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 gui.color.short_duration - elif minutes < 60: - return gui.color.medium_duration - else: - return gui.color.long_duration |