JhHardwareWRS_BackPoint/app/services/reporting_window.py
2026-06-24 15:19:14 +08:00

15 lines
502 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from datetime import datetime, timedelta
from app.models import WorkSession
from app.timezone import now
REPORTING_EXPIRE_MINUTES = 15
REPORTING_EXPIRED_DETAIL = "报工填写已超过15分钟请重新扫码点击重新报工"
def is_reporting_expired(session: WorkSession, current_time: datetime | None = None) -> bool:
if session.end_at is None:
return False
timestamp = current_time or now()
return timestamp - session.end_at > timedelta(minutes=REPORTING_EXPIRE_MINUTES)