Skip to content

Commit

Permalink
update datefunction
Browse files Browse the repository at this point in the history
add human formatted date
  • Loading branch information
realcodywburns committed Sep 1, 2017
1 parent c851aa4 commit 3848f7c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<h1>Ethereum Classic Era Countdown</h1>
<hr>
</div>
<!-- Date estimate -->
<div class="container text-center">
<div class="row text-center">
<h2 id="realDate"></h2>
</div>
</div>

<div class="countdown-container container">
<div class="clock row">
Expand Down Expand Up @@ -77,6 +83,7 @@ <h1>Ethereum Classic Era Countdown</h1>
</div>
</div>
</div>

<!-- Block Progress -->
<div class="bar-container container">
<div class="row text-center">
Expand Down
34 changes: 31 additions & 3 deletions js/1017.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ var uri = 'https://mewapi.epool.io';
var web3 = new Web3(new Web3.providers.HttpProvider(uri));
var currentblk = web3.eth.blockNumber;
var timeRemains = (5000000 - currentblk) * 14.5;
var countDownDate = (timeRemains*1000 ) + 604800000 + new Date().getTime();
var countDownDate = (timeRemains*1000 ) + 604800 + new Date().getTime();
var progress = (100-((5000000 - currentblk) / 5000000) * 100);
var real = new Date(countDownDate);

if(currentblk < 5000000){var currentEra = 5000000}

document.getElementById("realDate").innerHTML = formatDate(real);

if(currentblk < 5000000){var currentEra = 5000000}

function doGetBlk() {
currentblk = web3.eth.blockNumber;
timeRemains = (5000000 - currentblk) * 14.25;
progress = (100-((5000000 - currentblk) / 5000000) * 100);
$('#currentBlock').html(currentblk+"/"+currentEra);
document.getElementById('era-1').style.width = progress+"%";
console.log(currentblk);

}

window.onload = function() {
Expand Down Expand Up @@ -52,3 +55,28 @@ window.onload = function() {
}, 1000);

};

function formatDate(date) {
var monthNames = [
"January [一月]", "February [二月]", "March [三月]",
"April [四月]", "May [五月]", "June [六月]", "July [七月]",
"August [八月]", "September [九月]", "October [十月]",
"November [十一月]", "December [十二月]"
];
var dayNames = [
"Sunday [星期天]",
"Monday [星期]",
"Tuesday [星期二]",
"Wednesday [星期三]",
"Thursday [星期四]",
"Friday [星期五]",
"Saturday [星期六]"
]

var weekday = date.getDay();
var day = date.getDate();
var monthIndex = date.getMonth();
var year = date.getFullYear();

return dayNames[weekday] +" - " + day + ' ' + monthNames[monthIndex] + ' ' + year;
}

0 comments on commit 3848f7c

Please sign in to comment.