mikky1996af / My_repository

0 stars 0 forks source link

from datetime import date import calendar def get_date_range(start, end, result = []): if start.year == end.year: return result if start.month < 12: start = start.replace(month = start.month + 1) count_day = calendar.monthrange(start.year, start.month)[-1] result.extend([date(start.year, start.month, i) for i in range(1, count_day + 1)]) get_date_range(start, end, result) else: start = start.replace(year = start.year + 1, month = 1, day = 1) get_date_range(start, end, resulr) print(get_date_range(date(2021, 2,1), date(2023, 10,5))) #3

Open mikky1996af opened 10 months ago

mikky1996af commented 10 months ago

from datetime import date import calendar

def get_date_range(start, end, result = []): if start.year == end.year: return result if start.month < 12: start = start.replace(month = start.month + 1) count_day = calendar.monthrange(start.year, start.month)[-1] result.extend([date(start.year, start.month, i) for i in range(1, count_day + 1)]) get_date_range(start, end, result) else: start = start.replace(year = start.year + 1, month = 1, day = 1) get_date_range(start, end, resulr)

print(get_date_range(date(2021, 2,1), date(2023, 10,5)))