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

RadScheduler Export Times

12 Answers 247 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 17 Dec 2008, 09:03 PM

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.

12 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 20 Dec 2008, 03:19 PM
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.
0
Brian Mains
Top achievements
Rank 1
answered on 29 Dec 2008, 02:28 PM
Hello,

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

Thanks.
0
Peter
Telerik team
answered on 29 Dec 2008, 03:31 PM

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.
0
Brian Mains
Top achievements
Rank 1
answered on 16 Jan 2009, 07:30 PM
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...

 

0
Brian Mains
Top achievements
Rank 1
answered on 16 Jan 2009, 07:46 PM
I should also note that the user's are working in eastern time, but the server is in central time.  Is that an issue?
0
Peter
Telerik team
answered on 20 Jan 2009, 03:50 PM


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.
0
Brian Mains
Top achievements
Rank 1
answered on 20 Jan 2009, 04:06 PM
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.
0
Nick
Top achievements
Rank 1
answered on 11 Aug 2009, 02:18 AM
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?
0
Peter
Telerik team
answered on 11 Aug 2009, 10:49 AM
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.
0
Eric
Top achievements
Rank 1
answered on 04 Mar 2010, 01:18 AM
Has anyone come up with a regular expression to match this situation?
0
a b
Top achievements
Rank 1
answered on 20 Apr 2010, 03:21 AM
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}"); 


0
Bicky
Top achievements
Rank 1
answered on 07 May 2015, 03:54 PM
@Peter, great solution.
Tags
Scheduler
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Peter
Telerik team
Brian Mains
Top achievements
Rank 1
Nick
Top achievements
Rank 1
Eric
Top achievements
Rank 1
a b
Top achievements
Rank 1
Bicky
Top achievements
Rank 1
Share this question
or