JS: Utility function to convert ripple epoch to JS timestamp.

This commit is contained in:
Stefan Thomas
2013-03-10 21:42:44 +01:00
parent f4a598c249
commit d14be963f6
2 changed files with 12 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ exports.Amount = require('./amount').Amount;
exports.UInt160 = require('./amount').UInt160; exports.UInt160 = require('./amount').UInt160;
exports.Seed = require('./amount').Seed; exports.Seed = require('./amount').Seed;
exports.utils = require('./utils');
// Important: We do not guarantee any specific version of SJCL or for any // Important: We do not guarantee any specific version of SJCL or for any
// specific features to be included. The version and configuration may change at // specific features to be included. The version and configuration may change at
// any time without warning. // any time without warning.

View File

@@ -97,6 +97,15 @@ var assert = function (assertion, msg) {
} }
}; };
/**
* Convert a ripple epoch to a JavaScript timestamp.
*
* JavaScript timestamps are unix epoch in milliseconds.
*/
var toTimestamp = function (rpepoch) {
return (rpepoch + 0x386D4380) * 1000;
};
exports.trace = trace; exports.trace = trace;
exports.arraySet = arraySet; exports.arraySet = arraySet;
exports.hexToString = hexToString; exports.hexToString = hexToString;
@@ -106,5 +115,6 @@ exports.stringToHex = stringToHex;
exports.chunkString = chunkString; exports.chunkString = chunkString;
exports.logObject = logObject; exports.logObject = logObject;
exports.assert = assert; exports.assert = assert;
exports.toTimestamp = toTimestamp;
// vim:sw=2:sts=2:ts=8:et // vim:sw=2:sts=2:ts=8:et