Skip to content

Commit

Permalink
add:添加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
yunlong098 committed Jan 9, 2025
1 parent f132ec5 commit c0a5d8c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions saas/backend/util/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit c0a5d8c

Please sign in to comment.