Function Name:
isoweekday
Function Signature:
isoweekday()
Function Overview:
The function isoweekday() returns an integer value corresponding to the day of the week. Unlike the date.weekday() function the date.isoweekday() function returns the value 1 for Monday and increments it by one for the subsequent days.
Here is the mapping table between integer values and ISO weekday.
Integer Value |
Day of the week |
1 |
Monday |
2 |
Tuesday |
3 |
Wednesday |
4 |
Thursday |
5 |
Friday |
6 |
Saturday |
7 |
Sunday |
Example:
# import datetime module of Python import datetime
daysOftheWeek = ("ISO Week days start from 1", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" )
# Christmas Eve xmasEve = datetime.date(2014,12,24) isoWeekDay = xmasEve.isoweekday() print("Christmas Eve this year falls on a {}".format(daysOftheWeek[isoWeekDay]))
# Day after Christmas dayAfterXmas = datetime.date(2014,12,26) isoWeekDay = dayAfterXmas.isoweekday() print("Day after Christmas this year falls on a {}".format(daysOftheWeek[isoWeekDay]))
|
Output:
Christmas Eve this year falls on a Wednesday Day after Christmas this year falls on a Friday |