From 97f6e68ce3a515938228b9a4d3e41b5f4b25a015 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 29 Jan 2018 22:58:47 +0100 Subject: change protocol to string amount network format --- src/helpers.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/helpers.ts') diff --git a/src/helpers.ts b/src/helpers.ts index 3b7cd36f5..7cd176498 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -119,12 +119,19 @@ export function flatMap(xs: T[], f: (x: T) => U[]): U[] { */ export function getTalerStampSec(stamp: string): number | null { const m = stamp.match(/\/?Date\(([0-9]*)\)\/?/); - if (!m) { + if (!m || !m[1]) { return null; } return parseInt(m[1], 10); } +/** + * Check if a timestamp is in the right format. + */ +export function timestampCheck(stamp: string): boolean { + return getTalerStampSec(stamp) !== null; +} + /** * Get a JavaScript Date object from a Taler date string. -- cgit v1.2.3