Dont use kotlinx datetime

This commit is contained in:
2025-08-01 12:49:55 +08:00
parent 4c97d691fc
commit 638fc5e71e
5 changed files with 7 additions and 10 deletions

View File

@@ -12,7 +12,6 @@ repositories {
dependencies {
implementation(libs.kotlinx.coroutines)
implementation(libs.kotlinx.datetime)
implementation(libs.ktor.serialization.json)
implementation(libs.ktor.server.data.conversion)
implementation(libs.mongodb.bson)

View File

@@ -1,7 +1,8 @@
package ai.neuon.utility.json
import kotlinx.datetime.Instant
import kotlinx.serialization.json.*
import kotlin.time.ExperimentalTime
import kotlin.time.Instant
/**
@@ -113,6 +114,7 @@ fun JsonElement.asBooleanOrNull(): Boolean? {
/**
* @throws IllegalArgumentException if the current element is not a valid ISO 8601 [String]
*/
@OptIn(ExperimentalTime::class)
fun JsonElement.asInstant(): Instant {
val value = try {
asString()
@@ -125,6 +127,7 @@ fun JsonElement.asInstant(): Instant {
/**
* @return null if the current element is not a valid ISO 8601 [String]
*/
@OptIn(ExperimentalTime::class)
fun JsonElement.asInstantOrNull(): Instant? {
return try {
asInstant()