Results 1 to 3 of 3

Thread: [4.1.1] data.Writer sends invalid timestamps to server!

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-6826 in 4.1.2.
  1. #1

    Default [4.1.1] data.Writer sends invalid timestamps to server!

    Possibly related to: http://www.sencha.com/forum/showthread.php?215628-JSON-Dates-and-REST-Proxy-Sync

    Synopsis:
    1. Any browser.
    2. Ext 4.1.1 (was working fine on Ext 4.0.x)
    3. A store with a proxy and a writer (tested with 'rest' and 'json' reader/writer, but that's actually irrelevant).
    4. A model with 1 or more fields defined as type: 'date', dateFormat: 'timestamp' (still valid per docs)
    5. When syncing store, writer sends garbled dates to server - i.e. "fooDate":"310007e0031am07p"
    Cause:
    data/writer/Writer.js:116:
    Code:
                for (f = 0; f < fLen; f++) {
                    field = fieldItems[f];
                    if (field.persist) {
                        name = field[nameProperty] || field.name;
                        value = record.get(field.name);
                        if (field.serialize) {
                            data[name] = field.serialize(value, record);
                        } else if (field.type === Ext.data.Types.DATE && field.dateFormat) {
                            data[name] = Ext.Date.format(value, field.dateFormat);
                        } else {
                            data[name] = value;
                        }
                    }
                }
    1. Reader accepts and understands dateFormat of "time" and "timestamp".
    2. Writer takes literal dateFormat and passes it to Ext.Date.format() which serializes to invalid, unreadable dates.
    Workaround for the impatient:

    Code:
    // dateFormat: 'timestamp',  // replace with the one below:
    dateFormat: 'U'
    It's a Date.format equivalent of unix timestamp (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Date)


    ps: guys, could I count on a discount for 1 dev pack if I sent you a patch and a test case ? :-)
    Last edited by Artur Bodera (Joust); 20 Jul 2012 at 12:20 AM. Reason: title

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    I think the docs are just a little misleading. 'timestamp' and 'time' aren't valid values, the formats listed in Ext.Date are valid. The date being sent isn't garbled, it's thinking each letter is a different format. The ones that aren't formatted aren't valid.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3

    Default

    Quote Originally Posted by mitchellsimoens View Post
    I think the docs are just a little misleading. 'timestamp' and 'time' aren't valid values,
    They are valid values, because they had been recognized by Reader since Ext 3. It's just Writer that doesn't support these tokens. We can either make Writer support them the same way Reader does, or drop them altogether (breaking BC) and rely on "U" instead.

Tags for this Thread

Posting Permissions

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