Python - Week's Day
Description
Here is a function allowing to recover the day of the week according to a date
Argument
Function's arguments are:
year,monthanddayshort: return only the 3 first letters of day (default:False)
Code
import datetime
def week_day(year, month, day, short=False):
days=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
day_nb = datetime.date(year, month, day).weekday()
day_name = days[day_nb]
if short:
day_name = day_name[0:3]
return day_name