conference-archive/confarchive/__init__.py
2023-09-13 16:19:08 +05:30

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}]
)