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

Setting anchor = null allows invalid time periods #52

Closed jhegeman closed 8 years ago

jhegeman commented 8 years ago

Hi Jon,

First of all a big thank-you for this nice plugin! I think the below is a bug, or maybe I'm just doing something wrong.

The problem can be reproduced with the bottom 'Anchor example' of the documentation: http://jonthornton.github.io/Datepair.js/ With the anchor set to null, the begin and end dates are still kept in the correct order: end date after begin date. When selecting a begin date after the currently-set end date, the end date will be moved to match the new begin date. This is not the case for the times. So it will not allow one to select an end date before the begin date, but when the dates are equal, it does allow one to select an end time before the begin time, resulting in an impossible time period.

Cheers, Jeroen

jonthornton commented 8 years ago

Nice catch! Thanks for the detailed bug report.

jhegeman commented 8 years ago

Thanks Jon, but now, ahum, this had a side-effect. It looks as if it does not take into account the date when 'fixing' the time.

To reproduce (using the bottom example again):

I think it should only adjust the times in case the dates are equal.

Jeroen