Skip to content

Commit 5c73d62

Browse files
authored
Update get_time
1 parent f67e11f commit 5c73d62

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

get_time

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
def GetCurWorldTimeSec():
2-
import time
3-
return time.time()
4-
5-
def GetCurTimeStr(time_zone = 0): ### Default is World Standard Time
6-
import time
7-
time_sec = time.time() + time_zone*3600
8-
time_str = time.strftime("%Y%m%d %X",time.gmtime(time_sec))
9-
time_str = "".join(time_str.split(":"))
10-
return time_str
11-
12-
def GetCurrentChinaTime():
13-
return GetCurTimeStr(8) ### Eastern eight zones
14-
15-
def GetCurrentWorldTime():
16-
return GetCurTimeStr()
17-
18-
print(GetCurrentChinaTime())
19-
print(GetCurrentWorldTime())
1+
def GetCurWorldTimeSec():    import time    return time.time()def GetCurTimeSec(time_zone = 0):    import time    time_sec = GetCurWorldTimeSec() + time_zone*3600    return time_secdef GetCurTimeStr(time_zone = 0):   ### Default is World Standard Time    import time    time_str = time.strftime("%Y%m%d %X",time.gmtime(GetCurTimeSec(time_zone)))    time_str = "".join(time_str.split(":"))    return time_strdef GetCurChinaTime():    return GetCurTimeStr(8)     ### Eastern eight zonesdef GetCurChinaDay():    return GetCurChinaTime().split(" ")[0]    def GetCurWorldTime():    return GetCurTimeStr()def GetCurWorldDay():    return GetCurWorldTime().split(" ")[0]if __name__ == "__main__":       print(GetCurChinaTime())    print(GetCurWorldTime())    print(GetCurChinaDay())    print(GetCurWorldDay())

0 commit comments

Comments
 (0)