-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from DarkXanteR/master
Support ISO DateTime strings in parameters
- Loading branch information
Showing
6 changed files
with
503 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/com/papsign/ktor/openapigen/parameters/util/DateTimeFormatters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.papsign.ktor.openapigen.parameters.util | ||
|
||
import java.time.format.DateTimeFormatter | ||
import java.time.format.DateTimeFormatterBuilder | ||
import java.time.temporal.ChronoField | ||
|
||
private fun baseDateTimeFormatterBuilder() = DateTimeFormatterBuilder() | ||
.appendPattern("yyyy-MM-dd['T'][ ]HH:mm[:ss]") | ||
.optionalStart() | ||
.appendFraction(ChronoField.NANO_OF_SECOND, 1, 9, true) | ||
.optionalEnd() | ||
|
||
val localDateTimeFormatter: DateTimeFormatter = baseDateTimeFormatterBuilder().toFormatter() | ||
|
||
val offsetDateTimeFormatter: DateTimeFormatter = baseDateTimeFormatterBuilder() | ||
.appendPattern("[xxx][xx][X]") | ||
.toFormatter() | ||
|
||
val zonedDateTimeFormatter: DateTimeFormatter = baseDateTimeFormatterBuilder() | ||
.appendPattern("[xxx][xx][X]") | ||
.optionalStart() | ||
.appendLiteral('[') | ||
.optionalEnd() | ||
.optionalStart() | ||
.appendZoneId() | ||
.optionalEnd() | ||
.optionalStart() | ||
.appendLiteral(']') | ||
.optionalEnd() | ||
.toFormatter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.