User profile - Time Zone

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
6/17/2010 12:14:13 PM
Gravatar
Total Posts 72

User profile - Time Zone

Hi,

I've added my own profile configuration and set the TimeZone property like so:

        <add    name="TimeOffsetHours"
                type="System.Double"
                allowMarkup="false"
                labelResourceKey="TimeOffsetLabel"
                lazyLoad="false"
                requiredForRegistration="true"
                allowAnonymous="true"
                visibleToAnonymous="false"
                visibleToAuthenticated="true"
                visibleToUser="true"
                editableByUser="true"
                regexValidationExpression=""
        regexValidationErrorResourceKey=""
                onlyAvailableForRoles=""
                onlyVisibleForRoles=""
                defaultValue="0.00"
                includeHelpLink="true"
                >

However, when registering a new user, and going to profile, the time zone still defaults to GMT-5 (Eastern time...)

Do I need to do anything else to make this the default.

I've also added the following to user.config but understand that these are for different purposes:

 

  <add key="PreferredGreenwichMeantimeOffset" value="0.00"/>
  <add key="DefaultCountry" value="UK"/>

Thanks,

Ben

6/17/2010 1:05:52 PM
Gravatar
Total Posts 18439

Re: User profile - Time Zone

Hi Ben,

TimeZoneOffsetHours is a legacy field no longer used and PreferredGreenwichMeantimeOffset config setting is also legacy and no longer used (except under Mono).

We have a newer and better timezone system now. You can specify the default time zone from site settings and users already have a timezone setting on the profile page.

Under the new model we are actually storing a timezoneid and using the new .NET class TimeZoneInfo. This allows us to automatically adjust the offset even during daylight savings time. For example Eastern US Time Zone has an offset of -5, but during Daylight Savings (ie right now) the offset is actually -4 hours. The new system handles this automatically whereas the old system had only a fixed offset and we would have to adjust it manually during Daylight Savings.

So there is logic specifically suppressing any custom profile field with the name TimeZoneOffsetHours because that is a special name that maps specifically to our legacy field on mp_Users.

You can force a user to choose a TimeZone during registration like this:

<add name="TimeZoneId"
    type=""
        iSettingControlSrc="~/Controls/TimeZoneIdSetting.ascx"
    labelResourceKey="TimeOffsetLabel"
        defaulltValue="Eastern Standard Time"
    requiredForRegistration="true"
    regexValidationExpression=""
    regexValidationErrorResourceKey=""
    includeHelpLink="false"
      />

Hope it helps,

Joe

6/18/2010 7:24:47 AM
Gravatar
Total Posts 72

Re: User profile - Time ZoneTan

Thanks for that Joe.

In the end I went for:

    <add    name="TimeZoneId"
                type=""
        iSettingControlSrc="~/Controls/TimeZoneIdSetting.ascx"
                labelResourceKey="TimeOffsetLabel"
        defaultValue="GMT Standard Time"
                requiredForRegistration="false"
                regexValidationExpression=""
                regexValidationErrorResourceKey=""
                includeHelpLink="false"/> 

I didn't want to require it in registration, just set the default value. Took a while to find the correct string to use - ended up looking in DateTimeHelper to find the value for GMT.

Also there is a typo in the commented out TimeZoneId profile property - should be defaultValue - but currrently says defaullt value (2 l's)

Thanks again,

Ben

6/18/2010 12:30:18 PM
Gravatar
Total Posts 18439

Re: User profile - Time Zone

I don't understand why you want to add it as a custom property, it is on the profile already and the default value can be set in site settings. I don't really see the benefit of adding it yourself, but if it does what you want I guess its ok.

Best,

Joe

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