Skip to content
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

URL-encode dates using unix timestamp #2276

Conversation

thecheatah
Copy link
Contributor

@thecheatah thecheatah commented Mar 30, 2020

Changes default Date url-encoding to use unix timestamps instead of Apple-specific reference (#2276).

…g a `custom` DateFormat for `URLEncodedFormEncoder` or `URLEncodedFormDecoder`
…ustom(_:)` and `JSONEncoder.DateEncodingStrategy.custom(_:)` interfaces
…ttps://bugs.swift.org/browse/SR-7745?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

I tried running the sample program with `10000000` iterations in the `vapor/swift:5.2` docker image without any issue.
@tanner0101 tanner0101 added the bug Something isn't working label Mar 30, 2020
@tanner0101 tanner0101 added this to Awaiting Review in Vapor 4 via automation Mar 30, 2020
Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

Sources/Vapor/URLEncodedForm/URLEncodedFormDecoder.swift Outdated Show resolved Hide resolved
@tanner0101 tanner0101 moved this from Awaiting Review to Awaiting Updates in Vapor 4 Mar 30, 2020
@tanner0101 tanner0101 added the semver-patch Internal changes only label Mar 30, 2020
@tanner0101 tanner0101 changed the title Bug/default date encoding for urlencodedform to unix timestamp URL-encoded dates using unix timestamp Mar 30, 2020
@tanner0101 tanner0101 changed the title URL-encoded dates using unix timestamp URL-encode dates using unix timestamp Mar 30, 2020
@tanner0101 tanner0101 merged commit ad2aecc into vapor:master Mar 30, 2020
Vapor 4 automation moved this from Awaiting Updates to Done Mar 30, 2020
@tanner0101
Copy link
Member

These changes are now available in 4.0.0-rc.3.12

@thecheatah thecheatah deleted the bug/default-date-encoding-for-urlencodedform-to-unix-timestamp branch March 30, 2020 18:15
pull bot pushed a commit to scope-demo/vapor that referenced this pull request Mar 30, 2020
* Added ability to configure date coding/decoding for UrlEncodedForm

* Added documentation to the `DateFormat` enum

* renamed internetDateTime to iso8601

* Added custom date formatter

* Added comment about `ISO8601DateFormatter` performance

* Added ISO8601DateFormatter.threadSpecific so a new ISO8601DateFormatter isn't created for every encode/decode.

* Use typealias instead of declaring DateFormat 2x

* Added `ThreadSpecificDateFormatter` to ensure thread safety when using a `custom` DateFormat for `URLEncodedFormEncoder` or `URLEncodedFormDecoder`

* Fixed comment

* Changed custom interface to mimic `JSONDecoder.DateDecodingStrategy.custom(_:)` and `JSONEncoder.DateEncodingStrategy.custom(_:)` interfaces

* Removed unused ThreadSpecificDateFormatter

* `ISO8601DateFormatter` seems to be thread safe. This bug was filed: https://bugs.swift.org/browse/SR-7745?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
I tried running the sample program with `10000000` iterations in the `vapor/swift:5.2` docker image without any issue.

* Default the date format for URLEncodedFrom coding/decoding to `timeIntervalSinceReferenceDate`

* Default to `timeIntervalSince1970`

* Removed all references to customizing DateFormat and default to `timeIntervalSince1970`

* Removed reference to `import NIO` and fixed spacing

* Fixed spacing

* Implemented using `extension Date: URLQueryFragmentConvertible`

* Spacing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semver-patch Internal changes only
Projects
Vapor 4
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants