From ec56048bc92616b8a68433eac4a4052331029ce0 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Tue, 20 Feb 2024 16:00:27 +0800 Subject: [PATCH] update --- xumu.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xumu.py b/xumu.py index 664a67b..a8aa38e 100644 --- a/xumu.py +++ b/xumu.py @@ -344,7 +344,16 @@ async def past_seven_days(deviceId): "sql": sql } r = requests.post(baseHost + queryUri, headers=headers, json=send_json) - return BaseResponse(data=r.json()) + data = r.json() + timestamps = data["timestamps"] + times = [] + for timestamp in timestamps: + dt = datetime.fromtimestamp(timestamp / 1000) # 因为时间戳是以毫秒为单位的,所以需要除以1000 + # 将datetime对象格式化为只包含年月日的字符串 + year_month_day_str = dt.strftime('%Y-%m-%d') + times.append(year_month_day_str) + data["timestamps"] = times + return BaseResponse(data=data) except Exception as e: return BaseResponse(code=500, msg=str(e))