summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.html8
-rw-r--r--jquery-ui-timepicker-addon.js24
2 files changed, 21 insertions, 11 deletions
diff --git a/index.html b/index.html
index 1d728fd..13755ad 100644
--- a/index.html
+++ b/index.html
@@ -368,6 +368,7 @@
<dt>tt</dt><dd>am or pm for AM/PM</dd>
<dt>TT</dt><dd>AM or PM for AM/PM</dd>
<dt>z</dt><dd>Timezone as defined by timezoneList</dd>
+ <dt>'...'</dt><dd>Literal text (Uses single quotes)</dd>
</dl>
<p>Formats are used in the following ways:</p>
@@ -377,6 +378,8 @@
<li>$.datepicker.formatTime(format, timeObj, options) utility method</li>
<li>$.datepicker.parseTime(format, timeStr, options) utility method</li>
</ul>
+
+ <p>For help with formatting the date portion, visit the datepicker documentation for <a href="http://docs.jquery.com/UI/Datepicker/formatDate" title="jQuery UI Datepicker Formatting">formatting dates</a>.</p>
</div>
<!-- ############################################################################# -->
@@ -437,7 +440,8 @@ $.timepicker.regional['ru'] = {
timeFormat: 'hh:mm tt',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
- ampm: false
+ ampm: false,
+ isRTL: false
};
$.timepicker.setDefaults($.timepicker.regional['ru']);
</pre>
@@ -493,7 +497,7 @@ $('#basic_example_2').timepicker();
</div>
<pre>
$('#basic_example_3').datetimepicker({
- timeFormat: "h:m",
+ timeFormat: "h:m t",
ampm: true
});
</pre>
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js
index 80630a3..72da9ea 100644
--- a/jquery-ui-timepicker-addon.js
+++ b/jquery-ui-timepicker-addon.js
@@ -997,7 +997,7 @@
// figure out position of time elements.. cause js cant do named captures
var getFormatPositions = function(timeFormat) {
- var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),
+ var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z|'.*?')/g),
orders = {
h: -1,
m: -1,
@@ -1020,14 +1020,20 @@
var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {});
var regstr = '^' + timeFormat.toString()
- .replace(/h{1,2}/ig, '(\\d?\\d)')
- .replace(/m{1,2}/ig, '(\\d?\\d)')
- .replace(/s{1,2}/ig, '(\\d?\\d)')
- .replace(/l{1}/ig, '(\\d?\\d?\\d)')
- .replace(/t{1,2}/ig, getPatternAmpm(o.amNames, o.pmNames))
- .replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d|\\S+)?')
- .replace(/\s/g, '\\s?') +
- o.timeSuffix + '$',
+ .replace(/(hh?|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) {
+ switch (match.charAt(0).toLowerCase()) {
+ case 'h': return '(\\d?\\d)';
+ case 'm': return '(\\d?\\d)';
+ case 's': return '(\\d?\\d)';
+ case 'l': return '(\\d?\\d?\\d)';
+ case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
+ case 't': return getPatternAmpm(o.amNames, o.pmNames);
+ default: // literal escaped in quotes
+ return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
+ }
+ })
+ .replace(/\s/g, '\\s?') +
+ o.timeSuffix + '$',
order = getFormatPositions(timeFormat),
ampm = '',
treg;