Skip to content

Commit

Permalink
small fix for some iso dates
Browse files Browse the repository at this point in the history
  • Loading branch information
proggeramlug committed Oct 18, 2023
1 parent 1ff37f9 commit dfed086
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
Binary file not shown.
3 changes: 2 additions & 1 deletion Sources/String+SwiftyDates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ extension String {
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(".")) {
} else if cleanString.contains(" ") && (cleanString.contains(":") || cleanString.contains("am") || cleanString.contains("pm")) && (cleanString.contains("/") || cleanString.contains("-") || cleanString.contains("+") || cleanString.contains(".")) {

if cleanString.split(separator: " ").count > 1 {
// we likely have Fri, 15 Jan 2021 13:22:00 -0500 date
var cleanString_ = cleanString.lowercased()
Expand Down
1 change: 1 addition & 0 deletions SwiftyDatesTests/SwiftyDatesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SwiftyDatesTests: XCTestCase {
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"))
self.iso8601TestCases.append(TestCase("Wed, 18 Oct 2023 11:56:11 +0200", "10/18/2023 09:56:11"))

// Text dates
self.datetimeTestCases.append(TestCase("Fri, 15 Jan 2021 13:22:00 -0500", "01/15/2021 08:22:00"))
Expand Down

0 comments on commit dfed086

Please sign in to comment.