Hi,
I use the TimeView with a custom collection according to http://demos.telerik.com/aspnet-ajax/calendar/examples/datetimepicker/customcollection/defaultcs.aspx
Markup:
Script:
I use the TimeView with a custom collection according to http://demos.telerik.com/aspnet-ajax/calendar/examples/datetimepicker/customcollection/defaultcs.aspx
The custom collection is needed because the user should be able to select the time 23:59. But this does not work in other timezones: when not in the same timezone as UTC time, the picker "results" in another time than the selected. For example, if I pick 23:59, the time in the textbox results in 21:59 for my timezone. Every other time is ok - for example if I pick 12:00, it picks the right one. It seems that the property UseClientTimeOffset does not work for this particular time 23:59?
public
static
void
SetA4DValidTimeView(
this
RadTimeView timeView)
{
ArrayList arrayList =
new
ArrayList();
arrayList.Add(
new
DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 0));
for
(
int
hour = 1; hour < 24; hour++)
arrayList.Add(DateTime.UtcNow.Date.AddHours(hour));
timeView.DataList.DataSource = arrayList;
}
I created a class in order to use the UseClientTimeOffset property.
public
class
A4DRadTimeView: RadTimeView
{
public
A4DRadTimeView()
{
this
.SetA4DValidTimeView();
base
.UseClientTimeOffset =
true
;
}
}
Markup:
<
MCN:A4DRadDateTimePicker
runat
=
"server"
ID
=
"dateTimePickerDepartureTime"
Enabled
=
"false"
CssClass
=
"labelregular"
Calendar-CultureInfo
=
"en-US"
SharedTimeViewID
=
"A4DSharedTimeView"
>
<
DateInput
EmptyMessage
=
"____-__-__ __:__"
>
<
ClientEvents
OnValueChanged
=
"inputValueChanged"
/>
</
DateInput
>
</
MCN:A4DRadDateTimePicker
>
<
MCN:A4DRadTimeView
ID
=
"A4DSharedTimeView"
runat
=
"server"
></
MCN:A4DRadTimeView
>
Script:
function
inputValueChanged(sender, args) {
var
newValue = args.get_newValue();
var
dateFormat = sender.get_dateFormat();
var
date = args.get_newDate();
if
(date !=
null
) {
if
(newValue.indexOf(sender.get_dateFormatInfo().TimeSeparator) < 0 &&
date.getHours() == 0 &&
date.getMinutes() == 0 &&
date.getSeconds() == 0) {
date.setHours(0);
date.setMinutes(01);
sender.set_value(date.format(dateFormat));
}
}
}