Skip to content

Commit

Permalink
Fix: Issue with month jumping. Fixes #98, #86, #80
Browse files Browse the repository at this point in the history
  • Loading branch information
mugifly committed Feb 16, 2014
1 parent 24e57de commit ad9bb5c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
21 changes: 11 additions & 10 deletions jquery.simple-dtpicker.js
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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){
Expand All @@ -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;
}
Expand Down Expand Up @@ -1213,7 +1214,7 @@
}
}
};

$.fn.handleDtpicker = function( method ) {
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
Expand Down
2 changes: 1 addition & 1 deletion simple-dtpicker.jquery.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit ad9bb5c

Please sign in to comment.