-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpFuncs.py
More file actions
34 lines (27 loc) · 873 Bytes
/
HelpFuncs.py
File metadata and controls
34 lines (27 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from typing import List
from datetime import datetime
import calendar
def sortDays(lst: List[str]):
"""sortiert Wochentage relativ nach Dringlichkeit"""
days = dict(zip(calendar.day_name, range(7)))
today = datetime.today().weekday()
for i in range(len(lst)):
if lst[i] != "not specified":
lst[i] = days[lst[i].capitalize()] - today
else:
lst.pop(i)
lst = sorted(lst)
for i in range(len(lst) - 1):
if int(lst[i]) < 0:
lst.append(lst[0])
lst.remove(lst[0])
return [calendar.day_name[int(e) + today] for e in lst]
def roundFloat(x: float):
if x - int(x) == 0:
num = list(str(int(x)))
for i in range(len(num) - 3, 0, -3):
num.insert(i, ",")
num = "".join(num)
return num
else:
return f"roughly {round(x, 2)}"