From 553da649902f71d5ca34c9a6289ab6b1ef0ba7cb Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 20 Nov 2019 19:48:43 +0100 Subject: WIP: simplify DB queries and error handling --- src/helpers.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/helpers.ts') diff --git a/src/helpers.ts b/src/helpers.ts index 7cd176498..a063db169 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -25,6 +25,7 @@ import { AmountJson } from "./amounts"; import * as Amounts from "./amounts"; import URI = require("urijs"); +import { Timestamp } from "./walletTypes"; /** * Show an amount in a form suitable for the user. @@ -125,6 +126,19 @@ export function getTalerStampSec(stamp: string): number | null { return parseInt(m[1], 10); } +/** + * Extract a timestamp from a Taler timestamp string. + */ +export function extractTalerStamp(stamp: string): Timestamp | undefined { + const m = stamp.match(/\/?Date\(([0-9]*)\)\/?/); + if (!m || !m[1]) { + return undefined; + } + return { + t_ms: parseInt(m[1], 10) * 1000, + }; +} + /** * Check if a timestamp is in the right format. */ -- cgit v1.2.3