Skip to content

Commit 6ff9b7a

Browse files
Merge pull request trentrichardson#423 from Zauberfisch/dev
ENHANCEMENT: customizable alternative field
2 parents cad70fd + 643a324 commit 6ff9b7a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ function Timepicker() {
9191
alwaysSetTime: true,
9292
separator: ' ',
9393
altFieldTimeOnly: true,
94+
altSeparator: null,
95+
altTimeSuffix: null,
9496
showTimepicker: true,
9597
timezoneIso8601: false,
9698
timezoneList: null,
@@ -859,8 +861,21 @@ $.extend(Timepicker.prototype, {
859861
this.$altInput.val(this.formattedTime);
860862
this.$input.val(this.formattedDate);
861863
} else if(this.$altInput) {
862-
this.$altInput.val(formattedDateTime);
863864
this.$input.val(formattedDateTime);
865+
var altFormattedDateTime = '',
866+
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
867+
altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
868+
if (this._defaults.altFormat)
869+
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
870+
else
871+
altFormattedDateTime = this.formattedDate;
872+
if (altFormattedDateTime)
873+
altFormattedDateTime += altSeparator;
874+
if (this._defaults.altTimeFormat)
875+
altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
876+
else
877+
altFormattedDateTime += this.formattedTime + altTimeSuffix;
878+
this.$altInput.val(altFormattedDateTime);
864879
} else {
865880
this.$input.val(formattedDateTime);
866881
}

0 commit comments

Comments
 (0)