ghusse / jQRangeSlider

A jquery UI range selection slider that supports dates
http://ghusse.github.com/jQRangeSlider/
GNU General Public License v3.0
671 stars 147 forks source link

Date range bounds with month step don't handle timezone correctly #222

Open lukaswojnar opened 7 years ago

lukaswojnar commented 7 years ago

When user is in non-UTC timezone and Month step is enabled, is not possible to set the last day of the month correctly so the slider will end at the end.

These two other issues are about the same problem:

When the date is specified in UTC timezone the slider can correctly be slided to the end of the range. The problem is it adds one month to the slider max bounds as the bound is evaluated with user's timezone.

<div id="range-slider"></div>

<script>
var startBounds = new Date(Date.UTC(2016, 0, 1, 0, 0, 0));
var endBounds = new Date(Date.UTC(2017, 0, 31, 23, 59, 59));

$("#range-slider").dateRangeSlider({
  bounds:{min: startBounds,max: endBounds},
  formatter:function(d){return (d.getMonth()+1)+" - "+d.getFullYear();},range:{min:{months:1}},arrows:false,
  step:{months:1}
}).on("userValuesChanged", function(e, data){
  console.log("min: " + data.values.min + " - " + "max: " + data.values.max);
});
</script>

The same problem has the technical demo example: http://ghusse.github.io/jQRangeSlider/technicalDemo.html (set the operating system timezone to +2 and try the demo)

As you can see in the screenshot, with my timezone settings the last possible date of the slider I can slide to is 2011-06-01 instead of 2011-06-30.

daterangeslider-timezone

ghusse commented 7 years ago

Can you create a fix for this issue?

lukaswojnar commented 7 years ago

No. I'm sorry, I haven't worked with JS timezones yet.

Can you fix that?

ghusse commented 7 years ago

I don't even reproduce your issue on the demo page

lukaswojnar commented 7 years ago

I have created a screencast video with the bug: https://vid.me/ZHef

As you can see, when I set max. Bound to: 2011-06-30 the maximum value it allowes me to select is 2011-06-01.