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

MinDate / MaxDate not working properly

9 Answers 34 Views
TimePicker
This is a migrated thread and some comments may be shown as answers.
Veronique
Top achievements
Rank 1
Veronique asked on 09 Sep 2016, 06:35 PM

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);
    }      
}

9 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 14 Sep 2016, 12:06 PM
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.
0
Veronique
Top achievements
Rank 1
answered on 14 Sep 2016, 12:38 PM

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);

0
Maria Ilieva
Telerik team
answered on 19 Sep 2016, 10:25 AM
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.
0
Veronique
Top achievements
Rank 1
answered on 21 Sep 2016, 05:46 PM

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);

0
Maria Ilieva
Telerik team
answered on 26 Sep 2016, 02:20 PM
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.
0
Veronique
Top achievements
Rank 1
answered on 26 Sep 2016, 03:07 PM

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 ? 

0
Maria Ilieva
Telerik team
answered on 29 Sep 2016, 02:48 PM
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.
0
Veronique
Top achievements
Rank 1
answered on 29 Sep 2016, 02:50 PM
Thanks.  If you want you can start with the code I posted above.
0
Maria Ilieva
Telerik team
answered on 04 Oct 2016, 03:17 PM
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.
Tags
TimePicker
Asked by
Veronique
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Veronique
Top achievements
Rank 1
Share this question
or