ionic-datepicker icon indicating copy to clipboard operation
ionic-datepicker copied to clipboard

Month selector always wrong on 30 or 31 of the month if you select months that has lesser days

Open dickverweij opened this issue 8 years ago • 11 comments

This is caused by the following code that appears everywhere in the code.

$scope.currentDate.setMonth(XXX)

For example: if the currentDate = 31-Jan-2017 setting the month on februari will result in 31-Feb-2017. That date does not exist and will result in 03-Mar-2017

dickverweij avatar Jan 31 '17 10:01 dickverweij

Hi @dickverweij, please can you describe more precisely how you use the date picker. Your bug report is totally correct, but as far as I can play with the date picker, I have to click onto a date to set the new date. Changing month has no effect on selected date. I don't find how to reproduce the bug!

I wish to correct it. Thank you.

postb99 avatar Mar 24 '17 12:03 postb99

Note you can ONLY reproduce the bug if the CURRENT DATE is > 29 of the month.. and the month you want to set hasn’t that many days..

$scope.currentDate is the current date. for example 31-3-2017 now you call SET MONTH (4)

$scope.currentDate.setMonth(4) .. what is currentDate now? $scope.currentDate = 31-4-2017 .. that date dos not exist and javascripts makes it 1-5-2017

So IF you use the date picker ON the date 31-3-2017, when you press on April,.. you think you GOTO april, but you will go to may..

dickverweij avatar Mar 24 '17 12:03 dickverweij

Thanks for the feedback. I fixed it on my fork but haven't released the new version for now, I'm looking for some other things to fix these days. I found that the next month selector was bug free since it first sets the day to 1, but the previous month selector indeed had the bug. From March 28 you were jumping to January.

My fix was simply also setting to day to 1 when going back to previous month.

Oops, I misunderstood, not only next/previous month but also any month. I'll fix it.

https://github.com/OSAMES/ionic-datepicker/commits/v1.4.0 https://github.com/OSAMES/ionic-datepicker/commit/f572d29fb9e6d301959f80878d9fee319137a496

postb99 avatar Mar 28 '17 11:03 postb99

Hi @dickverweij I fixed it the same way, setting day to 1 before setting current month. So, going to February from today (March 29!) works now.

Fixed on my fork, version 1.4.0. bower package name is ionic-datepicker-fork-ionic1

My fork : https://github.com/OSAMES/ionic-datepicker

I wish I could do a pull request but since I changed package name etc I don't know how to handle this.

postb99 avatar Mar 29 '17 11:03 postb99

Fixed for original project : https://github.com/rajeshwarpatlolla/ionic-datepicker/pull/315

postb99 avatar May 02 '17 11:05 postb99

Hi @dickverweij in case you're still interested, my stable fork is ready (version 1.5.0): https://github.com/OSAMES/ionic-datepicker

postb99 avatar May 08 '17 11:05 postb99

@postb99 Can you change the positions of the close and set button please in your fork? Thanks!

fgagneten avatar May 17 '17 21:05 fgagneten

Hi @fgagneten, you're right, it's a better idea to swap them. I do this now, this will be version 1.5.1.

postb99 avatar May 19 '17 10:05 postb99

OK @fgagneten, it's ready, you can install it using bower. https://github.com/OSAMES/ionic-datepicker/releases/tag/v1.5.1

postb99 avatar May 19 '17 11:05 postb99

Thanks @postb99 , how can I using with bower? Please, give me the line code to run. Thanks

fgagneten avatar May 19 '17 21:05 fgagneten

@postb99 There is such a big error. Please, see this video to know what's going on with this fork: https://streamable.com/0xic0

Using the original library this error not happening. Please, is too important to solve the problem when you limit the first and the last day in the calendar

fgagneten avatar May 19 '17 23:05 fgagneten