Getting correct time clicked on using get_StartTime()

4 posts, 0 answers
  1. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 23 Jul 2008 Link to this post

    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

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 24 Jul 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 25 Jul 2008 Link to this post

    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
  5. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 25 Jul 2008 Link to this post

    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
Back to Top