HourCounter resets with high hour count
I want to add an hour counter to my website, starting from a date. Using the "counter-from-new-years" example, i changed it to use HourCounter face, instead of DayCounter. When the clock loads, it show the correct amount of hours "4000" and something, but at the first flip, it resets to 00:00:00 and starts counting up from this reset. Is this a bug, or am i missing a setting?
I confirm this issue. It doesn't work either with only a few hours (2).
Package version
Package installed via npm. Version 0.10.8. I am using it in a React project
Minimal example
const el = document.querySelector('#clock');
const now = new Date();
const end = new Date(now.getFullYear(), now.getMonth(),
now.getDate(), now.getHours() + 2);
const clock = new FlipClock(
el, end, {
face: 'HourCounter',
countdown: true,
});
The same identical code with the substitution HourCounter => DayCounter works well.
Wait, is there any solution to this? You can hide seconds, but I don't think you can hide days (if choosing "DayCounter")...
I spent too many hours digging in the code and I think I found the bug.
In flipclock.js line 3210:
Change this line:
var now = !instance.timer.started ? new Date() : value;
To this:
var now = new Date();
And the problem should be fixed.
@Dror-Bar awesome! hopefully this doesn't break something else. so far, so good.
I spent too many hours digging in the code and I think I found the bug.
In flipclock.js line 3210:
Change this line:
var now = !instance.timer.started ? new Date() : value;To this:
var now = new Date();And the problem should be fixed.
@tbone849 you may also be interested in this pull request. Look at some of his changes in dist/flipclock.js. He added more stuff, so it might be more robust than my solution.
@tbone849 you may also be interested in this pull request. Look at some of his changes in dist/flipclock.js. He added more stuff, so it might be more robust than my solution.
Interesting. I wonder if it really changes anything. The hour counter still seems to work perfectly per your change. I wonder if there is a circumstance where that wouldn't be the case. At any rate, it doesn't seem to affect my use case. I know this project is the last on the contributors minds with likely bigger fish to fry. I wish they would at least manage the simpler pull requests.