Timezone Bug

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
5/11/2010 8:59:12 PM
Gravatar
Total Posts 131

Timezone Bug

I hate reporting bugs because often I'm wrong and it's not really a bug, but I think this one is.

I use the SiteUtils.GetUserTimeOffset which appears to be correct, but also I use SiteUser.TimeOffsetHours as I have to send emails to the user using their time zone. It appears the SiteUser.TimeOffsetHours is using the old timeoffset setting and not the new TimeZoneInfo stuff.

Can you let me know if this is truly a bug or if there is another method I can call to get the SiteUser Offset Hours using the new settings?

Thanks.

 

5/12/2010 2:42:46 PM
Gravatar
Total Posts 18439

Re: Timezone Bug

Hi David,

Those 2 methods are legacy, that is how the old time zone adjustments were made which did not automatically adjust for Daylight savings. I kept the old methods for compatibility with Mono since the new TimeZoneInfo class is not yet fully supported under Mono.

Best way to do it now is to use code like:

TimeZoneInfo timeZone = SiteUtils.GetUserTimeZone();

DateTime localDate = DateTime.Parse(dpBeginDate.Text);
DateTime utcDate = TimeZoneInfo.ConvertTimeToUtc(localDate, timeZone);

DateTime localDate2 = TimeZoneInfo.ConvertTimeFromUtc(utcDate, timeZone);

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.