As for http2time, but parses the ISO 8601 formats: 1994-02-03 14:15:29 -0100 -- ISO 8601 format 1994-02-03 14:15:29 -- zone is optional 1994-02-03 -- only date 1994-02-03T14:15:29 -- Use T as separator 19940203T141529Z -- I
(text)
| 304 | \s* |
| 305 | )?$""", re.X | re. ASCII) |
| 306 | def iso2time(text): |
| 307 | """ |
| 308 | As for http2time, but parses the ISO 8601 formats: |
| 309 | |
| 310 | 1994-02-03 14:15:29 -0100 -- ISO 8601 format |
| 311 | 1994-02-03 14:15:29 -- zone is optional |
| 312 | 1994-02-03 -- only date |
| 313 | 1994-02-03T14:15:29 -- Use T as separator |
| 314 | 19940203T141529Z -- ISO 8601 compact format |
| 315 | 19940203 -- only date |
| 316 | |
| 317 | """ |
| 318 | # clean up |
| 319 | text = text.lstrip() |
| 320 | |
| 321 | # tz is time zone specifier string |
| 322 | day, mon, yr, hr, min, sec, tz = [None]*7 |
| 323 | |
| 324 | # loose regexp parse |
| 325 | m = ISO_DATE_RE.search(text) |
| 326 | if m is not None: |
| 327 | # XXX there's an extra bit of the timezone I'm ignoring here: is |
| 328 | # this the right thing to do? |
| 329 | yr, mon, day, hr, min, sec, tz, _ = m.groups() |
| 330 | else: |
| 331 | return None # bad format |
| 332 | |
| 333 | return _str2time(day, mon, yr, hr, min, sec, tz) |
| 334 | |
| 335 | |
| 336 | # Header parsing |
searching dependent graphs…