outofrang datetimepicker

0 Answers 68 Views
Calendar, DateTimePicker, TimePicker and Clock DateTimePicker
ebrahim
Top achievements
Rank 1
Iron
Iron
ebrahim asked on 08 Dec 2021, 01:35 PM

hi

how handling error

System.ArgumentOutOfRangeException: 'Day must be between 1 and 29 for month 12.

Parameter name: day'

 

i try handling in key peress but show error

my cod is

 

                                        

public static bool CheckIsLeapYear(DateTime date)
        {
            PersianCalendar pc = new PersianCalendar();
            int year, day;
            year = pc.GetYear(date);
            day = pc.GetDayOfMonth(date);
            bool result = false;
            bool isleapyear = false;
            isleapyear = pc.IsLeapYear(year);
            if (isleapyear!=true && day>29)
            {
                result= true;


            }
            return result;



        }

 

----------------------------------------------------------------------------------------------------

 

 

 private void radDateTimePickerDateOfBirth_KeyDown(object sender, KeyEventArgs e)
        {
           

            
           
                if (CheckIsLeapYear(radDateTimePickerDateOfBirth.Value))
                {


       
                radDateTimePickerDateOfBirth.Value = DateTime.Now;
                 
                }
            }


Dess | Tech Support Engineer, Principal
Telerik team
commented on 09 Dec 2021, 11:14 AM

Hello, Ebrahim, 

Following the provided information, I was unable to reproduce the issue you are facing with the latest version of the Telerik UI for WinForms suite. Could you please specify what Telerik version you are using? 

According to the provided code snippet, it seems that you are using a PersianCalendar. Please have in mind that there is a known issue in the .NET Framework considering the "fa-IR" culture. Please refer to the following forum post:
https://www.telerik.com/forums/persian-culture-bug-in-rad-datepicker 

I have attached my sample project. Please give it a try and see how it works on your end. Am I missing something? Could you please specify the exact steps how to reproduce the problem? Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ebrahim
Top achievements
Rank 1
Iron
Iron
commented on 10 Dec 2021, 06:46 AM

hi

my telerik version is WinForms_2021_3_1109

I have no problem with the Persianization of the calendar and it works properly
But this error occurs when the calendar is on a non-leap year and it is also the twelfth month and the user changes the day to thirty with the keyboard. But this error does not occur with the arrow keys.
I am filming this incident
Thankful
Dess | Tech Support Engineer, Principal
Telerik team
commented on 10 Dec 2021, 10:49 AM

The provided videos are greatly appreciated. Actually, it is related to converting a DateTime to PersianCalendar:

After investigating further, I can confirm that this case can be handled in RadDateTimePicker.

I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

Feel free to use the suggested solution in the referred item.

No answers yet. Maybe you can help?

Tags
Calendar, DateTimePicker, TimePicker and Clock DateTimePicker
Asked by
ebrahim
Top achievements
Rank 1
Iron
Iron
Share this question
or