1
1
/*
2
2
* jQuery timepicker addon
3
3
* 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
6
6
*
7
7
* Copyright 2010 Trent Richardson
8
8
* Dual licensed under the MIT and GPL licenses.
@@ -148,10 +148,9 @@ $.extend(Timepicker.prototype, {
148
148
_addTimePicker : function ( ) {
149
149
var currDT = ( this . $altInput ) ?
150
150
this . $input . val ( ) + ' ' + this . $altInput . val ( ) :
151
- this . $input . val ( ) ,
152
- parsedDT = this . _parseTime ( currDT ) ;
151
+ this . $input . val ( ) ;
153
152
154
- this . timeDefined = ( parsedDT ) ? true : false ;
153
+ this . timeDefined = this . _parseTime ( currDT ) ;
155
154
this . _injectTimePicker ( ) ;
156
155
} ,
157
156
@@ -165,9 +164,8 @@ $.extend(Timepicker.prototype, {
165
164
. replace ( / s { 1 , 2 } / ig, '(\\d?\\d)' )
166
165
. replace ( / t { 1 , 2 } / ig, '(am|pm|a|p)?' )
167
166
. replace ( / \s / g, '\\s?' ) + '$' ,
168
-
169
- treg = timeString . match ( new RegExp ( regstr , 'i' ) ) ,
170
- order = this . _getFormatPositions ( ) ;
167
+ order = this . _getFormatPositions ( ) ,
168
+ treg ;
171
169
172
170
if ( withDate || ! this . _defaults . timeOnly ) {
173
171
// the time should come after x number of characters and a space.
@@ -176,6 +174,8 @@ $.extend(Timepicker.prototype, {
176
174
regstr = '.{' + dp_dateFormat . length + ',}\\s+' + regstr ;
177
175
}
178
176
177
+ treg = timeString . match ( new RegExp ( regstr , 'i' ) ) ;
178
+
179
179
if ( treg ) {
180
180
if ( order . t !== - 1 )
181
181
this . ampm = ( ( treg [ order . t ] === undefined || treg [ order . t ] . length === 0 ) ?
@@ -187,12 +187,15 @@ $.extend(Timepicker.prototype, {
187
187
this . hour = 0 ; // 12am = 0 hour
188
188
else if ( this . ampm == 'PM' && treg [ order . h ] != '12' )
189
189
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 ] ) ;
191
191
}
192
192
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 ;
196
199
} ,
197
200
198
201
//########################################################################
0 commit comments