Better time formatting
This commit is contained in:
parent
90af4401e1
commit
be919a0f62
1 changed files with 18 additions and 1 deletions
19
index.js
19
index.js
|
@ -55,6 +55,23 @@ function timeFormatter(seconds) {
|
||||||
return `${minutes}:${seconds}`
|
return `${minutes}:${seconds}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gameTimeFormatter(seconds) {
|
||||||
|
seconds = Math.ceil(seconds)
|
||||||
|
var minutes = Math.ceil(seconds / 60)
|
||||||
|
var hours = 0
|
||||||
|
if (seconds < 60) {
|
||||||
|
return 'Under a minute ago'
|
||||||
|
} else if (minutes < 60) {
|
||||||
|
return `${minutes} Minutes`
|
||||||
|
} else {
|
||||||
|
while (minutes > 60) {
|
||||||
|
minutes -= 60
|
||||||
|
hours += 1
|
||||||
|
}
|
||||||
|
return `${hours} hours and ${minutes} minutes`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function pageUpdate() {
|
function pageUpdate() {
|
||||||
var statuses = {
|
var statuses = {
|
||||||
"online": {
|
"online": {
|
||||||
|
@ -230,7 +247,7 @@ function pageUpdate() {
|
||||||
Playing <span style="color: rgb(255, 100, 150);">${activity.name}</span>
|
Playing <span style="color: rgb(255, 100, 150);">${activity.name}</span>
|
||||||
<br> ${activity.details || activity.assets.large_text || " "}
|
<br> ${activity.details || activity.assets.large_text || " "}
|
||||||
<br> ${activity.state || activity.assets.small_text || " "}
|
<br> ${activity.state || activity.assets.small_text || " "}
|
||||||
<br> ${Math.ceil(((Date.now() - time) / 1000 / 60)).toString() + " Minutes" || " "}
|
<br> ${gameTimeFormatter((Date.now() - time) / 1000)}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue