Skip to content

useLocalTimezone causes bad behavior #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rehevkor5 opened this issue Oct 8, 2012 · 5 comments
Closed

useLocalTimezone causes bad behavior #471

rehevkor5 opened this issue Oct 8, 2012 · 5 comments

Comments

@rehevkor5
Copy link

If useLocalTimezone is set to true and the field value contains a time zone that differs from the local time zone, opening the picker will immediately change the time zone in the field to the local time zone, but does not make a corresponding change to the date/time. Thus, clicking in the field changes the time.

Instead, one of two things should happen:

  1. If there is a pre-existing time zone in the field, opening the picker uses that time zone, and does not modify the value of the field, OR
  2. The field is modified to match the local time zone, but correct changes are applied to the date & time values so that the actual UTC value remains the same.

Option 1 is obviously easier to accomplish.

@rehevkor5
Copy link
Author

By the way I'd be happy to try to fix it if you can point me in the right direction.

@trentrichardson
Copy link
Owner

Hard to say exactly where it is without tracing it through, but this may be a start:

https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/dev/jquery-ui-timepicker-addon.js#L1174

(Also note that is the dev branch)

@magnetik
Copy link
Contributor

Confirming it.

Go an input with a value (IE: 01/16/2013 18:00 +0000). When clicking on it (datePicker has option useLocalTimezone), the input is changed for +0100 (in my case)

@magnetik
Copy link
Contributor

On line 1764 (dev branch) selectLocalTimeZone is called (from $.datepicker._updateDatepicker) with the arguments

  • tp_inst (has tp_inst.timezone: "+0000")
  • date: Wed Jan 16 2013 18:00:00 GMT+0100 (Romance Standard Time)

then tzoffset is read from date (line 1768) so it has value "+0100"
then if (tp_inst._defaults.timezoneIso8601) { is false so no effect
then you call tp_inst.timezone_select.val("+0100")so the value is changed even if it's not correct at all.

If I come up with some elegant solution I'll do a pull request.

@magnetik
Copy link
Contributor

Moreover, you already does the selectLocalTimeZone in $.extend._injectTimePicker (line 456 in dev)

if (local_timezone == this.timezone) {
    selectLocalTimeZone(tp_inst);
} else {
    this.timezone_select.val(this.timezone);
}

Which does not modify anything is the local timezone is different of the parsed time zone.

I've made a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants