[OPEN] [3.3.0] [#1405] Timezone Problem - Chrome

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [OPEN] [3.3.0] [#1405] Timezone Problem - Chrome

    Hi all,

    There is a bug with datetime types in Chrome with ExtJs. I found some similar cases but it didn't solve my issue.

    http://forums.ext.net/showthread.php...-Date-Timezone
    http://forums.ext.net/showthread.php...ing-a-DateTime

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.Data;
            }
    
            foreach (var item in this.Data)
            {
                Response.Write(((object[])item)[0] + "<br><br>");
            }
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { DateTime.Parse("01.01.2014") },
                    new object[] { DateTime.Parse("01.01.2016")  },
                    new object[] { DateTime.Parse("02.01.2016")  },
                    new object[] { DateTime.Parse("06.01.2017") },
                    new object[] { DateTime.Parse("01.01.2017")  },
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title></title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:GridPanel
            ID="GridPanel1"
            runat="server"
            Title="Array Grid"
            Width="700"
            Height="350">
            <Store>
                <ext:Store ID="Store1" runat="server" IDMode="Static">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="Tarih" Type="Date" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column runat="server" ID="grid" Width="400" DataIndex="Tarih">
                        <%-- <Renderer Fn="Ext.util.Format.dateRenderer('d.m.Y h:i:s')" />--%>
                    </ext:Column>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
    </body>
    </html>
    How can I solve this problem?

    Thanks,

    Vzx
    Attached Thumbnails Click image for larger version. 

Name:	ie.png 
Views:	68 
Size:	11.9 KB 
ID:	24802   Click image for larger version. 

Name:	chrome.png 
Views:	98 
Size:	16.1 KB 
ID:	24803  
  2. #2
    Hello @vzx!

    It seems I can't reproduce this issue in my time zone. How exactly are you switching between time zones to trigger the issue?
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hi Fabricio,

    My time zone is (UTC +03:00) Ä°stanbul. Can you test with this timezone?

    Thanks,

    Vzx
  4. #4
    In some dates, it adds one hour.

    Like;
    01.01.2016 01:00
    02.01.2016 00:00

    Thanks,
    Vzx
  5. #5
    Hello @vzx!

    I don't see Jan 1st 2016 with the added hour in the screenshot you provided on your initial post. Maybe you changed your code and it broke that part somehow? Probably using formats C#-side and mm instead of MM for month?

    If I use the code as you provided, with Turkey time zone and regional settings, I read months in place of days, so I changed the code to use ParseExact somewhat like this:

    return new object[]
    {
        new object[] { parseDate("01.01.2014") },
        new object[] { parseDate("01.01.2016") },
        new object[] { parseDate("02.01.2016") },
        new object[] { parseDate("06.01.2017") },
        new object[] { parseDate("01.01.2017") }
    };
    with parseDate() as

    private DateTime parseDate(string date)
    {
        return DateTime.ParseExact(date, "dd.MM.yyyy", CultureInfo.InvariantCulture);
    }
    All I see is that the column value assumes different time zone depending on the year and for Turkey, it does not assume daylight saving times for 2014 and 2017. But that's an information not even present in the converted date, and date and time shows exactly as provided.

    Maybe you want to use ext:DateColumn instead of ext:Column for displaying dates? The received dates are in format like 2017-01-06T00:00:00 (for Jan 6th, 2017, for example), thus they are correct in the store and the conversion is happening when filling the textual column with the data thru the default renderer. You should either use a custom renderer or the DateColumn, in this case.
    Fabrício Murta
    Developer & Support Expert
  6. #6
    Hi,

    I changed code as your suggestions. You can see result attached. Unfortunately still same. I added new screenhot.

    In IE, there is no problem. But it adds one hour for somedays in chrome. I had added two of them. One of them is wrong, other one is ok.

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.Data;
            }
    
            foreach (var item in this.Data)
            {
                Response.Write(((object[])item)[0] + "<br><br>");
            }
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { DateTime.ParseExact("01.01.2014","dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture) },
                    new object[] { DateTime.ParseExact("01.01.2016","dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture)  },
                    new object[] { DateTime.ParseExact("02.01.2016","dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture)  },
                    new object[] { DateTime.ParseExact("06.01.2017","dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture) },
                    new object[] { DateTime.ParseExact("01.01.2017","dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture)  },
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title></title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:GridPanel
            ID="GridPanel1"
            runat="server"
            Title="Array Grid"
            Width="700"
            Height="350">
            <Store>
                <ext:Store ID="Store1" runat="server" IDMode="Static">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="Tarih" Type="Date" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:DateColumn runat="server" ID="grid" Width="400" DataIndex="Tarih">
                        <Renderer Fn="Ext.util.Format.dateRenderer('d.m.Y h:i:s')" />
                    </ext:DateColumn>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
    </body>
    </html>
    Thanks,
    Vzx
    Attached Thumbnails Click image for larger version. 

Name:	chrome2.png 
Views:	58 
Size:	4.5 KB 
ID:	24806  

Similar Threads

  1. Replies: 10
    Last Post: Oct 29, 2015, 8:15 AM
  2. Replies: 8
    Last Post: Jun 23, 2015, 3:29 PM
  3. Replies: 7
    Last Post: May 30, 2015, 5:16 PM
  4. date always foramt with GMT timezone in chrome
    By gpx1981 in forum 2.x Help
    Replies: 3
    Last Post: Mar 19, 2015, 1:07 AM

Tags for this Thread

Posting Permissions