A parser for ISO 8601 date formats, such as yyyy-mm-dd, using the ISO calendar for week calculations. For more information on the ISO calendar, see the chrono.calendar.ISOCalendar documentation.
Valid formats:
Format | Example | Description | Method |
---|---|---|---|
yyyy-mm-dd | 2009-12-27 | Date | chrono.parser.ISOParser.date() |
hh:mm:ss | 15:27:43 | Time | chrono.parser.ISOParser.time() |
yyyy-ddd | 2009-163 | Ordinal day | chrono.parser.ISOParser.ordinal() |
yyyy-Www-d | 2009-W36-3 | Week and weekday | chrono.parser.ISOParser.weekdate() |
yyyy-Www | 2009-W36 | Week | chrono.parser.ISOParser.week() |
yyyy-mm | 2009-12 | Month | chrono.parser.ISOParser.month() |
yyyy | 2009 | Year | chrono.parser.ISOParser.year() |
yyyymmdd | 20091227 | Compact date | chrono.parser.ISOParser.compactdate() |
hhmmss | 152743 | Compact time | chrono.parser.ISOParser.compacttime() |
yyyyddd | 2009163 | Compact ordinal day | chrono.parser.ISOParser.compactordinal() |
yyyyWwwd | 2009W363 | Compact week and day | chrono.parser.ISOParser.compactweekdate() |
yyyyWww | 2009W36 | Compact week | chrono.parser.ISOParser.compactweek() |
Datetime formats can consist of any combination of the date and time formats above, separated by space or a T.
Leading zeroes may be omitted in days and months.
Seconds and minutes may be omitted in times, which will be interpreted as 0.
Parses a compact ISO date (yyyymmdd), and returns a tuple with year, month, and day.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError, chrono.error.MonthError, or chrono.error.DayError for invalid date values.
Parses a compact ISO ordinal date (yyyyddd), and returns a tuple with year, month, and day.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError or chrono.error.DayError for invalid date values.
Parses a compact ISO time (hhmmss), and returns a tuple with hour, minute, and second.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.HourError, chrono.error.MinuteError, or chrono.error.SecondError for invalid time values.
Parses a compact ISO week (yyyyWww), and returns a tuple with year, month, and day (the first Monday of the week).
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError or chrono.error.WeekError for invalid date values.
Parses a compact ISO weekdate (yyyyWwwd), and returns a tuple with year, month, and day.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError, chrono.error.WeekError, or chrono.error.DayError for invalid date values.
Parses a ISO date (yyyy-mm-dd), and returns a tuple with year, month, and day.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError, chrono.error.MonthError, or chrono.error.DayError for invalid date values.
Parses an ISO month (yyyy-mm), and returns a tuple with year, month, and day (the first day of the month).
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError or chrono.error.MonthError for invalid date values.
Parses an ISO ordinal date (yyyy-ddd), and returns a tuple with year, month, and day.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError or chrono.error.DayError for invalid date values.
Parses an ISO date in any supported format, and returns a tuple with year, month, and day. For formats which doesn’t provide data with day precision, the earliest possible day is used - for example, 2009-W32 would return (2009, 8, 3), the Monday of week 32 2009.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and an appropriate chrono.error.DateError subclass for invalid date values.
Parses an ISO datetime in any supported format and returns a tuple with year, month, day, hour, minute, and second.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and an appropriate chrono.error.DateTimeError subclass for invalid datetime values.
Parses an ISO time in any supported format and returns a tuple with hour, minutes, and seconds.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and an appropriate chrono.error.TimeError subclass for invalid time values.
Parses an ISO time (hh:mm:ss), and returns a tuple with hour, minute, and second.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.HourError, chrono.error.MinuteError, or chrono.error.SecondError for invalid time values.
Parses an ISO week (yyyy-Www), and returns a tuple with year, month, and day (the first Monday of the week).
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError or chrono.error.WeekError for invalid date values.
Parses an ISO weekdate (yyyy-Www-d), and returns a tuple with year, month, and day.
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError, chrono.error.WeekError, or chrono.error.DayError for invalid date values.
Parses an ISO year (yyyy), and returns a tuple with year, month, and day (the first day of the year).
Raises chrono.error.ParseError for invalid input format, TypeError for invalid input type, and chrono.error.YearError for invalid year value.