Fix iOS time display and add timer unit labels

Times were always showing 0 because ISO8601DateFormatter with default
options does not parse fractional seconds, but Prisma/Node.js serialises
dates as "2026-02-20T09:00:00.000Z" (with .000). Every date(from:) call
silently returned nil, so elapsedTime and duration always fell back to 0.

- Date+Extensions: fromISO8601 now tries .withFractionalSeconds first,
  then falls back to whole seconds — single place to maintain
- OngoingTimer.elapsedTime: use Date.fromISO8601() instead of bare formatter
- TimeEntry.duration: use Date.fromISO8601() instead of bare formatters
- TimerView: add TimerUnitLabels view showing h/min/sec column headers
  under the monospaced clock digits
This commit is contained in:
2026-02-20 14:49:44 +01:00
parent da0cd302bf
commit f42de3353c
4 changed files with 40 additions and 10 deletions

View File

@@ -9,9 +9,7 @@ struct OngoingTimer: Codable, Identifiable, Equatable {
let updatedAt: String
var elapsedTime: TimeInterval {
guard let start = ISO8601DateFormatter().date(from: startTime) else {
return 0
}
guard let start = Date.fromISO8601(startTime) else { return 0 }
return Date().timeIntervalSince(start)
}
}

View File

@@ -11,10 +11,8 @@ struct TimeEntry: Codable, Identifiable, Equatable {
let updatedAt: String
var duration: TimeInterval {
guard let start = ISO8601DateFormatter().date(from: startTime),
let end = ISO8601DateFormatter().date(from: endTime) else {
return 0
}
guard let start = Date.fromISO8601(startTime),
let end = Date.fromISO8601(endTime) else { return 0 }
return end.timeIntervalSince(start)
}
}