When a DatePicker defines both a format option and parseFormat(s) values, the control doesn't convert the date to the format specified in option.format when it is the same date.
To reproduce use the following sample script and manually modify the datepicker to be 2012/08/21
<input id="sampleDate" name="sampleDate" value="21 Aug 2012" />
<input id="showInputValue" type="button" />
<div id="output"></div>
jQuery(
function
(){
jQuery(
"#sampleDate"
).kendoDatePicker({
"format"
:
"dd MMM yyyy"
,
"parseFormats"
:[
"yyyy/MM/dd"
]});
$(
"#showInputValue"
).click(
function
()
{
$(
"#output"
).append(
"<div>"
+ $(
"#sampleDate"
).val() +
"</div>"
);
}
);
});
Yann
7 Answers, 1 is accepted
I could not reproduce the depicted issue with the official release of Kendo UI (2012.2.710). Check this jsFiddle demo and let me know if I am missing something.
Georgi Krustev
the Telerik team

I can reproduce it on your demo.
Simply type in "2012/08/21" and tab out from the control.
The value will still be "2012/08/21" while it should be back to 21 Aug 2012
I am not sure that we have a demo which shows the "parseFormats" functionality. Could you please point me to the demo, which you are using? I will also suggest you modify the jsBin demo, which I send you. Thus it will be easer for more me to review the case.
As a side note, the DatePicker will not change the input if it is not a valid date. In other words if the end-user enters not valid date, for instance, "not valid" or "21 Aug 2012" when the expected one is "21/08/2012", then the DatePicker will not update the input, but its value will be null.
Georgi Krustev
the Telerik team

I have read the description of parseFormats from the official documentation : http://docs.kendoui.com/api/web/datepicker
There is nothing to change to your demo. Understand that setting programatically the value will not reproduce the issue. You have to manually set a value using the keyboard as would an end user.
I am not talking about setting an incorrect value.
The demo has
$(
"#sampleDate"
).kendoDatePicker({
format:
"dd MMM yyyy"
,
parseFormats: [
"yyyy/MM/dd"
]
});
To my knowledge, from the documentation it means:
the format stored in the input will be dd MMM yyyy .
The valid format that will be parsed are yyyy/MM/dd and dd MMM yyyy ( as the doc says : Note that value of the format option is always used )
Now, if you manually set a value 2012/08/22 and tab out, the behavior is as intended, that is the datepicker will display and store 22 Aug 2012.
But if you set the value to be the same than the current value of the datepicker , it doesn't change the format, ie set 2012/08/21 (valid value again as it is in the format yyyy/MM/dd) when the date picker already has 21 Aug 2012, then as you tab out , the value remains 2012/08/21 instead of 21 Aug 2012.
Does it make more sense ?
Thank you for the explanation. I was able to observe the depicted issue. I confirm it as a bug, which will be addressed in the next internal build. As a gratitude for your involvement I have updated your Telerik points.
Georgi Krustev
the Telerik team

When will this bug fix be in official relase or how do I get a hold of it?
I have the same issue illustrated here:
http://jsfiddle.net/CXcky/
the first one works fine when putting shorter year it expands to longer year.
On the second one however, if I put a long year in, it slices it off, but it takes the first two digits so 2012 becomes 20 which then gets interpreted as 2020.
Here is a quote of the bug report opened on the same subject:
The format property is extended with the parseFormats array and thus the result will be:
[
"MM/dd/yy"
,
"MM/dd/yyyy"
]
We will further investigate the case and will try to improve current behavior of parseFormats.
I will ask you to continue our conversation in only one thread in order to avoid any duplications.
Greetings,
Georgi Krustev
the Telerik team