MCPcopy Create free account
hub / github.com/C3ting/ARL / parse_datetime

Function parse_datetime

app/utils/time.py:27–38  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

25
26# 参考: https://github.com/PyGithub/PyGithub/blob/0245b758ca323dfa18cd7910d50300ca42514999/github/GithubObject.py#L173
27def 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)

Callers 1

commit_dateMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected