aboutsummaryrefslogtreecommitdiff
path: root/src/helpers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers.ts')
-rw-r--r--src/helpers.ts14
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 {