aaffa3771c
Two-target restructure: shared sources (models, services, settings, extensions, team logos) move into Shared/, consumed by both the existing macOS menu bar app and a new iOS app. MainService no longer imports AppKit — platform code attaches via a MainServiceObserver protocol (MacObserverAdapter wires back to MenuManager / StatusItemManager / NotificationManager). iPhone app is a single SwiftUI page mirroring the macOS menu (playoff round + yesterday/today/tomorrow), with a gear-icon settings sheet (display option + IndieAbout for license/changelog). Persistent JSON snapshot in Application Support paints last-known data on cold launch; "Updated …" header escalates secondary → orange (>5min) → red (>30min) so staleness is visually unmistakable. Foreground polling, scenePhase refresh, and pull-to-refresh; no notifications on iOS in v1.
69 lines
2.2 KiB
Swift
69 lines
2.2 KiB
Swift
//
|
|
// Date+gameWindow.swift
|
|
// IceGlass
|
|
//
|
|
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension Date {
|
|
/// Returns YYYY-MM-DD string for yesterday in Eastern Time
|
|
static var yesterdayET: String {
|
|
let calendar = etCalendar()
|
|
let yesterday = calendar.date(byAdding: .day, value: -1, to: .now)!
|
|
return formatDateString(yesterday)
|
|
}
|
|
|
|
/// Returns YYYY-MM-DD string for today in Eastern Time
|
|
static var todayET: String {
|
|
formatDateString(.now)
|
|
}
|
|
|
|
/// Returns YYYY-MM-DD string for tomorrow in Eastern Time
|
|
static var tomorrowET: String {
|
|
let calendar = etCalendar()
|
|
let tomorrow = calendar.date(byAdding: .day, value: 1, to: .now)!
|
|
return formatDateString(tomorrow)
|
|
}
|
|
|
|
private static func formatDateString(_ date: Date) -> String {
|
|
date.formatDateET(format: "yyyy-MM-dd")
|
|
}
|
|
|
|
/// Returns a friendly label like "YESTERDAY", "TODAY", "TOMORROW", or a formatted date
|
|
static func friendlyDateLabel(for dateString: String) -> String {
|
|
if dateString == todayET { return "TODAY" }
|
|
if dateString == yesterdayET { return "YESTERDAY" }
|
|
if dateString == tomorrowET { return "TOMORROW" }
|
|
|
|
// Parse and format as weekday abbreviation + date
|
|
let inputFormatter = DateFormatter()
|
|
inputFormatter.dateFormat = "yyyy-MM-dd"
|
|
inputFormatter.timeZone = easternTimeZone
|
|
|
|
if let date = inputFormatter.date(from: dateString) {
|
|
return date.formatDateET(format: "EEE, MMM d")
|
|
}
|
|
return dateString
|
|
}
|
|
|
|
/// Returns a full label like "TODAY — Sun, Apr 12"
|
|
static func fullDateLabel(for dateString: String) -> String {
|
|
let friendly = friendlyDateLabel(for: dateString)
|
|
|
|
let inputFormatter = DateFormatter()
|
|
inputFormatter.dateFormat = "yyyy-MM-dd"
|
|
inputFormatter.timeZone = easternTimeZone
|
|
|
|
if let date = inputFormatter.date(from: dateString) {
|
|
let formatted = date.formatDateET(format: "EEE, MMM d")
|
|
if friendly == "TODAY" || friendly == "YESTERDAY" || friendly == "TOMORROW" {
|
|
return "\(friendly) — \(formatted)"
|
|
}
|
|
return formatted
|
|
}
|
|
return friendly
|
|
}
|
|
}
|