longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

Fix the bug that time differs by 1 hour from the selected when BST/DST clocks change #500

Closed Hirurg103 closed 3 years ago

Hirurg103 commented 3 years ago

This PR fixes the issue that the time calculated by the plugin was one hour more than the time selected by the user when the clock moves forward an hour and one hour less when the clock moves back for users in BST/DST regions.

This happened because to calculate the selected time, the selected hours were added to the beginning of the selected day. For example, when user selected 02:00 on the day when the clock moves forward then the calculated time was 03:00 because the beginning of the day plus 2 hours is 03:00. This is due to the fact that at 01:00 the clock moves forward an hour.

For more details see https://en.wikipedia.org/wiki/British_Summer_Time https://en.wikipedia.org/wiki/Daylight_saving_time

In this PR the code was changed to use the hour/minute MomentJS functions to set time: https://momentjs.com/docs/#/get-set/hour https://momentjs.com/docs/#/get-set/minute

Fixes #462

monovertex commented 3 years ago

Thank you for your contribution! I'll be releasing a new version shortly with your fixes.

Hirurg103 commented 3 years ago

Thank you for accepting this fix @monovertex