Add production order search and shift drill-down
This commit is contained in:
1 parent
6e8eb6f50f
commit
dcde029bc7
8 files changed
+742
-4
No files matched your search
@@ -79,6 +79,28 @@ def shift_report_window(
|
||||
)
|
||||
|
||||
|
||||
def shift_containing(
|
||||
timestamp: datetime, timezone: ZoneInfo,
|
||||
) -> tuple[date, Literal["early", "late", "night"], datetime, datetime]:
|
||||
"""Return the site-local shift containing one confirmation instant."""
|
||||
if (not isinstance(timestamp, datetime) or timestamp.tzinfo is None
|
||||
or timestamp.utcoffset() is None):
|
||||
raise ValueError("timestamp must be timezone-aware")
|
||||
if not isinstance(timezone, ZoneInfo):
|
||||
raise ValueError("timezone must be a ZoneInfo")
|
||||
local = timestamp.astimezone(timezone)
|
||||
if local.hour < 6:
|
||||
day, shift = local.date() - timedelta(days=1), "night"
|
||||
elif local.hour < 14:
|
||||
day, shift = local.date(), "early"
|
||||
elif local.hour < 22:
|
||||
day, shift = local.date(), "late"
|
||||
else:
|
||||
day, shift = local.date(), "night"
|
||||
start, end = shift_report_window(day, shift, timezone)
|
||||
return day, shift, start, end
|
||||
|
||||
|
||||
def most_recent_completed_shift(
|
||||
now: datetime, timezone: ZoneInfo,
|
||||
) -> tuple[date, Literal["early", "late", "night"]]:
|
||||
|
||||
Reference in new issue
Block a user