Skip to content

Commit b830133

Browse files
Merge branch 'dev'
2 parents d47cb6f + 958f4e3 commit b830133

File tree

2 files changed

+33
-42
lines changed

2 files changed

+33
-42
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ <h3>Requirements</h3>
118118

119119

120120
<h3>Version</h3>
121-
<p>Version 1.0.3</p>
121+
<p>Version 1.0.4</p>
122122

123123
<p>Last updated on 09/15/2012</p>
124124
<p>jQuery Timepicker Addon is currently available for use in all personal or commercial projects under both MIT and GPL licenses. This means that you can choose the license that best suits your project, and use it accordingly. </p>

jquery-ui-timepicker-addon.js

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* jQuery timepicker addon
33
* By: Trent Richardson [http://trentrichardson.com]
4-
* Version 1.0.3
5-
* Last Modified: 09/15/2012
4+
* Version 1.0.4
5+
* Last Modified: 09/29/2012
66
*
77
* Copyright 2012 Trent Richardson
88
* You may use this project under MIT or GPL licenses.
@@ -35,7 +35,7 @@
3535
*/
3636
$.extend($.ui, {
3737
timepicker: {
38-
version: "1.0.3"
38+
version: "1.0.4"
3939
}
4040
});
4141

@@ -1149,7 +1149,7 @@
11491149
case 'l':
11501150
return ('00' + time.millisec).slice(-3);
11511151
case 'z':
1152-
return time.timezone;
1152+
return time.timezone === null? options.defaultTimezone : time.timezone;
11531153
case 't':
11541154
case 'tt':
11551155
if (options.ampm) {
@@ -1328,37 +1328,16 @@
13281328
$.datepicker._setTime = function(inst, date) {
13291329
var tp_inst = this._get(inst, 'timepicker');
13301330
if (tp_inst) {
1331-
var defaults = tp_inst._defaults,
1332-
// calling _setTime with no date sets time to defaults
1333-
hour = date ? date.getHours() : defaults.hour,
1334-
minute = date ? date.getMinutes() : defaults.minute,
1335-
second = date ? date.getSeconds() : defaults.second,
1336-
millisec = date ? date.getMilliseconds() : defaults.millisec;
1337-
//check if within min/max times..
1338-
// correct check if within min/max times.
1339-
// Rewritten by Scott A. Woodward
1340-
var hourEq = hour === defaults.hourMin,
1341-
minuteEq = minute === defaults.minuteMin,
1342-
secondEq = second === defaults.secondMin;
1343-
var reset = false;
1344-
if (hour < defaults.hourMin || hour > defaults.hourMax) reset = true;
1345-
else if ((minute < defaults.minuteMin || minute > defaults.minuteMax) && hourEq) reset = true;
1346-
else if ((second < defaults.secondMin || second > defaults.secondMax) && hourEq && minuteEq) reset = true;
1347-
else if ((millisec < defaults.millisecMin || millisec > defaults.millisecMax) && hourEq && minuteEq && secondEq) reset = true;
1348-
if (reset) {
1349-
hour = defaults.hourMin;
1350-
minute = defaults.minuteMin;
1351-
second = defaults.secondMin;
1352-
millisec = defaults.millisecMin;
1353-
}
1354-
tp_inst.hour = hour;
1355-
tp_inst.minute = minute;
1356-
tp_inst.second = second;
1357-
tp_inst.millisec = millisec;
1358-
if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
1359-
if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
1360-
if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
1361-
if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
1331+
var defaults = tp_inst._defaults;
1332+
1333+
// calling _setTime with no date sets time to defaults
1334+
tp_inst.hour = date ? date.getHours() : defaults.hour;
1335+
tp_inst.minute = date ? date.getMinutes() : defaults.minute;
1336+
tp_inst.second = date ? date.getSeconds() : defaults.second;
1337+
tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
1338+
1339+
//check if within min/max times..
1340+
tp_inst._limitMinMaxDateTime(inst, true);
13621341

13631342
tp_inst._onTimeChange();
13641343
tp_inst._updateDateTime(inst);
@@ -1426,7 +1405,11 @@
14261405
var tp_inst = this._get(inst, 'timepicker');
14271406

14281407
if (tp_inst) {
1429-
//this._setDateFromField(inst, noDefault); // This keeps setting to today when it shouldn't
1408+
// if it hasn't yet been defined, grab from field
1409+
if(inst.lastVal === undefined){
1410+
this._setDateFromField(inst, noDefault);
1411+
}
1412+
14301413
var date = this._getDate(inst);
14311414
if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
14321415
date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
@@ -1442,8 +1425,16 @@
14421425
*/
14431426
$.datepicker._base_parseDate = $.datepicker.parseDate;
14441427
$.datepicker.parseDate = function(format, value, settings) {
1445-
var splitRes = splitDateTime(format, value, settings);
1446-
return $.datepicker._base_parseDate(format, splitRes[0], settings);
1428+
var date;
1429+
try {
1430+
date = this._base_parseDate(format, value, settings);
1431+
} catch (err) {
1432+
// Hack! The error message ends with a colon, a space, and
1433+
// the "extra" characters. We rely on that instead of
1434+
// attempting to perfectly reproduce the parsing algorithm.
1435+
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1436+
}
1437+
return date;
14471438
};
14481439

14491440
/*
@@ -1568,10 +1559,10 @@
15681559
timePartsLen = timeParts.length;
15691560
}
15701561

1571-
if (allPartsLen > 0) {
1562+
if (allPartsLen > 1) {
15721563
return [
15731564
allParts.splice(0,allPartsLen-timePartsLen).join(separator),
1574-
allParts.splice(timePartsLen*-1).join(separator)
1565+
allParts.splice(0,timePartsLen).join(separator)
15751566
];
15761567
}
15771568

@@ -1759,6 +1750,6 @@
17591750
/*
17601751
* Keep up with the version
17611752
*/
1762-
$.timepicker.version = "1.0.3";
1753+
$.timepicker.version = "1.0.4";
17631754

17641755
})(jQuery);

0 commit comments

Comments
 (0)