// A time column's value, and where a clock's hands point for it: arithmetic// of the clock, not a look. The house's words for it are the app's// (`CottonUI/Editors/ColumnValues.swift`).importFoundation/// A clock time with no day: a time column's whole value, a date column's/// optional part.publicstructClockTime: Equatable, Hashable, Sendable, Comparable {publicvar hour: Intpublicvar minute: Intpublicinit(hour: Int, minute: Int) {self.hour = hourself.minute = minute }/// Minutes since midnight — the order and the identity.publicvar key: Int { hour * 60 + minute }publicstaticfunc < (left: ClockTime, right: ClockTime) -> Bool { left.key < right.key }/// Reads a time column's `"HH:mm"`. Anything else is no time at all.publicstaticfunc read(_ value: RecordValue) -> ClockTime? {guardcase .text(let raw) = value else { returnnil }let parts = raw.split(separator: ":")guard parts.count == 2, let hour = Int(parts[0]), let minute = Int(parts[1]), (0..<24).contains(hour), (0..<60).contains(minute)else { returnnil }returnClockTime(hour: hour, minute: minute) }publicvar stored: RecordValue { .text(String(format: "%02d:%02d", hour, minute)) }}/// The live hands drawn on the card's clock object.publicenumCardEnamelPrint {/// The two hands' angles, in degrees clockwise from twelve.publicstaticfunc hands(_ time: ClockTime) -> (hour: Double, minute: Double) {let minute = Double(time.minute) * 6let hour = Double(time.hour % 12) * 30 + Double(time.minute) * 0.5return (hour, minute) }}