mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
Rename toTimestamp/fromTimestamp
This commit is contained in:
@@ -17,6 +17,6 @@ module.exports = {
|
||||
convertExceptions: utils.convertExceptions,
|
||||
convertKeysFromSnakeCaseToCamelCase:
|
||||
utils.convertKeysFromSnakeCaseToCamelCase,
|
||||
toTimestamp: utils.toTimestamp,
|
||||
fromTimestamp: utils.fromTimestamp
|
||||
rippleToUnixTimestamp: utils.rippleToUnixTimestamp,
|
||||
unixToRippleTimestamp: utils.unixToRippleTimestamp
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ function removeUndefined(obj: Object): Object {
|
||||
* @return {Number} ms since unix epoch
|
||||
*
|
||||
*/
|
||||
function toTimestamp(rpepoch: number): number {
|
||||
function rippleToUnixTimestamp(rpepoch: number): number {
|
||||
return (rpepoch + 0x386D4380) * 1000;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ function toTimestamp(rpepoch: number): number {
|
||||
* @param {Number|Date} timestamp (ms since unix epoch)
|
||||
* @return {Number} seconds since ripple epoch ( 1/1/2000 GMT)
|
||||
*/
|
||||
function fromTimestamp(timestamp: number | Date): number {
|
||||
function unixToRippleTimestamp(timestamp: number | Date): number {
|
||||
const timestamp_ = timestamp instanceof Date ?
|
||||
timestamp.getTime() :
|
||||
timestamp;
|
||||
@@ -90,6 +90,6 @@ module.exports = {
|
||||
generateAddressAPI,
|
||||
convertKeysFromSnakeCaseToCamelCase,
|
||||
removeUndefined,
|
||||
toTimestamp,
|
||||
fromTimestamp
|
||||
rippleToUnixTimestamp,
|
||||
unixToRippleTimestamp
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const _ = require('lodash');
|
||||
const transactionParser = require('ripple-lib-transactionparser');
|
||||
const utils = require('../utils');
|
||||
const toTimestamp = utils.common.toTimestamp;
|
||||
const rippleToUnixTimestamp = utils.common.rippleToUnixTimestamp;
|
||||
const BigNumber = require('bignumber.js');
|
||||
|
||||
function adjustQualityForXRP(
|
||||
@@ -19,7 +19,8 @@ function adjustQualityForXRP(
|
||||
}
|
||||
|
||||
function parseTimestamp(tx: {date: string}): string | void {
|
||||
return tx.date ? (new Date(toTimestamp(tx.date))).toISOString() : undefined;
|
||||
return tx.date ? (new Date(rippleToUnixTimestamp(tx.date))).toISOString()
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function removeEmptyCounterparty(amount) {
|
||||
|
||||
@@ -29,7 +29,7 @@ function getFee(): Promise<number> {
|
||||
}
|
||||
|
||||
function rippleTimeToISO8601(rippleTime: string): string {
|
||||
return new Date(common.toTimestamp(rippleTime)).toISOString();
|
||||
return new Date(common.rippleToUnixTimestamp(rippleTime)).toISOString();
|
||||
}
|
||||
|
||||
function formatLedgerClose(ledgerClose: Object): Object {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
const _ = require('lodash');
|
||||
const utils = require('./utils');
|
||||
const {validate, fromTimestamp, toRippledAmount} = utils.common;
|
||||
const {validate, unixToRippleTimestamp, toRippledAmount} = utils.common;
|
||||
import type {Instructions, Prepare} from './types.js';
|
||||
import type {Adjustment, MaxAdjustment, Memo} from '../common/types.js';
|
||||
|
||||
@@ -32,10 +32,10 @@ function createSuspendedPaymentCreationTransaction(account: string,
|
||||
txJSON.Digest = payment.digest;
|
||||
}
|
||||
if (payment.allowCancelAfter !== undefined) {
|
||||
txJSON.CancelAfter = fromTimestamp(payment.allowCancelAfter);
|
||||
txJSON.CancelAfter = unixToRippleTimestamp(payment.allowCancelAfter);
|
||||
}
|
||||
if (payment.allowExecuteAfter !== undefined) {
|
||||
txJSON.FinishAfter = fromTimestamp(payment.allowExecuteAfter);
|
||||
txJSON.FinishAfter = unixToRippleTimestamp(payment.allowExecuteAfter);
|
||||
}
|
||||
if (payment.source.tag !== undefined) {
|
||||
txJSON.SourceTag = payment.source.tag;
|
||||
|
||||
@@ -121,7 +121,6 @@ describe('Account', function() {
|
||||
account.publicKeyIsActive(
|
||||
'025B32A54BFA33FB781581F49B235C0E2820C929FF41E677ADA5D3E53CFBA46332',
|
||||
function(err, is_valid) {
|
||||
|
||||
assert(err === null);
|
||||
assert(is_valid === false);
|
||||
done();
|
||||
|
||||
@@ -601,7 +601,7 @@ describe('RippleAPI', function() {
|
||||
assert(false, 'Should throw NetworkError');
|
||||
}).catch(error => {
|
||||
assert(error instanceof this.api.errors.RippledError);
|
||||
assert(error.message.indexOf('slowDown') !== -1);
|
||||
assert(_.includes(error.message, 'slowDown'));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user