Skip to content

Commit c9ff800

Browse files
fixed regex to parse time and fixed timeOnly bug
1 parent 1dd304b commit c9ff800

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
if (!this.defaults.timeOnly) {
7878
//the time should come after x number of characters and a space. x = at least the length of text specified by the date format
79-
regstr = '.{' + this.defaults.timeFormat.length + ',}\\s+' + regstr;
79+
regstr = '.{' + this.defaults.dateFormat.length + ',}\\s+' + regstr;
8080
}
8181

8282
var order = this.getFormatPositions();
@@ -306,7 +306,10 @@
306306
var formattedDateTime = this.formattedDate;
307307
var timeAvailable = dt !== null && tp_inst.timeDefined;
308308

309-
if (this.defaults.timeOnly !== true && (this.defaults.alwaysSetTime || timeAvailable)) {
309+
if(this.defaults.timeOnly === true){
310+
formattedDateTime = this.formattedTime;
311+
}
312+
else if (this.defaults.timeOnly !== true && (this.defaults.alwaysSetTime || timeAvailable)) {
310313
formattedDateTime += ' ' + this.formattedTime;
311314
}
312315

@@ -315,9 +318,9 @@
315318
},
316319

317320
setDefaults: function(settings) {
318-
extendRemove(this.defaults, settings || {});
319-
return this;
320-
}
321+
extendRemove(this.defaults, settings || {});
322+
return this;
323+
}
321324
};
322325

323326
//########################################################################

0 commit comments

Comments
 (0)