| 25 | |
| 26 | # 参考: https://github.com/PyGithub/PyGithub/blob/0245b758ca323dfa18cd7910d50300ca42514999/github/GithubObject.py#L173 |
| 27 | def parse_datetime(s): |
| 28 | if len(s) == 24: |
| 29 | return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%S.000Z") |
| 30 | |
| 31 | elif len(s) >= 25: |
| 32 | return datetime.datetime.strptime(s[:19], "%Y-%m-%dT%H:%M:%S") + ( |
| 33 | 1 if s[19] == "-" else -1 |
| 34 | ) * datetime.timedelta(hours=int(s[20:22]), minutes=int(s[23:25])) |
| 35 | |
| 36 | else: |
| 37 | date1 = datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ") |
| 38 | return date1 + datetime.timedelta(hours=8) |