Extracted Instant.nowExt()

This commit is contained in:
dankito 2024-09-08 20:31:12 +02:00
parent bd18644c0d
commit 113b817627
6 changed files with 17 additions and 9 deletions

View File

@ -1,7 +1,7 @@
package net.codinux.banking.fints
import kotlinx.coroutines.delay
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDate
import net.codinux.log.logger
import net.codinux.banking.fints.messages.MessageBuilder
@ -231,7 +231,7 @@ open class FinTsJobExecutor(
}
}
val startTime = Clock.System.now()
val startTime = Instant.now()
val response = getAndHandleResponseForMessage(context, message)

View File

@ -0,0 +1,8 @@
package net.codinux.banking.fints.extensions
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
// should actually be named `now()`, but that name is already shadowed by deprecated Instant.Companion.now() method
fun Instant.Companion.nowExt(): Instant = Clock.System.now()

View File

@ -13,5 +13,5 @@ fun LocalDateTime.Companion.nowAtEuropeBerlin(): LocalDateTime {
}
fun LocalDateTime.Companion.nowAt(timeZone: TimeZone): LocalDateTime {
return Clock.System.now().toLocalDateTime(timeZone)
return Instant.nowExt().toLocalDateTime(timeZone)
}

View File

@ -1,11 +1,11 @@
package net.codinux.banking.fints.extensions
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlin.random.Random
fun randomWithSeed(): Random = Random(randomSeed())
fun randomSeed(): Long {
return Clock.System.now().nanosecondsOfSecond.toLong() + Clock.System.now().toEpochMilliseconds()
return Instant.nowExt().nanosecondsOfSecond.toLong() + Instant.nowExt().toEpochMilliseconds()
}

View File

@ -1,7 +1,7 @@
package net.codinux.banking.fints.model
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import net.codinux.banking.fints.extensions.nowExt
import net.codinux.banking.fints.log.MessageContext
import net.codinux.banking.fints.response.segments.ReceivedSegment
@ -18,7 +18,7 @@ open class MessageLogEntry(
* Is only set if [type] is set to [MessageLogEntryType.Received] and response parsing was successful.
*/
open val parsedSegments: List<ReceivedSegment> = emptyList(),
open val time: Instant = Clock.System.now()
open val time: Instant = Instant.nowExt()
) {
val messageIncludingMessageTrace: String

View File

@ -1,7 +1,7 @@
package net.codinux.banking.fints.model
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import net.codinux.banking.fints.extensions.nowExt
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium
import net.codinux.banking.fints.response.BankResponse
import net.codinux.banking.fints.response.client.FinTsClientResponse
@ -15,7 +15,7 @@ open class TanChallenge(
val tanMediaIdentifier: String?,
val bank: BankData,
val account: AccountData? = null,
val timestamp: Instant = Clock.System.now()
val timestamp: Instant = Instant.nowExt()
) {
var enterTanResult: EnterTanResult? = null