@@ -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