Skip to content

Commit cb86fcd

Browse files
committed
add ISO_8601_FULL timestamp format for untruncated precision
1 parent 1f05008 commit cb86fcd

File tree

7 files changed

+25
-0
lines changed

7 files changed

+25
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "29e93882-7346-4a2f-bbcd-1cdf478a3b10",
3+
"type": "feature",
4+
"description": "Add new `ISO_8601_FULL` timestamp format for untruncated precision"
5+
}

runtime/runtime-core/api/runtime-core.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,7 @@ public final class aws/smithy/kotlin/runtime/time/TimestampFormat : java/lang/En
22112211
public static final field ISO_8601 Laws/smithy/kotlin/runtime/time/TimestampFormat;
22122212
public static final field ISO_8601_CONDENSED Laws/smithy/kotlin/runtime/time/TimestampFormat;
22132213
public static final field ISO_8601_CONDENSED_DATE Laws/smithy/kotlin/runtime/time/TimestampFormat;
2214+
public static final field ISO_8601_FULL Laws/smithy/kotlin/runtime/time/TimestampFormat;
22142215
public static final field RFC_5322 Laws/smithy/kotlin/runtime/time/TimestampFormat;
22152216
public static fun getEntries ()Lkotlin/enums/EnumEntries;
22162217
public static fun valueOf (Ljava/lang/String;)Laws/smithy/kotlin/runtime/time/TimestampFormat;

runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/time/TimestampFormat.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public enum class TimestampFormat {
2727
*/
2828
ISO_8601_CONDENSED_DATE,
2929

30+
/**
31+
* ISO-8601/RFC5399 timestamp including fractional seconds at arbitrary (i.e., untruncated) precision
32+
*/
33+
ISO_8601_FULL,
34+
3035
/**
3136
* RFC-5322/2822/822 IMF timestamp
3237
* See: https://tools.ietf.org/html/rfc5322

runtime/runtime-core/common/test/aws/smithy/kotlin/runtime/time/InstantTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class InstantTest {
3737
val expectedIso8601: String,
3838
val expectedIso8601Cond: String,
3939
val expectedIso8601CondDate: String,
40+
val expectedIso8601Full: String = expectedIso8601,
4041
)
4142

4243
private val iso8601Tests = listOf(
@@ -80,6 +81,16 @@ class InstantTest {
8081
Iso8601FmtTest(1604605357, 0, "2020-11-05T19:42:37Z", "20201105T194237Z", "20201105"),
8182
Iso8601FmtTest(1604558257, 0, "2020-11-05T06:37:37Z", "20201105T063737Z", "20201105"),
8283
Iso8601FmtTest(1604650057, 0, "2020-11-06T08:07:37Z", "20201106T080737Z", "20201106"),
84+
85+
// Test full-precision ISO 8601
86+
Iso8601FmtTest(
87+
1604604157,
88+
123_456_789,
89+
"2020-11-05T19:22:37.123456Z",
90+
"20201105T192237Z",
91+
"20201105",
92+
"2020-11-05T19:22:37.123456789Z",
93+
),
8394
)
8495

8596
private val iso8601Forms = mapOf(

runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/time/InstantJVM.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public actual class Instant(internal val value: jtInstant) : Comparable<Instant>
6969
TimestampFormat.ISO_8601 -> ISO_INSTANT.format(value.truncatedTo(ChronoUnit.MICROS))
7070
TimestampFormat.ISO_8601_CONDENSED -> ISO_8601_CONDENSED.format(value)
7171
TimestampFormat.ISO_8601_CONDENSED_DATE -> ISO_8601_CONDENSED_DATE.format(value)
72+
TimestampFormat.ISO_8601_FULL -> ISO_INSTANT.format(value)
7273
TimestampFormat.RFC_5322 -> RFC_5322_FIXED_DATE_TIME.format(ZonedDateTime.ofInstant(value, ZoneOffset.UTC))
7374
TimestampFormat.EPOCH_SECONDS -> {
7475
val sb = StringBuffer("$epochSeconds")

runtime/serde/common/src/aws/smithy/kotlin/runtime/serde/Parsers.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public fun String.parseBigDecimal(): Result<BigDecimal> = parse(::BigDecimal)
4343
private fun String.toTimestamp(fmt: TimestampFormat): Instant = when (fmt) {
4444
TimestampFormat.ISO_8601_CONDENSED,
4545
TimestampFormat.ISO_8601_CONDENSED_DATE,
46+
TimestampFormat.ISO_8601_FULL,
4647
TimestampFormat.ISO_8601,
4748
-> Instant.fromIso8601(this)
4849

runtime/serde/serde-json/common/src/aws/smithy/kotlin/runtime/serde/json/JsonSerializer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ public class JsonSerializer :
297297
TimestampFormat.ISO_8601,
298298
TimestampFormat.ISO_8601_CONDENSED,
299299
TimestampFormat.ISO_8601_CONDENSED_DATE,
300+
TimestampFormat.ISO_8601_FULL,
300301
TimestampFormat.RFC_5322,
301302
-> jsonWriter.writeValue(value.format(format))
302303
}

0 commit comments

Comments
 (0)