Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/UTC8.py
2020-08-02 09:46:20 +08:00

58 lines
No EOL
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
def UTC8(str1):
q = re.match(r'(.*)-(.*)-(.*)T(.*):(.*):(.*)Z', str1)
y = int(q.group(1))
m = int(q.group(2))
d = int(q.group(3))
h = int(q.group(4))
mi = int(q.group(5))
s = int(q.group(6))
h = h + 8
if h > 24 :
d = d + 1
h = h - 24
else:
pass
if m == 2:
if y % 100 == 0:
if y % 400 == 0:
pass
else:
if d == 29:
m = m + 1
d = d - 28
else:
pass
if d == 29:
if y % 4 == 0:
pass
else:
m = m + 1
d = d - 28
if d == 30:
m = m + 1
d = d - 29
else:
pass
else:
pass
if d == 31:
if m == 4 or m == 6 or m == 9 or m == 11:
m = m + 1
d = d - 30
else:
pass
else:
pass
if d == 32:
m = m + 1
d = d - 31
if m == 13:
m = m - 12
y = y + 1
if h == 24:
if mi != 0:
h = h - 24
return (str(h)+''+str(mi)+''+'UTC+8')