// The journal DAY KEY — and, since 4i, nothing else. // // This file used to hold a second implementation of the journal streak, landed // alongside the formatters in 4c. **It is gone.** // `cotton_core::rules::journal` owns the figure now — `journal_day_state` // answers `{writtenToday, streak}` and both surfaces that draw it read that one // answer through `read.home`. Two copies // once disagreed about the same day and the same data, which is the whole // reason the figure was consolidated at all — // and keeping a Swift copy nothing called would have been the same defect // waiting with a longer fuse // ([one-implementation-of-who-wins-the-same-schema-and-conflict-rule]). // // Its tests went with it, into `crates/cotton-core/src/rules/journal_tests.rs` // where the implementation is. The daylight-saving case is the one that had to // TRAVEL rather than simply be deleted: every streak case Rust already had is // in IST, which never shifts, so // `a_streak_survives_a_daylight_saving_transition` was written there in the // same commit that emptied this file. // // What survives is `dayKey`, and it survives because it has a caller that is // not about streaks at all: `Capture/CaptureText.swift` files a capture under // the local day. That is a FORMATTER, which is what this directory is for. import Foundation public enum JournalStreak { /// `YYYY-MM-DD` from the LOCAL calendar — never a UTC stamp. A /// late-evening entry east of Greenwich would otherwise be filed as /// tomorrow, and a day that was written would read as blank at 00:01. /// /// The same key `cotton_core::rules::journal::journal_date_key` mints /// below the boundary, and `journal_date_key_matches_the_typescript` is the /// case that pins the two spellings together. public static func dayKey(_ date: Date, calendar: Calendar = .current) -> String { let parts = calendar.dateComponents([.year, .month, .day], from: date) return String(format: "%04d-%02d-%02d", parts.year ?? 0, parts.month ?? 0, parts.day ?? 0) } }