From f8d12f7b0d4af1b1769b89e80c87f9c169678564 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 18 Mar 2022 15:32:41 +0100 Subject: wallet: t_s/d_us migration --- packages/taler-wallet-core/src/util/http.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'packages/taler-wallet-core/src/util/http.ts') diff --git a/packages/taler-wallet-core/src/util/http.ts b/packages/taler-wallet-core/src/util/http.ts index 43fe29bba..79afd5707 100644 --- a/packages/taler-wallet-core/src/util/http.ts +++ b/packages/taler-wallet-core/src/util/http.ts @@ -28,10 +28,7 @@ import { OperationFailedError, makeErrorDetails } from "../errors.js"; import { Logger, Duration, - Timestamp, - getTimestampNow, - timestampAddDuration, - timestampMax, + AbsoluteTime, TalerErrorDetails, Codec, j2s, @@ -314,24 +311,24 @@ export async function readSuccessResponseTextOrThrow( /** * Get the timestamp at which the response's content is considered expired. */ -export function getExpiryTimestamp( +export function getExpiry( httpResponse: HttpResponse, opt: { minDuration?: Duration }, -): Timestamp { +): AbsoluteTime { const expiryDateMs = new Date( httpResponse.headers.get("expiry") ?? "", ).getTime(); - let t: Timestamp; + let t: AbsoluteTime; if (Number.isNaN(expiryDateMs)) { - t = getTimestampNow(); + t = AbsoluteTime.now(); } else { t = { t_ms: expiryDateMs, }; } if (opt.minDuration) { - const t2 = timestampAddDuration(getTimestampNow(), opt.minDuration); - return timestampMax(t, t2); + const t2 = AbsoluteTime.addDuration(AbsoluteTime.now(), opt.minDuration); + return AbsoluteTime.max(t, t2); } return t; } -- cgit v1.2.3