I want to find out the following:
given a date (datetime object), what is the corresponding day of the week?
For instance, Sunday is the first day, Mond
If you're not solely reliant on the datetime module, calendar might be a better alternative. This, for example, will provide you with the day codes:
calendar.weekday(2017,12,22);
And this will give you the day itself:
days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
days[calendar.weekday(2017,12,22)]
Or in the style of python, as a one liner:
["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"][calendar.weekday(2017,12,22)]