logbon72 / angular-material-datetimepicker

Datepicker for Angular Material, mimick's Android's date time picker
https://logbon72.github.io/angular-material-datetimepicker
MIT License
169 stars 123 forks source link

Unable to select end date when using date range in a specific case #130

Open rahulgadhyan opened 6 years ago

rahulgadhyan commented 6 years ago

I am using start date and end date selection range with following condition: 1) end date cannot be less than start date

If the current system time is in AM, say 13/05/2018, 09:00 AM and i want to select date range as 12/05/2018-10:00PM to 12/05/2018-11:00PM.

After Selecting start date-time as 12/05/2018-10:00PM, i am not able to select end date-time as 12/05/2018-11:00PM because when I open the end date-time picker, it shown todays date, ie 13th (and time as 9:00 AM). and if I try to select 12th, it cannot select as 12/5/18, 9:00 AM is lesser than start date already selected.

I would like to know if there is a way to work around this particular isssue Thanks

hexadecy commented 6 years ago

Can you paste some template code and why the end date-time is set to today?

rahulgadhyan commented 6 years ago

this is how the code is handled in html:

And have the following code in javascript (using angular framework):

$scope.setMaxStartDate = function () { $scope.closeAlert(); if($scope.fromDate == null) $scope.maxStartDate = $scope.toDate; $scope.checkStartEndDate(); }

$scope.checkStartEndDate = function () { $scope.closeAlert(); if($scope.fromDate > $scope.toDate) $scope.toDate = null; //if($scope.toDate==null && current system time = AM && $scope.fromDate = yesterday PM) then set $scope.toDate as $scope.fromDate }

im using this code in an app. Now if current system time is say 17/5/18 - 9:00 AM.

I need to set the start and end date as follows:

start: 16/5/18, 10:00 PM

end: 16/5/18, 11:00 PM

I select the start date and enter as required.

Then I select the end date. currently it shows 17/5/18. If i select 17/5/18, i get the time auto set at 9:00AM, i.e. the current time.

This is the expected behaviour.

However, when i click the end date and select 16/5/18. I guesss, the time still refers to 9:00 AM so, effectively the ref is to 16/5/18-9:00AM

Now as i have set that the end date has to be greater than start date, i am not able to select anything as 16/5/18-9:00AM is lesser than the already selected start date.

If I try to select PM, as the hour reading refers to 9, it will point to 9:00PM which is still smaller than 10:00PM selected in the start date.

So it does not allow me to select PM. I am completely stuck.

I hope i have been able to clear my question

Thanks for your time

Regards

Rahul

On Wed, May 16, 2018 at 5:56 AM, Michel Couillard notifications@github.com wrote:

Can you paste some template code and why the end date-time is set to today?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/logbon72/angular-material-datetimepicker/issues/130#issuecomment-389356324, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac1kGswAbDZ0FjJMRLfwhCbU4nnRzeLeks5ty3IwgaJpZM4T8t3q .

hexadecy commented 6 years ago

What version are you using? v1.15.1 ?

I tried to reproduce it with you code, but it's working as I think it should.

  1. I set manually my system time to 17/5/18 - 9:00 AM
  2. start: 16/5/18, 10:00 PM
  3. end: 16/5/18, 11:00 PM
  4. go to change end again, but I clicked "today"
  5. Then change date to 16/5/18 and the time stay at 9:00 AM
  6. Cannot change time, but I can click on PM circle
  7. Then I can only select 10 PM or 11PM in hours. Max 11:59PM

Please see my video of this: https://drive.google.com/file/d/1M-y5GL_SpNVzTdoaNmm_xuOiA866cMbh/view?usp=sharing

hexadecy commented 6 years ago

@rahulgadhyan have you found something?

rahulgadhyan commented 6 years ago

Hi Michel,

I was busy with some other portion of our code. I shall try to work as directed this week. If the issue persists, I shall record the video and share it with you

Thanks a lot for your time and effort

Regards Rahul

On Thu, May 31, 2018 at 1:48 AM, Michel Couillard notifications@github.com wrote:

@rahulgadhyan https://github.com/rahulgadhyan have you found something?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/logbon72/angular-material-datetimepicker/issues/130#issuecomment-393304016, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac1kGqpQInEmreSUsUJBl5LNUjhnFKK8ks5t3v6GgaJpZM4T8t3q .

hexadecy commented 5 years ago

Yes @rahulgadhyan you can record a video with something like Screencastify. And add many info as you can on how to reproduce it.

hexadecy commented 5 years ago

I fixed this in https://github.com/beenote/angular-material-datetimepicker/issues/54.