File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api
tests/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import kotlin.reflect.KType
41
41
import kotlin.reflect.full.withNullability
42
42
import kotlin.reflect.jvm.jvmErasure
43
43
import kotlin.reflect.typeOf
44
+ import kotlin.time.Duration
44
45
45
46
internal interface StringParser <T > {
46
47
fun toConverter (options : ParserOptions ? ): TypeConverter
@@ -203,6 +204,9 @@ internal object Parsers : GlobalParserOptions {
203
204
parser
204
205
},
205
206
207
+ // kotlin.time.duration
208
+ stringParser { catchSilent { Duration .parse(it) } },
209
+
206
210
stringParserWithOptions { options ->
207
211
val formatter = options?.getDateTimeFormatter()
208
212
val parser = { it: String -> it.toLocalTimeOrNull(formatter) }
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ import org.junit.Test
13
13
import java.time.LocalTime
14
14
import java.time.Month
15
15
import kotlin.reflect.typeOf
16
+ import kotlin.time.Duration.Companion.days
17
+ import kotlin.time.Duration.Companion.hours
18
+ import kotlin.time.Duration.Companion.minutes
19
+ import kotlin.time.Duration.Companion.seconds
16
20
17
21
class ParseTests {
18
22
@@ -189,4 +193,9 @@ class ParseTests {
189
193
190
194
columnOf(" 2022-01-23T04:29:40" ).parse().type shouldBe typeOf<LocalDateTime >()
191
195
}
196
+
197
+ @Test
198
+ fun `parse duration` () {
199
+ columnOf(" 1d 15m" , " 20h 35m 11s" ).parse() shouldBe columnOf(1 .days + 15 .minutes, 20 .hours + 35 .minutes + 11 .seconds)
200
+ }
192
201
}
You can’t perform that action at this time.
0 commit comments