Event Calendar does not like en-NZ

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.
4/5/2011 3:54:42 PM
Gravatar
Total Posts 9

Event Calendar does not like en-NZ

Hi all,

When adding a new event to the event calendar on the demo site I get:

We're sorry but a server error has occurred while trying to process your request.

The error has been logged and will be reviewed by our staff as soon as possible. It is possible that the error was just a momentary hiccup and you may wish to use the back button and try again or go back to the home page.

How to Reproduce:

  1. Set your browser language to en-NZ
  2. Go to demo site
  3. login as admin
  4. Access the event calendar, select any day and then select "Add Event"
  5. In the "Event Date" field select the 14th of April. After the selection, according to the en-NZ culture you should see 14/04/2011 but the text field will contain 04/14/2011.
  6. Click Update and you will see the server error above.

If I set my browser language to en-US it works fine. 

Possible Fix

I fixed this in my custom feature by using this:

DateTime startDate = DateTime.Parse(startDateLabel.Text, MyUtils.ResolveCulture(HttpContext.Current));

public class  MyUtils
{
        // Based on http://madskristensen.net/post/Get-language-and-country-from-a-browser-in-ASPNET.aspx
        private static CultureInfo defaultCulture = CultureInfo.CreateSpecificCulture("en-US");
        public static CultureInfo ResolveCulture(HttpContext currentHttpContext)
        {
            string[] languages = currentHttpContext.Request.UserLanguages;
            if (languages == null || languages.Length == 0)
                return defaultCulture;
            try
            {
                string language = languages[0].ToLowerInvariant().Trim();
                return CultureInfo.CreateSpecificCulture(language);
            }
            catch (ArgumentException)
            {
                return defaultCulture;
            }
        }
}

Also, to get the AJAX Control toolkit calendar to localise properly, in my skin's layout.Master page, the script manger required EnableScriptGlobalization="true" EnableScriptLocalization="true". Like this:

<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true"/>

Extra info:

I have a German language Vista and IE8.

Demo Site System Information
mojoPortal Version 2.3.6.4 MSSQL
Operating System Microsoft Windows NT 6.0.6002 Service Pack 2
ASP.NET Info v4.0.30319 Running in Full Trust
Server Time Zone Eastern Daylight Time 

Regards,

Jonas

4/6/2011 7:57:03 AM
Gravatar
Total Posts 18439

Re: Event Calendar does not like en-NZ

Hi,

The problem is really the jQueryUI datepicker. It seems they added support for en-ZA in version 1.8.9 of jQueryUI. However it also requires a code change in mojoPortal because we have checks for supported languages in the date picker control that need to be updated to include the newly suported languages.

The other problem is that our time picker integration with the datepicker (ie used in the blog) is broken if you use jqueryUI higher than version 1.8.6. So I will have to try and solve that before I can change it to use a newer version.

I was able to reproduce the problem on my local machine and was able to get it working correctly in the Event Calendar using jQueryUI 1.8.9 but, again for now it breaks other things (like the datetime picker in the blog) so I cannot change to use jqueryui 1.8.9 until I resolve the other problems.

That looks like a good change on the script manager, but I would have thought it would be localized by default, other languages seem to work ok with the toolkit datepicker.

Best,

Joe

4/6/2011 4:20:36 PM
Gravatar
Total Posts 9

Re: Event Calendar does not like en-NZ

Hi Joe,

I noticed that in a few places, such as the Event Calender we use DateTime.Parse(), like this:

calEvent.EndTime = DateTime.Parse(this.ddEndTime.SelectedValue);

With en-NZ culture set in my browser the line above was throwing FormatException (with the script manager settings mentioned above it appeared  correctly in the UI). Paraphrasing msdn, with DateTime.Parse(s) the string s is parsed using formatting information in the current DateTimeFormatInfo object, which is supplied implicitly by the current thread culture.

So by using my browsers UI culture, instead of the current thread culture, as illustrated below, I could avoid the FormatException.

DateTime startDate = DateTime.Parse(startDateLabel.Text, MyUtils.ResolveCulture(HttpContext.Current));

Isn't the DateTime parsing problem independent of JqueryUI and toolkit datepicker?

Jonas

4/6/2011 4:28:00 PM
Gravatar
Total Posts 18439

Re: Event Calendar does not like en-NZ

Hi Jonas,

Isn't the DateTime parsing problem independent of JqueryUI and toolkit datepicker?

No because the date picker is what was formatting it incorrectly. If you notice when editing an existing event when the page loads it renders in the correct format for en-NZ (assuming that is the browser preference and a specific culture is not being forced by config settings), the thread in this case is already executing with the culture en-NZ, so it populates the text box correctly, but as soon as you change the date with the date picker the format is wrong because until the most recent version of jQueryUI it did not have correct formatting support for en-NZ. Even on creating a new event it only happens after you change the date with the datepicker and it happens because of incorrect handling in the jqueryui datepicker widget, when the page loads it has the current date correctly formatted.

Best,

Joe

4/8/2011 11:57:24 AM
Gravatar
Total Posts 18439

Re: Event Calendar does not like en-NZ

fyi, I found another time picker extension for jqueryui datepicker that does work with the latest jQueryUI, so I was able to update the config settings to use jQuery 1.5.2 and jQueryUI 1.8.11.

These changes are in the source code repository now and should resolve the problem where the datepicker was not formatting correctly for en-NZ

Best,

Joe

4/8/2011 6:31:30 PM
Gravatar
Total Posts 9

Re: Event Calendar does not like en-NZ

Excellent, Thanks. 

4/13/2011 12:16:54 AM
Gravatar
Total Posts 5

Re: Event Calendar does not like en-NZ

Hi Joe, just found this thread after I posted on another old thread. I am having the same issue with en-NZ date format with datepicker. Can you please explain more on how can I get this fixed? Will the new 2-3-6-4 version have it fixed? I am currently running 2-3-6-2. Thanks.

4/13/2011 6:00:18 AM
Gravatar
Total Posts 18439

Re: Event Calendar does not like en-NZ

currently this problem is only solved in the latest code in the source code repository. I'm planning to make a new minor upgrade release within the next few days to include this fix.

Best,

Joe

4/13/2011 6:58:10 PM
Gravatar
Total Posts 5

Re: Event Calendar does not like en-NZ

Hi Joe,

Thanks a lot. Looking forward to the new release.

Best regards,

Kevin

4/15/2011 1:20:19 PM
Gravatar
Total Posts 18439

Re: Event Calendar does not like en-NZ

Just released mojoPortal 2.3.6.5 with this fix.

Best,

Joe

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