Skip to content

ISO8601DateFormatter -> Date.ISO8601FormatStyle #9

Description

@zunda-pixel

Motivation

This package supports Codable date handling using ISO 8601 strings. Since the package targets cross-platform Swift, the implementation should fit well with Swift 6 strict concurrency and modern Foundation APIs.

ISO8601DateFormatter is a mutable reference type. It is commonly used as a cached shared formatter, but that pattern is awkward in Swift 6 concurrency because it can introduce Sendable issues or require unsafe workarounds.

Date.ISO8601FormatStyle is the newer value-style API for ISO 8601 formatting and parsing. Using it would make the implementation easier to reason about, more concurrency-friendly, and better aligned with modern Swift.

Proposed change

Replace internal uses of ISO8601DateFormatter with Date.ISO8601FormatStyle where possible, while preserving the current encoded date representation.

Important compatibility points:

  • preserve UTC / Z behavior
  • preserve fractional seconds behavior
  • keep existing Codable round-trip behavior
  • add tests for representative date encoding/decoding cases

Expected benefit

  • Better Swift 6 strict concurrency compatibility
  • Less reliance on shared mutable formatter state
  • Fewer unsafe Sendable workarounds
  • More modern Foundation API usage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions