Parse the string date. This supports the subset of ISO8601 used by xsd:time, but is lenient with what is accepted, handling most reasonable syntax. @param value: A time string. @type value: str @return: A time object. @rtype: B{datetime}.I{time}
(value)
| 129 | |
| 130 | @staticmethod |
| 131 | def parse(value): |
| 132 | """Parse the string date. |
| 133 | |
| 134 | This supports the subset of ISO8601 used by xsd:time, but is lenient |
| 135 | with what is accepted, handling most reasonable syntax. |
| 136 | |
| 137 | @param value: A time string. |
| 138 | @type value: str |
| 139 | @return: A time object. |
| 140 | @rtype: B{datetime}.I{time} |
| 141 | |
| 142 | """ |
| 143 | match_result = RE_TIME.match(value) |
| 144 | if match_result is None: |
| 145 | raise ValueError('date data has invalid format "%s"' % (value, )) |
| 146 | |
| 147 | date = time_from_match(match_result) |
| 148 | tzinfo = tzinfo_from_match(match_result) |
| 149 | |
| 150 | value = date.replace(tzinfo=tzinfo) |
| 151 | |
| 152 | return value |
| 153 | |
| 154 | def __str__(self): |
| 155 | return self.value.isoformat() |
no test coverage detected