Results 1 to 4 of 4

Thread: Microsoft Date in from REST, but no Microsoft Date out to REST

  1. #1
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Default Microsoft Date in from REST, but no Microsoft Date out to REST

    This is causing major heartache for me.

    So I use the
    Code:
    dateFormat: 'MS'
    But this only reads the date in from ASP.NET WCF, but it kills my service and sends a bad request 400. We had tested this with jQuery and this is the same. I need to send the date back in the M$ Date Format.

    How does the proxy or form or store or model get overridden so that the date format is in the M$ format?
    The format that gets sent to the server is:
    HTML Code:
    2011-05-24T00:00:00

  2. #2
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,153

    Default

    That's the default JSON format of an encoded date. You'll have to override some internal methods of Ext to have it another way.

    Look for "Ext.JSON = new(function() {"

    You'll need to patch these I think:
    Code:
     this.encodeDate = function(o) {
            return '"' + o.getFullYear() + "-"
            + pad(o.getMonth() + 1) + "-"
            + pad(o.getDate()) + "T"
            + pad(o.getHours()) + ":"
            + pad(o.getMinutes()) + ":"
            + pad(o.getSeconds()) + '"';
        };
    
    isNative = function() {
            var useNative = null;
    
            return function() {
                if (useNative === null) {
                    useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
                }
    
                return useNative;
            };
        }(),

  3. #3
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Thumbs up

    Thanks mankz. That helped a lot. You pointed me in the right direction to just override the function as you stated.

    Code:
    Ext.JSON.encodeDate = function (d) {
    return '"' + Ext.Date.format(d, 'MS') + '"';
    };
    Last edited by CrazyEnigma; 23 Nov 2011 at 9:53 AM. Reason: Proper Syntax

  4. #4
    Sencha Premium Member Nxs's Avatar
    Join Date
    Mar 2012
    Posts
    43

    Default

    Quote Originally Posted by CrazyEnigma View Post
    Thanks mankz. That helped a lot. You pointed me in the right direction to just override the function as you stated.

    Code:
    Ext.JSON.encodeDate = function (d) {
    return '"' + Ext.Date.format(d, 'MS') + '"';
    };
    You saved my day !!!

    Thanks a lot !

Posting Permissions

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