Results 1 to 7 of 7

Thread: [CLOSED-205] Dates coming as NaN on Safari only

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158
    Vote Rating
    0
      0  

    Default [CLOSED-205] Dates coming as NaN on Safari only

    I have some dates that I'm posting that are being transformed from their raw JSON response to a pretty date. This works fine for Chrome but in Safari they come across as "NaN-NaN-NaN".

    Here's the code for the date transform and I have them specified as type "date" in the model (also tried string):

    Code:
        <textarea class="x-hidden-display" id="dieinfo-dates">
             <p>ES (Latest): {latestESDate:date("Y-m-d")}</p>
        </textarea>
    In JSON, dates come across like this:
    "latestESDate":"2029-01-31 00:00:00.0"

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    19
      0  

    Default

    What about the supported devices?

  3. #3
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158
    Vote Rating
    0
      0  

    Default

    Yes, by Safari, I mean Safari that runs both on the desktop as well as iOS4.

  4. #4
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    19
      0  

    Default

    Perfect, that what I wanted to know.

  5. #5
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,001
    Vote Rating
    936
      0  

    Default

    I wouldn't say it's a bug in Touch. Since you didn't specify a date format, it runs the value through the native browser Date.parse. It seems Chrome treats that as a valid date by default, but Safari doesn't.

    However, you can easily work around it by specifying the format:

    Code:
    Ext.setup({
        onReady: function(){
            console.log(Date.parse('2029-01-31 00:00:00.0'));
            
            Ext.regModel('Test', {
                fields: [{
                    name: 'dob',
                    type: 'date',
                    dateFormat: 'Y-m-d H:i:s.u'
                }]
            })
            
            var store = new Ext.data.Store({
                autoLoad: true,
                model: 'Test',
                proxy: {
                    type: 'ajax',
                    url: 'test.json',
                    reader: {
                        type: 'json',
                        root: 'data'
                    }
                },
                listeners: {
                    read: function(){
                        console.log(store.getAt(0).get('dob'));
                    }
                }
            });
        }
    });
    Where the underlying data is:

    Code:
    {
        "data": [{
            "dob": "2029-01-31 00:00:00.0"
        }]
    }
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158
    Vote Rating
    0
      0  

    Default

    No, that doesn't quite work either. As I pointed out in this post, the dates still come access as NaN even with adding the date format in the model.

  7. #7
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,001
    Vote Rating
    936
      0  

    Default

    The above, on Safari 5 and my iPad shows the appropriate date in the read callback.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Similar Threads

  1. Dates coming as NaN on Safari only
    By locutusUT in forum Sencha Touch 1.x: Discussion
    Replies: 9
    Last Post: 28 Jan 2013, 4:49 PM
  2. daterender in xgcolumnmodel problem NaN/NaN/NaN
    By DominateQ in forum Ext 2.x: Help & Discussion
    Replies: 19
    Last Post: 22 Apr 2010, 9:25 AM
  3. [SOLVED] Grid + DateTime Column + add new record = NaN-NaN-NaN
    By alaska in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 29 May 2008, 1:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •