RadScheduler Export Times

13 posts, 1 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 17 Dec 2008 Link to this post

    Hello,

    How do you get appointment times in the current time zone?  I am exporting appointments using the RadScheduler.ExportToICalendar method.  But the times exported in the .ics file are in the wrong time zone.  Is that UTC?  I'm not displaying or converting to UTC times in the scheduler for my appointments.

     

    Thanks.

  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 20 Dec 2008 Link to this post

    Hi Brian,

    Please, see this kb article:
    http://www.telerik.com/support/kb/aspnet-ajax/scheduler/how-to-preserve-the-time-of-the-appointments-when-exporting-to-icalendar.aspx


    Kind regards,
    Peter
    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. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 29 Dec 2008 Link to this post

    Hello,

    That is currently working with one item; I'm looking to export a range of items.  Is the process the same?

    Thanks.
  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 29 Dec 2008 Link to this post


    Yes, the approach is the same. The ExportToICalendar() method has six overloads (you can view them with the intellisense). The second overload accepts a collection of appointments in contrast to just a single appointment.

    Regards,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 16 Jan 2009 Link to this post

    Hey,

    For some reason, this approach, while it helped, is currently exporting events that are off by 1 hr...  I have appointments at:

    9:00 to 11:00
    11:00 to 12:00

    These are exporting as:

    10:00 to 12:00
    12:00 to 1:00

    My code to setup the time zone is:

    DateTime

    aptStart = DateTime.SpecifyKind(outputAppointments[0].Start, DateTimeKind.Local);

     

    aptStartOffset =

    TimeZone.CurrentTimeZone.GetUtcOffset(aptStart) - this.rsScheduling.TimeZoneOffset;

     

    this

    .WriteCalendar(RadScheduler.ExportToICalendar(outputAppointments, aptStartOffset));

    All of this code uses the same approach you use on your demo site; writing the calendar works great, but it's off 1 hr.  It appears that this doesn't happen all the time, which is weird...

     

  7. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 16 Jan 2009 Link to this post

    I should also note that the user's are working in eastern time, but the server is in central time.  Is that an issue?
  8. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 20 Jan 2009 Link to this post



    Do you have a sample demo which you can send via a support ticket? We couldn't replicate the problem locally.


    Best wishes,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 20 Jan 2009 Link to this post

    No I can't, but I did figure out what was going on.  Using the export logic, If you export appointments in your current time zone using the logic you have on your demo site, and then view the appointments there.  Then change your time zone, run the command prompt and do iisreset, and try again.  For us, we did have an issue with the time zone.
  10. Nick
    Nick avatar
    11 posts
    Member since:
    Jan 2009

    Posted 10 Aug 2009 Link to this post

    Brian,
    I'm running into the same issue. I'm using the scheduler in eastern time zone, but the server is in central. I have followed the online demos, however my exports are an hour off as well. What seemed to fix the issue that you were having?
  11. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 11 Aug 2009 Link to this post

    Hello Nick,

    We managed to reproduce the problem in a local test. Here is the code that we used:
     protected void Page_Load(object sender, EventArgs e)  
        {  
            Appointment a = new Appointment();  
            a.Subject = "test";  
            a.Start = new DateTime(2009,06, 22, 9, 0,0);  
            a.End = new DateTime(2009,06, 22, 10, 0,0);  
            Session["Appointment"] = a;  
     
        }  
        private void WriteCalendar(string data)  
        {  
            HttpResponse response = Page.Response;  
            response.Clear();  
            response.Buffer = true;  
            response.ContentType = "text/calendar";  
            response.ContentEncoding = Encoding.UTF8;  
            response.Charset = "utf-8";  
            response.AddHeader("Content-Disposition","attachment;filename=\"RadSchedulerExport.ics\"");  
            response.Write(data);  
            response.End();  
        }  
        protected void Button1_Click(object sender, EventArgs e)  
        {  
            Appointment app = null;  
            if (!Equals(Session["Appointment"], null))  
            {  
                app = (Appointment)Session["Appointment"];  
                TimeSpan currentOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);  
                WriteCalendar(RadScheduler.ExportToICalendar(app, currentOffset));  
            }  
        } 

    The behavior that the appointment's time is not preserved on other time zones is expected. The reason for this is that  ExportToICalendar() is a basic method and it saves the dates in UTC format. This means that the string returned by ExportToICalendar() for the above appointment and a GMT +2 time zone would be as follows:

    BEGIN:VCALENDAR
    VERSION:2.0
    PRODID:-//Telerik Inc.//NONSGML RadScheduler//EN
    METHOD:PUBLISH
    BEGIN:VEVENT
    DTSTART:20090622T060000Z
    DTEND:20090622T070000Z
    UID:20090622T085631Z-
    DTSTAMP:20090622T085631Z
    SUMMARY:test
    END:VEVENT
    END:VCALENDAR

    Notice the "Z" after the start and end time. This indicates that the time is exported in UTC.

    A workaround for your case would be to call ExportToICalendar() without the offset argument:

    RadScheduler.ExportToICalendar(app)

    and then use regular expressions to remove the "Z" for the start and end time:

    BEGIN:VCALENDAR
    VERSION:2.0
    PRODID:-//Telerik Inc.//NONSGML RadScheduler//EN
    METHOD:PUBLISH
    BEGIN:VEVENT
    DTSTART:20090622T090000Z
    DTEND:20090622T100000Z
    UID:20090622T090120Z-
    DTSTAMP:20090622T090120Z
    SUMMARY:test
    END:VEVENT
    END:VCALENDAR

    Now, when you pass this string to the WriteCalendar() method, you will get the desired behavior.

    We realize that using this workaround is inconvenient and it is necessitated by a limitation of RadScheduler, so please accept our apologies. We will definitely consider this case and improve RadScheduler for the future.


    Greetings,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  12. Eric
    Eric avatar
    12 posts
    Member since:
    Apr 2009

    Posted 03 Mar 2010 Link to this post

    Has anyone come up with a regular expression to match this situation?
  13. a b
    a b avatar
    1 posts
    Member since:
    Apr 2010

    Posted 19 Apr 2010 Link to this post

    The following regular expression worked for me:

    string data = RadScheduler.ExportToICalendar(app); 
    Regex re = new Regex(@"(?<timestamp>((DTSTART)|(DTEND))[^Z]{16})Z", RegexOptions.ExplicitCapture); 
    data = re.Replace(data, "${timestamp}"); 


  14. Bicky
    Bicky avatar
    2 posts
    Member since:
    Feb 2015

    Posted 07 May 2015 in reply to Peter Link to this post

    @Peter, great solution.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017