diff options
author | Florian Dold <florian@dold.me> | 2022-03-30 20:41:21 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-30 20:41:21 +0200 |
commit | 123b92b3aa67f17d01586da0d7974de06318e551 (patch) | |
tree | 93fc7171aeafa58bbe82be7cf52cac55a1bd0e30 /packages/taler-util | |
parent | 89435696f9a28316ab3dc5ef7c73776d092da89c (diff) | |
download | wallet-core-123b92b3aa67f17d01586da0d7974de06318e551.tar.xz |
wallet: logging, timestamp parsing backwards compatibility
Diffstat (limited to 'packages/taler-util')
-rw-r--r-- | packages/taler-util/src/time.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts index 344bc0f74..695d6d274 100644 --- a/packages/taler-util/src/time.ts +++ b/packages/taler-util/src/time.ts @@ -323,6 +323,15 @@ export function durationAdd(d1: Duration, d2: Duration): Duration { export const codecForTimestamp: Codec<TalerProtocolTimestamp> = { decode(x: any, c?: Context): TalerProtocolTimestamp { + // Compatibility, should be removed soon. + const t_ms = x.t_ms; + if (typeof t_ms === "string") { + if (t_ms === "never") { + return { t_s: "never" }; + } + } else if (typeof t_ms === "number") { + return { t_s: Math.floor(t_ms / 1000) }; + } const t_s = x.t_s; if (typeof t_s === "string") { if (t_s === "never") { |