DanielYKPan / date-time-picker

Angular Date Time Picker (Responsive Design)
https://daniel-projects.firebaseapp.com/owlng/date-time-picker
MIT License
565 stars 356 forks source link

Time picker allows user to move to dates less than the given min dateTime moment #735

Open muvvalabharatha opened 3 years ago

muvvalabharatha commented 3 years ago

Hi, I have a use case where user can choose a start and end time. I am using current date and time as minimum dateTime range.

Sample code is as below:

<input [owlDateTimeTrigger]="startTimePicker" [min]="scheduleMinDateTime" [(ngModel)]="startTime" [owlDateTime]="startTimePicker" required #startTime="ngModel">
<owl-date-time [pickerType]="'timer'" #startTimePicker></owl-date-time>

<input [owlDateTimeTrigger]="endTimePicker" [min]="scheduleMinDateTime" [(ngModel)]="endTime" [owlDateTime]="endTimePicker" required #endTime="ngModel">
<owl-date-time [pickerType]="'timer'" #endTimePicker></owl-date-time>

If I try to change the time using keys provided, I can see that library allows me to select the time which is less that scheduleMinDateTime (current date and time).

Example is If the scheduleMinDateTime is given as 13 Apr 2021 23:56:34 GMT. In this case, I am able to select 01:56 using the time picker.

Issue is because when I use the options to increase/decrease the hours and minutes - Library uses whole dateTime moment to change the value.

Now the user selected value will be 14 Apr 2021 01:56:34 GMT which is not less than the given minDate as per library.

But I want only the time to change not the date. Is there any way to solve this issue. Please advise.

Thanks.