2020-08-02 01:46:20 +00:00
|
|
|
|
import re
|
|
|
|
|
|
2020-08-12 16:01:34 +00:00
|
|
|
|
|
|
|
|
|
def UTC8(str1, outtype):
|
2021-08-24 13:08:33 +00:00
|
|
|
|
print(str1)
|
|
|
|
|
if str1 in ['infinity', 'infinite']:
|
2020-08-08 06:30:04 +00:00
|
|
|
|
return ('无限期')
|
2020-08-02 01:46:20 +00:00
|
|
|
|
else:
|
2020-08-08 06:30:04 +00:00
|
|
|
|
q = re.match(r'(.*)-(.*)-(.*)T(.*):(.*):(.*)Z', str1)
|
2021-06-01 12:52:13 +00:00
|
|
|
|
if not q:
|
|
|
|
|
q = re.match(r'(....)(..)(..)(..)(..)(..)', str1)
|
2020-08-08 06:30:04 +00:00
|
|
|
|
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))
|
2020-09-20 11:11:11 +00:00
|
|
|
|
# s = int(q.group(6))
|
2020-08-08 06:30:04 +00:00
|
|
|
|
|
|
|
|
|
h = h + 8
|
2020-08-12 16:01:34 +00:00
|
|
|
|
if h > 24:
|
2020-08-08 06:30:04 +00:00
|
|
|
|
d = d + 1
|
|
|
|
|
h = h - 24
|
|
|
|
|
else:
|
|
|
|
|
pass
|
|
|
|
|
if m == 2:
|
|
|
|
|
if y % 100 == 0:
|
|
|
|
|
if y % 400 == 0:
|
|
|
|
|
pass
|
2020-08-02 01:46:20 +00:00
|
|
|
|
else:
|
2020-08-08 06:30:04 +00:00
|
|
|
|
if d == 29:
|
|
|
|
|
m = m + 1
|
|
|
|
|
d = d - 28
|
|
|
|
|
else:
|
|
|
|
|
pass
|
|
|
|
|
if d == 29:
|
|
|
|
|
if y % 4 == 0:
|
2020-08-02 01:46:20 +00:00
|
|
|
|
pass
|
2020-08-08 06:30:04 +00:00
|
|
|
|
else:
|
|
|
|
|
m = m + 1
|
|
|
|
|
d = d - 28
|
|
|
|
|
if d == 30:
|
2020-08-02 01:46:20 +00:00
|
|
|
|
m = m + 1
|
2020-08-08 06:30:04 +00:00
|
|
|
|
d = d - 29
|
|
|
|
|
else:
|
|
|
|
|
pass
|
2020-08-02 01:46:20 +00:00
|
|
|
|
else:
|
|
|
|
|
pass
|
2020-08-08 06:30:04 +00:00
|
|
|
|
if d == 31:
|
|
|
|
|
if m == 4 or m == 6 or m == 9 or m == 11:
|
|
|
|
|
m = m + 1
|
|
|
|
|
d = d - 30
|
|
|
|
|
else:
|
|
|
|
|
pass
|
2020-08-02 01:46:20 +00:00
|
|
|
|
else:
|
|
|
|
|
pass
|
2020-08-08 06:30:04 +00:00
|
|
|
|
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
|
|
|
|
|
if outtype == 'onlytimenoutc':
|
2020-08-12 16:01:34 +00:00
|
|
|
|
return (str(h) + '时' + str(mi) + '分')
|
2020-08-08 06:30:04 +00:00
|
|
|
|
elif outtype == 'onlytime':
|
2020-08-12 16:01:34 +00:00
|
|
|
|
return (str(h) + '时' + str(mi) + '分' + '(UTC+8)')
|
2020-08-08 06:30:04 +00:00
|
|
|
|
elif outtype == 'full':
|
2020-08-12 16:01:34 +00:00
|
|
|
|
return (str(y) + '年' + str(m) + '月' + str(d) + '日' + str(h) + '时' + str(mi) + '分' + '(UTC+8)')
|
2020-08-08 06:30:04 +00:00
|
|
|
|
elif outtype == 'notimezone':
|
2020-08-12 16:01:34 +00:00
|
|
|
|
return (str(y) + '年' + str(m) + '月' + str(d) + '日' + str(h) + '时' + str(mi) + '分')
|