jonthornton / Datepair.js

A javascript plugin for intelligently selecting date and time ranges, inspired by Google Calendar.
https://www.jonthornton.com/Datepair.js
358 stars 87 forks source link

Overlapping time ranges over those disabled #45

Closed andriuhatm closed 9 years ago

andriuhatm commented 9 years ago

For example, if i have defaultTimeDelta set to 3 hours and i choose a start time before the disabled period, the end time goes over the disabled period.

Example: 'disableTimeRanges': [ [ 8:00, 9:00 ], [ 11:00, 13:00 ] ]

I don't have to be able to select 10:00 because the timeDelta is 3 hours. How to disable 3 hour period before second time range? And there might be more keys in array, because the disabled time period is returned from Google Calendar API.. Thx..

jonthornton commented 9 years ago

You'll need to set disableTimeRanges on both the start and end pickers, with timeDelta as the offset between the two.

andriuhatm commented 9 years ago

Thank you. I did this in a different way- i just subtract current "defaultTimeDelta" from all start times and then created a new array.