diff --git a/.swiftpm/xcode/package.xcworkspace/xcuserdata/amlug.xcuserdatad/UserInterfaceState.xcuserstate b/.swiftpm/xcode/package.xcworkspace/xcuserdata/amlug.xcuserdatad/UserInterfaceState.xcuserstate index 934ab98..f36fb91 100644 Binary files a/.swiftpm/xcode/package.xcworkspace/xcuserdata/amlug.xcuserdatad/UserInterfaceState.xcuserstate and b/.swiftpm/xcode/package.xcworkspace/xcuserdata/amlug.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Sources/String+SwiftyDates.swift b/Sources/String+SwiftyDates.swift index 3b5d5f8..5ce5e95 100644 --- a/Sources/String+SwiftyDates.swift +++ b/Sources/String+SwiftyDates.swift @@ -163,8 +163,14 @@ extension String { let cleanString = replacingOccurrences(of: " am", with: "am").replacingOccurrences(of: " pm", with: "pm") // check for iso 8601 (yyyy-MM-ddTHH:mm:ss.SSZ) - if cleanString.contains("T") { - let parts: [String] = split(separator: "T").map(String.init) + var isIso8601 = false + let parts: [String] = split(separator: "T").map(String.init) + + if cleanString.contains("T"), parts.count == 2 { + isIso8601 = true + } + + if isIso8601 { date = parts[0].swiftyDate(calendar: calendar) time = parts[1].swiftyTime() } else if cleanString.contains(" ") && (cleanString.contains(":") || cleanString.contains("am") || cleanString.contains("pm")) && (cleanString.contains("/") || cleanString.contains("-") || cleanString.contains(".")) { diff --git a/SwiftyDatesTests/SwiftyDatesTests.swift b/SwiftyDatesTests/SwiftyDatesTests.swift index 2bd31b9..d7b059a 100644 --- a/SwiftyDatesTests/SwiftyDatesTests.swift +++ b/SwiftyDatesTests/SwiftyDatesTests.swift @@ -53,6 +53,7 @@ class SwiftyDatesTests: XCTestCase { self.iso8601TestCases.append(TestCase("2001-02-03T04:05:06.007+06:30", "02/02/2001 21:35:06")) self.iso8601TestCases.append(TestCase("2001-02-03T04:05:06.007-06:30", "02/03/2001 10:35:06")) self.iso8601TestCases.append(TestCase("2020-01-16T08:34:00Z", "01/16/2020 08:34:00")) + self.iso8601TestCases.append(TestCase("Tue, 17 Oct 2023 21:46:34 -0400", "10/17/2023 17:46:34")) // Text dates self.datetimeTestCases.append(TestCase("Fri, 15 Jan 2021 13:22:00 -0500", "01/15/2021 08:22:00"))