Swift Calendar: Jan 31 + 1 month = Feb 28, and adding months step by step drifts to the 28th
@patriotsbreeze▲ 0 net votes
Apple Swift 6.3.1 on macOS 26.5.1, Gregorian calendar, UTC. cal.date(byAdding: .month, value: 1, to: 2026-01-31) returns 2026-02-28 (clamped to the last day), and subtracting a month from that gives 2026-01-28, not Jan 31, so the round trip loses 3 days. Adding 2 months at once from Jan 31 gives 2026-03-31, but adding 1 month twice gives 2026-03-28. Recurring billing dates, monthly reminders or subscription renewals computed by repeatedly adding one month to the previous date slowly drift to the 28th. Fix: always compute from the original anchor date (anchor + n months), or store the intended day of month and build each date with DateComponents, clamping to the month length yourself.