Skip to content

Loading…

Fixed incorrect date when selecting previous month #65

Merged
merged 1 commit into from

2 participants

@danielksb

This commit is fixing a bug which occured during date selection. When selecting a day of the previous month which is higher than the current date's day the wrong date will be selected. This happens because setting a day with setDate() which is higher than the current month will automatically change the day to a lower number. That's why the month has to be set before the day.

How to reproduce: Let's say February, 26th is selected and then the user wants to switch to January, 30th then January, 2nd will be selected instead.

@danielksb danielksb Fixed date selection bug
This commit is fixing a bug which occured during date selection. When selecting a day of the previous month which is higher than the current date's day the wrong date will be selected. This happens because setting a day with setDate() which is higher than the current month will automatically change the day to a lower number. That's why the month has to be set before the day.

How to reproduce: Let's say February, 26th is selected and then the user wants to switch to January, 30th then January, 2nd will be selected instead.
14b24e8
@xdan xdan merged commit ff8a3d0 into xdan:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2014
  1. @danielksb

    Fixed date selection bug

    danielksb committed
    This commit is fixing a bug which occured during date selection. When selecting a day of the previous month which is higher than the current date's day the wrong date will be selected. This happens because setting a day with setDate() which is higher than the current month will automatically change the day to a lower number. That's why the month has to be set before the day.
    
    How to reproduce: Let's say February, 26th is selected and then the user wants to switch to January, 30th then January, 2nd will be selected instead.
Showing with 1 addition and 1 deletion.
  1. +1 −1 jquery.datetimepicker.js
View
2 jquery.datetimepicker.js
@@ -862,8 +862,8 @@
return false;
currentTime.setFullYear( $this.data('year') );
- currentTime.setDate( $this.data('date') );
currentTime.setMonth( $this.data('month') );
+ currentTime.setDate( $this.data('date') );
datetimepicker.trigger('select.xdsoft',[currentTime]);
input.val( _xdsoft_datetime.str() );
Something went wrong with that request. Please try again.