Skip to content

Commit 11a2545

Browse files
committed
Refactor the effective setting computations out of splitDateTime()
1 parent 5109082 commit 11a2545

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,10 @@
18231823
return String(hour);
18241824
};
18251825

1826+
var computeEffectiveSetting = function (settings, property) {
1827+
return settings && settings[property] ? settings[property] : $.timepicker._defaults[property];
1828+
};
1829+
18261830
/*
18271831
* Splits datetime string into date and time substrings.
18281832
* Throws exception when date can't be parsed
@@ -1832,8 +1836,8 @@
18321836
try {
18331837
// The idea is to get the number separator occurrences in datetime and the time format requested (since time has
18341838
// fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
1835-
var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
1836-
format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
1839+
var separator = computeEffectiveSetting(timeSettings, 'separator'),
1840+
format = computeEffectiveSetting(timeSettings, 'timeFormat'),
18371841
timeParts = format.split(separator), // how many occurrences of separator may be in our format?
18381842
timePartsLen = timeParts.length,
18391843
allParts = dateTimeString.split(separator),

0 commit comments

Comments
 (0)