mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 09:03:11 +00:00
Fix weekly schedule starting from today instead of Monday (#18)
The handler passed `now` as start_date, so mid-week runs showed 14 days from today instead of Mon–Sun x2. Also, day names were derived from a static index (DAY_ORDER[i%7]) which assumed index 0 = Monday — when start_date wasn't Monday, Saturday and Sunday were mislabeled as Monday and Tuesday. Fix: pass this week's Monday from the handler, and derive day names from the actual date via strftime instead of a static list. Fixes #17
This commit is contained in:
parent
14f9723a87
commit
fe6b780e12
2 changed files with 5 additions and 5 deletions
|
|
@ -5,7 +5,6 @@ from zoneinfo import ZoneInfo
|
|||
|
||||
EASTERN = ZoneInfo("America/New_York")
|
||||
|
||||
DAY_ORDER = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
||||
WEEKEND_DAYS = {"Saturday", "Sunday"}
|
||||
|
||||
|
||||
|
|
@ -47,7 +46,7 @@ def build_week_schedule(schedule, start_date: datetime | None = None) -> list[di
|
|||
lines.append("") # visual separator between weeks
|
||||
date = start_date + timedelta(days=i)
|
||||
date_str = date.strftime("%Y-%m-%d")
|
||||
day_name = DAY_ORDER[i % 7]
|
||||
day_name = date.strftime("%A")
|
||||
is_today = date_str == today_str
|
||||
|
||||
# Weekend day shift (8am–5pm)
|
||||
|
|
|
|||
|
|
@ -172,10 +172,11 @@ def handler(event, context):
|
|||
# Email pay summary to payroll
|
||||
_send_pay_email(week_label, pay_record)
|
||||
|
||||
# --- Two-week schedule ---
|
||||
blocks = build_week_schedule(schedule, start_date=now)
|
||||
# --- Two-week schedule (always starts on Monday of this week) ---
|
||||
this_monday = now - timedelta(days=now.weekday())
|
||||
blocks = build_week_schedule(schedule, start_date=this_monday)
|
||||
|
||||
end_date = now + timedelta(days=13)
|
||||
end_date = this_monday + timedelta(days=13)
|
||||
slack.chat_postMessage(
|
||||
channel=channel_id,
|
||||
blocks=blocks,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue