Skip to content

Commit e97d06e

Browse files
committed
Bugfixes for _parseDate()
1 parent 2781508 commit e97d06e

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 15 additions & 12 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 0.9.1
5-
* Last Modified: 12/2/2010
4+
* Version 0.9.1-dev
5+
* Last Modified: 12/5/2010 by Charles Phillips
66
*
77
* Copyright 2010 Trent Richardson
88
* Dual licensed under the MIT and GPL licenses.
@@ -148,10 +148,9 @@ $.extend(Timepicker.prototype, {
148148
_addTimePicker: function() {
149149
var currDT = (this.$altInput) ?
150150
this.$input.val() + ' ' + this.$altInput.val() :
151-
this.$input.val(),
152-
parsedDT = this._parseTime(currDT);
151+
this.$input.val();
153152

154-
this.timeDefined = (parsedDT) ? true : false;
153+
this.timeDefined = this._parseTime(currDT);
155154
this._injectTimePicker();
156155
},
157156

@@ -165,9 +164,8 @@ $.extend(Timepicker.prototype, {
165164
.replace(/s{1,2}/ig, '(\\d?\\d)')
166165
.replace(/t{1,2}/ig, '(am|pm|a|p)?')
167166
.replace(/\s/g, '\\s?') + '$',
168-
169-
treg = timeString.match(new RegExp(regstr, 'i')),
170-
order = this._getFormatPositions();
167+
order = this._getFormatPositions(),
168+
treg;
171169

172170
if (withDate || !this._defaults.timeOnly) {
173171
// the time should come after x number of characters and a space.
@@ -176,6 +174,8 @@ $.extend(Timepicker.prototype, {
176174
regstr = '.{' + dp_dateFormat.length + ',}\\s+' + regstr;
177175
}
178176

177+
treg = timeString.match(new RegExp(regstr, 'i'));
178+
179179
if (treg) {
180180
if (order.t !== -1)
181181
this.ampm = ((treg[order.t] === undefined || treg[order.t].length === 0) ?
@@ -187,12 +187,15 @@ $.extend(Timepicker.prototype, {
187187
this.hour = 0; // 12am = 0 hour
188188
else if (this.ampm == 'PM' && treg[order.h] != '12')
189189
this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
190-
else this.hour = treg[order.h];
190+
else this.hour = Number(treg[order.h]);
191191
}
192192

193-
if (order.m !== -1) this.minute = treg[order.m];
194-
if (order.s !== -1) this.second = treg[order.s];
195-
}
193+
if (order.m !== -1) this.minute = Number(treg[order.m]);
194+
if (order.s !== -1) this.second = Number(treg[order.s]);
195+
196+
return true;
197+
198+
} else return false;
196199
},
197200

198201
//########################################################################

0 commit comments

Comments
 (0)