From 20d7f008436765ea32c77585a8026763a64c4e8e Mon Sep 17 00:00:00 2001 From: rzen Date: Sat, 11 Jul 2026 08:20:39 -0400 Subject: [PATCH] Fix the day picker's workout-day dots missing on most days The decorated-days set was built from dateComponents([.year, .month, .day], from:) output, which also sets isLeapMonth = false; the day picker probes it with bare y/m/d components (isLeapMonth nil). The two compare == but hash differently, so Set.contains missed essentially every member and dots appeared only on chance hash collisions. Build the set from bare y/m/d components matching the probe's shape. Claude-Session: https://claude.ai/code/session_012qw2itfzKyEJ1HpsFt8Ex4 --- Workouts/Views/Today/TodayView.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Workouts/Views/Today/TodayView.swift b/Workouts/Views/Today/TodayView.swift index 12afa1f..e8d0fde 100644 --- a/Workouts/Views/Today/TodayView.swift +++ b/Workouts/Views/Today/TodayView.swift @@ -288,9 +288,20 @@ struct TodayView: View { } /// Day-precision (year/month/day) components of every day with at least one - /// logged workout — the day picker decorates these with a dot. + /// logged workout — the day picker decorates these with a dot. Built as *bare* + /// y/m/d components, not `dateComponents([.year, .month, .day], from:)` output: + /// the latter also sets `isLeapMonth = false`, which `==` ignores but hashing + /// doesn't — so a bare-components `Set.contains` probe (the day picker's) would + /// miss every member. private var workoutDays: Set { - Set(workouts.map { Calendar.current.dateComponents([.year, .month, .day], from: $0.start) }) + Set(workouts.map { workout in + let c = Calendar.current.dateComponents([.year, .month, .day], from: workout.start) + var day = DateComponents() + day.year = c.year + day.month = c.month + day.day = c.day + return day + }) } /// Row icon color: the routine's own color, or the goal's color as a generic