Created
July 20, 2020 04:54
-
-
Save maxcraftsman/89fb98041da1fee961d415ba971d9929 to your computer and use it in GitHub Desktop.
Date array generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date, datetime, timedelta | |
from calendar import monthrange | |
import pytz | |
dateRange = [] | |
curTime = datetime.now() | |
def generateRange(start,end): | |
for y in range(start,end): | |
for m in range(1,13): | |
datestr = '{}-{}-{}'.format(y,m,monthrange(y, m)[1]) | |
dateformat = datetime.strptime(datestr, "%Y-%m-%d") | |
if dateformat < curTime: | |
dateRange.append(datestr) | |
generateRange(2020,2021) | |
print(dateRange) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment