FlipClock icon indicating copy to clipboard operation
FlipClock copied to clipboard

HourCounter resets with high hour count

Open Danielss89 opened this issue 6 years ago • 6 comments

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?

Danielss89 avatar Jun 19 '19 08:06 Danielss89

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.

OrsoBruno96 avatar Aug 17 '19 09:08 OrsoBruno96

Wait, is there any solution to this? You can hide seconds, but I don't think you can hide days (if choosing "DayCounter")...

Dror-Bar avatar Sep 07 '20 11:09 Dror-Bar

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 avatar Sep 07 '20 15:09 Dror-Bar

@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 avatar Dec 16 '20 18:12 tbone849

@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.

Dror-Bar avatar Dec 16 '20 18:12 Dror-Bar

@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.

tbone849 avatar Dec 16 '20 20:12 tbone849