From ad9bb5cce1bab51caf9de5f4461719cf4e0edb0e Mon Sep 17 00:00:00 2001 From: Masanori Ohgita Date: Sun, 16 Feb 2014 12:06:05 +0900 Subject: [PATCH] Fix: Issue with month jumping. Fixes #98, #86, #80 --- CHANGES | 3 +++ README.md | 3 +++ bower.json | 2 +- jquery.simple-dtpicker.js | 21 +++++++++++---------- simple-dtpicker.jquery.json | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index f31d978..52a8de9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Version history for query-simple-datetimepicker https://github.com/mugifly/jquery-simple-datetimepicker/ +1.10.1 2014-02-16 (JST) + - [Fix] Issue with month jumping (Report by: jcutrell, LinTicket, cnorthwood). + 1.10.0 2014-02-16 (JST) - [Add] Polish locale (Thanks to: viszman). - [Add] Romanian locale (Thanks to: IngerAlHaosului). diff --git a/README.md b/README.md index b0de06e..49865aa 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ Thank you to: * [Kupid Wang](http://www.kupid.me/) * [IngerAlHaosului](https://github.com/IngerAlHaosului) * [jpetto](https://github.com/jpetto) +* [jcutrell](https://github.com/jcutrell) +* [LinTicket](https://github.com/LinTicket) +* [cnorthwood](https://github.com/cnorthwood) ## License and author diff --git a/bower.json b/bower.json index 61ea0ef..0f9decf 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jquery-simple-datetimepicker", - "version": "1.10.0", + "version": "1.10.1", "main": ["jquery.simple-dtpicker.js","jquery.simple-dtpicker.css"], "dependencies": { "jquery" : ">=1.7.2" diff --git a/jquery.simple-dtpicker.js b/jquery.simple-dtpicker.js index 93632b5..fed36ef 100644 --- a/jquery.simple-dtpicker.js +++ b/jquery.simple-dtpicker.js @@ -1,6 +1,6 @@ /** * jquery-simple-datetimepicker (jquery.simple-dtpicker.js) - * v1.10.0 + * v1.10.1 * (c) Masanori Ohgita - 2014. * https://github.com/mugifly/jquery-simple-datetimepicker */ @@ -297,7 +297,7 @@ } // Convert a string (with convert-table) to a date object - var date = new Date(); + var year, month, day, hour, min; var is_successful = false; for(var i = 0; i < formats.length; i++){ if(m.length < i){ @@ -306,28 +306,29 @@ var f = formats[i]; var d = m[i+1]; // Matched part of date - if(f == 'YYYY'){ - date.setFullYear(normalizeYear(d)); + year = normalizeYear(d); is_successful = true; } else if(f == 'YY'){ - date.setYear(parseInt(d) + 2000); + year = parseInt(d) + 2000; is_successful = true; } else if(f == 'MM' || f == 'M'){ - date.setMonth(parseInt(d) - 1); + day = parseInt(d) - 1; is_successful = true; } else if(f == 'DD' || f == 'D'){ - date.setDate(d); + day = d; is_successful = true; } else if(f == 'hh' || f == 'h'){ - date.setHours(d); + hour = d; is_successful = true; } else if(f == 'mm' || f == 'm'){ - date.setMinutes(d); + min = d; is_successful = true; } } + var date = new Date(year, month, day, hour, min); + if(is_successful == true && isNaN(date) == false && isNaN(date.getDate()) == false){ // Parse successful return date; } @@ -1213,7 +1214,7 @@ } } }; - + $.fn.handleDtpicker = function( method ) { if ( methods[method] ) { return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); diff --git a/simple-dtpicker.jquery.json b/simple-dtpicker.jquery.json index 91b9023..1aa817b 100644 --- a/simple-dtpicker.jquery.json +++ b/simple-dtpicker.jquery.json @@ -1,7 +1,7 @@ { "name": "simple-dtpicker", "title": "jquery-simple-datetimepicker", - "version": "1.10.0", + "version": "1.10.1", "author": { "name": "Masanori Ohgita", "url": "https://github.com/mugifly"