[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: nexus fetch: adapt time parser to camt
From: |
gnunet |
Subject: |
[libeufin] branch master updated: nexus fetch: adapt time parser to camt.054 |
Date: |
Wed, 15 Nov 2023 15:12:50 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new d1aa17de nexus fetch: adapt time parser to camt.054
d1aa17de is described below
commit d1aa17de9a16bd4dbf24ba4e946203e1db5c243f
Author: MS <ms@taler.net>
AuthorDate: Wed Nov 15 15:11:52 2023 +0100
nexus fetch: adapt time parser to camt.054
---
nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt | 2 +-
nexus/src/test/kotlin/Parsing.kt | 9 ++++++++-
util/src/main/kotlin/time.kt | 11 ++++++-----
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
index 295f482a..c873bffc 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
@@ -251,7 +251,7 @@ fun findIncomingTxInNotification(
// Obtaining the execution time.
val executionTime: Instant =
requireUniqueChildNamed("RltdDts") {
requireUniqueChildNamed("AccptncDtTm") {
-
parseGregorianTime(focusElement.textContent)
+ parseCamtTime(focusElement.textContent)
}
}
// Obtaining the payer's details
diff --git a/nexus/src/test/kotlin/Parsing.kt b/nexus/src/test/kotlin/Parsing.kt
index 71e4d985..e386e426 100644
--- a/nexus/src/test/kotlin/Parsing.kt
+++ b/nexus/src/test/kotlin/Parsing.kt
@@ -1,10 +1,10 @@
-import net.taler.wallet.crypto.Base32Crockford
import org.junit.Test
import org.junit.jupiter.api.assertThrows
import tech.libeufin.nexus.TalerAmount
import tech.libeufin.nexus.getAmountNoCurrency
import tech.libeufin.nexus.getTalerAmount
import tech.libeufin.nexus.isReservePub
+import tech.libeufin.util.parseCamtTime
import java.lang.StringBuilder
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@@ -12,6 +12,13 @@ import kotlin.test.assertNull
import kotlin.test.assertTrue
class Parsing {
+
+ @Test
+ fun gregorianTime() {
+ parseCamtTime("2023-11-06T20:00:00")
+ assertThrows<Exception> { parseCamtTime("2023-11-06T20:00:00+01:00") }
+ assertThrows<Exception> { parseCamtTime("2023-11-06T20:00:00Z") }
+ }
@Test // Could be moved in a dedicated Amounts.kt test module.
fun generateCurrencyAgnosticAmount() {
assertThrows<Exception> {
diff --git a/util/src/main/kotlin/time.kt b/util/src/main/kotlin/time.kt
index dc0ebb5a..2dac61e8 100644
--- a/util/src/main/kotlin/time.kt
+++ b/util/src/main/kotlin/time.kt
@@ -82,13 +82,14 @@ fun Long.microsToJavaInstant(): Instant? {
}
/**
- * Parses one timestamp from the ISO 8601 format.
+ * Parses timestamps found in camt.054 documents. They have
+ * the following format: yyy-MM-ddThh:mm:ss, without any timezone.
*
* @param timeFromXml input time string from the XML
* @return [Instant] in the UTC timezone
*/
-fun parseGregorianTime(timeFromXml: String): Instant {
- val formatter = DateTimeFormatter.ISO_DATE_TIME.parse(timeFromXml)
- return Instant.from(formatter)
-
+fun parseCamtTime(timeFromCamt: String): Instant {
+ val t = LocalDateTime.parse(timeFromCamt)
+ val utc = ZoneId.of("UTC")
+ return t.toInstant(utc.rules.getOffset(t))
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: nexus fetch: adapt time parser to camt.054,
gnunet <=