-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use only FoundationEssentials
when possible
#81
Conversation
40c5714
to
904af3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @t089 ! To check the formatting, I usually download the script from https://github.com/swiftlang/github-workflows/blob/main/.github/workflows/scripts/check-swift-format.sh and run it locally. |
} | ||
|
||
private static func parseISO8601(dateString: String) throws -> Date { | ||
if #available(macOS 12.0, *) { | ||
return try Date(dateString, strategy: .iso8601) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I don't think this will actually compile on older swift versions on Linux where this api is not yet available in Foundation, need to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah there are a bunch of build errors with swift 5.10 on linux. will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next version will support Swift 6 and onwards, aligned on the Swift Lambda Runtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you want to fix this or not. I'm happy to merge with a Swift 6 only change. If there is an easy fix, let's be nice with our existing users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the if #available(macOS 12, *)
check was redundant as the conditional compile already excludes macOS altogether. Now it should compile for both on linux and macOS.
@t089 looks like your last commit breaks the Swift 6 unit tests |
@sebsto should be good now! got a bit confused with all the platform specific checks... |
Merged - thank you ! |
Given this is being used with more than HTTP headers I think we need to extend the number of timezone identifiers. The list is missing standard ones listed in RFC PST, EST, MST, CST (funnily RFC only lists US zones). Also does the parser deal with additional characters at the en. It is common to see email dates written as follows |
@adam-fowler these are valid concerns indeed. I created #85 to follow up |
This is fair, I was assuming this is only used with AWS APIs where UTC/GMT should suffice.
Yes I think this should be covered: func testWithLeadingDayName() throws {
let input = "Fri, 26 Jun 2020 03:04:03 -0500 (CDT)"
let date = try strategy.parse(input)
XCTAssertEqual("2020-06-26 08:04:03 +0000", date.description)
} The Tz in brackets is ignored. |
For SES you are decoding the email header which could come from any email provider. |
Linking against
Foundation
on linux adds a hefty binary size penalty. Mostly due to the ICU data fromFoundationInternationalization
. To address this we conditionally importFoundationEssentials
instead ofFoundation
if possible and replaceFoundation
-only API with a different implementation.Motivation:
Smaller binary sizes are better.
Modifications:
import Foundation
withimport FoundationEssentials
.Result:
Ability to build the package without linking
Foundation
.