diff options
author | Florian Dold <florian.dold@gmail.com> | 2015-12-18 01:30:22 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2015-12-18 01:30:22 +0100 |
commit | 3ddfad19739f0f3ce2d93a507a3f6abff9b7fe7e (patch) | |
tree | be0eb759d7216d31bff4633ebf7e60d617787836 /extension/background/emscriptif.ts | |
parent | 0d5c37a49e688503dc2933d379c68541dd432248 (diff) |
Payment "works".
Diffstat (limited to 'extension/background/emscriptif.ts')
-rw-r--r-- | extension/background/emscriptif.ts | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/extension/background/emscriptif.ts b/extension/background/emscriptif.ts index ce6f351c0..e44747d21 100644 --- a/extension/background/emscriptif.ts +++ b/extension/background/emscriptif.ts @@ -709,7 +709,18 @@ class WithdrawRequestPS extends SignatureStruct { class AbsoluteTimeNbo extends PackedArenaObject { static fromTalerString(s: string): AbsoluteTimeNbo { - throw Error(); + let x = new AbsoluteTimeNbo(); + x.alloc(); + let r = /Date\(([0-9]+)\)/; + let m = r.exec(s); + if (m.length != 2) { + throw Error(); + } + let n = parseInt(m[1]); + console.log("setting", n); + // XXX: This only works up to 54 bit numbers. + set64(x.getNative(), n); + return x; } size() { @@ -718,9 +729,22 @@ class AbsoluteTimeNbo extends PackedArenaObject { } +// XXX: This only works up to 54 bit numbers. +function set64(p: number, n: number) { + for (let i = 0; i < 8; ++i) { + Module.setValue(p + (8 - i), n & 0xFF, "i8"); + n >>>= 8; + } + +} + + class UInt64 extends PackedArenaObject { static fromNumber(n: number): UInt64 { - throw Error(); + let x = new UInt64(); + x.alloc(); + set64(x.getNative(), n); + return x; } size() { |