Nelsonsanu / jquery-countdown

Automatically exported from code.google.com/p/jquery-countdown
0 stars 0 forks source link

3-digit days will not work #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Wenn specifying a 3-digit day format, the counter just produces garbage - the 
second are mixed up and wrap to 99 instead of 59.

The format I specified:
format: 'ddd:hh:mm:ss'   

Original issue reported on code.google.com by michael....@valnova.ch on 17 Nov 2010 at 6:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I solved this problem.

change line 53 with:

switch (options.format.charAt(i)) {
          case 'h':
            digits[c].__max = (c % 2 == 0) ? 3: 2;
            if (c % 2 != 0)
              digits[c].__condmax = 2;
            break;
          case 'd': 
            digits[c].__max = 9;
            break;
          case 'm':
          case 's':
            digits[c].__max = (c % 2 == 0) ? 9: 5;
        }
        ++c;
      }

Original comment by webffr...@gmail.com on 25 May 2011 at 10:28

GoogleCodeExporter commented 9 years ago
A better fix would be to use extern variables to determine the max digits 
instead of using the incremental "c". Because in yours, you can only use the 3 
digits for days. If you have another timer with only 2 digits, the bug will 
appear again.

In the attachment, I give you my file with the fix. Search the variables "hc" 
and "msc" if you want to see what I changed.

So you can have several timer, with 2 or 3 digits for days, and each of them 
work fine :)

Original comment by tommy.le...@gmail.com on 21 Jun 2011 at 10:33

Attachments:

GoogleCodeExporter commented 9 years ago
Problems occur when the "format" passed to the function doesn't match the 
format of the "startTime" passed to the function. I'm in the process of fixing 
this over at:

https://github.com/pfarmer/jquery-countdown

I'm happy to take patches or suggestions.

Thanks,

Peter

Original comment by pfar...@gmail.com on 21 Sep 2011 at 4:57

GoogleCodeExporter commented 9 years ago
This is now fixed over at my git repo: 
https://github.com/pfarmer/jquery-countdown

The format is now calculated to match the format passed in by startTime.

Original comment by pfar...@gmail.com on 22 Sep 2011 at 12:21

GoogleCodeExporter commented 9 years ago
Thank you pfarmer

Original comment by thomas.p...@gmail.com on 18 Jan 2014 at 6:00