feat(api): 統一使用台北時區 UTC+8 (禁止 UTC)
- 新增 src/utils/timezone.py 時區工具函式 - 修改 11 個後端檔案,全部改用 now_taipei() - 更新 HARD_RULES.md 加入時區鐵律章節 - 更新 Skills 02/04 加入時區禁令 🔴 HARD RULE: 禁止 datetime.utcnow() / datetime.now(UTC) ✅ 正確做法: from src.utils.timezone import now_taipei Memory: feedback_timezone_taipei.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,10 @@ import random
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
# 台北時區 (UTC+8) - 系統統一時區
|
||||
TAIPEI_TZ = timezone(timedelta(hours=8))
|
||||
from typing import Any
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -160,7 +163,7 @@ class SensorAgent:
|
||||
return None
|
||||
|
||||
# 建立標準 Signal 格式
|
||||
now = datetime.now(timezone.utc)
|
||||
now = datetime.now(TAIPEI_TZ)
|
||||
signal = {
|
||||
"alert_name": alert.get("alert_name", "UnknownAlert"),
|
||||
"severity": alert.get("severity", "warning"),
|
||||
@@ -261,7 +264,7 @@ def main() -> int:
|
||||
print("=" * 70)
|
||||
print("AWOOOI Sensor Agent - Phase 6.5 神經末梢")
|
||||
print("=" * 70)
|
||||
print(f"Time: {datetime.now().isoformat()}")
|
||||
print(f"Time: {datetime.now(TAIPEI_TZ).isoformat()}")
|
||||
print(f"Host: {socket.gethostname()}")
|
||||
print()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user