I have a problem, and I clearly have missed something very obvious, but have been looking for that obvious thing by using debug print statements, and cannot find what it is. The problem simply is when an integer (1) is passed into dayFromDayOfWeek, the default return value prints "Unknown Day", not "Monday".
I have printed the argument. It's an integer, and str is required to print the integer inside the function.
Here is the program that calls dayFromDayOfWeek. It is a a program that calls a function, if the day is Monday (reduced to make reading easier)
import sys
import os
import datetime
from dr_snap_lib import *
from util_lib import *
def main():
.
.
.
runDayOfWeek = 0
thisDay = datetime.today()
dayOfWeek = thisDay.weekday()
if runDayOfWeek == dayOfWeek:
delayInterval = timedelta(int(delayIntervalVal))
rc = genNonReadingErtRpt(delayInterval)
else:
day1 = dayFromDayOfWeek(dayOfWeek)
if __name__ == "__main__":
rc = main()
exit(rc)
and here is the function dayFromDayofWeek:
def dayFromDayOfWeek(dayOfWeek):
retDayOfWeek = "Unknown day."
if dayOfWeek == 0:
retDayOfWeek = "Monday"
elif dayOfWeek == 1:
retDayOfWeek == "Tuesday"
elif dayOfWeek == 2:
retDayOfWeek == "Wednesday"
elif dayOfWeek == 3:
retDayOfWeek == "Thursday"
elif dayOfWeek == 4:
retDayOfWeek == "Friday"
elif dayOfWeek == 5:
retDayOfWeek == "Saturday"
elif dayOfWeek == 6:
retDayOfWeek == "Sunday"
print(str(dayOfWeek) + " " + retDayOfWeek)
return retDayOfWeek
Aucun commentaire:
Enregistrer un commentaire