Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 71d9d55

Browse files
tanxvalentinewallace
authored andcommitted
Move function up in helper.js
1 parent 55acc64 commit 71d9d55

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/helper.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,23 @@ export const toLabel = (amount, settings) => {
137137
return toAmountLabel(satoshis, settings);
138138
};
139139

140+
/**
141+
* Convert a number of blocks to an amount of time in the format "X days and Y
142+
* hours" assuming 10 minutes per block.
143+
* @param {number} numBlocks The number of blocks to convert.
144+
* @return {string} The amount of time the blocks is equivalent to.
145+
*/
146+
export const getTimeTilAvailable = numBlocks => {
147+
if (!Number.isInteger(numBlocks)) {
148+
throw new Error('Invalid input!');
149+
}
150+
const days = Math.floor(numBlocks / (24 * 6));
151+
const hours = Math.floor((numBlocks % (24 * 6)) / 6);
152+
const daysString = days === 1 ? 'day' : 'days';
153+
const hoursString = hours === 1 ? 'hour' : 'hours';
154+
return `${days} ${daysString} and ${hours} ${hoursString}`;
155+
};
156+
140157
/**
141158
* Split '_' separated words and convert to uppercase
142159
* @param {string} value The input string
@@ -321,20 +338,3 @@ export const generateArc = (x, y, radius, startAngle, endAngle) => {
321338
'Z',
322339
].join(' ');
323340
};
324-
325-
/**
326-
* Convert a number of blocks to an amount of time in the format "X days and Y
327-
* hours" assuming 10 minutes per block.
328-
* @param {number} numBlocks The number of blocks to convert.
329-
* @return {string} The amount of time the blocks is equivalent to.
330-
*/
331-
export const getTimeTilAvailable = numBlocks => {
332-
if (!Number.isInteger(numBlocks)) {
333-
throw new Error('Invalid input!');
334-
}
335-
const days = Math.floor(numBlocks / (24 * 6));
336-
const hours = Math.floor((numBlocks % (24 * 6)) / 6);
337-
const daysString = days === 1 ? 'day' : 'days';
338-
const hoursString = hours === 1 ? 'hour' : 'hours';
339-
return `${days} ${daysString} and ${hours} ${hoursString}`;
340-
};

0 commit comments

Comments
 (0)