Skip to content

Instantly share code, notes, and snippets.

@maxcraftsman
Last active March 28, 2021 00:28
Show Gist options
  • Save maxcraftsman/c5a7ac594d073fbe362fef8c914a9041 to your computer and use it in GitHub Desktop.
Save maxcraftsman/c5a7ac594d073fbe362fef8c914a9041 to your computer and use it in GitHub Desktop.
Usefull tools
#loger
with open("/pavuki/doska/files/desk.log", "a", encoding='utf-8') as d:
d.write("Was runned at " + timenow.strftime("%d.%m.%Y %H:%M:%S"))
d.write('\n')
#generate array of dates
def generateRange(start,end):
global dateRange
dateRange = []
start_year = int(start[-4:])
end_year = int(end[-4:])
start_month = int(start[3:5])
end_month = int(end[3:5])
start_day = start[:2]
end_day = end[:2]
set_end = '{}-{}-{}'.format(end_year,end_month,end_day)[:7]
for y in range(start_year,end_year+1):
for m in range(start_month,end_month+1):
datestr_start = '{}-{}-{}'.format(y,str(m).zfill(2),start_day)
start_day = '01'
datestr_end = '{}-{}-{}'.format(y,str(m).zfill(2),monthrange(y, m)[1])
dateformat = datetime.strptime(datestr_end, "%Y-%m-%d")
# if set_end == datestr_end[:7]:
# datestr_end = '{}-{}-{}'.format(y,str(m).zfill(2),end_day)
dateRange.append([datestr_start,datestr_end])
start_month = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment