conference-archive/confarchive/__init__.py

29 lines
536 B
Python
Raw Normal View History

2023-09-13 11:49:08 +01:00
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}]
)