Skip to content

Commit

Permalink
Prepend "0" to 1-digit dates and times
Browse files Browse the repository at this point in the history
  • Loading branch information
Maingron committed Jul 27, 2021
1 parent 2a35235 commit ef11b9f
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,36 @@ function handleString(whichString) {
}

function tick(which) { // Render template values
var result = "";
if(which == "hours") {
return time.getHours();
result = time.getHours();
if(result.toString().length == 1) {
result = "0" + result;
}
} else if(which == "minutes") {
return time.getMinutes();
result = time.getMinutes();
if(result.toString().length == 1) {
result = "0" + result;
}
} else if(which == "seconds") {
return time.getSeconds();
result = time.getSeconds();
if(result.toString().length == 1) {
result = "0" + result;
}
} else if(which == "milliseconds") {
return time.getMilliseconds();

} else if(which == "day") {
return time.getDay();
result = time.getDay();
result
if(result.toString().length == 1) {
result = "0" + result;
}
} else if(which == "month") {
return time.getMonth();
result = time.getMonth();
if(result.toString().length == 1) {
result = "0" + result;
}
} else if(which == "year") {
return time.getFullYear();
} else if(which == "weekdayName") {
Expand All @@ -103,6 +121,8 @@ function tick(which) { // Render template values
} else {
return which;
}

return result;
}

function returnWeekday(which) {
Expand Down

0 comments on commit ef11b9f

Please sign in to comment.