MinDate / MaxDate not working properly

10 posts, 0 answers
  1. Veronique
    Veronique avatar
    19 posts
    Member since:
    Jul 2011

    Posted 09 Sep Link to this post

    I have an issue with the minDate of the RadTimePicker.

    Problem #1

    My schedule is from 9AM to 2AM the next day. 
    I can show it properly in the time view picker.
    However, when I set the MinDate and the MaxDate I am unable to select a schedule after midnight even thoug it's in the MinDate and MaxDate range.
    Is there a workaround ?

    Problem #2
    The timeview picker won't show the last time if it's equal to EndTime. 
    The control will allow you to type it, but you don't see it in the timeview picker.
    I patched it by adding 1 second to the end time.  Is it a normal behavior ?

     

    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
            <telerik:RadTimePicker ID="TimePicker1" runat="server" TimeView-Interval="30"></telerik:RadTimePicker>
        </div>
        </form>
    </body>
    </html>

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            var startTime = new TimeSpan(9, 0, 0);
            var endTime = new TimeSpan(1, 2, 0, 0);
            TimePicker1.TimeView.StartTime = startTime;
            TimePicker1.TimeView.EndTime = endTime.Add(new TimeSpan(0, 0, 1)); // Patch.  Add 1 sec. to show the end time in the time view picker
            TimePicker1.MinDate = DateTime.Today.Add(startTime);
            TimePicker1.MaxDate = DateTime.Today.Add(endTime);
        }      
    }

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 14 Sep Link to this post

    Hello,

    Please try to set the end date as startTime + 17 hours and see if this makes a difrenace. In your case the time span set like(1, 2, 0, 0) is actually taking 12 (midnight) as value

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Veronique
    Veronique avatar
    19 posts
    Member since:
    Jul 2011

    Posted 14 Sep in reply to Maria Ilieva Link to this post

    Timespan set as (1, 2, 0, 0) is not midnight but 2 AM plus 1 day.

    https://msdn.microsoft.com/fr-fr/library/85ydwftb%28v=vs.110%29.aspx
    public TimeSpan( int days, int hours, int minutes, int seconds )

    You can confirm by setting the selected time to this value.  It really gives 2AM (see code below and attachement).
    Is there a solution to use StartTime and EndTime with an EndTime after midnight ? 
    - I can select it from the time picker,
    - I can set it server side
    - I can't write the value in the textbox

    var startTime = new TimeSpan(9, 0, 0);
    var endTime = new TimeSpan(1, 2, 0, 0);
    TimePicker1.TimeView.StartTime = startTime;
    TimePicker1.TimeView.EndTime = endTime.Add(new TimeSpan(0, 0, 1)); // Patch.  Add 1 sec. to show the end time in the time view picker
    TimePicker1.SelectedTime = endTime;
    TimePicker1.MinDate = DateTime.Today.Add(startTime);
    TimePicker1.MaxDate = DateTime.Today.Add(endTime);

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 Sep Link to this post

    Hello,

    Note that the TimePicker idea is to select time in one day and not to use it for more than one days. In your case you should use DateTimePicker to be able to select hours in different days.
    I hope this helps.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Veronique
    Veronique avatar
    19 posts
    Member since:
    Jul 2011

    Posted 21 Sep in reply to Maria Ilieva Link to this post

    I have the exact same issue with the DateTimePicker.
    The user must be able to select time after midnight as long as it is in the MinDate and MaxDate range.
    You can test the behavior with the TimePicker and the DateTimePicker. 
    It's not working properly.

    <telerik:RadTimePicker ID="TimePicker1" runat="server" TimeView-Interval="30"></telerik:RadTimePicker><br />
    <telerik:RadDateTimePicker ID="DateTimePicker1" runat="server" DateInput-DateFormat="HH:mm" TimeView-Interval="30" ></telerik:RadDateTimePicker>

    //With TimePicker
    var startTime = new TimeSpan(9, 0, 0);
    var endTime = new TimeSpan(1, 2, 0, 0);
    TimePicker1.TimeView.StartTime = startTime;
    TimePicker1.TimeView.EndTime = endTime.Add(new TimeSpan(0, 0, 1)); // Patch.  Add 1 sec. to show the end time in the time view picker
    TimePicker1.MinDate = DateTime.Today.Add(startTime);
    TimePicker1.MaxDate = DateTime.Today.Add(endTime);
     
    //With DateTimePicker
    DateTimePicker1.TimeView.StartTime = startTime;
    DateTimePicker1.TimeView.EndTime = endTime.Add(new TimeSpan(0, 0, 1)); // Patch.  Add 1 sec. to show the end time in the time view picker               
    DateTimePicker1.MinDate = DateTime.Today.Add(startTime);
    DateTimePicker1.MaxDate = DateTime.Today.Add(endTime);

  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 26 Sep Link to this post

    Hi,

    In this case the required functionality should be achieved by using two separate picker controls for start and end date. This way you will be bale to allow time frame separated in two different dates.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  8. Veronique
    Veronique avatar
    19 posts
    Member since:
    Jul 2011

    Posted 26 Sep Link to this post

    Maybe I don't understand you or maybe you don't understand me.  I'm not sure yet. 
    Is it possible to show me a working code sample where you are able to select a time after midnight and validate it using the built in validator ? 

  9. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 29 Sep Link to this post

    Hi Veronique,

     I will need some additional time to prepare a sample with your requirements. I will get back to you with the working code as soon as possible.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  10. Veronique
    Veronique avatar
    19 posts
    Member since:
    Jul 2011

    Posted 29 Sep in reply to Maria Ilieva Link to this post

    Thanks.  If you want you can start with the code I posted above.
  11. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Oct Link to this post

    Hi Veronique,

    This is to let you know that I'm still working on your case for assembling appropriate example the required scenario. The picker's parsing mechanism should be overwritten in order to achieve similar scenario and that is causing some problems with the control's functionality.

    I will get back to you as soon as possible.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017