When leap the years ,There are something about the function of "week_of_month"
the source:
@property
def week_of_month(self):
first_day_of_month = self.replace(day=1)
return self.week_of_year - first_day_of_month.week_of_year + 1
the results eg.:
{'day_wid': '20211229', 'week_wid': '202152', 'week_code': 52, 'week_of_month': 5,} {'day_wid': '20211230', 'week_wid': '202152', 'week_code': 52, 'week_of_month': 5,} {'day_wid': '20211231', 'week_wid': '202152', 'week_code': 52, 'week_of_month': 5,} {'day_wid': '20220101', 'week_wid': '202152', 'week_code': 52, 'week_of_month': 1,} {'day_wid': '20220102', 'week_wid': '202152', 'week_code': 52, 'week_of_month': 1,} {'day_wid': '20220103', 'week_wid': '202201', 'week_code': '01', 'week_of_month': -50,} {'day_wid': '20220104', 'week_wid': '202201', 'week_code': '01', 'week_of_month': -50,}
Thanks🙌 ❤️
Perhaps this will be fine: @property def week_of_month(self): first_day_of_month = self.replace(day=1) # return self.week_of_year - first_day_of_month.week_of_year + 1 days = self.day + first_day_of_month.day_of_week-1 return math.ceil(days/7)
Hi @expressways what are you expecting? Can you elaborate more?