Skip to content

Adding ability to choose the timezone #117

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

Merged
3 commits merged into from
Mar 2, 2011
Merged

Conversation

harbulot
Copy link
Contributor

I'd like to suggest another selector for the time zone, since users may be in various time zones. I've used "z" for the formatter parameter, representing a time zone indicator in the RFC 2822 format (+xxxx or -xxxx).

The additional options are:

  • showTimezone: true/false
  • timezone: "+0100" (used by default if the time zone is missing from the value to parse)
  • timezoneList: [{"value": "+0000", "label": "British Winter Time"}, {"value": "+0100", "label": "British Summer Time"}] or, if no labels are required, simply something like ["+0100","+0200"].

The default values and the list to present could be customized depending on the user.

This includes a test HTML file.

Here is an example, with an input like this:

 <input type="text" value="Mon, 28 Feb 2011 10:58 +0100"/>

and with a datetimepicker initialized like this:

.datetimepicker({ dateFormat: $.datepicker.RFC_2822,
                  timeFormat: 'hh:mm z',
                  showTimezone: true,
                  timezoneList: ["+0000", "+0100"] });

@Volune
Copy link

Volune commented May 4, 2011

I suggest you add the support of the timezone in the _setTime function, with something like this :

var timezoneOffset = date.getTimezoneOffset();
var timezoneSign = (timezoneOffset < 0) ? '+' : '-'; //If your time zone is GMT+2, -120 will be returned.
timezoneOffset = Math.abs( timezoneOffset );
var timezoneHours = timezoneOffset / 60;
timezoneHours = ((timezoneHours < 10) ? '0' : '') + timezoneHours;
var timezoneMinutes = timezoneOffset % 60;
timezoneMinutes = ((timezoneMinutes < 10) ? '0' : '') + timezoneMinutes;
var timezone = timezoneSign + timezoneHours + timezoneMinutes;
if( tp_inst.timezone_select ) tp_inst.timezone_select.val( timezone );
else tp_inst.timezone = timezone;

I'm not familiar enough with jvascript or github to help more than this suggestion.

This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants