diff options
author | Florian Dold <florian@dold.me> | 2021-11-02 17:02:04 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-11-02 17:02:14 +0100 |
commit | fdc36b4fb75201e23023a583b8eebd05b1f24f77 (patch) | |
tree | 828fdd4cd2e80dcbd170211f8babff1adf096279 /packages/taler-util/src/time.ts | |
parent | 83b63d1cc076dced82a235d7ca37ff04357ddb73 (diff) | |
download | wallet-core-fdc36b4fb75201e23023a583b8eebd05b1f24f77.tar.gz wallet-core-fdc36b4fb75201e23023a583b8eebd05b1f24f77.tar.bz2 wallet-core-fdc36b4fb75201e23023a583b8eebd05b1f24f77.zip |
anastasis-core: compute upload fees
Diffstat (limited to 'packages/taler-util/src/time.ts')
-rw-r--r-- | packages/taler-util/src/time.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts index c0858ada6..856db8a57 100644 --- a/packages/taler-util/src/time.ts +++ b/packages/taler-util/src/time.ts @@ -69,6 +69,20 @@ export function getDurationRemaining( return { d_ms: deadline.t_ms - now.t_ms }; } +export namespace Duration { + export const getRemaining = getDurationRemaining; + export function toIntegerYears(d: Duration): number { + if (typeof d.d_ms !== "number") { + throw Error("infinite duration"); + } + return Math.ceil(d.d_ms / 1000 / 60 / 60 / 24 / 365); + } +} + +export namespace Timestamp { + export const min = timestampMin; +} + export function timestampMin(t1: Timestamp, t2: Timestamp): Timestamp { if (t1.t_ms === "never") { return { t_ms: t2.t_ms }; |