aboutsummaryrefslogtreecommitdiff
path: root/src/helpers.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-01-29 22:58:47 +0100
committerFlorian Dold <florian.dold@gmail.com>2018-01-29 22:58:47 +0100
commit97f6e68ce3a515938228b9a4d3e41b5f4b25a015 (patch)
tree371331acc56b7c56abec502126c2a40cdb23a95f /src/helpers.ts
parent9fe6dc596573f38b13f0b15c946b8bc16013fdd9 (diff)
change protocol to string amount network format
Diffstat (limited to 'src/helpers.ts')
-rw-r--r--src/helpers.ts9
1 files changed, 8 insertions, 1 deletions
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<T, U>(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.