Skip to content

Commit 3c29be6

Browse files
committed
[FIX] Better number formatting for est block time
1 parent a3cbd7d commit 3c29be6

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @copyright 2010 MAPIX Technologies Ltd, UK, http://mapix.com/
4+
* @license http://en.wikipedia.org/wiki/BSD_licenses BSD License
5+
* @package Smarty
6+
* @subpackage PluginsModifier
7+
*/
8+
9+
function smarty_modifier_seconds_to_hhmmss($sec, $padHours = false) {
10+
$hms = "";
11+
$hours = intval(intval($sec) / 3600);
12+
$hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':' : $hours. ':';
13+
$minutes = intval(($sec / 60) % 60);
14+
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
15+
$seconds = intval($sec % 60);
16+
$hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
17+
return $hms;
18+
}

public/site_assets/global/js/number_format.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,16 @@ function number_format (number, decimals, dec_point, thousands_sep) {
6868
}
6969
return s.join(dec);
7070
}
71+
72+
Number.prototype.toHHMMSS = function () {
73+
var sec_num = parseInt(this, 10); // don't forget the second param
74+
var hours = Math.floor(sec_num / 3600);
75+
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
76+
var seconds = sec_num - (hours * 3600) - (minutes * 60);
77+
78+
if (hours < 10) {hours = "0"+hours;}
79+
if (minutes < 10) {minutes = "0"+minutes;}
80+
if (seconds < 10) {seconds = "0"+seconds;}
81+
var time = hours+':'+minutes+':'+seconds;
82+
return time;
83+
}

templates/bootstrap/dashboard/js/api.tpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ $(document).ready(function(){
117117
$('#b-nextdiff').html('n/a');
118118
$('#b-nextdiffc').html(' No Estimates');
119119
}
120-
var minutes = Math.floor(data.getdashboarddata.data.pool.esttimeperblock / 60);
121-
var seconds = Math.floor(data.getdashboarddata.data.pool.esttimeperblock - minutes * 60);
122-
$('#b-esttimeperblock').html(minutes + " minutes " + seconds + " seconds"); // <- this needs some nicer format
120+
$('#b-esttimeperblock').html(data.getdashboarddata.data.pool.esttimeperblock.toString().toHHMMSS());
123121
$('#b-nblock').html(data.getdashboarddata.data.network.block);
124122
$('#b-roundprogress').html(number_format(parseFloat(data.getdashboarddata.data.pool.shares.progress).toFixed(2), 2) + "%");
125123
{/literal}{if $GLOBAL.config.payout_system != 'pps'}{literal }

templates/bootstrap/dashboard/round_statistics/pplns/round.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</div>
8484
<div class="circle-tile-content lightblue">
8585
<div class="circle-tile-description text-faded">
86-
<p class="h5 up-more" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_words}</p>
86+
<p class="h5 up-more" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_hhmmss}</p>
8787
</div>
8888
<div class="circle-tile-number text-faded">
8989
<p class="h6">Est. Avg. Time per Block</p>

templates/bootstrap/dashboard/round_statistics/pps/round.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</div>
4949
<div class="col-md-spark">
5050
<i class="fa fa-clock-o fa-2x"></i>
51-
<p id="b-esttimeperblock" class="h5 font-bold m-t">{$NETWORK.EstTimePerBlock|seconds_to_words}</p>
51+
<p id="b-esttimeperblock" class="h5 font-bold m-t">{$NETWORK.EstTimePerBlock|seconds_to_hhmmss}</p>
5252
<p class="h6 text-muted">Est. Avg. Time per Block</p>
5353
</div>
5454
</div>

templates/bootstrap/dashboard/round_statistics/prop/round.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</div>
8484
<div class="circle-tile-content lightblue">
8585
<div class="circle-tile-description text-faded">
86-
<p class="h5" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_words}</p>
86+
<p class="h5" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_hhmmss}</p>
8787
</div>
8888
<div class="circle-tile-number text-faded">
8989
<p class="h6">Est. Avg. Time per Block</p>

0 commit comments

Comments
 (0)