Fix iOS widget date formatting for RFC3339 dates
- Add centralized formatWidgetDate() helper that handles both yyyy-MM-dd and ISO8601 formats - Update widget date display to show "Today", "in X days", or "X days ago" - Fix isTaskOverdue() to parse ISO8601 dates from Go API - Remove duplicate date formatting functions from widget views - Switch API environment back to DEV 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -150,15 +150,32 @@ final class WidgetDataManager {
|
||||
private func isTaskOverdue(dueDate: String?, status: String?) -> Bool {
|
||||
guard let dueDateStr = dueDate else { return false }
|
||||
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "yyyy-MM-dd"
|
||||
var date: Date?
|
||||
|
||||
guard let date = formatter.date(from: dueDateStr) else { return false }
|
||||
// Try parsing as yyyy-MM-dd first
|
||||
let dateOnlyFormatter = DateFormatter()
|
||||
dateOnlyFormatter.dateFormat = "yyyy-MM-dd"
|
||||
date = dateOnlyFormatter.date(from: dueDateStr)
|
||||
|
||||
// Try parsing as ISO8601 (RFC3339) if that fails
|
||||
if date == nil {
|
||||
let isoFormatter = ISO8601DateFormatter()
|
||||
isoFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
date = isoFormatter.date(from: dueDateStr)
|
||||
|
||||
// Try without fractional seconds
|
||||
if date == nil {
|
||||
isoFormatter.formatOptions = [.withInternetDateTime]
|
||||
date = isoFormatter.date(from: dueDateStr)
|
||||
}
|
||||
}
|
||||
|
||||
guard let parsedDate = date else { return false }
|
||||
|
||||
// Task is overdue if due date is in the past and status is not completed
|
||||
let statusLower = status?.lowercased() ?? ""
|
||||
let isCompleted = statusLower == "completed" || statusLower == "done"
|
||||
|
||||
return !isCompleted && date < Calendar.current.startOfDay(for: Date())
|
||||
return !isCompleted && parsedDate < Calendar.current.startOfDay(for: Date())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user