summaryrefslogtreecommitdiffstats
path: root/Solsnu.Widget/Models/SolsticeEvent.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Solsnu.Widget/Models/SolsticeEvent.swift')
-rw-r--r--Solsnu.Widget/Models/SolsticeEvent.swift38
1 files changed, 0 insertions, 38 deletions
diff --git a/Solsnu.Widget/Models/SolsticeEvent.swift b/Solsnu.Widget/Models/SolsticeEvent.swift
deleted file mode 100644
index d8c4a7b..0000000
--- a/Solsnu.Widget/Models/SolsticeEvent.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-import Foundation
-
-struct SolsticeEvent: Identifiable, Codable {
- let id: UUID
- let name: String
- let date: Date // UTC
- let season: Season
-
- init(name: String, date: Date, season: Season) {
- self.id = UUID()
- self.name = name
- self.date = date
- self.season = season
- }
-
- /// Convert UTC date to user's local timezone
- func localDateTime() -> Date {
- let utcCalendar = Calendar(identifier: .gregorian)
- let utcComponents = utcCalendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: date)
- let timeZone = TimeZone.current
- let offset = timeZone.secondsFromGMT(for: date)
-
- var localCalendar = Calendar.current
- localCalendar.timeZone = timeZone
- var localComponents = utcComponents
- localComponents.second = (localComponents.second ?? 0) + offset
-
- return localCalendar.date(from: localComponents) ?? date
- }
-
- /// Days until this event from today
- func daysUntil() -> Int {
- let today = Calendar.current.startOfDay(for: Date())
- let eventDay = Calendar.current.startOfDay(for: date)
- let components = Calendar.current.dateComponents([.day], from: today, to: eventDay)
- return max(0, components.day ?? 0)
- }
-}