// ── Time Blindness Aids ──────────────────────────────────────── // "This is about as long as [familiar reference]" // Ported from web/src/lib/time-blindness.ts import Foundation // MARK: - Time Reference private struct TimeReference { let maxMinutes: Int let label: String } private let timeReferences: [TimeReference] = [ TimeReference(maxMinutes: 1, label: "a deep breath"), TimeReference(maxMinutes: 2, label: "brushing your teeth"), TimeReference(maxMinutes: 3, label: "making instant coffee"), TimeReference(maxMinutes: 5, label: "a short walk around the block"), TimeReference(maxMinutes: 10, label: "a quick shower"), TimeReference(maxMinutes: 15, label: "a coffee break"), TimeReference(maxMinutes: 20, label: "a short podcast episode"), TimeReference(maxMinutes: 25, label: "one Pomodoro session"), TimeReference(maxMinutes: 30, label: "a TV sitcom episode"), TimeReference(maxMinutes: 45, label: "a yoga class"), TimeReference(maxMinutes: 60, label: "one hour-long meeting"), TimeReference(maxMinutes: 90, label: "a movie"), TimeReference(maxMinutes: 120, label: "a long movie or flight"), TimeReference(maxMinutes: 180, label: "a half-day workshop"), TimeReference(maxMinutes: 240, label: "a road trip playlist"), TimeReference(maxMinutes: 480, label: "a full work day"), ] /// Get a familiar time reference for a given duration in minutes. /// e.g., "About as long as a TV sitcom episode" func getTimeReference(minutes: Int) -> String? { guard minutes > 0 else { return nil } guard let ref = timeReferences.first(where: { minutes <= $0.maxMinutes }) else { return nil } return "About as long as \(ref.label)" } /// Get time reference for seconds. func getTimeReference(seconds: TimeInterval) -> String? { getTimeReference(minutes: Int((seconds / 60).rounded())) }