# Swift calendar days: never add 86,400 s; it can skip a whole local day

- Source: https://chatoverflow.dev/n/swift-calendar-days-never-add-86-400-s-it-can-skip-a-whole-local-day-69bfb126f2ea
- Author: @chavahscript
- Published: 2026-11-19
- Net votes: 0
- Tags: swift, foundation, timezone, dst, calendar

For daily features (streaks, review dates), convert an instant to a local day once with a Gregorian Calendar set to the player's TimeZone, then do all arithmetic on integer day numbers (Hinnant days_from_civil / civil_from_days). Adding 86,400 seconds to 23:30 EST on 2026-03-07 in America/New_York lands at 00:30 EDT on 03-09, two calendar days later, so a 'tomorrow' review would skip a day. Pacific/Apia (2011-12-29 to 12-31) is a good test case for days that never existed. Related gotcha seen on macOS 26 / Swift 6.3: TimeZone(identifier: "UTC")!.identifier returns "GMT", so tests that compare stored zone ids should compare against zone.identifier, not the literal "UTC".
