[FIXED] [#521] [2.5.3] Datefield MMM format Issue

  1. #1

    [FIXED] [#521] [2.5.3] Datefield MMM format Issue

    Hi there,

    When we apply the Chinese Traditional Language to the Ext.Net's Datefield with datefield format set to "yyyy-MMM-dd", it failed to return the correct value by calling App.CtrlID.getValue().

    In addition, we found that the issue seems to be caused by missing some code in Ext, which shown as following

    /*
    This file is part of Ext JS 4.2
    
    Copyright (c) 2011-2013 Sencha Inc
    
    Contact:  http://www.sencha.com/contact
    
    Commercial Usage
    Licensees holding valid commercial licenses may use this file in accordance with the Commercial
    Software License Agreement provided with the Software or, alternatively, in accordance with the
    terms contained in a written agreement between you and Sencha.
    
    If you are unsure which license is appropriate for your use, please contact the sales department
    at http://www.sencha.com/contact.
    
    Build date: 2013-05-16 14:36:50 (f9be68accb407158ba2b1be2c226a6ce1f649314)
    */
    /**
     * Traditional Chinese translation
     * By hata1234
     * 09 April 2007
     */
    Ext.onReady(function() {
        var parseCodes;
    
        if (Ext.Date) {
            Ext.Date.monthNames = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"];
    
            Ext.Date.dayNames = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
    
            Ext.Date.formatCodes.a = "(this.getHours() < 12 ? '上午' : '下午')";
            Ext.Date.formatCodes.A = "(this.getHours() < 12 ? '上午' : '下午')";
    
            parseCodes = {
                g: 1,
                c: "if (/(上午)/i.test(results[{0}])) {\n"
                    + "if (!h || h == 12) { h = 0; }\n"
                    + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
                s: "(上午|下午)",
                calcAtEnd: true
            };
    
            Ext.Date.parseCodes.a = Ext.Date.parseCodes.A = parseCodes;
        }
    
        if (Ext.util && Ext.util.Format) {
            Ext.apply(Ext.util.Format, {
                thousandSeparator: ',',
                decimalSeparator: '.',
                currencySign: '\u00a5',
                // Chinese Yuan
                dateFormat: 'Y/m/d'
            });
        }
    });
    Which should be
    /*
    This file is part of Ext JS 4.2
    
    Copyright (c) 2011-2013 Sencha Inc
    
    Contact:  http://www.sencha.com/contact
    
    Commercial Usage
    Licensees holding valid commercial licenses may use this file in accordance with the Commercial
    Software License Agreement provided with the Software or, alternatively, in accordance with the
    terms contained in a written agreement between you and Sencha.
    
    If you are unsure which license is appropriate for your use, please contact the sales department
    at http://www.sencha.com/contact.
    
    Build date: 2013-05-16 14:36:50 (f9be68accb407158ba2b1be2c226a6ce1f649314)
    */
    /**
     * Traditional Chinese translation
     * By hata1234
     * 09 April 2007
     */
    Ext.onReady(function() {
        var parseCodes;
    
        if (Ext.Date) {
            Ext.Date.monthNames = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"];
    
            Ext.Date.dayNames = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
    
    
    /* Seems missing this assignment */
    /************************************************/
    Ext.Date.monthNumbers = {
                一月: 0,
                二月: 1,
                三月: 2,
                四月: 3,
                五月: 4,
                六月: 5,
                七月: 6,
                八月: 7,
                九月: 8,
                十月: 9,
                十一月: 10,
                十二月: 11
            };
    /************************************************/
    
    
            Ext.Date.formatCodes.a = "(this.getHours() < 12 ? '上午' : '下午')";
            Ext.Date.formatCodes.A = "(this.getHours() < 12 ? '上午' : '下午')";
    
            parseCodes = {
                g: 1,
                c: "if (/(上午)/i.test(results[{0}])) {\n"
                    + "if (!h || h == 12) { h = 0; }\n"
                    + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
                s: "(上午|下午)",
                calcAtEnd: true
            };
    
            Ext.Date.parseCodes.a = Ext.Date.parseCodes.A = parseCodes;
        }
    
        if (Ext.util && Ext.util.Format) {
            Ext.apply(Ext.util.Format, {
                thousandSeparator: ',',
                decimalSeparator: '.',
                currencySign: '\u00a5',
                // Chinese Yuan
                dateFormat: 'Y/m/d'
            });
        }
    });
    For your reference, the problematic file seems to be "locale/ext-lang-zh-TW-js/ext.axd"

    Also, it seems that all language are having this problem except English and German (Probably the update of v2.5.2 #5839 fixed it?).

    Will that be possible to have an update or temporary solution regarding this?

    Thanks.

    Regards,
    Vincent
    Last edited by Daniil; Jul 08, 2014 at 6:07 AM. Reason: [FIXED] [#521] [2.5.3]
  2. #2
    Hello Vincent,

    As for "ext-lang-zh-TW.js" I can add your fix if you don't mind.

    As for the rest locales, yes, it looks the Ext.Date.monthNumbers are not defined for all of them. Though, it is defined for some.

    I should say that all the locales originate from the Community (mostly, from the ExtJS community). The people have contributed that. Unfortunately, there is no way to check/test it thoroughly. Though, we are always happy to add a fix suggested by a forum member.

    In any way, you can add any JavaScript override directly on your page.
  3. #3
    Hi Danill,

    Yes, please add the fix to both "ext-lang-zh-TW.js" and "ext-lang-zh-CN.js", they should have the same translation for month name.

    Thanks.

    Regards,
    Vincent
    Last edited by AIM System Ltd; Jul 08, 2014 at 2:05 AM.
  4. #4
    Thank you.

    Before I add the fix I would like to reproduce the problem first, to ensure then that the fix actually works.

    I am trying to reproduce the issue with this test case, but it appears to be working correctly.

    Could you, please, provide your test case?

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" Locale="zh-TW" />
    
            <ext:DateField ID="DateField1" runat="server" Format="yyyy-MMM-dd" />
            
            <ext:Button runat="server" Text=".getValue()" Handler="App.Label1.setText(App.DateField1.getValue());" />
    
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
  5. #5
    Actually the problem occurs only when changing the "Month" from one to another (e.g. from July to May), please find the test case below. Thanks.

    test.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="prjTest.test" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="zh-TW" />
     
            <ext:DateField ID="DateField1" runat="server" Format="yyyy-MMM-dd" AltFormats="yyyyMMdd" />
             
            <ext:Button ID="Button1" runat="server" Text=".getValue()" Handler="App.Label1.setText(App.DateField1.getValue());" />
     
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
    Test Case 1 (Using DatePicker)
    1. Select the date "2014-07-01" from the DatePicker and press the button, correct value shown
    2. Then select the date "2014-04-01" from the DatePicker
    3. Leave the DateField control then the value in Datefield changed back to "2014-07-01"
    4. Press the button and incorrect value shown (Wed Jul 09 2014 00:00:00 GMT+0800 (China Standard Time))


    Test Case 2 (Typing in DateField)
    1. Type the value "20140701" in Datefield and press the button, correct value shown
    2. Then type the value "20140401" from the Date Picker
    3. Leave the control and the value changed to "2014-四月-01"
    4. Press the button and incorrect value shown (Wed Jul 09 2014 00:00:00 GMT+0800 (China Standard Time))



    My Temporary Fix:
    test.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="prjTest.test" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript" language="javascript">
            Ext.onReady(function () {
                Ext.Date.monthNumbers = {
                    一月: 0,
                    二月: 1,
                    三月: 2,
                    四月: 3,
                    五月: 4,
                    六月: 5,
                    七月: 6,
                    八月: 7,
                    九月: 8,
                    十月: 9,
                    十一月: 10,
                    十二月: 11
                };
            });
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="zh-TW" />
     
            <ext:DateField ID="DateField1" runat="server" Format="yyyy-MMM-dd" AltFormats="yyyyMMdd" />
             
            <ext:Button ID="Button1" runat="server" Text=".getValue()" Handler="App.Label1.setText(App.DateField1.getValue());" />
     
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>


    Regards,
    Vincent
    Last edited by AIM System Ltd; Jul 08, 2014 at 4:44 AM.
  6. #6
    The Issue has been created.
    https://github.com/extnet/Ext.NET/issues/521

    Fixed in SVN, revision #5901. It will go to the v2.5.3 release.

Similar Threads

  1. DateField Format
    By Timothy in forum 1.x Help
    Replies: 4
    Last Post: Jun 07, 2013, 5:42 PM
  2. Replies: 6
    Last Post: Jan 09, 2013, 10:30 AM
  3. DateField format
    By flaviodamaia in forum 1.x Help
    Replies: 0
    Last Post: Jul 01, 2009, 11:30 AM
  4. DateField Format
    By BLOZZY in forum 1.x Help
    Replies: 1
    Last Post: May 18, 2009, 3:41 PM
  5. DateField Format dd/MM/Y
    By Kaido in forum 1.x Help
    Replies: 2
    Last Post: Apr 13, 2009, 12:02 PM

Tags for this Thread

Posting Permissions