|
104 | 104 | pickerTimeFormat: null,
|
105 | 105 | pickerTimeSuffix: null,
|
106 | 106 | showTimepicker: true,
|
107 |
| - timezoneIso8601: false, |
108 | 107 | timezoneList: null,
|
109 | 108 | addSliderAccess: false,
|
110 | 109 | sliderAccessArgs: null,
|
|
245 | 244 | '+0100', '+0200', '+0300', '+0330', '+0400', '+0430', '+0500', '+0530', '+0545', '+0600', '+0630', '+0700', '+0800', '+0845', '+0900', '+0930',
|
246 | 245 | '+1000', '+1030', '+1100', '+1130', '+1200', '+1245', '+1300', '+1400'];
|
247 | 246 |
|
248 |
| - if (tp_inst._defaults.timezoneIso8601) { |
| 247 | + if (tp_inst.support.iso8601) { |
249 | 248 | timezoneList = $.map(timezoneList, function(val) {
|
250 | 249 | return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
|
251 | 250 | });
|
252 | 251 | }
|
253 | 252 | tp_inst._defaults.timezoneList = timezoneList;
|
254 | 253 | }
|
255 | 254 |
|
256 |
| - tp_inst.timezone = tp_inst._defaults.timezone !== null? tp_inst._defaults.timezone : $.timepicker.timezoneOffsetString((new Date()).getTimezoneOffset()); |
| 255 | + tp_inst.timezone = tp_inst._defaults.timezone !== null? tp_inst._defaults.timezone : |
| 256 | + $.timepicker.timezoneOffsetString((new Date()).getTimezoneOffset(), tp_inst.support.iso8601); |
257 | 257 | tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
|
258 | 258 | tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
|
259 | 259 | tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
|
|
477 | 477 | }));
|
478 | 478 | if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
|
479 | 479 | var local_date = new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12);
|
480 |
| - var local_timezone = $.timepicker.timezoneOffsetString(local_date.getTimezoneOffset()); |
| 480 | + var local_timezone = $.timepicker.timezoneOffsetString(local_date.getTimezoneOffset(), this.support.iso8601); |
481 | 481 | if (local_timezone == this.timezone) {
|
482 | 482 | selectLocalTimezone(tp_inst);
|
483 | 483 | } else {
|
|
1082 | 1082 | * Public utility to parse time
|
1083 | 1083 | */
|
1084 | 1084 | $.datepicker.parseTime = function(timeFormat, timeString, options) {
|
1085 |
| - var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}); |
| 1085 | + var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}), |
| 1086 | + iso8601 = (timeFormat.replace(/\'.*?\'/g,'').indexOf('Z') !== -1); |
1086 | 1087 |
|
1087 | 1088 | // Strict parse requires the timeString to match the timeFormat exactly
|
1088 | 1089 | var strictParse = function(f, s, o){
|
|
1126 | 1127 | };
|
1127 | 1128 |
|
1128 | 1129 | var regstr = '^' + f.toString()
|
1129 |
| - .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[lcz]|'.*?')/g, function (match) { |
| 1130 | + .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) { |
1130 | 1131 | var ml = match.length;
|
1131 | 1132 | switch (match.charAt(0).toLowerCase()) {
|
1132 | 1133 | case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
|
|
1193 | 1194 | }
|
1194 | 1195 | if (order.z !== -1 && treg[order.z] !== undefined) {
|
1195 | 1196 | var tz = treg[order.z].toUpperCase();
|
| 1197 | + |
1196 | 1198 | switch (tz.length) {
|
1197 |
| - case 1: |
1198 |
| - // Z |
1199 |
| - tz = o.timezoneIso8601 ? 'Z' : '+0000'; |
1200 |
| - break; |
1201 |
| - case 5: |
1202 |
| - // +hhmm |
1203 |
| - if (o.timezoneIso8601) { |
1204 |
| - tz = tz.substring(1) == '0000' ? 'Z' : tz.substring(0, 3) + ':' + tz.substring(3); |
1205 |
| - } |
1206 |
| - break; |
1207 |
| - case 6: |
1208 |
| - // +hh:mm |
1209 |
| - if (!o.timezoneIso8601) { |
1210 |
| - tz = tz == 'Z' || tz.substring(1) == '00:00' ? '+0000' : tz.replace(/:/, ''); |
1211 |
| - } else { |
1212 |
| - if (tz.substring(1) == '00:00') { |
1213 |
| - tz = 'Z'; |
| 1199 | + case 1: |
| 1200 | + // Z |
| 1201 | + tz = iso8601 ? 'Z' : '+0000'; |
| 1202 | + break; |
| 1203 | + case 5: |
| 1204 | + // +hhmm |
| 1205 | + if (iso8601) { |
| 1206 | + tz = tz.substring(1) == '0000' ? 'Z' : tz.substring(0, 3) + ':' + tz.substring(3); |
1214 | 1207 | }
|
1215 |
| - } |
1216 |
| - break; |
| 1208 | + break; |
| 1209 | + case 6: |
| 1210 | + // +hh:mm |
| 1211 | + if (!iso8601) { |
| 1212 | + tz = tz == 'Z' || tz.substring(1) == '00:00' ? '+0000' : tz.replace(/:/, ''); |
| 1213 | + } else { |
| 1214 | + if (tz.substring(1) == '00:00') { |
| 1215 | + tz = 'Z'; |
| 1216 | + } |
| 1217 | + } |
| 1218 | + break; |
1217 | 1219 | }
|
1218 | 1220 | resTime.timezone = tz;
|
1219 | 1221 | }
|
|
1244 | 1246 | second: d.getSeconds(),
|
1245 | 1247 | millisec: d.getMilliseconds(),
|
1246 | 1248 | microsec: d.getMicroseconds(),
|
1247 |
| - timezone: $.timepicker.timezoneOffsetString(d.getTimezoneOffset()) |
| 1249 | + timezone: $.timepicker.timezoneOffsetString(d.getTimezoneOffset(), iso8601) |
1248 | 1250 | };
|
1249 | 1251 | }
|
1250 | 1252 | catch(err){
|
|
1292 | 1294 | ampmName = options.pmNames[0];
|
1293 | 1295 | }
|
1294 | 1296 |
|
1295 |
| - tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[lcz]|('.*?'|".*?"))/g, function(match) { |
| 1297 | + tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|('.*?'|".*?"))/g, function(match) { |
1296 | 1298 | switch (match) {
|
1297 | 1299 | case 'HH':
|
1298 | 1300 | return ('0' + hour).slice(-2);
|
|
1316 | 1318 | return ('00' + time.microsec).slice(-3);
|
1317 | 1319 | case 'z':
|
1318 | 1320 | return time.timezone === null? options.timezone : time.timezone;
|
| 1321 | + case 'Z': |
| 1322 | + return time.timezone === null? options.timezone : time.timezone; |
1319 | 1323 | case 'T':
|
1320 | 1324 | return ampmName.charAt(0).toUpperCase();
|
1321 | 1325 | case 'TT':
|
|
1796 | 1800 | millisec: isIn(tf,'l'),
|
1797 | 1801 | microsec: isIn(tf,'c'),
|
1798 | 1802 | timezone: isIn(tf,'z'),
|
1799 |
| - ampm: isIn('t') && isIn(timeFormat,'h') |
| 1803 | + ampm: isIn('t') && isIn(timeFormat,'h'), |
| 1804 | + iso8601: isIn(timeFormat, 'Z') |
1800 | 1805 | };
|
1801 | 1806 | };
|
1802 | 1807 |
|
|
1897 | 1902 | var selectLocalTimezone = function(tp_inst, date) {
|
1898 | 1903 | if (tp_inst && tp_inst.timezone_select) {
|
1899 | 1904 | var now = typeof date !== 'undefined' ? date : new Date();
|
1900 |
| - var tzoffset = $.timepicker.timezoneOffsetString(now.getTimezoneOffset()); |
1901 |
| - if (tp_inst._defaults.timezoneIso8601) { |
1902 |
| - tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3); |
1903 |
| - } |
| 1905 | + var tzoffset = $.timepicker.timezoneOffsetString(now.getTimezoneOffset(), tp_inst.support.iso8601); |
1904 | 1906 | tp_inst.timezone_select.val(tzoffset);
|
1905 | 1907 | }
|
1906 | 1908 | };
|
|
1913 | 1915 | /**
|
1914 | 1916 | * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
|
1915 | 1917 | * @param date
|
1916 |
| - * @param boolean if true formats in accordance to iso1806 "+12:45" |
| 1918 | + * @param boolean if true formats in accordance to iso8601 "+12:45" |
1917 | 1919 | * @return string
|
1918 | 1920 | */
|
1919 |
| - $.timepicker.timezoneOffsetString = function(tzMinutes, iso1806) { |
| 1921 | + $.timepicker.timezoneOffsetString = function(tzMinutes, iso8601) { |
1920 | 1922 | var off = tzMinutes * -1,
|
1921 | 1923 | minutes = off % 60,
|
1922 | 1924 | hours = (off - minutes) / 60,
|
1923 |
| - iso = iso1806? ':':'', |
| 1925 | + iso = iso8601? ':':'', |
1924 | 1926 | tz = (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + iso + ('0' + (minutes * 101).toString()).slice(-2);
|
1925 | 1927 |
|
1926 | 1928 | if(tz == '+00:00'){
|
|
1935 | 1937 | * @return number
|
1936 | 1938 | */
|
1937 | 1939 | $.timepicker.timezoneOffsetNumber = function(tzString) {
|
1938 |
| - tzString = tzString.replace(/(\:|z)/gi,''); // excuse any iso1806, end up with "+1245" |
| 1940 | + tzString = tzString.replace(/(\:|z)/gi,''); // excuse any iso8601, end up with "+1245" |
1939 | 1941 |
|
1940 | 1942 | if(!/^(\-|\+)\d{4}$/.test(tzString)){
|
1941 | 1943 | return 0;
|
|
0 commit comments