mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 20:06:37 +01:00
Removes the need to use kotlinx.datetime on quartz
This commit is contained in:
@@ -107,7 +107,7 @@ kotlin {
|
|||||||
implementation(libs.kotlinx.serialization.json)
|
implementation(libs.kotlinx.serialization.json)
|
||||||
|
|
||||||
// in your shared module's dependencies block
|
// in your shared module's dependencies block
|
||||||
implementation( libs.kotlinx.datetime)
|
// implementation( libs.kotlinx.datetime)
|
||||||
|
|
||||||
// immutable collections to avoid recomposition
|
// immutable collections to avoid recomposition
|
||||||
implementation(libs.kotlinx.collections.immutable)
|
implementation(libs.kotlinx.collections.immutable)
|
||||||
|
|||||||
@@ -20,12 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.quartz.nip03Timestamp.ots
|
package com.vitorpamplona.quartz.nip03Timestamp.ots
|
||||||
|
|
||||||
import kotlinx.datetime.TimeZone
|
|
||||||
import kotlinx.datetime.number
|
|
||||||
import kotlinx.datetime.toLocalDateTime
|
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.Instant
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that lets us compare, sort, store and print timestamps.
|
* Class that lets us compare, sort, store and print timestamps.
|
||||||
*/
|
*/
|
||||||
@@ -38,19 +32,12 @@ class VerifyResult(
|
|||||||
/**
|
/**
|
||||||
* Returns, if existing, a string representation describing the existence of a block attest
|
* Returns, if existing, a string representation describing the existence of a block attest
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
if (height == 0 || timestamp == null) {
|
if (height == 0 || timestamp == null) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Create an Instant from the Unix timestamp (milliseconds)
|
return "block $height attests data existed as of unix timestamp of $timestamp"
|
||||||
val instant = Instant.fromEpochMilliseconds(timestamp * 1000)
|
|
||||||
|
|
||||||
// 2. Convert the Instant to a LocalDateTime in the UTC time zone
|
|
||||||
val dateTime = instant.toLocalDateTime(TimeZone.UTC)
|
|
||||||
|
|
||||||
return "block $height attests data existed as of ${dateTime.year}-${dateTime.month.number}-${dateTime.day} UTC"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun compareTo(other: VerifyResult): Int = this.height - other.height
|
override fun compareTo(other: VerifyResult): Int = this.height - other.height
|
||||||
|
|||||||
Reference in New Issue
Block a user