Skip to content

Commit a43ef3b

Browse files
change strict to parse
1 parent 0d7c569 commit a43ef3b

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

index.html

+23-3
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,19 @@ <h3>Time Field Options</h3>
220220
<dl class="defs">
221221

222222
<dt>controlType</dt>
223-
<dd><em>Default: 'slider'</em> - Whether to use 'slider' or 'select'. If 'slider' is unavailable through jQueryUI, 'select' will be used. For advanced usage you may pass an object which implements "create", "options", "value" methods to use controls other than sliders or selects. See the _controls property in the source code for more details.</dd>
223+
<dd><em>Default: 'slider'</em> - Whether to use 'slider' or 'select'. If 'slider' is unavailable through jQueryUI, 'select' will be used. For advanced usage you may pass an object which implements "create", "options", "value" methods to use controls other than sliders or selects. See the _controls property in the source code for more details.
224+
<pre>{
225+
create: function(tp_inst, obj, unit, val, min, max, step){
226+
// generate whatever controls you want here, just return obj
227+
},
228+
options: function(tp_inst, obj, unit, opts, val){
229+
// if val==undefined return the value, else return obj
230+
},
231+
value: function(tp_inst, obj, unit, val){
232+
// if val==undefined return the value, else return obj
233+
}
234+
}</pre>
235+
</dd>
224236

225237
<dt>showHour</dt>
226238
<dd><em>Default: true</em> - Whether to show the hour slider.</dd>
@@ -345,8 +357,16 @@ <h3>Other Options</h3>
345357
<dt>maxDateTime</dt>
346358
<dd><em>Default: null</em> - Date object of the maximum datetime allowed. Also Available as maxDate.</dd>
347359

348-
<dt>strict</dt>
349-
<dd><em>Default: true</em> - Requires the time to exactly match the timeFormat when parsing. False will attempt to allow Javascript Date() to parse the time string.</dd>
360+
<dt>parse</dt>
361+
<dd><em>Default: 'strict'</em> - How to parse the time string. Two methods are provided: 'strict' which must match the timeFormat exactly, and 'loose' which uses javascript's new Date(timeString) to guess the time. You may also pass in a function(timeFormat, timeString, options) to handle the parsing yourself, returning a simple object:
362+
<pre>{
363+
hour: 19,
364+
minutes: 10,
365+
seconds: 23,
366+
millisec: 45,
367+
timezone: '-0400'
368+
}</pre>
369+
</dd>
350370
</dl>
351371

352372
</div>

jquery-ui-timepicker-addon.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
sliderAccessArgs: null,
106106
controlType: 'slider',
107107
defaultValue: null,
108-
strict: true
108+
parse: 'strict'
109109
};
110110
$.extend(this._defaults, this.regional['']);
111111
}
@@ -1142,7 +1142,10 @@
11421142
return false;
11431143
}; // end looseParse
11441144

1145-
if(o.strict !== undefined && o.strict === false){
1145+
if(typeof o.parse === "function"){
1146+
return o.parse(timeFormat, timeString, o)
1147+
}
1148+
if(o.parse === 'loose'){
11461149
return looseParse(timeFormat, timeString, o);
11471150
}
11481151
return strictParse(timeFormat, timeString, o);

0 commit comments

Comments
 (0)