Open
Description
Description
ISO8601 standard allows representing years before 0000 or after 9999 using a "-" or "+" sign as prefix to four digits (±YYYYY). Apparently, there is no option in Swift's current ISO8601DateFormatter
that enables such formatting, which causes errors in systems where there is such an agreement with client and server to follow that standard option.
Steps to reproduce
import Foundation
let date = Date(timeIntervalSince1970: 253402300800) // January 1, 10000
let formatter = ISO8601DateFormatter()
let formattedDateString = formatter.string(from: date) // "10000-01-01T00:00:00Z"
print(formattedDateString)
Expected behavior
Expected formattedDateString
to be "+10000-01-01T00:00:00Z"
(either with the default ISO8601DateFormatter
implementation or with an option provided within the ISO8601DateFormatter.Options
and setting it on formatter instance explicitly) in order to be compliant with ISO8601.
Environment
- Swift compiler version info
- swift-driver version: 1.62.8 Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
- Target: arm64-apple-macosx12.0