Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumSetting Time zones ?Setting Time zones ?
Previous
 
Next
New Post
4/24/2006 2:00 PM
 

I am not throwing stones at anyone, I am just trying to show what is fairly obvious here. As I mentioned there are a few spots the conversion was not done which I noticed working on the unreleased version over a month ago.

The results are very predictable there. I just changed from - 5 GMT where it showed 12PM, to 0 GMT where it showed 5PM, this is a difference of 5 hours and is what I would expect. I have stated time and time again that it is dependant also on how the timezone for the portal, the webserver and the database server and that any one of these can skew results until you have an understanding of what is going on. I have an install where it is run in a completely different timezone that what i normally use and everything works on that install as expected.  All I am saying is I am done talking about this and it is up to you guys to see how to make it work. The only thing I can offer is that I will review again before another release.

 


Chris Paterra

Get direct answers to your questions in the Community Exchange.
 
New Post
4/25/2006 7:40 AM
 
Hi Guys.
I am using DNN 4 and am having the same problem. (Is it a problem with DNN 4 integration?)
Crispy I completely understand that you are frustrated at people asking this question...but clearly that means there is a problem somewhere.  Yes you can insist on people sorting it out themselves...but not everyone has such ability, and the point of new releases is to fix such problems.

My portal settings are set to local time, as are my forum settings, along with user settings (Ive now disabled this feature to prevent confusion), however my forum continues to show what I am assuming is my hosts local time (yes I'm using an overseas host).

You dont have to reply as you seem frustrated Crispy...but has anyone else had this occur and fixed the problem?  If so, how?

Thanks guys
 
New Post
4/26/2006 2:18 PM
 

I took Crispy's Advice and sorted it out myself, the ConvertTimezone function in the code only adjusts the displaytime by the difference between the users selected time zone and the forums configured timezone, it does not take into account the portals time zone nor the actual servers timezone at all. and as such is completely inaffective. I replaced it with the code below, it works for me, your mileage may vary

Public Shared Function ConvertTimeZone(ByVal value As DateTime, ByVal ForumConfig As Forum.Config) As DateTime
            Dim displayCreatedDate As DateTime = value
            Try
 
                'OK, Solving the post time issues in the DNN Forum.
 
                'First we will get all the relevant times and timezones we will need
                'in order to calculate everything.
                Dim _portalSettings As PortalSettings = PortalController.GetCurrentPortalSettings
 
 
                'Post Time is entered into the database using getdate so if your SQL Server
                'and Web server are in different time zones this might make things a little more
                'difficult.
                Dim Posttime As DateTime = value
 
                'We need to know the servers timezone, we will use this information to convert
                'the post time to a GMT time & date, which will make it much simpler to work with.
                'we will use the current timezone ofsset function from the TimeZone Class to get the
                ' number of minutes the servers timezone is offset from midnight GMT
 
                Dim tz As System.TimeZone = System.TimeZone.CurrentTimeZone
                Dim LocalTimeZone As Double = tz.GetUtcOffset(DateTime.Parse("00:00")).TotalMinutes
 
                'we also want to take into account Daylight savings time, since this will affect the
                'calculation as well. we will calculate daylight savings time based on when the post was made and
                'not based on what the current date and time is. i.e was the post made when  daylight savings time was
                'in affect or not.
                If tz.IsDaylightSavingTime(Posttime) Then
                    LocalTimeZone -= tz.GetDaylightChanges(Posttime.Year).Delta.TotalMinutes
                End If
 
                'we need to invert the timezone, when the timezone is GMT-8 for example we need to add 8 hours
                'to get GMT and if the timezone is GMT+2 for Example we need to deduct 2 hours to get GMT
                Dim InvertedTimeZone As Double = 0 - LocalTimeZone
 
                'Calculate the GMT time that the post was made, all calculations will be based on this
                Dim GMTTime As DateTime = Posttime.AddMinutes(InvertedTimeZone)
 
                'the portal time zone will be a our fallback timezone, this will allow you
                'to use the portals configured timezone if all else fails
                Dim PortalTimeZone As Double = _portalSettings.TimeZoneOffset
 
                'calculate the portal time that the post was made at. this will be used as our
                'fallback value
                Dim PortalTime As DateTime = GMTTime.AddMinutes(PortalTimeZone)
 
                'we need to get the forums configured timezone, if the forum is not configured to
                'allow us to use the users timezone this is what we will use
                Dim ForumTimeZone As Double = ForumConfig.TimeZone
 
                'calculate the forum time that the post was made, using the forums timezone.
                Dim ForumTime As DateTime = GMTTime.AddMinutes(ForumTimeZone)
 
                'is the user logged in? if he is then we can use his timezone settings.
                Dim UserLoggedIn As Boolean = HttpContext.Current.Request.IsAuthenticated
 
                'check if the portal is configured to allow us to use the users time zone.
                Dim UseUserTimeZone As Boolean = ForumConfig.EnableTimeZone
 
                'we will set the display date to the portal timezone here just incase anything goes wrong
                displayCreatedDate = PortalTime
 
                'if the forum allows us to use the users time zone then calculate it and use it
                If UseUserTimeZone = True Then
                    'check if the user is logegd in
                    If UserLoggedIn = True Then
                        'the user timezone will allow us to display the time and date
                        'in the users selected timezone, if the forum is configured
                        'to allow it.
                        Dim objUser As UserInfo = UserController.GetCurrentUserInfo
                        Dim UserTimeZone As Double = objUser.Profile.TimeZone
                        Dim UserTime As DateTime = GMTTime.AddMinutes(UserTimeZone)
                        displayCreatedDate = UserTime
                    Else
                        'if the user is not logged in and the forum is configured to use
                        'the suers time zone we will fall back to the portals time zone
                        displayCreatedDate = PortalTime
                    End If
                Else
                    'if the forum is configured not to use the users time zone we will
                    'use the forums configured tiem zone
                    displayCreatedDate = ForumTime
                End If
 
                Return displayCreatedDate
            Catch
                'a function as arbitary as converting the time to display it in a users timezone should never be allowed to
                'cause a fatal crash, so if any exception occurs in the conversion we will simply return the displayCreatedDate
 
                Return displayCreatedDate
            End Try
        End Function

 


"Life's journey is not to arrive at the end safely in a well preserved body, but rather to slide in sideways totally worn out shouting, "holy sh*t...what a ride!"
Dragon's Den
 
New Post
4/26/2006 11:01 PM
 

The point of the ability to set in the forum module itself is to offset the server/portal time. Therefore, there is no need to have this code change.

 


Chris Paterra

Get direct answers to your questions in the Community Exchange.
 
New Post
4/27/2006 4:48 AM
 

Ok Crispy, since you insist I will point out the problem with the original code

 

Firstly Server & Portal Time is not synonymous so the statement “The point of the ability to set in the forum module itself is to offset the server/portal time” is of no use to anyone that needs to offset the forum time correctly, since times are saved in the servers time zone and this is very often not the same as the portal time zone.

 

displayCreatedDate = DateAdd(DateInterval.Minute, (objUser.Profile.TimeZone - ForumConfig.TimeZone), displayCreatedDate)

 

The fact is that the original ChangeTimeZone function only has one line of code that effects the display time, this code does not take either server or portal time zones into account at all meaning that it is impossible for it to offset the server/portal time as you claim.

 

The first problem with the original code is that the forum time zone configuration is meaningless, you can not adjust the default display times for the forum using it since there is no code to offset the time from the server time.

 

The second problem is that the only way to make this code work is to set the forum time zone to match the server time zone and to then allow user time zones to be used, this will then offset the display time by the difference between the user time zone and the forum time zone, but it only works if the forum time zone matches the server time zone, making the setting obsolete. And the offset all but meaningless.

 

Please Crispy accept that this is a bug that needs t be fixed, or at the very least look at it as a feature enhancement request with the a draft of the code already supplied.

 

The simple fact is that "It works for me, so it should work for you" is just not true in this case, DNN has so many users with so many different configurations that it is impossible to foresee how a planned feature will be used until it is put into circulation, in this case the feature does not work for everyone so it needs to be revisited.

 


"Life's journey is not to arrive at the end safely in a well preserved body, but rather to slide in sideways totally worn out shouting, "holy sh*t...what a ride!"
Dragon's Den
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumSetting Time zones ?Setting Time zones ?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out