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!

    [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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  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.

Thread Participants: 1

Tags for this Thread