OpenAPITools / OpenAPITools/openapi-generator
[REQ] OpenISO8601DateFormatter date without zone
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
OpenISO8601DateFormatter supports a full ISO8601 format, date without time and without milliseconds. In case of responses that are not specifying Z, the formatter fails with an error Date string does not match format expected by formatter.
Describe the solution you'd like
Add an additional fallback with next method
static let withoutZone: DateFormatter = {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
return formatter
}()
then override override public func date(from string: String) -> Date? method with
override public func date(from string: String) -> Date? {
if let result = super.date(from: string) {
return result
} else if let result = OpenISO8601DateFormatter.withoutSeconds.date(from: string) {
return result
} else if let result = OpenISO8601DateFormatter.withoutZone.date(from: string) {
return result
}
return OpenISO8601DateFormatter.withoutTime.date(from: string)
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating OpenISO8601DateFormatter and its date(from:) implementation in the Swift client code. Compare the existing formatter fallbacks with the requested withoutZone format, then verify that ISO 8601 date-time strings without a zone are accepted without breaking the existing formats.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100