This commit is contained in:
2026-11-04 15:35:15 +08:00
parent 4709ea4328
commit 62291c57ec
12 changed files with 363 additions and 72 deletions
+18
View File
@@ -0,0 +1,18 @@
"""每个半小时刻度提前5分钟采集,返回值标记对应的半小时刻度。"""
import time
HALF_HOUR_SECONDS = 30 * 60
UPDATE_LEAD_SECONDS = 5 * 60
def half_hour_start(timestamp: float | None = None) -> int:
if timestamp is None:
timestamp = time.time()
return int(timestamp) // HALF_HOUR_SECONDS * HALF_HOUR_SECONDS
def refresh_slot(timestamp: float | None = None) -> int:
if timestamp is None:
timestamp = time.time()
return half_hour_start(timestamp + UPDATE_LEAD_SECONDS)