Skip to content

ISO8601 DateComponents format style #1209

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

Merged
merged 2 commits into from
Apr 4, 2025

Conversation

parkera
Copy link
Contributor

@parkera parkera commented Mar 13, 2025

Add an ISO8601 components format style. See pitch thread.

Resolves:

#323
#967
#1159

@parkera parkera requested a review from iCharlesHu March 13, 2025 16:30
@parkera
Copy link
Contributor Author

parkera commented Mar 13, 2025

@swift-ci test

@parkera parkera force-pushed the parkera/iso8601_style branch from 77493e1 to 2bf9583 Compare April 2, 2025 20:24
@parkera parkera force-pushed the parkera/iso8601_style branch from 2bf9583 to 025bf8c Compare April 2, 2025 20:50
@parkera
Copy link
Contributor Author

parkera commented Apr 2, 2025

@swift-ci test

@available(FoundationPreview 6.2, *)
extension DateComponents {
/// Options for generating and parsing string representations of dates following the ISO 8601 standard.
public struct ISO8601FormatStyle : Sendable, Codable {
Copy link
Contributor

Choose a reason for hiding this comment

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

The proposal has it conform to Hashable as well. Is that missing here?


@available(FoundationPreview 6.2, *)
public extension FormatStyle where Self == DateComponents.ISO8601FormatStyle {
static var iso8601: Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

The proposal has it named iso8601Components. I think it's ok to call it iso8601 here (unlike the one below for RegexComponent, but not sure what you ended up deciding on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this one as iso8601 and made the regex one “components” (and also made that consistent with HTTP)

@parkera
Copy link
Contributor Author

parkera commented Apr 4, 2025

@swift-ci test

@parkera parkera merged commit 63cfcb9 into swiftlang:main Apr 4, 2025
3 checks passed
theMomax pushed a commit that referenced this pull request Apr 10, 2025
* ISO8601 DateComponents style

* Add Hashable to ISO8601FormatStyle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants