diff options
Diffstat (limited to 'packages/taler-util/src/time.ts')
-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 { |