diff options
author | Florian Dold <florian@dold.me> | 2022-03-22 23:03:41 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-22 23:03:41 +0100 |
commit | 739c2f933770206b173a9b3cbafa79ee6048ff9d (patch) | |
tree | aaae15f5f22a0fe1a8449494a50477ca9ed3a0a5 /packages/taler-util/src | |
parent | 5d23eb36354d07508a015531f298b3e261bbafce (diff) | |
download | wallet-core-739c2f933770206b173a9b3cbafa79ee6048ff9d.tar.xz |
wallet: more time format fixes
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/time.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts index 43cb7ad4d..344bc0f74 100644 --- a/packages/taler-util/src/time.ts +++ b/packages/taler-util/src/time.ts @@ -101,6 +101,9 @@ export namespace Duration { export function getForever(): Duration { return { d_ms: "forever" }; } + export function getZero(): Duration { + return { d_ms: 0 }; + } export function fromTalerProtocolDuration( d: TalerProtocolDuration, ): Duration { @@ -113,6 +116,16 @@ export namespace Duration { d_ms: d.d_us / 1000, }; } + export function toTalerProtocolDuration(d: Duration): TalerProtocolDuration { + if (d.d_ms === "forever") { + return { + d_us: "forever", + }; + } + return { + d_us: d.d_ms * 1000, + }; + } } export namespace AbsoluteTime { |