jonthornton / Datepair.js

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

exmaple with jquery UTC bug #40

Closed krasi-georgiev closed 9 years ago

krasi-georgiev commented 9 years ago

the exmaple with overwriting the update funciton doesn't take into account the UTC

I think it should be:

updateDate: function (el, v) { var utc = new Date(); v.setMilliseconds(v.getMilliseconds()-(utc.getTimezoneOffset()* 60000)) $(el).datepicker('setDate',v); }

jonthornton commented 9 years ago

Can you demonstrate how the current behavior results in an error?

krasi-georgiev commented 9 years ago

Here is an example:

https://jsfiddle.net/bg9pxut2/

the second input is always one day behind

and here is a short video what happens http://screencast.com/t/n9fz6XF7

jonthornton commented 9 years ago

You're overriding the parseDate function in your example and introducing some sort of UTC based offset - that's what's causing the error. This isn't a Datepair bug.

krasi-georgiev commented 9 years ago

my point here was that in your Readme the example shows this code which is not right

https://github.com/jonthornton/Datepair.js/blob/master/README.md

jonthornton commented 9 years ago

The code in the jsFiddle you provided is different from the readme example.

krasi-georgiev commented 9 years ago

how about this one: https://jsfiddle.net/4hckgkxb/

jonthornton commented 9 years ago

I thought you were talking about the examples on this page - I'm sorry. You're right about the bug. I've updated the example.