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

Getting correct time clicked on using get_StartTime()

3 Answers 123 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
David Penny
Top achievements
Rank 2
David Penny asked on 23 Jul 2008, 02:06 PM

Hi,

I am using my own RadWindow to add and edit Appointments and that is all working fine.  However, when I pass the date and time double clicked to the RadWindow, it's an hour out.

The javascript:

var

start = formatDate(eventArgs.get_startTime());

seems to be returning 15:00 when I am clicking on 14:00.

Is this to do with UTC time and, if it is, how do I get it to consistently return the correct time?  I am assuming (maybe wrongly) that this is caused because I am in the UK and we are currently British Summer Time which is one hour offset. 

What can I do to make sure this is passed as the correct time I clicked on, Summer and Winter, and what happens if the app is used somewhere else in the world?

David Penny

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 24 Jul 2008, 08:16 AM
Hi David Penny,

I was unable to reproduce this behavior - correct time is returned regardless of the Time Zone.

Could you please provide more information about your case? For example, the JavaScript code involved in the event handling and the definition of the RadScheduler.

All the best,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
David Penny
Top achievements
Rank 2
answered on 25 Jul 2008, 11:03 AM
Hi,

The Javascript being used is:

            function AppointmentEditing(sender, eventArgs)  
            {  
                var apt = eventArgs.get_appointment();  
                //alert('Editing Event ' + apt.get_id());  
                var ow = window.radopen("EditEvent_RAD.aspx?Mode=Edit&UniqueID=" + apt.get_id(), "AdvancedForm");  
                eventArgs.set_cancel(true);  
                currentApt = null;  
                ow.Maximize();  
            }  
              
            function AppointmentInserting(sender, eventArgs)  
            {  
                var start = formatDate(eventArgs.get_startTime());  
                var isAllDay = eventArgs.get_isAllDay();  
                //alert("Start: " + start);      
                // New appointment  
                var ow = window.radopen("EditEvent_RAD.aspx?Mode=Insert&Start=" + start + "&IsAllDay=" + isAllDay, "AdvancedForm");              
                eventArgs.set_cancel(true);  
                ow.Maximize();  
            }                  
 
            function formatDate(date)  
            {  
                //alert("Format Date: " + date);  
 
                var year = padNumber(date.getFullYear(), 4);  
                var month = padNumber(date.getMonth() + 1, 2);  
                var day = padNumber(date.getDate(), 2);  
                var hour = padNumber(date.getHours(), 2);  
                var minute = padNumber(date.getMinutes(), 2);  
                  
                return year + '-' + month + '-' + day + ' ' + hour + ':' + minute;  
            }  
              
            function padNumber(number, totalDigits)   
            {   
                numbernumber = number.toString();   
                var padding = '';   
                if (totalDigits > number.length)   
                {   
                    for (i = 0; i < (totalDigits - number.length); i++)   
                    {   
                        padding += '0';   
                    }   
                }  
                  
                return padding + number.toString();   
            }  
              
            function refreshScheduler()  
            {  
                document.forms[0].submit();  
            }  
            --> 
        </script> 
 

I put an alert in to see what date was being passed to the FormatDate function and this value is also out by an hour - I double click in 14:00 but the raw date, before being passed to FormatDate is 15:00.

The RadScheduler definition is:

        <telerik:RadScheduler ID="RadScheduler1" runat="server" 
        StartEditingInAdvancedForm="False"   
        DataSourceID="SqlDataSource1"   
        DataEndField="EndTime"   
        DataKeyField="ID"   
        DataStartField="StartTime"   
        DataSubjectField="Subject"   
        Skin="Sunset" 
        onClientAppointmentInserting="AppointmentInserting" 
        onClientAppointmentEditing="AppointmentEditing" 
        CustomAttributeNames="Notes,ProjectID,OutOfOffice,Leave,Flexitime" 
        EnableCustomAttributeEditing="true" MonthVisibleAppointmentsPerDay="6">  
            <TimelineView HeaderDateFormat="ddd dd/MM/yy" NumberOfSlots="7" /> 
            <AppointmentTemplate> 
                <div style="text-align: center;"><%# Eval("Subject") %></div>  
                <hr style="width: 90%;" /> 
                <%#Eval("Notes")%> 
                  
            </AppointmentTemplate> 
            <MonthView VisibleAppointmentsPerDay="6" /> 
        </telerik:RadScheduler>      
 

David Penny
0
David Penny
Top achievements
Rank 2
answered on 25 Jul 2008, 02:50 PM
Hi Simon,

You might like to know that I have just upgraded to the Q2 2008 release of the toolkit and now the time is correct.  I have changed absolutely nothing, so I guess it was an issue in the Q1 2008 release.

David Penny
Tags
Scheduler
Asked by
David Penny
Top achievements
Rank 2
Answers by
Simon
Telerik team
David Penny
Top achievements
Rank 2
Share this question
or