From 4d9d8d8e45a14016dc1232e81e14dcbe7c11ad07 Mon Sep 17 00:00:00 2001 From: Trey t Date: Fri, 19 Dec 2025 21:15:12 -0600 Subject: [PATCH] Fix date parsing to handle ISO datetime format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The toDate() extension was only parsing "yyyy-MM-dd" format, causing ISO datetime strings like "2025-01-02T00:00:00Z" to fail parsing and display as raw strings. Now extracts the date part before the "T" before parsing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- iosApp/iosApp/Shared/Extensions/DateExtensions.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/iosApp/iosApp/Shared/Extensions/DateExtensions.swift b/iosApp/iosApp/Shared/Extensions/DateExtensions.swift index 51a88b3..1a5bd0f 100644 --- a/iosApp/iosApp/Shared/Extensions/DateExtensions.swift +++ b/iosApp/iosApp/Shared/Extensions/DateExtensions.swift @@ -65,12 +65,14 @@ extension Date { // MARK: - String to Date Extensions extension String { - /// Converts API date string (yyyy-MM-dd) to Date + /// Converts API date string (yyyy-MM-dd or ISO datetime) to Date func toDate() -> Date? { - DateFormatters.shared.apiDate.date(from: self) + // Extract date part if it includes time (e.g., "2025-01-02T00:00:00Z" -> "2025-01-02") + let datePart = self.components(separatedBy: "T").first ?? self + return DateFormatters.shared.apiDate.date(from: datePart) } - /// Converts API date string to formatted display string + /// Converts API date string to formatted display string (e.g., "Jan 2, 2025") func toFormattedDate() -> String { guard let date = self.toDate() else { return self } return date.formatted()