Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
API CHANGE: renamed timeZoneString
Renamed timeZoneString to $.timepicker.timeZoneOffsetString to make it
public accessable
  • Loading branch information
Zauberfisch committed Aug 30, 2012
commit cd51fb3768fcbfc893ef31c1f157ae6a29fe1bd7
20 changes: 11 additions & 9 deletions jquery-ui-timepicker-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ $.extend(Timepicker.prototype, {
);
if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
var local_date = new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12);
var local_timezone = timeZoneString(local_date);
var local_timezone = $.timepicker.timeZoneOffsetString(local_date);
if (local_timezone == this.timezone) {
selectLocalTimeZone(tp_inst);
} else {
Expand Down Expand Up @@ -1553,27 +1553,29 @@ var selectLocalTimeZone = function(tp_inst, date)
if (tp_inst && tp_inst.timezone_select) {
tp_inst._defaults.useLocalTimezone = true;
var now = typeof date !== 'undefined' ? date : new Date();
var tzoffset = timeZoneString(now);
var tzoffset = $.timepicker.timeZoneOffsetString(now);
if (tp_inst._defaults.timezoneIso8601) {
tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
}
tp_inst.timezone_select.val(tzoffset);
}
};

// Input: Date Object
// Output: String with timezone offset, e.g. '+0100'
var timeZoneString = function(date)
{
$.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "1.0.2";

/**
* Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
* @param date
* @return string
*/
$.timepicker.timeZoneOffsetString = function(date) {
var off = date.getTimezoneOffset() * -1,
minutes = off % 60,
hours = (off-minutes) / 60;
return (off >= 0 ? '+' : '-') + ('0'+(hours*101).toString()).substr(-2) + ('0'+(minutes*101).toString()).substr(-2);
};

$.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "1.0.2";

//#######################################################################################
// Changes by simonvwade to better handle time range limits
//#######################################################################################
Expand Down