Rename argument name to something more sensible
All checks were successful
CI / CI (push) Successful in 1m23s
All checks were successful
CI / CI (push) Successful in 1m23s
and add comment explaining off by 1 error
This commit is contained in:
parent
9062b32009
commit
8c642f16f0
1 changed files with 3 additions and 4 deletions
|
@ -1,6 +1,5 @@
|
||||||
module.exports = function(timeElapsed) {
|
module.exports = function(targetTime) {
|
||||||
|
let countDownDate = new Date(targetTime).getTime();
|
||||||
let countDownDate = new Date(timeElapsed).getTime();
|
|
||||||
let now = new Date().getTime();
|
let now = new Date().getTime();
|
||||||
|
|
||||||
let distance = countDownDate - now;
|
let distance = countDownDate - now;
|
||||||
|
@ -9,7 +8,7 @@ module.exports = function(timeElapsed) {
|
||||||
let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||||
let seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
let seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||||
|
|
||||||
if (seconds < 0) {
|
if (seconds < 0) { // Due to how the math above works, if the input time is in the past, the time will be off by 1.
|
||||||
days = days + 1;
|
days = days + 1;
|
||||||
hours = hours + 1;
|
hours = hours + 1;
|
||||||
minutes = minutes + 1;
|
minutes = minutes + 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue