This commit is contained in:
aozhiwei 2020-11-26 21:00:36 +08:00
parent 4af43d5649
commit dfefdc732a

View File

@ -2,14 +2,24 @@
#!/usr/bin/python #!/usr/bin/python
import binascii import binascii
import time
import datetime
def xPrint(text): def xPrint(text):
print(text, flush=True) print(text, flush=True)
def getDaySeconds(time_val, incdays): def getDaySeconds(time_val, incdays = 0):
time_zone = 8 time_zone = 8
return int((time_val + time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * time_zone; return int((time_val + time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * time_zone;
def getMondaySeconds(time_val):
dt_val = datetime.datetime.fromtimestamp(time_val)
day = dt_val.weekday()
if day == 0:
return getDaySeconds(time_val - (3600 * 24 * 6))
else:
return getDaySeconds(time_val - (3600 * 24 * (day - 1)))
def crc32(data): def crc32(data):
hash_code = binascii.crc32(data) hash_code = binascii.crc32(data)
assert hash_code >= 0 assert hash_code >= 0