jQRangeSlider icon indicating copy to clipboard operation
jQRangeSlider copied to clipboard

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

Open lukaswojnar opened this issue 8 years ago • 4 comments
trafficstars

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:

  • https://github.com/ghusse/jQRangeSlider/issues/210
  • https://github.com/ghusse/jQRangeSlider/issues/212

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

lukaswojnar avatar Feb 21 '17 21:02 lukaswojnar

Can you create a fix for this issue?

ghusse avatar Feb 22 '17 08:02 ghusse

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

Can you fix that?

lukaswojnar avatar Feb 22 '17 09:02 lukaswojnar

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

ghusse avatar Feb 22 '17 15:02 ghusse

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.

lukaswojnar avatar Feb 24 '17 09:02 lukaswojnar