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

[Solved] RadScheduler TimeZoneOffset

5 Answers 406 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 18 Sep 2008, 12:47 PM
Hi

I want to use the power of the TimeZoneOffset property on the radscheduler.
I have looked at the examples in the online demos and the programming pages and the example given shows a radscheduler with a dropdown populated with GMT +1 +2 etc etc.

Changing the value in the dropdown causes an ajax postback to get the new appointment items adjusted to the localized times.

My need is much simpler nut I can't quite seem to get it to work. I don't want the dropdown for the user. All I need is that if say a user puts in say a telephone conference at 18:00 uk time when a user in New York looks at the scheduler it shows it at 13:00. So all the code would seem to have to do somewhere once it has detected it's a request from a New york user is something like this.

int

hoursOffset = -5;
RadScheduler1.TimeZoneOffset =
TimeSpan.Parse(hoursOffset.ToString());

Is this correct and where do I put such code? I've tried it on a little test project in onload but it doesn't seem to have any effect on the appointment times.

Thanks

Gary

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 19 Sep 2008, 10:21 AM
Hi Gary,

Please, try the following:

protected void Page_Load(object sender, EventArgs e)  
    {  
         
        int hoursOffset = -5;  
        RadSchedulerXML.TimeZoneOffset = new TimeSpan(hoursOffset, 0, 0);  
         
    } 


Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Piotr
Top achievements
Rank 1
answered on 07 Aug 2009, 04:56 PM
I was doing the same code for TimeZoneOffset, but when I set it to [1:00:00] or any time span greater than zero [0:00:00], I get this:
ArgumentOutOfRangeException: The added or subtracted value results in an un-representable DateTime. Parameter name: value]

Any TimeSpan object with value less than 0 is fine, i.e. [-1:00:00] or [-4:00:00] works fine.

My code is as follows:
UserTimeZoneOffset = Convert.ToInt16(Request["UserTimeZoneOffset"].ToString());



timeSpan = new TimeSpan(UserTimeZoneOffset, 0, 0);
this.HRadScheduler.TimeZoneOffset = new TimeSpan(UserTimeZoneOffset, 0, 0);

Any ideas?

0
Peter
Telerik team
answered on 10 Aug 2009, 02:51 PM
Hello Piotr,

With Q1 2009 SP2, we have fixed similar issue - ArgumentOutOfRangeException exception when using negative TimeZoneOffset with web service data binding.
http://www.telerik.com/products/aspnet-ajax/whats-new/release-history/q1-2009-sp2-version-2009-1-527.aspx

Please, check if your case is the same.


Kind regards,
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
Piotr
Top achievements
Rank 1
answered on 11 Aug 2009, 03:26 PM
Hi Peter,
Thanks for the link, I downloaded/installed latest release, but that didn't help, I am still getting the exception.

However, I used Add/Subtract function on the RadScheduler.TimeZoneOffset(), which seems to work.  I still have to test to make sure, but, please let me know if this is a viable solution:

 

 

 

 

 

bool addHours = false;

 

 

if (UserTimeZoneOffset > 0)

 

{

addHours =

false;

 

}

else {

 

addHours =

true;

 

}

 

int UserTimeZoneOffsetAbs = Math.Abs(UserTimeZoneOffset);

 

 

timeSpan =

new TimeSpan(UserTimeZoneOffsetAbs, 0, 0);

 

 

if (addHours)

 

{

 

this.HelixRadScheduler.TimeZoneOffset.Add(timeSpan);

 

}

 

else

 

 

 

 

{

 

this.HelixRadScheduler.TimeZoneOffset.Subtract(timeSpan);

 

}

 

Thank you,
Piotr

0
Peter
Telerik team
answered on 11 Aug 2009, 03:50 PM

It seems fine to me, but let us know if you discover any problems eventually.


Regards,
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.
Tags
Scheduler
Asked by
Gary
Top achievements
Rank 1
Answers by
Peter
Telerik team
Piotr
Top achievements
Rank 1
Share this question
or