Initial MVP for QA asset backend
This commit is contained in:
20
hy_qa_asset_backend/backend/app/utils/time_utils.py
Normal file
20
hy_qa_asset_backend/backend/app/utils/time_utils.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
def utc_now() -> datetime:
|
||||
return datetime.now(timezone.utc)
|
||||
|
||||
|
||||
def split_cron(cron: str) -> dict[str, str]:
|
||||
parts = cron.split()
|
||||
if len(parts) != 5:
|
||||
raise ValueError("SCHEDULE_CRON 需要使用 5 段 cron 表达式,例如 0 1 * * *")
|
||||
minute, hour, day, month, day_of_week = parts
|
||||
return {
|
||||
"minute": minute,
|
||||
"hour": hour,
|
||||
"day": day,
|
||||
"month": month,
|
||||
"day_of_week": day_of_week,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user