Repository: config4k/config4k (kotlin)

Issue:
`java.time.Duration` is not supported when toConfig
**Describe the bug**
```kotlin
import io.github.config4k.toConfig
 import java.time.Duration
 
 Duration.ofMinutes(1).toConfig("")
```
throw
```
io.github.config4k.Config4kException$UnSupportedType: type: java.time.Duration is not supported
	at io.github.config4k.ExtensionKt.toConfig(Extension.kt:90)
```
**Expected behavior**
toConfig works.

Pull request:
Fixes #100

Patch:
diff --git a/src/main/kotlin/io/github/config4k/Extension.kt b/src/main/kotlin/io/github/config4k/Extension.kt
index defe908..e882e0e 100644
--- a/src/main/kotlin/io/github/config4k/Extension.kt
+++ b/src/main/kotlin/io/github/config4k/Extension.kt
@@ -6,6 +6,7 @@ import com.typesafe.config.ConfigFactory
 import io.github.config4k.readers.SelectReader
 import java.io.File
 import java.nio.file.Path
+import java.time.Duration
 import java.util.UUID
 import kotlin.reflect.KProperty
 import kotlin.reflect.full.primaryConstructor
@@ -90,6 +91,7 @@ public fun Any.toConfig(name: String): Config {
         this is File -> mapOf(name to this.toString())
         this is Path -> mapOf(name to this.toString())
         this is UUID -> mapOf(name to this.toString())
+        this is Duration -> mapOf(name to if (this.nano == 0) "${this.seconds} s" else "${this.toNanos()} ns")
         this is Iterable<*> -> {
             val list = this.map {
                 it?.toConfigValue()?.unwrapped()


Test patch:
diff --git a/src/test/kotlin/io/github/config4k/TestArbitraryType.kt b/src/test/kotlin/io/github/config4k/TestArbitraryType.kt
index 7ee4906..f03a3aa 100644
--- a/src/test/kotlin/io/github/config4k/TestArbitraryType.kt
+++ b/src/test/kotlin/io/github/config4k/TestArbitraryType.kt
@@ -2,6 +2,7 @@ package io.github.config4k
 
 import io.kotest.core.spec.style.WordSpec
 import io.kotest.matchers.shouldBe
+import java.time.Duration
 import java.util.UUID
 
 class TestArbitraryType : WordSpec({
@@ -149,3 +150,5 @@ data class NestHyphenated(val nestedPerson: Person)
 data class NestJavaBean(val person: TestJavaBean, val person2: TestJavaBean?)
 
 data class DataWithUUID(val uuid: UUID)
+
+data class DataWithDuration(val duration: Duration)
diff --git a/src/test/kotlin/io/github/config4k/TestToConfigForArbitraryType.kt b/src/test/kotlin/io/github/config4k/TestToConfigForArbitraryType.kt
index de56432..9072ebd 100644
--- a/src/test/kotlin/io/github/config4k/TestToConfigForArbitraryType.kt
+++ b/src/test/kotlin/io/github/config4k/TestToConfigForArbitraryType.kt
@@ -2,6 +2,7 @@ package io.github.config4k
 
 import io.kotest.core.spec.style.WordSpec
 import io.kotest.matchers.shouldBe
+import java.time.Duration
 import java.util.*
 
 class TestToConfigForArbitraryType : WordSpec({
@@ -55,6 +56,18 @@ class TestToConfigForArbitraryType : WordSpec({
             config.extract<DataWithUUID>("data") shouldBe data
         }
     }
+
+    "DataWithDuration.toConfig" should {
+        "return Config having DataWithDuration" {
+            val data = DataWithDuration(Duration.ofMinutes(15))
+            val config = data.toConfig("data")
+            config.extract<DataWithDuration>("data") shouldBe data
+
+            val dataNanos = DataWithDuration(Duration.ofHours(8).plusNanos(123))
+            val configNanos = dataNanos.toConfig("data")
+            configNanos.extract<DataWithDuration>("data") shouldBe dataNanos
+        }
+    }
 })
 
 data class NullableName(val name: String?)