diff options
Diffstat (limited to 'src/helpers.ts')
-rw-r--r-- | src/helpers.ts | 9 |
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. |