This is a migrated thread and some comments may be shown as answers.

ParseDateTimeValue problems

9 Answers 138 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Tomas
Top achievements
Rank 1
Tomas asked on 26 Oct 2010, 11:39 AM

Hi!

I'm having trouble with how the RadDateTimePicker parses the datetime string.
I have the culture set to "sv-FI" and that culture has the following ShortDatePattern: "d.M.yyyy".
The RadDateTimePicker's DisplayFormat is set to Short.

I made two test's with two different dates and here are the results that was displayed in the ToolTip.

Test 1:
26 => 26.10.2010 (OK)

26.1 => Error (Should have been 26.1.2010)
26.10 => Error (Should have been 26.10.2010)

26.10.2 => 26.10.2002 (OK, I think?)
26.10.20 => 26.10.2020 (OK, I think?)
26.10.201 => 26.10.0201 (not sure, maybe 26.10.2010 would have been better?)

Test 2:
4 => 4.10.2010 (OK)

4.1 => 1.4.2010 (Not ok, turns day and month around!)
4.10 => 10.4.2010 (Not ok, turns day and month around!)

4.10.2 => 4.10.2002 (OK, I think?)
4.10.20 => 4.10.2020 (OK, I think?)
4.10.201 => 4.10.0201 (not sure, maybe 4.10.2010 would have been better?)

I'm not sure about the result in some of the cases but at least when I entered d.M the parser shouldn't interpret it as M.d

Can you help me please?

Tomas

9 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 28 Oct 2010, 09:17 AM
Hi Tomas,

I am sorry for the misleading caused. Let me explain the parsing logic. The DateTImePicker removes all of the unnecessary information. Then it passes to the DateTime.TryParse system function, where the final result comes from. In case you are not satisfied with the retrieve date, use the ParseDateTimeValue event. There you have an access to the current entered string and you can put the desired date in the args.Result argument. Let me know if my explanation is not clear enough.

Best wishes,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tomas
Top achievements
Rank 1
answered on 28 Oct 2010, 01:41 PM

Hi Kaloyan,

Thank you for your reply. However I'm still a little bit confused as of why the DateTimePicker removes information about the current culture's shortdate pattern because I don't think this is "unnecessary information". In my case as the shortdate pattern is "d.M.yyyy" I think the characters after the first dot should be treated as "month", but in the testcase I supplied 4.10 => 10.4.2010 the parser for some reason treats the characters after the first dot as day and the character before the first dot as month.

Tomas

0
Kaloyan
Telerik team
answered on 03 Nov 2010, 10:46 AM
Hello Tomas,

The parser doesn't remove any information related to the date format. It is checking if some alphabetical symbols are at their places with the help of the regular expression and the result is passed to the DateTime.Parse function.

Kind regards,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tomas
Top achievements
Rank 1
answered on 03 Nov 2010, 11:44 AM

Hi Kaloyan,

So how would you solve my problem then? I understand that the logic has to support many different dateformats
but in my opinion it's clearly something wrong here. As the regex is able to locate the different parts of the string it should then be possible to send the parts in correct order accoring to the culture's dateformat to the DateTime.Parse method don't you think? The string "03.11" (November 3rd) should by no means turn into March 11th 2010.

Sorry for repeating myself over and over but I'm a little bit stuck right now.

Tomas

0
Henk
Top achievements
Rank 1
answered on 08 Nov 2010, 12:47 PM
Hi,

I have the same problem with dutch culture "nl-NL".
Is there a solution or workaround?

Kind Regards.
0
Kaloyan
Telerik team
answered on 09 Nov 2010, 10:35 AM
Hello Henk,

Thank you for the feedback and the suggestions. We will try to improve it in the next version of the control.

Regards,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tomas
Top achievements
Rank 1
answered on 14 Dec 2010, 04:18 PM
Hi Kaloyan,

I noticed something strange today. The parsing works as expected on my new Windows 7 machine. First I thought you had made some changes to the 2010 Q3 release. But then I started my old XP machine but there the problem still exists.

So I did some testing and this is what I've found so far:
Windows XP (32-bit) IE8 => not working
Windows Vista (32-bit) IE8 => not working
Windows 7 (64-bit) IE8 => working

I'm not sure anymore if this is related to Telerik or if this is a problem in Silverlight.

Henk can you please try on different Windows versions as well?

Tomas
0
Henk
Top achievements
Rank 1
answered on 15 Dec 2010, 04:43 PM
Hello,

I can now confirm the following:

Windows Vista (32-bit) IE8 => not working

I will try the other versions as well.
0
Accepted
Boyan
Telerik team
answered on 20 Dec 2010, 10:35 AM
Hello Guys,

Thanks for reporting the issue. We were able to reproduce the problem. This is a very strange problem as the parser should not care of the OS. I have entered the bug in our PITS. You can follow its progress here: http://www.telerik.com/support/pits.aspx#/public/silverlight/4385

 Thank you once again for the cooperation. I have updated your telerik points.


All the best,
Boyan
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
DateTimePicker
Asked by
Tomas
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Tomas
Top achievements
Rank 1
Henk
Top achievements
Rank 1
Boyan
Telerik team
Share this question
or