You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is simple. When you use swedish time format 'kl' h:mm:ss and choose the time for instance 15:30:45, you will get the correct text value kl 15:30:45. Buit when you request a Date object (by calling $("#your_id").datetimepicker("getDate") method), you will get the Date object with time set to midnight (00:00:00). The problem is with the l control character in timeFormat options. Even if it is enclosed by quotes, parsing of such text is failing (and then no time is datermined and applied to the output Date object).
Problem lays in $.datepicker.parseTime function, which is not counting with literars enclosed by quotes. The problem is in regular expression in getFormatPositions inner function and also right after it when the timeFormat is transformed to regstr regular expression variable. Here is the code snippet, which is solving such issue (we're already using this modification for our project, because we need to have this working):
// figure out position of time elements.. cause js cant do named capturesvargetFormatPositions=function(timeFormat){varfinds=timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z|'.*?')/g),orders={h: -1,m: -1,s: -1,l: -1,t: -1,z: -1};if(finds){for(vari=0;i<finds.length;i++){if(orders[finds[i].toString().charAt(0)]==-1){orders[finds[i].toString().charAt(0)]=i+1;}}}returnorders;};varo=extendRemove(extendRemove({},$.timepicker._defaults),options||{});varregstr='^'+timeFormat.toString().replace(/(hh?|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g,function(match){switch(match.toLowerCase()){case'h':
case'hh':
return'(\\d?\\d)';case'm':
case'mm':
return'(\\d?\\d)';case's':
case'ss':
return'(\\d?\\d)';case'l':
return'(\\d?\\d?\\d)';case'z':
return'(z|[-+]\\d\\d:?\\d\\d|\\S+)?';case't':
case'tt':
returngetPatternAmpm(o.amNames,o.pmNames);default: // literar escaped in quotesreturn'('+match.replace(/\'/g,"").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g,function(m){return"\\"+m;})+')?';}}).replace(/\s/g,'\\s?')+o.timeSuffix+'$',order=getFormatPositions(timeFormat),ampm='',treg;treg=timeString.match(newRegExp(regstr,'i'));
Note: This solution is working only for literars enclosed by single quotes. It will not work for double quotes, becuse it shouldn't. See #465 issue for more details about quotes.
The text was updated successfully, but these errors were encountered:
Master version: 1.0.4
The issue is simple. When you use swedish time format 'kl' h:mm:ss and choose the time for instance 15:30:45, you will get the correct text value kl 15:30:45. Buit when you request a Date object (by calling $("#your_id").datetimepicker("getDate") method), you will get the Date object with time set to midnight (00:00:00). The problem is with the l control character in timeFormat options. Even if it is enclosed by quotes, parsing of such text is failing (and then no time is datermined and applied to the output Date object).
Problem lays in $.datepicker.parseTime function, which is not counting with literars enclosed by quotes. The problem is in regular expression in getFormatPositions inner function and also right after it when the timeFormat is transformed to regstr regular expression variable. Here is the code snippet, which is solving such issue (we're already using this modification for our project, because we need to have this working):
Note: This solution is working only for literars enclosed by single quotes. It will not work for double quotes, becuse it shouldn't. See #465 issue for more details about quotes.
The text was updated successfully, but these errors were encountered: