Isocalendar() Method Of Datetime Class In Python
Last Updated :
23 Aug, 2021
The isocalendar() function is used to return a tuple of ISO Year, ISO Week Number, and ISO Weekday.
Note:
- According to ISO standard 8601 and ISO standard 2015, Thursday is the middle day of a week.
- Therefore, ISO years always start with Monday.
- ISO year can start as yearly as 29th January or as late as 4th January of a Gregorian calendar.
- ISO years can have either 52 full weeks or 53 full weeks.
- ISO years do not have any fractional weeks during the beginning of the year or at the end of the year.
Syntax: isocalendar()
Parameters: This function does not accept any parameter.
Return values: This function returns a tuple of ISO Year, ISO Week Number and ISO Weekday.
Example 1: Using today’s dates.
Python3
from datetime import date
Todays_date = date.today()
print (Todays_date)
print (Todays_date.isocalendar())
|
Output:
2021-07-25
(2021, 29, 7)
Example 2: Using a specific date.
Python3
from datetime import date
A = date( 2020 , 10 , 11 )
Date = A.isocalendar()
print ( "Original date:" ,A)
print ( "Date in isocalendar is:" , Date)
|
Output:
Original date: 2020-10-11
Date in isocalendar is: (2020, 41, 7)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...