I am trying to create an array that will house the days of each month from the CURRENT MONTH until a future date that is specified (for this case I will use 12/31/2022).
So far I am able to set it up to get each day of each month in a given year, but only starting in January.
What I need to have happen is, for example starting now in September, have the array created with days in a month for SEPTEMBER, OCTOBER, NOVEMBER...DECEMBER of 2022.
The code I have thus far:
total = 0
days = []
dayst = []
for i in range(1,13):
month = datetime.datetime.strptime('{}'.format(i), "%m").strftime("%B")
length_of_month = calendar.monthrange(MODELYEAR, i)[1]
total = total + length_of_month
days.append(length_of_month)
dayst.append(total)
totaldays = sum(days)
With current output:
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
I essentially just need to make the end time dynamic and shift the start time to current month.
Thank you all!