jiemianNews/defs/dump_data.py

17 lines
403 B
Python
Raw Normal View History

2022-08-02 15:24:13 +00:00
import json
import time as time_
from os.path import exists
def get_time() -> int:
if exists("data.json"):
with open("data.json", "r") as f:
data = json.load(f)
return data.get("update_time", int(time_.time()) - 600)
return int(time_.time()) - 600
def set_time(time: int) -> None:
with open("data.json", "w") as f:
json.dump({"update_time": time}, f)