Skip to content

Commit 89ac700

Browse files
authored
Update jquery-ui-timepicker-addon.js
1 parent f9415cd commit 89ac700

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

dist/jquery-ui-timepicker-addon.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
microsecGrid: 0,
9696
alwaysSetTime: true,
9797
separator: ' ',
98+
timePortionLocation: 'right',
9899
altFieldTimeOnly: true,
99100
altTimeFormat: null,
100101
altSeparator: null,
@@ -944,7 +945,11 @@
944945
if (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === false) {
945946
formattedDateTime = this.formattedTime;
946947
} else if ((this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) || (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === true)) {
947-
formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
948+
if (this._defaults.timePortionLocation === 'left') {
949+
formattedDateTime = this.formattedTime + this._defaults.timeSuffix + this._defaults.separator + formattedDateTime;
950+
} else {
951+
formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
952+
}
948953
}
949954

950955
this.formattedDateTime = formattedDateTime;
@@ -1983,17 +1988,25 @@
19831988
// The idea is to get the number separator occurrences in datetime and the time format requested (since time has
19841989
// fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
19851990
var separator = computeEffectiveSetting(timeSettings, 'separator'),
1991+
timePortionLocation = computeEffectiveSetting(timeSettings, 'timePortionLocation'),
19861992
format = computeEffectiveSetting(timeSettings, 'timeFormat'),
19871993
timeParts = format.split(separator), // how many occurrences of separator may be in our format?
19881994
timePartsLen = timeParts.length,
19891995
allParts = dateTimeString.split(separator),
19901996
allPartsLen = allParts.length;
19911997

19921998
if (allPartsLen > 1) {
1993-
return {
1994-
dateString: allParts.splice(0, allPartsLen - timePartsLen).join(separator),
1995-
timeString: allParts.splice(0, timePartsLen).join(separator)
1996-
};
1999+
if (timePortionLocation === 'left') {
2000+
return {
2001+
timeString: allParts.splice(0, allPartsLen - timePartsLen).join(separator),
2002+
dateString: allParts.splice(0, timePartsLen).join(separator)
2003+
};
2004+
} else {
2005+
return {
2006+
dateString: allParts.splice(0, allPartsLen - timePartsLen).join(separator),
2007+
timeString: allParts.splice(0, timePartsLen).join(separator)
2008+
};
2009+
}
19972010
}
19982011

19992012
return {

0 commit comments

Comments
 (0)