|
1833 | 1833 | * Returns {dateString: dateString, timeString: timeString}
|
1834 | 1834 | */
|
1835 | 1835 | var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
|
1836 |
| - try { |
1837 |
| - // The idea is to get the number separator occurrences in datetime and the time format requested (since time has |
1838 |
| - // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split. |
1839 |
| - var separator = computeEffectiveSetting(timeSettings, 'separator'), |
1840 |
| - format = computeEffectiveSetting(timeSettings, 'timeFormat'), |
1841 |
| - timeParts = format.split(separator), // how many occurrences of separator may be in our format? |
1842 |
| - timePartsLen = timeParts.length, |
1843 |
| - allParts = dateTimeString.split(separator), |
1844 |
| - allPartsLen = allParts.length; |
1845 |
| - |
1846 |
| - if (allPartsLen > 1) { |
1847 |
| - return { |
1848 |
| - dateString: allParts.splice(0,allPartsLen-timePartsLen).join(separator), |
1849 |
| - timeString: allParts.splice(0,timePartsLen).join(separator) |
1850 |
| - }; |
1851 |
| - } |
1852 |
| - |
1853 |
| - } catch (err) { |
1854 |
| - $.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' + |
1855 |
| - "\nthrown error: " + err + |
1856 |
| - "\ndateTimeString" + dateTimeString + |
1857 |
| - "\ndateFormat = " + dateFormat + |
1858 |
| - "\nseparator = " + timeSettings.separator + |
1859 |
| - "\ntimeFormat = " + timeSettings.timeFormat); |
1860 |
| - |
1861 |
| - if (err.indexOf(":") >= 0) { |
1862 |
| - // Hack! The error message ends with a colon, a space, and |
1863 |
| - // the "extra" characters. We rely on that instead of |
1864 |
| - // attempting to perfectly reproduce the parsing algorithm. |
1865 |
| - var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2); |
1866 |
| - |
1867 |
| - return { |
1868 |
| - dateString: $.trim(dateTimeString.substring(0, dateStringLength)), |
1869 |
| - timeString: $.trim(dateTimeString.substring(dateStringLength)) |
1870 |
| - }; |
1871 |
| - |
1872 |
| - } else { |
1873 |
| - throw err; |
1874 |
| - } |
| 1836 | + // The idea is to get the number separator occurrences in datetime and the time format requested (since time has |
| 1837 | + // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split. |
| 1838 | + var separator = computeEffectiveSetting(timeSettings, 'separator'), |
| 1839 | + format = computeEffectiveSetting(timeSettings, 'timeFormat'), |
| 1840 | + timeParts = format.split(separator), // how many occurrences of separator may be in our format? |
| 1841 | + timePartsLen = timeParts.length, |
| 1842 | + allParts = dateTimeString.split(separator), |
| 1843 | + allPartsLen = allParts.length; |
| 1844 | + |
| 1845 | + if (allPartsLen > 1) { |
| 1846 | + return { |
| 1847 | + dateString: allParts.splice(0,allPartsLen-timePartsLen).join(separator), |
| 1848 | + timeString: allParts.splice(0,timePartsLen).join(separator) |
| 1849 | + }; |
1875 | 1850 | }
|
| 1851 | + |
1876 | 1852 | return {
|
1877 | 1853 | dateString: dateTimeString,
|
1878 | 1854 | timeString: ''
|
|
0 commit comments