From c0a5d8cbe9206407dbfc9a09ed7495adaee7078a Mon Sep 17 00:00:00 2001 From: yunlongJia Date: Thu, 9 Jan 2025 11:09:48 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- saas/backend/util/time.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/saas/backend/util/time.py b/saas/backend/util/time.py index 341e3c6f5..d61d854d9 100644 --- a/saas/backend/util/time.py +++ b/saas/backend/util/time.py @@ -33,7 +33,9 @@ def utc_string_to_timestamp(str_time: str) -> int: """ 后端UTC时间转换为时间戳 """ + # Note: 该转换后是 naive datetime,即不带时区 naive_t = string_to_datetime(str_time, fmt="%Y-%m-%dT%H:%M:%SZ") + # 由于 str_time 本身就是 utc 时间字符串,所以可以设置时区为 UTC,这样就得到 aware datetime aware_t = naive_t.replace(tzinfo=datetime.timezone.utc) return int(aware_t.timestamp())