aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/collateral/common.py')
-rw-r--r--python/collateral/common.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/python/collateral/common.py b/python/collateral/common.py
index a7a34be6..3db7349e 100644
--- a/python/collateral/common.py
+++ b/python/collateral/common.py
@@ -131,3 +131,12 @@ def get_col(l, top, bottom, left, right):
and int(c["top"]) >= top
and int(c["top"]) < bottom
]
+
+
+def prev_business_day(d: datetime.date):
+ if (offset := d.weekday() - 4) > 0:
+ return d - datetime.timedelta(days=offset)
+ elif offset == -4:
+ return d - datetime.timedelta(days=3)
+ else:
+ return d - datetime.timedelta(days=1)