29 lines
536 B
Python
29 lines
536 B
Python
|
from dateutil.relativedelta import relativedelta
|
||
|
|
||
|
durations = [
|
||
|
"5 seconds",
|
||
|
"25 seconds",
|
||
|
"2 minutes",
|
||
|
"10 minutes",
|
||
|
"1 hour",
|
||
|
"5 hours",
|
||
|
"1 day",
|
||
|
"5 days",
|
||
|
"25 days",
|
||
|
"4 months",
|
||
|
]
|
||
|
|
||
|
|
||
|
def rd(label):
|
||
|
num, _, unit = label.partition(" ")
|
||
|
if not unit.endswith("s"):
|
||
|
unit += "s"
|
||
|
return relativedelta(**{unit: int(num)})
|
||
|
|
||
|
|
||
|
bins = (
|
||
|
[{"label": None, "delta": None}]
|
||
|
+ [{"label": label, "delta": rd(label)} for label in durations]
|
||
|
+ [{"label": "Never", "delta": None}]
|
||
|
)
|