diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-11-20 19:48:43 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-11-20 19:48:43 +0100 |
commit | 553da649902f71d5ca34c9a6289ab6b1ef0ba7cb (patch) | |
tree | 857c4eb2c39e4a92e71c8a623d3188e6dbbbd1e9 /src/helpers.ts | |
parent | faedf697626dd37f3ac74ad4cac1ec378598bbf3 (diff) |
WIP: simplify DB queries and error handling
Diffstat (limited to 'src/helpers.ts')
-rw-r--r-- | src/helpers.ts | 14 |
1 files changed, 14 insertions, 0 deletions
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. @@ -126,6 +127,19 @@ export function getTalerStampSec(stamp: string): number | null { } /** + * 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. */ export function timestampCheck(stamp: string): boolean { |