From 68ba9797f6695f03d915977c4ea21e08e32c30a2 Mon Sep 17 00:00:00 2001 From: Yuri Druzhkov Date: Thu, 31 Oct 2013 14:50:38 +0400 Subject: [PATCH 1/2] day non be zero --- js/jquery.countdown.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/jquery.countdown.js b/js/jquery.countdown.js index 1fafda6..7086ba6 100644 --- a/js/jquery.countdown.js +++ b/js/jquery.countdown.js @@ -58,7 +58,7 @@ jQuery.fn.countdown = function(userOptions) // Add max digits, for example, first digit of minutes (mm) has // a max of 5. Conditional max is used when the left digit has reach // the max. For example second "hours" digit has a conditional max of 4 - switch (options.format[i]) + switch (options.format[i]) { case 'h': digits[c]._max = function(pos, isStart) { @@ -157,15 +157,15 @@ jQuery.fn.countdown = function(userOptions) makeMovement(elem, 1); }; - + // add leading zeros var pad = function(x){return (1e15+""+x).substr(-2)}; - + // convert a date object to the format specified var formatCompute = function(d) { var format = userOptions.format||options.format; var parse = { - d: d.getDate(), + d: d.getDate() - 1, // date can not be zero h: d.getHours(), m: d.getMinutes(), s: d.getSeconds() @@ -174,7 +174,7 @@ jQuery.fn.countdown = function(userOptions) return pad(parse[form[0]]); }); }; - + // parses a date of the form hh:mm:ss, for example, where // ... precision is the same as the format. var parseRelativeDate = function(form) { @@ -184,7 +184,7 @@ jQuery.fn.countdown = function(userOptions) var m = now.getMonth() + 1; var y = now.getFullYear(); var h = now.getHours(), mm, s; - + // read in components and render based on format var format = userOptions.format||options.format; var parts = form.split(':'); @@ -211,9 +211,9 @@ jQuery.fn.countdown = function(userOptions) // return our constructed date object return new Date([m, d, y].join('/') + ' ' + [h, mm, s].map(pad).join(':') + ' GMT-0900'); }; - + // if an endTime is provided... - if( userOptions.endTime ) { + if( userOptions.endTime ) { // calculate the difference between endTime and present time var endDate = userOptions.endTime instanceof Date ? userOptions.endTime : parseRelativeDate(userOptions.endTime); var diff = endDate.getTime() - (new Date()).getTime(); From 678600b93067a7fcdb5be020c3bd17c7477042e2 Mon Sep 17 00:00:00 2001 From: Yuri Druzhkov Date: Thu, 31 Oct 2013 15:30:34 +0400 Subject: [PATCH 2/2] fixes UTC timestamp diff --- js/jquery.countdown.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/jquery.countdown.js b/js/jquery.countdown.js index 7086ba6..8ec99aa 100644 --- a/js/jquery.countdown.js +++ b/js/jquery.countdown.js @@ -165,10 +165,10 @@ jQuery.fn.countdown = function(userOptions) var formatCompute = function(d) { var format = userOptions.format||options.format; var parse = { - d: d.getDate() - 1, // date can not be zero - h: d.getHours(), - m: d.getMinutes(), - s: d.getSeconds() + d: d.getUTCDate() - 1, + h: d.getUTCHours(), + m: d.getUTCMinutes(), + s: d.getUTCSeconds() }; return format.replace(/(dd|hh|mm|ss)/g, function($0, form) { return pad(parse[form[0]]);