Initial commit: IceGlass NHL game tracker

macOS menu bar app providing NHL game situational awareness with
league-wide scoreboard, dynamic polling, notifications with team
logos, and configurable display options.
This commit is contained in:
2026-04-13 21:44:08 -04:00
commit 8f8f8b2755
158 changed files with 2752 additions and 0 deletions
@@ -0,0 +1,14 @@
//
// Date+easternTimeZone.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Date {
static var easternTimeZone: TimeZone {
TimeZone(identifier: "America/New_York")!
}
}
+16
View File
@@ -0,0 +1,16 @@
//
// Date+etCalendar.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Date {
static func etCalendar() -> Calendar {
var calendar = Calendar.current
calendar.timeZone = Date.easternTimeZone
return calendar
}
}
@@ -0,0 +1,21 @@
//
// Date+formatDateET.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Date {
func formatDateET(format: String = "MMMM, d yyyy @ h:mm a z") -> String {
let formatter = DateFormatter()
formatter.timeZone = TimeZone(identifier: "America/New_York")
formatter.dateFormat = format
return formatter.string(from: self)
}
static var ISO8601: String {
"yyyy-MM-dd'T'HH:mm:ssZ"
}
}
+68
View File
@@ -0,0 +1,68 @@
//
// 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
}
}
@@ -0,0 +1,15 @@
//
// NSMenuItem+withTarget.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import AppKit
extension NSMenuItem {
func withTarget(_ target: AnyObject) -> NSMenuItem {
self.target = target
return self
}
}
@@ -0,0 +1,36 @@
//
// TimeInterval+humanReadableTime.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension TimeInterval {
static func humanReadableTime(from timeInterval: TimeInterval) -> String {
let seconds = Int(timeInterval)
let hours = seconds / 3600
let minutes = (seconds % 3600) / 60
let remainingSeconds = seconds % 60
var components: [String] = []
if hours > 0 {
components.append("\(hours) \(hours == 1 ? "hour" : "hours")")
}
if minutes > 0 {
components.append("\(minutes) \(minutes == 1 ? "minute" : "minutes")")
}
if remainingSeconds > 0 || components.isEmpty {
components.append("\(remainingSeconds) \(remainingSeconds == 1 ? "second" : "seconds")")
}
return components.joined(separator: " ")
}
func humanReadableTime() -> String {
return TimeInterval.humanReadableTime(from: self)
}
}
@@ -0,0 +1,19 @@
//
// Timer+startTimer.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Timer {
static func startTimer(timer: Timer?, interval: TimeInterval, action: @escaping @Sendable (Timer) -> Void) -> Timer {
timer?.invalidate()
return Timer.scheduledTimer(
withTimeInterval: interval,
repeats: true,
block: action
)
}
}