Skip to content

Commit 68cf4db

Browse files
committed
Print seconds in ISO constants for time and datetime
1 parent 3a2d1ec commit 68cf4db

File tree

13 files changed

+47
-132
lines changed

13 files changed

+47
-132
lines changed

core/common/src/LocalDateTime.kt

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,35 +74,25 @@ public expect class LocalDateTime : Comparable<LocalDateTime> {
7474
/**
7575
* A collection of predefined formats for parsing and formatting [LocalDateTime] values.
7676
*
77-
* See [LocalDateTime.Formats.ISO] and [LocalDateTime.Formats.ISO_BASIC] for popular predefined formats.
78-
* [LocalDateTime.parse] and [LocalDateTime.toString] can be used as convenient shortcuts for the
79-
* [LocalDateTime.Formats.ISO] format.
77+
* [LocalDateTime.Formats.ISO] is a popular predefined format.
8078
*
8179
* If predefined formats are not sufficient, use [LocalDateTime.Format] to create a custom
8280
* [kotlinx.datetime.format.DateTimeFormat] for [LocalDateTime] values.
8381
*/
8482
public object Formats {
8583
/**
86-
* ISO 8601 extended format, which is the format used by [LocalDateTime.toString] and [LocalDateTime.parse].
84+
* ISO 8601 extended format.
8785
*
8886
* Examples of date/time in ISO 8601 format:
8987
* - `2020-08-30T18:43`
9088
* - `+12020-08-30T18:43:00`
9189
* - `0000-08-30T18:43:00.500`
9290
* - `-0001-08-30T18:43:00.123456789`
93-
*/
94-
public val ISO: DateTimeFormat<LocalDateTime>
95-
96-
/**
97-
* ISO 8601 basic format.
9891
*
99-
* Examples of date/time in ISO 8601 basic format:
100-
* - `20200830T1843`
101-
* - `+120200830T184300`
102-
* - `00000830T184300.500`
103-
* - `-00010830T184300.123456789`
92+
* When formatting, seconds are always included, even if they are zero.
93+
* Fractional parts of the second are included if non-zero.
10494
*/
105-
public val ISO_BASIC: DateTimeFormat<LocalDateTime>
95+
public val ISO: DateTimeFormat<LocalDateTime>
10696
}
10797

10898
/**

core/common/src/LocalTime.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,21 @@ public expect class LocalTime : Comparable<LocalTime> {
114114
/**
115115
* A collection of predefined formats for parsing and formatting [LocalDateTime] values.
116116
*
117-
* See [LocalTime.Formats.ISO] and [LocalTime.Formats.ISO_BASIC] for popular predefined formats.
118-
* [LocalTime.parse] and [LocalTime.toString] can be used as convenient shortcuts for the
119-
* [LocalTime.Formats.ISO] format.
117+
* [LocalTime.Formats.ISO] is a popular predefined format.
120118
*
121119
* If predefined formats are not sufficient, use [LocalTime.Format] to create a custom
122120
* [kotlinx.datetime.format.DateTimeFormat] for [LocalTime] values.
123121
*/
124122
public object Formats {
125123
/**
126-
* ISO 8601 extended format, used by [LocalTime.toString] and [LocalTime.parse].
124+
* ISO 8601 extended format.
127125
*
128126
* Examples: `12:34`, `12:34:56`, `12:34:56.789`.
129-
*/
130-
public val ISO: DateTimeFormat<LocalTime>
131-
132-
/**
133-
* ISO 8601 basic format.
134127
*
135-
* Examples: `T1234`, `T123456`, `T123456.789`.
128+
* When formatting, seconds are always included, even if they are zero.
129+
* Fractional parts of the second are included if non-zero.
136130
*/
137-
public val ISO_BASIC: DateTimeFormat<LocalTime>
131+
public val ISO: DateTimeFormat<LocalTime>
138132
}
139133

140134
/**

core/common/src/format/DateTimeFormat.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,18 @@ internal sealed class AbstractDateTimeFormat<T, U : Copyable<U>> : DateTimeForma
137137
@SharedImmutable
138138
private val allFormatConstants: List<Pair<String, StringFormat<*>>> = run {
139139
fun unwrap(format: DateTimeFormat<*>): StringFormat<*> = (format as AbstractDateTimeFormat<*, *>).actualFormat
140+
// the formats are ordered vaguely by decreasing length, as the topmost among suitable ones is chosen.
140141
listOf(
142+
"${DateTimeFormatBuilder.WithDateTimeComponents::appendDateTimeComponents.name}(DateTimeComponents.Formats.RFC_1123)" to
143+
unwrap(DateTimeComponents.Formats.RFC_1123),
144+
"${DateTimeFormatBuilder.WithDateTimeComponents::appendDateTimeComponents.name}(DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET)" to
145+
unwrap(DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET),
146+
"${DateTimeFormatBuilder.WithDateTime::appendDate.name}(LocalDateTime.Formats.ISO)" to unwrap(LocalDateTime.Formats.ISO),
141147
"${DateTimeFormatBuilder.WithDate::appendDate.name}(LocalDate.Formats.ISO)" to unwrap(LocalDate.Formats.ISO),
142148
"${DateTimeFormatBuilder.WithDate::appendDate.name}(LocalDate.Formats.ISO_BASIC)" to unwrap(LocalDate.Formats.ISO_BASIC),
143149
"${DateTimeFormatBuilder.WithTime::appendTime.name}(LocalTime.Formats.ISO)" to unwrap(LocalTime.Formats.ISO),
144-
"${DateTimeFormatBuilder.WithTime::appendTime.name}(LocalTime.Formats.ISO_BASIC)" to unwrap(LocalTime.Formats.ISO_BASIC),
145150
"${DateTimeFormatBuilder.WithUtcOffset::appendOffset.name}(UtcOffset.Formats.ISO)" to unwrap(UtcOffset.Formats.ISO),
146151
"${DateTimeFormatBuilder.WithUtcOffset::appendOffset.name}(UtcOffset.Formats.ISO_BASIC)" to unwrap(UtcOffset.Formats.ISO_BASIC),
147152
"${DateTimeFormatBuilder.WithUtcOffset::appendOffset.name}(UtcOffset.Formats.FOUR_DIGITS)" to unwrap(UtcOffset.Formats.FOUR_DIGITS),
148-
"${DateTimeFormatBuilder.WithDateTimeComponents::appendDateTimeComponents.name}(DateTimeComponents.Formats.RFC_1123)" to
149-
unwrap(DateTimeComponents.Formats.RFC_1123),
150-
"${DateTimeFormatBuilder.WithDateTimeComponents::appendDateTimeComponents.name}(DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET)" to
151-
unwrap(DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET),
152153
)
153154
}

core/common/src/format/LocalDateTimeFormat.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ internal val ISO_DATETIME by lazy {
105105
}
106106

107107
@SharedImmutable
108-
internal val ISO_DATETIME_BASIC by lazy {
108+
internal val ISO_DATETIME_OPTIONAL_SECONDS by lazy {
109109
LocalDateTimeFormat.build {
110-
appendDate(ISO_DATE_BASIC)
111-
appendTime(ISO_TIME_BASIC)
110+
appendDate(ISO_DATE)
111+
alternativeParsing({ char('t') }) { char('T') }
112+
appendTime(ISO_TIME_OPTIONAL_SECONDS)
112113
}
113114
}

core/common/src/format/LocalTimeFormat.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ internal val ISO_TIME by lazy {
235235
appendHour()
236236
char(':')
237237
appendMinute()
238-
optional {
238+
alternativeParsing({
239+
// intentionally empty
240+
}) {
239241
char(':')
240242
appendSecond()
241243
optional {
@@ -245,12 +247,15 @@ internal val ISO_TIME by lazy {
245247
}
246248
}
247249
}
250+
248251
@SharedImmutable
249-
internal val ISO_TIME_BASIC by lazy {
252+
internal val ISO_TIME_OPTIONAL_SECONDS by lazy {
250253
LocalTimeFormat.build {
251-
alternativeParsing({ char('t') }) { char('T') }
252-
appendHour(); appendMinute()
254+
appendHour()
255+
char(':')
256+
appendMinute()
253257
optional {
258+
char(':')
254259
appendSecond()
255260
optional {
256261
char('.')

core/common/test/format/LocalDateTimeFormatTest.kt

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,16 @@ class LocalDateTimeFormatTest {
194194
@Test
195195
fun testIso() {
196196
val dateTimes = buildMap<LocalDateTime, Pair<String, Set<String>>> {
197-
put(LocalDateTime(2008, 7, 5, 0, 0, 0, 0), ("2008-07-05T00:00" to setOf("2008-07-05T00:00:00")))
198-
put(LocalDateTime(2007, 12, 31, 1, 0, 0, 0), ("2007-12-31T01:00" to setOf("2007-12-31t01:00")))
199-
put(LocalDateTime(999, 11, 30, 23, 0, 0, 0), ("0999-11-30T23:00" to setOf()))
200-
put(LocalDateTime(-1, 1, 2, 0, 1, 0, 0), ("-0001-01-02T00:01" to setOf()))
201-
put(LocalDateTime(9999, 10, 31, 12, 30, 0, 0), ("9999-10-31T12:30" to setOf()))
202-
put(LocalDateTime(-9999, 9, 30, 23, 59, 0, 0), ("-9999-09-30T23:59" to setOf()))
197+
put(LocalDateTime(2008, 7, 5, 0, 0, 0, 0), ("2008-07-05T00:00:00" to setOf("2008-07-05T00:00")))
198+
put(LocalDateTime(2007, 12, 31, 1, 0, 0, 0), ("2007-12-31T01:00:00" to setOf("2007-12-31t01:00")))
199+
put(LocalDateTime(999, 11, 30, 23, 0, 0, 0), ("0999-11-30T23:00:00" to setOf()))
200+
put(LocalDateTime(-1, 1, 2, 0, 1, 0, 0), ("-0001-01-02T00:01:00" to setOf()))
201+
put(LocalDateTime(9999, 10, 31, 12, 30, 0, 0), ("9999-10-31T12:30:00" to setOf()))
202+
put(LocalDateTime(-9999, 9, 30, 23, 59, 0, 0), ("-9999-09-30T23:59:00" to setOf()))
203203
put(LocalDateTime(10000, 8, 1, 0, 0, 1, 0), ("+10000-08-01T00:00:01" to setOf()))
204204
put(LocalDateTime(-10000, 7, 1, 0, 0, 59, 0), ("-10000-07-01T00:00:59" to setOf()))
205-
put(LocalDateTime(123456, 6, 1, 13, 44, 0, 0), ("+123456-06-01T13:44" to setOf()))
206-
put(LocalDateTime(-123456, 5, 1, 13, 44, 0, 0), ("-123456-05-01T13:44" to setOf()))
205+
put(LocalDateTime(123456, 6, 1, 13, 44, 0, 0), ("+123456-06-01T13:44:00" to setOf()))
206+
put(LocalDateTime(-123456, 5, 1, 13, 44, 0, 0), ("-123456-05-01T13:44:00" to setOf()))
207207
put(LocalDateTime(123456, 6, 1, 0, 0, 0, 100000000), ("+123456-06-01T00:00:00.100" to setOf("+123456-06-01T00:00:00.10", "+123456-06-01T00:00:00.1")))
208208
put(LocalDateTime(-123456, 5, 1, 0, 0, 0, 10000000), ("-123456-05-01T00:00:00.010" to setOf()))
209209
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 1000000), ("2022-01-02T00:00:00.001" to setOf()))
@@ -226,41 +226,6 @@ class LocalDateTimeFormatTest {
226226
test(dateTimes, LocalDateTime.Formats.ISO)
227227
}
228228

229-
@Test
230-
fun testBasicIso() {
231-
val dateTimes = buildMap<LocalDateTime, Pair<String, Set<String>>> {
232-
put(LocalDateTime(2008, 7, 5, 0, 0, 0, 0), ("20080705T0000" to setOf("20080705T000000")))
233-
put(LocalDateTime(2007, 12, 31, 1, 0, 0, 0), ("20071231T0100" to setOf("20071231t0100")))
234-
put(LocalDateTime(999, 11, 30, 23, 0, 0, 0), ("09991130T2300" to setOf()))
235-
put(LocalDateTime(-1, 1, 2, 0, 1, 0, 0), ("-00010102T0001" to setOf()))
236-
put(LocalDateTime(9999, 10, 31, 12, 30, 0, 0), ("99991031T1230" to setOf()))
237-
put(LocalDateTime(-9999, 9, 30, 23, 59, 0, 0), ("-99990930T2359" to setOf()))
238-
put(LocalDateTime(10000, 8, 1, 0, 0, 1, 0), ("+100000801T000001" to setOf()))
239-
put(LocalDateTime(-10000, 7, 1, 0, 0, 59, 0), ("-100000701T000059" to setOf()))
240-
put(LocalDateTime(123456, 6, 1, 13, 44, 0, 0), ("+1234560601T1344" to setOf()))
241-
put(LocalDateTime(-123456, 5, 1, 13, 44, 0, 0), ("-1234560501T1344" to setOf()))
242-
put(LocalDateTime(123456, 6, 1, 0, 0, 0, 100000000), ("+1234560601T000000.100" to setOf("+1234560601T000000.10", "+1234560601T000000.1")))
243-
put(LocalDateTime(-123456, 5, 1, 0, 0, 0, 10000000), ("-1234560501T000000.010" to setOf()))
244-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 1000000), ("20220102T000000.001" to setOf()))
245-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 100000), ("20220102T000000.000100" to setOf()))
246-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 10000), ("20220102T000000.000010" to setOf()))
247-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 1000), ("20220102T000000.000001" to setOf()))
248-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 100), ("20220102T000000.000000100" to setOf()))
249-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 10), ("20220102T000000.000000010" to setOf()))
250-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 1), ("20220102T000000.000000001" to setOf()))
251-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 999999999), ("20220102T000000.999999999" to setOf()))
252-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 99999999), ("20220102T000000.099999999" to setOf()))
253-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 9999999), ("20220102T000000.009999999" to setOf()))
254-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 999999), ("20220102T000000.000999999" to setOf()))
255-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 99999), ("20220102T000000.000099999" to setOf()))
256-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 9999), ("20220102T000000.000009999" to setOf()))
257-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 999), ("20220102T000000.000000999" to setOf()))
258-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 99), ("20220102T000000.000000099" to setOf()))
259-
put(LocalDateTime(2022, 1, 2, 0, 0, 0, 9), ("20220102T000000.000000009" to setOf()))
260-
}
261-
test(dateTimes, LocalDateTime.Formats.ISO_BASIC)
262-
}
263-
264229
@Test
265230
fun testDoc() {
266231
val dateTime = LocalDateTime(2020, 8, 30, 18, 43, 13, 0)

core/common/test/format/LocalTimeFormatTest.kt

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ class LocalTimeFormatTest {
8989
@Test
9090
fun testIso() {
9191
val times = buildMap<LocalTime, Pair<String, Set<String>>> {
92-
put(LocalTime(0, 0, 0, 0), ("00:00" to setOf("00:00:00")))
93-
put(LocalTime(1, 0, 0, 0), ("01:00" to setOf()))
94-
put(LocalTime(23, 0, 0, 0), ("23:00" to setOf()))
95-
put(LocalTime(0, 1, 0, 0), ("00:01" to setOf()))
96-
put(LocalTime(12, 30, 0, 0), ("12:30" to setOf()))
97-
put(LocalTime(23, 59, 0, 0), ("23:59" to setOf()))
92+
put(LocalTime(0, 0, 0, 0), ("00:00:00" to setOf("00:00")))
93+
put(LocalTime(1, 0, 0, 0), ("01:00:00" to setOf("01:00")))
94+
put(LocalTime(23, 0, 0, 0), ("23:00:00" to setOf("23:00")))
95+
put(LocalTime(0, 1, 0, 0), ("00:01:00" to setOf("00:01")))
96+
put(LocalTime(12, 30, 0, 0), ("12:30:00" to setOf("12:30")))
97+
put(LocalTime(23, 59, 0, 0), ("23:59:00" to setOf("23:59")))
9898
put(LocalTime(0, 0, 1, 0), ("00:00:01" to setOf()))
9999
put(LocalTime(0, 0, 59, 0), ("00:00:59" to setOf()))
100100
put(LocalTime(0, 0, 0, 100000000), ("00:00:00.100" to setOf("00:00:00.1")))
@@ -119,39 +119,6 @@ class LocalTimeFormatTest {
119119
test(times, LocalTime.Formats.ISO)
120120
}
121121

122-
@Test
123-
fun testBasicIso() {
124-
val times = buildMap<LocalTime, Pair<String, Set<String>>> {
125-
put(LocalTime(0, 0, 0, 0), ("T0000" to setOf("T000000", "T0000", "t0000")))
126-
put(LocalTime(1, 0, 0, 0), ("T0100" to setOf()))
127-
put(LocalTime(23, 0, 0, 0), ("T2300" to setOf()))
128-
put(LocalTime(0, 1, 0, 0), ("T0001" to setOf()))
129-
put(LocalTime(12, 30, 0, 0), ("T1230" to setOf()))
130-
put(LocalTime(23, 59, 0, 0), ("T2359" to setOf()))
131-
put(LocalTime(0, 0, 1, 0), ("T000001" to setOf()))
132-
put(LocalTime(0, 0, 59, 0), ("T000059" to setOf()))
133-
put(LocalTime(0, 0, 0, 100000000), ("T000000.100" to setOf("T000000.1")))
134-
put(LocalTime(0, 0, 0, 10000000), ("T000000.010" to setOf("T000000.01")))
135-
put(LocalTime(0, 0, 0, 1000000), ("T000000.001" to setOf()))
136-
put(LocalTime(0, 0, 0, 100000), ("T000000.000100" to setOf("T000000.0001")))
137-
put(LocalTime(0, 0, 0, 10000), ("T000000.000010" to setOf()))
138-
put(LocalTime(0, 0, 0, 1000), ("T000000.000001" to setOf()))
139-
put(LocalTime(0, 0, 0, 100), ("T000000.000000100" to setOf()))
140-
put(LocalTime(0, 0, 0, 10), ("T000000.000000010" to setOf()))
141-
put(LocalTime(0, 0, 0, 1), ("T000000.000000001" to setOf()))
142-
put(LocalTime(0, 0, 0, 999999999), ("T000000.999999999" to setOf()))
143-
put(LocalTime(0, 0, 0, 99999999), ("T000000.099999999" to setOf()))
144-
put(LocalTime(0, 0, 0, 9999999), ("T000000.009999999" to setOf()))
145-
put(LocalTime(0, 0, 0, 999999), ("T000000.000999999" to setOf()))
146-
put(LocalTime(0, 0, 0, 99999), ("T000000.000099999" to setOf()))
147-
put(LocalTime(0, 0, 0, 9999), ("T000000.000009999" to setOf()))
148-
put(LocalTime(0, 0, 0, 999), ("T000000.000000999" to setOf()))
149-
put(LocalTime(0, 0, 0, 99), ("T000000.000000099" to setOf()))
150-
put(LocalTime(0, 0, 0, 9), ("T000000.000000009" to setOf()))
151-
}
152-
test(times, LocalTime.Formats.ISO_BASIC)
153-
}
154-
155122
@Test
156123
fun testFormattingSecondFractions() {
157124
fun check(nanoseconds: Int, minLength: Int?, maxLength: Int?, string: String) {

core/js/src/LocalDateTime.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package kotlinx.datetime
66

77
import kotlinx.datetime.format.*
88
import kotlinx.datetime.format.ISO_DATETIME
9-
import kotlinx.datetime.format.ISO_DATETIME_BASIC
109
import kotlinx.datetime.format.LocalDateTimeFormat
1110
import kotlinx.datetime.serializers.LocalDateTimeIso8601Serializer
1211
import kotlinx.serialization.Serializable
@@ -72,7 +71,6 @@ public actual class LocalDateTime internal constructor(internal val value: jtLoc
7271

7372
public actual object Formats {
7473
public actual val ISO: DateTimeFormat<LocalDateTime> = ISO_DATETIME
75-
public actual val ISO_BASIC: DateTimeFormat<LocalDateTime> = ISO_DATETIME_BASIC
7674
}
7775

7876
}

core/js/src/LocalTime.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package kotlinx.datetime
66

77
import kotlinx.datetime.format.*
88
import kotlinx.datetime.format.ISO_TIME
9-
import kotlinx.datetime.format.ISO_TIME_BASIC
109
import kotlinx.datetime.format.LocalTimeFormat
1110
import kotlinx.datetime.internal.*
1211
import kotlinx.datetime.serializers.LocalTimeIso8601Serializer
@@ -81,6 +80,5 @@ public actual class LocalTime internal constructor(internal val value: jtLocalTi
8180

8281
public actual object Formats {
8382
public actual val ISO: DateTimeFormat<LocalTime> get() = ISO_TIME
84-
public actual val ISO_BASIC: DateTimeFormat<LocalTime> get() = ISO_TIME_BASIC
8583
}
8684
}

core/jvm/src/LocalDateTime.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public actual class LocalDateTime internal constructor(internal val value: jtLoc
7373

7474
public actual object Formats {
7575
public actual val ISO: DateTimeFormat<LocalDateTime> = ISO_DATETIME
76-
public actual val ISO_BASIC: DateTimeFormat<LocalDateTime> = ISO_DATETIME_BASIC
7776
}
7877

7978
}

core/jvm/src/LocalTime.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public actual class LocalTime internal constructor(internal val value: jtLocalTi
7979

8080
public actual object Formats {
8181
public actual val ISO: DateTimeFormat<LocalTime> get() = ISO_TIME
82-
public actual val ISO_BASIC: DateTimeFormat<LocalTime> get() = ISO_TIME_BASIC
8382

8483
}
8584
}

core/native/src/LocalDateTime.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import kotlinx.serialization.*
1717
public actual class LocalDateTime
1818
public actual constructor(public actual val date: LocalDate, public actual val time: LocalTime) : Comparable<LocalDateTime> {
1919
public actual companion object {
20-
public actual fun parse(isoString: String): LocalDateTime = parse(isoString, Formats.ISO)
20+
public actual fun parse(isoString: String): LocalDateTime = parse(isoString, ISO_DATETIME_OPTIONAL_SECONDS)
2121

2222
internal actual val MIN: LocalDateTime = LocalDateTime(LocalDate.MIN, LocalTime.MIN)
2323
internal actual val MAX: LocalDateTime = LocalDateTime(LocalDate.MAX, LocalTime.MAX)
@@ -29,7 +29,6 @@ public actual constructor(public actual val date: LocalDate, public actual val t
2929

3030
public actual object Formats {
3131
public actual val ISO: DateTimeFormat<LocalDateTime> = ISO_DATETIME
32-
public actual val ISO_BASIC: DateTimeFormat<LocalDateTime> = ISO_DATETIME_BASIC
3332
}
3433

3534
public actual constructor(year: Int, monthNumber: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanosecond: Int) :
@@ -67,7 +66,7 @@ public actual constructor(public actual val date: LocalDate, public actual val t
6766
}
6867

6968
// org.threeten.bp.LocalDateTime#toString
70-
actual override fun toString(): String = format(Formats.ISO)
69+
actual override fun toString(): String = format(ISO_DATETIME_OPTIONAL_SECONDS)
7170

7271
// org.threeten.bp.chrono.ChronoLocalDateTime#toEpochSecond
7372
internal fun toEpochSecond(offset: UtcOffset): Long {

core/native/src/LocalTime.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public actual class LocalTime actual constructor(
3333
}
3434

3535
public actual companion object {
36-
public actual fun parse(isoString: String): LocalTime = parse(isoString, Formats.ISO)
36+
public actual fun parse(isoString: String): LocalTime = parse(isoString, ISO_TIME_OPTIONAL_SECONDS)
3737

3838
public actual fun fromSecondOfDay(secondOfDay: Int): LocalTime =
3939
ofSecondOfDay(secondOfDay, 0)
@@ -82,7 +82,6 @@ public actual class LocalTime actual constructor(
8282

8383
public actual object Formats {
8484
public actual val ISO: DateTimeFormat<LocalTime> get() = ISO_TIME
85-
public actual val ISO_BASIC: DateTimeFormat<LocalTime> get() = ISO_TIME_BASIC
8685
}
8786

8887
// Several times faster than using `compareBy`
@@ -127,7 +126,7 @@ public actual class LocalTime actual constructor(
127126
return total
128127
}
129128

130-
actual override fun toString(): String = format(Formats.ISO)
129+
actual override fun toString(): String = format(ISO_TIME_OPTIONAL_SECONDS)
131130

132131
override fun equals(other: Any?): Boolean =
133132
other is LocalTime && this.compareTo(other) == 0

0 commit comments

Comments
 (0)