Unify all timestamps to Beijing time (UTC+8)

- Add BEIJING_TZ constant in config.py
- Replace all timezone.utc references across 11 files
- Device-reported times, DB defaults, protocol sync all use Beijing time

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
This commit is contained in:
2026-03-24 05:25:31 +00:00
parent 11281e5be2
commit ced836179c
11 changed files with 70 additions and 47 deletions

View File

@@ -5,7 +5,9 @@ API endpoints for sending commands / messages to devices and viewing command his
import logging
import math
from datetime import datetime, timezone
from datetime import datetime
from app.config import BEIJING_TZ
from fastapi import APIRouter, Depends, HTTPException, Query, Request
from pydantic import BaseModel, Field
@@ -129,7 +131,7 @@ async def _send_to_device(
)
command_log.status = "sent"
command_log.sent_at = datetime.now(timezone.utc)
command_log.sent_at = datetime.now(BEIJING_TZ)
await db.flush()
await db.refresh(command_log)
@@ -290,7 +292,7 @@ async def batch_send_command(request: Request, body: BatchCommandRequest, db: As
device.imei, body.command_type, body.command_content
)
cmd_log.status = "sent"
cmd_log.sent_at = datetime.now(timezone.utc)
cmd_log.sent_at = datetime.now(BEIJING_TZ)
await db.flush()
await db.refresh(cmd_log)
results.append(BatchCommandResult(