Method Name:
isoweekday
Method Signature:
isoweekday()
Method Overview:
- Returns the integer mapping corresponding the day of the week, where Monday is 1 and Sunday is 7
Return Values:
Integer returned by isoweekday() |
Day of the week |
1 |
Monday |
2 |
Tuesday |
3 |
Wednesday |
4 |
Thursday |
5 |
Friday |
6 |
Saturday |
7 |
Sunday |
Example:
import datetime
ISOWeekDays = ("NoZeroInISOWeek","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
dateTimeObject = datetime.datetime(2017,10,1,00,00,00) ISOday = ISOWeekDays[dateTimeObject.isoweekday()] print("{} falls on a {}".format(dateTimeObject, ISOday))
nextDay = dateTimeObject.replace(day=2) ISOday = ISOWeekDays[nextDay.isoweekday()] print("{} falls on a {}".format(nextDay, ISOday))
nextDay = dateTimeObject.replace(day=3) ISOday = ISOWeekDays[nextDay.isoweekday()] print("{} falls on a {}".format(nextDay, ISOday))
nextDay = dateTimeObject.replace(day=4) ISOday = ISOWeekDays[nextDay.isoweekday()] print("{} falls on a {}".format(nextDay, ISOday))
nextDay = dateTimeObject.replace(day=5) ISOday = ISOWeekDays[nextDay.isoweekday()] print("{} falls on a {}".format(nextDay, ISOday))
nextDay = dateTimeObject.replace(day=6) ISOday = ISOWeekDays[nextDay.isoweekday()] print("{} falls on a {}".format(nextDay, ISOday))
nextDay = dateTimeObject.replace(day=7) dayOfTheWeek = ISOWeekDays[nextDay.isoweekday()] print("{} falls on a {}".format(nextDay, dayOfTheWeek))
|
Output:
2017-10-01 00:00:00 falls on a Sunday 2017-10-02 00:00:00 falls on a Monday 2017-10-03 00:00:00 falls on a Tuesday 2017-10-04 00:00:00 falls on a Wednesday 2017-10-05 00:00:00 falls on a Thursday 2017-10-06 00:00:00 falls on a Friday 2017-10-07 00:00:00 falls on a Saturday |