Skip to content

Commit

Permalink
fix: properly parse timestamps when format override is applied to tar…
Browse files Browse the repository at this point in the history
…get shapes
  • Loading branch information
ianbotsf authored Oct 11, 2022
1 parent 0a1eeda commit 7e8a5b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .changes/cccb2f1d-b607-4b8d-9f26-5ff172fffa1d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "cccb2f1d-b607-4b8d-9f26-5ff172fffa1d",
"type": "bugfix",
"description": "Properly parse timestamps when format override is applied to target shapes",
"issues": [
"awslabs/smithy-kotlin#714"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,8 @@ open class DeserializeStructGenerator(

target.type == ShapeType.TIMESTAMP -> {
writer.addImport(RuntimeTypes.Core.Instant)
val tsFormat = shape
.getTrait(TimestampFormatTrait::class.java)
.map { it.format }
.orElse(defaultTimestampFormat)
val trait = shape.getTrait<TimestampFormatTrait>() ?: target.getTrait()
val tsFormat = trait?.format ?: defaultTimestampFormat

when (tsFormat) {
TimestampFormatTrait.Format.EPOCH_SECONDS -> "deserializeString().let { Instant.fromEpochSeconds(it) }"
Expand Down

0 comments on commit 7e8a5b1

Please sign in to comment.