Steve Aby
03/25/2021, 4:13 PMZanie
now = pendulum.now("utc")
dates = {
"date": now,
"today": now.strftime("%Y-%m-%d"),
"yesterday": now.add(days=-1).strftime("%Y-%m-%d"),
"tomorrow": now.add(days=1).strftime("%Y-%m-%d"),
"today_nodash": now.strftime("%Y%m%d"),
"yesterday_nodash": now.add(days=-1).strftime("%Y%m%d"),
"tomorrow_nodash": now.add(days=1).strftime("%Y%m%d"),
}
to test different dates you can monkeypatch the result of pendulum.now()
Zanie
setdefault
e.g.
for key, val in dates.items():
context.setdefault(key, val)
you can just set the date in the context beforehand and it will not be overriddenSteve Aby
03/25/2021, 4:45 PMZanie