I have to a run a python script in command line and pass the date as argument and below is my command to run the date
parser = argparse.ArgumentParser()
parser.add_argument('date')
tdate= parser.parse_args().date
i would like to change this to check if it is sunday or saturday. If it is saturday, tdate should be tdate-1 and if it is sunday , it should be tdate-2.
I tried to get weekno in python and if it is 5, i am considering this as saturday and if it is 6 then it is sunday.
#this code is in python getting today() weekday()
weekno = datetime.datetime.today().weekday()
if weekno==5:
tdate= parser.parse_args().date-1
elif weekno==6:
tdate= parser.parse_args().date-2
else:
tdate= parser.parse_args().date
I am missing something in this code. Can anyone please help me ?