Parse the string date. This supports the subset of ISO8601 used by xsd:date, but is lenient with what is accepted, handling most reasonable syntax. Any timezone is parsed but ignored because a) it's meaningless without a time and b) B{datetime}.I{date} does not sup
(value)
| 74 | |
| 75 | @staticmethod |
| 76 | def parse(value): |
| 77 | """Parse the string date. |
| 78 | |
| 79 | This supports the subset of ISO8601 used by xsd:date, but is lenient |
| 80 | with what is accepted, handling most reasonable syntax. |
| 81 | |
| 82 | Any timezone is parsed but ignored because a) it's meaningless without |
| 83 | a time and b) B{datetime}.I{date} does not support a tzinfo property. |
| 84 | |
| 85 | @param value: A date string. |
| 86 | @type value: str |
| 87 | @return: A date object. |
| 88 | @rtype: B{datetime}.I{date} |
| 89 | |
| 90 | """ |
| 91 | match_result = RE_DATE.match(value) |
| 92 | if match_result is None: |
| 93 | raise ValueError('date data has invalid format "%s"' % value) |
| 94 | |
| 95 | value = date_from_match(match_result) |
| 96 | |
| 97 | return value |
| 98 | |
| 99 | def __str__(self): |
| 100 | return self.value.isoformat() |
no test coverage detected