This commit is contained in:
xyj 2024-02-20 16:00:27 +08:00
parent fe712cc09c
commit ec56048bc9
1 changed files with 10 additions and 1 deletions

11
xumu.py
View File

@ -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))