mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
Add a utility function for converting back from JS time to Ripple epoch.
This commit is contained in:
@@ -137,6 +137,19 @@ function toTimestamp(rpepoch) {
|
|||||||
return (rpepoch + 0x386D4380) * 1000;
|
return (rpepoch + 0x386D4380) * 1000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a JavaScript timestamp or Date to a Ripple epoch.
|
||||||
|
*
|
||||||
|
* JavaScript timestamps are unix epoch in milliseconds.
|
||||||
|
*/
|
||||||
|
function fromTimestamp(rpepoch) {
|
||||||
|
if (rpepoch instanceof Date) {
|
||||||
|
rpepoch = rpepoch.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round(rpepoch/1000) - 0x386D4380;
|
||||||
|
};
|
||||||
|
|
||||||
exports.trace = trace;
|
exports.trace = trace;
|
||||||
exports.arraySet = arraySet;
|
exports.arraySet = arraySet;
|
||||||
exports.hexToString = hexToString;
|
exports.hexToString = hexToString;
|
||||||
@@ -148,6 +161,7 @@ exports.logObject = logObject;
|
|||||||
exports.assert = assert;
|
exports.assert = assert;
|
||||||
exports.arrayUnique = arrayUnique;
|
exports.arrayUnique = arrayUnique;
|
||||||
exports.toTimestamp = toTimestamp;
|
exports.toTimestamp = toTimestamp;
|
||||||
|
exports.fromTimestamp = fromTimestamp;
|
||||||
|
|
||||||
// Going up three levels is needed to escape the src-cov folder used for the
|
// Going up three levels is needed to escape the src-cov folder used for the
|
||||||
// test coverage stuff.
|
// test coverage stuff.
|
||||||
|
|||||||
Reference in New Issue
Block a user