[lang-ref] ( get_beginning_of_month ) ( python )
def test_get_beginning_of_month():
# d.replace(day=1)
def to_date(yyyymmdd):
return datetime.datetime.strptime(yyyymmdd, r'%Y%m%d').date()
def get_bom(d):
bom = d.replace(day=1)
return bom
assert get_bom(to_date('20251128')) == to_date('20251101')
assert get_bom(to_date('20250228')) == to_date('20250201')
assert get_bom(to_date('20251101')) == to_date('20251101')
assert get_bom(to_date('20250201')) == to_date('20250201')